项目初始化
This commit is contained in:
74
klp-ui/src/plugins/package/penal/task/ElementTask.vue
Normal file
74
klp-ui/src/plugins/package/penal/task/ElementTask.vue
Normal file
@@ -0,0 +1,74 @@
|
||||
<template>
|
||||
<div class="panel-tab__content">
|
||||
<el-form size="mini" label-width="96px" @submit.native.prevent>
|
||||
<!-- <el-form-item label="异步延续">-->
|
||||
<!-- <el-checkbox v-model="taskConfigForm.asyncBefore" label="异步前" @change="changeTaskAsync" />-->
|
||||
<!-- <el-checkbox v-model="taskConfigForm.asyncAfter" label="异步后" @change="changeTaskAsync" />-->
|
||||
<!-- <el-checkbox v-model="taskConfigForm.exclusive" v-if="taskConfigForm.asyncAfter || taskConfigForm.asyncBefore" label="排除" @change="changeTaskAsync" />-->
|
||||
<!-- </el-form-item>-->
|
||||
<component :is="witchTaskComponent" v-bind="$props" />
|
||||
</el-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import UserTask from "./task-components/UserTask";
|
||||
import ServiceTask from "./task-components/ServiceTask";
|
||||
import ScriptTask from "./task-components/ScriptTask";
|
||||
import ReceiveTask from "./task-components/ReceiveTask";
|
||||
|
||||
export default {
|
||||
name: "ElementTaskConfig",
|
||||
components: { UserTask, ServiceTask, ScriptTask, ReceiveTask },
|
||||
props: {
|
||||
id: String,
|
||||
type: String
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
taskConfigForm: {
|
||||
asyncAfter: false,
|
||||
asyncBefore: false,
|
||||
exclusive: false
|
||||
},
|
||||
witchTaskComponent: "",
|
||||
installedComponent: {
|
||||
// 手工任务与普通任务一致,不需要其他配置
|
||||
// 接收消息任务,需要在全局下插入新的消息实例,并在该节点下的 messageRef 属性绑定该实例
|
||||
// 发送任务、服务任务、业务规则任务共用一个相同配置
|
||||
UserTask: "UserTask", // 用户任务配置
|
||||
ServiceTask: "ServiceTask", // 服务任务配置
|
||||
ScriptTask: "ScriptTask", // 脚本任务配置
|
||||
ReceiveTask: "ReceiveTask" // 消息接收任务
|
||||
}
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
id: {
|
||||
immediate: true,
|
||||
handler() {
|
||||
this.bpmnElement = window.bpmnInstances.bpmnElement;
|
||||
this.taskConfigForm.asyncBefore = this.bpmnElement?.businessObject?.asyncBefore;
|
||||
this.taskConfigForm.asyncAfter = this.bpmnElement?.businessObject?.asyncAfter;
|
||||
this.taskConfigForm.exclusive = this.bpmnElement?.businessObject?.exclusive;
|
||||
}
|
||||
},
|
||||
type: {
|
||||
immediate: true,
|
||||
handler() {
|
||||
this.witchTaskComponent = this.installedComponent[this.type];
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
changeTaskAsync() {
|
||||
if (!this.taskConfigForm.asyncBefore && !this.taskConfigForm.asyncAfter) {
|
||||
this.taskConfigForm.exclusive = false;
|
||||
}
|
||||
window.bpmnInstances.modeling.updateProperties(window.bpmnInstances.bpmnElement, {
|
||||
...this.taskConfigForm
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -0,0 +1,97 @@
|
||||
<template>
|
||||
<div style="margin-top: 16px">
|
||||
<el-form-item label="消息实例">
|
||||
<div style="display: flex; align-items: center; justify-content: space-between; flex-wrap: nowrap">
|
||||
<el-select v-model="bindMessageId" @change="updateTaskMessage">
|
||||
<el-option v-for="id in Object.keys(messageMap)" :value="id" :label="messageMap[id]" :key="id" />
|
||||
</el-select>
|
||||
<el-button size="mini" type="primary" icon="el-icon-plus" style="margin-left: 8px" @click="openMessageModel" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-dialog :visible.sync="messageModelVisible" :close-on-click-modal="false" title="创建新消息" width="400px" append-to-body destroy-on-close>
|
||||
<el-form :model="newMessageForm" size="mini" label-width="90px" @submit.native.prevent>
|
||||
<el-form-item label="消息ID">
|
||||
<el-input v-model="newMessageForm.id" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="消息名称">
|
||||
<el-input v-model="newMessageForm.name" clearable />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template slot="footer">
|
||||
<el-button size="mini" type="primary" @click="createNewMessage">确 认</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "ReceiveTask",
|
||||
props: {
|
||||
id: String,
|
||||
type: String
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
bindMessageId: "",
|
||||
newMessageForm: {},
|
||||
messageMap: {},
|
||||
messageModelVisible: false
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
id: {
|
||||
immediate: true,
|
||||
handler() {
|
||||
this.$nextTick(() => this.getBindMessage());
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.bpmnMessageRefsMap = Object.create(null);
|
||||
this.bpmnRootElements = window.bpmnInstances.modeler.getDefinitions().rootElements;
|
||||
this.bpmnRootElements
|
||||
.filter(el => el.$type === "bpmn:Message")
|
||||
.forEach(m => {
|
||||
this.bpmnMessageRefsMap[m.id] = m;
|
||||
this.$set(this.messageMap, m.id, m.name);
|
||||
});
|
||||
this.$set(this.messageMap, "-1", "无"); // 添加一个空对象,保证可以取消原消息绑定
|
||||
},
|
||||
methods: {
|
||||
getBindMessage() {
|
||||
this.bpmnElement = window.bpmnInstances.bpmnElement;
|
||||
this.bindMessageId = this.bpmnElement.businessObject?.messageRef?.id || "-1";
|
||||
},
|
||||
openMessageModel() {
|
||||
this.messageModelVisible = true;
|
||||
this.newMessageForm = {};
|
||||
},
|
||||
createNewMessage() {
|
||||
if (this.messageMap[this.newMessageForm.id]) {
|
||||
this.$message.error("该消息已存在,请修改id后重新保存");
|
||||
return;
|
||||
}
|
||||
const newMessage = window.bpmnInstances.moddle.create("bpmn:Message", this.newMessageForm);
|
||||
this.bpmnRootElements.push(newMessage);
|
||||
this.$set(this.messageMap, this.newMessageForm.id, this.newMessageForm.name);
|
||||
this.bpmnMessageRefsMap[this.newMessageForm.id] = newMessage;
|
||||
this.messageModelVisible = false;
|
||||
},
|
||||
updateTaskMessage(messageId) {
|
||||
if (messageId === "-1") {
|
||||
window.bpmnInstances.modeling.updateProperties(this.bpmnElement, {
|
||||
messageRef: null
|
||||
});
|
||||
} else {
|
||||
window.bpmnInstances.modeling.updateProperties(this.bpmnElement, {
|
||||
messageRef: this.bpmnMessageRefsMap[messageId]
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.bpmnElement = null;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -0,0 +1,85 @@
|
||||
<template>
|
||||
<div style="margin-top: 16px">
|
||||
<el-form-item label="脚本格式">
|
||||
<el-input v-model="scriptTaskForm.scriptFormat" clearable @input="updateElementTask()" @change="updateElementTask()" />
|
||||
</el-form-item>
|
||||
<el-form-item label="脚本类型">
|
||||
<el-select v-model="scriptTaskForm.scriptType">
|
||||
<el-option label="内联脚本" value="inline" />
|
||||
<el-option label="外部资源" value="external" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="脚本" v-show="scriptTaskForm.scriptType === 'inline'">
|
||||
<el-input
|
||||
v-model="scriptTaskForm.script"
|
||||
type="textarea"
|
||||
resize="vertical"
|
||||
:autosize="{ minRows: 2, maxRows: 4 }"
|
||||
clearable
|
||||
@input="updateElementTask()"
|
||||
@change="updateElementTask()"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="资源地址" v-show="scriptTaskForm.scriptType === 'external'">
|
||||
<el-input v-model="scriptTaskForm.resource" clearable @input="updateElementTask()" @change="updateElementTask()" />
|
||||
</el-form-item>
|
||||
<el-form-item label="结果变量">
|
||||
<el-input v-model="scriptTaskForm.resultVariable" clearable @input="updateElementTask()" @change="updateElementTask()" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "ScriptTask",
|
||||
props: {
|
||||
id: String,
|
||||
type: String
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
defaultTaskForm: {
|
||||
scriptFormat: "",
|
||||
script: "",
|
||||
resource: "",
|
||||
resultVariable: ""
|
||||
},
|
||||
scriptTaskForm: {}
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
id: {
|
||||
immediate: true,
|
||||
handler() {
|
||||
this.bpmnElement = window.bpmnInstances.bpmnElement;
|
||||
this.$nextTick(() => this.resetTaskForm());
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
resetTaskForm() {
|
||||
for (let key in this.defaultTaskForm) {
|
||||
let value = this.bpmnElement?.businessObject[key] || this.defaultTaskForm[key];
|
||||
this.$set(this.scriptTaskForm, key, value);
|
||||
}
|
||||
this.$set(this.scriptTaskForm, "scriptType", this.scriptTaskForm.script ? "inline" : "external");
|
||||
},
|
||||
updateElementTask() {
|
||||
let taskAttr = Object.create(null);
|
||||
taskAttr.scriptFormat = this.scriptTaskForm.scriptFormat || null;
|
||||
taskAttr.resultVariable = this.scriptTaskForm.resultVariable || null;
|
||||
if (this.scriptTaskForm.scriptType === "inline") {
|
||||
taskAttr.script = this.scriptTaskForm.script || null;
|
||||
taskAttr.resource = null;
|
||||
} else {
|
||||
taskAttr.resource = this.scriptTaskForm.resource || null;
|
||||
taskAttr.script = null;
|
||||
}
|
||||
window.bpmnInstances.modeling.updateProperties(this.bpmnElement, taskAttr);
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.bpmnElement = null;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -0,0 +1,86 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-form-item label="执行类型" key="executeType">
|
||||
<el-select v-model="serviceTaskForm.executeType">
|
||||
<el-option label="Java类" value="class" />
|
||||
<el-option label="表达式" value="expression" />
|
||||
<el-option label="代理表达式" value="delegateExpression" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="serviceTaskForm.executeType === 'class'"
|
||||
label="Java类"
|
||||
prop="class"
|
||||
key="execute-class"
|
||||
>
|
||||
<el-input v-model="serviceTaskForm.class" clearable @change="updateElementTask" />
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="serviceTaskForm.executeType === 'expression'"
|
||||
label="表达式"
|
||||
prop="expression"
|
||||
key="execute-expression"
|
||||
>
|
||||
<el-input v-model="serviceTaskForm.expression" clearable @change="updateElementTask" />
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="serviceTaskForm.executeType === 'delegateExpression'"
|
||||
label="代理表达式"
|
||||
prop="delegateExpression"
|
||||
key="execute-delegate"
|
||||
>
|
||||
<el-input v-model="serviceTaskForm.delegateExpression" clearable @change="updateElementTask" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "ServiceTask",
|
||||
props: {
|
||||
id: String,
|
||||
type: String
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
defaultTaskForm: {
|
||||
executeType: "",
|
||||
class: "",
|
||||
expression: "",
|
||||
delegateExpression: ""
|
||||
},
|
||||
serviceTaskForm: {}
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
id: {
|
||||
immediate: true,
|
||||
handler() {
|
||||
this.bpmnElement = window.bpmnInstances.bpmnElement;
|
||||
this.$nextTick(() => this.resetTaskForm());
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
resetTaskForm() {
|
||||
for (let key in this.defaultTaskForm) {
|
||||
let value = this.bpmnElement?.businessObject[key] || this.defaultTaskForm[key];
|
||||
if (value) this.$set(this.serviceTaskForm, "executeType", key);
|
||||
this.$set(this.serviceTaskForm, key, value);
|
||||
}
|
||||
},
|
||||
updateElementTask() {
|
||||
let taskAttr = Object.create(null);
|
||||
const type = this.serviceTaskForm.executeType;
|
||||
for (let key in this.serviceTaskForm) {
|
||||
if (key !== 'executeType' && key !== type) taskAttr[key] = null;
|
||||
}
|
||||
taskAttr[type] = this.serviceTaskForm[type] || "";
|
||||
window.bpmnInstances.modeling.updateProperties(this.bpmnElement, taskAttr);
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.bpmnElement = null;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -0,0 +1,525 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-row>
|
||||
<h4><b>审批人设置</b></h4>
|
||||
<el-radio-group v-model="dataType" @change="changeDataType">
|
||||
<el-radio label="USERS">指定用户</el-radio>
|
||||
<el-radio label="ROLES">角色</el-radio>
|
||||
<el-radio label="DEPTS">部门</el-radio>
|
||||
<el-radio label="INITIATOR">发起人</el-radio>
|
||||
</el-radio-group>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<div v-if="dataType === 'USERS'">
|
||||
<el-tag v-for="userText in selectedUser.text" :key="userText" effect="plain">
|
||||
{{userText}}
|
||||
</el-tag>
|
||||
<div class="element-drawer__button">
|
||||
<el-button size="mini" type="primary" icon="el-icon-plus" @click="onSelectUsers()">添加用户</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="dataType === 'ROLES'">
|
||||
<el-select v-model="roleIds" multiple size="mini" placeholder="请选择 角色" @change="changeSelectRoles">
|
||||
<el-option
|
||||
v-for="item in roleOptions"
|
||||
:key="item.roleId"
|
||||
:label="item.roleName"
|
||||
:value="`ROLE${item.roleId}`"
|
||||
:disabled="item.status === 1">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
<div v-if="dataType === 'DEPTS'">
|
||||
<tree-select
|
||||
:width="320"
|
||||
:height="400"
|
||||
size="mini"
|
||||
:data="deptTreeData"
|
||||
:defaultProps="deptProps"
|
||||
multiple
|
||||
clearable
|
||||
checkStrictly
|
||||
nodeKey="id"
|
||||
:checkedKeys="deptIds"
|
||||
@change="checkedDeptChange">
|
||||
</tree-select>
|
||||
</div>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<div v-show="showMultiFlog">
|
||||
<el-divider />
|
||||
<h4><b>多实例审批方式</b></h4>
|
||||
<el-row>
|
||||
<el-radio-group v-model="multiLoopType" @change="changeMultiLoopType()">
|
||||
<el-row><el-radio label="Null">无</el-radio></el-row>
|
||||
<el-row><el-radio label="SequentialMultiInstance">会签(需所有审批人同意)</el-radio></el-row>
|
||||
<el-row><el-radio label="ParallelMultiInstance">或签(一名审批人同意即可)</el-radio></el-row>
|
||||
</el-radio-group>
|
||||
</el-row>
|
||||
<el-row v-if="multiLoopType !== 'Null'">
|
||||
<el-tooltip content="开启后,实例需按顺序轮流审批" placement="top-start" @click.stop.prevent>
|
||||
<i class="header-icon el-icon-info"></i>
|
||||
</el-tooltip>
|
||||
<span class="custom-label">顺序审批:</span>
|
||||
<el-switch v-model="isSequential" @change="changeMultiLoopType()" />
|
||||
</el-row>
|
||||
</div>
|
||||
</el-row>
|
||||
|
||||
<!-- 候选用户弹窗 -->
|
||||
<el-dialog title="候选用户" :visible.sync="userOpen" width="60%" append-to-body>
|
||||
<el-row type="flex" :gutter="20">
|
||||
<!--部门数据-->
|
||||
<el-col :span="7">
|
||||
<el-card shadow="never" style="height: 100%">
|
||||
<div slot="header">
|
||||
<span>部门列表</span>
|
||||
</div>
|
||||
<div class="head-container">
|
||||
<el-input
|
||||
v-model="deptName"
|
||||
placeholder="请输入部门名称"
|
||||
clearable
|
||||
size="small"
|
||||
prefix-icon="el-icon-search"
|
||||
style="margin-bottom: 20px"
|
||||
/>
|
||||
<el-tree
|
||||
:data="deptOptions"
|
||||
:props="deptProps"
|
||||
:expand-on-click-node="false"
|
||||
:filter-node-method="filterNode"
|
||||
ref="tree"
|
||||
default-expand-all
|
||||
@node-click="handleNodeClick"
|
||||
/>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :span="17">
|
||||
<el-table ref="multipleTable" height="600" :data="userTableList" border @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="50" align="center" />
|
||||
<el-table-column label="用户名" align="center" prop="nickName" />
|
||||
<el-table-column label="部门" align="center" prop="dept.deptName" />
|
||||
</el-table>
|
||||
<pagination
|
||||
:total="userTotal"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getUserList"
|
||||
/>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="handleTaskUserComplete">确 定</el-button>
|
||||
<el-button @click="userOpen = false">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listUser, deptTreeSelect } from "@/api/system/user";
|
||||
import { listRole } from "@/api/system/role";
|
||||
import TreeSelect from "@/components/TreeSelect";
|
||||
|
||||
const userTaskForm = {
|
||||
dataType: '',
|
||||
assignee: '',
|
||||
candidateUsers: '',
|
||||
candidateGroups: '',
|
||||
text: '',
|
||||
// dueDate: '',
|
||||
// followUpDate: '',
|
||||
// priority: ''
|
||||
}
|
||||
|
||||
export default {
|
||||
name: "UserTask",
|
||||
props: {
|
||||
id: String,
|
||||
type: String
|
||||
},
|
||||
components: { TreeSelect },
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
dataType: 'USERS',
|
||||
selectedUser: {
|
||||
ids: [],
|
||||
text: []
|
||||
},
|
||||
userOpen: false,
|
||||
deptName: undefined,
|
||||
deptOptions: [],
|
||||
deptProps: {
|
||||
children: "children",
|
||||
label: "label"
|
||||
},
|
||||
deptTempOptions: [],
|
||||
userTableList: [],
|
||||
userTotal: 0,
|
||||
selectedUserDate: [],
|
||||
roleOptions: [],
|
||||
roleIds: [],
|
||||
deptTreeData: [],
|
||||
deptIds: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
deptId: undefined
|
||||
},
|
||||
showMultiFlog: false,
|
||||
isSequential: false,
|
||||
multiLoopType: 'Null',
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
id: {
|
||||
immediate: true,
|
||||
handler() {
|
||||
this.bpmnElement = window.bpmnInstances.bpmnElement;
|
||||
this.$nextTick(() => this.resetTaskForm());
|
||||
}
|
||||
},
|
||||
// 根据名称筛选部门树
|
||||
deptName(val) {
|
||||
this.$refs.tree.filter(val);
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.bpmnElement = null;
|
||||
},
|
||||
methods: {
|
||||
resetTaskForm() {
|
||||
const bpmnElementObj = this.bpmnElement?.businessObject;
|
||||
if (!bpmnElementObj) {
|
||||
return;
|
||||
}
|
||||
this.clearOptionsData()
|
||||
this.dataType = bpmnElementObj['dataType'];
|
||||
if (this.dataType === 'USERS') {
|
||||
let userIdData = bpmnElementObj['candidateUsers'] || bpmnElementObj['assignee'];
|
||||
let userText = bpmnElementObj['text'] || [];
|
||||
if (userIdData && userIdData.toString().length > 0 && userText && userText.length > 0) {
|
||||
this.selectedUser.ids = userIdData?.toString().split(',');
|
||||
this.selectedUser.text = userText?.split(',');
|
||||
}
|
||||
if (this.selectedUser.ids.length > 1) {
|
||||
this.showMultiFlog = true;
|
||||
}
|
||||
} else if (this.dataType === 'ROLES') {
|
||||
this.getRoleOptions();
|
||||
let roleIdData = bpmnElementObj['candidateGroups'] || [];
|
||||
if (roleIdData && roleIdData.length > 0) {
|
||||
this.roleIds = roleIdData.split(',')
|
||||
}
|
||||
this.showMultiFlog = true;
|
||||
} else if (this.dataType === 'DEPTS') {
|
||||
this.getDeptTreeData();
|
||||
let deptIdData = bpmnElementObj['candidateGroups'] || [];
|
||||
if (deptIdData && deptIdData.length > 0) {
|
||||
this.deptIds = deptIdData.split(',');
|
||||
}
|
||||
this.showMultiFlog = true;
|
||||
}
|
||||
this.getElementLoop(bpmnElementObj);
|
||||
},
|
||||
/**
|
||||
* 清空选项数据
|
||||
*/
|
||||
clearOptionsData() {
|
||||
this.selectedUser.ids = [];
|
||||
this.selectedUser.text = [];
|
||||
this.roleIds = [];
|
||||
this.deptIds = [];
|
||||
},
|
||||
/**
|
||||
* 跟新节点数据
|
||||
*/
|
||||
updateElementTask() {
|
||||
const taskAttr = Object.create(null);
|
||||
for (let key in userTaskForm) {
|
||||
taskAttr[key] = userTaskForm[key];
|
||||
}
|
||||
window.bpmnInstances.modeling.updateProperties(this.bpmnElement, taskAttr);
|
||||
},
|
||||
/**
|
||||
* 查询部门下拉树结构
|
||||
*/
|
||||
getDeptOptions() {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!this.deptOptions || this.deptOptions.length <= 0) {
|
||||
deptTreeSelect().then(response => {
|
||||
this.deptTempOptions = response.data;
|
||||
this.deptOptions = response.data;
|
||||
resolve()
|
||||
})
|
||||
} else {
|
||||
reject()
|
||||
}
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 查询部门下拉树结构(含部门前缀)
|
||||
*/
|
||||
getDeptTreeData() {
|
||||
function refactorTree(data) {
|
||||
return data.map(node => {
|
||||
let treeData = { id: `DEPT${node.id}`, label: node.label, parentId: node.parentId, weight: node.weight };
|
||||
if (node.children && node.children.length > 0) {
|
||||
treeData.children = refactorTree(node.children);
|
||||
}
|
||||
return treeData;
|
||||
});
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!this.deptTreeData || this.deptTreeData.length <= 0) {
|
||||
this.getDeptOptions().then(() => {
|
||||
this.deptTreeData = refactorTree(this.deptOptions);
|
||||
resolve()
|
||||
}).catch(() => {
|
||||
reject()
|
||||
})
|
||||
} else {
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 查询部门下拉树结构
|
||||
*/
|
||||
getRoleOptions() {
|
||||
if (!this.roleOptions || this.roleOptions.length <= 0) {
|
||||
listRole().then(response => this.roleOptions = response.rows);
|
||||
}
|
||||
},
|
||||
/** 查询用户列表 */
|
||||
getUserList() {
|
||||
listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
|
||||
this.userTableList = response.rows;
|
||||
this.userTotal = response.total;
|
||||
});
|
||||
},
|
||||
// 筛选节点
|
||||
filterNode(value, data) {
|
||||
if (!value) return true;
|
||||
return data.label.indexOf(value) !== -1;
|
||||
},
|
||||
// 节点单击事件
|
||||
handleNodeClick(data) {
|
||||
this.queryParams.deptId = data.id;
|
||||
this.getUserList();
|
||||
},
|
||||
// 关闭标签
|
||||
handleClose(tag) {
|
||||
this.selectedUserDate.splice(this.selectedUserDate.indexOf(tag), 1);
|
||||
this.$refs.multipleTable.toggleRowSelection(tag);
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.selectedUserDate = selection;
|
||||
},
|
||||
onSelectUsers() {
|
||||
this.selectedUserDate = []
|
||||
this.$refs.multipleTable?.clearSelection();
|
||||
this.getDeptOptions();
|
||||
this.userOpen = true;
|
||||
},
|
||||
handleTaskUserComplete() {
|
||||
if (!this.selectedUserDate || this.selectedUserDate.length <= 0) {
|
||||
this.$modal.msgError('请选择用户');
|
||||
return;
|
||||
}
|
||||
userTaskForm.dataType = 'USERS';
|
||||
this.selectedUser.text = this.selectedUserDate.map(k => k.nickName) || [];
|
||||
if (this.selectedUserDate.length === 1) {
|
||||
let data = this.selectedUserDate[0];
|
||||
userTaskForm.assignee = data.userId;
|
||||
userTaskForm.text = data.nickName;
|
||||
userTaskForm.candidateUsers = null;
|
||||
this.showMultiFlog = false;
|
||||
this.multiLoopType = 'Null';
|
||||
this.changeMultiLoopType();
|
||||
} else {
|
||||
userTaskForm.candidateUsers = this.selectedUserDate.map(k => k.userId).join() || null;
|
||||
userTaskForm.text = this.selectedUserDate.map(k => k.nickName).join() || null;
|
||||
userTaskForm.assignee = null;
|
||||
this.showMultiFlog = true;
|
||||
}
|
||||
this.updateElementTask()
|
||||
this.userOpen = false;
|
||||
},
|
||||
changeSelectRoles(val) {
|
||||
let groups = null;
|
||||
let text = null;
|
||||
if (val && val.length > 0) {
|
||||
userTaskForm.dataType = 'ROLES';
|
||||
groups = val.join() || null;
|
||||
let textArr = this.roleOptions.filter(k => val.indexOf(`ROLE${k.roleId}`) >= 0);
|
||||
text = textArr?.map(k => k.roleName).join() || null;
|
||||
} else {
|
||||
userTaskForm.dataType = null;
|
||||
this.multiLoopType = 'Null';
|
||||
}
|
||||
userTaskForm.candidateGroups = groups;
|
||||
userTaskForm.text = text;
|
||||
this.updateElementTask();
|
||||
this.changeMultiLoopType();
|
||||
},
|
||||
checkedDeptChange(checkedIds) {
|
||||
let groups = null;
|
||||
let text = null;
|
||||
this.deptIds = checkedIds;
|
||||
if (checkedIds && checkedIds.length > 0) {
|
||||
userTaskForm.dataType = 'DEPTS';
|
||||
groups = checkedIds.join() || null;
|
||||
let textArr = []
|
||||
let treeStarkData = JSON.parse(JSON.stringify(this.deptTreeData));
|
||||
checkedIds.forEach(id => {
|
||||
let stark = []
|
||||
stark = stark.concat(treeStarkData);
|
||||
while(stark.length) {
|
||||
let temp = stark.shift();
|
||||
if(temp.children) {
|
||||
stark = temp.children.concat(stark);
|
||||
}
|
||||
if(id === temp.id) {
|
||||
textArr.push(temp);
|
||||
}
|
||||
}
|
||||
})
|
||||
text = textArr?.map(k => k.label).join() || null;
|
||||
} else {
|
||||
userTaskForm.dataType = null;
|
||||
this.multiLoopType = 'Null';
|
||||
}
|
||||
userTaskForm.candidateGroups = groups;
|
||||
userTaskForm.text = text;
|
||||
this.updateElementTask();
|
||||
this.changeMultiLoopType();
|
||||
},
|
||||
changeDataType(val) {
|
||||
if (val === 'ROLES' || val === 'DEPTS' || (val === 'USERS' && this.selectedUser.ids.length > 1)) {
|
||||
this.showMultiFlog = true;
|
||||
} else {
|
||||
this.showMultiFlog = false;
|
||||
}
|
||||
this.multiLoopType = 'Null';
|
||||
this.changeMultiLoopType();
|
||||
// 清空 userTaskForm 所有属性值
|
||||
Object.keys(userTaskForm).forEach(key => userTaskForm[key] = null);
|
||||
userTaskForm.dataType = val;
|
||||
if (val === 'USERS') {
|
||||
if (this.selectedUser && this.selectedUser.ids && this.selectedUser.ids.length > 0) {
|
||||
if (this.selectedUser.ids.length === 1) {
|
||||
userTaskForm.assignee = this.selectedUser.ids[0];
|
||||
} else {
|
||||
userTaskForm.candidateUsers = this.selectedUser.ids.join()
|
||||
}
|
||||
userTaskForm.text = this.selectedUser.text?.join() || null
|
||||
}
|
||||
} else if (val === 'ROLES') {
|
||||
this.getRoleOptions();
|
||||
if (this.roleIds && this.roleIds.length > 0) {
|
||||
userTaskForm.candidateGroups = this.roleIds.join() || null;
|
||||
let textArr = this.roleOptions.filter(k => this.roleIds.indexOf(`ROLE${k.roleId}`) >= 0);
|
||||
userTaskForm.text = textArr?.map(k => k.roleName).join() || null;
|
||||
}
|
||||
} else if (val === 'DEPTS') {
|
||||
this.getDeptTreeData();
|
||||
if (this.deptIds && this.deptIds.length > 0) {
|
||||
userTaskForm.candidateGroups = this.deptIds.join() || null;
|
||||
let textArr = []
|
||||
let treeStarkData = JSON.parse(JSON.stringify(this.deptTreeData));
|
||||
this.deptIds.forEach(id => {
|
||||
let stark = []
|
||||
stark = stark.concat(treeStarkData);
|
||||
while(stark.length) {
|
||||
let temp = stark.shift();
|
||||
if(temp.children) {
|
||||
stark = temp.children.concat(stark);
|
||||
}
|
||||
if(id === temp.id) {
|
||||
textArr.push(temp);
|
||||
}
|
||||
}
|
||||
})
|
||||
userTaskForm.text = textArr?.map(k => k.label).join() || null;
|
||||
}
|
||||
} else if (val === 'INITIATOR') {
|
||||
userTaskForm.assignee = "${initiator}";
|
||||
userTaskForm.text = "流程发起人";
|
||||
}
|
||||
this.updateElementTask();
|
||||
},
|
||||
getElementLoop(businessObject) {
|
||||
if (!businessObject.loopCharacteristics) {
|
||||
this.multiLoopType = "Null";
|
||||
return;
|
||||
}
|
||||
this.isSequential = businessObject.loopCharacteristics.isSequential;
|
||||
if (businessObject.loopCharacteristics.completionCondition) {
|
||||
if (businessObject.loopCharacteristics.completionCondition.body === "${nrOfCompletedInstances >= nrOfInstances}") {
|
||||
this.multiLoopType = "SequentialMultiInstance";
|
||||
} else {
|
||||
this.multiLoopType = "ParallelMultiInstance";
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
changeMultiLoopType() {
|
||||
// 取消多实例配置
|
||||
if (this.multiLoopType === "Null") {
|
||||
window.bpmnInstances.modeling.updateProperties(this.bpmnElement, { loopCharacteristics: null, assignee: null });
|
||||
return;
|
||||
}
|
||||
this.multiLoopInstance = window.bpmnInstances.moddle.create("bpmn:MultiInstanceLoopCharacteristics", { isSequential: this.isSequential });
|
||||
// 更新多实例配置
|
||||
window.bpmnInstances.modeling.updateProperties(this.bpmnElement, {
|
||||
loopCharacteristics: this.multiLoopInstance,
|
||||
assignee: '${assignee}'
|
||||
});
|
||||
// 完成条件
|
||||
let completionCondition = null;
|
||||
// 会签
|
||||
if (this.multiLoopType === "SequentialMultiInstance") {
|
||||
completionCondition = window.bpmnInstances.moddle.create("bpmn:FormalExpression", { body: "${nrOfCompletedInstances >= nrOfInstances}" });
|
||||
}
|
||||
// 或签
|
||||
if (this.multiLoopType === "ParallelMultiInstance") {
|
||||
completionCondition = window.bpmnInstances.moddle.create("bpmn:FormalExpression", { body: "${nrOfCompletedInstances > 0}" });
|
||||
}
|
||||
// 更新模块属性信息
|
||||
window.bpmnInstances.modeling.updateModdleProperties(this.bpmnElement, this.multiLoopInstance, {
|
||||
collection: '${multiInstanceHandler.getUserIds(execution)}',
|
||||
elementVariable: 'assignee',
|
||||
completionCondition
|
||||
});
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.el-row .el-radio-group {
|
||||
margin-bottom: 15px;
|
||||
.el-radio {
|
||||
line-height: 28px;
|
||||
}
|
||||
}
|
||||
.el-tag {
|
||||
margin-bottom: 10px;
|
||||
+ .el-tag {
|
||||
margin-left: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.custom-label {
|
||||
padding-left: 5px;
|
||||
font-weight: 500;
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user