Browse Source

项目工作空间切换地图BUG修复

李富豪 1 year ago
parent
commit
e428ea744b

+ 3 - 3
Web/src/api/manage.ts

@@ -90,9 +90,9 @@ export const setLivestreamQuality = async function (body: {}): Promise<IWorkspac
   return result.data
 }
 
-export const getAllUsersInfo = async function (wid: string, body: { page: number, page_size: number }): Promise<CommonListResponse<any>> {
-  const url = `${HTTP_PREFIX}/users/${wid}/users?&page=${body.page}&page_size=${body.page_size}`
-  const result = await request.get(url)
+export const getAllUsersInfo = async function (wid: string, body: { page: number, page_size: number, search_info: string }): Promise<CommonListResponse<any>> {
+  const url = `${HTTP_PREFIX}/users/${wid}/users`
+  const result = await request.get(url, { params: body })
   return result.data
 }
 

+ 8 - 4
Web/src/components/devices/changeRecord/index.vue

@@ -29,11 +29,13 @@ import CustomCell from './components/CustomCell.vue';
 import { apis } from '/@/api/custom/index';
 
 interface State {
+  query: any,
   listLoading: boolean,
   list: any[],
 };
 
 const state: State = reactive({
+  query: undefined,
   listLoading: false,
   list: [],
 });
@@ -47,11 +49,11 @@ const paginationConfig = reactive({
   total: 0
 })
 
-const fetchList = async (query?: any) => {
+const fetchList = async () => {
   state.listLoading = true;
   try {
     const res = await apis.fetchChangeRecordList({
-      ...query,
+      ...state.query,
       page: paginationConfig.current,
       page_size: paginationConfig.pageSize
     });
@@ -137,12 +139,14 @@ const refreshData = async (page: any) => {
 
 // 点击搜索
 const onClickSearch = async (query: any) => {
-  await fetchList(query);
+  state.query = query;
+  await fetchList();
 }
 
 // 点击重置
 const onClickReset = async (query: any) => {
-  await fetchList(query);
+  state.query = query;
+  await fetchList();
 }
 </script>
 

+ 10 - 5
Web/src/components/devices/deviceList/index.vue

@@ -84,9 +84,11 @@ import DeviceFirmwareUpgrade from '/@/components/devices/device-upgrade/DeviceFi
 import DeviceLogUploadRecordDrawer from '/@/components/devices/device-log/DeviceLogUploadRecordDrawer.vue';
 import DeviceHmsDrawer from '/@/components/devices/device-hms/DeviceHmsDrawer.vue';
 import { getBindingDevices, updateDevice, unbindDevice } from '/@/api/manage';
+import { getWorkspaceId } from '/@/utils/index';
 
 interface State {
   workspaceId: string,
+  query: any,
   listLoading: boolean,
   list: any[],
   selectedRowKeys: string[],
@@ -99,7 +101,8 @@ interface State {
 };
 
 const state: State = reactive({
-  workspaceId: localStorage.getItem('workspace_id') || '',
+  workspaceId: getWorkspaceId(),
+  query: undefined,
   listLoading: false,
   list: [],
   selectedRowKeys: [],
@@ -118,11 +121,11 @@ const paginationConfig = reactive({
   total: 0
 })
 
-const fetchList = async (query?: any) => {
+const fetchList = async () => {
   state.listLoading = true;
   try {
     const res = await getBindingDevices(state.workspaceId, {
-      ...query,
+      ...state.query,
       page: paginationConfig.current,
       page_size: paginationConfig.pageSize,
     });
@@ -236,12 +239,14 @@ const onClickBatchDelete = async () => {
 
 // 点击搜索
 const onClickSearch = async (query: any) => {
-  await fetchList(query);
+  state.query = query;
+  await fetchList();
 }
 
 // 点击重置
 const onClickReset = async (query: any) => {
-  await fetchList(query);
+  state.query = query;
+  await fetchList();
 }
 
 // 点击设备日志

+ 8 - 4
Web/src/components/devices/feedbackRecord/index.vue

@@ -53,6 +53,7 @@ import Drawer from './components/Drawer.vue';
 import { apis } from '/@/api/custom/index';
 
 interface State {
+  query: any,
   listLoading: boolean,
   list: any[],
   currentId: string,
@@ -60,6 +61,7 @@ interface State {
 };
 
 const state: State = reactive({
+  query: undefined,
   listLoading: false,
   list: [],
   currentId: '',
@@ -75,11 +77,11 @@ const paginationConfig = reactive({
   total: 0
 })
 
-const fetchList = async (query?: any) => {
+const fetchList = async () => {
   state.listLoading = true;
   try {
     const res = await apis.fetchChangeRecordList({
-      ...query,
+      ...state.query,
       page: paginationConfig.current,
       page_size: paginationConfig.pageSize
     });
@@ -177,12 +179,14 @@ const refreshData = async (page: any) => {
 
 // 点击搜索
 const onClickSearch = async (query: any) => {
-  await fetchList(query);
+  state.query = query;
+  await fetchList();
 }
 
 // 点击重置
 const onClickReset = async (query: any) => {
-  await fetchList(query);
+  state.query = query;
+  await fetchList();
 }
 
 // 点击详情

+ 7 - 1
Web/src/hooks/use-mouse-tool.ts

@@ -136,7 +136,13 @@ export function useMouseTool() {
     const AMap = root.$aMap;
     const map = root.$map
 
-    map.remove(map.getLayers());
+    // 移除所有背景图层
+    map.getLayers().forEach((layer: any) => {
+      if (layer instanceof AMap.TileLayer) {
+        map.remove(layer);
+      }
+    });
+
     if (type === 0) {
       // 标准图层
       map.add(new AMap.createDefaultLayer());

+ 13 - 5
Web/src/pages/page-web/projects/media/detail/components/FileInfo.vue

@@ -154,6 +154,7 @@ import { useGMapManage } from '/@/hooks/use-g-map';
 import { apis } from '/@/api/custom';
 import { downloadFile } from '/@/utils/common';
 import { downloadMediaFile } from '/@/api/media';
+import { wgs84togcj02 } from '/@/vendors/coordtransform'
 import { getWorkspaceId } from '/@/utils/index'
 
 interface Props {
@@ -186,6 +187,7 @@ const state = reactive({
     picture_time: '',
     longitude: '',// 经度
     latitude: '',// 纬度
+    coordinates: [],
   },
   map: null, // 高德地图实例
 })
@@ -198,7 +200,12 @@ const AmapHook = useGMapManage();
 const init = async () => {
   try {
     const res = await apis.fetchFileDetail(state.currentId);
-    state.info = res.data;
+    state.info = {
+      ...res.data,
+      longitude: res.data.longitude ? res.data.longitude.toFixed(6) : '',
+      latitude: res.data.latitude ? res.data.latitude.toFixed(6) : '',
+      coordinates: (res.data.longitude && res.data.latitude) ? wgs84togcj02(res.data.longitude, res.data.latitude) : [],
+    };
     if (res.data.media_type !== 4) {
       state.imgLoading = true;
       const img = new Image();
@@ -207,7 +214,7 @@ const init = async () => {
         state.imgLoading = false;
       };
     }
-    if (state.info.longitude && state.info.latitude) {
+    if (state.info.coordinates.length) {
       const AMap = await AmapHook.asyncInitMap();
       const map = new AMap.Map('photoPositionMap', {
         layers: [new AMap.TileLayer.Satellite()],// 卫星图-图层
@@ -215,14 +222,14 @@ const init = async () => {
         rotateEnable: true,// 开启地图旋转交互
         pitchEnable: true,// 开启地图倾斜交互
         zoom: 17, // 初始化地图层级
-        center: [state.info.longitude, state.info.latitude],// 中心点
+        center: state.info.coordinates,// 中心点
       })
       state.map = map;
       // 创建一个标记并将其添加到地图上
       new AMap.Marker({
         map: map,
         cursor: 'pointer',
-        position: [state.info.longitude, state.info.latitude],
+        position: state.info.coordinates,
       });
     }
   } catch (e) {
@@ -278,7 +285,7 @@ const onClickDeleteMapElement = async () => {
 
 // 点击地图位置重置
 const onClickMapLocationReset = () => {
-  const markerPosition = [state.info.longitude, state.info.latitude];
+  const markerPosition = state.info.coordinates;
   const map: any = state.map;
   map.setCenter(markerPosition);
   map.setZoom(17);
@@ -316,6 +323,7 @@ const onClickSelected = async (id: string) => {
     picture_time: '',
     longitude: '',// 经度
     latitude: '',// 纬度
+    coordinates: [],
   }
   await init()
 }

+ 9 - 12
Web/src/pages/page-web/projects/media/detail/index.vue

@@ -147,12 +147,12 @@ const paginationConfig = reactive({
   }
 })
 
-const fetchList = async (query?: any) => {
+const fetchList = async () => {
   state.listLoading = true;
   try {
     const dirId = router.currentRoute.value.params?.id;
     const res = await apis.fetchFileListByFolder(dirId as string, {
-      ...query,
+      ...state.query,
       page: paginationConfig.current,
       page_size: paginationConfig.pageSize,
     });
@@ -258,18 +258,18 @@ const onClickBatchDelete = async () => {
     id: canDeleteList.map(item => item.file_id).join(',')
   }
   await apis.batchDeletePicture(data);
-  await fetchList(state.query)
+  await fetchList()
 }
 
 // 点击搜索
 const onClickSearch = async (query: any) => {
   state.query = query;
-  await fetchList(query);
+  await fetchList();
 }
 
 // 点击重置
 const onClickReset = async (query: any) => {
-  await fetchList(query);
+  await fetchList();
 }
 
 // 点击返回
@@ -292,16 +292,14 @@ const onClickLookFile = (record: any) => {
 const fileInfoOnClickClose = async () => {
   state.fileId = '';
   state.fileInfoVisible = false;
-  const query = state.query;
-  await fetchList(query);
+  await fetchList();
 }
 
 // 点击在地图上加载
 const onClickCreateMapElement = async (id: string) => {
   try {
     await apis.createMapElement(id);
-    const query = state.query;
-    await fetchList(query);
+    await fetchList();
     message.success('在地图上加载成功');
   } catch (e: any) {
     console.error(e);
@@ -312,8 +310,7 @@ const onClickCreateMapElement = async (id: string) => {
 const onClickDeleteMapElement = async (id: string) => {
   try {
     await apis.deleteMapElement(id);
-    const query = state.query;
-    await fetchList(query);
+    await fetchList();
     message.success('在地图上取消加载成功');
   } catch (e: any) {
     console.error(e);
@@ -329,7 +326,7 @@ const onClickRechristen = (record: any) => {
 const onClickSave = async (record: any) => {
   delete state.editableData[record.file_id];
   await apis.updateFileName(record.file_id, { file_name: record.file_name })
-  await fetchList(state.query);
+  await fetchList();
 }
 
 // 点击删除

+ 8 - 4
Web/src/pages/page-web/projects/media/index/index.vue

@@ -91,6 +91,7 @@ import { downloadFile } from '/@/utils/common';
 import moment from 'moment';
 
 interface State {
+  query: any,
   listLoading: boolean,
   list: any[],
   selectedRowKeys: string[],
@@ -99,6 +100,7 @@ interface State {
 };
 
 const state: State = reactive({
+  query: undefined,
   listLoading: false,
   list: [],
   selectedRowKeys: [],
@@ -123,11 +125,11 @@ const paginationConfig = reactive({
   }
 })
 
-const fetchList = async (query?: any) => {
+const fetchList = async () => {
   state.listLoading = true;
   try {
     const res = await apis.fetchMediaFileList({
-      ...query,
+      ...state.query,
       page: paginationConfig.current,
       page_size: paginationConfig.pageSize,
     });
@@ -256,12 +258,14 @@ const onClickBatchDownload = async () => {
 
 // 点击搜索
 const onClickSearch = async (query: any) => {
-  await fetchList(query);
+  state.query = query;
+  await fetchList();
 }
 
 // 点击重置
 const onClickReset = async (query: any) => {
-  await fetchList(query);
+  state.query = query;
+  await fetchList();
 }
 
 // 点击文件夹

+ 3 - 4
Web/src/pages/page-web/projects/member/components/Search.vue

@@ -7,8 +7,8 @@
     </a-col>
     <a-col>
       <a-form ref="formRef" layout="inline" :model="formModel" :colon="false">
-        <a-form-item name="keyword">
-          <a-input style="width: 200px;" placeholder="用户名称" v-model:value="formModel.keyword" />
+        <a-form-item name="search_info">
+          <a-input style="width: 200px;" placeholder="用户名称" v-model:value="formModel.search_info" />
         </a-form-item>
         <a-form-item>
           <a-button style="margin-right: 10px;" @click="handleClicSekarch">
@@ -44,8 +44,7 @@ const props = withDefaults(defineProps<Props>(), {
 const formRef = ref();
 
 const formModel = reactive({
-  device_name: undefined,
-  keyword: '',
+  search_info: '',
 })
 
 // 点击查询

+ 16 - 13
Web/src/pages/page-web/projects/member/index.vue

@@ -3,7 +3,7 @@
     <Search :onClickAddUser="onClickAddUser" :onClickSearch="onClickSearch" :onClickReset="onClickReset" />
     <div class="mediaList-table">
       <a-table :scroll="{ x: '100%', y: 500 }" rowKey="user_id" :loading="state.listLoading" :columns="columns"
-        @change="refreshData" :rowClassName="rowClassName" :dataSource="state.list" :pagination="paginationConfig">
+        :rowClassName="rowClassName" :dataSource="state.list" :pagination="paginationConfig">
         <!-- 操作 -->
         <template #action="{ record }">
           <a-tooltip title="显示密码" v-if="!record.password">
@@ -60,14 +60,22 @@ const paginationConfig = reactive({
   showSizeChanger: true,
   pageSize: 20,
   current: 1,
-  total: 0
+  total: 0,
+  onChange: async (current: number) => {
+    paginationConfig.current = current;
+    await fetchList();
+  },
+  onShowSizeChange: async (current: number, pageSize: number) => {
+    paginationConfig.pageSize = pageSize;
+    await fetchList();
+  }
 })
 
-const fetchList = async (query?: any) => {
+const fetchList = async () => {
   state.listLoading = true;
   try {
     const res = await getAllUsersInfo(getWorkspaceId(), {
-      ...query,
+      ...state.query,
       page: paginationConfig.current,
       page_size: paginationConfig.pageSize,
     });
@@ -141,12 +149,6 @@ const rowClassName = (record: any, index: number) => {
   return className.toString().replaceAll(',', ' ')
 }
 
-const refreshData = async (page: any) => {
-  paginationConfig.current = page?.current!
-  paginationConfig.pageSize = page?.pageSize!
-  await fetchList();
-}
-
 // 点击添加飞行员
 const onClickAddUser = () => {
   state.visible = true;
@@ -156,7 +158,7 @@ const onClickAddUser = () => {
 const addModalOnClickConfirm = async (data: any) => {
   state.visible = false;
   await apis.AddPilot(data);
-  await fetchList(state.query)
+  await fetchList()
 }
 
 // 添加飞行员弹出层-点击取消
@@ -167,12 +169,13 @@ const addModalOnClickCancel = () => {
 // 点击搜索
 const onClickSearch = async (query: any) => {
   state.query = query;
-  await fetchList(query);
+  await fetchList();
 }
 
 // 点击重置
 const onClickReset = async (query: any) => {
-  await fetchList(query);
+  state.query = query;
+  await fetchList();
 }
 
 // 点击查看密码

+ 8 - 4
Web/src/pages/page-web/projects/trajectory/index.vue

@@ -28,11 +28,13 @@ import { wgs84togcj02 } from '/@/vendors/coordtransform'
 const store = useMyStore()
 
 interface State {
+  query: any,
   listLoading: boolean,
   list: any[],
 };
 
 const state: State = reactive({
+  query: undefined,
   listLoading: false,
   list: [],
 });
@@ -46,11 +48,11 @@ const paginationConfig = reactive({
   total: 0
 })
 
-const fetchList = async (query?: any) => {
+const fetchList = async () => {
   state.listLoading = true;
   try {
     const res = await apis.fetchTrajectoryList({
-      ...query,
+      ...state.query,
       page: paginationConfig.current,
       page_size: paginationConfig.pageSize
     });
@@ -150,12 +152,14 @@ const refreshData = async (page: any) => {
 
 // 点击搜索
 const onClickSearch = async (query: any) => {
-  await fetchList(query);
+  state.query = query;
+  await fetchList();
 }
 
 // 点击重置
 const onClickReset = async (query: any) => {
-  await fetchList(query);
+  state.query = query;
+  await fetchList();
 }
 
 // 点击查看轨迹