|
@@ -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(','))}))
|
|
|
+};
|