ysy 2 лет назад
Родитель
Сommit
ca69cad1be
1 измененных файлов с 82 добавлено и 50 удалено
  1. 82 50
      src/views/material/product/components/mouldDialog.vue

+ 82 - 50
src/views/material/product/components/mouldDialog.vue

@@ -44,22 +44,35 @@
 
             <header-title title="工序"> </header-title>
 
-            <ele-pro-table ref="table" :needPage="false" :columns="columns" :datasource="form.taskList"
-                row-key="produceTaskId">
+            <ele-pro-table ref="table" class="table" :needPage="false" :columns="columns" :datasource="form.taskList"
+                row-key="id">
                 <!-- 表头工具栏 -->
                 <template v-slot:toolbar>
                     <el-button size="small" type="primary" icon="el-icon-plus" class="ele-btn-icon"
                         @click="openEdit">新增</el-button>
                 </template>
 
-                <template v-slot:modelCategoryLevelCode="{ row, $index }">
-                    <el-input v-model="row.modelCategoryLevelCode" placeholder="请输入模具BOM编码"
-                        @click.native="openMould(row, $index)"></el-input>
+                <template v-slot:modelCategoryLevelCode="scope">
+
+                    <el-form-item  :prop="'taskList.modelCategoryLevelCode'+ scope.$index" >
+   
+                        <el-input  v-model="scope.row.modelCategoryLevelCode" placeholder="请输入模具分类编码"
+                            @click.native="openMould(scope.row, scope.$index)"></el-input>
+
+                    </el-form-item>
+
                 </template>
 
-                <template v-slot:modelCategoryLevelName="{ row, $index }">
-                    <el-input v-model="row.modelCategoryLevelName" placeholder="请输入模具BOM名称"
-                        @click.native="openMould(row, $index)"></el-input>
+                <template v-slot:modelCategoryLevelName="scope">
+                   
+                    <el-form-item :prop="'taskList.modelCategoryLevelName'+ scope.$index" >
+                        <el-input v-model="scope.row.modelCategoryLevelName" placeholder="请输入模具分类名称"
+                            @click.native="openMould(scope.row, scope.$index)"></el-input>
+
+                    </el-form-item>
+                   
+
+
                 </template>
 
                 <!-- 操作列 -->
@@ -116,26 +129,25 @@ export default {
             brandNum: '',
             specification: '',
             measuringUnit: '',
-
-            routeList: []
+            taskList: []
+        
         };
         return {
             defaultForm,
             // 表单数据
             form: {
-                ...defaultForm
+                ...defaultForm,
+              
             },
             // 表单验证规则
             rules: {
-                categoryName: [
-                    { required: true, message: '请输入产品名称', trigger: 'blur' }
-                ]
+              
             },
 
             // 提交状态
             loading: false,
             current: null,
-        
+
 
             columns: [
 
@@ -172,14 +184,14 @@ export default {
 
                 {
                     prop: 'modelCategoryLevelCode',
-                    label: '模具BOM编码',
+                    label: '模具分类编码',
                     align: 'center',
                     slot: 'modelCategoryLevelCode',
                     minWidth: 150
                 },
                 {
                     prop: 'modelCategoryLevelName',
-                    label: '模具BOM名称',
+                    label: '模具分类名称',
                     align: 'center',
                     slot: 'modelCategoryLevelName',
                     minWidth: 150
@@ -210,7 +222,7 @@ export default {
         }
     },
     methods: {
-  
+
 
         /* 更新visible */
         updateVisible(value) {
@@ -218,16 +230,16 @@ export default {
         },
 
         openEdit() {
-            console.log( this.form)
-            this.form.taskList.map((m) => {
-                
+            let _arr = this.$refs.table.getData();
+            _arr.map((m) => {
+
                 m.id = m.produceTaskId;
                 delete m.produceTaskId;
                 return {
                     ...m
                 };
             });
-            this.$refs.processRefs.open(this.form.taskList);
+            this.$refs.processRefs.open(_arr);
         },
 
         chooseProcess(data) {
@@ -239,32 +251,32 @@ export default {
                 };
             });
             this.$refs.table.setData([...data, ...this.$refs.table.getData()]);
-         
+            this.$forceUpdate()
+
         },
 
         handleDel(row, index) {
             let _arr = this.$refs.table.getData();
             _arr.splice(index, 1);
             this.$refs.table.setData(_arr);
-            if (row?.produceTaskId) {
-                this.removeList.push(row.produceTaskId);
+            if (row?.id) {
+                this.removeList.push(row.id);
             }
         },
 
 
-        openMould(row,index) {
-            console.log(index)
+        openMould(row, index) {
             this.$refs.mouldRef.open(row, index)
         },
 
-        saveMould(row,idx) {
+        saveMould(row, idx) {
             let _arr = this.$refs.table.getData()
             this.$set(_arr[idx], 'modelCategoryLevelId', row.id)
             this.$set(_arr[idx], 'modelCategoryLevelCode', row.code)
             this.$set(_arr[idx], 'modelCategoryLevelName', row.name)
             this.$refs.table.setData([..._arr]);
-         
-            
+
+
         },
 
 
@@ -276,26 +288,31 @@ export default {
         },
 
         save() {
-            let _arr = this.$refs.table.getData();
 
-       
-
-
-            let param = {
-                categoryId: this.categoryId,
-                taskList: _arr
-            };
-            categoryTaskPallet(param)
-                .then((msg) => {
-                    this.loading = false;
-                    this.$message.success(msg);
-                    this.updateVisible(false);
-                    this.$emit('done');
-                })
-                .catch((e) => {
-                    this.loading = false;
-                    this.$message.error(e.message);
-                });
+            this.$refs.form.validate(async (value) => {
+                if (value) {
+                    let _arr = this.$refs.table.getData();
+
+                    let param = {
+                        categoryId: this.categoryId,
+                        taskList: _arr,
+                        removeList: this.removeList
+                    };
+                    categoryTaskPallet(param)
+                        .then((msg) => {
+                            this.loading = false;
+                            this.$message.success(msg);
+                            this.updateVisible(false);
+                            this.$emit('done');
+                        })
+                        .catch((e) => {
+                            this.loading = false;
+                            this.$message.error(e.message);
+                        });
+                }
+
+            })
+
         }
     },
 
@@ -312,6 +329,7 @@ export default {
 
                 this.getCategoryTaskDetail();
             } else {
+                this.removeList = []
                 this.$refs.form.clearValidate();
                 this.form = { ...this.defaultForm };
             }
@@ -319,4 +337,18 @@ export default {
     }
 };
 </script>
-  
+  
+
+<style lang="scss" scoped>
+.table {
+    .el-form-item {
+        margin-bottom: 0 !important;
+    }
+
+ 
+}
+.table    ::v-deep .el-form-item__content{
+  margin-left: 0px !important;
+}
+
+</style>