GasGeoViewer.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <div class="content">
  3. <div class="left-box">
  4. <FileSystem :selected="selected" :list="treeData" @on-click="openFile" />
  5. </div>
  6. <div class="right-box">
  7. <CADViewer class="w-100% h-100%" />
  8. </div>
  9. </div>
  10. </template>
  11. <script lang="ts" setup>
  12. import { onMounted, onUnmounted, ref } from 'vue';
  13. import { CADViewer, useCADViewer } from '/@/components/CADViewer';
  14. // import { queryGasGeoMap } from './cad.api';
  15. import FileSystem from '../performance/fileDetail/commen/fileSystem.vue';
  16. import { getTree } from '../performance/fileDetail/fileDetail.api';
  17. const selected = ref<any>({});
  18. const treeData = ref<any[]>([]);
  19. const { processFile, postMessage, registHook, unregistHook } = useCADViewer();
  20. async function getTreeList() {
  21. // 瓦斯地质图
  22. const { records } = await getTree({ parentId: '1871508264848617473', pageNo: 1, pageSize: 1000 });
  23. treeData.value = records.map((e) => {
  24. return {
  25. id: e.id,
  26. isFolder: false,
  27. title: e.fileName,
  28. };
  29. });
  30. selected.value = treeData.value[0];
  31. }
  32. function openFile(id?: string) {
  33. if (!id) return;
  34. processFile(id).then((path) => {
  35. postMessage('MKY_Open_Mxweb', path);
  36. });
  37. }
  38. // watch(
  39. // () => props.id,
  40. // (v) => {
  41. // if (!v) return;
  42. // openFile(v, props.filename);
  43. // }
  44. // );
  45. // let initByRoute = false;
  46. onMounted(() => {
  47. // 只触发一次,因为MKY_Open_Mxweb之后会自动触发MKY_Open_File_Complete钩子,导致循环
  48. registHook('MKY_Open_File_Complete', () => {
  49. unregistHook('MKY_Open_File_Complete');
  50. getTreeList().then(() => {
  51. openFile(selected.value.id);
  52. });
  53. });
  54. });
  55. onUnmounted(() => {
  56. unregistHook('MKY_Open_File_Complete');
  57. });
  58. </script>
  59. <style scoped lang="less">
  60. @import '/@/design/theme.less';
  61. .content {
  62. width: 100%;
  63. height: 100%;
  64. display: flex;
  65. flex-direction: row;
  66. justify-content: space-between;
  67. align-items: flex-start;
  68. position: relative;
  69. z-index: 999;
  70. .left-box {
  71. width: 18%;
  72. height: 100%;
  73. padding: 10px;
  74. border: 1px solid var(--vent-device-manager-box-border);
  75. background: var(--vent-device-manager-box-bg);
  76. overflow-y: auto;
  77. // box-shadow: 0px 0px 20px 7px rgba(145, 233, 254, 0.7) inset;
  78. }
  79. .right-box {
  80. width: 82%;
  81. height: 100%;
  82. padding: 10px;
  83. box-sizing: border-box;
  84. }
  85. .list {
  86. height: calc(100% - 49px);
  87. position: relative;
  88. }
  89. }
  90. ::v-deep .suffix {
  91. height: 32px;
  92. line-height: 32px;
  93. margin-left: 5px;
  94. color: var(--vent-font-color);
  95. }
  96. </style>