update 优化属性面板,当面板未选中时默认展示流程面板

This commit is contained in:
LiuHao 2024-01-31 15:33:05 +08:00
parent b97068c72f
commit a73ce7f8bf

View File

@ -20,6 +20,7 @@ interface propsType {
const props = withDefaults(defineProps<propsType>(), {}); const props = withDefaults(defineProps<propsType>(), {});
const element = ref<Element>(); const element = ref<Element>();
const processElement = ref<Element>();
const startEndType = ['bpmn:IntermediateThrowEvent', 'bpmn:StartEvent', 'bpmn:EndEvent']; const startEndType = ['bpmn:IntermediateThrowEvent', 'bpmn:StartEvent', 'bpmn:EndEvent'];
const taskType = [ const taskType = [
@ -36,6 +37,7 @@ const sequenceType = ['bpmn:SequenceFlow'];
const gatewayType = ['bpmn:InclusiveGateway', 'bpmn:ExclusiveGateway', 'bpmn:ParallelGateway', 'bpmn:EventBasedGateway']; const gatewayType = ['bpmn:InclusiveGateway', 'bpmn:ExclusiveGateway', 'bpmn:ParallelGateway', 'bpmn:EventBasedGateway'];
const processType = ['bpmn:Process']; const processType = ['bpmn:Process'];
//
const component = computed(() => { const component = computed(() => {
if (!element.value) return null; if (!element.value) return null;
const type = element.value.type; const type = element.value.type;
@ -57,20 +59,20 @@ const nodeName = computed(() => {
const handleModeler = () => { const handleModeler = () => {
props.modeler.on('root.added', (e: any) => { props.modeler.on('root.added', (e: any) => {
element.value = null;
if (e.element.type === 'bpmn:Process') { if (e.element.type === 'bpmn:Process') {
element.value = null;
nextTick(() => { nextTick(() => {
element.value = e.element; element.value = e.element;
// const modeling = props.modeler.get<Modeling>('modeling'); processElement.value = e.element;
// modeling.setColor(e.element.children, {
// fill: 'green'
// });
}); });
} }
}); });
props.modeler.on('element.click', (e: any) => { props.modeler.on('element.click', (e: any) => {
if (e.element.type === 'bpmn:Process') { if (e.element.type === 'bpmn:Process') {
element.value = e.element; nextTick(() => {
element.value = e.element;
processElement.value = e.element;
});
} }
}); });
props.modeler.on('selection.changed', (e: any) => { props.modeler.on('selection.changed', (e: any) => {
@ -81,6 +83,10 @@ const handleModeler = () => {
nextTick(() => { nextTick(() => {
element.value = newElement; element.value = newElement;
}); });
} else {
nextTick(() => {
element.value = processElement.value;
});
} }
}); });
}; };