lex-xin 3 роки тому
батько
коміт
2cc7d05126

+ 92 - 45
src/components/VueFormMaking/components/GenerateForm.vue

@@ -54,7 +54,8 @@
           </el-form-item>
         </template>
         <!-- 子表单 -->
-        <template v-else-if="item.type === 'subform'">
+        <template v-else-if="item.type === 'subform' && !item.hidden">
+          <!-- <span :key="item.key">{{ item.type }}{{ item.hidden }}---</span> -->
           <el-form-item
             :key="item.key"
             :label-width="!item.options.labelWidthStatus ? '0px' : 150 + 'px'"
@@ -106,12 +107,14 @@
                         :remote="remote"
                         :data="data"
                         :disabled="disabled"
+                        :fileCheck="fileCheck"
                         :is-label="false"
                         :organ-list="itemOrganList"
                         :cooperation-list="cooperationList"
                         :subform-index="scope.$index"
                         :subform-model="item.model"
                         @relationFormChange="relationFormChange"
+                        @fileCheckRequired="fileCheckRequired"
                       />
                     </template>
                   </el-table-column>
@@ -133,6 +136,7 @@
             :organ-list="itemOrganList"
             :disabled="disabled"
             @relationFormChange="relationFormChange"
+            @fileCheckRequired="fileCheckRequired"
           />
         </template>
       </template>
