ソースを参照

[Feat 0000] 开发支持预览远程文件的CAD文件

ruienger 3 ヶ月 前
コミット
577348dc19
2 ファイル変更25 行追加23 行削除
  1. 11 23
      src/views/vent/cad/GasGeoViewer.vue
  2. 14 0
      src/views/vent/cad/cad.api.ts

+ 11 - 23
src/views/vent/cad/TestViewer.vue → src/views/vent/cad/GasGeoViewer.vue

@@ -1,28 +1,22 @@
 <template>
   <!-- 更适用于文件共享中心的CAD viewer组件,支持两种使用方法,详见下文 -->
-  <CADViewer class="w-100% h-100%" :height="height" />
+  <CADViewer class="w-100% h-100%" />
 </template>
 <script lang="ts" setup>
   import { onMounted, onUnmounted } from 'vue';
   import { CADViewer, useCADViewer } from '/@/components/CADViewer';
-  import { useRoute } from 'vue-router';
-
-  const props = defineProps<{
-    // 文件共享中心中该文件的ID
-    id: string;
-    // 文件名
-    filename?: string;
-    height: number;
-  }>();
+  import { queryGasGeoMap } from './cad.api';
 
   const { processFile, postMessage, registHook, unregistHook } = useCADViewer();
 
-  function openFile(id: string) {
+  function openFile() {
     // 只触发一次,因为MKY_Open_Mxweb之后会自动触发MKY_Open_File_Complete钩子,导致循环
     registHook('MKY_Open_File_Complete', () => {
       unregistHook('MKY_Open_File_Complete');
-      processFile(id).then((path) => {
-        postMessage('MKY_Open_Mxweb', path);
+      queryGasGeoMap({}).then(({ id }) => {
+        processFile(id).then((path) => {
+          postMessage('MKY_Open_Mxweb', path);
+        });
       });
     });
   }
@@ -38,15 +32,7 @@
   // let initByRoute = false;
 
   onMounted(() => {
-    const route = useRoute();
-    if (route.query.id && route.query.filename) {
-      // initByRoute = true;
-      // 通过 url query 指定文件 ID 的形式使用该组件
-      openFile(route.query.id as string);
-    } else {
-      // 通过 props 指定文件 ID 的形式使用该组件
-      openFile(props.id);
-    }
+    openFile();
   });
 
   onUnmounted(() => {
@@ -55,10 +41,12 @@
 </script>
 
 <style scoped lang="less">
+  @import '/@/design/theme.less';
+
   ::v-deep .suffix {
     height: 32px;
     line-height: 32px;
     margin-left: 5px;
-    color: #fff;
+    color: var(--vent-font-color);
   }
 </style>

+ 14 - 0
src/views/vent/cad/cad.api.ts

@@ -0,0 +1,14 @@
+import { defHttp } from '/@/utils/http/axios';
+import { omitBy, isNil } from 'lodash-es';
+
+enum Api {
+  queryGasGeoMap = '/ventanaly-sharefile/fileServer/queryGasGeoMap',
+}
+
+/**
+ * 列表接口
+ * @param params
+ */
+export function queryGasGeoMap(params: any) {
+  return defHttp.get({ url: Api.queryGasGeoMap, params: omitBy(params, isNil) });
+}