Browse Source

地图scale缩放还原

feature
SongZhen 2 years ago
parent
commit
713973449d
  1. 4
      src/App.vue
  2. 35
      src/js/store/modules/chooseArea.js
  3. 1
      src/views/components/fixed1920.vue
  4. 14
      src/views/dataBoard/organizational/dangTree/index.vue
  5. 1498
      yarn.lock

4
src/App.vue

@ -42,7 +42,7 @@ export default {
}, },
computed: {}, computed: {},
mounted() { mounted() {
console.log("开始::::" + localStorage.getItem("userType")); // console.log("" + localStorage.getItem("userType"));
if (!localStorage.getItem("userType")) { if (!localStorage.getItem("userType")) {
localStorage.setItem("userType", "oper"); localStorage.setItem("userType", "oper");
} }
@ -64,7 +64,7 @@ export default {
// eslint-disable-next-line // eslint-disable-next-line
// debugger // debugger
that.setEnv(env); that.setEnv(env);
console.log("屏幕宽度:" + document.documentElement.clientWidth); // console.log(":" + document.documentElement.clientWidth);
// size // size
if (document.documentElement.clientHeight < 800) { if (document.documentElement.clientHeight < 800) {
// medium // medium

35
src/js/store/modules/chooseArea.js

@ -1,25 +1,32 @@
const state = { const state = {
chooseName: { chooseName: {
orgId: '', orgId: "",
level: '', level: "",
}, },
realScale: null,
}; };
const mutations = { const mutations = {
CHOOSE_NAME: (state, name) => { CHOOSE_NAME: (state, name) => {
state.chooseName = name; state.chooseName = name;
}, },
CHOOSE_REAL_SCALE: (state, name) => {
state.realScale = name;
},
}; };
const actions = { const actions = {
chooseName({commit}, name) { chooseName({ commit }, name) {
commit("CHOOSE_NAME", name); commit("CHOOSE_NAME", name);
}, },
chooseScale({ commit }, name) {
commit("CHOOSE_REAL_SCALE", name);
},
}; };
export default { export default {
namespaced: true, namespaced: true,
state, state,
mutations, mutations,
actions, actions,
}; };

1
src/views/components/fixed1920.vue

@ -24,6 +24,7 @@ export default {
const top = (clientHeight - height) / 2; const top = (clientHeight - height) / 2;
const left = (clientWidth - 1920) / 2; const left = (clientWidth - 1920) / 2;
this.$store.state.fixed1920.height = height; this.$store.state.fixed1920.height = height;
this.$store.dispatch("chooseArea/chooseScale", scale);
return { return {
transform: `scale(${scale})`, transform: `scale(${scale})`,
height: `${height}px`, height: `${height}px`,

14
src/views/dataBoard/organizational/dangTree/index.vue

@ -28,6 +28,7 @@ export default {
levelArr: [], levelArr: [],
nowVal: 100, nowVal: 100,
nodeConfig: {}, nodeConfig: {},
zoom: 0,
}; };
}, },
watch: { watch: {
@ -38,15 +39,28 @@ export default {
this.getTreeData(); this.getTreeData();
} }
}, },
"$store.state.chooseArea.realScale"(n, v) {
this.setStartScale(n);
},
}, },
computed: {}, computed: {},
mounted() { mounted() {
const orgId = this.$store.state.chooseArea.chooseName.orgId; const orgId = this.$store.state.chooseArea.chooseName.orgId;
const scale = this.$store.state.chooseArea.realScale;
if (scale) {
this.setStartScale(scale);
}
if (orgId) { if (orgId) {
this.getTreeData(); this.getTreeData();
} }
this.getTextMap();
}, },
methods: { methods: {
setStartScale(n) {
const scale = 1 / n;
this.zoom = scale;
},
getLevelArrNum(myArray) { getLevelArrNum(myArray) {
const arr = [...myArray]; const arr = [...myArray];
while (arr.length > 1) { while (arr.length > 1) {

1498
yarn.lock

File diff suppressed because it is too large
Loading…
Cancel
Save