Quellcode durchsuchen

refactor(contractReview): 移除未使用的代码和简化表单处理逻辑

liujt vor 8 Monaten
Ursprung
Commit
ed02fb93b6
1 geänderte Dateien mit 4 neuen und 299 gelöschten Zeilen
  1. 4 299
      src/views/contractManage/contractReview/components/addDialog.vue

+ 4 - 299
src/views/contractManage/contractReview/components/addDialog.vue

@@ -104,23 +104,14 @@
 <script>
   import {
     getModelPage,
-    getProcessDefinitionBpmnXML,
-    getTaskAssignRuleList,
-    listAllUserBind,
-    listSimpleUserGroups,
     processInstanceCreateAPI
   } from './api';
-  import { treeClassifyCodeEnum } from '@/enum/dict';
   import { listRoles } from '@/api/system/role';
-  import { listOrganizations } from '@/api/system/organization';
   import dictMixins from '@/mixins/dictMixins';
-  import { getByCode } from '@/api/system/dictionary-data';
-  import { getGroupUserTree, getProduceTreeByCode } from '@/api/main';
   import { getModel } from '@/api/bpm/model';
   import { getToken } from '@/utils/token-util';
   import { mapGetters } from 'vuex';
   import staffSelection from '@/components/staffSelection/staffSelection.vue';
-  import { topLevel1, topLevel2, topLevel3 } from '@/enum/dict';
   import dayjs from 'dayjs';
   import parentList from '@/views/saleManage/contact/components/parentList.vue';
   export default {
@@ -144,7 +135,6 @@
     },
     data() {
       return {
-        isRight: false,
         jsonData: {},
         form: {
           LCFL: '',
@@ -160,7 +150,6 @@
         formId: '',
         title: '',
         active: 0,
-        bpmnXML: null,
         filterText: null,
         treeList: [],
         treeData: [],
@@ -168,44 +157,20 @@
           children: 'children',
           label: 'name'
         },
-        LCFLList: [],
         processList: [],
         datasource: [],
         roleOptions: [],
-        deptOptions: [],
-        deptTreeOptions: [],
-        postOptions: [],
-        userOptions: [],
-        userGroupOptions: [],
-        dictList: {},
-        rules: {},
         editForm: {
           start: '',
           end: '',
           days: ''
         },
-        componentRef: ['blank_business_component', 'blank_use_seal', 'blank_use_qualification', 'blank_product_specification', 'blank_event_component', 'blank_reissue_component'],
-
       };
     },
     computed: {
       ...mapGetters(['user']),
-      modelWidth() {
-        let width = this.jsonData.config?.platform && this.jsonData.config.platform === 'pc' ? 1100 : 450;
-        if(this.isRight) {
-          return width + 350 + 'px'
-        } else {
-          return width + 'px'
-        }
-      }
     },
     async created() {
-      let typeObj = await getProduceTreeByCode(
-        treeClassifyCodeEnum['PROCESSTYPE']
-      );
-      //  await this.getTreeData();
-      this.LCFLList = typeObj[0].children;
-
       // 获得角色列表
       this.roleOptions = [];
       listRoles({
@@ -214,79 +179,11 @@
       }).then((data) => {
         this.roleOptions.push(...data.list);
       });
-      // 获得部门列表
-      this.deptOptions = [];
-      this.deptTreeOptions = [];
-      listOrganizations().then((data) => {
-        this.deptOptions.push(...data);
-        this.deptTreeOptions.push(...this.handleTree(data, 'id'));
-      });
-      // 获得岗位列表 暂无岗位概念
-      this.postOptions = [];
-      /*listSimplePosts().then(response => {
-this.postOptions.push(...response.data);
-});*/
-      // 获得用户列表
-      this.userOptions = [];
-      listAllUserBind().then((data) => {
-        this.userOptions.push(...data);
-      });
-      // 获得用户组列表
-      this.userGroupOptions = [];
-      listSimpleUserGroups().then((response) => {
-        this.userGroupOptions.push(...response);
-      });
 
-      //this.dictEnum['工作流任务分配自定义脚本']
-      await this.getDictList(this.dictEnum['工作流任务分配自定义脚本']);
-      await this.getDictList(this.dictEnum['工种类型']);
     },
     mounted() {
-      //this.isRight = false
     },
     methods: {
-      async addNewRow(key) {
-        console.log(key);
-        let data = await this.$refs.generateForm.getData(false);
-        data[key].push({
-          price: '',
-          remark: ''
-        });
-        this.$refs.generateForm.setData({
-          key: data[key]
-        });
-      },
-      async delNewRow(key, index) {
-        let data = await this.$refs.generateForm.getData(false);
-        data[key] = data[key].filter((item, index1) => index1 != index);
-        this.$refs.generateForm.setData({
-          [key]: data[key]
-        });
-        this.changePrice(data[key]);
-      },
-      changePrice(data) {
-        let num = 0;
-        data.forEach((item) => {
-          num += Number(item.price);
-        });
-        this.$refs.generateForm.setData({
-          input_jd9ouzyh: num
-        });
-      },
-
-      // 获取组件的中文名称,用于错误提示
-      getComponentName(componentKey) {
-        const nameMap = {
-          'blank_business_component': '差旅交通',
-          'blank_use_seal': '印章使用',
-          'blank_use_qualification': '资质使用',
-          'blank_product_specification': '产品规格',
-          'blank_event_component': '事件',
-          'blank_reissue_component': '补发信息'
-        }
-        return nameMap[componentKey] || componentKey;
-      },
-      
       async addContact(type) {
         console.log(type);
         let data = await this.$refs.generateForm.getData(false);
@@ -361,11 +258,6 @@ this.postOptions.push(...response.data);
             //   });
           }
         });
