Quellcode durchsuchen

fix: 更新切换标签时表单默认值,确保文档工作区标签打开时使用正确的默认值

xieyong vor 6 Tagen
Ursprung
Commit
32b1df3116
1 geänderte Dateien mit 18 neuen und 3 gelöschten Zeilen
  1. 18 3
      src/components/addDoc/file-edit.vue

+ 18 - 3
src/components/addDoc/file-edit.vue

@@ -209,14 +209,17 @@
     },
     methods: {
       handleClick() {
-        this.form.directoryId = '';
-        this.form.businessCodeId = '';
-        this.form.codeType = '';
         if (this.activeName == 2) {
           this.folderList = this.myFolderList;
         } else {
           this.folderList = this.allFolderList;
         }
+        // 切换 tab 时使用新 tab 的默认值(文档位置 / 编码分类 / 编码方案)联动更新
+        // 其他字段(type / 备注 / 已上传文件等)保留不动
+        if (this.folderList && this.folderList.length > 0) {
+          this.form.directoryId = this.folderList[0].id;
+          this.initFileCode();
+        }
       },
       async getTreeCode() {
         let nodeData = {};
@@ -242,10 +245,22 @@
         }
       },
       async open() {
+        // 每次重新打开都回到"文档工作区"标签
+        this.activeName = '1';
+        this.folderList = this.allFolderList;
         this.showEditFlag = true;
         this.$nextTick(async () => {
           this.list = await selectTreeList();
+          // 强制使用 文档工作区 的默认值(避免 cancel() 保留的旧 directoryId 导致默认值缺失)
+          if (this.folderList && this.folderList.length > 0) {
+            this.form.directoryId = this.folderList[0].id;
+          }
+          // 触发 initFileCode,根据选中的文档位置默认填充 编码分类 / 编码方案
           await this.initFileCode();
+          // 文档类型默认值
+          if (!this.form.type) {
+            this.form.type = '1';
+          }
           this.setTree(this.list);
         });
       },