Explorar el Código

refactor(contractReview): 重构合同评审页面参数处理和表单逻辑

liujt hace 8 meses
padre
commit
58fe56692d
Se han modificado 1 ficheros con 98 adiciones y 77 borrados
  1. 98 77
      src/views/contractManage/contractReview/index.vue

+ 98 - 77
src/views/contractManage/contractReview/index.vue

@@ -215,12 +215,12 @@
   import tabMixins from '@/mixins/tableColumnsMixin';
 
   // 默认表单数据
-  const defaultParams = {
-    dictType: '5',
-    status: '',
-    name: '',
-    formId: ''
-  };
+  // const defaultParams = {
+  //   dictType: '5',
+  //   status: '',
+  //   name: '',
+  //   formId: ''
+  // };
   export default {
     name: 'index',
     // components: {
@@ -239,7 +239,12 @@
         defaultTemplateList: [],
         userList: [],
         deptList: [],
-        params: { ...defaultParams },
+        params: {
+          status: '',
+          formId: '',
+          createTimeBegin: '',
+          createTimeEnd: ''
+        },
         statusList: [],
         formColumnList: [],
         createTime1: [],
@@ -402,14 +407,14 @@
       }
     },
     watch: {
-    //   'params.formId': {
-    //     handler(val) {
-    //       this.reload();
-    //       this.deptReload();
-    //       this.reload();
-    //       this.noticeReload();
-    //     }
-    //   },
+      'params.formId': {
+        handler(val) {
+          this.reload();
+          // this.deptReload();
+          // this.reload();
+          // this.noticeReload();
+        }
+      },
     //   'params.dictType': {
     //     handler(val) {
     //       this.params.formId = this.templateList[val][0].id;
@@ -466,10 +471,18 @@
                 })) || [];
         console.log('templateList~~~', this.templateList);
         // this.params.dictType = this.dictList['collaborative_type'][0].value;
