bill 1 week ago
parent
commit
fcb75c71cd

+ 3 - 3
profile/.env.jmdev

@@ -1,11 +1,11 @@
 VITE_PRIMARY='#109BE0'
 VITE_TITLE='绘图'
-VITE_ENTRY='/example/fuse/enter-case.ts'
+VITE_ENTRY='/example/fuse/enter.ts'
 VITE_ENTRY_EXAMPLE='./main.ts'
-VITE_MOCK_ENV=jmg
+VITE_MOCK_ENV=jmtest
 
 
-VITE_STATIC='https://survey.4dkankan.com/'
+VITE_STATIC='http://192.168.0.125:1804/'
 VITE_OSS='/oss/'
 VITE_OSS_ROOT="/rootOss/"
 VITE_MESH_OSS='/meshOSS/'

+ 9 - 9
profile/.env.jmtest

@@ -4,14 +4,14 @@ VITE_ENTRY='/example/fuse/enter.ts'
 VITE_ENTRY_EXAMPLE='./main.ts'
 
 
-VITE_OSS_ROOT="http://192.168.0.25/"
-VITE_OSS='http://192.168.0.25/oss/'
-VITE_MESH_OSS='http://192.168.0.25/oss/'
-VITE_MESH_API='http://192.168.0.25/'
-VITE_CLOUD_API='http://192.168.0.25/'
-VITE_FUSE_API='http://192.168.0.25/'
+VITE_OSS_ROOT="http://192.168.0.125:1804/"
+VITE_OSS='http://192.168.0.125:1804/oss/'
+VITE_MESH_OSS='http://192.168.0.125:1804/oss/'
+VITE_MESH_API='http://192.168.0.125:1804/'
+VITE_CLOUD_API='http://192.168.0.125:1804/'
+VITE_FUSE_API='http://192.168.0.125:1804/'
 
 VITE_MESH_VIEW='./static/kankan.html?m={m}&lang=zh&env=dev'
-VITE_CLOUD_VIEW='http://192.168.0.25/swss/index.html?m={m}&lang=zh'
-VITE_FUSE_VIEW='http://192.168.0.25/code/'
-VITE_LOGIN_VIEW='http://192.168.0.25/admin/#/statistics/scene?redirect={redirect}'
+VITE_CLOUD_VIEW='http://192.168.0.125:1804/swss/index.html?m={m}&lang=zh'
+VITE_FUSE_VIEW='http://192.168.0.125:1804/code/'
+VITE_LOGIN_VIEW='http://192.168.0.125:1804/admin/#/statistics/scene?redirect={redirect}'

+ 3 - 2
src/example/dialog/basemap/index.ts

@@ -4,10 +4,11 @@ import { Size } from "@/utils/math";
 import { Tile } from "./leaflet/useLeaflet";
 import { LatLng } from "leaflet";
 
-export type SearchResultItem = { address: string, latlng: LatLng }
-export type SearchAPI = (keyword: string) => Promise<SearchResultItem[]>
+export type SearchResultItem = { name: string, address: string, latlng: LatLng }
+export type SearchAPI = (keyword: string, mapId: number) => Promise<SearchResultItem[]>
 export type BasemapInfo = { blob: Blob; size: Size };
 export type TileGroup = {
+  id: number
   tiles: Tile[];
   name: string;
 };

+ 16 - 2
src/example/dialog/basemap/leaflet/index.vue

@@ -44,6 +44,7 @@
           :class="{ active: activeOption === option }"
           @click="clickOption(option)"
         >
+          <span>{{ option.name }}</span>
           {{ option.address }}
         </div>
       </div>
