From 4e2ae414c483a5bcb0866fffdffc1bbde832fe3f Mon Sep 17 00:00:00 2001 From: Zy <1448159279@qq.com> Date: Wed, 24 Jun 2026 16:19:19 +0800 Subject: [PATCH] =?UTF-8?q?6/24=20=E7=BB=9F=E4=B8=80=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=85=A5=E5=8F=A3=EF=BC=8C=E8=A7=84=E8=8C=83?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E6=96=B9=E6=B3=95=EF=BC=8C=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E3=80=82=20=E5=AE=8C=E6=88=90=E5=A4=A9=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E5=92=8C=E9=AB=98=E5=BE=B7=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 3 - .env.production | 7 +- src/api/system/InspectionPoint/type.ts | 4 +- src/api/system/InspectionRoute/index.ts | 2 +- src/api/system/InspectionRoute/type.ts | 4 +- src/components/Map/GD.vue | 42 +-- src/components/Map/TDT.vue | 299 +++++++++++++++++- src/components/Map/index.vue | 44 ++- src/components/Map/type.ts | 30 ++ src/types/env.d.ts | 10 + .../inspection/Plan/addInspectionPlan.vue | 36 ++- .../inspection/Point/addInspectionPoint.vue | 55 ++-- .../inspection/Route/addInspectionRoute.vue | 81 +++-- src/views/system/inspection/Task/addTask.vue | 86 ++--- 14 files changed, 515 insertions(+), 188 deletions(-) create mode 100644 src/components/Map/type.ts diff --git a/.env.development b/.env.development index 30774f4..2b221f4 100644 --- a/.env.development +++ b/.env.development @@ -37,8 +37,6 @@ VITE_APP_SHOW_WORK_PLATFORM = true # 地图类型 天地图 WGS84 高德地图 GCJ02, 高德地图 需要在高德地图官网申请key -# 高德地图 GCJ02 -# 天地图 WGS84 VITE_APP_MAP_TYPE = 'GCJ02' # 高德地图key 建议放入环境变量中,避免泄露 @@ -47,7 +45,6 @@ VITE_GCJ02_JS_CODE_GD = '09534b3534d8da53968529a9ce164118' # 天地图key 建议放入环境变量中,避免泄露 VITE_TIANDITU_KEY = 'f71689f9e22158947ebf64ad95e0a595' -VITE_TIANDITU_JS_CODE = '' # 接口加密功能开关(如需关闭 后端也必须对应关闭) diff --git a/.env.production b/.env.production index ac6c1bb..508d339 100644 --- a/.env.production +++ b/.env.production @@ -27,15 +27,16 @@ VITE_LOGIN_BACK_URL_WORKBENCH_TRUE= true VITE_APP_SHOW_WORK_PLATFORM = true -# 地图类型 天地图 or 高德地图 天地图 WGS84 高德地图 GCJ02, 高德地图 需要在高德地图官网申请key -# 高德地图 GCJ02 -# 天地图 WGS84 +# 地图类型 天地图 WGS84 高德地图 GCJ02, 高德地图 需要在高德地图官网申请key VITE_APP_MAP_TYPE = 'GCJ02' # 高德地图key 建议放入环境变量中,避免泄露 VITE_GCJ02_KEY_GD = '8e302fe1be5f4db62bc734db23dca149' VITE_GCJ02_JS_CODE_GD = '09534b3534d8da53968529a9ce164118' +# 天地图key 建议放入环境变量中,避免泄露 +VITE_TIANDITU_KEY = 'f71689f9e22158947ebf64ad95e0a595' + # 是否在打包时开启压缩,支持 gzip 和 brotli diff --git a/src/api/system/InspectionPoint/type.ts b/src/api/system/InspectionPoint/type.ts index 4ea9ed4..36ed7bc 100644 --- a/src/api/system/InspectionPoint/type.ts +++ b/src/api/system/InspectionPoint/type.ts @@ -2,7 +2,7 @@ export interface PointVO { /** * 主键ID */ - id: string | number; + id: string; /** * 巡检点名称 @@ -17,7 +17,7 @@ export interface PointVO { /** * 所属路线ID */ - routeId: string | number; + routeId: string; /** * 巡检点位置(经纬度),格式:经度,纬度 diff --git a/src/api/system/InspectionRoute/index.ts b/src/api/system/InspectionRoute/index.ts index d6fdaed..88d1c11 100644 --- a/src/api/system/InspectionRoute/index.ts +++ b/src/api/system/InspectionRoute/index.ts @@ -20,7 +20,7 @@ export const listRoute = (query: RouteQuery | {} = {}): AxiosPromise * 查询巡检路线详细 * @param id */ -export const getRoute = (id: string | number): AxiosPromise => { +export const getRoute = (id: string): AxiosPromise => { return request({ url: '/inspection/route/' + id, method: 'get' diff --git a/src/api/system/InspectionRoute/type.ts b/src/api/system/InspectionRoute/type.ts index 808fcf7..47e4f95 100644 --- a/src/api/system/InspectionRoute/type.ts +++ b/src/api/system/InspectionRoute/type.ts @@ -4,7 +4,7 @@ export interface RouteVO { /** * 主键ID */ - id: string | number; + id: string; /** * 巡检路线名称 @@ -70,7 +70,7 @@ export interface RouteForm extends BaseEntity { /** * 主键ID */ - id?: string | number; + id?: string; /** * 巡检路线名称 diff --git a/src/components/Map/GD.vue b/src/components/Map/GD.vue index 22f6ef2..0ae5a62 100644 --- a/src/components/Map/GD.vue +++ b/src/components/Map/GD.vue @@ -2,6 +2,7 @@ import AMapLoader from '@amap/amap-jsapi-loader'; import { getVillageByIdAPI } from '@/api/system/community'; import { onUnmounted, ref, watch, onMounted, nextTick } from 'vue'; +import { LngLat } from '@/components/Map/type'; // 密钥配置 const autoloader = import.meta.env.VITE_GCJ02_KEY_GD; @@ -12,7 +13,7 @@ window._AMapSecurityConfig = { securityJsCode: VITE_GCJ02_JS_CODE_GD }; const AMAP = ref(null); const map = ref(null); const mapReady = ref(false); -const maploading = ref(false); +const mapLoading = ref(false); const markers = ref([]); const mouseTool = ref(null); const AddMarkered = new Map(); @@ -26,7 +27,7 @@ const props = defineProps({ }, clickOrDraw: { type: Boolean, - default: false + default: true }, smallScroll: { type: Boolean, @@ -34,7 +35,7 @@ const props = defineProps({ } }); const emits = defineEmits<{ - clickPoint: [value: number[]]; + clickPoint: [value: LngLat]; }>(); // 对外暴露方法 @@ -191,7 +192,7 @@ function initDrawTool() { } /** 获取路线坐标数组 */ -function getAllDrawLines(): number[][] { +function getAllDrawLines(): LngLat[] | [] { if (!isMapAvailable() || drawnPolylines.length === 0) return []; const path = drawnPolylines[0].getPath(); return path.map((p: any) => [p.lng, p.lat]); @@ -257,7 +258,7 @@ function handleMap() { // ===================== 地图初始化 ===================== onMounted(async () => { - maploading.value = true; + mapLoading.value = true; try { const AMap = await AMapLoader.load({ key: autoloader, @@ -266,10 +267,6 @@ onMounted(async () => { }); AMAP.value = AMap; - // 获取村庄城市定位 - const villageInfo = await getVillageByIdAPI(village); - const city = villageInfo.data.city.replaceAll('/', ''); - // 创建地图,全局关闭动画,解决移动缓慢 map.value = new AMap.Map('GD-Map', { viewMode: '3D', @@ -277,24 +274,33 @@ onMounted(async () => { center: [116.397428, 39.90923] }); - // 城市地理编码定位 - const geocoder = new AMap.Geocoder({ city }); - geocoder.getLocation(city, (status: string, result: any) => { - if (status === 'complete' && result.info === 'OK') { - map.value.setCenter(result.geocodes[0].location.toArray()); - } - }); + try { + // 获取村庄城市定位 + const villageInfo = await getVillageByIdAPI(village); + const city = villageInfo.data.city.replaceAll('/', ''); + // 城市地理编码定位 + const geocoder = new AMap.Geocoder({ city }); + geocoder.getLocation(city, (status: string, result: any) => { + if (status === 'complete' && result.info === 'OK') { + map.value.setCenter(result.geocodes[0].location.toArray()); + } + }); + } catch (e) { + console.error(e); + map.value.setCenter([116.397428, 39.90923]); + } mapReady.value = true; // 禁用状态不开启绘制/点击 if (!props.disabled) { + console.log(props.clickOrDraw); props.clickOrDraw ? handleMap() : MapDrawLine(); } } catch (err) { console.error('高德地图加载失败', err); } finally { - maploading.value = false; + mapLoading.value = false; } }); @@ -319,7 +325,7 @@ onUnmounted(() => { + diff --git a/src/components/Map/index.vue b/src/components/Map/index.vue index 1115ded..b845395 100644 --- a/src/components/Map/index.vue +++ b/src/components/Map/index.vue @@ -1,14 +1,36 @@ - + - diff --git a/src/components/Map/type.ts b/src/components/Map/type.ts new file mode 100644 index 0000000..963960e --- /dev/null +++ b/src/components/Map/type.ts @@ -0,0 +1,30 @@ +// src/types/map.ts +export type LngLat = [number, number]; + +// 统一对外暴露的地图方法类型 +export interface IMapInstance { + // 单点标记 + addMarker_only(lnglat: LngLat, pointName: string): void; + clearLocation(): void; + // 多点可删除标记 + addMarker_more(lnglat: LngLat, pointName: string, pointId: string): void; + // 绘制路线 + getAllDrawLines(): LngLat[] | []; + renderSavedPath(pathStr: string): void; + clearAll(): void; + // 全局清空覆盖物 + clearMapMarker(): void; +} + +// 统一Props +export interface MapBaseProps { + /** 禁用功能,只做展示 */ + disabled?: boolean; + /** true 标注点 false 路线*/ + clickOrDraw?: boolean; +} + +// 统一事件 +export type MapEmits = { + clickPoint: [lnglat: LngLat]; +}; diff --git a/src/types/env.d.ts b/src/types/env.d.ts index d06d39f..7b62f35 100644 --- a/src/types/env.d.ts +++ b/src/types/env.d.ts @@ -10,6 +10,7 @@ interface ImportMetaEnv { VITE_APP_TITLE: string; VITE_APP_PORT: number; VITE_APP_BASE_API: string; + VITE_APP_PROXY_API: string; VITE_APP_BASE_URL: string; VITE_APP_CONTEXT_PATH: string; VITE_APP_MONITOR_ADMIN: string; @@ -21,6 +22,15 @@ interface ImportMetaEnv { VITE_APP_CLIENT_ID: string; VITE_APP_WEBSOCKET: string; VITE_APP_SSE: string; + + VITE_APP_MAP_TYPE: string; + VITE_GCJ02_KEY_GD: string; + VITE_GCJ02_JS_CODE_GD: string; + VITE_TIANDITU_KEY: string; + + VITE_LOGIN_BACK_URL: string; + VITE_LOGIN_BACK_URL_WORKBENCH_TRU: boolean; + VITE_APP_SHOW_WORK_PLATFORM: boolean; } interface ImportMeta { readonly env: ImportMetaEnv; diff --git a/src/views/system/inspection/Plan/addInspectionPlan.vue b/src/views/system/inspection/Plan/addInspectionPlan.vue index c5fae63..f4c2101 100644 --- a/src/views/system/inspection/Plan/addInspectionPlan.vue +++ b/src/views/system/inspection/Plan/addInspectionPlan.vue @@ -5,7 +5,7 @@
基本信息
-
+
@@ -22,7 +22,7 @@ v-for="(item, index) in 7" :key="index" > -
+
{{ numToWeek(item) }} @@ -64,7 +64,7 @@ - + 提交 @@ -83,7 +83,9 @@ import { numToWeek } from '@/utils/time'; import { ref } from 'vue'; import { addPlan, getPlan, updatePlan } from '@/api/system/InspectionPlan'; import { Check } from '@element-plus/icons-vue'; -import GD from '@/components/Map/GD.vue'; +import MapWrapper from '@/components/Map/index.vue'; +import { PointVO } from '@/api/system/InspectionPoint/type'; +import { LngLat } from '@/components/Map/type'; const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { com_inspection_remind_tiime } = toRefs(proxy?.useDict('com_inspection_remind_tiime')); @@ -123,7 +125,7 @@ function checkoutWeekFun(val: number) { // 提醒时间 // 巡检计划id -const editid = ref(null); +const editId = ref(null); // 初始化 // 路线列表 @@ -132,8 +134,8 @@ async function init() { const res = await listRoute(); playlist.value = res.rows; if (route.query.id) { - editid.value = route.query.id; - getPlan(editid.value).then((res) => { + editId.value = route.query.id; + getPlan(editId.value).then((res) => { form.value = { id: res.data.id, planName: res.data.planName, // 巡检计划名称 @@ -176,21 +178,21 @@ function outback() { router.back(); } -const GDef = ref(null); +const MapWrapperRef = ref>(); function handleChangeMap(val: string) { if (val) { - GDef.value.clearMapMarker(); + MapWrapperRef.value.clearMapMarker(); const find = playlist.value.find((item) => item.id === val); if (find.points && find.points.length > 0) { - find.points.forEach((item) => { - const angular = item.location.split(',').map(Number).filter(Boolean); - GDef.value.addMarker_more(angular, item.pointNames, item.id); + find.points.forEach((item: PointVO) => { + const angular = item.location.split(',').map(Number).filter(Boolean) as LngLat; + MapWrapperRef.value.addMarker_more(angular, item.pointName, item.id); }); } // 巡检路线 if (find.pathPoints) { - GDef.value.renderSavedPath(find.pathPoints); + MapWrapperRef.value.renderSavedPath(find.pathPoints); } } } @@ -208,7 +210,7 @@ function submit() { formRef.value?.validate(async (valid: boolean) => { if (valid) { - if (editid.value) { + if (editId.value) { updatePlan(form.value).then(() => { ElMessage.success('编辑成功'); outback(); @@ -229,7 +231,7 @@ function submit() { margin-top: 20px; padding: 30px; background-color: white; - .bodybox { + .bodyBox { width: 600px; margin: 20px auto 0; } @@ -264,7 +266,7 @@ function submit() { color: #44a0ff; } } - .deleteaction { + .deleteAction { margin-left: 10px; cursor: pointer; &:hover { @@ -284,7 +286,7 @@ function submit() { color: #000; display: flex; align-items: center; - .iconbox { + .iconBox { width: 30px; height: 30px; margin-left: 5px; diff --git a/src/views/system/inspection/Point/addInspectionPoint.vue b/src/views/system/inspection/Point/addInspectionPoint.vue index e23e6c1..3774a02 100644 --- a/src/views/system/inspection/Point/addInspectionPoint.vue +++ b/src/views/system/inspection/Point/addInspectionPoint.vue @@ -9,15 +9,15 @@ -
+
@@ -25,11 +25,6 @@
- {{ @@ -38,7 +33,7 @@ - +
点击地图选择位置 清空选择地点(proxy?.useDict('com_inspection_point_status')); @@ -103,17 +99,17 @@ const rules = ref({ // !== 初始化 ============================================================================= const pointId = ref(null); -const pointItemlist = ref([]); -const checkoutPointItemlist = ref([]); +const pointItemList = ref([]); +const checkoutPointItemList = ref([]); const marker = ref(null); function checkoutItem(id: string) { form.value.itemId = ''; // 每次点击都先清空 itemId - if (checkoutPointItemlist.value.includes(id)) { - checkoutPointItemlist.value = checkoutPointItemlist.value.filter((item) => item !== id); + if (checkoutPointItemList.value.includes(id)) { + checkoutPointItemList.value = checkoutPointItemList.value.filter((item) => item !== id); } else { - checkoutPointItemlist.value.push(id); + checkoutPointItemList.value.push(id); } - form.value.itemId = checkoutPointItemlist.value.join(','); // 将选中的 id 数组转换为逗号分隔的字符串 + form.value.itemId = checkoutPointItemList.value.join(','); // 将选中的 id 数组转换为逗号分隔的字符串 } function init() { // 获取巡检项目列表 @@ -122,7 +118,7 @@ function init() { pageNum: 1, pageSize: 9999 }).then((res) => { - pointItemlist.value = res.rows; + pointItemList.value = res.rows; }); if (route.query.id) { @@ -133,18 +129,15 @@ function init() { ...form.value, ...res.data }; - // 如果有 itemId,拆分到 checkoutPointItemlist + // 如果有 itemId,拆分到 checkoutPointItemList if (res.data.itemId) { - checkoutPointItemlist.value = res.data.itemId.split(','); + checkoutPointItemList.value = res.data.itemId.split(','); } - const location = form.value.location - .split(',') - .map((item) => Number(item)) - .filter((item) => !Number.isNaN(item)); + const location = form.value.location.split(',').map(Number).filter(Boolean) as LngLat; if (location.length >= 2) { setTimeout(() => { - marker.value = GDef.value.addMarker_only(location); + marker.value = MapWrapperRef.value.addMarker_only(location, form.value.pointName); }, 500); } }); @@ -156,7 +149,7 @@ const submitForm = () => { formRef.value?.validate(async (valid: boolean) => { if (valid) { // 设置 itemId - form.value.itemId = checkoutPointItemlist.value.join(','); + form.value.itemId = checkoutPointItemList.value.join(','); if (pointId.value) { updatePoint(form.value).then(() => { ElMessage.success('编辑成功'); @@ -176,11 +169,11 @@ const cancelForm = () => { router.back(); }; -const GDef = ref(); -function handleClickPoint(laglat: number[]) { +const MapWrapperRef = ref>(); +function handleClickMapPoint(LngLat: LngLat) { marker.value = null; - form.value.location = `${laglat[0]},${laglat[1]}`; - marker.value = GDef.value.addMarker_only(laglat); + form.value.location = `${LngLat[0]},${LngLat[1]}`; + marker.value = MapWrapperRef.value.addMarker_only(LngLat, form.value.pointName); } onMounted(async () => { @@ -215,7 +208,7 @@ onMounted(async () => { width: 800px; margin: 0 auto; - .itembox { + .itemBox { display: flex; flex-wrap: wrap; .item { diff --git a/src/views/system/inspection/Route/addInspectionRoute.vue b/src/views/system/inspection/Route/addInspectionRoute.vue index b7fef39..789c9b5 100644 --- a/src/views/system/inspection/Route/addInspectionRoute.vue +++ b/src/views/system/inspection/Route/addInspectionRoute.vue @@ -9,23 +9,23 @@ -
+
- +
{{ item.pointName }}
- +
点击地图,绘制巡检路线;再次点击可继续绘制下一条(但只能保留一条)
@@ -33,7 +33,7 @@ class="deleteMarker" @click=" () => { - GDef.clearAll(); + MapWrapperRef.clearAll(); } " >清空所有路线>(); +const routeId = ref(null); // 巡检点 列表 -const pointslist = ref([]); +const pointsList = ref([]); // 选择巡检点列表 -const checkoutPointlist = ref([]); +const checkoutPointList = ref([]); // ! 初始化 ========================================================================= function init() { if (route.query.id) { - routeid.value = route.query.id; + routeId.value = route.query.id; // 获取巡检点详情 - getRoute(routeid.value).then((res) => { + getRoute(routeId.value).then((res) => { form.value = { id: res.data.id, startLat: res.data.startLat, @@ -112,29 +114,27 @@ function init() { totalPoints: res.data.totalPoints // 巡检点 }; nextTick(() => { - if (routeid.value) { - checkoutPointlist.value = res.data.totalPoints ? res.data.totalPoints.split(',') : []; - if (checkoutPointlist.value.length > 0) { + if (routeId.value) { + checkoutPointList.value = res.data.totalPoints ? res.data.totalPoints.split(',') : []; + if (checkoutPointList.value.length > 0) { // 回显 marker - checkoutPointlist.value.forEach((id) => { + checkoutPointList.value.forEach((id) => { const find = res.data.points.find((item) => item.id === id); if (find && find.location) { - // addPointMarker(id, find.location, find.pointName); const location = find.location .split(',') .map((item) => Number(item)) - .filter((item) => !Number.isNaN(item)); + .filter(Boolean) as LngLat; if (location.length >= 2) { - GDef.value.addMarker_more(location, find.pointName, find.id); + MapWrapperRef.value.addMarker_more(location, find.pointName, find.id); } } }); } // 回显路线 if (res.data.pathPoints) { - // renderSavedPath(res.data.pathPoints); setTimeout(() => { - GDef.value.renderSavedPath(res.data.pathPoints); + MapWrapperRef.value.renderSavedPath(res.data.pathPoints); }, 800); } } @@ -146,9 +146,9 @@ const map = ref(null); onMounted(async () => { // 获取巡检点列表 - if (!routeid.value) { + if (!routeId.value) { listPoint({}).then((res) => { - pointslist.value = res.rows; + pointsList.value = res.rows; }); } await nextTick(() => init()); @@ -163,15 +163,15 @@ const submitForm = () => { formRef.value?.validate(async (valid: boolean) => { if (valid) { // 获取路线经纬度 - const path = GDef.value.getAllDrawLines() as [number, number][]; + const path = MapWrapperRef.value.getAllDrawLines() as LngLat[]; console.log(path); if (path.length === 0) { ElMessage.warning('请绘制巡检路线'); return; } // 转成字符串传给后端 - const [start_lng, start_lat] = path.at(0) as [number, number]; - const [end_lng, end_lat] = path.at(-1) as [number, number]; + const [start_lng, start_lat] = path.at(0) as LngLat; + const [end_lng, end_lat] = path.at(-1) as LngLat; form.value.startLng = `${start_lng}`; form.value.startLat = `${start_lat}`; @@ -179,8 +179,8 @@ const submitForm = () => { form.value.endLat = `${end_lat}`; form.value.pathPoints = JSON.stringify(path); - form.value.totalPoints = checkoutPointlist.value.join(','); - if (routeid.value) { + form.value.totalPoints = checkoutPointList.value.join(','); + if (routeId.value) { updateRoute(form.value).then(() => { ElMessage.success('编辑成功'); cancelForm(); @@ -200,20 +200,19 @@ const cancelForm = () => { }; // 点击展现 巡检点 -function checkoutItemPoint(pop) { - const find = pointslist.value.find((item) => item.id === pop.id); +function checkoutItemPoint(pop: PointVO) { + const find = pointsList.value.find((item) => item.id === pop.id); if (find && find.location) { - const locations = - find.location - .split(',') - .map((item: string) => Number(item)) - .filter(Boolean) ?? []; + const locations = find.location + .split(',') + .map((item: string) => Number(item)) + .filter(Boolean) as LngLat; if (locations.length >= 2) { - GDef.value.addMarker_more(locations, find.pointName, find.id); - if (checkoutPointlist.value.includes(pop.id)) { - checkoutPointlist.value = checkoutPointlist.value.filter((item) => item !== pop.id); + MapWrapperRef.value.addMarker_more(locations, find.pointName, find.id); + if (checkoutPointList.value.includes(pop.id)) { + checkoutPointList.value = checkoutPointList.value.filter((item) => item !== pop.id); } else { - checkoutPointlist.value.push(pop.id); + checkoutPointList.value.push(pop.id); } } else { ElMessage.error(find.pointName + ' - 巡检点经纬度定位有误'); @@ -252,7 +251,7 @@ onUnmounted(() => { width: 800px; margin: 0 auto; - .itembox { + .itemBox { display: flex; flex-wrap: wrap; .item { diff --git a/src/views/system/inspection/Task/addTask.vue b/src/views/system/inspection/Task/addTask.vue index 28b0552..d6ba6b4 100644 --- a/src/views/system/inspection/Task/addTask.vue +++ b/src/views/system/inspection/Task/addTask.vue @@ -5,7 +5,7 @@
基本信息
-
+
@@ -14,7 +14,7 @@
{{ item.nickName }}
- +
@@ -51,22 +51,17 @@ - - + - + 提交 - 返回 + 返回
@@ -82,8 +77,8 @@ import { ref } from 'vue'; import { listPlan } from '@/api/system/InspectionPlan'; import { addTask, getTask, updateTask } from '@/api/system/InspectionTask'; import { getRoute } from '@/api/system/InspectionRoute'; - -import GD from '@/components/Map/GD.vue'; +import MapWrapper from '@/components/Map/index.vue'; +import { LngLat } from '@/components/Map/type'; const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { com_inspection_remind_tiime } = toRefs(proxy?.useDict('com_inspection_remind_tiime')); @@ -106,36 +101,19 @@ const rules = ref({ inspectorId: [{ required: true, message: '请选择巡检人员', trigger: 'blur' }], planId: [{ required: true, message: '请选择巡检计划', trigger: 'blur' }] }); - -// 提醒时间 -const remindTimeoptions = ref([ - { - value: 10, - label: '任务开始前10分钟' - }, - { - value: 15, - label: '任务开始前15分钟' - }, - { - value: 20, - label: '任务开始前30分钟' - } -]); - // 巡检计划id -const editid = ref(null); +const editId = ref(null); // 初始化 // 路线列表 -const planlist = ref([]); +const planList = ref([]); async function init() { // 获取 路线 列表 const res = await listPlan(); - planlist.value = res.rows; + planList.value = res.rows; if (route.query.id) { - editid.value = route.query.id; - getTask(editid.value).then((res) => { + editId.value = route.query.id; + getTask(editId.value).then((res) => { form.value = { id: res.data.id, taskName: res.data.taskName, // 巡检计划名称 @@ -157,51 +135,51 @@ function handleAddUser() { RepairUserRef.value.open(); } const checkoutUserlist = ref([]); -function handleUserChange(val) { +function handleUserChange(val: any[]) { checkoutUserlist.value = val; } -function handleDelete(id) { +function handleDelete(id: string) { checkoutUserlist.value = checkoutUserlist.value.filter((item) => item.userId !== id); } // 返回 -function routeback() { +function outback() { router.back(); } -const maploading = ref(false); +const mapLoading = ref(false); -const GDef = ref(null); +const MapWrapperRef = ref>(); function handleChangeMap(val: string) { - maploading.value = true; - const find = planlist.value.find((item) => item.id === val); + mapLoading.value = true; + const find = planList.value.find((item) => item.id === val); if (find) { const route = find.routeList[find.routeList.length - 1]; if (route) { getRoute(route.id) .then((res) => { if (res) { - GDef.value.clearMapMarker(); + MapWrapperRef.value.clearMapMarker(); if (res.data.points && res.data.points.length > 0) { res.data.points.forEach((item) => { - const angular = item.location.split(',').map(Number).filter(Boolean); - GDef.value.addMarker_more(angular, item.pointName, item.id); + const angular = item.location.split(',').map(Number).filter(Boolean) as LngLat; + MapWrapperRef.value.addMarker_more(angular, item.pointName, item.id); }); } // 巡检路线 if (res.data.pathPoints) { - GDef.value.renderSavedPath(res.data.pathPoints); + MapWrapperRef.value.renderSavedPath(res.data.pathPoints); } } }) .finally(() => { - maploading.value = false; + mapLoading.value = false; }); } else { - maploading.value = false; + mapLoading.value = false; } } else { - maploading.value = false; + mapLoading.value = false; } } @@ -219,15 +197,15 @@ function submit() { form.value.inspectorId = checkoutUserlist.value.map((item) => item.userId).join(','); formRef.value?.validate(async (valid: boolean) => { if (valid) { - if (editid.value) { + if (editId.value) { updateTask(form.value).then(() => { ElMessage.success('编辑成功'); - routeback(); + outback(); }); } else { addTask(form.value).then(() => { ElMessage.success('添加成功'); - routeback(); + outback(); }); } } @@ -240,7 +218,7 @@ function submit() { margin-top: 20px; padding: 30px; background-color: white; - .bodybox { + .bodyBox { width: 600px; margin: 20px auto 0; } @@ -275,7 +253,7 @@ function submit() { color: #44a0ff; } } - .deleteaction { + .deleteAction { margin-left: 10px; cursor: pointer; &:hover { @@ -295,7 +273,7 @@ function submit() { color: #000; display: flex; align-items: center; - .iconbox { + .iconBox { width: 30px; height: 30px; margin-left: 5px;