From 3062c46b496236ce1f89ece74e4626c15c66bfe5 Mon Sep 17 00:00:00 2001 From: dap <dap@qq.com> Date: 星期四, 16 五月 2024 08:18:54 +0800 Subject: [PATCH] fix: 流程定义xml预览问题 & 重构代码 --- src/views/workflow/processDefinition/index.vue | 27 ++++--------- src/views/workflow/processDefinition/components/processPreview.vue | 39 ++++--------------- 2 files changed, 16 insertions(+), 50 deletions(-) diff --git a/src/views/workflow/processDefinition/components/processPreview.vue b/src/views/workflow/processDefinition/components/processPreview.vue index 3159b32..19a95df 100644 --- a/src/views/workflow/processDefinition/components/processPreview.vue +++ b/src/views/workflow/processDefinition/components/processPreview.vue @@ -1,12 +1,10 @@ <template> - <el-dialog v-model="data.visible" title="棰勮" width="70%" append-to-body> - <div v-if="data.type === 'png' && data.xmlStr" style="align: center"> + <el-dialog v-model="data.visible" title="棰勮" width="70%" append-to-body destroy-on-close> + <div v-if="data.type === 'bpmn' && data.xmlStr"> <BpmnViewer ref="bpmnViewerRef"></BpmnViewer> </div> - <div v-if="data.type === 'xml'" class="xml-data"> - <div v-for="(xml, index) in data.url" :key="index"> - <pre class="font">{{ xml }}</pre> - </div> + <div v-if="data.type === 'xml' && data.xmlStr"> + <highlightjs language="xml" :code="data.xmlStr" /> </div> <template #footer> <span v-if="data.type === 'xml'" class="dialog-footer"> </span> @@ -19,20 +17,19 @@ const data = reactive({ visible: false, - url: new Array<string>(), type: '', xmlStr: '' }); const bpmnViewerRef = ref<InstanceType<typeof BpmnViewer>>(); +type PreviewType = 'xml' | 'bpmn'; //鎵撳紑 -const openDialog = (url: string[], type: string) => { +const openDialog = (xmlStr: string, type: PreviewType) => { data.visible = true; - data.url = url; + data.xmlStr = xmlStr; data.type = type; /** 娴佺▼鍥� */ - if (type === 'png') { - data.xmlStr = url.join('\n'); + if (type === 'bpmn') { /** 蹇呴』鏀惧湪nextTick 鍚﹀垯绗竴娆℃墦寮�涓虹┖ */ nextTick(() => { bpmnViewerRef.value?.initXml(data.xmlStr); @@ -46,23 +43,3 @@ openDialog }); </script> -<style> -.xml-data { - background-color: #2b2b2b; - border-radius: 5px; - color: #c6c6c6; - word-break: break-all; - overflow-y: scroll; - overflow-x: hidden; - box-sizing: border-box; - padding: 8px 0px; - height: 500px; - width: inherit; - line-height: 1px; - overflow: auto; -} -.font { - font-family: '骞煎渾'; - font-weight: 500; -} -</style> diff --git a/src/views/workflow/processDefinition/index.vue b/src/views/workflow/processDefinition/index.vue index 6f13d32..1dacb80 100644 --- a/src/views/workflow/processDefinition/index.vue +++ b/src/views/workflow/processDefinition/index.vue @@ -61,12 +61,12 @@ </el-table-column> <el-table-column align="center" prop="resourceName" label="娴佺▼XML" width="100" :show-overflow-tooltip="true"> <template #default="scope"> - <el-link type="primary" @click="clickPreviewXML(scope.row.id)">{{ scope.row.resourceName }}</el-link> + <el-link type="primary" @click="clickPreview(scope.row.id, 'xml')">{{ scope.row.resourceName }}</el-link> </template> </el-table-column> <el-table-column align="center" prop="diagramResourceName" label="娴佺▼鍥剧墖" width="100" :show-overflow-tooltip="true"> <template #default="scope"> - <el-link type="primary" @click="clickPreviewImg(scope.row.id)">{{ scope.row.diagramResourceName }}</el-link> + <el-link type="primary" @click="clickPreview(scope.row.id, 'bpmn')">{{ scope.row.diagramResourceName }}</el-link> </template> </el-table-column> <el-table-column align="center" prop="suspensionState" label="鐘舵��" width="80"> @@ -293,7 +293,6 @@ const uploadDialogLoading = ref(false); const processDefinitionList = ref<ProcessDefinitionVO[]>([]); const processDefinitionHistoryList = ref<ProcessDefinitionVO[]>([]); -const url = ref<string[]>([]); const categoryOptions = ref<CategoryOption[]>([]); const categoryName = ref(''); /** 閮ㄧ讲鏂囦欢鍒嗙被閫夋嫨 */ @@ -400,28 +399,18 @@ loading.value = false; }; -//棰勮鍥剧墖 -const clickPreviewImg = async (id: string) => { +type PreviewType = 'xml' | 'bpmn'; +//棰勮 鍏叡鏂规硶 +const clickPreview = async (id: string, type: PreviewType) => { loading.value = true; const resp = await definitionXml(id); if (previewRef.value) { - url.value = []; - url.value = resp.data.xml; + const xmlStr = resp.data.xmlStr; loading.value = false; - previewRef.value.openDialog(url.value, 'png'); + previewRef.value.openDialog(xmlStr, type); } }; -//棰勮xml -const clickPreviewXML = async (id: string) => { - loading.value = true; - const resp = await definitionXml(id); - if (previewRef.value) { - url.value = []; - url.value = resp.data.xml; - loading.value = false; - previewRef.value.openDialog(url.value, 'xml'); - } -}; + /** 鍒犻櫎鎸夐挳鎿嶄綔 */ const handleDelete = async (row?: ProcessDefinitionVO) => { const id = row?.id || ids.value; -- Gitblit v1.9.3