* fix -- 修改获取流程节点信息接口(供前端渲染流程跟踪图着色使用) * fix -- 修复流程跟踪着色问题 * fix -- 采用ProcessViewer组件显示流程跟踪信息 * fix -- 整合表单设计代码 * fix -- 简易实现用户任务选择用户下拉框内容 * fix -- 修改项目介绍及sql文件 * del -- 移除未使用的文件 * fix -- 修复组件无法显示和修改的问题 * add -- 整合 Rtony/RuoYi-flowable 工作流 * add -- 添加process-designer流程设计插件 * !3 同步ruoyi-vue-plus更新 * !2 登录认证用户信息添加nickName字段(流程任务需要使用到)
70 lines
2.7 KiB
JavaScript
70 lines
2.7 KiB
JavaScript
// 创建监听器实例
|
|
export function createListenerObject(options, isTask, prefix) {
|
|
const listenerObj = Object.create(null);
|
|
listenerObj.event = options.event;
|
|
isTask && (listenerObj.id = options.id); // 任务监听器特有的 id 字段
|
|
switch (options.listenerType) {
|
|
case "scriptListener":
|
|
listenerObj.script = createScriptObject(options, prefix);
|
|
break;
|
|
case "expressionListener":
|
|
listenerObj.expression = options.expression;
|
|
break;
|
|
case "delegateExpressionListener":
|
|
listenerObj.delegateExpression = options.delegateExpression;
|
|
break;
|
|
default:
|
|
listenerObj.class = options.class;
|
|
}
|
|
// 注入字段
|
|
if (options.fields) {
|
|
listenerObj.fields = options.fields.map(field => {
|
|
return createFieldObject(field, prefix);
|
|
});
|
|
}
|
|
// 任务监听器的 定时器 设置
|
|
if (isTask && options.event === "timeout" && !!options.eventDefinitionType) {
|
|
const timeDefinition = window.bpmnInstances.moddle.create("bpmn:FormalExpression", { body: options.eventTimeDefinitions });
|
|
const TimerEventDefinition = window.bpmnInstances.moddle.create("bpmn:TimerEventDefinition", {
|
|
id: `TimerEventDefinition_${uuid(8)}`,
|
|
[`time${options.eventDefinitionType.replace(/^\S/, s => s.toUpperCase())}`]: timeDefinition
|
|
});
|
|
listenerObj.eventDefinitions = [TimerEventDefinition];
|
|
}
|
|
return window.bpmnInstances.moddle.create(`${prefix}:${isTask ? "TaskListener" : "ExecutionListener"}`, listenerObj);
|
|
}
|
|
|
|
// 创建 监听器的注入字段 实例
|
|
export function createFieldObject(option, prefix) {
|
|
const { name, fieldType, string, expression } = option;
|
|
const fieldConfig = fieldType === "string" ? { name, string } : { name, expression };
|
|
return window.bpmnInstances.moddle.create(`${prefix}:Field`, fieldConfig);
|
|
}
|
|
|
|
// 创建脚本实例
|
|
export function createScriptObject(options, prefix) {
|
|
const { scriptType, scriptFormat, value, resource } = options;
|
|
const scriptConfig = scriptType === "inlineScript" ? { scriptFormat, value } : { scriptFormat, resource };
|
|
return window.bpmnInstances.moddle.create(`${prefix}:Script`, scriptConfig);
|
|
}
|
|
|
|
// 更新元素扩展属性
|
|
export function updateElementExtensions(element, extensionList) {
|
|
const extensions = window.bpmnInstances.moddle.create("bpmn:ExtensionElements", {
|
|
values: extensionList
|
|
});
|
|
window.bpmnInstances.modeling.updateProperties(element, {
|
|
extensionElements: extensions
|
|
});
|
|
}
|
|
|
|
// 创建一个id
|
|
export function uuid(length = 8, chars) {
|
|
let result = "";
|
|
let charsString = chars || "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
for (let i = length; i > 0; --i) {
|
|
result += charsString[Math.floor(Math.random() * charsString.length)];
|
|
}
|
|
return result;
|
|
}
|