兰宝车间质量管理系统-前端
dap
2024-05-15 3b8ecadc78d6a247c1bd736fe37dfb7ff53badd4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<template>
  <el-dialog v-model="data.visible" title="预览" width="70%" append-to-body>
    <div v-if="data.type === 'png' && data.xmlStr" style="align: center">
      <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>
    <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,
  url: new Array<string>(),
  type: '',
  xmlStr: ''
});
 
const bpmnViewerRef = ref<InstanceType<typeof BpmnViewer>>();
//打开
const openDialog = (url: string[], type: string) => {
  data.visible = true;
  data.url = url;
  data.type = type;
  /** 流程图 */
  if (type === 'png') {
    data.xmlStr = url.join('\n');
    /** 必须放在nextTick 否则第一次打开为空 */
    nextTick(() => {
      bpmnViewerRef.value?.initXml(data.xmlStr);
    });
  }
};
/**
 * 对外暴露子组件方法
 */
defineExpose({
  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>