index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="公司名称" prop="name">
  5. <el-input
  6. v-model="queryParams.name"
  7. placeholder="请输入快递公司名称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item>
  14. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  15. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  16. </el-form-item>
  17. </el-form>
  18. <el-row :gutter="10" class="mb8">
  19. <el-col :span="1.5">
  20. <el-button
  21. type="primary"
  22. icon="el-icon-plus"
  23. size="mini"
  24. @click="handleAdd"
  25. v-hasPermi="['store:express:add']"
  26. >新增</el-button>
  27. </el-col>
  28. <el-col :span="1.5">
  29. <el-button
  30. type="success"
  31. icon="el-icon-edit"
  32. size="mini"
  33. :disabled="single"
  34. @click="handleUpdate"
  35. v-hasPermi="['store:express:edit']"
  36. >修改</el-button>
  37. </el-col>
  38. <el-col :span="1.5">
  39. <el-button
  40. type="danger"
  41. icon="el-icon-delete"
  42. size="mini"
  43. :disabled="multiple"
  44. @click="handleDelete"
  45. v-hasPermi="['store:express:remove']"
  46. >删除</el-button>
  47. </el-col>
  48. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  49. </el-row>
  50. <el-table height="500" border v-loading="loading" :data="expressList" @selection-change="handleSelectionChange">
  51. <el-table-column type="selection" width="55" align="center" />
  52. <el-table-column label="ID" align="center" prop="id" />
  53. <el-table-column label="快递公司编号" align="center" prop="code" />
  54. <el-table-column label="快递公司" align="center" prop="name" />
  55. <el-table-column label="OMS编号" align="center" prop="omsCode" />
  56. <el-table-column label="排序" align="center" prop="sort" />
  57. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  58. <template slot-scope="scope">
  59. <el-button
  60. size="mini"
  61. type="text"
  62. icon="el-icon-edit"
  63. @click="handleAllot(scope.row)"
  64. v-hasPermi="['store:express:allot']"
  65. >分配公司</el-button>
  66. <el-button
  67. size="mini"
  68. type="text"
  69. icon="el-icon-edit"
  70. @click="handleUpdate(scope.row)"
  71. v-hasPermi="['store:express:edit']"
  72. >修改</el-button>
  73. <el-button
  74. size="mini"
  75. type="text"
  76. icon="el-icon-delete"
  77. @click="handleDelete(scope.row)"
  78. v-hasPermi="['store:express:remove']"
  79. >删除</el-button>
  80. </template>
  81. </el-table-column>
  82. </el-table>
  83. <pagination
  84. v-show="total>0"
  85. :total="total"
  86. :page.sync="queryParams.pageNum"
  87. :limit.sync="queryParams.pageSize"
  88. @pagination="getList"
  89. />
  90. <!-- 添加或修改快递公司对话框 -->
  91. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  92. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  93. <el-form-item label="快递公司简称" prop="code">
  94. <el-input v-model="form.code" placeholder="请输入快递公司简称" />
  95. </el-form-item>
  96. <el-form-item label="快递公司全称" prop="name">
  97. <el-input v-model="form.name" placeholder="请输入快递公司全称" />
  98. </el-form-item>
  99. <el-form-item label="OMS编号" prop="omsCode">
  100. <el-input v-model="form.omsCode" placeholder="请输入快递公司简称" />
  101. </el-form-item>
  102. <el-form-item label="排序" prop="sort">
  103. <el-input-number :min="0" v-model="form.sort" placeholder="请输入排序" />
  104. </el-form-item>
  105. </el-form>
  106. <div slot="footer" class="dialog-footer">
  107. <el-button type="primary" @click="submitForm">确 定</el-button>
  108. <el-button @click="cancel">取 消</el-button>
  109. </div>
  110. </el-dialog>
  111. <el-dialog :title="allot.title" :visible.sync="allot.open" width="1100px" append-to-body>
  112. <el-transfer
  113. filterable
  114. width="960px"
  115. :filter-method="filterMethod"
  116. filter-placeholder="请输入公司名称"
  117. v-model="value"
  118. :titles="['所有公司', '已选公司']"
  119. :right-default-checked="value"
  120. :data="allCompanies">
  121. </el-transfer>
  122. <div slot="footer" class="dialog-footer">
  123. <el-button type="primary" @click="handleAllotCompany">分 配</el-button>
  124. <el-button @click="cancel1">取 消</el-button>
  125. </div>
  126. </el-dialog>
  127. </div>
  128. </template>
  129. <script>
  130. import { listExpress, getExpress, delExpress, addExpress, updateExpress, exportExpress ,allotExpress ,getExpressList,getCompanyByOmsCode} from "@/api/store/express";
  131. import { getCompanyList} from "@/api/company/company";
  132. export default {
  133. name: "Express",
  134. data() {
  135. return {
  136. formId:null,
  137. value: [],
  138. value2:[],
  139. filterMethod(query, item) {
  140. return item.label.indexOf(query) > -1;
  141. },
  142. // 遮罩层
  143. loading: true,
  144. // 选中数组
  145. ids: [],
  146. allCompanies:undefined,
  147. allot:{
  148. title:"分配公司",
  149. open:false,
  150. },
  151. // 非单个禁用
  152. single: true,
  153. // 非多个禁用
  154. multiple: true,
  155. // 显示搜索条件
  156. showSearch: true,
  157. // 总条数
  158. total: 0,
  159. // 快递公司表格数据
  160. expressList: [],
  161. // 弹出层标题
  162. title: "",
  163. // 是否显示弹出层
  164. open: false,
  165. // 查询参数
  166. queryParams: {
  167. pageNum: 1,
  168. pageSize: 10,
  169. code: null,
  170. name: null,
  171. sort: null,
  172. isShow: null,
  173. isDel: null
  174. },
  175. // 表单参数
  176. form: {},
  177. // 表单校验
  178. rules: {
  179. code: [
  180. { required: true, message: "快递公司简称不能为空", trigger: "blur" }
  181. ],
  182. omsCode: [
  183. { required: true, message: "OMS编号不能为空", trigger: "blur" }
  184. ],
  185. name: [
  186. { required: true, message: "快递公司全称不能为空", trigger: "blur" }
  187. ],
  188. sort: [
  189. { required: true, message: "排序不能为空", trigger: "blur" }
  190. ],
  191. isShow: [
  192. { required: true, message: "是否显示不能为空", trigger: "blur" }
  193. ],
  194. }
  195. };
  196. },
  197. created() {
  198. this.getList();
  199. },
  200. methods: {
  201. handleAllotCompany(){
  202. console.log(this.value);
  203. allotExpress(this.value,this.formId).then(response => {
  204. if (response.code === 200) {
  205. this.msgSuccess("修改成功");
  206. this.allot.open = false;
  207. this.getList();
  208. }
  209. });
  210. },
  211. /** 查询快递公司列表 */
  212. getList() {
  213. this.loading = true;
  214. listExpress(this.queryParams).then(response => {
  215. this.expressList = response.rows;
  216. this.total = response.total;
  217. this.loading = false;
  218. });
  219. },
  220. // 取消按钮
  221. cancel() {
  222. this.open = false;
  223. this.reset();
  224. },
  225. cancel1() {
  226. this.allot.open = false;
  227. },
  228. // 表单重置
  229. reset() {
  230. this.form = {
  231. id: null,
  232. code: null,
  233. omsCode: null,
  234. name: null,
  235. sort: null,
  236. isShow: null,
  237. createTime: null,
  238. updateTime: null,
  239. isDel: null
  240. };
  241. this.resetForm("form");
  242. },
  243. /** 搜索按钮操作 */
  244. handleQuery() {
  245. this.queryParams.pageNum = 1;
  246. this.getList();
  247. },
  248. /** 重置按钮操作 */
  249. resetQuery() {
  250. this.resetForm("queryForm");
  251. this.handleQuery();
  252. },
  253. // 多选框选中数据
  254. handleSelectionChange(selection) {
  255. this.ids = selection.map(item => item.id)
  256. this.single = selection.length!==1
  257. this.multiple = !selection.length
  258. },
  259. /** 新增按钮操作 */
  260. handleAdd() {
  261. this.reset();
  262. this.open = true;
  263. this.title = "添加快递公司";
  264. },
  265. /**分配公司按钮 */
  266. handleAllot(row){
  267. this.allot.open = true;
  268. this.formId = row.omsCode;
  269. getCompanyList().then(response => {
  270. let data = [];
  271. response.data.forEach((item,index) => {
  272. data.push({
  273. key: item.companyId,
  274. label:item.companyName,
  275. })
  276. });
  277. this.allCompanies = data;
  278. });
  279. const omsCode = row.omsCode;
  280. getCompanyByOmsCode(omsCode).then(response => {
  281. this.value = response.data2
  282. console.log(this.value);
  283. });
  284. },
  285. /** 修改按钮操作 */
  286. handleUpdate(row) {
  287. this.reset();
  288. const id = row.id || this.ids
  289. getExpress(id).then(response => {
  290. this.form = response.data;
  291. this.open = true;
  292. this.title = "修改快递公司";
  293. });
  294. },
  295. /** 提交按钮 */
  296. submitForm() {
  297. this.$refs["form"].validate(valid => {
  298. if (valid) {
  299. if (this.form.id != null) {
  300. updateExpress(this.form).then(response => {
  301. if (response.code === 200) {
  302. this.msgSuccess("修改成功");
  303. this.open = false;
  304. this.getList();
  305. }
  306. });
  307. } else {
  308. addExpress(this.form).then(response => {
  309. if (response.code === 200) {
  310. this.msgSuccess("新增成功");
  311. this.open = false;
  312. this.getList();
  313. }
  314. });
  315. }
  316. }
  317. });
  318. },
  319. /** 删除按钮操作 */
  320. handleDelete(row) {
  321. const ids = row.id || this.ids;
  322. this.$confirm('是否确认删除快递公司编号为"' + ids + '"的数据项?', "警告", {
  323. confirmButtonText: "确定",
  324. cancelButtonText: "取消",
  325. type: "warning"
  326. }).then(function() {
  327. return delExpress(ids);
  328. }).then(() => {
  329. this.getList();
  330. this.msgSuccess("删除成功");
  331. }).catch(function() {});
  332. },
  333. /** 导出按钮操作 */
  334. handleExport() {
  335. const queryParams = this.queryParams;
  336. this.$confirm('是否确认导出所有快递公司数据项?', "警告", {
  337. confirmButtonText: "确定",
  338. cancelButtonText: "取消",
  339. type: "warning"
  340. }).then(function() {
  341. return exportExpress(queryParams);
  342. }).then(response => {
  343. this.download(response.msg);
  344. }).catch(function() {});
  345. }
  346. },
  347. };
  348. </script>
  349. <style scoped lang="scss">
  350. .container {
  351. display: flex;
  352. justify-content: space-between;
  353. margin-bottom: 20px;
  354. }
  355. .box {
  356. width: 300px;
  357. }
  358. .el-scrollbar {
  359. max-height: 300px;
  360. overflow-y: auto; /* 添加滚动条 */
  361. }
  362. /* 新增样式 */
  363. .container {
  364. display: flex;
  365. justify-content: center;
  366. align-items: flex-start;
  367. }
  368. .box {
  369. margin: 0 10px;
  370. }
  371. /deep/.el-transfer-panel {
  372. width:40%;
  373. }
  374. /deep/.el-transfer-panel__body{
  375. height: 450px;
  376. }
  377. /deep/.el-transfer-panel__list.is-filterable {
  378. height: 88%;
  379. }
  380. </style>