695593266@qq.com 7 месяцев назад
Родитель
Сommit
12bebb29e2

+ 15 - 6
src/api/producetaskrecordrules/index.js

@@ -12,10 +12,7 @@ export async function produceTaskRecordRules(data) {
 
 // 批量保存 /main/producetaskconfig/batchSave
 export async function produceTaskRecordRulesBatchSave(data) {
-  const res = await request.post(
-    `/main/producetaskconfig/batchSave`,
-    data
-  );
+  const res = await request.post(`/main/producetaskconfig/batchSave`, data);
   if (res.data.code == 0) {
     return res.data.data;
   }
@@ -24,8 +21,20 @@ export async function produceTaskRecordRulesBatchSave(data) {
 
 // /main/producetaskconfig/getById/{id}
 export async function produceTaskRecordRulesGetById(id) {
-  const res = await request.get(
-    `/main/producetaskconfig/getById/${id}`
+  const res = await request.get(`/main/producetaskconfig/getById/${id}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// /main/producetaskconfig/getTemplateListByProduceTaskId post
+export async function produceTaskRecordRulesGetTemplateListByProduceTaskId(
+  data
+) {
+  const res = await request.post(
+    `/main/producetaskconfig/getTemplateListByProduceTaskId`,
+    data
   );
   if (res.data.code == 0) {
     return res.data.data;

+ 27 - 4
src/store/getters.js

@@ -2,6 +2,8 @@
  * vuex getter
  */
 import dictEnum from '@/enum/dict';
+import store from './index';
+
 export default {
   user: (state) => state.user,
   paramsSetData: (state) => state.paramsSetData,
@@ -17,10 +19,31 @@ export default {
     const obj = (state.dict[dictEnum[enumName]] || []).find((item) => {
       return item.dictCode == dictCode;
     });
-    // console.log(dictEnum);
-    // console.log(enumName);
-    // console.log(state.dict);
-    // console.log('obj-----', obj);
+
+    if (!obj) {
+      // 提交dict模块下的actions的requestDict
+      store.dispatch('dict/requestDict', enumName);
+      return '';
+    }
+
     return obj && obj.dictValue;
+  },
+  // 根据字典enumName 获取字典列表 label value 格式
+  getDictListByName: (sate) => (enumName) => {
+    const dList = sate.dict[dictEnum[enumName]] || [];
+
+    if (!dList.length) {
+      // 提交dict模块下的actions的requestDict
+      store.dispatch('dict/requestDict', enumName);
+      return '';
+    }
+
+    return dList.map((i) => {
+      return {
+        ...i,
+        label: i.dictValue,
+        value: i.dictCode
+      };
+    });
   }
 };

+ 38 - 37
src/store/modules/dict.js

@@ -12,12 +12,21 @@ import { getByCode } from '@/api/system/dictionary-data';
 //   //   }
 // };
 
-const state = {};
+const state = {
+  // 加载中的字典项
+  dictLoading: []
+};
 
 const mutations = {
   //根据字典code 添加字典
   ADD_DICT: (state, { code, dict }) => {
     Vue.set(state, code, dict);
+  },
+  dictLoadingAdd: (state, code) => {
+    state.dictLoading.push(code);
+  },
+  dictLoadingRemove: (state, code) => {
+    state.dictLoading = state.dictLoading.filter((item) => item !== code);
   }
 };
 
@@ -25,46 +34,38 @@ const actions = {
   // 根据字典enumName请求字典 已获取的不做重复请求
   async requestDict({ commit, state }, enumName) {
     const code = dictEnum[enumName];
+    // 如果字典正在加载中,则不重复请求
+    if (state.dictLoading.includes(code)) return;
+
+    commit('dictLoadingAdd', code);
 
     if (state[code]?.length) return state[code];
-    let res;
-    // if (otherDictConfig[dictEnum[enumName]]) {
-    //   const config = otherDictConfig[dictEnum[enumName]];
-    //   console.log(config);
-    //   //非枚举定义
-    //   res = await config.request();
-    //   if (res?.code == 0) {
-    //     let list = config.resKey ? res.data[config.resKey] : res.data;
-    //     commit('ADD_DICT', {
-    //       code,
-    //       dict: list.map((item) => ({
-    //         ...item,
-    //         dictCode: item[config.dictCode],
-    //         dictValue: item[config.dictValue]
-    //       }))
-    //     });
-    //     return res.list;
-    //   }
-    // } else {
-    res = await getByCode(code);
-    if (res?.code == 0) {
-      const isNumber = numberList.includes(code);
-      commit('ADD_DICT', {
-        code,
-        dict: res.data.map((item) => {
-          const arr = Object.entries(item)[0] || [];
 
-          return {
-            dictCode: isNumber ? Number(arr[0]) : arr[0],
-            dictValue: arr[1]
-          };
-        })
-      });
-      return res.data;
-    }
-    // }
+    try {
+      let res = await getByCode(code);
+      if (res?.code == 0) {
+        const isNumber = numberList.includes(code);
+        commit('ADD_DICT', {
+          code,
+          dict: res.data.map((item) => {
+            const arr = Object.entries(item)[0] || [];
 
-    return [];
+            return {
+              dictCode: isNumber ? Number(arr[0]) : arr[0],
+              dictValue: arr[1]
+            };
+          })
+        });
+        commit('dictLoadingRemove', code);
+        return res.data;
+      }
+
+      commit('dictLoadingRemove', code);
+      return [];
+    } catch (error) {
+      commit('dictLoadingRemove', code);
+      return [];
+    }
   },
   // 更新字典
   async reloadRequestDict({ commit }, enumName) {

+ 5 - 2
src/views/documentManagement/certificateManagement/components/add-dialog.vue

@@ -119,7 +119,7 @@
         </el-col>
         <el-col v-bind="styleResponsive ? { sm: 24 } : { span: 24 }">
           <el-form-item prop="fileObj" label="附件">
-            <fileMain v-model="form.fileObj" />
+            <fileMain v-model="form.fileObj" @updateVal="handleFileSuccess" />
           </el-form-item>
         </el-col>
         <el-col v-bind="styleResponsive ? { sm: 24 } : { span: 24 }">
@@ -237,6 +237,9 @@
       this.getCompanyData();
     },
     methods: {
+      handleFileSuccess() {
+        this.$refs.form.validateField('fileObj');
+      },
       //选择负责人
       confirmStaffSelection(data) {
         console.log(data);
@@ -284,7 +287,7 @@
       close() {
         this.dialogVisible = false;
         // this.$refs.form.resetFields()
-        this.form = { defaultForm };
+        this.form = { ...defaultForm };
         this.$refs.productTableRef.initData();
       },
 

+ 9 - 21
src/views/material/BOMmanage/components/workingProcedure.vue

@@ -410,7 +410,7 @@
           </el-form>
         </el-tab-pane>
 
-        <el-tab-pane v-if="!process" label="材料定额" name="材料定额">
+        <el-tab-pane label="材料定额" name="材料定额">
           <ele-pro-table
             ref="materialTable"
             :columns="columns1"
@@ -578,7 +578,7 @@
           </ele-pro-table>
         </el-tab-pane>
 
-        <el-tab-pane v-if="!process" label="制造资源" name="制造资源">
+        <el-tab-pane label="制造资源" name="制造资源">
           <ele-pro-table
             ref="resourceTable"
             :columns="columns1"
@@ -696,7 +696,7 @@
             </template>
           </ele-pro-table>
         </el-tab-pane>
-        <el-tab-pane v-if="!process" label="工艺文件" name="工艺文件">
+        <el-tab-pane label="工艺文件" name="工艺文件">
           <ele-pro-table
             ref="fileTable"
             :columns="jobColumns1"
@@ -717,7 +717,7 @@
           </ele-pro-table>
         </el-tab-pane>
 
-        <el-tab-pane v-if="!process" label="标准产出" name="标准产出">
+        <el-tab-pane label="标准产出" name="标准产出">
           <ele-pro-table
             ref="standard"
             :columns="standardCol"
@@ -738,9 +738,10 @@
         </el-tab-pane>
         <el-tab-pane label="过程监测" name="过程监测">
           <userSettingMatterProcess
-            :produce-task-id="rowData.id"
+            :produce-task-id="rowData.sourceTaskId"
             :produce-task-name="rowData.name"
             :produce-task-code="rowData.code"
+            :bom-category-id="resourceBomId"
             ref="userSettingMatterProcessRef"
           ></userSettingMatterProcess>
         </el-tab-pane>
@@ -1192,9 +1193,7 @@
         resourceBomId: '',
         level: '',
         attributeData: {},
-        unitList: [],
-        // 从工序管理过来为 true tab-pane隐藏 工艺文件、标准产出、材料定额、制造资源
-        process: false
+        unitList: []
       };
     },
     created() {
@@ -1670,15 +1669,7 @@
           dom.getData()
         );
       },
-      open(
-        rowData,
-        treeData,
-        tableData,
-        isView,
-        attributeData,
-        resourceBomId,
-        process = false
-      ) {
+      open(rowData, treeData, tableData, isView, attributeData, resourceBomId) {
         // 工序信息
         console.log('rowData', rowData);
         // bom 信息
@@ -1689,11 +1680,8 @@
         console.log('isView', isView);
         // bom 信息 和 treeData 一致
         console.log('attributeData', attributeData);
-        // bom id 对应 treeData和attributeData里的id
+        // bom category id
         console.log('resourceBomId', resourceBomId);
-        // 从工序管理过来带有process=true
-        console.log('process', process);
-        this.process = process;
         this.columns = [];
         this.columns1 = [];
         this.isView = isView; //true详情 false编辑

+ 1 - 1
src/views/material/BOMmanage/components/workmanship.vue

@@ -286,7 +286,7 @@
       UserEdit
     },
     props: {
-      // bom id
+      // bom bomCategoryId
       resourceBomId: String,
       // bom 信息
       taskParam: Object,

+ 1 - 4
src/views/rulesManagement/releaseRules/components/ProductModal.vue

@@ -138,10 +138,7 @@
           ...where,
           pageNum: page,
           size: limit,
-          categoryLevelId: this.categoryLevelId,
-          isProduct: true,
-          produceTaskCode: this.produceTaskCode,
-          bomTypes: [1, 2, 3]
+          categoryLevelId: this.categoryLevelId
         });
       },
       handleNodeClick(data) {

+ 28 - 33
src/views/rulesManagement/releaseRules/components/permitAdd.vue

@@ -289,11 +289,7 @@
               label-width="110px"
               style="margin-bottom: 0"
             >
-              <el-input
-                type="text"
-                :disabled="formData.executeMethodTitle == '无执行方式'"
-                v-model="executeMethodTitleComputed"
-              />
+              <el-input type="text" v-model="executeMethodTitleComputed" />
             </el-form-item>
           </div>
         </template>
@@ -303,7 +299,6 @@
             v-model="row.paramType"
             placeholder="请选择参数类型"
             size="mini"
-            required
           >
             <el-option label="数值" :value="1" />
             <el-option label="选择" :value="2" />
@@ -689,6 +684,10 @@
             prop: 'modelType',
             label: '型号'
           },
+          {
+            prop: 'specification',
+            label: '规格'
+          },
           {
             prop: 'measuringUnit',
             label: '计量单位'
@@ -925,7 +924,8 @@
             deletedIds: [],
             produceTaskId: data.produceTaskConfigs[0]?.produceTaskId,
             produceTaskName: data.produceTaskConfigs[0]?.produceTaskName,
-            updatePOs: []
+            updatePOs: [],
+            isTemplate: 1
           };
 
           if (data.isExecuteMethod) {
@@ -1116,6 +1116,13 @@
             }
           }
 
+          // 判断参数类型是否选择
+          for (const detail of this.formData.details) {
+            if (!detail.paramType) {
+              return this.$message.warning('请选择规则明细中的参数类型!');
+            }
+          }
+
           try {
             this.btnLoading = true;
 
@@ -1200,7 +1207,8 @@
                     produceTaskName:
                       body.produceTaskConfigBatchSavePo.produceTaskName,
                     categoryLevelId: categoryId,
-                    reportWorkType: this.formData.reportWorkType
+                    reportWorkType: this.formData.reportWorkType,
+                    isTemplate: 1
                   });
                 }
               });
@@ -1234,7 +1242,8 @@
                     productCode: product.code,
                     productId: product.id || product.productId,
                     productName: product.name || product.productName,
-                    reportWorkType: this.formData.reportWorkType
+                    reportWorkType: this.formData.reportWorkType,
+                    isTemplate: 1
                   });
                 }
               });
@@ -1268,7 +1277,8 @@
                     body.produceTaskConfigBatchSavePo.produceTaskId,
                   produceTaskName:
                     body.produceTaskConfigBatchSavePo.produceTaskName,
-                  reportWorkType: this.formData.reportWorkType
+                  reportWorkType: this.formData.reportWorkType,
+                  isTemplate: 1
                 });
               } else {
                 // 新增
@@ -1282,7 +1292,8 @@
                     body.produceTaskConfigBatchSavePo.produceTaskId,
                   produceTaskName:
                     body.produceTaskConfigBatchSavePo.produceTaskName,
-                  reportWorkType: this.formData.reportWorkType
+                  reportWorkType: this.formData.reportWorkType,
+                  isTemplate: 1
                 });
               }
             }
@@ -1308,7 +1319,8 @@
                   produceTaskName:
                     body.produceTaskConfigBatchSavePo.produceTaskName,
                   categoryLevelId: categoryId,
-                  reportWorkType: this.formData.reportWorkType
+                  reportWorkType: this.formData.reportWorkType,
+                  isTemplate: 1
                 });
               });
             }
@@ -1326,7 +1338,8 @@
                   productCode: product.code,
                   productId: product.id || product.productId,
                   productName: product.name || product.productName,
-                  reportWorkType: this.formData.reportWorkType
+                  reportWorkType: this.formData.reportWorkType,
+                  isTemplate: 1
                 });
               });
             }
@@ -1339,7 +1352,8 @@
                 produceTaskId: body.produceTaskConfigBatchSavePo.produceTaskId,
                 produceTaskName:
                   body.produceTaskConfigBatchSavePo.produceTaskName,
-                reportWorkType: this.formData.reportWorkType
+                reportWorkType: this.formData.reportWorkType,
+                isTemplate: 1
               });
             }
           }
@@ -1520,15 +1534,6 @@
       },
       // 选择工序
       openProduceTaskDialog() {
-        if (this.formData.produceTaskConfigs) {
-          // 其中包含 isUsing 为 true 则不能修改
-          const some = this.formData.produceTaskConfigs.some((i) => i.isUsing);
-          if (some) {
-            return this.$message.warning(
-              '当前规则关联的工序有执行中的记录,不能更改!'
-            );
-          }
-        }
         this.$refs.processModalRef.open();
       },
       // 工序
@@ -1597,16 +1602,6 @@
         }
       },
       clearProductTask() {
-        // 如果有执行中的记录 则不能清空
-        if (
-          this.formData.produceTaskConfigs &&
-          this.formData.produceTaskConfigs[0] &&
-          this.formData.produceTaskConfigs[0].isUsing
-        ) {
-          return this.$message.warning(
-            '当前规则关联的工序有执行中的记录,不能更改!'
-          );
-        }
         this.formData.produceTaskConfigBatchSavePo.produceTaskId = '';
         this.formData.produceTaskConfigBatchSavePo.produceTaskName = '';
         this.formData.relateProductMethod = 0;

+ 1 - 4
src/views/rulesManagement/releaseRules/index.vue

@@ -292,10 +292,7 @@
         cacheKeyUrl: 'maindata-25922-recordrules-index'
       };
     },
-    created() {
-      this.requestDict('记录规则类型');
-      this.requestDict('规则周期');
-    },
+    created() {},
     methods: {
       addPermit(row, type, title) {
         this.$refs.permitAddRef.open(row, type, title);

+ 133 - 0
src/views/technology/production/components/select-template.vue

@@ -0,0 +1,133 @@
+<template>
+  <el-dialog
+    :title="title"
+    :visible.sync="visible"
+    v-if="visible"
+    :before-close="handleClose"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    append-to-body
+    width="75%"
+  >
+    <ele-pro-table
+      ref="table"
+      :columns="columns"
+      :datasource="templateList"
+      row-key="id"
+      height="calc(100vh - 350px)"
+      :selection.sync="selection"
+      :needPage="false"
+      @refresh="getList"
+    >
+    </ele-pro-table>
+    <div class="btns">
+      <el-button type="primary" size="small" @click="selected">选择</el-button>
+      <el-button size="small" @click="handleClose">关闭</el-button>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+  import { produceTaskRecordRulesGetTemplateListByProduceTaskId } from '@/api/producetaskrecordrules/index.js';
+  import dictMixins from '@/mixins/dictMixins';
+
+  export default {
+    mixins: [dictMixins],
+    components: {},
+    props: {
+      // 工序id
+      produceTaskId: {
+        type: String,
+        required: true
+      }
+    },
+    data() {
+      return {
+        visible: false,
+
+        // 表格列配置
+        columns: [
+          {
+            width: 50,
+            type: 'selection',
+            columnKey: 'selection',
+            align: 'center'
+          },
+          {
+            columnKey: 'index',
+            type: 'index',
+            width: 45,
+            align: 'center',
+            reserveSelection: true
+          },
+          {
+            prop: 'itemType',
+            label: '类型',
+            align: 'center',
+            formatter: (row) => {
+              return this.getDictValue('记录规则事项类型', row.itemType);
+            }
+          },
+          {
+            prop: 'executeMethod',
+            label: '执行方式',
+            align: 'center',
+            formatter: (row) => {
+              return this.getDictValue('记录规则执行方式', row.executeMethod);
+            }
+          },
+          {
+            prop: 'rulesName',
+            label: '名称',
+            align: 'center',
+            formatter: (row) => {
+              return row.rulesName || row.itemTaskName;
+            }
+          }
+        ],
+        title: '选择模板',
+        selection: [],
+        templateList: []
+      };
+    },
+    mounted() {
+      this.getList();
+    },
+    methods: {
+      async getList() {
+        const data = await produceTaskRecordRulesGetTemplateListByProduceTaskId(
+          {
+            produceTaskId: this.produceTaskId
+          }
+        );
+        console.log('模板列表', data);
+        this.templateList = data;
+      },
+      /* 刷新表格 */
+      reload(where) {
+        this.isCategory = false;
+        this.$refs.table.reload({ pageNum: 1, where: where });
+      },
+      open() {
+        this.visible = true;
+      },
+      handleClose() {
+        this.visible = false;
+      },
+      selected() {
+        if (!this.selection.length) {
+          return this.$message.warning('请选择模板!');
+        }
+        this.$emit('confirm', this.selection);
+        this.handleClose();
+      }
+    }
+  };
+</script>
+
+<style lang="scss" scoped>
+  .btns {
+    text-align: center;
+    padding: 10px 0;
+  }
+</style>

+ 0 - 1
src/views/technology/production/components/user-setting-matter-add.vue

@@ -148,7 +148,6 @@
 </template>
 
 <script>
-  import { produceTaskRecordRules } from '@/api/producetaskrecordrules';
   import tableColumnsMixin from '@/mixins/tableColumnsMixin';
   import dictMixins from '@/mixins/dictMixins';
   import rules from '@/components/bpmnProcessDesigner/src/modules/rules';

+ 13 - 5
src/views/technology/production/components/user-setting-matter-process-drawer.vue

@@ -189,6 +189,10 @@
             label: '型号',
             prop: 'modelType'
           },
+          {
+            label: '规格',
+            prop: 'specification'
+          },
           // 下拉
           {
             label: 'BOM类型',
@@ -312,7 +316,7 @@
           pageNum: page,
           size: limit,
           categoryLevelId: 9,
-          bomTypes: [1, 2, 3],
+          bomTypes: [2, 3],
           produceTaskCode: this.currentProcessData.code
         });
         data.list.forEach((item) => {
@@ -334,6 +338,13 @@
               label: label
             };
           });
+          // 默认选择第一个bom类型
+          item.bomType = item.bomTypeList[0]?.value || '';
+          // 默认最后一个版本
+          const bomList = item.bomCategoryMap[item.bomType] || [];
+          if (bomList.length > 0) {
+            item.bomVersion = bomList[bomList.length - 1].versions;
+          }
         });
         console.log('getList', data);
         return data;
@@ -372,8 +383,6 @@
             (item) => item.code == this.currentProcessData.code
           );
 
-          console.log('currentTask', currentTask, this.currentProcessData.code);
-
           if (currentTask) {
             // 打开配置
             this.$refs.workingProcedureRef.open(
@@ -382,8 +391,7 @@
               data[0],
               false,
               bomInfo,
-              bomInfo.id,
-              true
+              bomInfo.id
             );
           } else {
             this.$message.warning('该BOM下未配置此工序');

+ 66 - 14
src/views/technology/production/components/user-setting-matter-process.vue

@@ -19,6 +19,15 @@
         >
           新建
         </el-button>
+        <el-button
+          size="small"
+          type="primary"
+          icon="el-icon-plus"
+          class="ele-btn-icon"
+          @click="selectTemplate"
+        >
+          从模板添加
+        </el-button>
       </template>
 
       <!-- 操作列 -->
@@ -57,6 +66,13 @@
       @changeProduct="changeRelateProduct"
       multiple
     ></ProductModal>
+
+    <selectTemplate
+      ref="selectTemplateRef"
+      :produceTaskId="produceTaskId"
+      @confirm="handleTemplateConfirm"
+    >
+    </selectTemplate>
   </div>
 </template>
 
@@ -72,11 +88,12 @@
   import { mapGetters } from 'vuex';
   import { getTreeByPid } from '@/api/classifyManage';
   import ProductModal from '@/components/selectProduct/ProductModal.vue';
+  import selectTemplate from './select-template.vue';
 
   export default {
     name: 'UserSettingMatter',
     mixins: [dictMixins, tableColumnsMixin],
-    components: { userSettingMatterAdd, ProductModal },
+    components: { userSettingMatterAdd, ProductModal, selectTemplate },
     props: {
       // 工序id
       produceTaskId: {
@@ -93,11 +110,28 @@
         type: String,
         required: false,
         default: ''
+      },
+      bomCategoryId: {
+        type: String,
+        required: true
       }
     },
     watch: {
-      produceTaskId() {
-        this.getMatterList();
+      produceTaskId: {
+        immediate: true,
+        handler() {
+          if (this.produceTaskId) {
+            this.getMatterList();
+          }
+        }
+      },
+      bomCategoryId: {
+        immediate: true,
+        handler() {
+          if (this.bomCategoryId) {
+            this.getMatterList();
+          }
+        }
       }
     },
     data() {
@@ -225,7 +259,6 @@
     },
     created() {
       this.getProductCategory();
-      this.getMatterList();
     },
     methods: {
       // 获取产品分类
@@ -239,6 +272,7 @@
         const { list } = await produceTaskRecordRules({
           // 工序id
           produceTaskId: this.produceTaskId,
+          bomCategoryId: this.bomCategoryId,
           pageNum: 1,
           size: 9999,
           reportWorkType: this.reportWorkType
@@ -280,14 +314,16 @@
           id: id,
           produceTaskId: this.produceTaskId,
           produceTaskName: this.produceTaskName,
-          reportWorkType: this.reportWorkType
+          reportWorkType: this.reportWorkType,
+          isTemplate: 0
         });
         this.addPOs.push({
           ...matter,
           id: id,
           produceTaskId: this.produceTaskId,
           produceTaskName: this.produceTaskName,
-          reportWorkType: this.reportWorkType
+          reportWorkType: this.reportWorkType,
+          isTemplate: 0
         });
         this.handleSort();
       },
@@ -310,10 +346,7 @@
             (item) => item.id !== matter.id
           );
           this.updatePOs.push({
-            ...matter,
-            produceTaskId: this.produceTaskId,
-            produceTaskName: this.produceTaskName,
-            reportWorkType: this.reportWorkType
+            ...matter
           });
         } else {
           // 如果是临时id,直接更新addPOs
@@ -363,11 +396,21 @@
           this.butLoading = true;
 
           await produceTaskRecordRulesBatchSave({
-            addPOs: this.addPOs,
+            addPOs: this.addPOs.map((i) => {
+              return {
+                ...i,
+                id: null,
+                bomCategoryId: this.bomCategoryId
+              };
+            }),
             deletedIds: this.deletedIds,
-            produceTaskId: this.produceTaskId,
-            produceTaskName: this.produceTaskName,
-            updatePOs: this.updatePOs
+            updatePOs: this.updatePOs.map((i) => {
+              return {
+                ...i,
+                bomCategoryId: this.bomCategoryId
+              };
+            }),
+            isTemplate: 0
           });
           this.handleClose();
 
@@ -398,6 +441,15 @@
             (i) => !this.params.products.some((cat) => cat.id === i.id)
           )
         ];
+      },
+      selectTemplate() {
+        this.$refs.selectTemplateRef.open();
+      },
+      handleTemplateConfirm(rows) {
+        console.log('rows', rows);
+        rows.forEach((row) => {
+          this.addMatter(row);
+        });
       }
     }
   };

+ 51 - 28
src/views/technology/production/components/user-setting-matter.vue

@@ -25,6 +25,9 @@
       :datasource="datasource"
       :need-page="false"
       class="table_list"
+      row-key="id"
+      cache-key="user-setting-matter-2510241427"
+      @refresh="getMatterList"
     >
       <template v-slot:toolbar>
         <el-button
@@ -109,6 +112,11 @@
             width: 45,
             align: 'center'
           },
+          {
+            prop: 'produceTaskName',
+            label: '工序名称',
+            align: 'center'
+          },
           {
             prop: 'itemType',
             label: '类型',
@@ -140,8 +148,8 @@
             slot: 'action'
           }
         ],
-        // 当前行数据
-        currentRow: null,
+        // 配置工序数据
+        currentRows: [],
         // 添加事项列表
         addPOs: [],
         deletedIds: [],
@@ -169,19 +177,36 @@
       updateVisible(val) {
         this.visible = val;
       },
-      openSetting(row) {
-        console.log('row', row);
-        this.currentRow = row;
+      openSetting(rows) {
+        console.log('rows', rows);
+
+        if (Array.isArray(rows)) {
+          this.currentRows = rows;
+        } else {
+          this.currentRows = [rows];
+        }
+
         this.visible = true;
-        this.getMatterList(row);
+        this.getMatterList();
+        // if (rows.length > 1) {
+        //   this.bankColumns.splice(1, 0, {
+        //     prop: 'produceTaskName',
+        //     label: '工序名称',
+        //     align: 'center'
+        //   });
+        // } else {
+        //   this.bankColumns = this.bankColumns.filter(
+        //     (col) => col.prop !== 'produceTaskName'
+        //   );
+        // }
       },
       // 查询事项数据
       async getMatterList() {
         const { list } = await produceTaskRecordRules({
-          produceTaskId: this.currentRow.id,
+          produceTaskIds: this.currentRows.map((row) => row.id),
           pageNum: 1,
-          size: 9999
-          // reportWorkType: this.reportWorkType
+          size: 9999,
+          isTemplate: 0
         });
         console.log('list', list);
         // 表格数据
@@ -215,20 +240,23 @@
         console.log('matter', matter);
         const id = 'tem' + new Date().getTime();
         // 添加事项
-        this.matterList.push({
-          ...matter,
-          id: id,
-          produceTaskId: this.currentRow.id,
-          produceTaskName: this.currentRow.name,
-          reportWorkType: this.reportWorkType
-        });
-        this.addPOs.push({
-          ...matter,
-          id: id,
-          produceTaskId: this.currentRow.id,
-          produceTaskName: this.currentRow.name,
-          reportWorkType: this.reportWorkType
+        this.currentRows.forEach((task) => {
+          this.matterList.push({
+            ...matter,
+            id: id + task.id,
+            produceTaskId: task.id,
+            produceTaskName: task.name,
+            reportWorkType: this.reportWorkType
+          });
+          this.addPOs.push({
+            ...matter,
+            id: id + task.id,
+            produceTaskId: task.id,
+            produceTaskName: task.name,
+            reportWorkType: this.reportWorkType
+          });
         });
+
         this.handleSort();
       },
       editMatter(matter) {
@@ -250,10 +278,7 @@
             (item) => item.id !== matter.id
           );
           this.updatePOs.push({
-            ...matter,
-            produceTaskId: this.currentRow.id,
-            produceTaskName: this.currentRow.name,
-            reportWorkType: this.reportWorkType
+            ...matter
           });
         } else {
           // 如果是临时id,直接更新addPOs
@@ -305,8 +330,6 @@
           await produceTaskRecordRulesBatchSave({
             addPOs: this.addPOs,
             deletedIds: this.deletedIds,
-            produceTaskId: this.currentRow.id,
-            produceTaskName: this.currentRow.name,
             updatePOs: this.updatePOs
           });
           this.$message.success('保存成功');

+ 16 - 13
src/views/technology/production/index.vue

@@ -58,6 +58,14 @@
           >
             批量修改工作中心
           </el-button>
+          <el-button
+            size="small"
+            type="primary"
+            class="ele-btn-icon"
+            @click="batchSettingMatter"
+          >
+            生产前生产后配置
+          </el-button>
         </template>
 
         <template v-slot:name="{ row }">
@@ -106,15 +114,6 @@
             </template>
           </el-popconfirm>
 
-          <el-link
-            type="primary"
-            :underline="false"
-            icon="el-icon-setting"
-            @click="openSettingMatter(row)"
-          >
-            配置事项
-          </el-link>
-
           <el-link
             type="primary"
             :underline="false"
@@ -269,7 +268,7 @@
           {
             columnKey: 'action',
             label: '操作',
-            width: 280,
+            width: 210,
             align: 'center',
             resizable: false,
             slot: 'action',
@@ -372,8 +371,13 @@
       this.requestDict('记录规则事项类型');
     },
     methods: {
-      openSettingMatter(row) {
-        this.$refs.userSettingMatterRef.openSetting(row);
+      // 批量配置事项
+      batchSettingMatter() {
+        if (this.selection.length == 0) {
+          this.$message.error('请至少选择一条数据');
+          return;
+        }
+        this.$refs.userSettingMatterRef.openSetting(this.selection);
       },
       openSettingMatterProcess(row) {
         this.$refs.userSettingMatterProcessDrawerRef.open(row);
@@ -384,7 +388,6 @@
           this.typeList.find((m) => m.value == type).label
         );
       },
-
       /*配置工艺参数 */
       openSetting(row) {
         this.current = row;

+ 2 - 0
vue.config.js

@@ -37,6 +37,8 @@ module.exports = {
         // target: 'http://192.168.1.176:18086',
         target: 'http://192.168.1.125:18086',
         // target: 'http://192.168.1.251:18186',
+        // target: 'http://192.168.1.125:18086',
+        // target: 'http://192.168.1.251:18186', // 测试环境
         // target: 'http://192.168.1.251:18087',
         // target: 'http://192.168.1.116:18086',
         // target: 'http://192.168.1.251:18086',