|
|
@@ -91,10 +91,10 @@
|
|
|
fixed
|
|
|
/>
|
|
|
<el-table-column
|
|
|
- label="执行人"
|
|
|
+ label="需要审批的角色"
|
|
|
align="center"
|
|
|
prop="options"
|
|
|
- min-width="140px"
|
|
|
+ min-width="200px"
|
|
|
>
|
|
|
<template v-slot="scope">
|
|
|
<div
|
|
|
@@ -104,18 +104,21 @@
|
|
|
scope.row.type !== 71 &&
|
|
|
scope.row.options.length > 0
|
|
|
"
|
|
|
+ style="display: flex; flex-wrap: wrap; gap: 4px; justify-content: center;"
|
|
|
>
|
|
|
<el-tag
|
|
|
- size="medium"
|
|
|
+ size="small"
|
|
|
:key="option"
|
|
|
v-for="option in scope.row.options"
|
|
|
+ style="margin: 1px;"
|
|
|
+ hit
|
|
|
>
|
|
|
{{ getAssignRuleOptionName(scope.row, option) }}
|
|
|
</el-tag>
|
|
|
</div>
|
|
|
|
|
|
<el-tag
|
|
|
- size="medium"
|
|
|
+ size="small"
|
|
|
v-if="
|
|
|
scope.row.type === 60 ||
|
|
|
scope.row.type === 70 ||
|
|
|
@@ -127,6 +130,46 @@
|
|
|
</el-tag>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ label="审批人选择"
|
|
|
+ align="center"
|
|
|
+ min-width="240px"
|
|
|
+ >
|
|
|
+ <template v-slot="scope">
|
|
|
+ <el-select
|
|
|
+ v-if="!isInitiatorNode(scope.row)"
|
|
|
+ v-model="scope.row.selectedUsers"
|
|
|
+ multiple
|
|
|
+ filterable
|
|
|
+ clearable
|
|
|
+ placeholder="请选择审批人"
|
|
|
+ style="width: 100%;"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="user in getFilteredUserOptions(scope.row)"
|
|
|
+ :key="user.id"
|
|
|
+ :label="user.nickname || user.name"
|
|
|
+ :value="user.id"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ <span v-else style="color: #909399; font-size: 12px;">发起人</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ label="审批方式"
|
|
|
+ align="center"
|
|
|
+ prop="approvalType"
|
|
|
+ width="100"
|
|
|
+ >
|
|
|
+ <template v-slot="scope">
|
|
|
+ <el-tag
|
|
|
+ :type="scope.row.approvalType === 1 ? 'success' : 'warning'"
|
|
|
+ size="small"
|
|
|
+ >
|
|
|
+ {{ getApprovalTypeName(scope.row.approvalType) }}
|
|
|
+ </el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
</el-table>
|
|
|
<my-process-viewer
|
|
|
v-show="active == 0"
|
|
|
@@ -354,6 +397,21 @@
|
|
|
modelId: find.modelId,
|
|
|
processDefinitionId: find.processDefinitionId
|
|
|
});
|
|
|
+ // 从 bpmnXML 解析每个节点是否是多实例,用于判断审批方式
|
|
|
+ this.datasource.forEach(row => {
|
|
|
+ row.approvalType = this.getApprovalTypeFromBpmn(row.taskDefinitionKey);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getApprovalTypeFromBpmn(taskDefinitionKey) {
|
|
|
+ // 如果 bpmnXML 不存在,默认单人审批
|
|
|
+ if (!this.bpmnXML) return 1;
|
|
|
+ // 在 BPMN XML 中找到该 userTask 节点的内容
|
|
|
+ const regex = new RegExp(
|
|
|
+ `<[^:]*:?userTask[^>]*\\s(id="${taskDefinitionKey}")[^>]*>[\\s\\S]*?</[^:]*:?userTask>`
|
|
|
+ );
|
|
|
+ const match = this.bpmnXML.match(regex);
|
|
|
+ // 没有匹配到或没有多实例配置 → 单人审批;有多实例配置 → 多人审批
|
|
|
+ return match && match[0].includes('multiInstanceLoopCharacteristics') ? 2 : 1;
|
|
|
},
|
|
|
getAssignRuleOptionName(row, option) {
|
|
|
if (row.type == 10) {
|
|
|
@@ -404,6 +462,15 @@
|
|
|
}
|
|
|
return '未知(' + option + ')';
|
|
|
},
|
|
|
+ isInitiatorNode(row) {
|
|
|
+ return row.type === 60;
|
|
|
+ },
|
|
|
+ getFilteredUserOptions(row) {
|
|
|
+ return this.userOptions;
|
|
|
+ },
|
|
|
+ getApprovalTypeName(type) {
|
|
|
+ return type === 1 ? '单人审批' : '多人审批';
|
|
|
+ },
|
|
|
/**
|
|
|
* 构造树型结构数据
|
|
|
* @param {*} data 数据源
|
|
|
@@ -459,6 +526,14 @@
|
|
|
text: '提交中',
|
|
|
background: 'rgba(0, 0, 0, 0.7)'
|
|
|
});
|
|
|
+ // 从表格中构建审批人映射: { taskDefinitionKey: [userId1, userId2] }
|
|
|
+ const assignee = {};
|
|
|
+ this.datasource.forEach(row => {
|
|
|
+ if (row.selectedUsers && row.selectedUsers.length > 0) {
|
|
|
+ assignee[row.taskDefinitionKey] = row.selectedUsers;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.form.assignee = assignee;
|
|
|
const submitPromise = this.customSubmit
|
|
|
? this.customSubmit(this.form.businessId, this.form)
|
|
|
: processInstanceCreateAPI(this.form);
|
|
|
@@ -485,6 +560,14 @@
|
|
|
approvalStatus: this.approvalStatus,
|
|
|
...this.form
|
|
|
};
|
|
|
+ // 从表格中构建审批人映射
|
|
|
+ const assignee = {};
|
|
|
+ this.datasource.forEach(row => {
|
|
|
+ if (row.selectedUsers && row.selectedUsers.length > 0) {
|
|
|
+ assignee[row.taskDefinitionKey] = row.selectedUsers;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ params.assignee = assignee;
|
|
|
await this[this.apiFunName](params)
|
|
|
.then((res) => {
|
|
|
console.log(res, 'res');
|