Commit 3aeddf2c by 张杰

修复围栏bug

1 parent e5d57ecd
...@@ -155,4 +155,9 @@ export const GET_DEVICE_LOCATION = params => { ...@@ -155,4 +155,9 @@ export const GET_DEVICE_LOCATION = params => {
// 批量查询设备在线状态 // 批量查询设备在线状态
export const GET_MONITOR_ONLINELIST = params => { export const GET_MONITOR_ONLINELIST = params => {
return request(params, '/devicemonitor/monitor/onlinelist', 'get') return request(params, '/devicemonitor/monitor/onlinelist', 'get')
}
// 获取高德地图的省市区
export const GET_AMAP_PROVINCE = params => {
return request(params, 'https://restapi.amap.com/v3/config/district', 'get')
} }
\ No newline at end of file \ No newline at end of file
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
</template> </template>
<script> <script>
import cityJson from "@/assets/json/city.json"; import cityJson from "@/assets/json/city.json";
import { CONSTANT } from "@/constant";
// import axios from "axios";
// import store from "@/vuex/store";
export default { export default {
name: "CitySelect", name: "CitySelect",
props: { props: {
...@@ -41,6 +44,14 @@ export default { ...@@ -41,6 +44,14 @@ export default {
// immediate: true, // immediate: true,
// }, // },
}, },
created() {
// 查询
// console.log(store);
// let list = store.state.common.provinceList;
// if (!list || list.length <= 0) {
// this.getList();
// }
},
mounted() { mounted() {
//this.city = this.value; //this.city = this.value;
this.init(); this.init();
...@@ -49,18 +60,18 @@ export default { ...@@ -49,18 +60,18 @@ export default {
onChange(e) { onChange(e) {
console.log(e); console.log(e);
let list = this.cityList; let list = this.cityList;
let nameList = [] let nameList = [];
let m = list.find((k) => k.code == e[0]); let m = list.find((k) => k.code == e[0]);
console.log(m) console.log(m);
nameList.push(m.name) nameList.push(m.name);
let n = m.children.find((k) => k.code == e[1]); let n = m.children.find((k) => k.code == e[1]);
let b = (n && n.children || []).find((k) => k.code == e[2]); let b = ((n && n.children) || []).find((k) => k.code == e[2]);
if (n) { if (n) {
this.$emit("input", n.name); this.$emit("input", n.name);
nameList.push(n.name) nameList.push(n.name);
} }
if(b){ if (b) {
nameList.push(b.name) nameList.push(b.name);
} }
this.$emit("change", { code: e, name: nameList }); this.$emit("change", { code: e, name: nameList });
}, },
...@@ -131,6 +142,26 @@ export default { ...@@ -131,6 +142,26 @@ export default {
}); });
return afterArray; return afterArray;
}, },
// 查询高德地图的省市区
getList() {
let oParams = {};
oParams.key = CONSTANT.MAP_SERVICE_KEY;
oParams.subdistrict = 3;
oParams.keywords = "中国";
axios({
url: "https://restapi.amap.com/v3/config/district",
params: oParams,
}).then((res) => {
console.log(res);
let obj = res.data;
let { districts } = obj;
let list = districts[0] ? districts[0].districts : [];
console.log(list);
this.cityList = list;
store.commit('SET_AMAP_PROVINCE',list)
});
},
}, },
}; };
</script> </script>
......
export const MAP_KEY = '75116f653f3b2e4568116dad8cd9b899' export const MAP_KEY = '75116f653f3b2e4568116dad8cd9b899'
export const MAP_SERVICE_KEY = 'd22348363c34c266f772ae9b635eef2a'
// 地图插件 // 地图插件
export const MAP_PLUGINS = [ export const MAP_PLUGINS = [
...@@ -19,6 +20,7 @@ export const CONSTANT = { ...@@ -19,6 +20,7 @@ export const CONSTANT = {
//ROOT: process.env.NODE_ENV === 'development'?'ots/':'', //ROOT: process.env.NODE_ENV === 'development'?'ots/':'',
API_URL: '/ots/', API_URL: '/ots/',
MAP_KEY, MAP_KEY,
MAP_SERVICE_KEY,
MAP_PLUGINS, MAP_PLUGINS,
AMAP_URL: `https://webapi.amap.com/maps?v=1.4.2&key=${MAP_KEY}&plugin=${MAP_PLUGINS.toString()}` AMAP_URL: `https://webapi.amap.com/maps?v=1.4.2&key=${MAP_KEY}&plugin=${MAP_PLUGINS.toString()}`
} }
\ No newline at end of file \ No newline at end of file
...@@ -228,6 +228,11 @@ export default { ...@@ -228,6 +228,11 @@ export default {
}); });
} else { } else {
this.drawFenceCircle(mapService.getLngLat(this.lng, this.lat)); this.drawFenceCircle(mapService.getLngLat(this.lng, this.lat));
this.$emit("onUpdateMapData", {
lng: this.lng,
lat: this.lat,
radius: this.radius,
});
} }
}, },
drawFenceCircle(fenceCenter) { drawFenceCircle(fenceCenter) {
......
...@@ -21,6 +21,7 @@ const state = { ...@@ -21,6 +21,7 @@ const state = {
zlAccount: false, zlAccount: false,
permission: [], permission: [],
vehicleGenerate: false, vehicleGenerate: false,
provinceList:[], // 高德地图的省市区
} }
const mutations = { const mutations = {
...@@ -84,6 +85,12 @@ const mutations = { ...@@ -84,6 +85,12 @@ const mutations = {
[types.vehicleGenerate](state, data) { [types.vehicleGenerate](state, data) {
state.vehicleGenerate = data state.vehicleGenerate = data
}, },
// 高德地图的省市区
SET_AMAP_PROVINCE(state,data){
state.provinceList = data
}
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!