Commit b0331d21 authored by 吕超's avatar 吕超

feat: 新增省范围的获取方法

parent 9d7ad0a5
...@@ -7,10 +7,17 @@ ...@@ -7,10 +7,17 @@
</template> </template>
<script> <script>
import { mapActions } from "vuex";
export default { export default {
data() { data() {
return {}; return {};
}, },
created() {
this.getRegionProvince();
},
methods: {
...mapActions(["getRegionProvince"]),
},
}; };
</script> </script>
......
import Vue from "vue"; import Vue from "vue";
import Vuex from "vuex"; import Vuex from "vuex";
import energyVillage from "./module/energyVillage";
import { query } from "@/api/modules/layer.js";
Vue.use(Vuex); Vue.use(Vuex);
export default new Vuex.Store({ export default new Vuex.Store({
state: {}, state: {
mutations: {}, province: [],
actions: {}, },
modules: {}, mutations: {
GET_REGION_PROVINCE(state, data) {
state.province = data;
},
},
actions: {
getRegionProvince({ commit }) {
query("land_region_province").then((res) => {
commit("GET_REGION_PROVINCE", res.data.features);
});
},
},
getters: {
getMsgOfProvince: (state) => (code) => {
const detail = state.province.find(
(item) => item.properties.PXZQDM === code
);
if (!detail) return null;
const { PXZQDM, PXZQMC, x_max, x_min, y_max, y_min } = detail.properties;
const res = {
key: PXZQDM,
value: PXZQMC,
bbox: [
[x_min, y_min],
[x_max, y_max],
],
};
return res;
},
},
modules: {
energyVillage,
},
}); });
export default {
namespaced: true,
state: {
data: 1,
},
mutations: {},
actions: {},
getters: {},
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment