ysy 2 anni fa
parent
commit
15a0e4f04c

+ 22 - 0
src/api/material/BOM.js

@@ -75,3 +75,25 @@ export async function getVersionCode (categoryId) {
 
 
 
+// 工序列表  保存
+
+export async function saveBatch (data) {
+  const res = await request.post(`/main/bomtask/saveBatch`, data);
+  if (res.data.code == 0) {
+    return res.data.message;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 工序列表
+
+
+export async function bomTaskList (categoryId) {
+  const res = await request.get(`/main/bomtask/list/${categoryId}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+

+ 47 - 4
src/views/material/product/components/MaterialModal.vue

@@ -179,7 +179,7 @@
 import MaterialAdd from './MaterialAdd.vue';
 import { pageList } from '@/api/technology/version/version.js';
 import { getCategoryBom } from '@/api/material/product';
-import { bomDelete } from '@/api/material/BOM';
+import { bomDelete, saveBatch, bomTaskList } from '@/api/material/BOM';
 import factorySelect from '@/components/CommomSelect/factory-select.vue';
 import Production from '@/views/technology/route/components/production/index.vue'
 
@@ -386,20 +386,60 @@ export default {
 
         /*关闭选择参数*/
         closeAdd() {
-            // this.$refs.ProductionCom.$refs.table.setSelectedRows([]);
+            this.$refs.ProductionCom.$refs.table.setSelectedRows([]);
             this.addDialog = false;
         },
 
         addParamrter() {
-            let arr = this.$refs.ProductionCom.selection;
+            let arr = [] ;
+            arr =  this.$refs.ProductionCom.selection.map(m => {
+                return {
+                    sourceTaskId: m.id,
+                    ...m
+                }
+            })
             this.tabsList = arr
             this.addDialog = false;
 
             if( this.tabsList.length > 0) {
                 this.tabsValue = this.tabsList[0].id
+
+                this.saveBatchFn()
             }
 
-        }
+          
+
+        },
+
+        // 保存
+        saveBatchFn() {
+            let arr = [] ;
+            arr =  this.tabsList.map(m => {
+                return {
+                    taskId: m.id,
+                    sort: m.sort,
+                    categoryId: this.categoryId
+                }
+            })
+
+            saveBatch(arr).then(res => {
+                this.taskListHead()
+            })
+        },
+
+        taskListHead() {
+            bomTaskList(this.categoryId).then(res => {
+                let arr = []
+                arr = res.map(m => {
+                return {
+                    sourceTaskId: m.id,
+                    id: m.taskId,
+                    name: m.taskName
+                }
+            })
+            this.tabsList = arr
+            })
+        },
 
     },
 
@@ -407,6 +447,7 @@ export default {
         async visible(visible) {
             if (visible) {
                 this.getVersionList();
+              
                 if (this.data) {
                     this.categoryId = this.data.id;
                     this.getCategoryBomFn();
@@ -415,6 +456,8 @@ export default {
                     });
                 } else {
                 }
+
+                this.taskListHead()
             } else {
                 this.$refs.form.clearValidate();
                 this.form = { ...this.defaultForm };

+ 21 - 16
src/views/technology/route/components/production/index.vue

@@ -6,7 +6,8 @@
       <!-- 数据表格 -->
 
 
-      <ele-pro-table ref="table" :columns="columns" :datasource="datasource"  @selection-change="selectListChange" row-key="id">
+      <ele-pro-table ref="table" :columns="columns" :datasource="datasource" @selection-change="selectListChange"
+        row-key="id">
         <!-- 状态列 -->
 
         <!-- 操作列 -->
@@ -57,7 +58,7 @@ export default {
           width: 45,
           align: 'center',
           selectable: (row, index) => {
-            return !this.tableData.some((it) => it.sourceTaskId == row.id || it.id == row.id);
+            return !this.tableData.some((it) => it.sourceTaskId == row.id);
           },
 
           reserveSelection: true,
@@ -191,29 +192,33 @@ export default {
 
     // 表格某一行的单击事件
     selectListChange(selection) {
-
-      if(this.isRadio) {
+      if (this.isRadio) {
         if (Array.isArray(selection) && selection.length > 1) {//点击勾选框
-        this.$refs.table.toggleRowSelection(selection[0],false);
-        this.$refs.table.toggleRowSelection(selection[1],true);
-
-      }else if(!Array.isArray(selection)){//点击行
-        this.$refs.table.toggleRowSelection(selection,false);
-        this.$refs.table.toggleRowSelection(selection,true);
+          this.$refs.table.toggleRowSelection(selection[0], false);
+          this.$refs.table.toggleRowSelection(selection[1], true);
 
-      }else{
-        this.rowData = []
-        this.rowData = Array.isArray(selection)?selection[0]:selection;
+        } else if (!Array.isArray(selection)) {//点击行
+          this.$refs.table.toggleRowSelection(selection, false);
+          this.$refs.table.toggleRowSelection(selection, true);
 
+        } else {
+          this.rowData = []
+          this.rowData = Array.isArray(selection) ? selection[0] : selection;
+        }
+      } else {
+        this.selection = selection
       }
-      }
- 
+
 
 
     },
 
     getRowData() {
-      return   this.rowData
+      return this.rowData
+    },
+
+    getSelection() {
+      return this.selection
     }
 
   }