ysy 2 лет назад
Родитель
Сommit
f102a7eedc

+ 5 - 3
src/components/material/index.vue

@@ -82,7 +82,8 @@ export default {
             selection: [],
 
             tableData: [],
-            current: null
+            current: null,
+            idx: null // 索引 
         }
     },
 
@@ -108,7 +109,7 @@ export default {
         reload() {
             this.$refs.table.reload();
         },
-        open(list, title, id) {
+        open(list, title, id, idx) {
             if (list) {
                 this.tableData = list
             }
@@ -118,6 +119,7 @@ export default {
             if (id) {
                 this.categoryLevelId = id
             }
+            this.idx = idx
             this.visible = true
         },
 
@@ -133,7 +135,7 @@ export default {
                 this.$message.error('请至少选择一条数据');
                 return;
             }
-            this.$emit('chooseModal', this.selection, this.id)
+            this.$emit('chooseModal', this.selection, this.id, this.idx)
             this.handleClose()
         },
     }

+ 11 - 18
src/views/material/product/components/MaterialModal.vue

@@ -52,10 +52,6 @@
 
 
 
-
-
-
-
             </el-row>
 
 
@@ -127,7 +123,7 @@
                 <el-row>
 
                     <div class="ele-body">
-                        <ele-pro-table ref="table" :datasource="bomItem.materialList" :columns="columns">
+                        <ele-pro-table ref="table" :datasource="bomItem.materialList" row-key="id" :columns="columns">
                             <!-- 表头工具栏 -->
                             <template v-slot:toolbar>
                                 <el-button size="small" icon="el-icon-plus" class="ele-btn-icon" type="primary"
@@ -136,7 +132,7 @@
 
                             <!-- 操作列 -->
                             <template v-slot:action="{ row }">
-                                <el-popconfirm class="ele-action" title="确定要删除当前物料吗?" @confirm="remove(row)">
+                                <el-popconfirm class="ele-action" title="确定要删除当前物料吗?" @confirm="remove(index,row)">
                                     <template v-slot:reference>
                                         <el-link type="danger" :underline="false" icon="el-icon-delete">
                                             删除
@@ -308,13 +304,14 @@ export default {
 
 
 
-        openParam() {
-            this.tableData = this.$refs.table.getData()
-            this.$refs.materiaRef.open(this.tableData, '选择物料', '1')
+        openParam(index) {
+            this.tableData = this.form.list[index].materialList
+            this.$refs.materiaRef.open(this.tableData, '选择物料', '1', index)
         },
 
-        chooseModal(data) {
-            this.$refs.table.setData([...data, ...this.$refs.table.getData()]);
+        chooseModal(data, id, idx) {
+            this.$set(this.form.list[idx], 'materialList', data)
+          
         },
 
         chooseBom(index) {
@@ -329,13 +326,9 @@ export default {
         },
 
         /* 删除 */
-        remove(row) {
-            const data = this.$refs.table.getData() ?? [];
-            if (row.id) {
-                this.removeList.push(row.id);
-                this.$refs.table.setData(data.filter((d) => d.id !== row.id));
-            }
-
+        remove(index,row) {
+           console.log(row)
+           this.form.list[index].materialList = this.form.list[index].materialList.filter((d) => d.id !== row.id)
 
         },