调整:代码修改

This commit is contained in:
fan 2019-08-12 13:40:34 +08:00
parent 9623c98994
commit 0b5cfcc9a7
5 changed files with 114 additions and 69 deletions

View File

@ -28,6 +28,6 @@ export default class TrainBodyBox extends Group {
this.add(this.trainBodyBox); this.add(this.trainBodyBox);
} }
setColor(key, color) { setColor(key, color) {
this.train.setStyle(key, color); this.trainBodyBox.setStyle(key, color);
} }
} }

View File

@ -75,42 +75,39 @@ export default {
}, },
initMenu() { initMenu() {
this.menuNormal = []; this.menuNormal = [];
let resultCode = this.$route.path.indexOf("/display"); // this.stationList.forEach(station => {
if(resultCode === -1){ // if (station.code === station.concentrateStationCode) {
this.stationList.forEach(station => { // let node = {
if (station.code === station.concentrateStationCode) { // label: station.name,
let node = { // children: []
label: station.name, // }
children: [] //
} // this.stationList.forEach(elem => {
// if (elem.visible) {
this.stationList.forEach(elem => { // let next = elem;
if (elem.visible) { // while (next.code != next.concentrateStationCode || !next.concentrateStationCode) {
let next = elem; // next = this.$store.getters['map/getDeviceByCode'](next.concentrateStationCode);
while (next.code != next.concentrateStationCode || !next.concentrateStationCode) { // }
next = this.$store.getters['map/getDeviceByCode'](next.concentrateStationCode); //
} // if (station.code == next.code) {
// node.children.push({
if (station.code == next.code) { // code: elem.code,
node.children.push({ // label: elem.name,
code: elem.code, // handler: this.mapLocation,
label: elem.name, // });
handler: this.mapLocation, // }
}); // }
} // })
} //
}) // this.menuNormal.push(node);
// }
this.menuNormal.push(node); // });
}
});
}
if (this.isScreen) { if (this.isScreen) {
this.menu = [...this.menuScreen]; this.menu = [...this.menuScreen];
} }
else { // else {
this.menu = [...this.menuNormal]; // this.menu = [...this.menuNormal];
} // }
}, },
doShow(point) { doShow(point) {
this.clickEvent(); this.clickEvent();

View File

@ -77,40 +77,40 @@ export default {
}, },
initMenu() { initMenu() {
this.menuNormal = []; this.menuNormal = [];
this.stationList.forEach(station => { // this.stationList.forEach(station => {
if (station.code === station.concentrateStationCode) { // if (station.code === station.concentrateStationCode) {
let node = { // let node = {
label: station.name, // label: station.name,
children: [] // children: []
} // }
//
this.stationList.forEach(elem => { // this.stationList.forEach(elem => {
if (elem.visible) { // if (elem.visible) {
let next = elem; // let next = elem;
while (next.code != next.concentrateStationCode || !next.concentrateStationCode) { // while (next.code != next.concentrateStationCode || !next.concentrateStationCode) {
next = this.$store.getters['map/getDeviceByCode'](next.concentrateStationCode); // next = this.$store.getters['map/getDeviceByCode'](next.concentrateStationCode);
} // }
//
if (station.code == next.code) { // if (station.code == next.code) {
node.children.push({ // node.children.push({
code: elem.code, // code: elem.code,
label: elem.name, // label: elem.name,
handler: this.mapLocation, // handler: this.mapLocation,
}); // });
} // }
} // }
}) // })
//
this.menuNormal.push(node); // this.menuNormal.push(node);
} // }
}); // });
if (this.isScreen) { if (this.isScreen) {
this.menu = [...this.menuScreen]; this.menu = [...this.menuScreen];
} }
else { // else {
this.menu = [...this.menuNormal]; // this.menu = [...this.menuNormal];
} // }
}, },
doShow(point) { doShow(point) {
this.clickEvent(); this.clickEvent();

View File

@ -243,7 +243,6 @@ export default {
x: em.clientX, x: em.clientX,
y: em.clientY y: em.clientY
}; };
var menu = getDeviceMenuByDeviceType('Cancel'); var menu = getDeviceMenuByDeviceType('Cancel');
this.$store.dispatch('menuOperation/setPopMenu', { position: this.point, menu: menu }); this.$store.dispatch('menuOperation/setPopMenu', { position: this.point, menu: menu });

View File

@ -16,6 +16,7 @@ import PopMenu from '@/components/PopMenu';
import MapEdit from './edit'; import MapEdit from './edit';
import MapSaveAs from './saveAs'; import MapSaveAs from './saveAs';
import MapPublish from './publish'; import MapPublish from './publish';
import { mapGetters } from 'vuex';
export default { export default {
name: 'MapOperateMenu', name: 'MapOperateMenu',
@ -42,7 +43,7 @@ export default {
data() { data() {
return { return {
menuShow: false, menuShow: false,
menu: [ menuMap: [
{ {
label: this.$t('map.updateObj'), label: this.$t('map.updateObj'),
handler: this.updateObj handler: this.updateObj
@ -87,14 +88,25 @@ export default {
label: this.$t('map.jlmap3d'), label: this.$t('map.jlmap3d'),
handler: this.jlmap3d handler: this.jlmap3d
} }
] ],
menuNormal:[],
menu: []
}; };
}, },
computed: {
...mapGetters('map', [
'stationList'
]),
},
watch: { watch: {
'$store.state.menuOperation.menuCount': function (val) { '$store.state.menuOperation.menuCount': function (val) {
if (this.$store.getters['menuOperation/checkDialogIsOpen'](DeviceMenu.Map)) { if (this.$store.getters['menuOperation/checkDialogIsOpen'](DeviceMenu.Map)) {
this.menu = [ ...this.menuMap]
this.doShow(this.$store.state.menuOperation.menuPosition); this.doShow(this.$store.state.menuOperation.menuPosition);
} else { } else if(this.$store.getters['menuOperation/checkDialogIsOpen'](DeviceMenu.Cancel)){
this.initCancelMenu();
this.doShow(this.$store.state.menuOperation.menuPosition);
}else {
this.doClose(); this.doClose();
} }
} }
@ -187,7 +199,44 @@ export default {
}, },
refresh() { refresh() {
this.$emit('refresh'); this.$emit('refresh');
},
initCancelMenu() {
this.menuNormal = [];
this.stationList.forEach(station => {
if (station.code === station.concentrateStationCode) {
let node = {
label: station.name,
children: []
};
this.stationList.forEach(elem => {
if (elem.visible) {
let next = elem;
while (next.code != next.concentrateStationCode || !next.concentrateStationCode) {
next = this.$store.getters['map/getDeviceByCode'](next.concentrateStationCode);
} }
if (station.code == next.code) {
node.children.push({
code: elem.code,
label: elem.name,
handler: this.mapLocation,
});
}
}
});
this.menuNormal.push(node);
}
});
this.menu = [ ...this.menuNormal ]
},
mapLocation(item) {
if (item) {
this.$store.dispatch('training/updateOffsetStationCode', { offsetStationCode: item.code });
this.doClose();
}
},
} }
}; };
</script> </script>