Procházet zdrojové kódy

fix(workOrder): 修复类型切换时表单数据未正确重置的问题

liujt před 6 měsíci
rodič
revize
8d8e0bc1ab

+ 26 - 13
src/views/produce/components/prenatalExamination/components/workOrder/programRulesDialog.vue

@@ -781,9 +781,20 @@
         });
         console.log('this.addForm.executeUsers', this.addForm.executeUsers);
       },
-      typeChange() {
-        this.addForm.groupId = '';
-        this.addForm.executeIdList = [];
+      typeChange(v) {
+        console.log('typeChange', v, this.addForm.executeIdList);
+        // this.addForm.groupId = '';
+        // this.addForm.executeIdList = [];
+        // this.addForm.teamId = '';
+        // this.addForm.executeUsers = [];
+        this.$set(this.addForm, 'executeUsers', []);
+        if(v == 0) {
+          this.$set(this.addForm, 'groupId', '');
+          this.$set(this.addForm, 'executeIdList', []);
+        } else {
+          this.$set(this.addForm, 'teamId', '');
+        }
+        this.$forceUpdate();
       },
       async getAllTeamList() {
         const { list } = await getteampage({
@@ -937,9 +948,10 @@
           const res = await getById(id);
 
           console.log('res----------', res.data);
-          this.addForm = res.data;
-
-          this.addForm.id = res.data.planId;
+        
+          const data = res.data
+          // this.addForm = res.data;
+          // this.addForm.id = res.data.planId;
           // if (this.dialogTitle === '派单') {
           //   this.addForm.autoOrder = 1;
           // }
@@ -971,22 +983,22 @@
           console.log(this.ruleIdList);
 
           // 处理回显数据
-          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';
             }
 
             groupIds.map((item) => {
@@ -994,10 +1006,11 @@
             });
           } else {
             // 班组
-            this.addForm.teamId = this.addForm.executeUsers?.[0]?.teamId || '';
+            res.teamId = res.executeUsers?.[0]?.teamId || '';
           }
           this.tabsValue = this.ruleIdList[0].ruleId;
-
+          this.$set(this, 'addForm', data);
+          this.$set(this.addForm, 'id', data.planId);
           // this._getMatterRulesDetails(res.ruleId);
           this.$set(this.addForm, 'code', res.data.code);
           this.$set(this.addForm, 'urgent', JSON.stringify(res.data.urgent));