-        // this.params.formId = this.defaultTemplateList[0]?.id;
-        let makingJson =
-          JSON.parse(this.templateList[0].formJson.makingJson) || {};
-        this.formColumnList = makingJson.list;
+        this.params.formId = this.templateList[0]?.id;
+        console.log('this.params.formId~~~', this.params.formId);
+        // 安全获取第一个模板的formJson数据
+        let makingJson = {};
+        if (this.templateList.length > 0 && this.templateList[0]?.formJson?.makingJson) {
+          try {
+            makingJson = JSON.parse(this.templateList[0].formJson.makingJson) || {};
+          } catch (e) {
+            console.error('解析formJson失败:', e);
+          }
+        }
+        this.formColumnList = makingJson.list || [];
         console.log(this.formColumnList);
       },
       handleStartProcess(i) {
@@ -486,6 +499,7 @@
           pageNo: page,
           pageSize: limit,
           ...where,
+          dictType: '5',
         //   ...this.params,
           processType: '1',
         //   createTimeBegin,
@@ -506,82 +520,89 @@
       /* 刷新表格 */
       reload(where) {
         let find =
-          this.defaultTemplateList.find(
+          this.templateList.find(
             (item) => item.id == this.params.formId
           ) || {};
-        let makingJson = JSON.parse(find.formJson.makingJson) || {};
-        this.formColumnList = makingJson.list;
+        // 安全获取模板的formJson数据
+        let makingJson = {};
+        if (find && find.formJson && find.formJson.makingJson) {
+          try {
+            makingJson = JSON.parse(find.formJson.makingJson) || {};
+          } catch (e) {
+            console.error('解析formJson失败:', e);
+          }
+        }
+        this.formColumnList = makingJson.list || [];
         this.$refs.table.reload({ page: 1, where });
-        this.$refs.table.reRenderTable();
       },
 
       /*  重置 */
       reset() {
         this.params = { ...defaultParams };
         this.createTime1 = [];
-        this.params.dictType = this.dictList['collaborative_type'][0].value;
-        this.params.formId = this.templateList[this.params.dictType][0]?.id;
+        // this.params.dictType = this.dictList['collaborative_type'][0].value;
+        this.params.formId = this.templateList[0]?.id;
 
         this.reload();
       },
       /* 表格数据源 */
-      async deptDatasource({ page, limit, where, order }) {
-        let [createTimeBegin, createTimeEnd] = this.createTime1 || [];
-        let data = await getProcessInstanceDeptPage({
-          pageNo: page,
-          pageSize: limit,
-          ...this.params,
-          processType: '1',
-          createTimeBegin,
-          createTimeEnd
-        });
-        data = data.list.map((item) => {
-          return {
-            ...item,
-            ...item.valueJson
-          };
-        });
-        return data;
-      },
+      // async deptDatasource({ page, limit, where, order }) {
+      //   let [createTimeBegin, createTimeEnd] = this.createTime1 || [];
+      //   let data = await getProcessInstanceDeptPage({
+      //     pageNo: page,
+      //     pageSize: limit,
+      //     ...this.params,
+      //     processType: '1',
+      //     createTimeBegin,
+      //     createTimeEnd
+      //   });
+      //   data = data.list.map((item) => {
+      //     return {
+      //       ...item,
+      //       ...item.valueJson
+      //     };
+      //   });
+      //   return data;
+      // },
       /* 刷新表格 */
-      deptReload(where) {
-        let find =
-          this.defaultTemplateList.find(
-            (item) => item.id == this.params.formId
-          ) || {};
-        let makingJson = JSON.parse(find.formJson.makingJson) || {};
-        this.formColumnList = makingJson.list;
+      // deptReload(where) {
+      //   let find =
+      //     this.defaultTemplateList.find(
+      //       (item) => item.id == this.params.formId
+      //     ) || {};
+      //   let makingJson = JSON.parse(find.formJson.makingJson) || {};
+      //   this.formColumnList = makingJson.list;
 
-        this.$refs.deptTable.reload({ page: 1, where });
-      },
+      //   this.$refs.deptTable.reload({ page: 1, where });
+      // },
       /*  重置 */
-      deptReset() {
-        this.params = { ...defaultParams };
-        this.createTime1 = [];
-        this.params.formId = this.defaultTemplateList[0]?.id;
-        this.params.dictType = this.dictList['collaborative_type'][0].value;
-        this.deptReload();
-      },
+      // deptReset() {
+      //   this.params = { ...defaultParams };
+      //   this.createTime1 = [];
+      //   this.params.formId = this.defaultTemplateList[0]?.id;
+      //   this.params.dictType = this.dictList['collaborative_type'][0].value;
+      //   this.deptReload();
+      // },
       /* 表格数据源 */
-      async noticeDatasource({ page, limit, where, order }) {
-        let [createTimeBegin, createTimeEnd] = this.createTime1 || [];
+      // async noticeDatasource({ page, limit, where, order }) {
+      //   let [createTimeBegin, createTimeEnd] = this.createTime1 || [];
 
-        let data = await getProcessInstanceNoticePage({
-          pageNo: page,
-          pageSize: limit,
-          ...this.params,
-          processType: '1',
-          createTimeBegin,
-          createTimeEnd
-        });
-        data = data.list.map((item) => {
-          return {
-            ...item,
-            ...item.valueJson
-          };
-        });
-        return data;
-      },
+      //   let data = await getProcessInstanceNoticePage({
+      //     pageNo: page,
+      //     pageSize: limit,
+      //     ...this.params,
+      //     processType: '1',
+      //     createTimeBegin,
+      //     createTimeEnd
+      //   });
+      //   data = data.list.map((item) => {
+      //     return {
+      //       ...item,
+      //       ...item.valueJson
+      //     };
+      //   });
+      //   return data;
+      // },
       /**  */
       handleAudit(row) {
         this.$refs.detailRef.open(row.id);