rt-sim-training-client/src/views/newMap/displayNew/selectStation.vue

135 lines
5.6 KiB
Vue
Raw Normal View History

2020-08-20 20:27:19 +08:00
<template>
2021-09-14 17:10:00 +08:00
<span>
<el-select v-if="$store.state.training.prdType === '01'" v-model="oldShowMemberId" :style="styleCss" size="small" @change="switchStationMode">
<el-option v-for="item in stationListMode" :key="item.value" :label="item.name" :value="item.value" />
</el-select>
<el-select v-else-if="$store.state.training.prdType === '09'" v-model="oldShowMemberId" :style="styleCss" size="small" style="margin-right:20px;" @change="switchStationMode">
2021-09-14 17:10:00 +08:00
<el-option v-for="item in depotListMode" :key="item.value" :label="item.name" :value="item.value" />
</el-select>
</span>
2020-08-20 20:27:19 +08:00
</template>
<script>
import { mapGetters } from 'vuex';
import { assignUsersPlayRoles } from '@/api/jointSimulation';
2021-01-25 15:46:18 +08:00
import { EventBus } from '@/scripts/event-bus';
2020-08-20 20:27:19 +08:00
export default {
name:'SelectStation',
props:{
styleCss: {
type: String,
required: true
}
},
data() {
return {
stationListMode: [], // 设备集中站列表
2021-09-14 17:10:00 +08:00
depotListMode: [],
showMemberId: '', // 展示的值班站memberId
oldShowMemberId: '',
stationCentralizedMap: {},
showStation: ''
2020-08-20 20:27:19 +08:00
};
},
computed:{
...mapGetters('map', [
'map',
'stationList'
])
},
watch:{
'$store.state.training.memberData': function (val) {
this.initStationListMode();
2020-08-20 20:27:19 +08:00
},
'$store.state.training.simulationUserList': function(val) {
this.initData();
}
},
mounted() {
this.initStationListMode();
this.initData();
EventBus.$on('switchStationMode', (stationCode) => {
this.$store.state.training.memberList.filter(el => el.type == 'STATION_SUPERVISOR').find(el => {
if (el.deviceCode == stationCode) {
this.oldShowMemberId = el.id;
this.switchStationMode(el.id);
2020-08-20 20:27:19 +08:00
}
});
});
},
2020-08-20 20:27:19 +08:00
methods:{
switchStationMode(val) {
assignUsersPlayRoles([{ userId: this.$store.state.user.id, memberId: val}], this.$route.query.group).then(resp => {
this.showMemberId = val;
const member = this.$store.state.training.memberData[val];
const station = this.$store.getters['map/getDeviceByCode'](member.deviceCode);
2021-07-15 10:50:29 +08:00
if (station) {
this.showStation = station.code;
const showStationCode = this.stationCentralizedMap[station.code];
const mapDevice = this.$store.state.map.mapDevice;
const list = [];
for (const key in mapDevice) {
list.push(mapDevice[key]);
}
this.$store.dispatch('training/setRoleDeviceCode', station.code);
2021-09-14 17:10:00 +08:00
this.$jlmap.updateShowStation(list, showStationCode || station.code);
this.setCenter(showStationCode);
}
}).catch((err) => {
console.log(err);
this.showMemberId = this.oldShowMemberId;
this.$message.error('调整角色成员失败!');
});
2020-08-20 20:27:19 +08:00
},
setCenter(code) {
2021-10-11 16:41:56 +08:00
if (this.$store.state.training.prdType === '09' && this.$store.state.map.map.displayList && this.$store.state.map.map.displayList.length) {
2021-10-14 18:05:24 +08:00
const tempData = this.$store.state.map.map.displayList.find(item => { return item.stationCodeList.includes(code) && item.type === 'DEPOT_IL'; });
2021-10-11 16:41:56 +08:00
const dataZoom = { offsetX: tempData.offsetX, offsetY: tempData.offsetY, scaleRate: tempData.scaleRate };
this.$store.commit('map/setDataZoom', dataZoom);
this.$jlmap.setDepot(dataZoom);
} else {
this.$jlmap.setCenter(code);
}
},
initStationListMode() {
this.stationListMode = [];
this.$store.state.training.memberList.forEach(item => {
if (item.type === 'STATION_SUPERVISOR') {
const station = this.$store.getters['map/getDeviceByCode'](item.deviceCode);
if (station) {
this.stationListMode.push({value:item.id, name: station.name});
}
2021-09-14 17:10:00 +08:00
} else if (item.type === 'DEPOT_DISPATCHER') {
const station = this.$store.getters['map/getDeviceByCode'](item.deviceCode);
if (station) {
this.depotListMode.push({value:item.id, name: station.name});
}
}
});
},
initData() {
this.$store.state.training.simulationUserList.forEach(item => {
if (item.type === 'STATION_SUPERVISOR' && item.userId == this.$store.state.user.id) {
this.showMemberId = item.memberId;
this.oldShowMemberId = item.memberId;
2021-09-14 17:10:00 +08:00
} else if (item.type === 'DEPOT_DISPATCHER' && item.userId == this.$store.state.user.id) {
this.showMemberId = item.memberId;
this.oldShowMemberId = item.memberId;
}
});
this.stationList.forEach(item => {
if (item.centralized) {
this.stationCentralizedMap[item.code] = item.code;
item.chargeStationCodeList.forEach(ele => {
this.stationCentralizedMap[ele] = item.code;
});
}
});
if (this.showMemberId) {
this.switchStationMode( this.showMemberId);
}
2020-08-20 20:27:19 +08:00
}
}
};
</script>