Просмотр исходного кода

refactor(programRulesDialog): 优化表单数据处理逻辑

liujt 6 месяцев назад
Родитель
Сommit
35502bf989
1 измененных файлов с 11 добавлено и 10 удалено
  1. 11 10
      src/views/rulesManagement/components/programRulesDialog.vue

+ 11 - 10
src/views/rulesManagement/components/programRulesDialog.vue

@@ -763,7 +763,7 @@ export default {
         const res = await getInfoById(id);
         console.log('res----------', res);
         // this.addForm = res;
-        this.$set(this, 'addForm', res)
+        
         this.isBindPlan = res.isBindPlan;
         this.categoryEquipment(res.categoryLevelId);
         this.ruleIdList = res.planConfigVOList.map((item) => {
@@ -790,35 +790,35 @@ export default {
         });
 
         // 处理回显数据
-        if (this.addForm.type === 0) {
+        if (res.type === 0) {
           // 个人
-          this.addForm.executeIdList = this.addForm.executeUsers.map(
+          res.executeIdList = res.executeUsers.map(
             (item) => item.userId
           );
 
-          let groupIds = this.addForm.executeUsers
+          let groupIds = res.executeUsers
             .map((i) => i.groupId)
             .filter((i) => i);
           groupIds = Array.from(new Set(groupIds));
 
           if (groupIds.includes('1')) {
             // 包含全部部门,置空
-            this.addForm.groupId = '1';
+            res.groupId = '1';
           } else {
-            this.addForm.groupId = this.addForm.executeUsers?.[0]?.groupId || '1';
+            res.groupId = res.executeUsers?.[0]?.groupId || '1';
           }
 
           // this.addForm.teamId = ''
-          this.$set(this.addForm, 'teamId', '');
+          // this.$set(this.addForm, 'teamId', '');
 
           groupIds.map((item) => {
             this.searchDeptNodeClick(item);
           });
         } else {
           // 班组
-          this.addForm.teamId = this.addForm.executeUsers?.[0]?.teamId || '';
-          this.$set(this.addForm, 'groupId', '');
-          this.$set(this.addForm, 'executeIdList', []);
+          res.teamId = res.executeUsers?.[0]?.teamId || '';
+          // this.$set(this.addForm, 'groupId', '');
+          // this.$set(this.addForm, 'executeIdList', []);
           // this.addForm.groupId = ''
           // this.addForm.executeIdList = []
         }
@@ -827,6 +827,7 @@ export default {
           const params = { groupId: res.groupId };
           this.getUserList(params);
         }
+        this.$set(this, 'addForm', res)
         // this._getMatterRulesDetails(res.ruleId);
         this.$set(this.addForm, 'code', res.code);
         this.$set(this.addForm, 'urgent', JSON.stringify(res.urgent));