update 调整类型声明文件

This commit is contained in:
LiuHao 2024-01-22 00:14:24 +08:00
parent 1940b1b116
commit 64e2ebbc0d
2 changed files with 14 additions and 6 deletions

View File

@ -9,7 +9,7 @@
<el-button size="small" icon="FolderOpened" @click="loadXML" /> <el-button size="small" icon="FolderOpened" @click="loadXML" />
</el-tooltip> </el-tooltip>
<el-tooltip effect="dark" content="新建" placement="bottom"> <el-tooltip effect="dark" content="新建" placement="bottom">
<el-button size="small" icon="CirclePlus" @click="initDiagram" /> <el-button size="small" icon="CirclePlus" @click="newDiagram" />
</el-tooltip> </el-tooltip>
<el-tooltip effect="dark" content="自适应屏幕" placement="bottom"> <el-tooltip effect="dark" content="自适应屏幕" placement="bottom">
<el-button size="small" icon="Rank" @click="fitViewport" /> <el-button size="small" icon="Rank" @click="fitViewport" />
@ -68,6 +68,7 @@ import diagramXML from '@/components/BpmnDesign/assets/defaultXML';
import flowableModdle from '@/components/BpmnDesign/assets/moddle/flowable'; import flowableModdle from '@/components/BpmnDesign/assets/moddle/flowable';
import Modules from './assets/module/index'; import Modules from './assets/module/index';
import useModelerStore from '@/store/modules/modeler'; import useModelerStore from '@/store/modules/modeler';
import { Canvas, Modeler } from 'bpmn';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@ -81,7 +82,7 @@ const xmlUploadRef = ref<ElUploadInstance>();
const canvas = ref<HTMLDivElement>(); const canvas = ref<HTMLDivElement>();
const panel = ref<HTMLDivElement>(); const panel = ref<HTMLDivElement>();
const bpmnModeler = ref(); const bpmnModeler = ref<Modeler>();
const zoom = ref(1); const zoom = ref(1);
const perviewXMLShow = ref(false); const perviewXMLShow = ref(false);
@ -159,10 +160,16 @@ const initModel = () => {
const closeDialog = () => { const closeDialog = () => {
dialog.visible = false; dialog.visible = false;
}; };
/** /**
* 新建 * 新建
*/ */
const newDiagram = async () => {
await proxy?.$modal.confirm('是否确认新建');
initDiagram();
};
/**
* 初始化
*/
const initDiagram = () => { const initDiagram = () => {
bpmnModeler.value.importXML(diagramXML); bpmnModeler.value.importXML(diagramXML);
}; };
@ -171,7 +178,7 @@ const initDiagram = () => {
* 自适应屏幕 * 自适应屏幕
*/ */
const fitViewport = () => { const fitViewport = () => {
zoom.value = bpmnModeler.value.get('canvas').zoom('fit-viewport'); zoom.value = bpmnModeler.value.get<Canvas>('canvas').zoom('fit-viewport');
const bbox = (document.querySelector('.app-containers .viewport') as SVGGElement).getBBox(); const bbox = (document.querySelector('.app-containers .viewport') as SVGGElement).getBBox();
const currentViewBox = bpmnModeler.value.get('canvas').viewbox(); const currentViewBox = bpmnModeler.value.get('canvas').viewbox();
const elementMid = { const elementMid = {
@ -213,7 +220,7 @@ const downloadXML = async () => {
*/ */
const downloadSVG = async () => { const downloadSVG = async () => {
try { try {
const { svg } = await bpmnModeler.value.saveSVG({ format: true }); const { svg } = await bpmnModeler.value.saveSVG();
downloadFile(getProcessElement().name, svg, 'image/svg+xml'); downloadFile(getProcessElement().name, svg, 'image/svg+xml');
} catch (e) { } catch (e) {
proxy?.$modal.msgError(e); proxy?.$modal.msgError(e);
@ -238,7 +245,7 @@ const previewXML = async () => {
*/ */
const previewSVG = async () => { const previewSVG = async () => {
try { try {
const { svg } = await bpmnModeler.value.saveSVG({ format: true }); const { svg } = await bpmnModeler.value.saveSVG();
svgData.value = svg; svgData.value = svg;
perviewSVGShow.value = true; perviewSVGShow.value = true;
} catch (e) { } catch (e) {

View File

@ -5,6 +5,7 @@ declare global {
interface Window { interface Window {
bpmnInstances: any; bpmnInstances: any;
__messageBox: MessageApiInjection; __messageBox: MessageApiInjection;
URL: any;
} }
type BpmnElement = ElementLike & { type: string }; type BpmnElement = ElementLike & { type: string };