2022-12-16 17:26:54 +08:00
|
|
|
<template>
|
|
|
|
<div class="process-design" :style="'display: flex; height:' + height">
|
2022-12-19 17:29:18 +08:00
|
|
|
<bpmn-process-designer
|
2022-12-16 17:26:54 +08:00
|
|
|
v-model="xmlString"
|
|
|
|
v-bind="controlForm"
|
|
|
|
keyboard
|
|
|
|
ref="processDesigner"
|
2022-12-20 14:34:38 +08:00
|
|
|
:eventlist="[
|
2022-12-16 17:26:54 +08:00
|
|
|
'element.click',
|
|
|
|
'connection.added',
|
|
|
|
'connection.removed',
|
|
|
|
'connection.changed',
|
|
|
|
]"
|
|
|
|
@element-click="elementClick"
|
|
|
|
@init-finished="initModeler"
|
|
|
|
@event="handlerEvent"
|
|
|
|
@save="onSaveProcess"
|
|
|
|
/>
|
2022-12-19 17:29:18 +08:00
|
|
|
|
2022-12-16 17:26:54 +08:00
|
|
|
<bmpn-process-penal
|
|
|
|
:bpmn-modeler="modeler"
|
|
|
|
:prefix="controlForm.prefix"
|
|
|
|
class="process-panel"
|
2023-01-05 09:18:03 +08:00
|
|
|
ref="bmpnProcessPenalRef"
|
2022-12-19 17:29:18 +08:00
|
|
|
/>
|
2022-12-16 17:26:54 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script setup>
|
2022-12-19 17:29:18 +08:00
|
|
|
import BmpnProcessPenal from "@/plugins/package/penal";
|
|
|
|
import BpmnProcessDesigner from "@/plugins/package/designer";
|
2022-12-16 17:26:54 +08:00
|
|
|
import "@/plugins/package/theme/index.scss";
|
2022-12-20 14:34:38 +08:00
|
|
|
// import vuePlugin from "@/plugins/package/highlight";
|
|
|
|
// import "highlight.js/styles/atom-one-dark-reasonable.css";
|
2022-12-19 17:29:18 +08:00
|
|
|
// import "highlight.js/styles/atom-one-dark-reasonable.css";
|
|
|
|
import CustomContentPadProvider from "@/plugins/package/designer/plugins/content-pad";
|
|
|
|
import CustomPaletteProvider from "@/plugins/package/designer/plugins/palette";
|
2022-12-16 17:26:54 +08:00
|
|
|
import { ref } from "vue";
|
2023-01-05 09:18:03 +08:00
|
|
|
import { ElMessage, ElMessageBox } from "element-plus";
|
2022-12-20 14:34:38 +08:00
|
|
|
|
2022-12-16 17:26:54 +08:00
|
|
|
const props = defineProps({
|
|
|
|
bpmnXml: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
designerForm: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
const { bpmnXml, designerForm } = toRefs(props);
|
2022-12-20 14:34:38 +08:00
|
|
|
let element;
|
2023-01-05 09:18:03 +08:00
|
|
|
let msgInstance;
|
2022-12-19 17:29:18 +08:00
|
|
|
const modeler = ref(null);
|
2022-12-16 17:26:54 +08:00
|
|
|
const height = ref(document.documentElement.clientHeight - 94.5 + "px;");
|
|
|
|
const xmlString = ref(bpmnXml.value);
|
2022-12-19 17:29:18 +08:00
|
|
|
const emit = defineEmits(["save"]);
|
|
|
|
const data = reactive({
|
|
|
|
controlForm: {
|
|
|
|
processId: designerForm.value.processKey || "",
|
|
|
|
processName: designerForm.value.processName || "",
|
|
|
|
simulation: false,
|
|
|
|
labelEditing: false,
|
|
|
|
labelVisible: false,
|
|
|
|
prefix: "flowable",
|
|
|
|
headerButtonSize: "small",
|
|
|
|
additionalModel: [CustomContentPadProvider, CustomPaletteProvider],
|
|
|
|
},
|
|
|
|
});
|
2022-12-20 14:34:38 +08:00
|
|
|
const { controlForm } = toRefs(data);
|
2023-01-05 09:18:03 +08:00
|
|
|
const bmpnProcessPenalRef = ref();
|
2022-12-19 17:29:18 +08:00
|
|
|
function elementClick(elementArgv) {
|
2022-12-20 14:34:38 +08:00
|
|
|
element = elementArgv;
|
2023-01-05 09:18:03 +08:00
|
|
|
// if(elementArgv)
|
|
|
|
debugger;
|
|
|
|
goToFormSelect();
|
2022-12-19 17:29:18 +08:00
|
|
|
}
|
|
|
|
function initModeler(modelerArgv) {
|
|
|
|
setTimeout(() => {
|
|
|
|
modeler.value = modelerArgv;
|
|
|
|
}, 10);
|
|
|
|
}
|
2023-01-05 09:18:03 +08:00
|
|
|
function handlerEvent(eventName) {
|
|
|
|
if (eventName === "connection-added") {
|
|
|
|
goToFormSelect();
|
|
|
|
}
|
2022-12-19 17:29:18 +08:00
|
|
|
}
|
2022-12-16 17:26:54 +08:00
|
|
|
|
2023-01-05 09:18:03 +08:00
|
|
|
function goToFormSelect() {
|
|
|
|
if (!window.bpmnInstances) return;
|
|
|
|
const formKeyExist =
|
|
|
|
!!window.bpmnInstances.elementRegistry.find(
|
|
|
|
(el) => el.type == "bpmn:StartEvent"
|
|
|
|
)?.businessObject?.formKey ?? false;
|
2022-12-16 17:26:54 +08:00
|
|
|
|
2023-01-05 09:18:03 +08:00
|
|
|
if (!formKeyExist) {
|
|
|
|
// msgInstance?.close();
|
|
|
|
ElMessageBox.alert("请为开始节点选择表单", "未选择表单", {
|
|
|
|
confirmButtonText: "去选择",
|
|
|
|
callback: () => {
|
|
|
|
const startEle = window.bpmnInstances.elementRegistry.find(
|
|
|
|
(el) => el.type == "bpmn:StartEvent"
|
|
|
|
);
|
|
|
|
const EventBus = window.bpmnInstances.eventBus;
|
|
|
|
if (element.type != "bpmn:StartEvent") {
|
|
|
|
startEle && EventBus.fire("element.click", { element: startEle });
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
// return;
|
|
|
|
// msgInstance = ElMessage.warning({
|
|
|
|
// message: "请为开始节点选择表单",
|
|
|
|
// showClose: true,
|
|
|
|
// duration: 0,
|
|
|
|
// onClose: () => {
|
|
|
|
// const startEle = window.bpmnInstances.elementRegistry.find(
|
|
|
|
// (el) => el.type == "bpmn:StartEvent"
|
|
|
|
// );
|
|
|
|
// const EventBus = window.bpmnInstances.eventBus;
|
|
|
|
// if (element.type != "bpmn:StartEvent") {
|
|
|
|
// startEle && EventBus.fire("element.click", { element: startEle });
|
|
|
|
// }
|
|
|
|
// // startEle && bmpnProcessPenalRef.value.initFormOnChanged(startEle);
|
|
|
|
// },
|
|
|
|
// });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function onSaveProcess(saveData) {
|
|
|
|
emit("save", saveData);
|
|
|
|
}
|
2022-12-16 17:26:54 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
body {
|
|
|
|
overflow: hidden;
|
|
|
|
margin: 0;
|
|
|
|
box-sizing: border-box;
|
|
|
|
}
|
|
|
|
body,
|
|
|
|
body * {
|
|
|
|
/* 滚动条 */
|
|
|
|
&::-webkit-scrollbar-track-piece {
|
|
|
|
background-color: #fff; /*滚动条的背景颜色*/
|
|
|
|
-webkit-border-radius: 0; /*滚动条的圆角宽度*/
|
|
|
|
}
|
|
|
|
|
|
|
|
&::-webkit-scrollbar {
|
|
|
|
width: 10px; /*滚动条的宽度*/
|
|
|
|
height: 8px; /*滚动条的高度*/
|
|
|
|
}
|
|
|
|
|
|
|
|
&::-webkit-scrollbar-thumb:vertical {
|
|
|
|
/*垂直滚动条的样式*/
|
|
|
|
height: 50px;
|
|
|
|
background-color: rgba(153, 153, 153, 0.5);
|
|
|
|
-webkit-border-radius: 4px;
|
|
|
|
outline: 2px solid #fff;
|
|
|
|
outline-offset: -2px;
|
|
|
|
border: 2px solid #fff;
|
|
|
|
}
|
|
|
|
|
|
|
|
&::-webkit-scrollbar-thumb {
|
|
|
|
/*滚动条的hover样式*/
|
|
|
|
background-color: rgba(159, 159, 159, 0.3);
|
|
|
|
-webkit-border-radius: 4px;
|
|
|
|
}
|
|
|
|
|
|
|
|
&::-webkit-scrollbar-thumb:hover {
|
|
|
|
/*滚动条的hover样式*/
|
|
|
|
background-color: rgba(159, 159, 159, 0.5);
|
|
|
|
-webkit-border-radius: 4px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|