Pārlūkot izejas kodu

feat(规则管理): 根据路由路径动态设置业务类型并优化类型编辑功能

yusheng 5 mēneši atpakaļ
vecāks
revīzija
cd0ed436c7

+ 14 - 0
src/views/rulesManagement/releaseRules/components/editTypeModal.vue

@@ -23,6 +23,7 @@
           dictName="业务类型"
           placeholder="请选择业务分类"
           @itemChange="(data) => (form.businessName = data.dictValue)"
+          :isProhibit="!!businessType"
         />
       </el-form-item>
 
@@ -30,6 +31,7 @@
         <dict-selection
           v-model="form.reportWorkType"
           dictName="记录规则报工类型"
+          :listFormatte="listFormatte"
           placeholder="请选择模块划分"
           @itemChange="(data) => (form.reportWorkName = data.dictValue)"
         />
@@ -74,6 +76,9 @@
   export default {
     components: { DictSelection },
     mixins: [dictMixins],
+    props: {
+      businessType: ''
+    },
     data() {
       const formBaseData = {
         id: null,
@@ -125,11 +130,20 @@
       };
     },
     methods: {
+      listFormatte(list, valueName) {
+        console.log('list', list);
+        console.log('valueName', valueName);
+       
+      },
       // 外部调用,打开弹窗
       open(type, data) {
         console.log('type', type);
         console.log('data', data);
         if (type == 'add') {
+          if (this.businessType) {
+            this.form.businessType = this.businessType + '';
+            this.form.businessName = this.businessType == '1' ? '生产' : '质检';
+          }
           this.title = '新增类型';
           if (data) {
             // 根据data.type赋值

+ 1 - 1
src/views/rulesManagement/releaseRules/components/permitAdd.vue

@@ -700,7 +700,7 @@
       typeInfo: {
         type: Object,
         default: () => null
-      }
+      },
     },
     computed: {
       bankColumns() {

+ 33 - 12
src/views/rulesManagement/releaseRules/index.vue

@@ -68,6 +68,7 @@
             :datasource="datasource"
             :cache-key="cacheKeyUrl"
             row-key="id"
+            :initLoad="false"
           >
             <template v-slot:toolbar>
               <el-button
@@ -188,7 +189,17 @@
       @reloadTypeList="getTypeList"
     />
     <historyModal ref="historyModalRef" />
-    <editTypeModal ref="editTypeModalRef" @reload="getTypeList"></editTypeModal>
+    <editTypeModal
+      ref="editTypeModalRef"
+      @reload="getTypeList"
+      :businessType="
+        $route.path == '/releaseRules/productionReleaseRules'
+          ? 1
+          : '/releaseRules/qualityReleaseRules'
+          ? 2
+          : ''
+      "
+    ></editTypeModal>
   </div>
 </template>
 
@@ -201,7 +212,7 @@
     recordrulesPublish,
     recordrulesRevokePublish,
     recordrulesTypePage,
-    recordrulesTypeDeletes,
+    recordrulesTypeDeletes
   } from '@/api/recordrules/index';
   import tabMixins from '@/mixins/tableColumnsMixin';
   import dictMixins from '@/mixins/dictMixins';
@@ -415,15 +426,20 @@
         cacheKeyUrl: 'maindata-25922-recordrules-index',
         typeTree: [],
         treeNode: null,
-        qmsReportWorkType: [5, 6, 7],
+        qmsReportWorkType: [5, 6, 7]
       };
     },
     created() {
       this.getTypeList();
     },
+    watch: {
+      $route() {
+        this.treeNode = null;
+        this.getTypeList();
+      }
+    },
     methods: {
       addPermit(row, type, title) {
-     
         if (type == 'add') {
           if (!this.treeNode) {
             return this.$message.warning('请先选择类型节点!');
@@ -477,7 +493,9 @@
           pageNum: page,
           size: limit,
           ...where,
-          ...typeWhere
+          ...typeWhere,
+          businessType:
+            this.$route.path == '/releaseRules/productionReleaseRules' ? 1 : 2
         });
       },
       /* 刷新表格 */
@@ -519,7 +537,7 @@
           return this.$message.warning('请先修改规则停用时间!');
         }
 
-        console.log('row~~~~~', row)
+        console.log('row~~~~~', row);
         if (!this.qmsReportWorkType.includes(row.reportWorkType)) {
           if (row.details.length == 0) {
             return this.$message.warning('至少选择一条规则项');
@@ -527,9 +545,7 @@
 
           if (row.reportWorkType == 4) {
             // 生产统计过滤掉非成品统计的明细
-            row.details = row.details.filter(
-              (i) => i.statisticsType
-            );
+            row.details = row.details.filter((i) => i.statisticsType);
           }
 
           // 判断参数类型是否选择
@@ -567,7 +583,9 @@
       async getTypeList() {
         const { list = [] } = await recordrulesTypePage({
           pageNum: 1,
-          size: 99999
+          size: 99999,
+          businessType:
+            this.$route.path == '/releaseRules/productionReleaseRules' ? 1 : 2
         });
 
         console.log('type list', list);
@@ -671,7 +689,7 @@
         this.typeTree = tree; // 结果树
 
         console.log('typeTree~~~~~', this.typeTree);
-        
+
         if (!this.treeNode) {
           // 默认选中第一个节点
           this.treeNode = this.typeTree.length > 0 ? this.typeTree[0] : null;
@@ -689,7 +707,10 @@
       },
       // 打开新增类型
       openEditType(type = 'add', data = null) {
-        this.$refs.editTypeModalRef.open(type, type == 'add' ? this.treeNode : data);
+        this.$refs.editTypeModalRef.open(
+          type,
+          type == 'add' ? this.treeNode : data
+        );
       },
       async deleteTypeNode(node) {
         console.log('delete node', node);