Kaynağa Gözat

fix:4525【发运管理】调拨发货单需要支持多选

mlchen 5 gün önce
ebeveyn
işleme
a1d0848357

+ 38 - 8
src/views/transportManager/shipManage/dispatchManage/components/inventoryAllocationDialog.vue

@@ -10,10 +10,11 @@
   >
     <el-card shadow="never">
       <searchTable @search="reload"></searchTable>
-      <ele-pro-table ref="table" :columns="columns" :datasource="datasource" row-key="id"
-                     height="calc(100vh - 500px)" class="dict-table" @cell-click="cellClick">
+      <ele-pro-table ref="table" :columns="tableColumns" :datasource="datasource" row-key="id"
+                     height="calc(100vh - 500px)" class="dict-table" @cell-click="cellClick"
+                     :selection.sync="selection">
         <!-- 表头工具栏 -->
-        <template v-slot:action="{ row }">
+        <template v-slot:action="{ row }" v-if="!multiple">
           <el-radio class="radio" v-model="radio" :label="row.id"><i></i></el-radio>
         </template>
       </ele-pro-table>
@@ -38,7 +39,13 @@ export default {
   components: {
     searchTable
   },
-  props: ['inventoryAllocationDialogFlag'],
+  props: {
+    inventoryAllocationDialogFlag: Boolean,
+    multiple: {
+      type: Boolean,
+      default: false
+    }
+  },
   data() {
     return {
       currentIndex: null,
@@ -156,6 +163,23 @@ export default {
           },
         ],
       radio: null,
+      current: null,
+      selection: []
+    }
+  },
+  computed: {
+    tableColumns() {
+      if (!this.multiple) return this.columns;
+      return [
+        this.columns[0],
+        {
+          width: 45,
+          type: 'selection',
+          columnKey: 'selection',
+          align: 'center'
+        },
+        ...this.columns.slice(2)
+      ];
     }
   },
 
@@ -178,18 +202,24 @@ export default {
 
     // 单击获取id
     cellClick(row) {
-      this.current = row
-      this.radio = row.id
+      if (!this.multiple) {
+        this.current = row
+        this.radio = row.id
+      }
     },
     handleClose() {
       this.$emit('update:inventoryAllocationDialogFlag', false)
+      this.current = null;
+      this.radio = null;
+      this.selection = [];
     },
 
     selected() {
-      if (!this.current) {
+      const selectedRows = this.multiple ? this.selection : this.current ? [this.current] : [];
+      if (selectedRows.length === 0) {
         return this.$message.warning('请至少选择一条数据')
       }
-      this.$emit('changeParent', this.current, this.currentIndex)
+      this.$emit('changeParent', this.multiple ? selectedRows : selectedRows[0], this.currentIndex)
       this.handleClose()
     },
 

+ 9 - 5
src/views/transportManager/shipManage/dispatchManage/components/taskInfoTable.vue

@@ -250,6 +250,7 @@
     <inventory-allocation-dialog
       ref="inventoryAllocationDialogRef"
       :inventoryAllocationDialogFlag.sync="inventoryAllocationDialogFlag"
+      :multiple="true"
       v-if="inventoryAllocationDialogFlag"
       @changeParent="getTransferSendInfo"
     ></inventory-allocation-dialog>
@@ -610,11 +611,14 @@
       },
       //调拨发货单回调
       getTransferSendInfo(params) {
-        let row = {
-          id: params.id,
-          code: params.allotCode
-        };
-        this.setSelectData(row);
+        const rows = Array.isArray(params) ? params : [params];
+        const currentRow = this.form.datasource[this.editIndex];
+        const taskRows = rows.map((item) => ({
+          ...currentRow,
+          taskId: item.id,
+          taskCode: item.allotCode
+        }));
+        this.form.datasource.splice(this.editIndex, 1, ...taskRows);
       },
 
       //选择司机