兰宝车间质量管理系统-前端
baoshiwei
2025-03-12 6b988bd582bfcd17fee48c476a5a6e5cc172b0d5
src/views/workflow/processDefinition/components/processPreview.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,45 @@
<template>
  <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' && data.xmlStr">
      <highlightjs language="xml" :code="data.xmlStr" />
    </div>
    <template #footer>
      <span v-if="data.type === 'xml'" class="dialog-footer"> </span>
    </template>
  </el-dialog>
</template>
<script setup lang="ts">
import BpmnViewer from '@/components/BpmnView/index.vue';
const data = reactive({
  visible: false,
  type: '',
  xmlStr: ''
});
const bpmnViewerRef = ref<InstanceType<typeof BpmnViewer>>();
type PreviewType = 'xml' | 'bpmn';
//打开
const openDialog = (xmlStr: string, type: PreviewType) => {
  data.visible = true;
  data.xmlStr = xmlStr;
  data.type = type;
  /** æµç¨‹å›¾ */
  if (type === 'bpmn') {
    /** å¿…须放在nextTick å¦åˆ™ç¬¬ä¸€æ¬¡æ‰“开为空 */
    nextTick(() => {
      bpmnViewerRef.value?.initXml(data.xmlStr);
    });
  }
};
/**
 * å¯¹å¤–暴露子组件方法
 */
defineExpose({
  openDialog
});
</script>