@@ -160,10 +164,12 @@ export default {
   ],
   data() {
     return {
+      fileCheck: false,
       templateData: [], // 临时对象
       formStatus: false,
       tableData: [],
       models: {},
+      originRules: {}, // 原始规则
       rules: {},
       subformFields: {},
       itemOrganList: [],
@@ -183,47 +189,76 @@ export default {
       handler(val) {
         this.models = { ...this.models, ...val };
       }
+    },
+    fileCheck: {
+      deep: true,
+      handler(val) {
+        // // 监听是否必填
+        // if(val) {
+        //   this.changeFormRulesRequired();
+        // } else {
+        //   this.rules = JSON.parse(JSON.stringify(this.rules));
+        // }
+      }
     }
   },
   created() {
     this.itemOrganList = this.organList;
-    this.templateData = this.data.list
+    this.templateData = JSON.parse(JSON.stringify(this.data.list));
     this.generateModle(this.templateData);
-
     // 选项关联不支付子表单
     if (!this.preview) {
       let tempData = this.templateData;
       let hiddenFormList = this.getSelectValueObject(tempData);
       this.formStatus = hiddenFormList;
       this.relationFormChange();
-
       // 如果不是预览时,则默认给子表单添加一行数据
-      tempData.forEach(item => {
+      tempData.forEach(async (item) => {
         if (item.type === "subform") {
-          this.addSubformCol(item);
+          await this.addSubformCol(item);
         }
       });
     } else {
-      let tempData = this.templateData
+      let tempData = this.templateData;
       let hiddenFormList = this.getSelectValueObject(tempData);
       this.formStatus = hiddenFormList;
-      let ids = this.getSelectValueObject(tempData, true)
+      let ids = this.getSelectValueObject(tempData, true);
 
-      const values = this.models[ids.model]
-      let relationArray = []
-      ids.options && ids.options.options.forEach(item => {
-          if(values == item.value) {
-              let tempRelation = item.relationOptions || []
-              relationArray.push(...tempRelation)
+      const values = this.models[ids.model];
+      let relationArray = [];
+      ids.options &&
+        ids.options.options.forEach(item => {
+          if (values == item.value) {
+            let tempRelation = item.relationOptions || [];
+            relationArray.push(...tempRelation);
           }
-      })
-      if(relationArray.length > 0) {
-          this.relationFormChange(relationArray)
+        });
+      if (relationArray.length > 0) {
+        this.relationFormChange(relationArray);
       }
     }
+
+    this.originRules = JSON.parse(JSON.stringify(this.rules));
   },
-  mounted() {},
   methods: {
+    changeFormRulesRequired() {
+      const rules = this.rules || []
+      for(let rule in rules) {
+        // 判断是否是子表单
+        if(rule.indexOf('subform') >= 0 && rule) {
+          // 子表单有多个
+          rules[rule].forEach(subItem => {
+            for(let sub in subItem) {
+              subItem[sub].forEach(last => {
+                last['required'] = false
+              });
+            }
+          })
+        }
+      }
+      this.rules = rules
+      this.$forceUpdate()
+    },
     addSubformCol(item) {
       var subformFields = {};
       for (var c of item.columns) {
@@ -251,23 +286,30 @@ export default {
               if (item.pattern) {
                 return { ...item, pattern: eval(item.pattern) };
               } else {
+                if(this.fileCheck) {
+                  item.required = false
+                }
                 return { ...item };
               }
             })
           ];
         }
       }
+      this.originRules = JSON.parse(JSON.stringify(this.rules));
+      // if(this.fileCheck) {
+      //   this.changeFormRulesRequired()
+      // }
       this.models[item.model].push(subformFields);
       this.models.status = 1;
     },
     getSelectValueObject(tpls, relationStatus) {
       let tempList = tpls || [];
       let status = false;
-      let relationId = ''
+      let relationId = "";
       tempList.forEach(list => {
         if (list.type == "select" && list.options.relationStatus) {
           status = true;
-          relationId = list
+          relationId = list;
         }
         if (list.type == "subform") {
           let childList = list.columns || [];
@@ -276,7 +318,7 @@ export default {
             childList.forEach(c => {
               if (c.type == "select" && list.options.relationStatus) {
                 status = true;
-                relationId = list
+                relationId = list;
               }
             });
           });
@@ -284,6 +326,10 @@ export default {
       });
       return relationStatus ? relationId : status;
     },
+    // 处理是否需要校验
+    fileCheckRequired(state) {
+      this.fileCheck = state;
+    },
     relationFormChange(value) {
       // false 为显示,true 为隐藏
       let temp = value || [];
@@ -308,34 +354,35 @@ export default {
         // 子表单  不支持子表单,根据不同的类型显示不同
         if (item.type == "subform") {
           let childList = item.columns || []
-          (item.columns || []).forEach(child => {
-            if (child.list.length > 0) {
-              child.list.forEach(c => {
-                // c.hidden = true
-                if (this.formStatus) {
-                  if (
-                    c.type != "text" &&
-                    c.type != "subform" &&
-                    !c.options.relationStatus
-                  ) {
-                    c.hidden = true;
+          childList.forEach(child => {
+              if (child.list.length > 0) {
+                child.list.forEach(c => {
+                  // c.hidden = true
+                  if (this.formStatus) {
+                    if (
+                      c.type != "text" &&
+                      c.type != "subform" &&
+                      !c.options.relationStatus
+                    ) {
+                      c.hidden = true;
+                    } else {
+                      c.hidden = false;
+                    }
+                    if (temp.includes(c.model)) {
+                      c.hidden = false;
+                    }
                   } else {
                     c.hidden = false;
                   }
-                  if (temp.includes(c.originModel)) {
-                    c.hidden = false;
-                  }
-                } else {
-                  c.hidden = false;
-                }
-              });
-            }
-          });
+                });
+              }
+            });
           // 重置数据
-          let subForm = this.$refs.subform;
-          subForm && subForm.forEach(item => {
-            item.reSetFormData();
-          });
+          // let subForm = this.$refs.subform;
+          // subForm &&
+          //   subForm.forEach(item => {
+          //     item.reSetFormData();
+          //   });
           let subFormStatus = true;
           childList.forEach(child => {
             if (child.list.length > 0) {

+ 15 - 1
src/components/VueFormMaking/components/GenerateFormItem.vue

@@ -1,7 +1,7 @@
 <template>
   <el-form-item
     v-if="showStatus && !widget.hidden"
-    :label-width="isLabel===false||!widget.options.labelWidthStatus?'0px': widgetLabelWidth + 'px'"
+    :label-width="isLabel===false||!widget.options.labelWidthStatus?'0px': 150 + 'px'"
     :label="isLabel===false||widget.type==='divider' || !widget.options.labelWidthStatus?'':widget.name"
     :prop="propValue"
     :class="parentForm"
@@ -516,6 +516,9 @@ export default {
           this.$emit('relationFormChange', relationArray)
       }
     },
+    fileCheckRequired(state) {
+      this.$emit('fileCheckRequired', state)
+    },
     async onGetSchoolList(val) {
       // 隐藏的时候的不获取数据,
       // 为什么每次都需要请求,因为我没有判断分部数据是否有修改
@@ -580,6 +583,17 @@ export default {
       this.dataModel = v;
     },
     fileList(files) {
+      // 只处理乐团退费
+      const query = this.$route.query
+      if(query.processId == 19) {
+        if(files && files.length > 0) {
+          this.$emit('fileCheckRequired', true)
+        } else {
+          this.$emit('fileCheckRequired', false)
+        }
+      } else {
+        this.$emit('fileCheckRequired', false)
+      }
       this.dataModel = files
     },
     handleDisplayVerifiy() {

+ 265 - 64
src/views/process/list/create.vue

@@ -29,10 +29,17 @@
             style="margin-bottom: 0"
           >
             <el-select v-model="ruleForm.deptId" size="small" clearable>
-              <el-option v-for="(item, index) in deptList" :label="item.deptName" :value="item.deptId" :key="index"></el-option>
+              <el-option
+                v-for="(item, index) in deptList"
+                :label="item.deptName"
+                :value="item.deptId"
+                :key="index"
+              ></el-option>
             </el-select>
             <span v-if="!socialId && currentNode.id">(未设置社保部门)</span>
-            <span v-if="ruleForm.deptId && socialId != ruleForm.deptId">(该部门非社保部门)</span>
+            <span v-if="ruleForm.deptId && socialId != ruleForm.deptId"
+              >(该部门非社保部门)</span
+            >
           </el-form-item>
         </el-form>
       </div>
@@ -53,14 +60,18 @@
             :key="tplIndex"
             :ref="'generateForm-' + tplItem.id"
             :preview="
-              currentNode.hideTpls === undefined || currentNode.hideTpls === null || currentNode.hideTpls.indexOf(tplItem.id) === -1
+              currentNode.hideTpls === undefined ||
+              currentNode.hideTpls === null ||
+              currentNode.hideTpls.indexOf(tplItem.id) === -1
                 ? false
                 : true
             "
             :remote="remoteFunc"
             :data="tplItem.form_structure"
             :disabled="
-              currentNode.readonlyTpls === undefined || currentNode.readonlyTpls === null || currentNode.readonlyTpls.indexOf(tplItem.id) === -1
+              currentNode.readonlyTpls === undefined ||
+              currentNode.readonlyTpls === null ||
+              currentNode.readonlyTpls.indexOf(tplItem.id) === -1
                 ? null
                 : true
             "
@@ -70,11 +81,14 @@
       </div>
       <hr style="background-color: #d9d9d9; border:0; height:1px;" />
       <div class="text item" style="text-align: center;margin-top:18px">
-        <el-button v-for="(item, index) in btn_group"
+        <el-button
+          v-for="(item, index) in btn_group"
           :key="index"
           :type="item.className"
           :disabled="submitDisabled"
-          @click="submitAction(item.target)">提交</el-button>
+          @click="submitAction(item.target)"
+          >提交</el-button
+        >
       </div>
     </el-card>
   </div>
@@ -86,7 +100,13 @@ import { GenerateForm } from "@/components/VueFormMaking";
 import "form-making/dist/FormMaking.css";
 Vue.component(GenerateForm.name, GenerateForm);
 
-import { processStructure, createWorkOrder, checkCourseReturnFee, queryAllOrgan, queryUserInfo } from "@/api/process/work-order";
+import {
+  processStructure,
+  createWorkOrder,
+  checkCourseReturnFee,
+  queryAllOrgan,
+  queryUserInfo
+} from "@/api/process/work-order";
 import { listUser } from "@/api/system/sysuser";
 export default {
   name: "Create",
@@ -139,92 +159,270 @@ export default {
     };
   },
   async created() {
-    await this.getUserInfo()
-    this.getAllOrgan()
-    this.getProcessNodeList()
+    await this.getUserInfo();
+    this.getAllOrgan();
+    this.getProcessNodeList();
   },
   methods: {
     async getUserInfo() {
       await queryUserInfo().then(res => {
-        console.log(res)
-        if(res.code == 200) {
-          this.userId = res.data.id
-          this.tenantId = res.data.tenantId
+        if (res.code == 200) {
+          this.userId = res.data.id;
+          this.tenantId = res.data.tenantId;
         } else {
-          this.$message.error(res.data)
+          this.$message.error(res.data);
         }
-      })
+      });
     },
-    getAllOrgan() { // 获取分部
+    getAllOrgan() {
+      // 获取分部
       queryAllOrgan({ tenantId: this.tenantId }).then(res => {
         if (res.code == 200) {
           const result = res.data;
-          const filterOrganId = [36, 39, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 52, 54, 55, 56]
-          let tempOrgan = []
+          const filterOrganId = [
+            36,
+            39,
+            41,
+            42,
+            43,
+            44,
+            45,
+            46,
+            47,
+            48,
+            49,
+            50,
+            52,
+            54,
+            55,
+            56
+          ];
+          let tempOrgan = [];
           // 过滤不会显示的分部
           result.forEach(item => {
             if (!filterOrganId.includes(item.id)) {
-              tempOrgan.push(item)
+              tempOrgan.push(item);
             }
-          })
-          this.organList = tempOrgan
+          });
+          this.organList = tempOrgan;
         }
-      })
+      });
     },
     getProcessNodeList() {
       processStructure({
         processId: this.$route.query.processId,
         userId: this.userId
       }).then(response => {
-        this.processStructureValue = response.data
-        this.currentNode = this.processStructureValue.nodes[0]
+        let tempData = response.data.tpls;
+        console.log(response);
+        // 获取对应模板中,下拉框的key, value
+        let selectList = this.getSelectValueObject(tempData);
+        console.log(selectList);
+
+        // 获取对应模板中,需要隐藏的字段
+        let hiddenFormList = this.getSelectValueObject(
+          tempData,
+          "hiddenForm",
+          selectList
+        );
 
-        this.deptList = response.data.depts || []
-        const defaultDept = response.data.deptId
-        this.socialId = defaultDept
+        tempData.forEach((temp, index) => {
+          let tempList = temp.form_structure.list || [];
+          tempList.forEach(item => {
+            if (hiddenFormList[index].length > 0) {
+              if (item.type != "text" && !item.options.relationStatus) {
+                item.hidden = true;
+              } else {
+                item.hidden = false;
+              }
+              // item.hidden = false
+              if (hiddenFormList[index].includes(item.model)) {
+                item.hidden = false;
+              }
+            } else {
+              item.hidden = false;
+            }
+            // 子表单
+            if (item.type == "subform") {
+              let childList = item.columns || [];
+              let subFormStatus = true;
+              childList.forEach(child => {
+                let childList = child.list || [];
+                childList.forEach(c => {
+                  if (hiddenFormList[index].length > 0) {
+                    if (c.type != "text" && !c.options.relationStatus) {
+                      c.hidden = true;
+                    } else {
+                      c.hidden = false;
+                      subFormStatus = false;
+                    }
+                    if (hiddenFormList[index].includes(c.model)) {
+                      c.hidden = false;
+                      subFormStatus = false;
+                    }
+                  } else {
+                    c.hidden = false;
+                    subFormStatus = false;
+                  }
+                });
+              });
+              item.hidden = subFormStatus;
+            }
+          });
+        });
+
+        this.processStructureValue = response.data;
+        this.currentNode = this.processStructureValue.nodes[0];
+
+        this.deptList = response.data.depts || [];
+        const defaultDept = response.data.deptId;
+        this.socialId = defaultDept;
         this.deptList.forEach((item, index) => {
           if (defaultDept) {
             if (item.deptId == defaultDept) {
-              this.deptName = item.deptName
-              this.ruleForm.deptId = item.deptId
+              this.deptName = item.deptName;
+              this.ruleForm.deptId = item.deptId;
             }
           } else {
             if (index == 0) {
-              this.deptName = item.deptName
-              this.ruleForm.deptId = item.deptId
+              this.deptName = item.deptName;
+              this.ruleForm.deptId = item.deptId;
             }
           }
-          item.text = item.deptName
-        })
+          item.text = item.deptName;
+        });
 
-        const psv = response.data.edges || []
-        const btn_group = []
+        const psv = response.data.edges || [];
+        const btn_group = [];
         psv.forEach(item => {
           if (item.source === this.currentNode.id && item.flowProperties == 1) {
             if (item.flowProperties == 1) {
-              item.className = "primary"
+              item.className = "primary";
             } else if (item.flowProperties == 0) {
-              item.className = "danger"
+              item.className = "danger";
             } else if (item.flowProperties == 2) {
-              item.className = "primary"
+              item.className = "primary";
             }
-            btn_group.push(item)
+            btn_group.push(item);
           } else {
-            item.className = "primary"
+            item.className = "primary";
           }
         });
-        this.btn_group = btn_group
+        this.btn_group = btn_group;
         if (!this.socialId && this.deptList.length <= 0) {
           // this.$dialog.alert({
           //   message: "您当前暂未设置所属部门,请联系管理员",
           //   confirmButtonColor: "#01C1B5"
           // })
-          this.$alert('您当前暂未设置所属部门,请联系管理员', '提示', {
-          confirmButtonText: '确定',
-          callback: action => {}
+          this.$alert("您当前暂未设置所属部门,请联系管理员", "提示", {
+            confirmButtonText: "确定",
+            callback: action => {}
+          });
+        }
+      });
+    },
+    getSelectValueObject(tpls, type = "value", tplValues = []) {
+      const tempData = tpls || [];
+      let selectList = [];
+      tempData.forEach((temp, index) => {
+        let tempList = temp.form_structure.list || [];
+        let tempSelectList = tplValues[index] || [];
+        let listArray = [];
+        tempList.forEach(list => {
+          if (list.type == "select") {
+            if (type == "value") {
+              const result = this.getFormDataDetail(temp.form_data, list.model);
+              if (result.status) {
+                listArray.push(result);
+              }
+            } else {
+              let selectOptions = [];
+              let selectValue = [];
+              tempSelectList.forEach(tsl => {
+                if (tsl.model == list.model) {
+                  selectOptions = list.options.options || [];
+                  selectValue = tsl.value || [];
+                }
+              });
+              selectOptions.forEach(so => {
+                if (selectValue.includes(so.value)) {
+                  let tempRo = so.relationOptions || [];
+                  listArray.push(...tempRo);
+                }
+              });
+            }
+          }
+          if (list.type == "subform") {
+            let childList = list.columns || [];
+            childList.forEach(child => {
+              let childList = child.list || [];
+              childList.forEach(c => {
+                if (c.type == "select") {
+                  if (type == "value") {
+                    const originObj = JSON.parse(JSON.stringify(c));
+                    const result = this.getFormDataDetail(
+                      temp.form_data,
+                      originObj.model
+                    );
+                    if (result.status) {
+                      listArray.push(result);
+                    }
+                  } else {
+                    let selectOptions = [];
+                    let selectValue = [];
+                    tempSelectList.forEach(tsl => {
+                      if (tsl.model == c.model) {
+                        selectOptions = c.options.options || [];
+                        selectValue = tsl.value || [];
+                      }
+                    });
+                    selectOptions.forEach(so => {
+                      if (selectValue.includes(so.value)) {
+                        let tempRo = so.relationOptions || [];
+                        listArray.push(...tempRo);
+                      }
+                    });
+                  }
+                }
+              });
+            });
+          }
         });
+        selectList.push(listArray);
+      });
+      return selectList;
+    },
+    // 获取对应元素的值
+    getFormDataDetail(formData, model) {
+      let modelStatus = {
+        status: false,
+        value: null
+      };
+      for (let data in formData) {
+        if (typeof formData[data] == "object") {
+          // 没有子表单里面有子表单
+          for (let child in formData[data]) {
+            if (child == model) {
+              modelStatus = {
+                status: true,
+                model: child,
+                value: formData[data][child]
+                  ? formData[data][child].split(",")
+                  : []
+              };
+            }
+          }
+        } else {
+          if (data == model) {
+            modelStatus = {
+              status: true,
+              model: data,
+              value: formData[data] ? formData[data].split(",") : []
+            };
+          }
         }
-      })
+      }
+      return modelStatus;
     },
     submitAction(target) {
       this.$refs["ruleForm"].validate(valid => {
@@ -280,30 +478,33 @@ export default {
             promiseList.push(this.$refs["generateForm-" + tpl.id][0].getData());
           }
           Promise.all(promiseList)
-            .then(async (values) => {
+            .then(async values => {
               this.ruleForm.source = this.processStructureValue.nodes[
                 this.active
               ].id;
               this.ruleForm.tpls.form_data = values;
-              const formData = values[0]
-              const tplInfo = this.processStructureValue.tpls[0] // 默认只用第一个模板
-              console.log(this.ruleForm.tpls.form_data)
+              const formData = values[0];
+              const tplInfo = this.processStructureValue.tpls[0]; // 默认只用第一个模板
+              console.log(this.ruleForm.tpls.form_data);
               // 校验数据
-              const res = await checkCourseReturnFee({tplInfoId: tplInfo.id, formData })
-              if(res.code == 200){
+              const res = await checkCourseReturnFee({
+                tplInfoId: tplInfo.id,
+                formData
+              });
+              if (res.code == 200) {
                 await createWorkOrder(this.ruleForm)
-                .then(response => {
-                  if (response.code === 200) {
-                    this.$message.success('工单申请成功')
-                    this.$router.push({ path: "/process/my-create" });
-                  }
-                })
-                .catch(() => {
-                  this.submitDisabled = false;
-                });
-              }else{
-                this.$message.error(res.message)
-                return
+                  .then(response => {
+                    if (response.code === 200) {
+                      this.$message.success("工单申请成功");
+                      this.$router.push({ path: "/process/my-create" });
+                    }
+                  })
+                  .catch(() => {
+                    this.submitDisabled = false;
+                  });
+              } else {
+                this.$message.error(res.message);
+                return;
               }
             })
             .catch(() => {

Різницю між файлами не показано, бо вона завелика
+ 0 - 0
web/index.html


Різницю між файлами не показано, бо вона завелика
+ 0 - 0
web/static/web/js/chunk-73f7679b.aa1276e5.js


Різницю між файлами не показано, бо вона завелика
+ 0 - 0
web/static/web/js/chunk-73f7679b.f56f89ec.js


Деякі файли не було показано, через те що забагато файлів було змінено