ysy пре 2 година
родитељ
комит
57091ba44b

+ 51 - 29
src/views/technology/route/components/user-edit.vue

@@ -1,6 +1,6 @@
 <!-- 用户编辑弹窗 -->
 <!-- 用户编辑弹窗 -->
 <template>
 <template>
-  <ele-modal width="1060px" :visible="visible" :append-to-body="true" :close-on-click-modal="true"
+  <ele-modal width="1060px" :visible="visible" v-if="visible" :append-to-body="true" :close-on-click-modal="true"
     custom-class="ele-dialog-form" :title="isUpdate ? '修改工艺路线' : '添加工艺路线'" @update:visible="updateVisible">
     custom-class="ele-dialog-form" :title="isUpdate ? '修改工艺路线' : '添加工艺路线'" @update:visible="updateVisible">
     <header-title title="基本信息"> </header-title>
     <header-title title="基本信息"> </header-title>
     <el-form ref="form" :model="form" :rules="rules" label-width="140px">
     <el-form ref="form" :model="form" :rules="rules" label-width="140px">
@@ -27,7 +27,8 @@
 
 
         <el-col :span="8">
         <el-col :span="8">
           <el-form-item label="生产版本:" prop="produceVersionId">
           <el-form-item label="生产版本:" prop="produceVersionId">
-            <el-select v-model="form.produceVersionId" filterable placeholder="请选择" :style="{ width: '100%' }" :disabled="isUpdate">
+            <el-select v-model="form.produceVersionId" filterable placeholder="请选择" :style="{ width: '100%' }"
+              :disabled="isUpdate">
               <el-option v-for="item in versionList" :key="item.code" :label="item.code + '-' + item.name"
               <el-option v-for="item in versionList" :key="item.code" :label="item.code + '-' + item.name"
                 :value="item.id">
                 :value="item.id">
               </el-option>
               </el-option>
@@ -43,22 +44,37 @@
         </el-col>
         </el-col>
         <el-col :span="8">
         <el-col :span="8">
           <el-form-item label="状态:" prop="status">
           <el-form-item label="状态:" prop="status">
-            <el-select v-model="form.status" placeholder="" filterable >
+            <el-select v-model="form.status" placeholder="" filterable>
               <el-option v-for="item in statusList" :key="item.value" :label="item.label" :value="item.value">
               <el-option v-for="item in statusList" :key="item.value" :label="item.label" :value="item.value">
               </el-option>
               </el-option>
             </el-select>
             </el-select>
           </el-form-item>
           </el-form-item>
         </el-col>
         </el-col>
 
 
+        <el-col :span="8" v-if="isUpdate">
+          <el-form-item label="版本是否升级:" prop="versionUpgradeType">
+            <el-select v-model="form.versionUpgradeType" placeholder="请选择">
+              <el-option label="不升级" :value="0" />
+              <el-option label="小版本" :value="1" />
+              <el-option label="大版本" :value="2" />
+            </el-select>
+
+          </el-form-item>
+        </el-col>
+
+
+
 
 
       </el-row>
       </el-row>
 
 
     </el-form>
     </el-form>
 
 
-    <user-taskinstance v-if="step == 2" :isEdit="isUpdate"  :taskInfo="form" @refresh="refresh" />
+    <user-taskinstance :isEdit="isUpdate" ref="taskRef" :taskInfo="form" @taskList="taskList" />
+
+
 
 
     <template v-slot:footer>
     <template v-slot:footer>
-      <el-button type="primary" v-if="step == 1" :loading="loading" @click="save">
+      <el-button type="primary" :loading="loading" @click="save">
         确定
         确定
       </el-button>
       </el-button>
 
 
@@ -99,6 +115,7 @@ export default {
       produceVersionId: '',
       produceVersionId: '',
       version: '1.0',
       version: '1.0',
       id: '',
       id: '',
+      versionUpgradeType: 0
 
 
     };
     };
     return {
     return {
@@ -133,7 +150,7 @@ export default {
           { required: true, message: '请输入工艺路线版本', trigger: 'blur' }
           { required: true, message: '请输入工艺路线版本', trigger: 'blur' }
         ],
         ],
         produceVersionId: [
         produceVersionId: [
-        { required: true, message: '请输入生产版本', trigger: 'blur' }
+          { required: true, message: '请输入生产版本', trigger: 'blur' }
         ]
         ]
 
 
       },
       },