@@ -127,6 +128,7 @@ const activeOption = ref<SearchResultItem>();
 const clickOption = (item: SearchResultItem) => {
   activeOption.value = item;
   mark.value = item.latlng;
+  console.log(item);
 };
 let token = 0;
 const searchHandler = async () => {
@@ -140,7 +142,7 @@ const searchHandler = async () => {
 
   if (!keyword.value) return;
 
-  const result = await props.search(keyword.value);
+  const result = await props.search(keyword.value, props.tileGroups[groupIndex.value].id);
   if (currentToken === token) {
     options.value = result;
   }
@@ -255,10 +257,22 @@ defineExpose({ submit });
   margin-top: 10px;
   border: 1px solid #d9d9d9;
   border-radius: 2px;
+  max-height: 600px;
+  overflow-y: auto;
 
   .address-item {
-    padding: 10px 6px;
+    padding: 15px 6px;
     margin: 0 10px;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    flex-direction: column;
+    color: #999;
+    span {
+      font-size: 14px;
+      font-weight: bold;
+      color: #333;
+    }
     cursor: pointer;
 
     &.active {

+ 32 - 9
src/example/dialog/vr/vr.vue

@@ -13,11 +13,12 @@
       clearable
       :remote-method="searchSenects"
       remote-show-suffix
-      :loading="loading"
+      @popup-scroll="scrollHandler"
+      popper-class="vr-select-list"
     >
       <el-option
         v-for="item in scenes"
-        :key="item.m"
+        :key="item.id"
         :label="item.title"
         :value="item.id"
       />
@@ -31,7 +32,7 @@ import { computed, ref } from "vue";
 import { asyncTimeout } from "@/utils/shared";
 import { Scene, SceneTypeNames } from "../../platform/platform-resource";
 
-const props = defineProps<{ value?: Scene; label: string }>();
+const props = defineProps<{ value?: Scene; label?: string }>();
 const emit = defineEmits<{ (e: "update:value", val: Scene): void }>();
 
 const _value = ref<Scene>();
@@ -51,21 +52,43 @@ const value = computed({
 
 const loading = ref(false);
 const scenes = ref<Scene[]>([]);
-let oldKeyword: string;
-const searchSenects = async (keyword: string) => {
-  if (oldKeyword! === keyword) return;
-  oldKeyword = keyword;
-
+const refresh = async () => {
   loading.value = true;
   await asyncTimeout(300);
-  scenes.value = await window.platform.getSceneList(keyword);
+  scenes.value = [...(await getSceneList.value.next()).list];
   loading.value = false;
+};
+
+const keyword = ref<string>("");
+const getSceneList = computed(() => window.platform.getSceneList(keyword.value));
+let oldKeyword: string;
+const searchSenects = async (word: string) => {
+  if (oldKeyword! === word) return;
+  oldKeyword = word;
+  keyword.value = word;
+  await refresh();
 
   if (!keyword && scenes.value.length === 0) {
     ElMessage.error("当前绘图无场景数据");
   }
 };
 
+const scrollHandler = (offset: { scrollTop: number }) => {
+  if (loading.value) return;
+
+  const dom = document.querySelector(
+    ".vr-select-list .el-select-dropdown__wrap"
+  ) as HTMLDivElement;
+  if (!dom) return;
+  const height = dom.scrollHeight;
+  const current = dom.offsetHeight;
+  if (current + offset.scrollTop + 10 > height) {
+    console.log("分页请求");
+    // 分页请求
+    refresh();
+  }
+};
+
 searchSenects("");
 defineExpose({
   disabled: computed(() => !value.value),

+ 45 - 19
src/example/fuse/enter-shared.ts

@@ -5,6 +5,7 @@ import { token, params, urlUpdateQuery, urlGetQuery } from "../env";
 import { genLoading } from "../loadding";
 import { tempStrFill } from "@/utils/shared";
 import { gdSearch } from "../dialog/basemap/leaflet/mock";
+import { latlngStrTransform } from "../dialog/basemap/leaflet/useLeaflet";
 
 export const SCENE_TYPE = {
   fuse: "fuse",
@@ -37,7 +38,9 @@ export const get = (url: string, params: Record<string, any>) => {
     p.append(key, params[key]);
   }
   const l = `${resourceURLS[SCENE_TYPE.fuse]}${url}?${p.toString()}`;
-  return after(fetch(l, { method: "get", headers: window.platform.getHeaders() }));
+  return after(
+    fetch(l, { method: "get", headers: window.platform.getHeaders() })
+  );
 };
 
 export const post = (url: string, data: Record<string, any>) => {
@@ -109,7 +112,6 @@ const after = async (fet: Promise<Response>) => {
 
   if ([4008, 4010, 7012].includes(res.code)) {
     setTimeout(() => {
-      
       window.platform.login(res.code !== 7012);
     }, 1000);
     throw res.message;
@@ -120,19 +122,43 @@ const after = async (fet: Promise<Response>) => {
   }
 };
 
-export const getSceneList = genLoading(async (keyword: string): Promise<Scene[]> => {
-  const list = await post(`fusion/case/sceneListPost`, {
-    isMesh: 1,
-    sceneName: keyword,
+export const getSceneList = (keyword: string) => {
+  let page = 1;
+  let final = false;
+
+  const list: Scene[] = [];
+  const request = genLoading(async () => {
+    const data = await post(`fusion/case/sceneListPost`, {
+      isMesh: 1,
+      pageNum: page,
+      sceneName: keyword,
+    });
+    const current = data.list.map(
+      (item: any) =>
+        ({
+          type: SCENE_TYPE.mesh,
+          m: item.num,
+          title: item.sceneName,
+          id: item.id.toString(),
+          token,
+        } as Scene)
+    );
+    list.push(...current);
+    page++;
+    final = data.total / data.pageSize <= page;
   });
-  return list.map((item: any) => ({
-    type: SCENE_TYPE.mesh,
-    m: item.num,
-    title: item.name,
-    id: item.id.toString(),
-    token,
-  }));
-});
+  let next = async () => {
+    if (!final) {
+      await request();
+    }
+    return {
+      next,
+      final,
+      list,
+    };
+  };
+  return {next, final, list};
+};
 
 export const getOverviewData = genLoading(async (id: string) => {
   if (!id) {
@@ -230,8 +256,6 @@ export const getTabulationData = genLoading(async (id: string) => {
   };
 });
 
-
-
 export const saveTabulationData = genLoading(
   async (
     id: string,
@@ -301,6 +325,7 @@ export const getTileGroups = async () => {
   return data.map((item: any) => {
     const mitem = JSON.parse(item.mapUrl);
     return {
+      id: item.id,
       name: item.name,
       tiles: mitem.map((tileItem: any) => ({
         url: tileItem.tempUrl,
@@ -311,6 +336,7 @@ export const getTileGroups = async () => {
   });
 };
 
-export const searchAddress = (keyword: string) => {
-  return gdSearch(keyword)
-}
+export const searchAddress = async (keyword: string, mapId: number) => {
+  const data = await post(`/fusion/mapConfig/geocode`, { address: keyword, mapId })
+  return data.map((item: any) => ({...item, latlng: latlngStrTransform(item.location.split(',').reverse().join(','))}))
+};

+ 5 - 2
src/example/fuse/enter.ts

@@ -30,12 +30,15 @@ if (window.platform.sceneDraw) {
     import(import.meta.env.VITE_ENTRY_EXAMPLE);
   });
 
-  window.platform.saveOverviewData = (id: any, data: any) => {
-    return platform.saveOverviewData(id, {
+  window.platform.saveOverviewData = async (id: any, data: any) => {
+    const result = await platform.saveOverviewData(id, {
       ...data,
       num: m,
       subGroup: subgroup,
     });
+    const key = `${m}-${subgroup}-draw-kankan-cover`
+    localStorage.setItem(key, data.kankanCover)
+    return result
   };
 } else {
   /* @vite-ignore */

+ 0 - 3
src/example/fuse/views/overview/index.vue

@@ -69,9 +69,6 @@ const initScene = async (draw: Draw) => {
   };
   saveAfterHandlers.push(delHandler);
 
-  // const scenes = await window.platform.getSceneList("");
-  // const scene = scenes.find((scene: any) => scene.m === m);
-  // const floors = await getFloors(scene);
 
   // 目前只支持看看平台
   const scene = { m, type: SCENE_TYPE["mesh"] } as any;