2019-07-26 13:32:43 +08:00
|
|
|
<template>
|
2019-11-08 09:02:18 +08:00
|
|
|
<div class="room">
|
|
|
|
<div class="room__head">
|
|
|
|
<div class="room__head--title">
|
|
|
|
{{ $t('trainRoom.comprehensiveDrillRoom') }}
|
2019-10-18 17:15:04 +08:00
|
|
|
</div>
|
2019-11-08 09:02:18 +08:00
|
|
|
<div class="room__head--notes">
|
2019-11-08 18:15:52 +08:00
|
|
|
{{ $t('trainRoom.comprehensiveTrainingManager') + room.creator.nickName }}
|
2019-10-18 17:15:04 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-11-08 09:02:18 +08:00
|
|
|
<div class="room__container">
|
2019-11-08 18:15:52 +08:00
|
|
|
<e-members
|
|
|
|
class="room__container--members"
|
|
|
|
:room="room"
|
|
|
|
:members="members"
|
|
|
|
:height="height"
|
|
|
|
@message="messageInfo"
|
|
|
|
/>
|
|
|
|
<e-roles
|
|
|
|
class="room__container--roles"
|
|
|
|
:room="room"
|
|
|
|
:members="members"
|
|
|
|
:height="height"
|
|
|
|
:station-list="stationList"
|
|
|
|
:stand-list="standList"
|
|
|
|
:door-list="doorList"
|
|
|
|
@message="messageInfo"
|
|
|
|
@joinTraining="jumpInSimulation"
|
|
|
|
/>
|
|
|
|
<e-chat
|
|
|
|
class="room__container--chat"
|
|
|
|
:room="room"
|
|
|
|
:members="members"
|
|
|
|
:height="height"
|
|
|
|
@message="messageInfo"
|
|
|
|
/>
|
2019-07-26 13:32:43 +08:00
|
|
|
</div>
|
2019-11-08 09:02:18 +08:00
|
|
|
<div class="room__footer" />
|
2019-10-18 17:15:04 +08:00
|
|
|
</div>
|
2019-07-26 13:32:43 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-11-08 09:02:18 +08:00
|
|
|
import eMembers from './e-members';
|
|
|
|
import eChat from './e-chat';
|
|
|
|
import eRoles from './e-roles';
|
2019-11-08 18:15:52 +08:00
|
|
|
import { postRoomDetail, getJointTrainRoomUserList, getRealDevices, putJointTrainingSimulationEntrance } from '@/api/chat';
|
|
|
|
import { getPublishMapInfo, hasDoorStationList } from '@/api/jmap/map';
|
|
|
|
import { launchFullscreen } from '@/utils/screen';
|
2019-10-18 17:15:04 +08:00
|
|
|
import { getStationList } from '@/api/runplan';
|
2019-11-08 18:15:52 +08:00
|
|
|
import { checkLoginLine } from '@/api/login';
|
2019-07-26 13:32:43 +08:00
|
|
|
|
2019-10-18 17:15:04 +08:00
|
|
|
export default {
|
2019-10-30 19:36:26 +08:00
|
|
|
components: {
|
2019-11-08 09:02:18 +08:00
|
|
|
eMembers,
|
|
|
|
eChat,
|
|
|
|
eRoles
|
2019-10-30 19:36:26 +08:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2019-11-08 09:02:18 +08:00
|
|
|
room: {
|
2019-11-08 18:15:52 +08:00
|
|
|
totalNum: 0,
|
2019-10-30 19:36:26 +08:00
|
|
|
group: '',
|
2019-11-08 09:02:18 +08:00
|
|
|
mapId: '',
|
2019-11-08 18:15:52 +08:00
|
|
|
creatorId: '',
|
|
|
|
creator: {
|
|
|
|
nickName: ''
|
2019-11-08 09:02:18 +08:00
|
|
|
},
|
2019-11-08 18:15:52 +08:00
|
|
|
permissionRest: 0,
|
|
|
|
permissionNum: 0,
|
|
|
|
state: ''
|
|
|
|
},
|
|
|
|
userMap: [],
|
|
|
|
members: [],
|
|
|
|
stationList: [],
|
|
|
|
standList: [],
|
|
|
|
doorList: []
|
2019-10-30 19:36:26 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
height() {
|
2019-11-08 09:02:18 +08:00
|
|
|
return this.$store.state.app.height - 100;
|
2019-10-30 19:36:26 +08:00
|
|
|
},
|
2019-11-08 18:15:52 +08:00
|
|
|
group() {
|
|
|
|
return this.$route.query.group;
|
|
|
|
},
|
2019-11-08 09:02:18 +08:00
|
|
|
userId() {
|
2019-11-08 18:15:52 +08:00
|
|
|
return this.$store.state.user ? this.$store.state.user.id : '';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
members: {
|
|
|
|
deep: true,
|
|
|
|
handler() {
|
|
|
|
this.room.permissionRest = this.members.filter(elem => ['Audience'].includes(elem.userRole)).length;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 用户信息
|
|
|
|
'$store.state.socket.roleList': async function (val) {
|
|
|
|
if (val.length) {
|
|
|
|
await this.dispatchUsers(val);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 房间消息
|
|
|
|
'$store.state.socket.jointRoomInfo': async function (val) {
|
|
|
|
if (val.creatorId) {
|
|
|
|
await this.dispatchRoomInfo(val);
|
2019-10-30 19:36:26 +08:00
|
|
|
}
|
2019-11-08 18:15:52 +08:00
|
|
|
},
|
|
|
|
// 设备信息
|
|
|
|
'$store.state.socket.realDeviceInfo': async function (val) {
|
|
|
|
await this.getStandList();
|
2019-10-30 19:36:26 +08:00
|
|
|
}
|
|
|
|
},
|
2019-11-08 18:15:52 +08:00
|
|
|
async created() {
|
|
|
|
await this.getRoomInfo();
|
|
|
|
await this.getUserList();
|
|
|
|
await this.getStandList();
|
|
|
|
await this.getStaionList(this.room.mapId);
|
|
|
|
await this.getDoorList(this.room.mapId, this.stationList);
|
|
|
|
this.timeDemon = setInterval(() => {
|
|
|
|
checkLoginLine();
|
|
|
|
}, 5000 * 60);
|
2019-10-30 19:36:26 +08:00
|
|
|
},
|
|
|
|
methods: {
|
2019-11-08 18:15:52 +08:00
|
|
|
async getRoomInfo() {
|
|
|
|
const resp = await postRoomDetail(this.group);
|
2019-11-08 09:02:18 +08:00
|
|
|
this.room = {
|
2019-11-08 18:15:52 +08:00
|
|
|
permissionRest: 0,
|
|
|
|
totalNum: Number(resp.data.permissionNum) + Number(resp.data.audiencePermissionNum),
|
|
|
|
...resp.data || {}
|
2019-10-30 19:36:26 +08:00
|
|
|
};
|
2019-11-08 18:15:52 +08:00
|
|
|
},
|
|
|
|
async getStandList() {
|
|
|
|
const resp = await getRealDevices(this.group);
|
|
|
|
this.standList = resp.data || [];
|
|
|
|
},
|
|
|
|
async getStaionList(mapId) {
|
|
|
|
const resp = await getStationList(mapId);
|
|
|
|
this.stationList = resp.data || [];
|
|
|
|
},
|
|
|
|
async getDoorList(mapId, stationList) {
|
|
|
|
const doorList = [];
|
|
|
|
hasDoorStationList(mapId).then(res =>{
|
|
|
|
stationList.forEach(item => {
|
|
|
|
res.data.forEach(it =>{
|
|
|
|
if (item.code === it.stationCode) {
|
|
|
|
const direction = parseInt(it.doorLocationType) % 2 === 0 ? this.$t('trainRoom.uplinkPlatform') : this.$t('trainRoom.downlinkPlatform');
|
|
|
|
doorList.push({code: it.code, name: item.name + direction});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.doorList = doorList;
|
|
|
|
}).catch(() => {
|
|
|
|
this.$messageBox(this.$t('error.getScreenDoorsListFailed'));
|
|
|
|
});
|
|
|
|
},
|
|
|
|
async getUserList() {
|
|
|
|
const res = await getJointTrainRoomUserList(this.group);
|
|
|
|
this.members = (res.data || []).map(elem => { return this.transformUser(elem); });
|
|
|
|
},
|
|
|
|
async dispatchUsers(users) {
|
|
|
|
users.forEach(user => {
|
|
|
|
const index = this.members.findIndex(elem => { return user.id == elem.id; });
|
|
|
|
if (user.userRole) {
|
|
|
|
if (index >= 0) {
|
2019-11-08 19:32:21 +08:00
|
|
|
this.checkUserState(user, this.members[index]);
|
2019-11-12 14:56:53 +08:00
|
|
|
this.members.splice(index, 1, this.transformUser(user));
|
2019-11-08 18:15:52 +08:00
|
|
|
} else {
|
2019-11-08 19:32:21 +08:00
|
|
|
this.checkUserState(user, null);
|
2019-11-08 18:15:52 +08:00
|
|
|
this.members.push(this.transformUser(user));
|
|
|
|
}
|
|
|
|
} else {
|
2019-11-08 19:32:21 +08:00
|
|
|
this.checkUserState(user, this.members[index]);
|
2019-11-08 18:15:52 +08:00
|
|
|
this.members.splice(index, 1);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
async dispatchRoomInfo(room) {
|
|
|
|
Object.assign(this.room, room);
|
|
|
|
switch (room.state) {
|
|
|
|
case '03': // 房间销毁
|
|
|
|
this.$router.go(-1);
|
|
|
|
break;
|
|
|
|
case '02': // 开始仿真
|
|
|
|
this.jumpInSimulation();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 清空房间信息
|
|
|
|
this.$store.dispatch('socket/setJointRoomInfo');
|
|
|
|
},
|
2019-11-08 19:32:21 +08:00
|
|
|
async checkUserState(user, old) {
|
|
|
|
const message = {
|
|
|
|
join: true,
|
|
|
|
id: user.id,
|
|
|
|
userName: user.nickName,
|
|
|
|
userRole: user.userRole,
|
|
|
|
name: user.name,
|
|
|
|
roomTip: '',
|
|
|
|
chatInfo: true,
|
|
|
|
inSimulation: user.inSimulation,
|
|
|
|
inRoom: user.inRoom,
|
|
|
|
session: 'session',
|
|
|
|
oneself: user.id === this.$store.state.user.id
|
|
|
|
};
|
|
|
|
|
|
|
|
if (old) {
|
2019-11-12 13:39:52 +08:00
|
|
|
if (!user.userRole) {
|
|
|
|
this.$store.dispatch('socket/setChatContent', {...message, roomTip: `${user.nickName}被提出房间`});
|
|
|
|
if (this.userId == user.id) {
|
|
|
|
this.jumpOutRoom();
|
|
|
|
}
|
|
|
|
} else if (old.userRole) {
|
2019-11-12 14:56:53 +08:00
|
|
|
if (old.inRoom && !user.inRoom) {
|
2019-11-12 13:39:52 +08:00
|
|
|
this.$store.dispatch('socket/setChatContent', {...message, roomTip: `${user.nickName}离线`});
|
2019-11-08 19:32:21 +08:00
|
|
|
if (this.userId == user.id) {
|
|
|
|
this.jumpOutRoom();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!old.inRoom && user.inRoom) {
|
2019-11-12 13:39:52 +08:00
|
|
|
this.$store.dispatch('socket/setChatContent', {...message, roomTip: `${user.nickName}在线`});
|
2019-11-08 18:15:52 +08:00
|
|
|
}
|
|
|
|
|
2019-11-08 19:32:21 +08:00
|
|
|
if (user.inSimulation) {
|
|
|
|
this.$store.dispatch('socket/setChatContent', {...message, roomTip: `${user.nickName}进入仿真`});
|
|
|
|
if (this.userId == user.id) {
|
|
|
|
this.jumpInSimulation();
|
|
|
|
}
|
|
|
|
}
|
2019-11-08 18:15:52 +08:00
|
|
|
}
|
2019-11-08 19:32:21 +08:00
|
|
|
} else {
|
|
|
|
this.$store.dispatch('socket/setChatContent', {...message, roomTip: `${user.nickName}进入房间`});
|
2019-11-08 18:15:52 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
async jumpInSimulation() {
|
|
|
|
const room = this.room;
|
|
|
|
await putJointTrainingSimulationEntrance(room.group);
|
|
|
|
const rest = await getPublishMapInfo(room.mapId);
|
2019-11-11 15:54:04 +08:00
|
|
|
const query = { lineCode: rest.data.lineCode, mapId: room.mapId, group: room.group, subSystem: this.$route.query.subSystem };
|
2019-11-08 18:15:52 +08:00
|
|
|
this.$router.replace({ path: `/jointTraining`, query: query });
|
|
|
|
launchFullscreen();
|
|
|
|
// 清空房间信息
|
|
|
|
this.$store.dispatch('socket/setJointRoomInfo');
|
|
|
|
},
|
|
|
|
async jumpOutRoom() {
|
|
|
|
this.$router.push({ path: `/` });
|
|
|
|
this.messageInfo({error: 'warning', message: this.$t('tip.beKickedOut')});
|
|
|
|
},
|
|
|
|
transformUser(user) {
|
|
|
|
// 根据用户角色专用数据数据
|
|
|
|
switch (user.userRole) {
|
|
|
|
case 'IBP':
|
|
|
|
user.deviceCode = [user.deviceCode || '', user.ibpPart || ''];
|
|
|
|
break;
|
|
|
|
}
|
2019-07-26 13:32:43 +08:00
|
|
|
|
2019-11-08 18:15:52 +08:00
|
|
|
return user;
|
|
|
|
},
|
|
|
|
messageInfo(info) {
|
|
|
|
this.$message({ showClose: true, ...info });
|
2019-10-30 19:36:26 +08:00
|
|
|
}
|
|
|
|
}
|
2019-10-18 17:15:04 +08:00
|
|
|
};
|
2019-07-26 13:32:43 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2019-11-08 09:02:18 +08:00
|
|
|
.room {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
box-sizing: border-box;
|
|
|
|
background: #f0f0f0;
|
|
|
|
|
|
|
|
&__head {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
background: #000;
|
|
|
|
color: #fff;
|
|
|
|
padding: 10px;
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
&--title {
|
|
|
|
font-size: 22px;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
|
|
|
|
&--notes {
|
|
|
|
position: absolute;
|
|
|
|
left: 10px;
|
|
|
|
bottom: 5px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&__container {
|
|
|
|
display: flex;
|
|
|
|
flex-grow: 1;
|
|
|
|
padding: 10px;
|
|
|
|
|
|
|
|
&--members {
|
|
|
|
flex-shrink: 1;
|
|
|
|
flex-grow: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
&--roles {
|
|
|
|
flex-grow: 5;
|
|
|
|
flex-shrink: 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
&--chat {
|
|
|
|
flex-basis: 360px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&__footer {
|
|
|
|
height: 20px;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-07-26 13:32:43 +08:00
|
|
|
</style>
|