From d6be0488c4343e445dc725ca190de4bc29dab93d Mon Sep 17 00:00:00 2001 From: qsh <> Date: Sun, 18 Aug 2024 16:29:01 +0800 Subject: [PATCH] sc --- src/views/Home/CloseRate.vue | 7 + src/views/SchoolManagement/Place/index.vue | 220 ++++++++++++++------- 2 files changed, 153 insertions(+), 74 deletions(-) create mode 100644 src/views/Home/CloseRate.vue diff --git a/src/views/Home/CloseRate.vue b/src/views/Home/CloseRate.vue new file mode 100644 index 0000000..c8876d0 --- /dev/null +++ b/src/views/Home/CloseRate.vue @@ -0,0 +1,7 @@ + + + + + diff --git a/src/views/SchoolManagement/Place/index.vue b/src/views/SchoolManagement/Place/index.vue index 4939e7b..3a96e42 100644 --- a/src/views/SchoolManagement/Place/index.vue +++ b/src/views/SchoolManagement/Place/index.vue @@ -71,80 +71,107 @@ - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + +
+ 保存 + 取消 +
+
+ + import * as PlaceApi from '@/api/school/place' +import { getConfigByConfigKey } from '@/api/system/set' import { getAreaSimpleList } from '@/api/school/setting/area' import { checkPermi } from '@/utils/permission' @@ -267,18 +295,35 @@ const mapHelpText = ref('') const tipPostion = ref({}) const placeTab = ref('info') -function initMap() { +const defaultLatLng = ref({ + lat: 31.86119, + lng: 117.283042 +}) +const defaultCity = ref('合肥') + +let AutoComplete = ref(null) +async function initMap() { + const data = await getConfigByConfigKey({ configKey: 'defaultLocation' }) + const cityInfo = JSON.parse(data.configValue) + defaultLatLng.value = { + lat: cityInfo.lat, + lng: cityInfo.lng + } + defaultCity.value = cityInfo.locationName AMapLoader.load({ key: '713d839ff505943b0f18e6df45f3b0dc', //设置您的key version: '2.0', - plugins: ['AMap.Geocoder'] + plugins: ['AMap.Geocoder', 'AMap.AutoComplete'] }).then((AMap) => { aMap.value = AMap geoCoder.value = new AMap.Geocoder() dialogMap.value = new AMap.Map('dialogMap', { zoom: 12, zooms: [2, 22], - center: [117.283042, 31.86119] + center: [defaultLatLng.value.lng, defaultLatLng.value.lat] + }) + AutoComplete.value = new AMap.AutoComplete({ + city: defaultCity.value }) locationMarker.value = new AMap.Marker({ icon: FlagRed @@ -313,6 +358,32 @@ function initMap() { }) } +const areaValue = ref('') +function remoteMethod(searchValue, cb) { + if (searchValue) { + AutoComplete.value?.search(searchValue, (status, result) => { + if (result.tips?.length) { + // areaList.value = result?.tips + const list = result.tips.map((it) => ({ + ...it, + value: it.name + })) + cb(list) + } else { + cb([]) + } + }) + } else { + cb([]) + } +} + +function currentSelect(val) { + if (val) { + dialogMap.value.setCenter([val.location?.lng, val.location?.lat], true) + } +} + function regeoCode() { geoCoder.value.getAddress([placeForm.value.lng, placeForm.value.lat], (status, result) => { if (status === 'complete' && result.regeocode) { @@ -678,7 +749,8 @@ onMounted(() => { position: absolute; left: 20px; top: 20px; - width: 350px; + width: 500px; + display: flex; } .map-tip {