提交
This commit is contained in:
9
src/views/Process-supervision/flowPath/.bpmnlintrc.json
Normal file
9
src/views/Process-supervision/flowPath/.bpmnlintrc.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": [
|
||||
"bpmnlint:recommended",
|
||||
"plugin:local/recommended"
|
||||
],
|
||||
"rules": {
|
||||
"local/no-manual-task": "warn"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import translations from '../lang/zh'
|
||||
|
||||
// export default function customTranslate(template, replacements) {
|
||||
// replacements = replacements || {}
|
||||
//
|
||||
// // Translate
|
||||
// template = translations[template] || template
|
||||
//
|
||||
// // Replace
|
||||
// return template.replace(/{([^}]+)}/g, function(_, key) {
|
||||
// var str = replacements[key]
|
||||
// if (
|
||||
// translations[replacements[key]] !== null &&
|
||||
// translations[replacements[key]] !== 'undefined'
|
||||
// ) {
|
||||
// str = translations[replacements[key]]
|
||||
// }
|
||||
// return str || '{' + key + '}'
|
||||
// })
|
||||
// }
|
||||
|
||||
export default function customTranslate(template, replacements) {
|
||||
replacements = replacements || {};
|
||||
|
||||
// Translate
|
||||
template = translations[template] || template;
|
||||
|
||||
// Replace
|
||||
return template.replace(/{([^}]+)}/g, function(_, key) {
|
||||
return replacements[key] || '{' + key + '}';
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
|
||||
import executionListenerDialog from '../components/nodePanel/property/executionListener'
|
||||
export default {
|
||||
components: {
|
||||
executionListenerDialog
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
executionListenerLength: 0,
|
||||
dialogName: null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
computedExecutionListenerLength() {
|
||||
this.executionListenerLength = this.element.businessObject.extensionElements.values.length == 0
|
||||
},
|
||||
finishExecutionListener() {
|
||||
if (this.dialogName === 'executionListenerDialog') {
|
||||
this.computedExecutionListenerLength()
|
||||
}
|
||||
this.dialogName = ''
|
||||
}
|
||||
}
|
||||
}
|
||||
70
src/views/Process-supervision/flowPath/common/mixinPanel.js
Normal file
70
src/views/Process-supervision/flowPath/common/mixinPanel.js
Normal file
@@ -0,0 +1,70 @@
|
||||
import xcrud from 'xcrud'
|
||||
import golbalConfig from 'xcrud/package/common/config'
|
||||
import showConfig from '../flowable/showConfig'
|
||||
golbalConfig.set({
|
||||
input: {
|
||||
// size: 'mini'
|
||||
},
|
||||
select: {
|
||||
// size: 'mini'
|
||||
},
|
||||
colorPicker: {
|
||||
showAlpha: true
|
||||
},
|
||||
xform: {
|
||||
form: {
|
||||
labelWidth: 'auto'
|
||||
// size: 'mini'
|
||||
}
|
||||
}
|
||||
})
|
||||
export default {
|
||||
components: { xForm: xcrud.xForm },
|
||||
props: {
|
||||
modeler: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
element: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
categorys: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'formData.id': function(val) {
|
||||
this.updateProperties({ id: val })
|
||||
},
|
||||
'formData.name': function(val) {
|
||||
this.updateProperties({ name: val })
|
||||
},
|
||||
'formData.documentation': function(val) {
|
||||
if (!val) {
|
||||
this.updateProperties({ documentation: [] })
|
||||
return
|
||||
}
|
||||
const documentationElement = this.modeler.get('moddle').create('bpmn:Documentation', { text: val })
|
||||
this.updateProperties({ documentation: [documentationElement] })
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
updateProperties(properties) {
|
||||
const modeling = this.modeler.get('modeling')
|
||||
modeling.updateProperties(this.element, properties)
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
elementType() {
|
||||
const bizObj = this.element.businessObject
|
||||
return bizObj.eventDefinitions
|
||||
? bizObj.eventDefinitions[0].$type
|
||||
: bizObj.$type
|
||||
},
|
||||
showConfig() {
|
||||
return showConfig[this.elementType] || {}
|
||||
}
|
||||
}
|
||||
}
|
||||
22
src/views/Process-supervision/flowPath/common/mixinXcrud.js
Normal file
22
src/views/Process-supervision/flowPath/common/mixinXcrud.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import xcrud from 'xcrud'
|
||||
import golbalConfig from 'xcrud/package/common/config'
|
||||
golbalConfig.set({
|
||||
input: {
|
||||
// size: 'mini'
|
||||
},
|
||||
select: {
|
||||
// size: 'mini'
|
||||
},
|
||||
colorPicker: {
|
||||
showAlpha: true
|
||||
},
|
||||
xform: {
|
||||
form: {
|
||||
labelWidth: 'auto'
|
||||
// size: 'mini'
|
||||
}
|
||||
}
|
||||
})
|
||||
export default {
|
||||
components: { xForm: xcrud.xForm }
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
export function commonParse(element) {
|
||||
const result = {
|
||||
...element.businessObject,
|
||||
...element.businessObject.$attrs
|
||||
}
|
||||
return formatJsonKeyValue(result)
|
||||
}
|
||||
|
||||
export function formatJsonKeyValue(result) {
|
||||
// 移除flowable前缀,格式化数组
|
||||
for (const key in result) {
|
||||
if (key.indexOf('flowable:') === 0) {
|
||||
const newKey = key.replace('flowable:', '')
|
||||
result[newKey] = result[key]
|
||||
delete result[key]
|
||||
}
|
||||
}
|
||||
result = documentationParse(result)
|
||||
return result
|
||||
}
|
||||
|
||||
export function documentationParse(obj) {
|
||||
if ('documentation' in obj) {
|
||||
let str = ''
|
||||
obj.documentation.forEach(item => {
|
||||
str += item.text
|
||||
})
|
||||
obj.documentation = str
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
export function conditionExpressionParse(obj) {
|
||||
if ('conditionExpression' in obj) {
|
||||
if (obj.conditionExpression) {
|
||||
obj.conditionExpression = obj.conditionExpression.body
|
||||
}
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
export function userTaskParse(obj) {
|
||||
for (const key in obj) {
|
||||
if (key === 'candidateUsers') {
|
||||
obj.userType = 'candidateUsers'
|
||||
obj[key] = obj[key].split(',') || []
|
||||
} else if (key === 'candidateGroups') {
|
||||
obj.userType = 'candidateGroups'
|
||||
obj[key] = obj[key].split(',') || []
|
||||
} else if (key === 'assignee') {
|
||||
obj.userType = 'assignee'
|
||||
}
|
||||
}
|
||||
return obj
|
||||
}
|
||||
@@ -0,0 +1,524 @@
|
||||
import {
|
||||
assign,
|
||||
forEach,
|
||||
isArray,
|
||||
every
|
||||
} from 'min-dash';
|
||||
|
||||
import {
|
||||
is
|
||||
} from 'bpmn-js/lib/util/ModelUtil';
|
||||
|
||||
import {
|
||||
isExpanded,
|
||||
isEventSubProcess
|
||||
} from 'bpmn-js/lib/util/DiUtil';
|
||||
|
||||
import {
|
||||
isAny
|
||||
} from 'bpmn-js/lib/features/modeling/util/ModelingUtil';
|
||||
|
||||
import {
|
||||
getChildLanes
|
||||
} from 'bpmn-js/lib/features/modeling/util/LaneUtil';
|
||||
|
||||
import {
|
||||
hasPrimaryModifier
|
||||
} from 'diagram-js/lib/util/Mouse';
|
||||
|
||||
|
||||
/**
|
||||
* A provider for BPMN 2.0 elements context pad
|
||||
*/
|
||||
export default function ContextPadProvider(
|
||||
config, injector, eventBus,
|
||||
contextPad, modeling, elementFactory,
|
||||
connect, create, popupMenu,
|
||||
canvas, rules, translate) {
|
||||
|
||||
config = config || {};
|
||||
|
||||
contextPad.registerProvider(this);
|
||||
|
||||
this._contextPad = contextPad;
|
||||
|
||||
this._modeling = modeling;
|
||||
|
||||
this._elementFactory = elementFactory;
|
||||
this._connect = connect;
|
||||
this._create = create;
|
||||
this._popupMenu = popupMenu;
|
||||
this._canvas = canvas;
|
||||
this._rules = rules;
|
||||
this._translate = translate;
|
||||
|
||||
if (config.autoPlace !== false) {
|
||||
this._autoPlace = injector.get('autoPlace', false);
|
||||
}
|
||||
|
||||
eventBus.on('create.end', 250, function(event) {
|
||||
var context = event.context,
|
||||
shape = context.shape;
|
||||
|
||||
if (!hasPrimaryModifier(event) || !contextPad.isOpen(shape)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var entries = contextPad.getEntries(shape);
|
||||
|
||||
if (entries.replace) {
|
||||
entries.replace.action.click(event, shape);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ContextPadProvider.$inject = [
|
||||
'config.contextPad',
|
||||
'injector',
|
||||
'eventBus',
|
||||
'contextPad',
|
||||
'modeling',
|
||||
'elementFactory',
|
||||
'connect',
|
||||
'create',
|
||||
'popupMenu',
|
||||
'canvas',
|
||||
'rules',
|
||||
'translate'
|
||||
];
|
||||
|
||||
ContextPadProvider.prototype.getMultiElementContextPadEntries = function(elements) {
|
||||
var modeling = this._modeling;
|
||||
|
||||
var actions = {};
|
||||
|
||||
if (this._isDeleteAllowed(elements)) {
|
||||
assign(actions, {
|
||||
'delete': {
|
||||
group: 'edit',
|
||||
className: 'bpmn-icon-trash',
|
||||
title: this._translate('Remove'),
|
||||
action: {
|
||||
click: function(event, elements) {
|
||||
modeling.removeElements(elements.slice());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return actions;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {djs.model.Base[]} elements
|
||||
* @return {boolean}
|
||||
*/
|
||||
ContextPadProvider.prototype._isDeleteAllowed = function(elements) {
|
||||
|
||||
var baseAllowed = this._rules.allowed('elements.delete', {
|
||||
elements: elements
|
||||
});
|
||||
|
||||
if (isArray(baseAllowed)) {
|
||||
return every(baseAllowed, function(element) {
|
||||
return includes(baseAllowed, element);
|
||||
});
|
||||
}
|
||||
|
||||
return baseAllowed;
|
||||
};
|
||||
|
||||
ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
||||
var contextPad = this._contextPad,
|
||||
modeling = this._modeling,
|
||||
|
||||
elementFactory = this._elementFactory,
|
||||
connect = this._connect,
|
||||
create = this._create,
|
||||
popupMenu = this._popupMenu,
|
||||
rules = this._rules,
|
||||
autoPlace = this._autoPlace,
|
||||
translate = this._translate;
|
||||
|
||||
var actions = {};
|
||||
|
||||
if (element.type === 'label') {
|
||||
return actions;
|
||||
}
|
||||
|
||||
var businessObject = element.businessObject;
|
||||
|
||||
function startConnect(event, element) {
|
||||
connect.start(event, element);
|
||||
}
|
||||
|
||||
function removeElement(e, element) {
|
||||
modeling.removeElements([ element ]);
|
||||
}
|
||||
|
||||
function getReplaceMenuPosition(element) {
|
||||
|
||||
var Y_OFFSET = 5;
|
||||
|
||||
var pad = contextPad.getPad(element).html;
|
||||
|
||||
var padRect = pad.getBoundingClientRect();
|
||||
|
||||
var pos = {
|
||||
x: padRect.left,
|
||||
y: padRect.bottom + Y_OFFSET
|
||||
};
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create an append action
|
||||
*
|
||||
* @param {string} type
|
||||
* @param {string} className
|
||||
* @param {string} [title]
|
||||
* @param {Object} [options]
|
||||
*
|
||||
* @return {Object} descriptor
|
||||
*/
|
||||
function appendAction(type, className, title, options) {
|
||||
|
||||
if (typeof title !== 'string') {
|
||||
options = title;
|
||||
title = translate('Append {type}', { type: type.replace(/^bpmn:/, '') });
|
||||
}
|
||||
|
||||
function appendStart(event, element) {
|
||||
|
||||
var shape = elementFactory.createShape(assign({ type: type }, options));
|
||||
create.start(event, shape, {
|
||||
source: element
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var append = autoPlace ? function(event, element) {
|
||||
var shape = elementFactory.createShape(assign({ type: type }, options));
|
||||
|
||||
autoPlace.append(element, shape);
|
||||
} : appendStart;
|
||||
|
||||
|
||||
return {
|
||||
group: 'model',
|
||||
className: className,
|
||||
title: title,
|
||||
action: {
|
||||
dragstart: appendStart,
|
||||
click: append
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function splitLaneHandler(count) {
|
||||
|
||||
return function(event, element) {
|
||||
|
||||
// actual split
|
||||
modeling.splitLane(element, count);
|
||||
|
||||
// refresh context pad after split to
|
||||
// get rid of split icons
|
||||
contextPad.open(element, true);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
if (isAny(businessObject, [ 'bpmn:Lane', 'bpmn:Participant' ]) && isExpanded(element)) {
|
||||
|
||||
var childLanes = getChildLanes(element);
|
||||
|
||||
assign(actions, {
|
||||
'lane-insert-above': {
|
||||
group: 'lane-insert-above',
|
||||
className: 'bpmn-icon-lane-insert-above',
|
||||
title: translate('Add Lane above'),
|
||||
action: {
|
||||
click: function(event, element) {
|
||||
modeling.addLane(element, 'top');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (childLanes.length < 2) {
|
||||
|
||||
if (element.height >= 120) {
|
||||
assign(actions, {
|
||||
'lane-divide-two': {
|
||||
group: 'lane-divide',
|
||||
className: 'bpmn-icon-lane-divide-two',
|
||||
title: translate('Divide into two Lanes'),
|
||||
action: {
|
||||
click: splitLaneHandler(2)
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (element.height >= 180) {
|
||||
assign(actions, {
|
||||
'lane-divide-three': {
|
||||
group: 'lane-divide',
|
||||
className: 'bpmn-icon-lane-divide-three',
|
||||
title: translate('Divide into three Lanes'),
|
||||
action: {
|
||||
click: splitLaneHandler(3)
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
assign(actions, {
|
||||
'lane-insert-below': {
|
||||
group: 'lane-insert-below',
|
||||
className: 'bpmn-icon-lane-insert-below',
|
||||
title: translate('Add Lane below'),
|
||||
action: {
|
||||
click: function(event, element) {
|
||||
modeling.addLane(element, 'bottom');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (is(businessObject, 'bpmn:FlowNode')) {
|
||||
|
||||
if (is(businessObject, 'bpmn:EventBasedGateway')) {
|
||||
|
||||
assign(actions, {
|
||||
'append.receive-task': appendAction(
|
||||
'bpmn:ReceiveTask',
|
||||
'bpmn-icon-receive-task',
|
||||
translate('Append ReceiveTask')
|
||||
),
|
||||
'append.message-intermediate-event': appendAction(
|
||||
'bpmn:IntermediateCatchEvent',
|
||||
'bpmn-icon-intermediate-event-catch-message',
|
||||
translate('Append MessageIntermediateCatchEvent'),
|
||||
{ eventDefinitionType: 'bpmn:MessageEventDefinition' }
|
||||
),
|
||||
'append.timer-intermediate-event': appendAction(
|
||||
'bpmn:IntermediateCatchEvent',
|
||||
'bpmn-icon-intermediate-event-catch-timer',
|
||||
translate('Append TimerIntermediateCatchEvent'),
|
||||
{ eventDefinitionType: 'bpmn:TimerEventDefinition' }
|
||||
),
|
||||
'append.condition-intermediate-event': appendAction(
|
||||
'bpmn:IntermediateCatchEvent',
|
||||
'bpmn-icon-intermediate-event-catch-condition',
|
||||
translate('Append ConditionIntermediateCatchEvent'),
|
||||
{ eventDefinitionType: 'bpmn:ConditionalEventDefinition' }
|
||||
),
|
||||
'append.signal-intermediate-event': appendAction(
|
||||
'bpmn:IntermediateCatchEvent',
|
||||
'bpmn-icon-intermediate-event-catch-signal',
|
||||
translate('Append SignalIntermediateCatchEvent'),
|
||||
{ eventDefinitionType: 'bpmn:SignalEventDefinition' }
|
||||
)
|
||||
});
|
||||
} else
|
||||
|
||||
if (isEventType(businessObject, 'bpmn:BoundaryEvent', 'bpmn:CompensateEventDefinition')) {
|
||||
|
||||
assign(actions, {
|
||||
'append.compensation-activity':
|
||||
appendAction(
|
||||
'bpmn:Task',
|
||||
'bpmn-icon-task',
|
||||
translate('Append compensation activity'),
|
||||
{
|
||||
isForCompensation: true
|
||||
}
|
||||
)
|
||||
});
|
||||
} else
|
||||
|
||||
if (!is(businessObject, 'bpmn:EndEvent') &&
|
||||
!businessObject.isForCompensation &&
|
||||
!isEventType(businessObject, 'bpmn:IntermediateThrowEvent', 'bpmn:LinkEventDefinition') &&
|
||||
!isEventSubProcess(businessObject)) {
|
||||
|
||||
assign(actions, {
|
||||
'append.end-event': appendAction(
|
||||
'bpmn:EndEvent',
|
||||
'bpmn-icon-end-event-none',
|
||||
translate('Append EndEvent')
|
||||
),
|
||||
'append.gateway': appendAction(
|
||||
'bpmn:ExclusiveGateway',
|
||||
'bpmn-icon-gateway-none',
|
||||
translate('Append Gateway')
|
||||
),
|
||||
'append.append-user-task': appendAction(
|
||||
'bpmn:UserTask',
|
||||
'bpmn-icon-user-task',
|
||||
'添加用户任务'
|
||||
),
|
||||
'append.intermediate-event': appendAction(
|
||||
'bpmn:IntermediateThrowEvent',
|
||||
'bpmn-icon-intermediate-event-none',
|
||||
translate('Append Intermediate/Boundary Event')
|
||||
)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!popupMenu.isEmpty(element, 'bpmn-replace')) {
|
||||
|
||||
// Replace menu entry
|
||||
assign(actions, {
|
||||
'replace': {
|
||||
group: 'edit',
|
||||
className: 'bpmn-icon-screw-wrench',
|
||||
title: translate('Change type'),
|
||||
action: {
|
||||
click: function(event, element) {
|
||||
|
||||
var position = assign(getReplaceMenuPosition(element), {
|
||||
cursor: { x: event.x, y: event.y }
|
||||
});
|
||||
|
||||
popupMenu.open(element, 'bpmn-replace', position, {
|
||||
title: translate('Change element'),
|
||||
width: 300,
|
||||
search: true
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (is(businessObject, 'bpmn:SequenceFlow')) {
|
||||
assign(actions, {
|
||||
'append.text-annotation': appendAction(
|
||||
'bpmn:TextAnnotation',
|
||||
'bpmn-icon-text-annotation'
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
isAny(businessObject, [
|
||||
'bpmn:FlowNode',
|
||||
'bpmn:InteractionNode',
|
||||
'bpmn:DataObjectReference',
|
||||
'bpmn:DataStoreReference',
|
||||
])
|
||||
) {
|
||||
assign(actions, {
|
||||
'append.text-annotation': appendAction(
|
||||
'bpmn:TextAnnotation',
|
||||
'bpmn-icon-text-annotation'
|
||||
),
|
||||
|
||||
'connect': {
|
||||
group: 'connect',
|
||||
className: 'bpmn-icon-connection-multi',
|
||||
title: translate(
|
||||
'Connect using ' +
|
||||
(businessObject.isForCompensation
|
||||
? ''
|
||||
: 'Sequence/MessageFlow or ') +
|
||||
'Association'
|
||||
),
|
||||
action: {
|
||||
click: startConnect,
|
||||
dragstart: startConnect,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (is(businessObject, 'bpmn:TextAnnotation')) {
|
||||
assign(actions, {
|
||||
'connect': {
|
||||
group: 'connect',
|
||||
className: 'bpmn-icon-connection-multi',
|
||||
title: translate('Connect using Association'),
|
||||
action: {
|
||||
click: startConnect,
|
||||
dragstart: startConnect,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (isAny(businessObject, [ 'bpmn:DataObjectReference', 'bpmn:DataStoreReference' ])) {
|
||||
assign(actions, {
|
||||
'connect': {
|
||||
group: 'connect',
|
||||
className: 'bpmn-icon-connection-multi',
|
||||
title: translate('Connect using DataInputAssociation'),
|
||||
action: {
|
||||
click: startConnect,
|
||||
dragstart: startConnect
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (is(businessObject, 'bpmn:Group')) {
|
||||
assign(actions, {
|
||||
'append.text-annotation': appendAction('bpmn:TextAnnotation', 'bpmn-icon-text-annotation')
|
||||
});
|
||||
}
|
||||
|
||||
// delete element entry, only show if allowed by rules
|
||||
var deleteAllowed = rules.allowed('elements.delete', { elements: [ element ] });
|
||||
|
||||
if (isArray(deleteAllowed)) {
|
||||
|
||||
// was the element returned as a deletion candidate?
|
||||
deleteAllowed = deleteAllowed[0] === element;
|
||||
}
|
||||
|
||||
if (deleteAllowed) {
|
||||
assign(actions, {
|
||||
'delete': {
|
||||
group: 'edit',
|
||||
className: 'bpmn-icon-trash',
|
||||
title: translate('Remove'),
|
||||
action: {
|
||||
click: removeElement
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return actions;
|
||||
};
|
||||
|
||||
|
||||
// helpers /////////
|
||||
|
||||
function isEventType(eventBo, type, definition) {
|
||||
|
||||
var isType = eventBo.$instanceOf(type);
|
||||
var isDefinition = false;
|
||||
|
||||
var definitions = eventBo.eventDefinitions || [];
|
||||
forEach(definitions, function(def) {
|
||||
if (def.$type === definition) {
|
||||
isDefinition = true;
|
||||
}
|
||||
});
|
||||
|
||||
return isType && isDefinition;
|
||||
}
|
||||
|
||||
function includes(array, item) {
|
||||
return array.indexOf(item) !== -1;
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
import { assign } from "min-dash";
|
||||
|
||||
export default function CustomPalette(
|
||||
palette,
|
||||
create,
|
||||
elementFactory,
|
||||
handTool,
|
||||
lassoTool,
|
||||
spaceTool,
|
||||
globalConnect,
|
||||
translate
|
||||
) {
|
||||
this.create = create;
|
||||
this.elementFactory = elementFactory;
|
||||
this.handTool = handTool;
|
||||
this.lassoTool = lassoTool;
|
||||
this.spaceTool = spaceTool;
|
||||
this.globalConnect = globalConnect;
|
||||
this.translate = translate;
|
||||
|
||||
palette.registerProvider(this);
|
||||
}
|
||||
|
||||
CustomPalette.$inject = [
|
||||
"palette",
|
||||
"create",
|
||||
"elementFactory",
|
||||
"handTool",
|
||||
"lassoTool",
|
||||
"spaceTool",
|
||||
"globalConnect",
|
||||
"translate"
|
||||
];
|
||||
|
||||
CustomPalette.prototype.getPaletteEntries = function (element) {
|
||||
const {
|
||||
create,
|
||||
elementFactory,
|
||||
handTool,
|
||||
lassoTool,
|
||||
spaceTool,
|
||||
globalConnect,
|
||||
translate
|
||||
} = this;
|
||||
|
||||
function createAction(type, group, className, title, options) {
|
||||
function createListener(event) {
|
||||
var shape = elementFactory.createShape(assign({ type: type }, options));
|
||||
|
||||
if (options) {
|
||||
shape.businessObject.di.isExpanded = options.isExpanded;
|
||||
}
|
||||
|
||||
create.start(event, shape);
|
||||
}
|
||||
|
||||
var shortType = type.replace(/^bpmn:/, "");
|
||||
|
||||
return {
|
||||
group: group,
|
||||
className: className,
|
||||
title: title || translate("Create {type}", { type: shortType }),
|
||||
action: {
|
||||
dragstart: createListener,
|
||||
click: createListener
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
'hand-tool': {
|
||||
group: 'tools',
|
||||
className: 'bpmn-icon-hand-tool',
|
||||
title: '激活抓手工具',
|
||||
action: {
|
||||
click: function(event) {
|
||||
handTool.activateHand(event);
|
||||
}
|
||||
}
|
||||
},
|
||||
"lasso-tool": {
|
||||
group: "tools",
|
||||
className: "bpmn-icon-lasso-tool",
|
||||
title: "激活套索工具",
|
||||
action: {
|
||||
click: function (event) {
|
||||
lassoTool.activateSelection(event);
|
||||
}
|
||||
}
|
||||
},
|
||||
'space-tool': {
|
||||
group: 'tools',
|
||||
className: 'bpmn-icon-space-tool',
|
||||
title: translate('Activate the create/remove space tool'),
|
||||
action: {
|
||||
click: function(event) {
|
||||
spaceTool.activateSelection(event);
|
||||
}
|
||||
}
|
||||
},
|
||||
'global-connect-tool': {
|
||||
group: 'tools',
|
||||
className: 'bpmn-icon-connection-multi',
|
||||
title: translate('Activate the global connect tool'),
|
||||
action: {
|
||||
click: function(event) {
|
||||
globalConnect.start(event);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"tool-separator": {
|
||||
group: "tools",
|
||||
separator: true
|
||||
},
|
||||
|
||||
"create.start-event": createAction(
|
||||
"bpmn:StartEvent",
|
||||
"event",
|
||||
"bpmn-icon-start-event-none",
|
||||
"创建开始节点"
|
||||
),
|
||||
"create.end-event": createAction(
|
||||
"bpmn:EndEvent",
|
||||
"event",
|
||||
"bpmn-icon-end-event-none",
|
||||
"创建结束节点"
|
||||
),
|
||||
"create.user-task": createAction(
|
||||
"bpmn:UserTask",
|
||||
"activity",
|
||||
"bpmn-icon-user-task",
|
||||
"创建用户任务"
|
||||
),
|
||||
"create.exclusive-gateway": createAction(
|
||||
"bpmn:ExclusiveGateway",
|
||||
"gateway",
|
||||
"bpmn-icon-gateway-xor",
|
||||
"创建排他网关"
|
||||
)
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
import CustomContextPad from './CustomContextPad';
|
||||
import CustomPalette from "./CustomPalette";
|
||||
|
||||
export default {
|
||||
__init__: [ 'paletteProvider','contextPadProvider'],
|
||||
paletteProvider: [ 'type', CustomPalette ],
|
||||
contextPadProvider: [ 'type', CustomContextPad ],
|
||||
};
|
||||
1195
src/views/Process-supervision/flowPath/flowable/flowable.json
Normal file
1195
src/views/Process-supervision/flowPath/flowable/flowable.json
Normal file
File diff suppressed because it is too large
Load Diff
33
src/views/Process-supervision/flowPath/flowable/init.js
Normal file
33
src/views/Process-supervision/flowPath/flowable/init.js
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
function randomStr() {
|
||||
return Math.random().toString(36).slice(-8)
|
||||
}
|
||||
|
||||
export default function() {
|
||||
return `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<definitions
|
||||
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
|
||||
xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC"
|
||||
xmlns:bioc="http://bpmn.io/schema/bpmn/biocolor/1.0"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:flowable="http://flowable.org/bpmn"
|
||||
targetNamespace="http://www.flowable.org/processdef"
|
||||
>
|
||||
<process id="flow_${randomStr()}" name="flow_${randomStr()}">
|
||||
<startEvent id="start_event" name="开始" />
|
||||
</process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_flow">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_flow" bpmnElement="T-2d89e7a3-ba79-4abd-9f64-ea59621c258c">
|
||||
<bpmndi:BPMNShape id="BPMNShape_start_event" bpmnElement="start_event" bioc:stroke="">
|
||||
<omgdc:Bounds x="240" y="200" width="30" height="30" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<omgdc:Bounds x="242" y="237" width="23" height="14" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</definitions>
|
||||
`
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
export default {
|
||||
'bpmn:EndEvent': {},
|
||||
'bpmn:StartEvent': {
|
||||
initiator: true,
|
||||
formKey: true
|
||||
},
|
||||
'bpmn:UserTask': {
|
||||
userType: true,
|
||||
assignee: true,
|
||||
candidateUsers: true,
|
||||
candidateGroups: true,
|
||||
async: true,
|
||||
priority: true,
|
||||
formKey: true,
|
||||
skipExpression: true,
|
||||
dueDate: true,
|
||||
taskListener: true
|
||||
},
|
||||
'bpmn:ServiceTask': {
|
||||
async: true,
|
||||
skipExpression: true,
|
||||
isForCompensation: true,
|
||||
triggerable: true,
|
||||
class: true
|
||||
},
|
||||
'bpmn:ScriptTask': {
|
||||
async: true,
|
||||
isForCompensation: true,
|
||||
autoStoreVariables: true
|
||||
},
|
||||
'bpmn:ManualTask': {
|
||||
async: true,
|
||||
isForCompensation: true
|
||||
},
|
||||
'bpmn:ReceiveTask': {
|
||||
async: true,
|
||||
isForCompensation: true
|
||||
},
|
||||
'bpmn:SendTask': {
|
||||
async: true,
|
||||
isForCompensation: true
|
||||
},
|
||||
'bpmn:BusinessRuleTask': {
|
||||
async: true,
|
||||
isForCompensation: true,
|
||||
ruleVariablesInput: true,
|
||||
rules: true,
|
||||
resultVariable: true,
|
||||
exclude: true
|
||||
}
|
||||
}
|
||||
232
src/views/Process-supervision/flowPath/lang/zh.js
Normal file
232
src/views/Process-supervision/flowPath/lang/zh.js
Normal file
@@ -0,0 +1,232 @@
|
||||
export default {
|
||||
// Labels
|
||||
'Activate the global connect tool': '激活全局连接工具',
|
||||
'Append {type}': '添加 {type}',
|
||||
'Append Task': '添加任务',
|
||||
'Append Gateway': '添加网关',
|
||||
'Append EndEvent': '添加结束事件',
|
||||
'Append StartEvent': '添加开始事件',
|
||||
"Append Intermediate/Boundary Event": '添加边界事件',
|
||||
'Add Lane above': '在上面添加道',
|
||||
'Divide into two Lanes': '分割成两个道',
|
||||
'Divide into three Lanes': '分割成三个道',
|
||||
'Add Lane below': '在下面添加道',
|
||||
'Append compensation activity': '追加补偿活动',
|
||||
'Change type': '修改类型',
|
||||
'Connect using Association': '使用关联连接',
|
||||
'Connect using Sequence/MessageFlow or Association': '使用顺序/消息流或者关联连接',
|
||||
'Connect using DataInputAssociation': '使用数据输入关联连接',
|
||||
'Remove': '移除',
|
||||
'Activate the hand tool': '激活抓手工具',
|
||||
'Activate the lasso tool': '激活套索工具',
|
||||
'Activate the create/remove space tool': '激活创建/删除空间工具',
|
||||
'Create expanded SubProcess': '创建扩展子过程',
|
||||
'Create IntermediateThrowEvent/BoundaryEvent': '创建中间抛出事件/边界事件',
|
||||
'Create Pool/Participant': '创建池/参与者',
|
||||
'Parallel Multi Instance': '并行多重事件',
|
||||
'Sequential Multi Instance': '时序多重事件',
|
||||
'DataObjectReference': '数据对象参考',
|
||||
'DataStoreReference': '数据存储参考',
|
||||
'Loop': '循环',
|
||||
'Ad-hoc': '即席',
|
||||
'Create {type}': '创建 {type}',
|
||||
'Task': '任务',
|
||||
'Send Task': '发送任务',
|
||||
'Receive Task': '接收任务',
|
||||
'User Task': '用户任务',
|
||||
'Manual Task': '手工任务',
|
||||
'Business Rule Task': '业务规则任务',
|
||||
'Service Task': '服务任务',
|
||||
'Script Task': '脚本任务',
|
||||
'Call Activity': '调用活动',
|
||||
'Sub Process (collapsed)': '子流程(折叠的)',
|
||||
'Sub Process (expanded)': '子流程(展开的)',
|
||||
'Start Event': '开始事件',
|
||||
'StartEvent': '开始事件',
|
||||
'Intermediate Throw Event': '中间事件',
|
||||
'End Event': '结束事件',
|
||||
'EndEvent': '结束事件',
|
||||
'Create Gateway': '创建网关',
|
||||
'Create Intermediate/Boundary Event': '创建中间/边界事件',
|
||||
'Message Start Event': '消息开始事件',
|
||||
'Timer Start Event': '定时开始事件',
|
||||
'Conditional Start Event': '条件开始事件',
|
||||
'Signal Start Event': '信号开始事件',
|
||||
'Error Start Event': '错误开始事件',
|
||||
'Escalation Start Event': '升级开始事件',
|
||||
'Compensation Start Event': '补偿开始事件',
|
||||
'Message Start Event (non-interrupting)': '消息开始事件(非中断)',
|
||||
'Timer Start Event (non-interrupting)': '定时开始事件(非中断)',
|
||||
'Conditional Start Event (non-interrupting)': '条件开始事件(非中断)',
|
||||
'Signal Start Event (non-interrupting)': '信号开始事件(非中断)',
|
||||
'Escalation Start Event (non-interrupting)': '升级开始事件(非中断)',
|
||||
'Message Intermediate Catch Event': '消息中间捕获事件',
|
||||
'Message Intermediate Throw Event': '消息中间抛出事件',
|
||||
'Timer Intermediate Catch Event': '定时中间捕获事件',
|
||||
'Escalation Intermediate Throw Event': '升级中间抛出事件',
|
||||
'Conditional Intermediate Catch Event': '条件中间捕获事件',
|
||||
'Link Intermediate Catch Event': '链接中间捕获事件',
|
||||
'Link Intermediate Throw Event': '链接中间抛出事件',
|
||||
'Compensation Intermediate Throw Event': '补偿中间抛出事件',
|
||||
'Signal Intermediate Catch Event': '信号中间捕获事件',
|
||||
'Signal Intermediate Throw Event': '信号中间抛出事件',
|
||||
'Message End Event': '消息结束事件',
|
||||
'Escalation End Event': '定时结束事件',
|
||||
'Error End Event': '错误结束事件',
|
||||
'Cancel End Event': '取消结束事件',
|
||||
'Compensation End Event': '补偿结束事件',
|
||||
'Signal End Event': '信号结束事件',
|
||||
'Terminate End Event': '终止结束事件',
|
||||
'Message Boundary Event': '消息边界事件',
|
||||
'Message Boundary Event (non-interrupting)': '消息边界事件(非中断)',
|
||||
'Timer Boundary Event': '定时边界事件',
|
||||
'Timer Boundary Event (non-interrupting)': '定时边界事件(非中断)',
|
||||
'Escalation Boundary Event': '升级边界事件',
|
||||
'Escalation Boundary Event (non-interrupting)': '升级边界事件(非中断)',
|
||||
'Conditional Boundary Event': '条件边界事件',
|
||||
'Conditional Boundary Event (non-interrupting)': '条件边界事件(非中断)',
|
||||
'Error Boundary Event': '错误边界事件',
|
||||
'Cancel Boundary Event': '取消边界事件',
|
||||
'Signal Boundary Event': '信号边界事件',
|
||||
'Signal Boundary Event (non-interrupting)': '信号边界事件(非中断)',
|
||||
'Compensation Boundary Event': '补偿边界事件',
|
||||
'Exclusive Gateway': '互斥网关',
|
||||
'Parallel Gateway': '并行网关',
|
||||
'Inclusive Gateway': '相容网关',
|
||||
'Complex Gateway': '复杂网关',
|
||||
'Event based Gateway': '事件网关',
|
||||
'Transaction': '转运',
|
||||
'Sub Process': '子流程',
|
||||
'Event Sub Process': '事件子流程',
|
||||
'Collapsed Pool': '折叠池',
|
||||
'Expanded Pool': '展开池',
|
||||
// Errors
|
||||
'no parent for {element} in {parent}': '在{parent}里,{element}没有父类',
|
||||
'no shape type specified': '没有指定的形状类型',
|
||||
'flow elements must be children of pools/participants': '流元素必须是池/参与者的子类',
|
||||
'out of bounds release': 'out of bounds release',
|
||||
'more than {count} child lanes': '子道大于{count} ',
|
||||
'element required': '元素不能为空',
|
||||
'diagram not part of bpmn:Definitions': '流程图不符合bpmn规范',
|
||||
'no diagram to display': '没有可展示的流程图',
|
||||
'no process or collaboration to display': '没有可展示的流程/协作',
|
||||
'element {element} referenced by {referenced}#{property} not yet drawn': '由{referenced}#{property}引用的{element}元素仍未绘制',
|
||||
'already rendered {element}': '{element} 已被渲染',
|
||||
'failed to import {element}': '导入{element}失败',
|
||||
// 属性面板的参数
|
||||
'Id': '标识',
|
||||
'Name': '名称',
|
||||
'General': '常规',
|
||||
'Details': '详情',
|
||||
'Message Name': '消息名称',
|
||||
'Message': '消息',
|
||||
'Initiator': '创建者',
|
||||
'Asynchronous Continuations': '持续异步',
|
||||
'Asynchronous Before': '异步前',
|
||||
'Asynchronous After': '异步后',
|
||||
'Job Configuration': '工作配置',
|
||||
'Exclusive': '排除',
|
||||
'Job Priority': '工作优先级',
|
||||
'Retry Time Cycle': '重试时间周期',
|
||||
'Documentation': '文档',
|
||||
'Element Documentation': '元素文档',
|
||||
'History Configuration': '历史配置',
|
||||
'History Time To Live': '历史的生存时间',
|
||||
'Forms': '表单',
|
||||
'Form Key': '表单key',
|
||||
'Form Fields': '表单字段',
|
||||
'Business Key': '业务key',
|
||||
'Form Field': '表单字段',
|
||||
'ID': '编号',
|
||||
'Type': '类型',
|
||||
'Label': '名称',
|
||||
'Default Value': '默认值',
|
||||
'Validation': '校验',
|
||||
'Add Constraint': '添加约束',
|
||||
'Config': '配置',
|
||||
'Properties': '属性',
|
||||
'Add Property': '添加属性',
|
||||
'Value': '值',
|
||||
'Listeners': '监听器',
|
||||
'Execution Listener': '执行监听',
|
||||
'Event Type': '事件类型',
|
||||
'Listener Type': '监听器类型',
|
||||
'Java Class': 'Java类',
|
||||
'Expression': '表达式',
|
||||
'Must provide a value': '必须提供一个值',
|
||||
'Delegate Expression': '代理表达式',
|
||||
'Script': '脚本',
|
||||
'Script Format': '脚本格式',
|
||||
'Script Type': '脚本类型',
|
||||
'Inline Script': '内联脚本',
|
||||
'External Script': '外部脚本',
|
||||
'Resource': '资源',
|
||||
'Field Injection': '字段注入',
|
||||
'Extensions': '扩展',
|
||||
'Input/Output': '输入/输出',
|
||||
'Input Parameters': '输入参数',
|
||||
'Output Parameters': '输出参数',
|
||||
'Parameters': '参数',
|
||||
'Output Parameter': '输出参数',
|
||||
'Timer Definition Type': '定时器定义类型',
|
||||
'Timer Definition': '定时器定义',
|
||||
'Date': '日期',
|
||||
'Duration': '持续',
|
||||
'Cycle': '循环',
|
||||
'Signal': '信号',
|
||||
'Signal Name': '信号名称',
|
||||
'Escalation': '升级',
|
||||
'Error': '错误',
|
||||
'Link Name': '链接名称',
|
||||
'Condition': '条件名称',
|
||||
'Variable Name': '变量名称',
|
||||
'Variable Event': '变量事件',
|
||||
'Specify more than one variable change event as a comma separated list.': '多个变量事件以逗号隔开',
|
||||
'Wait for Completion': '等待完成',
|
||||
'Activity Ref': '活动参考',
|
||||
'Version Tag': '版本标签',
|
||||
'Executable': '可执行文件',
|
||||
'External Task Configuration': '扩展任务配置',
|
||||
'Task Priority': '任务优先级',
|
||||
'External': '外部',
|
||||
'Connector': '连接器',
|
||||
'Must configure Connector': '必须配置连接器',
|
||||
'Connector Id': '连接器编号',
|
||||
'Implementation': '实现方式',
|
||||
'Field Injections': '字段注入',
|
||||
'Fields': '字段',
|
||||
'Result Variable': '结果变量',
|
||||
'Topic': '主题',
|
||||
'Configure Connector': '配置连接器',
|
||||
'Input Parameter': '输入参数',
|
||||
'Assignee': '代理人',
|
||||
'Candidate Users': '候选用户',
|
||||
'Candidate Groups': '候选组',
|
||||
'Due Date': '到期时间',
|
||||
'Follow Up Date': '跟踪日期',
|
||||
'Priority': '优先级',
|
||||
'The follow up date as an EL expression (e.g. ${someDate} or an ISO date (e.g. 2015-06-26T09:54:00)': '跟踪日期必须符合EL表达式,如: ${someDate} ,或者一个ISO标准日期,如:2015-06-26T09:54:00',
|
||||
'The due date as an EL expression (e.g. ${someDate} or an ISO date (e.g. 2015-06-26T09:54:00)': '跟踪日期必须符合EL表达式,如: ${someDate} ,或者一个ISO标准日期,如:2015-06-26T09:54:00',
|
||||
'Variables': '变量'
|
||||
}
|
||||
|
||||
export const NodeName = {
|
||||
'bpmn:Process': '流程',
|
||||
'bpmn:StartEvent': '开始事件',
|
||||
'bpmn:IntermediateThrowEvent': '中间事件',
|
||||
'bpmn:Task': '任务',
|
||||
'bpmn:SendTask': '发送任务',
|
||||
'bpmn:ReceiveTask': '接收任务',
|
||||
'bpmn:UserTask': '用户任务',
|
||||
'bpmn:ManualTask': '手工任务',
|
||||
'bpmn:BusinessRuleTask': '业务规则任务',
|
||||
'bpmn:ServiceTask': '服务任务',
|
||||
'bpmn:ScriptTask': '脚本任务',
|
||||
'bpmn:EndEvent': '结束事件',
|
||||
'bpmn:SequenceFlow': '流程线',
|
||||
'bpmn:ExclusiveGateway': '互斥网关',
|
||||
'bpmn:ParallelGateway': '并行网关',
|
||||
'bpmn:InclusiveGateway': '相容网关',
|
||||
'bpmn:ComplexGateway': '复杂网关',
|
||||
'bpmn:EventBasedGateway': '事件网关'
|
||||
}
|
||||
427
src/views/Process-supervision/flowPath/tools.vue
Normal file
427
src/views/Process-supervision/flowPath/tools.vue
Normal file
@@ -0,0 +1,427 @@
|
||||
<template>
|
||||
<div
|
||||
v-loading="isView"
|
||||
class="flow-containers"
|
||||
:class="{ 'view-mode': isView }"
|
||||
>
|
||||
<el-container style="height: 100%">
|
||||
<el-header
|
||||
style="
|
||||
border-bottom: 1px solid rgb(218 218 218);
|
||||
height: auto;
|
||||
padding-left: 0px;
|
||||
"
|
||||
>
|
||||
<div
|
||||
style="
|
||||
display: flex;
|
||||
padding: 10px 0px;
|
||||
justify-content: space-between;
|
||||
"
|
||||
>
|
||||
<div>
|
||||
<el-upload
|
||||
action=""
|
||||
:before-upload="openBpmn"
|
||||
style="margin-right: 10px; display: inline-block"
|
||||
>
|
||||
<el-tooltip effect="dark" content="加载xml" placement="bottom">
|
||||
<el-button size="mini" icon="el-icon-folder-opened" />
|
||||
</el-tooltip>
|
||||
</el-upload>
|
||||
<el-tooltip effect="dark" content="新建" placement="bottom">
|
||||
<el-button
|
||||
size="mini"
|
||||
icon="el-icon-circle-plus"
|
||||
@click="newDiagram"
|
||||
/>
|
||||
</el-tooltip>
|
||||
<el-tooltip effect="dark" content="自适应屏幕" placement="bottom">
|
||||
<el-button size="mini" icon="el-icon-rank" @click="fitViewport" />
|
||||
</el-tooltip>
|
||||
<el-tooltip effect="dark" content="放大" placement="bottom">
|
||||
<el-button
|
||||
size="mini"
|
||||
icon="el-icon-zoom-in"
|
||||
@click="zoomViewport(true)"
|
||||
/>
|
||||
</el-tooltip>
|
||||
<el-tooltip effect="dark" content="缩小" placement="bottom">
|
||||
<el-button
|
||||
size="mini"
|
||||
icon="el-icon-zoom-out"
|
||||
@click="zoomViewport(false)"
|
||||
/>
|
||||
</el-tooltip>
|
||||
<el-tooltip effect="dark" content="后退" placement="bottom">
|
||||
<el-button
|
||||
size="mini"
|
||||
icon="el-icon-back"
|
||||
@click="modeler.get('commandStack').undo()"
|
||||
/>
|
||||
</el-tooltip>
|
||||
<el-tooltip effect="dark" content="前进" placement="bottom">
|
||||
<el-button
|
||||
size="mini"
|
||||
icon="el-icon-right"
|
||||
@click="modeler.get('commandStack').redo()"
|
||||
/>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<div>
|
||||
<el-button size="mini" icon="el-icon-s-check" @click="verifyXML"
|
||||
>校验xml</el-button
|
||||
>
|
||||
<el-button size="mini" icon="el-icon-view" @click="showXML"
|
||||
>查看xml</el-button
|
||||
>
|
||||
<el-button
|
||||
size="mini"
|
||||
icon="el-icon-download"
|
||||
@click="saveXML(true)"
|
||||
>下载xml</el-button
|
||||
>
|
||||
<el-button
|
||||
size="mini"
|
||||
icon="el-icon-picture"
|
||||
@click="saveImg('svg', true)"
|
||||
>下载svg</el-button
|
||||
>
|
||||
<el-button size="mini" type="primary" @click="save"
|
||||
>保存模型</el-button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</el-header>
|
||||
<el-container style="align-items: stretch">
|
||||
<el-main style="padding: 0">
|
||||
<div ref="canvas" class="canvas" />
|
||||
</el-main>
|
||||
<el-aside
|
||||
style="width: 400px; min-height: 650px; background-color: #f0f2f5"
|
||||
>
|
||||
<!-- <panel
|
||||
v-if="modeler"
|
||||
:modeler="modeler"
|
||||
:users="users"
|
||||
:groups="groups"
|
||||
:exps="exps"
|
||||
:categorys="categorys"
|
||||
/> -->
|
||||
</el-aside>
|
||||
</el-container>
|
||||
</el-container>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// 汉化
|
||||
import customTranslate from "./common/customTranslate";
|
||||
// import lintModule from "bpmn-js-bpmnlint";
|
||||
import Modeler from "bpmn-js/lib/Modeler";
|
||||
import bpmnlintConfig from "./.bpmnlintrc.json";
|
||||
// import panel from './PropertyPanel'
|
||||
import getInitStr from "./flowable/init";
|
||||
// 引入flowable的节点文件
|
||||
import FlowableModule from "./flowable/flowable.json";
|
||||
import customControlsModule from "./customPanel";
|
||||
|
||||
export default {
|
||||
components: {},
|
||||
props: {
|
||||
xml: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
users: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
groups: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
categorys: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
exps: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
isView: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
created() {},
|
||||
mounted() {
|
||||
// 生成实例
|
||||
this.modeler = new Modeler({
|
||||
container: this.$refs.canvas,
|
||||
additionalModules: [
|
||||
// lintModule,
|
||||
customControlsModule,
|
||||
{
|
||||
//汉化
|
||||
translate: ["value", customTranslate],
|
||||
},
|
||||
],
|
||||
linting: {
|
||||
bpmnlint: bpmnlintConfig,
|
||||
},
|
||||
moddleExtensions: {
|
||||
flowable: FlowableModule,
|
||||
},
|
||||
});
|
||||
// 新增流程定义
|
||||
if (!this.xml) {
|
||||
this.newDiagram();
|
||||
} else {
|
||||
this.createNewDiagram(this.xml);
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
newDiagram() {
|
||||
this.createNewDiagram(getInitStr());
|
||||
},
|
||||
// 让图能自适应屏幕
|
||||
fitViewport() {
|
||||
this.zoom = this.modeler.get("canvas").zoom("fit-viewport");
|
||||
const bbox = document
|
||||
.querySelector(".flow-containers .viewport")
|
||||
.getBBox();
|
||||
const currentViewbox = this.modeler.get("canvas").viewbox();
|
||||
const elementMid = {
|
||||
x: bbox.x + bbox.width / 2 - 65,
|
||||
y: bbox.y + bbox.height / 2,
|
||||
};
|
||||
this.modeler.get("canvas").viewbox({
|
||||
x: elementMid.x - currentViewbox.width / 2,
|
||||
y: elementMid.y - currentViewbox.height / 2,
|
||||
width: currentViewbox.width,
|
||||
height: currentViewbox.height,
|
||||
});
|
||||
this.zoom = (bbox.width / currentViewbox.width) * 1.8;
|
||||
},
|
||||
// 放大缩小
|
||||
zoomViewport(zoomIn = true) {
|
||||
this.zoom = this.modeler.get("canvas").zoom();
|
||||
this.zoom += zoomIn ? 0.1 : -0.1;
|
||||
this.modeler.get("canvas").zoom(this.zoom);
|
||||
},
|
||||
async createNewDiagram(data) {
|
||||
// 将字符串转换成图显示出来
|
||||
// data = data.replace(/<!\[CDATA\[(.+?)]]>/g, '<![CDATA[$1]]>')
|
||||
data = data.replace(/<!\[CDATA\[(.+?)]]>/g, function (match, str) {
|
||||
return str.replace(/</g, "<");
|
||||
});
|
||||
try {
|
||||
await this.modeler.importXML(data);
|
||||
// this.adjustPalette()
|
||||
this.fitViewport();
|
||||
} catch (err) {
|
||||
// console.error(err.message, err.warnings);
|
||||
}
|
||||
},
|
||||
// 对外 api
|
||||
getProcess() {
|
||||
const element = this.getProcessElement();
|
||||
return {
|
||||
id: element.id,
|
||||
name: element.name,
|
||||
category: element.$attrs["flowable:processCategory"],
|
||||
};
|
||||
},
|
||||
getProcessElement() {
|
||||
const rootElements = this.modeler.getDefinitions().rootElements;
|
||||
for (let i = 0; i < rootElements.length; i++) {
|
||||
if (rootElements[i].$type === "bpmn:Process") return rootElements[i];
|
||||
}
|
||||
},
|
||||
async verifyXML() {
|
||||
const linting = this.modeler.get("linting");
|
||||
linting.toggle();
|
||||
},
|
||||
async saveXML(download = false) {
|
||||
try {
|
||||
const { xml } = await this.modeler.saveXML({ format: true });
|
||||
if (download) {
|
||||
this.downloadFile(
|
||||
`${this.getProcessElement().name}.bpmn20.xml`,
|
||||
xml,
|
||||
"application/xml"
|
||||
);
|
||||
}
|
||||
return xml;
|
||||
} catch (err) {
|
||||
// console.log(err);
|
||||
}
|
||||
},
|
||||
async showXML() {
|
||||
try {
|
||||
const xml = await this.saveXML();
|
||||
this.$emit("showXML", xml);
|
||||
} catch (err) {
|
||||
// console.log(err);
|
||||
}
|
||||
},
|
||||
async saveImg(type = "svg", download = false) {
|
||||
try {
|
||||
const { svg } = await this.modeler.saveSVG({ format: true });
|
||||
if (download) {
|
||||
this.downloadFile(
|
||||
this.getProcessElement().name,
|
||||
svg,
|
||||
"image/svg+xml"
|
||||
);
|
||||
}
|
||||
return svg;
|
||||
} catch (err) {
|
||||
// console.log(err);
|
||||
}
|
||||
},
|
||||
async save() {
|
||||
const process = this.getProcess();
|
||||
const xml = await this.saveXML();
|
||||
const svg = await this.saveImg();
|
||||
const result = { process, xml, svg };
|
||||
this.$emit("save", result);
|
||||
window.parent.postMessage(result, "*");
|
||||
},
|
||||
openBpmn(file) {
|
||||
const reader = new FileReader();
|
||||
reader.readAsText(file, "utf-8");
|
||||
reader.onload = () => {
|
||||
this.createNewDiagram(reader.result);
|
||||
};
|
||||
return false;
|
||||
},
|
||||
downloadFile(filename, data, type) {
|
||||
const a = document.createElement("a");
|
||||
const url = window.URL.createObjectURL(new Blob([data], { type: type }));
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
},
|
||||
},
|
||||
|
||||
computed: {},
|
||||
|
||||
watch: {},
|
||||
};
|
||||
</script>
|
||||
<style lang="scss">
|
||||
/*左边工具栏以及编辑节点的样式*/
|
||||
@import "~bpmn-js/dist/assets/diagram-js.css";
|
||||
@import "~bpmn-js/dist/assets/bpmn-font/css/bpmn.css";
|
||||
@import "~bpmn-js/dist/assets/bpmn-font/css/bpmn-codes.css";
|
||||
@import "~bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css";
|
||||
@import "~bpmn-js-bpmnlint/dist/assets/css/bpmn-js-bpmnlint.css";
|
||||
.view-mode {
|
||||
.el-header,
|
||||
.el-aside,
|
||||
.djs-palette,
|
||||
.bjs-powered-by {
|
||||
display: none;
|
||||
}
|
||||
.el-loading-mask {
|
||||
background-color: initial;
|
||||
}
|
||||
.el-loading-spinner {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
.flow-containers {
|
||||
// background-color: #ffffff;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
.canvas {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
//flex: 1;
|
||||
//position: relative;
|
||||
//background: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PHBhdHRlcm4gaWQ9ImEiIHdpZHRoPSI0MCIgaGVpZ2h0PSI0MCIgcGF0dGVyblVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+PHBhdGggZD0iTTAgMTBoNDBNMTAgMHY0ME0wIDIwaDQwTTIwIDB2NDBNMCAzMGg0ME0zMCAwdjQwIiBmaWxsPSJub25lIiBzdHJva2U9IiNlMGUwZTAiIG9wYWNpdHk9Ii4yIi8+PHBhdGggZD0iTTQwIDBIMHY0MCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjZTBlMGUwIi8+PC9wYXR0ZXJuPjwvZGVmcz48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSJ1cmwoI2EpIi8+PC9zdmc+")
|
||||
//repeat !important;
|
||||
//div.toggle-mode {
|
||||
// display: none;
|
||||
//}
|
||||
}
|
||||
.panel {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 50px;
|
||||
width: 300px;
|
||||
}
|
||||
.load {
|
||||
margin-right: 10px;
|
||||
}
|
||||
.el-form-item__label {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.djs-palette {
|
||||
left: 0px !important;
|
||||
top: 0px;
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.djs-container svg {
|
||||
//min-height: 650px;
|
||||
}
|
||||
|
||||
.highlight.djs-shape .djs-visual > :nth-child(1) {
|
||||
fill: green !important;
|
||||
stroke: green !important;
|
||||
fill-opacity: 0.2 !important;
|
||||
}
|
||||
.highlight.djs-shape .djs-visual > :nth-child(2) {
|
||||
fill: green !important;
|
||||
}
|
||||
.highlight.djs-shape .djs-visual > path {
|
||||
fill: green !important;
|
||||
fill-opacity: 0.2 !important;
|
||||
stroke: green !important;
|
||||
}
|
||||
.highlight.djs-connection > .djs-visual > path {
|
||||
stroke: green !important;
|
||||
}
|
||||
// .djs-connection > .djs-visual > path {
|
||||
// stroke: orange !important;
|
||||
// stroke-dasharray: 4px !important;
|
||||
// fill-opacity: 0.2 !important;
|
||||
// }
|
||||
// .djs-shape .djs-visual > :nth-child(1) {
|
||||
// fill: orange !important;
|
||||
// stroke: orange !important;
|
||||
// stroke-dasharray: 4px !important;
|
||||
// fill-opacity: 0.2 !important;
|
||||
// }
|
||||
.highlight-todo.djs-connection > .djs-visual > path {
|
||||
stroke: orange !important;
|
||||
stroke-dasharray: 4px !important;
|
||||
fill-opacity: 0.2 !important;
|
||||
}
|
||||
.highlight-todo.djs-shape .djs-visual > :nth-child(1) {
|
||||
fill: orange !important;
|
||||
stroke: orange !important;
|
||||
stroke-dasharray: 4px !important;
|
||||
fill-opacity: 0.2 !important;
|
||||
}
|
||||
.overlays-div {
|
||||
font-size: 10px;
|
||||
color: red;
|
||||
width: 100px;
|
||||
top: -20px !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="less" scoped>
|
||||
@import url("../../../styles/comStyle.less");
|
||||
</style>
|
||||
Reference in New Issue
Block a user