@@ -143,7 +160,9 @@ export default {
       // 是否是修改
       // 是否是修改
       isUpdate: false,
       isUpdate: false,
 
 
-      step: 1,
+      taskInstanceList: [],
+
+
 
 
     };
     };
   },
   },
@@ -165,6 +184,7 @@ export default {
         if (!valid) {
         if (!valid) {
           return false;
           return false;
         }
         }
+        this.$refs.taskRef.getTaskList()
         if (!this.data) {
         if (!this.data) {
           delete this.form.id;
           delete this.form.id;
         }
         }
@@ -172,24 +192,29 @@ export default {
         this.loading = true;
         this.loading = true;
 
 
 
 
+        if (this.taskInstanceList.length == 0) {
+          this.$message.warning('至少配置一条工序才能保存');
+          return;
+        }
+
+        let param = {
+          taskInstanceList: this.taskInstanceList,
+          routingInfo: this.form
+        }
 
 
         route
         route
-          .save(this.form)
-          .then((data) => {
-            if (!this.isUpdate) {
-              this.form.id = data
-              this.step = 2
+          .taskinstanceSave(param)
+          .then((msg) => {
+            if (msg) {
+              this.$message.success(msg);
+              this.updateVisible(false)
+              this.$emit('done')
             }
             }
+          }).finally(() => {
+            this.loading = false
+          })
 
 
 
 
-            this.loading = false;
-            this.$message.success('操作成功');
-
-          })
-          .catch((e) => {
-            this.loading = false;
-            // this.$message.error(e.message);
-          });
       });
       });
     },
     },
 
 
@@ -208,10 +233,8 @@ export default {
       this.$emit('update:visible', value);
       this.$emit('update:visible', value);
     },
     },
 
 
-    refresh() {
-      this.save()
-      this.updateVisible(false)
-      this.$emit('done')
+    taskList(list) {
+      this.taskInstanceList = list
     },
     },
 
 
 
 
@@ -221,7 +244,7 @@ export default {
     async visible(visible) {
     async visible(visible) {
 
 
       if (visible) {
       if (visible) {
-        this.step = 1
+      
         this.getVersionList()
         this.getVersionList()
         const res = await route.Flist({
         const res = await route.Flist({
           pageNum: 1,
           pageNum: 1,
@@ -230,24 +253,23 @@ export default {
         });
         });
         this.fList = res.list;
         this.fList = res.list;
         if (this.data) {
         if (this.data) {
-
           const res = await route.getById(this.data.id);
           const res = await route.getById(this.data.id);
-
           this.$util.assignObject(this.form, {
           this.$util.assignObject(this.form, {
             ...res
             ...res
           });
           });
-          this.step = 2
           this.isUpdate = true;
           this.isUpdate = true;
         } else {
         } else {
           const res = await route.getCode();
           const res = await route.getCode();
           this.form.code = res;
           this.form.code = res;
-          this.step = 1
           this.isUpdate = false;
           this.isUpdate = false;
         }
         }
+
+        this.$refs.taskRef.getList()
       } else {
       } else {
         this.$refs.form.clearValidate();
         this.$refs.form.clearValidate();
         this.form = { ...this.defaultForm };
         this.form = { ...this.defaultForm };
       }
       }
+      
     }
     }
   }
   }
 };
 };

+ 26 - 61
src/views/technology/route/components/user-taskinstance.vue

@@ -2,7 +2,7 @@
 <template>
 <template>
   <div>
   <div>
     <div class="ele-body">
     <div class="ele-body">
-   
+
       <ele-pro-table ref="table" :needPage="false" :columns="columns" :datasource="datasource" row-key="id">
       <ele-pro-table ref="table" :needPage="false" :columns="columns" :datasource="datasource" row-key="id">
         <!-- 表头工具栏 -->
         <!-- 表头工具栏 -->
         <template v-slot:toolbar>
         <template v-slot:toolbar>
@@ -12,7 +12,7 @@
         </template>
         </template>
 
 
         <template v-slot:orderNum="{ row }">
         <template v-slot:orderNum="{ row }">
-         
+
           <el-input v-model="row.orderNum" placeholder="请输入排序"></el-input>
           <el-input v-model="row.orderNum" placeholder="请输入排序"></el-input>
 
 
         </template>
         </template>
@@ -36,19 +36,7 @@
         </template>
         </template>
       </ele-pro-table>
       </ele-pro-table>
 
 
