diff --git a/package.json b/package.json index 33ef86790..b269eeffa 100644 --- a/package.json +++ b/package.json @@ -27,8 +27,8 @@ "babel-plugin-component": "^1.1.1", "echarts": "^5.2.2", "echarts-gl": "^2.0.9", - "element-theme": "^2.0.1", - "element-ui": "^2.13.0", + "element-theme": "2.0.1", + "element-ui": "2.13.2", "file-saver": "^2.0.5", "gulp-autoprefixer": "^6.1.0", "gulp-clean-css": "^4.2.0", @@ -112,4 +112,4 @@ "not ie <= 10" ] } -} +} \ No newline at end of file diff --git a/public/index.html b/public/index.html index 3f25f83a1..b91b1e447 100644 --- a/public/index.html +++ b/public/index.html @@ -7,12 +7,9 @@ - - - + + diff --git a/src/main.js b/src/main.js index 51a5d6bea..f5f3634b1 100644 --- a/src/main.js +++ b/src/main.js @@ -1,7 +1,7 @@ import Vue from "vue"; import Element from "element-ui"; -import Mint from "mint-ui"; -import "mint-ui/lib/style.css"; +// import Mint from "mint-ui"; +// import "mint-ui/lib/style.css"; import App from "@/App"; import i18n from "@/i18n"; @@ -12,14 +12,14 @@ import "@/assets/scss/aui.scss"; //按钮 import http from "@/utils/request"; -import renRadioGroup from "@/components/ren-radio-group"; -import renSelect from "@/components/ren-select"; -import renProcessMultiple from "@/components/ren-process-multiple"; -import renProcessStart from "@/components/ren-process-start"; -import renProcessRunning from "@/components/ren-process-running"; -import renProcessDetail from "@/components/ren-process-detail"; -import renDeptTree from "@/components/ren-dept-tree"; -import renRegionTree from "@/components/ren-region-tree"; +// import renRadioGroup from "@/components/ren-radio-group"; +// import renSelect from "@/components/ren-select"; +// import renProcessMultiple from "@/components/ren-process-multiple"; +// import renProcessStart from "@/components/ren-process-start"; +// import renProcessRunning from "@/components/ren-process-running"; +// import renProcessDetail from "@/components/ren-process-detail"; +// import renDeptTree from "@/components/ren-dept-tree"; +// import renRegionTree from "@/components/ren-region-tree"; import cloneDeep from "lodash/cloneDeep"; // axios封装 @@ -30,7 +30,7 @@ import service from "@/js/service"; import store from "@/js/store"; //系统工具 import util from "@js/util"; -import Cookies from "js-cookie"; +// import Cookies from "js-cookie"; import getQueryPara from "dai-js/modules/getQueryPara"; // 兼容token传参登录 @@ -51,16 +51,16 @@ window.app = Object.assign( Vue.config.productionTip = false; -Vue.use(renRadioGroup); -Vue.use(renSelect); -Vue.use(renDeptTree); -Vue.use(renRegionTree); -Vue.use(renProcessMultiple); -Vue.use(renProcessStart); -Vue.use(renProcessRunning); -Vue.use(renProcessDetail); -Vue.use(Element); -Vue.use(Mint); +// Vue.use(renRadioGroup); +// Vue.use(renSelect); +// Vue.use(renDeptTree); +// Vue.use(renRegionTree); +// Vue.use(renProcessMultiple); +// Vue.use(renProcessStart); +// Vue.use(renProcessRunning); +// Vue.use(renProcessDetail); +// Vue.use(Element); +// Vue.use(Mint); Vue.use(Element, { size: "default", diff --git a/src/utils/dai-map.js b/src/utils/dai-map.js new file mode 100644 index 000000000..712bc5b4d --- /dev/null +++ b/src/utils/dai-map.js @@ -0,0 +1,259 @@ +import nextTick from "dai-js/tools/nextTick"; + +export const mapType = typeof window.TMap !== "undefined" ? "qq" : "td"; + +export const QQMap = window.TMap; +export const TDMap = window.T; + +export function searchNearby(map, keyword) { + if (mapType == "qq") { + return new Promise((reslove) => { + const search = new QQMap.service.Search(map, { pageSize: 10 }); + search + .searchNearby({ + keyword, + radius: 1000, + autoExtend: true, + center: map.getCenter(), + }) + .then((result) => { + let { data } = result; + if (Array.isArray(data) && data.length > 0) { + const { + location: { lat, lng, address }, + } = data[0]; + reslove({ + msg: "success", + data: { + lng, + lat, + address, + resultList: data, + }, + }); + } else { + reslove({ + msg: "failed", + error: "未检索到相关位置坐标", + }); + } + }) + .catch((error) => { + reslove({ + msg: "failed", + error, + }); + }); + }); + } else { + return new Promise(async (reslove) => { + const search = new TDMap.LocalSearch(map, { pageCapacity: 10 }); + search.setQueryType(1); + search.searchNearby(keyword, map.getCenter(), 1000000000); + + await nextTick(1000); + + const result = search.getResults(); + const data = result ? result.getPois() : null; + + console.log("检索结果", data); + + if (Array.isArray(data) && data.length > 0) { + const { lonlat, address, name } = data[0]; + const lng = lonlat.split(" ")[0]; + const lat = lonlat.split(" ")[1]; + reslove({ + msg: "success", + data: { + lng, + lat, + address: address + name, + resultList: data, + }, + }); + } else { + reslove({ + msg: "failed", + error: "未检索到相关位置坐标", + }); + } + }); + } +} + +// 封装了地图相关函数,兼容天地图、腾讯地图常用api +export default function init(ele, position, params) { + this.mapType = mapType; + this.map = null; + this.marker = null; + this.markers = null; + this.getCenter = function () { + return { + lat: 0, + lng: 0, + }; + }; + this.setCenter = function (lat, lng) {}; + this.setMarker = function (lat, lng, title) {}; + this.getAddress = async function (lat, lng) {}; + this.on = function (eventType, fn) {}; + + let { latitude, longitude } = position; + if (!latitude || latitude == "" || latitude == "0") { + latitude = 39.9088810666821; + longitude = 116.39743841556731; + } + + if (mapType == "qq") { + let center = new QQMap.LatLng(latitude, longitude); + this.map = new QQMap.Map(ele, { + center, + ...params, + }); + + this.markers = new QQMap.MultiMarker({ + map: this.map, + geometries: [], + }); + + this.getCenter = function () { + const center = this.map.getCenter(); + const lat = center.getLat(); + const lng = center.getLng(); + return { lat, lng }; + }; + + this.setCenter = function (lat, lng) { + this.map.setCenter(new QQMap.LatLng(lat, lng)); + }; + + this.setMarker = function (lat, lng, title = "位置") { + this.markers.setGeometries([]); + this.markers.add([ + { + id: "4", + styleId: "marker", + position: new QQMap.LatLng(lat, lng), + properties: { + title, + }, + }, + ]); + }; + + this.geocoder = new QQMap.service.Geocoder(); // 新建一个正逆地址解析类 + this.getAddress = async function (lat, lng) { + return new Promise((reslove) => { + this.geocoder + .getAddress({ location: new QQMap.LatLng(lat, lng) }) // 将给定的坐标位置转换为地址 + .then((result) => { + reslove({ + msg: "success", + data: { + address: result.result.address, + }, + }); + }) + .catch((error) => { + reslove({ + msg: "failed", + error, + }); + }); + }); + }; + + this.on = function (eventType, fn) { + if (eventType == "dragend") { + this.map.on("moveend", (e) => { + console.log("dragend", e); + if (e && e.originalEvent) { + fn(e); + } + }); + } else { + this.map.on(eventType, fn); + } + }; + } else { + if (typeof ele == "string") { + ele = document.getElementById("app"); + } + let width = ele.offsetWidth; + let height = ele.offsetHeight; + if (height == 0) { + ele.style.height = width * 0.5 + "px"; + } + + let center = new TDMap.LngLat(longitude, latitude); + this.map = new TDMap.Map(ele, { + center, + ...params, + }); + + this.getCenter = function () { + const center = this.map.getCenter(); + const lat = center.getLat(); + const lng = center.getLng(); + return { lat, lng }; + }; + + this.setCenter = function (lat, lng) { + this.map.panTo(new TDMap.LngLat(lng, lat)); + }; + + this.setMarker = function (lat, lng, title = "位置") { + let lnglat = new TDMap.LngLat(lng, lat); + if (!this.marker) { + this.marker = new TDMap.Marker(lnglat, { + title, + }); + this.map.addOverLay(this.marker); + } else { + this.marker.setLngLat(lnglat); + } + }; + + this.geocoder = new TDMap.Geocoder(); // 新建一个正逆地址解析类 + this.getAddress = async function (lat, lng) { + return new Promise((reslove) => { + this.geocoder.getLocation(new TDMap.LngLat(lng, lat), (result) => { + if (result) { + console.log("this.geocoder.getLocation", result); + let status = result.getStatus(); + reslove({ + msg: "success", + data: { + address: result.getAddress(), + }, + }); + } else { + reslove({ + msg: "failed", + error: "解析失败", + }); + } + }); + }); + }; + + this.on = function (eventType, fn) { + if (eventType == "dragend") { + this.map.on("dragend", (e) => { + console.log("dragend", e); + fn(e); + }); + } else { + this.map.on(eventType, fn); + } + }; + } + + this.searchNearby = async function (keyword) { + const ret = await searchNearby(this.map, keyword); + + return ret; + }; + + return this; +} diff --git a/src/views/modules/communityService/dqfwzx/index.vue b/src/views/modules/communityService/dqfwzx/index.vue index 8173f6524..0ebe2dc7c 100644 --- a/src/views/modules/communityService/dqfwzx/index.vue +++ b/src/views/modules/communityService/dqfwzx/index.vue @@ -162,12 +162,9 @@ import { mapGetters } from "vuex"; import editForm from "./cpts/edit"; import orderForm from "./cpts/order"; import orderList from "./cpts/orderList"; +import daiMap from "@/utils/dai-map"; var map; -var search; -var markers; -var infoWindowList; -let loading; // 加载动画 export default { components: { editForm, orderForm, orderList }, @@ -207,49 +204,25 @@ export default { methods: { // 地图初始化函数,本例取名为init,开发者可根据实际情况定义 initMap() { - // 定义地图中心点坐标 - var center = new window.TMap.LatLng(36.0722275, 120.38945519); - // 定义map变量,调用 TMap.Map() 构造函数创建地图 - map = new window.TMap.Map(document.getElementById("centerIndexApp"), { - center: center, // 设置地图中心点坐标 - zoom: 17.2, // 设置地图缩放级别 - pitch: 43.5, // 设置俯仰角 - rotation: 45, // 设置地图旋转角度 - }); + let { latitude, longitude } = this.$store.state.user; - search = new window.TMap.service.Search({ pageSize: 10 }); - // 新建一个地点搜索类 - markers = new TMap.MultiMarker({ - map: map, - geometries: [], - }); - infoWindowList = Array(10); - }, - - setMarker(lat, lng, centerName) { - markers.setGeometries([]); - markers.add([ + map = new daiMap( + document.getElementById("centerIndexApp"), + { latitude, longitude }, { - id: "911", - styleId: "marker", - position: new TMap.LatLng(lat, lng), - properties: { - title: centerName, - }, - }, - ]); - }, - - setCenter(lat, lng) { - map.setCenter(new window.TMap.LatLng(lat, lng)); + zoom: 16.2, // 设置地图缩放级别 + pitch: 43.5, // 设置俯仰角 + rotation: 45, // 设置地图旋转角度 + } + ); }, setMap() { const { tableData, currentIndex } = this; let item = tableData[currentIndex]; if (item) { - this.setCenter(item.latitude, item.longitude); - this.setMarker(item.latitude, item.longitude, item.centerName); + map.setCenter(item.latitude, item.longitude); + map.setMarker(item.latitude, item.longitude, item.centerName); } }, diff --git a/src/views/modules/communityService/sqzzz/cpts/edit.vue b/src/views/modules/communityService/sqzzz/cpts/edit.vue index 01ba67f11..6fe29bdf3 100644 --- a/src/views/modules/communityService/sqzzz/cpts/edit.vue +++ b/src/views/modules/communityService/sqzzz/cpts/edit.vue @@ -1,246 +1,192 @@ @@ -251,6 +197,7 @@ import { Loading } from "element-ui"; // 引入Loading服务 import { requestPost } from "@/js/dai/request"; import formVltHelper from "dai-js/tools/formVltHelper"; import nextTick from "dai-js/tools/nextTick"; +import daiMap from "@/utils/dai-map"; var map; var search; @@ -262,10 +209,15 @@ var geocoder; // 新建一个正逆地址解析类 export default { components: {}, props: {}, - data() { + data () { return { formType: "add", //表单操作类型 add新增,edit编辑,detail详情 + searchOptions: [], + searchValue: '', + resultList: [], + loading: false, + btnDisable: false, orgId: "", @@ -288,7 +240,7 @@ export default { }; }, computed: { - dataRule() { + dataRule () { return { organizationName: [ { required: true, message: "组织名称 不能为空", trigger: "blur" }, @@ -323,25 +275,67 @@ export default { }, watch: {}, - async mounted() { + async mounted () { this.getCategoryList(); this.getVolunteerList(); - this.initMap(); + }, methods: { - querySearchVolunteer(queryString, cb) { + + async remoteMethod (query) { + + if (query !== '') { + this.loading = true; + + const { msg, data } = await map.searchNearby(query); + this.loading = false; + this.resultList = [] + + if (msg == "success" && data.resultList && data.resultList.length > 0) { + + if (data.resultList && data.resultList.length > 0) { + this.resultList = data.resultList + this.searchOptions = this.resultList.map(item => { + return { value: `${item.hotPointID}`, label: `${item.address + item.name}` }; + + }); + } + } else { + this.searchOptions = [ + { + value: '0', + label: '未检索到结果' + } + ] + } + } else { + this.searchOptions = []; + } + }, + + handleClickKey (index) { + let selPosition = this.resultList[index] + let lonlat = selPosition.lonlat.split(" ") + map.setCenter(lonlat[1], lonlat[0]); + map.setMarker(lonlat[1], lonlat[0]); + this.formData.latitude = lonlat[1]; + this.formData.longitude = lonlat[0]; + this.dataForm.address = selPosition.address + selPosition.name + }, + + querySearchVolunteer (queryString, cb) { const { volunteerList } = this; var results = queryString ? volunteerList.filter((item) => { - return item.value.indexOf(queryString) !== -1; - }) + return item.value.indexOf(queryString) !== -1; + }) : volunteerList; // 调用 callback 返回建议列表的数据 cb(results); }, - handleSelectVolunteer(index, vItem) { + handleSelectVolunteer (index, vItem) { this.dataForm.organizationPersonnel[index] = { personName: vItem.name, personPhone: vItem.mobile, @@ -349,7 +343,7 @@ export default { }; }, - async getVolunteerList() { + async getVolunteerList () { const url = "/epmetuser/icresiuser/volunteer-list"; const params = {}; const { data, code, msg } = await requestPost(url, params); @@ -367,7 +361,7 @@ export default { } }, - async getCategoryList() { + async getCategoryList () { const url = "/sys/dict/data/dictlist"; const params = { dictType: "self_org_category", @@ -379,131 +373,83 @@ export default { this.$message.error(msg); } }, - handleAddStaff() { + handleAddStaff () { this.dataForm.organizationPersonnel = [ ...this.dataForm.organizationPersonnel, { personName: "", personPhone: "", icResiUserId: "" }, ]; }, - handleDelStaff(index) { + handleDelStaff (index) { const { organizationPersonnel } = this.dataForm; organizationPersonnel.splice(index, 1); this.dataForm.organizationPersonnel = organizationPersonnel; }, - // 地图初始化函数,本例取名为init,开发者可根据实际情况定义 - initMap() { + + async initForm (type, row) { + this.$refs.ref_form.resetFields(); + + this.formType = type; + console.log(row); + let { latitude, longitude } = this.$store.state.user; - if (!latitude || latitude == "" || latitude == "0") { - latitude = 39.9088810666821; - longitude = 116.39743841556731; + if (row) { + this.dataForm = { ...this.dataForm, ...row }; + this.orgId = this.dataForm.orgId; + + } else { + this.dataForm.latitude = latitude + this.dataForm.longitude = longitude + } + if (!map) { + this.initMap(this.dataForm.latitude, this.dataForm.longitude); } - // 定义地图中心点坐标 - var center = new window.TMap.LatLng(latitude, longitude); - // 定义map变量,调用 TMap.Map() 构造函数创建地图 - map = new window.TMap.Map(document.getElementById("app"), { - center: center, // 设置地图中心点坐标 - zoom: 16.2, // 设置地图缩放级别 - pitch: 43.5, // 设置俯仰角 - rotation: 45, // 设置地图旋转角度 - }); - search = new window.TMap.service.Search({ pageSize: 10 }); - // 新建一个地点搜索类 - markers = new TMap.MultiMarker({ - map: map, - geometries: [], - }); - infoWindowList = Array(10); - geocoder = new TMap.service.Geocoder(); // 新建一个正逆地址解析类 + }, + + // 地图初始化函数,本例取名为init,开发者可根据实际情况定义 + initMap (latitude, longitude) { + + map = new daiMap( + document.getElementById("app"), + { latitude, longitude }, + { + zoom: 16.2, // 设置地图缩放级别 + pitch: 43.5, // 设置俯仰角 + rotation: 45, // 设置地图旋转角度 + } + ); // 监听地图平移结束 - map.on("panend", (e) => { + map.on("dragend", (e) => { this.handleMoveCenter(e); }); - // this.handleMoveCenter(); - }, - setMarker(lat, lng) { - markers.setGeometries([]); - markers.add([ - { - id: "4", - styleId: "marker", - position: new TMap.LatLng(lat, lng), - properties: { - title: "marker4", - }, - }, - ]); - }, + map.setCenter(latitude, longitude); + map.setMarker(latitude, longitude); - handleSearchMap() { - infoWindowList.forEach((infoWindow) => { - infoWindow.close(); - }); - infoWindowList.length = 0; - markers.setGeometries([]); - // 在地图显示范围内以给定的关键字搜索地点 - search - .searchNearby({ - keyword: this.dataForm.address, - radius: 1000, - autoExtend: true, - center: map.getCenter(), - }) - .then((result) => { - let { data } = result; - if (Array.isArray(data) && data.length > 0) { - const { - location: { lat, lng }, - } = data[0]; - map.setCenter(new TMap.LatLng(lat, lng)); - this.setMarker(lat, lng); - this.dataForm.latitude = lat; - this.dataForm.longitude = lng; - } else { - this.$message.error("未检索到相关位置坐标"); - } - }); }, - handleMoveCenter(e) { - console.log(e); + + async handleMoveCenter () { //修改地图中心点 - const center = map.getCenter(); - const lat = center.getLat(); - const lng = center.getLng(); + const { lat, lng } = map.getCenter(); this.dataForm.latitude = lat; this.dataForm.longitude = lng; - this.setMarker(lat, lng); + map.setMarker(lat, lng); + + let { msg, data } = await map.getAddress(lat, lng); + if (msg == "success") { + this.dataForm.address = data.address + this.searchValue = data.address + this.searchOptions = [] - if (e && e.originalEvent) { - geocoder - .getAddress({ location: new TMap.LatLng(lat, lng) }) // 将给定的坐标位置转换为地址 - .then((result) => { - this.dataForm.address = result.result.address; - }); } }, - async initForm(type, row) { - this.$refs.ref_form.resetFields(); - this.formType = type; - console.log(row); - if (row) { - this.dataForm = { ...this.dataForm, ...row }; - this.orgId = this.dataForm.orgId; - await nextTick(800); - if (map) { - map.setCenter(new TMap.LatLng(row.latitude, row.longitude)); - } - } - }, - - async handleComfirm() { + async handleComfirm () { this.btnDisable = true; setTimeout(() => { this.btnDisable = false; @@ -536,7 +482,7 @@ export default { }); }, - async submit() { + async submit () { let url = ""; if (this.formType === "add") { url = "/heart/iccommunityselforganization/addcommunityselforganization"; @@ -564,11 +510,16 @@ export default { } }, - handleCancle() { + handleCancle () { this.resetData(); this.$emit("dialogCancle"); }, - resetData() { + resetData () { + + this.searchValue = '' + this.searchOptions = [] + this.resultList = [] + this.orgId = ""; this.dataForm = { organizationName: "", @@ -585,8 +536,23 @@ export default { organizationPersonnel: [], }; }, + + // async handleSearchMap () { + // const { msg, data } = await map.searchNearby(this.keyWords); + // if (msg == "success") { + // const { lat, lng } = data; + // map.setCenter(lat, lng); + // map.setMarker(lat, lng); + // this.dataForm.latitude = lat; + // this.dataForm.longitude = lng; + // this.handleMoveCenter() + // } else { + // this.$message.error("未检索到相关位置坐标"); + // } + // }, + // 开启加载动画 - startLoading() { + startLoading () { loading = Loading.service({ lock: true, // 是否锁定 text: "正在加载……", // 加载中需要显示的文字 @@ -594,7 +560,7 @@ export default { }); }, // 结束加载动画 - endLoading() { + endLoading () { // clearTimeout(timer); if (loading) { loading.close(); diff --git a/src/views/modules/cpts/base/cpts/edit.vue b/src/views/modules/cpts/base/cpts/edit.vue index f3989e228..972d079d4 100644 --- a/src/views/modules/cpts/base/cpts/edit.vue +++ b/src/views/modules/cpts/base/cpts/edit.vue @@ -331,12 +331,9 @@ import { requestPost } from "@/js/dai/request"; import nextTick from "dai-js/tools/nextTick"; import Schema from "async-validator"; import Tinymce from "@c/tinymce2/index.vue"; +import daiMap from "@/utils/dai-map"; var map; -var search; -var markers; -var infoWindowList; -var geocoder; // 新建一个正逆地址解析类 export default { components: { Tinymce }, @@ -626,101 +623,49 @@ export default { // 地图初始化函数,本例取名为init,开发者可根据实际情况定义 initMap(item) { let { latitude, longitude } = this.$store.state.user; - if (!latitude || latitude == "" || latitude == "0") { - latitude = 39.9088810666821; - longitude = 116.39743841556731; - } - // 定义地图中心点坐标 - var center = new window.TMap.LatLng(latitude, longitude); - // 定义map变量,调用 TMap.Map() 构造函数创建地图 - map = new window.TMap.Map(document.getElementById("app"), { - center: center, // 设置地图中心点坐标 - zoom: 16.2, // 设置地图缩放级别 - pitch: 43.5, // 设置俯仰角 - rotation: 45, // 设置地图旋转角度 - }); - search = new window.TMap.service.Search({ pageSize: 10 }); - // 新建一个地点搜索类 - markers = new TMap.MultiMarker({ - map: map, - geometries: [], - }); - infoWindowList = Array(10); - - geocoder = new TMap.service.Geocoder(); // 新建一个正逆地址解析类 + map = new daiMap( + document.getElementById("app"), + { latitude, longitude }, + { + zoom: 16.2, // 设置地图缩放级别 + pitch: 43.5, // 设置俯仰角 + rotation: 45, // 设置地图旋转角度 + } + ); // 监听地图平移结束 - map.on("panend", (e) => { + map.on("dragend", (e) => { this.handleMoveCenter(item, e); }); // this.handleMoveCenter(item); }, - setMarker(lat, lng) { - markers.setGeometries([]); - markers.add([ - { - id: "4", - styleId: "marker", - position: new TMap.LatLng(lat, lng), - properties: { - title: "marker4", - }, - }, - ]); - }, - - handleSearchMap(item) { - infoWindowList.forEach((infoWindow) => { - infoWindow.close(); - }); - infoWindowList.length = 0; - markers.setGeometries([]); - // 在地图显示范围内以给定的关键字搜索地点 - search - .searchNearby({ - keyword: this.fmData[item.keyName], - radius: 1000, - autoExtend: true, - center: map.getCenter(), - }) - .then((result) => { - let { data } = result; - if (Array.isArray(data) && data.length > 0) { - const { - location: { lat, lng }, - } = data[0]; - map.setCenter(new TMap.LatLng(lat, lng)); - this.setMarker(lat, lng); - // item.supValues[0] = lng; - // item.supValues[1] = lat; - this.fmData[item.supKeys[0]] = lng; - this.fmData[item.supKeys[1]] = lat; - } else { - this.$message.error("未检索到相关位置坐标"); - } - }); + async handleSearchMap(item) { + const { msg, data } = await map.searchNearby(this.fmData[item.keyName]); + if (msg == "success") { + const { lat, lng } = data; + map.setCenter(lat, lng); + map.setMarker(lat, lng); + this.fmData[item.supKeys[0]] = lng; + this.fmData[item.supKeys[1]] = lat; + } else { + this.$message.error("未检索到相关位置坐标"); + } }, - handleMoveCenter(item, e) { - console.log(e); + async handleMoveCenter(item, e) { + console.log("handleMoveCenter", e); //修改地图中心点 - const center = map.getCenter(); - const lat = center.getLat(); - const lng = center.getLng(); - // item.supValues[0] = lng; - // item.supValues[1] = lat; + const { lat, lng } = map.getCenter(); + this.fmData[item.supKeys[0]] = lng; this.fmData[item.supKeys[1]] = lat; - this.setMarker(lat, lng); + map.setMarker(lat, lng); - if (e && e.originalEvent) { - geocoder - .getAddress({ location: new TMap.LatLng(lat, lng) }) // 将给定的坐标位置转换为地址 - .then((result) => { - this.fmData[item.keyName] = result.result.address; - }); + let { msg, data } = await map.getAddress(lat, lng); + if (msg == "success") { + this.fmData[item.keyName] = data.address; } }, @@ -752,7 +697,8 @@ export default { await nextTick(600); if (map) { if (data.latitude) { - map.setCenter(new TMap.LatLng(data.latitude, data.longitude)); + map.setCenter(data.latitude, data.longitude); + map.setMarker(data.latitude, data.longitude); } else { if (this.formType == "edit" && this.$refs && this.$refs.mapSearch) { this.$refs.mapSearch[0].handleClick(); diff --git a/src/views/modules/shequzhili/csgltc/csgl.vue b/src/views/modules/shequzhili/csgltc/csgl.vue index 8eacbd0ed..e29f1c93a 100644 --- a/src/views/modules/shequzhili/csgltc/csgl.vue +++ b/src/views/modules/shequzhili/csgltc/csgl.vue @@ -52,7 +52,8 @@ style="margin-left:10px" size="small" @click="handleExportModule('room')">下载模板 -
- 地理位置: + 所在位置: {{ formData.address }}
@@ -41,7 +41,7 @@ 地图位置:
-
+
@@ -61,6 +61,7 @@ - +