Browse Source

11482-【CR】【投资系统】增加审批流程-更改表单导致页面无法加载

hxy 3 months ago
parent
commit
f2c35fc4ff

+ 9 - 2
ruoyi-ui/src/components/Process/components/nodePanel/task.vue

@@ -488,7 +488,7 @@ export default {
       if (attrs.hasOwnProperty("flowable:assignee")) {
         const val = attrs["flowable:assignee"];
         // 查找是否动态指定人员(选中流程表达式)
-        if (attrs["flowable:dataType"] === "dynamic") {
+        if (attrs["flowable:dataType"] === "dynamic"||(attrs["flowable:dataType"] === "fixed"&&this.isFlowableExpression(attrs["flowable:assignee"]) == true)) {
           this.checkValues = that.expList.find(item => item.expression == val).name;
           this.selectValues = that.expList.find(item => item.expression == val).id;
         } else {
@@ -537,6 +537,13 @@ export default {
       }
       this.dialogName = ''
     },
+    isFlowableExpression(value) {
+      // 正则:严格匹配 ${任意内容}
+      const expressionPattern = /^\$\{[\s\S]*\}$/;
+      return expressionPattern.test(value);
+    },
+
+// ------ 流程审批人员信息弹出框 start---------
     /*单选人员*/
     singleUserCheck(){
       this.userVisible = true;
@@ -565,7 +572,7 @@ export default {
     // 选中表达式
     handleSingleExpSelect(selection) {
       this.deleteFlowAttar();
-      this.updateProperties({'flowable:dataType': 'dynamic'})
+      this.updateProperties({'flowable:dataType':selection.dataType})
       if ("assignee" === this.expType) {
         this.updateProperties({'flowable:assignee': selection.expression});
       } else if ("candidateUsers" === this.expType) {

+ 94 - 7
ruoyi-ui/src/views/flowable/task/myProcess/send/index.vue

@@ -10,8 +10,23 @@
         <el-tab-pane label="表单信息" name="1">
             <!--初始化流程加载表单信息-->
             <el-col :span="16" :offset="4">
-              <div class="test-form">
+<!--              <div class="test-form">
                 <parser :key="new Date().getTime()" :form-conf="formConf" @submit="submitForm" ref="parser" @getData="getData" />
+              </div>-->
+              <v-form-render :form-data="formRenderData" ref="vFormRef"/>
+              <div style="margin-left:15%;margin-bottom: 20px;font-size: 14px;">
+<!--                <el-button type="primary" @click="submitForm">提 交</el-button>
+                <el-button type="primary" @click="resetForm">重 置</el-button>-->
+                <el-button @click="goBack">返 回</el-button>
+<!--                <el-button
+                  type="warning"
+                  @click="submitForm(1)"
+                  v-preventReClick
+                  v-if="!form.projectState || form.projectState == '1'"
+                >暂 存</el-button
+                >-->
+                <el-button type="warning" @click="submitForm(false)">暂 存</el-button>
+                <el-button type="primary" @click="submitForm(true)" v-preventReClick>提 交</el-button>
               </div>
             </el-col>
         </el-tab-pane>
@@ -68,7 +83,8 @@ export default {
       loading: true,
       deployId: "",  // 流程定义编号
       procDefId: "",  // 流程实例编号
-      formConf: {}, // 默认表单数据
+      //formConf: {}, // 默认表单数据
+      formRenderData: {},// 默认表单数据
       variables: [], // 流程变量数据
       taskTitle: null,
       taskOpen: false,
@@ -77,7 +93,8 @@ export default {
       checkType: '', // 选择类型
       checkValues: null, // 选中任务接收人员数据
       formData: {}, // 填写的表单数据,
-      multiInstanceVars: '' // 会签节点
+      multiInstanceVars: '', // 会签节点
+      formJson: {} // 表单json
     };
   },
   created() {
@@ -101,7 +118,12 @@ export default {
       const params = {deployId: deployId}
       flowFormData(params).then(res => {
         // 流程过程中不存在初始化表单 直接读取的流程变量中存储的表单值
-          that.formConf = res.data;
+          //that.formConf = res.data;
+        this.$nextTick(() => {
+          // 回显数据
+          this.$refs.vFormRef.setFormJson(res.data);
+          this.formJson = res.data;
+        })
       }).catch(res => {
         this.goBack();
       })
@@ -135,9 +157,9 @@ export default {
       }
     },
     /** 申请流程表单数据提交 */
-    submitForm(formData) {
+    submitForm(flag) {
       // 根据当前任务或者流程设计配置的下一步节点 todo 暂时未涉及到考虑网关、表达式和多节点情况
-      getNextFlowNodeByStart({deploymentId: this.deployId,variables:formData.valData}).then(res => {
+     /* getNextFlowNodeByStart({deploymentId: this.deployId,variables:formData.valData}).then(res => {
         const data = res.data;
         if (data) {
           this.formData = formData;
@@ -173,8 +195,56 @@ export default {
             }
           }
         }
+      })*/
+      this.$refs.vFormRef.getFormData().then(formData => {
+        formData.auditPass=flag;
+        // 根据当前任务或者流程设计配置的下一步节点 todo 暂时未涉及到考虑网关、表达式和多节点情况
+        getNextFlowNodeByStart({deploymentId: this.deployId, variables: formData}).then(res => {
+          const data = res.data;
+          debugger
+          if (data) {
+            this.formData = formData;
+            if (data.dataType === 'dynamic') {
+              if (data.type === 'assignee') { // 指定人员
+                this.checkSendUser = true;
+                this.checkType = "single";
+              } else if (data.type === 'candidateUsers') {  // 候选人员(多个)
+                this.checkSendUser = true;
+                this.checkType = "multiple";
+              } else if (data.type === 'candidateGroups') { // 指定组(所属角色接收任务)
+                this.checkSendRole = true;
+              } else { // 会签
+                // 流程设计指定的 elementVariable 作为会签人员列表
+                this.multiInstanceVars = data.vars;
+                this.checkSendUser = true;
+                this.checkType = "multiple";
+              }
+              this.taskOpen = true;
+              this.taskTitle = "选择任务接收";
+            } else {
+              if (this.procDefId) {
+                const param = {
+                  formJson:  this.formJson,
+                }
+                // 复制对象的属性值给新的对象
+                Object.assign(param, formData);
+                // 启动流程并将表单数据加入流程变量
+                definitionStart(this.procDefId, param).then(res => {
+                  this.$modal.msgSuccess(res.msg);
+                  this.goBack();
+                })
+              }
+            }
+          }
+        })
+      }).catch(error => {
+        // this.$modal.msgError(error)
       })
     },
+    /** 重置表单 */
+    resetForm() {
+      this.$refs.vFormRef.resetForm();
+    },
     /** 提交流程 */
     submitTask() {
       if (!this.checkValues && this.checkSendUser){
@@ -185,7 +255,7 @@ export default {
         this.$modal.msgError("请选择流程接收角色组!");
         return;
       }
-      if (this.formData) {
+      /*if (this.formData) {
         const variables = this.formData.valData;
         const formData = this.formData.formData;
         // 表单是否禁用
@@ -204,6 +274,23 @@ export default {
           this.$modal.msgSuccess(res.msg);
           this.goBack();
         })
+      }*/
+      if (this.formData) {
+        const param = {
+          formJson:  this.formJson,
+        }
+        // 复制对象的属性值给新的对象
+        Object.assign(param, this.formData);
+        if (this.multiInstanceVars) {
+          this.$set(param, this.multiInstanceVars, this.checkValues);
+        } else {
+          this.$set(param, "approval", this.checkValues);
+        }
+        // 启动流程并将表单数据加入流程变量
+        definitionStart(this.procDefId, param).then(res => {
+          this.$modal.msgSuccess(res.msg);
+          this.goBack();
+        })
       }
     },
     /** 根据当前任务获取流程设计配置的下一步节点 */

+ 77 - 15
ruoyi-ui/src/views/flowable/task/todo/detail/index.vue

@@ -4,15 +4,15 @@
       <div slot="header" class="clearfix">
         <span class="el-icon-document">待办任务</span>
         <el-tag style="margin-left:10px">发起人:{{ startUser }}</el-tag>
-        <el-tag>任务节点:{{ taskName }}</el-tag>
+        <el-tag>任务节点:{{ taskName }}||{{ taskDefKey }}</el-tag>
         <el-button style="float: right;" size="mini" type="danger" @click="goBack">关闭</el-button>
       </div>
       <el-tabs tab-position="top" v-model="activeName" @tab-click="handleClick">
         <!--表单信息-->
         <el-tab-pane label="表单信息" name="1">
           <el-col :span="16" :offset="4">
-            <div class="test-form">
-              <!--              <parser :key="new Date().getTime()" :form-conf="variablesData"/>-->
+<!--            <div class="test-form">
+              &lt;!&ndash;              <parser :key="new Date().getTime()" :form-conf="variablesData"/>&ndash;&gt;
               <parser :key="new Date().getTime()" :form-conf="variablesData" @submit="submitForm" ref="parser"/>
 
             </div>
@@ -20,11 +20,24 @@
               <el-button v-if="!formKeyExist" icon="el-icon-edit-outline" type="success" size="mini"
                          @click="handleComplete">审批
               </el-button>
-              <!--                <el-button  icon="el-icon-edit-outline" type="primary" size="mini" @click="handleDelegate">委派</el-button>-->
-              <!--                <el-button  icon="el-icon-edit-outline" type="primary" size="mini" @click="handleAssign">转办</el-button>-->
-              <!--                <el-button  icon="el-icon-edit-outline" type="primary" size="mini" @click="handleDelegate">签收</el-button>-->
-              <!--              <el-button icon="el-icon-refresh-left" type="warning" size="mini" @click="handleReturn">退回</el-button>-->
-              <!--              <el-button icon="el-icon-circle-close" type="danger" size="mini" @click="handleReject">驳回</el-button>-->
+              &lt;!&ndash;                <el-button  icon="el-icon-edit-outline" type="primary" size="mini" @click="handleDelegate">委派</el-button>&ndash;&gt;
+              &lt;!&ndash;                <el-button  icon="el-icon-edit-outline" type="primary" size="mini" @click="handleAssign">转办</el-button>&ndash;&gt;
+              &lt;!&ndash;                <el-button  icon="el-icon-edit-outline" type="primary" size="mini" @click="handleDelegate">签收</el-button>&ndash;&gt;
+              &lt;!&ndash;              <el-button icon="el-icon-refresh-left" type="warning" size="mini" @click="handleReturn">退回</el-button>&ndash;&gt;
+              &lt;!&ndash;              <el-button icon="el-icon-circle-close" type="danger" size="mini" @click="handleReject">驳回</el-button>&ndash;&gt;
+            </div>-->
+            <v-form-render ref="vFormRef"/>
+            <div style="margin-left:10%;margin-bottom: 20px;font-size: 14px;">
+              <!-- taskDefKey 为“暂存”时显示提交、关闭 -->
+              <template v-if="taskDefKey === 'modifyApply'||taskDefKey === 'Activity_0iaxnuk'">
+                <el-button type="primary" @click="handleComplete(true)">提交</el-button>
+                <el-button type="primary" @click="handleComplete(false)">关闭</el-button>
+              </template>
+              <!-- taskDefKey 不为“暂存”时显示审批、驳回 -->
+              <template v-else>
+                <el-button type="primary" @click="handleComplete(true)">审批</el-button>
+                <el-button type="primary" @click="handleComplete(false)">驳回</el-button>
+              </template>
             </div>
           </el-col>
         </el-tab-pane>
@@ -167,6 +180,7 @@ export default {
   props: {},
   data() {
     return {
+      eventName: "click",
       // 模型xml数据
       xmlData: "",
       flowData: {},
@@ -222,14 +236,17 @@ export default {
       checkSendRole: false,// 是否展示角色选择模块
       checkType: 'single', // 选择类型
       taskName: null, // 任务节点
+      taskDefKey:null,//节点Id
       startUser: null, // 发起人信息,
       multiInstanceVars: '', // 会签节点
       formKeyExist: false, // 当前节点是否存在表单
+      formJson:{}
     };
   },
   created() {
     if (this.$route.query) {
       this.taskName = this.$route.query.taskName;
+      this.taskDefKey = this.$route.query.taskDefKey;
       this.startUser = this.$route.query.startUser;
       this.taskForm.deployId = this.$route.query.deployId;
       this.taskForm.taskId = this.$route.query.taskId;
@@ -324,17 +341,31 @@ export default {
       if (taskId) {
         // 提交流程申请时填写的表单存入了流程变量中后续任务处理时需要展示
         flowTaskForm({taskId: taskId}).then(res => {
-          this.variablesData = res.data.formData;
+          /*this.variablesData = res.data.formData;
           this.taskForm.variables = res.data.formData;
-          this.formKeyExist = res.data.formKeyExist;
+          this.formKeyExist = res.data.formKeyExist;*/
+          // 回显表单
+          this.$refs.vFormRef.setFormJson(res.data.formJson);
+          this.formJson = res.data.formJson;
+          this.$nextTick(() => {
+            // 加载表单填写的数据
+            this.$refs.vFormRef.setFormData(res.data);
+            // this.$nextTick(() => {
+            //   // 表单禁用
+            //   this.$refs.vFormRef.disableForm();
+            // })
+          })
         });
       }
     },
     /** 加载审批任务弹框 */
-    handleComplete() {
+    handleComplete(flag) {
       // this.completeOpen = true;
       // this.completeTitle = "流程审批";
-      this.submitForm(null);
+      //this.submitForm(null);
+      this.completeOpen = true;
+      this.completeTitle = "流程审批";
+      this.submitForm(flag);
     },
     /** 用户审批任务 */
     taskComplete() {
@@ -443,11 +474,11 @@ export default {
       this.returnTaskList = [];
     },
     /** 申请流程表单数据提交 */
-    submitForm(formData) {
+    submitForm(flag) {
       // 根据当前任务或者流程设计配置的下一步节点 todo 暂时未涉及到考虑网关、表达式和多节点情况
       const params = {taskId: this.taskForm.taskId}
       getNextFlowNode(params).then(res => {
-        const data = res.data;
+        /*const data = res.data;
         this.taskForm.formData = formData;
         if (data) {
           if (data.dataType === 'dynamic') {
@@ -468,9 +499,40 @@ export default {
           }
         }
         this.completeOpen = true;
-        this.completeTitle = "流程审批";
+        this.completeTitle = "流程审批";*/
+        this.$refs.vFormRef.getFormData().then(formData => {
+          formData.auditPass=flag;
+          Object.assign(this.taskForm.variables, formData);
+          this.taskForm.variables.formJson = this.formJson;
+          console.log(this.taskForm, "流程审批提交表单数据1")
+        }).catch(error => {
+          // this.$modal.msgError(error)
+        })
+        const data = res.data;
+        if (data) {
+          if (data.dataType === 'dynamic') {
+            if (data.type === 'assignee') { // 指定人员
+              this.checkSendUser = true;
+              this.checkType = "single";
+            } else if (data.type === 'candidateUsers') {  // 候选人员(多个)
+              this.checkSendUser = true;
+              this.checkType = "multiple";
+            } else if (data.type === 'candidateGroups') { // 指定组(所属角色接收任务)
+              this.checkSendRole = true;
+            } else { // 会签
+              // 流程设计指定的 elementVariable 作为会签人员列表
+              this.multiInstanceVars = data.vars;
+              this.checkSendUser = true;
+              this.checkType = "multiple";
+            }
+          }
+        }
       })
     },
+    // 动态绑定操作按钮的点击事件
+    handleButtonClick(method) {
+      this[method]();
+    }
   },
 };
 </script>

+ 15 - 1
ruoyi-ui/src/views/flowable/task/todo/index.vue

@@ -58,7 +58,12 @@
       <el-table-column label="接收时间" align="center" prop="createTime" width="180"/>
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
+          <!-- 1. 签收按钮:无签收人时显示 -->
+          <el-button v-if="!scope.row.assigneeId" icon="el-icon-edit-outline" type="primary" size="mini" @click="handleSign(scope.row)">签收</el-button>
+          <!-- 2. 处理按钮:有签收人时显示 -->
+<!--          <el-button v-else size="mini" type="text" icon="el-icon-edit-outline" @click="handleProcess(scope.row)">处理</el-button>-->
           <el-button
+            v-else
             size="mini"
             type="text"
             icon="el-icon-edit-outline"
@@ -88,7 +93,8 @@ import {
   rejectTask,
   getDeployment,
   delDeployment,
-  exportDeployment
+  exportDeployment,
+  claimTask,
 } from "@/api/flowable/todo";
 
 export default {
@@ -149,6 +155,7 @@ export default {
           deployId: row.deployId,
           taskId: row.taskId,
           taskName: row.taskName,
+          taskDefKey:row.taskDefKey,
           startUser: row.startUserName + '-' + row.startDeptName,
         }})
     },
@@ -203,6 +210,13 @@ export default {
        this.$modal.msgSuccess("删除成功");
       })
     },
+    handleSign(row) {
+      const taskId = row.taskId;
+      claimTask(taskId).then(() => {
+        this.$modal.msgSuccess("签收成功");
+        this.getList();
+      });
+    }
   }
 };
 </script>

+ 1 - 1
ruoyi-ui/src/views/invest/meeting/mark.vue

@@ -31,4 +31,4 @@ export default {
     }, 200);
   },
 };
-</script>
+</script>