-      <div class="btn_box rx-bc">
-       
-        <el-select v-model="versionUpgradeType" placeholder="请选择" v-if="isEdit" >
-          <el-option label="不升级" :value="0" />
-          <el-option label="小版本" :value="1" />
-          <el-option label="大版本" :value="2" />
-        </el-select>
-        <div v-else></div>
-
-        <el-button type="primary" @click="save">
-          确定
-        </el-button>
-      </div>
+
 
 
     </div>
     </div>
 
 
@@ -82,14 +70,12 @@ export default {
 
 
     // 修改回显的数据
     // 修改回显的数据
     taskInfo: Object,
     taskInfo: Object,
-    isEdit: Boolean,
+    isEdit: Boolean
+
   },
   },
   data() {
   data() {
     return {
     return {
-      timeType: [
-        { value: 1, label: '是' },
-        { value: 0, label: '否' }
-      ],
+
       // 表格列配置
       // 表格列配置
       columns: [
       columns: [
 
 
@@ -144,6 +130,8 @@ export default {
         }
         }
       ],
       ],
 
 
+      tableList: [],
+
       loading: false,
       loading: false,
       addDialog: false,
       addDialog: false,
       showSetting: false,
       showSetting: false,
@@ -154,7 +142,8 @@ export default {
       controlList: [],
       controlList: [],
 
 
       visible: true,
       visible: true,
-      versionUpgradeType: 0
+
+
     };
     };
   },
   },
 
 
@@ -164,7 +153,7 @@ export default {
       let arr = this.$refs.ProductionCom.selection;
       let arr = this.$refs.ProductionCom.selection;
 
 
       let arrM = arr.map((item, index) => {
       let arrM = arr.map((item, index) => {
-        return { ...item.detail  };
+        return { ...item.detail };
       });
       });
       arrM.forEach((element) => {
       arrM.forEach((element) => {
         if (element.id) {
         if (element.id) {
@@ -174,18 +163,15 @@ export default {
       });
       });
 
 
       this.$refs.table.setData([...arrM, ...this.$refs.table.getData()]);
       this.$refs.table.setData([...arrM, ...this.$refs.table.getData()]);
+      this.$emit('taskList', this.$refs.table.getData())
       this.closeAdd();
       this.closeAdd();
     },
     },
     showAddLog() {
     showAddLog() {
       this.tableData = this.$refs.table.getData();
       this.tableData = this.$refs.table.getData();
-      
       this.addDialog = true;
       this.addDialog = true;
-
     },
     },
     /* 打开编辑弹窗 */
     /* 打开编辑弹窗 */
     openEdit(row) {
     openEdit(row) {
-
-
       this.getControlList()
       this.getControlList()
       this.current = row;
       this.current = row;
       this.showEdit = true;
       this.showEdit = true;
@@ -225,13 +211,18 @@ export default {
         });
         });
       } else {
       } else {
         const data = this.$refs.table.getData() ?? [];
         const data = this.$refs.table.getData() ?? [];
-        console.log(data);
         this.$refs.table.setData(data.filter((d) => d.code !== row.code));
         this.$refs.table.setData(data.filter((d) => d.code !== row.code));
       }
       }
+      this.$emit('taskList', this.$refs.table.getData())
     },
     },
     /* 表格数据源 */
     /* 表格数据源 */
-    async datasource({ page, limit, where }) {
-      if (this.taskInfo?.id) {
+
+    datasource({ page, limit, where, order }) {
+      return []
+    },
+
+    async getList() {
+      if (this.isEdit) {
         const res = await route.taskinstanceList({
         const res = await route.taskinstanceList({
           routingId: this.taskInfo.id,
           routingId: this.taskInfo.id,
           isDetail: true,
           isDetail: true,
@@ -243,45 +234,19 @@ export default {
           it.detail.orderNum = it.orderNum
           it.detail.orderNum = it.orderNum
           return it.detail
           return it.detail
         });
         });
-        return {
-          list:  arr,
-        };
+        this.$refs.table.setData([...arr]);
+        this.$forceUpdate()
       }
       }
     },
     },
-    /* 保存编辑 */
-    save() {
-      let arr = this.$refs.table.getData();
-      if (arr.length == 0) {
-        this.$message.warning('至少配置一条工序才能保存');
-        return;
-      }
 
 
-      route
-        .taskinstanceSave({
-          routingId: this.taskInfo.id,
-          versionUpgradeType: this.versionUpgradeType,
-          taskInstanceList: arr
-        })
-        .then((res) => {
-          if (res) {
-            this.$message.success('保存成功!');
-            this.$emit('refresh')
-          }
-        });
 
 
-    },
+      getTaskList() {
+        this.$emit('taskList', this.$refs.table.getData())
+      },
 
 
   },
   },
 
 
