53 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-01-21 15:35:43 +08:00
import { Ref } from 'vue';
import showConfig from '@/components/BpmnDesign/assets/showConfig';
interface Options {
modeler: any;
element: any;
}
export default (ops: Options) => {
const { modeler, element } = ops;
const elementType = computed(() => {
const bizObj = element.businessObject;
return bizObj.eventDefinitions ? bizObj.eventDefinitions[0].$type : bizObj.$type;
});
const config = computed(() => showConfig[elementType.value] || {});
const updateProperties = (properties: any) => {
const modeling = modeler.get('modeling');
modeling.updateProperties(element, properties);
};
2024-01-21 18:13:15 +08:00
const idChange = (newVal: string) => {
if (newVal) {
updateProperties({ id: newVal });
}
};
const nameChange = (newVal: string) => {
if (newVal) {
updateProperties({ name: newVal });
}
};
const documentationChange = (newVal: string) => {
if (newVal) {
const documentationElement = modeler.get('moddle').create('bpmn:Documentation', { text: newVal });
updateProperties({ documentation: [documentationElement] });
} else {
2024-01-21 22:35:34 +08:00
updateProperties({ documentation: null });
2024-01-21 18:13:15 +08:00
}
};
2024-01-21 15:35:43 +08:00
return {
elementType,
showConfig: config,
2024-01-21 18:13:15 +08:00
updateProperties,
idChange,
nameChange,
documentationChange
2024-01-21 15:35:43 +08:00
};
};