同步6/16
This commit is contained in:
@@ -8,19 +8,19 @@
|
||||
<el-form-item label="巡检路线名称" prop="routeName">
|
||||
<el-input v-model.trim="form.routeName" placeholder="请输入巡检路线名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="巡检路线描述" prop="description">
|
||||
<!-- <el-form-item label="巡检路线描述" prop="description">
|
||||
<el-input type="textarea" :rows="3" v-model.trim="form.description" placeholder="请输入巡检路线描述" />
|
||||
</el-form-item>
|
||||
<el-form-item label="预计巡检时长" prop="estimatedTime">
|
||||
</el-form-item> -->
|
||||
<!-- <el-form-item label="预计巡检时长" prop="estimatedTime">
|
||||
<el-input v-model.trim.number="form.estimatedTime" placeholder="预计巡检时长">
|
||||
<template #append>分钟</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="巡检路线状态" prop="routeStatus">
|
||||
</el-form-item> -->
|
||||
<!-- <el-form-item label="巡检路线状态" prop="routeStatus">
|
||||
<el-radio-group v-model="form.routeStatus">
|
||||
<el-radio v-for="(item, index) in com_inspection_route_status" :key="index" :value="item.value" :label="item.label"></el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="巡检点">
|
||||
<div class="itembox">
|
||||
<div
|
||||
@@ -57,19 +57,15 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, toRefs, nextTick } from 'vue';
|
||||
import { getCurrentInstance, ComponentInternalInstance } from 'vue';
|
||||
import { ref, nextTick } from 'vue';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
import PageHeader from '@/components/Pageheader/index.vue';
|
||||
import { addPoint, getPoint, listPoint, updatePoint } from '@/api/system/InspectionPoint';
|
||||
import { listPoint } from '@/api/system/InspectionPoint';
|
||||
import { onMounted, onUnmounted } from 'vue';
|
||||
import AMapLoader from '@amap/amap-jsapi-loader';
|
||||
import { addRoute, getRoute, updateRoute } from '@/api/system/InspectionRoute';
|
||||
import { getVillageByIdAPI } from '@/api/system/community';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { com_inspection_route_status } = toRefs<any>(proxy?.useDict('com_inspection_route_status'));
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
@@ -193,7 +189,7 @@ function init() {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// TODO 巡检路线开关
|
||||
// ! map
|
||||
const mapReady = ref(false);
|
||||
const AMapLib = ref(null);
|
||||
@@ -203,28 +199,26 @@ const markers = ref<Record<string, any>>({});
|
||||
const mouseTool = ref(null);
|
||||
const drawnPolylines = ref([]); // 存所有线条
|
||||
const villageid = localStorage.getItem('villageid');
|
||||
const aloaderkey = import.meta.env.VITE_GCJ02_KEY_GD;
|
||||
const VITE_GCJ02_JS_CODE_GD = import.meta.env.VITE_GCJ02_JS_CODE_GD;
|
||||
onMounted(async () => {
|
||||
// 获取巡检点列表
|
||||
if (!routeid.value) {
|
||||
listPoint().then((res) => {
|
||||
listPoint({}).then((res) => {
|
||||
pointslist.value = res.rows;
|
||||
});
|
||||
}
|
||||
|
||||
await nextTick();
|
||||
|
||||
window._AMapSecurityConfig = { securityJsCode: '09534b3534d8da53968529a9ce164118' };
|
||||
|
||||
window._AMapSecurityConfig = { securityJsCode: VITE_GCJ02_JS_CODE_GD };
|
||||
AMapLoader.load({
|
||||
key: '8e302fe1be5f4db62bc734db23dca149',
|
||||
key: aloaderkey,
|
||||
version: '2.0',
|
||||
plugins: ['AMap.Scale', 'AMap.Marker']
|
||||
}).then(async (AMap) => {
|
||||
AMapLib.value = AMap;
|
||||
map.value = new AMap.Map('containerMap', {
|
||||
viewMode: '3D',
|
||||
zoom: 11,
|
||||
center: [116.397428, 39.90923]
|
||||
zoom: 11
|
||||
});
|
||||
|
||||
const villageinfo = await getVillageByIdAPI(villageid);
|
||||
@@ -233,10 +227,7 @@ onMounted(async () => {
|
||||
const geocoder = new AMap.Geocoder({
|
||||
city: city // city 指定进行编码查询的城市,支持传入城市名、adcode 和 citycode
|
||||
});
|
||||
|
||||
const address = villageinfo.data.address;
|
||||
|
||||
geocoder.getLocation(address, function (status, result) {
|
||||
geocoder.getLocation(city, function (status, result) {
|
||||
if (status === 'complete' && result.info === 'OK') {
|
||||
// result中对应详细地理坐标信息
|
||||
map.value.setCenter(result.geocodes[0].location.toArray());
|
||||
@@ -331,8 +322,10 @@ function clearAll() {
|
||||
// !!! 核心:获取绘制的路线经纬度数组
|
||||
function getPolylinePath() {
|
||||
if (drawnPolylines.value.length === 0) return [];
|
||||
const lastLine = drawnPolylines.value.pop();
|
||||
const path = lastLine.getPath().map((p) => [p.lng, p.lat]);
|
||||
// 获取最后一条线
|
||||
const lastPolyline = drawnPolylines.value[drawnPolylines.value.length - 1];
|
||||
// const lastLine = drawnPolylines.value.pop();
|
||||
const path = lastPolyline.getPath().map((p) => [p.lng, p.lat]);
|
||||
return path;
|
||||
}
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user