-  watch: {
-    visible(visible) {
-      if (visible) {
-        this.$nextTick(() => {
-          this.reload();
-        });
-      }
-    }
-  }
+
 };
 };
 </script>
 </script>
 
 

+ 13 - 20
src/views/technology/route/index.vue

@@ -4,7 +4,7 @@
       <!-- 搜索表单 -->
       <!-- 搜索表单 -->
       <user-search @search="reload" />
       <user-search @search="reload" />
       <!-- 数据表格 -->
       <!-- 数据表格 -->
-      <ele-pro-table  ref="table" :columns="columns" :datasource="datasource"  :selection.sync="selection" row-key="id">
+      <ele-pro-table ref="table" :columns="columns" :datasource="datasource" :selection.sync="selection" row-key="id">
         <!-- 表头工具栏 -->
         <!-- 表头工具栏 -->
         <template v-slot:toolbar>
         <template v-slot:toolbar>
           <el-button size="small" type="primary" icon="el-icon-plus" class="ele-btn-icon"
           <el-button size="small" type="primary" icon="el-icon-plus" class="ele-btn-icon"
@@ -16,7 +16,7 @@
 
 
 
 
         <template v-slot:code="{ row }">
         <template v-slot:code="{ row }">
-          <el-link  type="primary" :underline="false" @click="openDetail(row)" > {{ row.code }}</el-link>
+          <el-link type="primary" :underline="false" @click="openDetail(row)"> {{ row.code }}</el-link>
         </template>
         </template>
 
 
 
 
@@ -44,7 +44,7 @@
             </template>
             </template>
           </el-popconfirm>
           </el-popconfirm>
 
 
-          
+
 
 
         </template>
         </template>
       </ele-pro-table>
       </ele-pro-table>
@@ -55,9 +55,9 @@
 
 
 
 
     <!-- 历史版本弹框 -->
     <!-- 历史版本弹框 -->
-    <historyModal  ref="historyRefs"></historyModal>
+    <historyModal ref="historyRefs"></historyModal>
 
 
-    <UserDetail  :visible.sync="detailEdit" :data="current"  @close="detailEdit = false"></UserDetail>
+    <UserDetail :visible.sync="detailEdit" :data="current" @close="detailEdit = false"></UserDetail>
 
 
   </div>
   </div>
 </template>
 </template>
@@ -80,18 +80,11 @@ export default {
     return {
     return {
       // 表格列配置
       // 表格列配置
       columns: [
       columns: [
-        // {
-        //   columnKey: 'selection',
-        //   type: 'selection',
-        //   width: 45,
-        //   align: 'center',
-        //   fixed: 'left'
-        // },
+ 
 
 
         {
         {
           prop: 'code',
           prop: 'code',
           label: '工艺路线组编码',
           label: '工艺路线组编码',
-          // sortable: 'custom',
           showOverflowTooltip: true,
           showOverflowTooltip: true,
           align: 'center',
           align: 'center',
           minWidth: 110,
           minWidth: 110,
@@ -104,7 +97,7 @@ export default {
           align: 'center',
           align: 'center',
           minWidth: 110
           minWidth: 110
         },
         },
- 
+
 
 
         {
         {
           prop: 'version',
           prop: 'version',
@@ -120,7 +113,7 @@ export default {
           align: 'center',
           align: 'center',
           showOverflowTooltip: true
           showOverflowTooltip: true
         },
         },
-        
+
         {
         {
           prop: 'status',
           prop: 'status',
           label: '状态',
           label: '状态',
@@ -185,10 +178,10 @@ export default {
       this.$refs.userEdit.$refs.form &&
       this.$refs.userEdit.$refs.form &&
         this.$refs.userEdit.$refs.form.clearValidate();
         this.$refs.userEdit.$refs.form.clearValidate();
     },
     },
-   /* 打开历史版本 */
-   openHistory(row) {
-     this.$refs.historyRefs.open(row)
-   },
+    /* 打开历史版本 */
+    openHistory(row) {
+      this.$refs.historyRefs.open(row)
+    },
     /* 删除 */
     /* 删除 */
     remove(row) {
     remove(row) {
       const loading = this.$loading({ lock: true });
       const loading = this.$loading({ lock: true });
@@ -249,7 +242,7 @@ export default {
     openDetail(row) {
     openDetail(row) {
       this.current = row
       this.current = row
       this.detailEdit = true
       this.detailEdit = true
-     
+
     },
     },
 
 
   }
   }