同步6/16
This commit is contained in:
@@ -25,11 +25,11 @@
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="打卡方式" prop="checkMode">
|
||||
<!-- <el-form-item label="打卡方式" prop="checkMode">
|
||||
<el-select v-model="form.checkMode" placeholder="请选择打卡方式" clearable>
|
||||
<el-option v-for="dict in com_inspection_point_checkmode" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="巡检点状态" prop="status">
|
||||
<el-radio-group v-model="form.status">
|
||||
<el-radio v-for="item in com_inspection_point_status" :value="item.value" :key="item.value" :label="item.value">{{
|
||||
@@ -67,7 +67,7 @@ import AMapLoader from '@amap/amap-jsapi-loader';
|
||||
import { getVillageByIdAPI } from '@/api/system/community';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { com_inspection_point_checkmode } = toRefs<any>(proxy?.useDict('com_inspection_point_checkmode'));
|
||||
// const { com_inspection_point_checkmode } = toRefs<any>(proxy?.useDict('com_inspection_point_checkmode'));
|
||||
const { com_inspection_point_status } = toRefs<any>(proxy?.useDict('com_inspection_point_status'));
|
||||
|
||||
const router = useRouter();
|
||||
@@ -79,6 +79,7 @@ const form = ref({
|
||||
pointName: '',
|
||||
itemId: '',
|
||||
location: '',
|
||||
locationName: '',
|
||||
status: '0',
|
||||
checkMode: '9999'
|
||||
});
|
||||
@@ -106,7 +107,11 @@ function checkoutItem(id: string) {
|
||||
}
|
||||
function init() {
|
||||
// 获取巡检项目列表
|
||||
listItem().then((res) => {
|
||||
listItem({
|
||||
status: '0',
|
||||
pageNum: 1,
|
||||
pageSize: 9999
|
||||
}).then((res) => {
|
||||
pointItemlist.value = res.rows;
|
||||
});
|
||||
|
||||
@@ -157,27 +162,31 @@ const mapReady = ref(false);
|
||||
const map = ref(null);
|
||||
const marker = ref(null);
|
||||
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 () => {
|
||||
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) => {
|
||||
const villageinfo = await getVillageByIdAPI(villageid);
|
||||
const city = villageinfo.data.city.replaceAll('/', '');
|
||||
map.value = new AMap.Map('containerMap', {
|
||||
viewMode: '3D',
|
||||
zoom: 11,
|
||||
center: [116.397428, 39.90923]
|
||||
});
|
||||
|
||||
AMap.plugin('AMap.Geocoder', function () {
|
||||
const city = villageinfo.data.city.replaceAll('/', '');
|
||||
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());
|
||||
@@ -185,14 +194,8 @@ onMounted(async () => {
|
||||
});
|
||||
});
|
||||
|
||||
map.value = new AMap.Map('containerMap', {
|
||||
viewMode: '3D',
|
||||
zoom: 11,
|
||||
center: [116.397428, 39.90923]
|
||||
});
|
||||
|
||||
mapReady.value = true;
|
||||
handleMap(AMap);
|
||||
handleMap(AMap, city);
|
||||
initLocation(AMap);
|
||||
});
|
||||
});
|
||||
@@ -206,11 +209,21 @@ function clearLocation() {
|
||||
}
|
||||
}
|
||||
|
||||
function handleMap(AMap) {
|
||||
function handleMap(AMap, city = '010') {
|
||||
// 添加点击事件
|
||||
map.value.on('click', (e) => {
|
||||
const lnglat = e.lnglat;
|
||||
form.value.location = `${lnglat.lng},${lnglat.lat}`;
|
||||
const lnglatarr = [lnglat.lng, lnglat.lat];
|
||||
const geocoder = new AMap.Geocoder({
|
||||
city: city // city 指定进行编码查询的城市,支持传入城市名、adcode 和 citycode
|
||||
});
|
||||
geocoder.getAddress(lnglatarr, function (status, result) {
|
||||
if (status === 'complete' && result.info === 'OK') {
|
||||
// result为对应的地理位置详细信息
|
||||
form.value.locationName = result.regeocode.formattedAddress;
|
||||
}
|
||||
});
|
||||
// 如果有 marker.value,先移除
|
||||
if (marker.value) {
|
||||
map.value.remove(marker.value);
|
||||
|
||||
Reference in New Issue
Block a user