diff --git a/src/components/BpmnDesign/index.vue b/src/components/BpmnDesign/index.vue index 2e5cb4b..6c7e38b 100644 --- a/src/components/BpmnDesign/index.vue +++ b/src/components/BpmnDesign/index.vue @@ -9,7 +9,7 @@ - + @@ -68,6 +68,7 @@ import diagramXML from '@/components/BpmnDesign/assets/defaultXML'; import flowableModdle from '@/components/BpmnDesign/assets/moddle/flowable'; import Modules from './assets/module/index'; import useModelerStore from '@/store/modules/modeler'; +import { Canvas, Modeler } from 'bpmn'; const { proxy } = getCurrentInstance() as ComponentInternalInstance; @@ -81,7 +82,7 @@ const xmlUploadRef = ref(); const canvas = ref(); const panel = ref(); -const bpmnModeler = ref(); +const bpmnModeler = ref(); const zoom = ref(1); const perviewXMLShow = ref(false); @@ -159,10 +160,16 @@ const initModel = () => { const closeDialog = () => { dialog.visible = false; }; - /** * 新建 */ +const newDiagram = async () => { + await proxy?.$modal.confirm('是否确认新建'); + initDiagram(); +}; +/** + * 初始化 + */ const initDiagram = () => { bpmnModeler.value.importXML(diagramXML); }; @@ -171,7 +178,7 @@ const initDiagram = () => { * 自适应屏幕 */ const fitViewport = () => { - zoom.value = bpmnModeler.value.get('canvas').zoom('fit-viewport'); + zoom.value = bpmnModeler.value.get('canvas').zoom('fit-viewport'); const bbox = (document.querySelector('.app-containers .viewport') as SVGGElement).getBBox(); const currentViewBox = bpmnModeler.value.get('canvas').viewbox(); const elementMid = { @@ -213,7 +220,7 @@ const downloadXML = async () => { */ const downloadSVG = async () => { try { - const { svg } = await bpmnModeler.value.saveSVG({ format: true }); + const { svg } = await bpmnModeler.value.saveSVG(); downloadFile(getProcessElement().name, svg, 'image/svg+xml'); } catch (e) { proxy?.$modal.msgError(e); @@ -238,7 +245,7 @@ const previewXML = async () => { */ const previewSVG = async () => { try { - const { svg } = await bpmnModeler.value.saveSVG({ format: true }); + const { svg } = await bpmnModeler.value.saveSVG(); svgData.value = svg; perviewSVGShow.value = true; } catch (e) { diff --git a/src/types/bpmn/editor/global.d.ts b/src/types/bpmn/editor/global.d.ts index 678fe18..679b811 100644 --- a/src/types/bpmn/editor/global.d.ts +++ b/src/types/bpmn/editor/global.d.ts @@ -5,6 +5,7 @@ declare global { interface Window { bpmnInstances: any; __messageBox: MessageApiInjection; + URL: any; } type BpmnElement = ElementLike & { type: string };