-        await this.getProcessDefinitionBpmnXMLInfo(this.form.processModelId);
-        await this.getTaskAssignRuleListInfo({
-          modelId: this.form.processModelId,
-          processDefinitionId: this.form.processDefinitionId
-        });
         await this.getDefaultInfo(row.processModelId);
       },
       async getDefaultInfo(businessKey) {
@@ -385,20 +277,6 @@ this.postOptions.push(...response.data);
         const { list } = await getModelPage(params);
         this.processList = list.filter((item) => item.processDefinition);
       },
-      async getProcessDefinitionBpmnXML(val) {
-        this.bpmnXML = await getProcessDefinitionBpmnXML(val);
-      },
-      async getProcessDefinitionBpmnXMLInfo(val) {
-        // 加载流程图
-        let res = await getModel(val);
-        this.bpmnXML = res.bpmnXml;
-      },
-      async getTaskAssignRuleListInfo(find) {
-        this.datasource = await getTaskAssignRuleList({
-          modelId: find.modelId,
-          processDefinitionId: find.processDefinitionId
-        });
-      },
       handleEditDataScope() {
         this.$refs.staffSelection.open(this.form.noticeScope);
       },
@@ -411,191 +289,18 @@ this.postOptions.push(...response.data);
       handleCloseTag(index) {
         this.form.noticeScope.splice(index, 1);
       },
-      getAssignRuleOptionName(row, option) {
-        if (row.type == 10) {
-          for (const roleOption of this.roleOptions) {
-            if (roleOption.id === option) {
-              return roleOption.name;
-            }
-          }
-        } else if (row.type === 20 || row.type === 21) {
-          for (const deptOption of this.deptOptions) {
-            if (deptOption.id === option) {
-              return deptOption.name;
-            }
-          }
-        } else if (row.type === 22) {
-          option = option + ''; // 转换成 string
-          return this.getDictV(this.dictEnum['工种类型'], option);
-        } else if (row.type === 30 || row.type === 31 || row.type === 32) {
-          for (const userOption of this.userOptions) {
-            if (userOption.id === option) {
-              return userOption.nickname || userOption.name;
-            }
-          }
-        } else if (row.type === 40) {
-          for (const userGroupOption of this.userGroupOptions) {
-            if (userGroupOption.id === option) {
-              return userGroupOption.name;
-            }
-          }
-        } else if (row.type === 50) {
-          option = option + ''; // 转换成 string
-          return this.getDictV(
-            this.dictEnum['工作流任务分配自定义脚本'],
-            option
-          );
-        } else if (row.type === 60) {
-          return row.variableName;
-        } else if (row.type === 70) {
-          let data = JSON.parse(row.variableName);
-          if (data.direction == 1) {
-            return topLevel2.find((item) => item.value == data.topLevel)?.label;
-          } else {
-            return topLevel1.find((item) => item.value == data.topLevel)?.label;
-          }
-        } else if (row.type === 80) {
-          let data = JSON.parse(row.variableName);
-          return topLevel3.find((item) => item.value == data.topLevel)?.label;
-        }
-        return '未知(' + option + ')';
-      },
-      async getTreeData() {
-        this.treeData = await getGroupUserTree();
-      },
-      filterNode(value, data) {
-        if (!value) return true;
-        return data.name.indexOf(value) !== -1;
-      },
-      /**
-       * 构造树型结构数据
-       * @param {*} data 数据源
-       * @param {*} id id字段 默认 'id'
-       * @param {*} parentId 父节点字段 默认 'parentId'
-       * @param {*} children 孩子节点字段 默认 'children'
-       * @param {*} rootId 根Id 默认 0
-       */
-      handleTree(data, id, parentId, children, rootId) {
-        id = id || 'id';
-        parentId = parentId || 'parentId';
-        children = children || 'children';
-        rootId =
-          rootId ||
-          Math.min.apply(
-            Math,
-            data.map((item) => {
-              return item[parentId];
-            })
-          ) ||
-          0;
-        //对源数据深度克隆
-        const cloneData = JSON.parse(JSON.stringify(data));
-        //循环所有项
-        const treeData = cloneData.filter((father) => {
-          let branchArr = cloneData.filter((child) => {
-            //返回每一项的子级数组
-            return father[id] == child[parentId];
-          });
-          branchArr.length > 0 ? (father.children = branchArr) : '';
-          //返回第一层
-          return father[parentId] == rootId;
-        });
-        return treeData !== '' ? treeData : data;
-      },
-      getDictV(code, val) {
-        if (!this.dictList[code]) return '';
-        return this.dictList[code].find((item) => item.value == val)?.label;
-      },
-      async getDictList(code) {
-        let { data: res } = await getByCode(code);
-        this.dictList[code] = res.map((item) => {
-          let values = Object.keys(item);
-          return {
-            value: values[0],
-            label: item[values[0]]
-          };
-        });
-      },
+
+
       generateFormValid(validate = true) {
         return this.$refs.generateForm.getData(validate).then((data) => {
           return data;
         });
       },
