修改数据弹出层
parent
89c366be68
commit
a03f702fa1
@ -1,69 +1,73 @@
|
|||||||
// 创建监听器实例
|
// 创建监听器实例
|
||||||
export function createListenerObject(options, isTask, prefix) {
|
export function createListenerObject (options, isTask, prefix) {
|
||||||
const listenerObj = Object.create(null);
|
const listenerObj = Object.create(null)
|
||||||
listenerObj.event = options.event;
|
listenerObj.event = options.event
|
||||||
isTask && (listenerObj.id = options.id); // 任务监听器特有的 id 字段
|
isTask && (listenerObj.id = options.id) // 任务监听器特有的 id 字段
|
||||||
switch (options.listenerType) {
|
switch (options.listenerType) {
|
||||||
case "scriptListener":
|
case "scriptListener":
|
||||||
listenerObj.script = createScriptObject(options, prefix);
|
listenerObj.script = createScriptObject(options, prefix)
|
||||||
break;
|
break
|
||||||
case "expressionListener":
|
case "expressionListener":
|
||||||
listenerObj.expression = options.expression;
|
listenerObj.expression = options.expression
|
||||||
break;
|
break
|
||||||
case "delegateExpressionListener":
|
case "delegateExpressionListener":
|
||||||
listenerObj.delegateExpression = options.delegateExpression;
|
listenerObj.delegateExpression = options.delegateExpression
|
||||||
break;
|
break
|
||||||
default:
|
default:
|
||||||
listenerObj.class = options.class;
|
listenerObj.class = options.class
|
||||||
}
|
}
|
||||||
// 注入字段
|
// 注入字段
|
||||||
if (options.fields) {
|
if (options.fields) {
|
||||||
listenerObj.fields = options.fields.map(field => {
|
listenerObj.fields = options.fields.map(field => {
|
||||||
return createFieldObject(field, prefix);
|
return createFieldObject(field, prefix)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
// 任务监听器的 定时器 设置
|
// 任务监听器的 定时器 设置
|
||||||
if (isTask && options.event === "timeout" && !!options.eventDefinitionType) {
|
if (isTask && options.event === "timeout" && !!options.eventDefinitionType) {
|
||||||
const timeDefinition = window.bpmnInstances.moddle.create("bpmn:FormalExpression", { body: options.eventTimeDefinitions });
|
const timeDefinition = window.bpmnInstances.moddle.create("bpmn:FormalExpression", { body: options.eventTimeDefinitions })
|
||||||
const TimerEventDefinition = window.bpmnInstances.moddle.create("bpmn:TimerEventDefinition", {
|
const TimerEventDefinition = window.bpmnInstances.moddle.create("bpmn:TimerEventDefinition", {
|
||||||
id: `TimerEventDefinition_${uuid(8)}`,
|
id: `TimerEventDefinition_${uuid(8)}`,
|
||||||
[`time${options.eventDefinitionType.replace(/^\S/, s => s.toUpperCase())}`]: timeDefinition
|
[`time${options.eventDefinitionType.replace(/^\S/, s => s.toUpperCase())}`]: timeDefinition
|
||||||
});
|
})
|
||||||
listenerObj.eventDefinitions = [TimerEventDefinition];
|
listenerObj.eventDefinitions = [TimerEventDefinition]
|
||||||
}
|
}
|
||||||
return window.bpmnInstances.moddle.create(`${prefix}:${isTask ? "TaskListener" : "ExecutionListener"}`, listenerObj);
|
return window.bpmnInstances.moddle.create(`${prefix}:${isTask ? "TaskListener" : "ExecutionListener"}`, listenerObj)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建 监听器的注入字段 实例
|
// 创建 监听器的注入字段 实例
|
||||||
export function createFieldObject(option, prefix) {
|
export function createFieldObject (option, prefix) {
|
||||||
const { name, fieldType, string, expression } = option;
|
const { name, fieldType, string, expression } = option
|
||||||
const fieldConfig = fieldType === "string" ? { name, string } : { name, expression };
|
const fieldConfig = fieldType === "string" ? { name, string } : { name, expression }
|
||||||
return window.bpmnInstances.moddle.create(`${prefix}:Field`, fieldConfig);
|
return window.bpmnInstances.moddle.create(`${prefix}:Field`, fieldConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建脚本实例
|
// 创建脚本实例
|
||||||
export function createScriptObject(options, prefix) {
|
export function createScriptObject (options, prefix) {
|
||||||
const { scriptType, scriptFormat, value, resource } = options;
|
const { scriptType, scriptFormat, value, resource } = options
|
||||||
const scriptConfig = scriptType === "inlineScript" ? { scriptFormat, value } : { scriptFormat, resource };
|
const scriptConfig = scriptType === "inlineScript" ? { scriptFormat, value } : { scriptFormat, resource }
|
||||||
return window.bpmnInstances.moddle.create(`${prefix}:Script`, scriptConfig);
|
return window.bpmnInstances.moddle.create(`${prefix}:Script`, scriptConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新元素扩展属性
|
// 更新元素扩展属性
|
||||||
export function updateElementExtensions(element, extensionList) {
|
export function updateElementExtensions (element, extensionList) {
|
||||||
|
console.log(element, 'element')
|
||||||
|
console.log(extensionList, 'extensionList')
|
||||||
const extensions = window.bpmnInstances.moddle.create("bpmn:ExtensionElements", {
|
const extensions = window.bpmnInstances.moddle.create("bpmn:ExtensionElements", {
|
||||||
values: extensionList
|
values: extensionList
|
||||||
});
|
})
|
||||||
|
console.log(extensions, 'extensionsextensions')
|
||||||
|
console.log(window.bpmnInstances.modeling, 'window.bpmnInstances.modeling')
|
||||||
window.bpmnInstances.modeling.updateProperties(element, {
|
window.bpmnInstances.modeling.updateProperties(element, {
|
||||||
extensionElements: extensions
|
extensionElements: extensions.values
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建一个id
|
// 创建一个id
|
||||||
export function uuid(length = 8, chars) {
|
export function uuid (length = 8, chars) {
|
||||||
let result = "";
|
let result = ""
|
||||||
let charsString = chars || "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
let charsString = chars || "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
for (let i = length; i > 0; --i) {
|
for (let i = length; i > 0; --i) {
|
||||||
result += charsString[Math.floor(Math.random() * charsString.length)];
|
result += charsString[Math.floor(Math.random() * charsString.length)]
|
||||||
}
|
}
|
||||||
return result;
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue