Просмотр исходного кода

fix(库存调拨): 修复选择数据回显和删除逻辑问题

liujt 7 месяцев назад
Родитель
Сommit
de9c6217f6
1 измененных файлов с 22 добавлено и 9 удалено
  1. 22 9
      src/views/warehouseManagement/inventoryAllocation/add.vue

+ 22 - 9
src/views/warehouseManagement/inventoryAllocation/add.vue

@@ -244,6 +244,7 @@
             :selection.sync="selection"
             row-key="id"
             :initLoad="false"
+            @done="onDone"
           >
           </ele-pro-table>
         </div>
@@ -813,10 +814,7 @@
       }
     },
     async created() {
-      const code = await getCode('transfer_no');
-      const name = await getCode('inventory_allocation_name');
-      this.params.name = name;
-      this.params.code = code;
+      
       // this.getTreeData();
       await this.getFactoryList();
       if (this.$route.query.isEdit) {
@@ -824,6 +822,10 @@
         this.isEdit = true;
         this.getEditInfo();
       } else {
+        const code = await getCode('transfer_no');
+        const name = await getCode('inventory_allocation_name');
+        this.params.name = name;
+        this.params.code = code;
         if(this.factoryList.find(item => item.id == this.userInfo.factoryId)?.id) {
           this.factoryId = this.userInfo.factoryId;
           this.params.targetFactoriesId = this.factoryId
@@ -837,6 +839,7 @@
     watch: {
       productList() {
         this.doLayout();
+        this.$refs.table.setSelectedRowKeys(this.selectionIds);
       }
     },
     methods: {
@@ -863,6 +866,14 @@
         });
         return data;
       },
+      onDone(res) {
+          console.log('res:', res);
+          this.$nextTick(() => {
+              // 回显选中的数据的复选框
+              console.log('data------data', this.selectionIds);
+              this.$refs.table.setSelectedRowKeys(this.selectionIds);
+          });
+      },
       /* 刷新表格 */
       reload(where) {
         this.$refs.table.reload({ page: 1, where });
@@ -938,9 +949,10 @@
         //   return this.selectionIds.includes(item.id);
         // });
         this.selection = dataList;
-        this.selection.forEach((item) => {
-          this.$refs.table.toggleRowSelection(item);
-        });
+        // this.selection.forEach((item) => {
+        //   this.$refs.table.toggleRowSelection(item);
+        // });
+        this.$refs.table.setSelectedRowKeys(this.selectionIds);
         console.log('this.selection------', this.selection);
         this.tableData = this.selection.map((item, index) => {
           // let filterObj = dataList.filter(
@@ -1401,7 +1413,7 @@
       deleted(row, index) {
         console.log('deleted~~~', row.id, index);
         this.tableData.splice(index, 1);
-        this.selectionIds = this.selectionIds.filter((item) => item != row.id);
+        this.selectionIds = this.selectionIds.filter((item) => item != row.outInDetailRecordId);
         this.selection = this.selection.filter((item) => item.id != row.id);
         this.$refs.table.setSelectedRowKeys(this.selectionIds);
         this.$forceUpdate()
@@ -1443,7 +1455,7 @@
                   goodsAllocationName: item.goodsAllocationName,
                   goodsShelfId: item.goodsShelfId,
                   goodsShelfName: item.goodsShelfName,
-                  outInDetailRecordId: item.id,
+                  outInDetailRecordId: item.outInDetailRecordId,
                   targetAreaId: item.targetAreaId,
                   targetAreaName: item.targetAreaName,
                   targetGoodsAllocationId: item.targetGoodsAllocationId,
@@ -1689,6 +1701,7 @@
                 console.log('this.params---------', this.params);
                 return {
                   ...item,
+                  outInDetailRecordId: item.id,
                   quantity: item.quantity || item.measureQuantity,
                   categoryId: item.categoryId,
                   warehouseId: this.params.outWarehouseId,