-      handleTreeChange() {
-        this.$nextTick(() => {
-          this.form.noticeScope =
-            this.$refs.treeSelect.$refs.tree.getCheckedNodes();
-          console.log(this.form.noticeScope);
-        });
-      },
-      async changeLCFL(val) {
-        this.bpmnXML = null;
-        this.form.processDefinitionId = null;
-        this.form.FQLC = null;
-        await this.getProcessList(val);
-      },
-      async changeFQLC(val) {
-        if (!val) return;
-        let find = this.processList.find((item) => item.id === val) || {};
-        this.form.name = find.name;
-        this.form.key = find.key;
-        this.form.processDefinitionId = find.processDefinition.id;
-        this.form.processModelId = val;
-        await this.getProcessDefinitionBpmnXML(find.processDefinition.id);
-        await this.getTaskAssignRuleListInfo({
-          modelId: find.id,
-          processDefinitionId: find.processDefinition.id
-        });
-      },
+
       async submit() {
-        // console.log('this.form~~~', this.$refs.businessComponentRef.form);
-        
-        // const businessComponentForm = this.$refs.businessComponentRef.form;
+
         let data = await this.$refs.generateForm.getData(false);
-        // data['blank_business_component'] = businessComponentForm.blank_business_component;
-        // this.$refs.generateForm.setData({
-        //   'blank_business_component': data['blank_business_component']
-        // });
-        // 获取所有组件的引用
-        let validArr = []
-        // 过滤出存在于componentRef中的键
-        Object.keys(data).forEach((key) => {
-          if (this.componentRef.includes(key)) {
-            validArr.push(key)
-          }
-        })
-        
-        // 检查每个组件的数据是否为空数组
-        let emptyComponents = []
-        validArr.forEach(item => {
-          // 检查data[item]是否存在且为数组,并且长度为0
-          if (Array.isArray(data[item]) && data[item].length === 0) {
-            emptyComponents.push(item)
-          }
-        })
-        
-        // 如果有未填写的组件,显示提示信息
-        if (emptyComponents.length > 0) {
-          // this.$message.warning(`请填写完整信息:${emptyComponents.map(comp => this.getComponentName(comp)).join('、')}`);
-          this.$message.warning(`请填写完整信息`);
-          return false;
-        }
         
-        // 使用Promise.all并行校验所有组件
-        // try {
-        //   await Promise.all(validArr.map(key => {
-        //     if (this.$refs[key] && typeof this.$refs[key].validateForm === 'function') {
-        //       return this.$refs[key].validateForm();
-        //     }
-        //     return Promise.resolve(true); // 如果组件不存在或没有validateForm方法,默认通过
-        //   }));
-        //   console.log('所有组件校验通过');
-        // } catch (error) {
-        //   console.error('表单校验失败:', error);
-        //   this.$message.error('表单校验失败,请检查必填项');
-        //   return false; // 任一组件校验失败则整体失败
-        // }
-        // console.log('data~~~~', data);
         this.form.valueJson = await this.generateFormValid()
         this.form.processType = '1';
         console.log('formformformform', this.form);