2020-04-01 13:47:29 +08:00
|
|
|
import store from '@/store/index_APP_TARGET';
|
2019-11-05 16:40:36 +08:00
|
|
|
import { Notification } from 'element-ui';
|
2019-07-26 13:32:43 +08:00
|
|
|
|
|
|
|
function handle(state, data) {
|
2020-03-31 18:30:15 +08:00
|
|
|
// console.log(data, 'socket订阅');
|
2019-11-05 16:40:36 +08:00
|
|
|
const msg = data.body;
|
|
|
|
const path = window.location.href;
|
|
|
|
switch (data.type) {
|
|
|
|
case 'Order_Pay_Result': // 订单支付结果消息
|
|
|
|
state.payOrder = msg;
|
|
|
|
break;
|
|
|
|
case 'JointTraining_Room': // 综合演练室-房间消息
|
|
|
|
if (!path.includes('/plan') || !path.includes('/dp/')) {
|
|
|
|
state.jointRoomInfo = msg; // 房间信息
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'JointTraining_User': // 综合演练室-用户消息
|
|
|
|
handleUserinfo(state, msg); // 分配角色权限消息
|
|
|
|
break;
|
|
|
|
case 'JointTraining_Chat': // 综合演练室-群聊消息
|
|
|
|
handleRecordList(state, msg);
|
|
|
|
break;
|
|
|
|
case 'Simulation_DeviceStatus': // 仿真-设备状态消息
|
|
|
|
state.equipmentStatus = msg;
|
|
|
|
break;
|
2020-06-30 18:35:57 +08:00
|
|
|
case 'Simulation_User': // 仿真-进出仿真消息
|
2020-05-13 18:05:48 +08:00
|
|
|
handleSimulationUserinfo(state, msg); // 用户进出仿真消息
|
|
|
|
break;
|
2020-08-17 13:21:27 +08:00
|
|
|
case 'Simulation_Script_Action_Tip': // 剧本提示消息
|
|
|
|
handleSimulationScriptTipInfo(state, msg); // 剧本提示消息
|
|
|
|
break;
|
|
|
|
case 'Simulation_Script_Action_Finish':
|
|
|
|
state.simulationScriptTipFinish++; // 剧本某一部操作完成提示
|
2020-05-15 16:54:31 +08:00
|
|
|
break;
|
2020-06-05 09:35:00 +08:00
|
|
|
case 'Simulation_PlayBack_Finish': // 竞赛裁判系统裁判员回放结束推送
|
|
|
|
state.playBackFinish++; // 竞赛裁判系统裁判员回放结束推送
|
2020-05-21 10:43:32 +08:00
|
|
|
break;
|
2020-05-22 09:32:48 +08:00
|
|
|
case 'Simulation_Over': // 用户退出仿真推送消息
|
|
|
|
state.simulationOver++; // 用户退出仿真推送消息
|
|
|
|
break;
|
2020-05-15 20:45:59 +08:00
|
|
|
case 'Simulation_Script_Finish': // 剧本执行完成推送消息
|
|
|
|
state.scriptFinish++; // 剧本执行完成推送消息
|
|
|
|
break;
|
2020-06-12 17:44:18 +08:00
|
|
|
case 'Simulation_Script_Action':// 剧本编制添加指令的推送消息
|
|
|
|
state.scriptAction = msg;
|
|
|
|
break;
|
2020-07-03 17:13:24 +08:00
|
|
|
case 'Simulation_AutoFault_Trigger': // 自动故障触发操作推送消息
|
|
|
|
state.autoFaultTrigger++;
|
|
|
|
break;
|
2019-11-05 16:40:36 +08:00
|
|
|
case 'Simulation_RunFact': // 仿真-列车实际到发车站消息
|
2020-03-23 13:48:35 +08:00
|
|
|
if (!Array.isArray(msg)) {
|
|
|
|
state.trainStationList = [msg];
|
2020-07-31 18:57:27 +08:00
|
|
|
} else {
|
|
|
|
state.trainStationList = msg;
|
2020-02-27 18:51:48 +08:00
|
|
|
}
|
2019-11-05 16:40:36 +08:00
|
|
|
break;
|
|
|
|
case 'Simulation_Error': // 仿真-异常消息
|
2020-07-01 18:52:29 +08:00
|
|
|
state.simulationError += 1;
|
2019-11-05 16:40:36 +08:00
|
|
|
break;
|
|
|
|
case 'Simulation_RunAsPlan_Start': // 仿真-仿真开始按计划行车消息
|
|
|
|
state.simulationStart = msg;
|
|
|
|
break;
|
|
|
|
case 'Simulation_Reset': // 仿真-仿真重置消息 退出计划行车
|
2020-07-10 10:52:31 +08:00
|
|
|
state.simulationReset += 1;
|
2019-11-05 16:40:36 +08:00
|
|
|
break;
|
|
|
|
case 'Simulation_Conversation': // 仿真-用户交互消息(聊天/命令)
|
2020-07-06 18:00:44 +08:00
|
|
|
handleSimulationInfo(state, msg);
|
|
|
|
break;
|
2019-11-05 16:40:36 +08:00
|
|
|
case 'Simulation_PlayBack_Conversation': // 回放-用户交互消息
|
|
|
|
handleSimulationInfo(state, msg);
|
|
|
|
break;
|
2020-08-06 19:34:13 +08:00
|
|
|
|
|
|
|
case 'Simulation_ApplyHandle': // 请求处理消息(旧版可能在用,新版地图不用这个)
|
2019-11-05 16:40:36 +08:00
|
|
|
handlePushMsgQueue(state, msg);
|
|
|
|
break;
|
2020-08-06 19:34:13 +08:00
|
|
|
|
2019-11-05 16:40:36 +08:00
|
|
|
case 'JointTraining_User_Permit': // 综合演练室-用户获取权限消息
|
|
|
|
state.userPermit = msg;
|
|
|
|
break;
|
2020-06-30 18:35:57 +08:00
|
|
|
case 'Simulation_Invite': // 综合演练-仿真邀请消息
|
|
|
|
state.simulationInvite = msg;
|
2019-11-05 16:40:36 +08:00
|
|
|
break;
|
2020-07-13 14:34:56 +08:00
|
|
|
case 'JointTraining_Room_Invite': // 综合演练室-房间邀请消息
|
|
|
|
state.roomInvite = msg;
|
|
|
|
break;
|
2019-11-05 16:40:36 +08:00
|
|
|
case 'Big_Screen_Simulation_DeviceStatus': // 大屏仿真状态数据
|
|
|
|
state.equipmentStatus = msg;
|
|
|
|
break;
|
|
|
|
case 'Big_Screen_Simulation_RunFact': // 大屏仿真运行图状态
|
|
|
|
state.trainStationList = msg;
|
|
|
|
break;
|
|
|
|
case 'Plan_Simulation_DeviceStatus': // 大屏仿真状态数据
|
|
|
|
state.equipmentStatus = msg;
|
|
|
|
break;
|
|
|
|
case 'Plan_Simulation_RunFact': // 大屏仿真运行图状态
|
|
|
|
state.trainStationList = msg;
|
|
|
|
break;
|
|
|
|
case 'Simulation_Permission_Over': // 权限结束
|
|
|
|
state.permissionOver = msg;
|
|
|
|
break;
|
|
|
|
case 'Simulation_Quest_Finish': // 任务结束标志
|
|
|
|
state.tipOperateCount++;
|
|
|
|
break;
|
|
|
|
case 'JointTraining_Device':
|
|
|
|
state.realDeviceInfo++;
|
|
|
|
break;
|
2019-11-18 10:34:18 +08:00
|
|
|
case 'Be_Logged_Out': // 重复登录被登出
|
|
|
|
state.beLogoutCount++;
|
|
|
|
break;
|
2020-04-21 15:08:27 +08:00
|
|
|
case 'Simulation_Run_Plan_Reload': // 运行图变更
|
|
|
|
state.runPlanReloadCount++;
|
|
|
|
break;
|
2019-11-05 16:40:36 +08:00
|
|
|
case 'Simulation_Control_Pause': // 暂停中
|
|
|
|
store.dispatch('scriptRecord/updateSimulationPause', msg);
|
|
|
|
break;
|
|
|
|
case 'BROADCAST': // 升级通知消息
|
|
|
|
Notification.warning({
|
|
|
|
title: msg.title,
|
|
|
|
center: true,
|
|
|
|
message: msg.message,
|
|
|
|
position: 'bottom-right',
|
|
|
|
showClose: msg.showClose,
|
|
|
|
duration: 0
|
|
|
|
});
|
|
|
|
break;
|
2020-07-03 18:42:29 +08:00
|
|
|
case 'Simulation_Member':
|
|
|
|
state.memberChangeCount++;
|
|
|
|
break;
|
2019-11-05 16:40:36 +08:00
|
|
|
}
|
2019-07-26 13:32:43 +08:00
|
|
|
}
|
2019-08-06 10:11:32 +08:00
|
|
|
|
2019-07-26 13:32:43 +08:00
|
|
|
// 操作聊天信息
|
|
|
|
function handleRecordList(state, data) {
|
2019-11-05 16:40:36 +08:00
|
|
|
const userId = store.state.user.id;
|
|
|
|
let isSelf = false;
|
|
|
|
if (data.member.id == userId) {
|
|
|
|
isSelf = true;
|
|
|
|
}
|
|
|
|
const myDate = new Date();
|
|
|
|
const myDate1 = myDate.toLocaleDateString().replace(/\//g, '-');
|
|
|
|
const param = {
|
|
|
|
join: false,
|
|
|
|
value: data.message,
|
|
|
|
self: isSelf,
|
|
|
|
voice: data.isAudio,
|
2020-05-14 14:36:15 +08:00
|
|
|
src: data.isAudio ? `/jlcloud/audio/${data.audioPath}` : '',
|
2019-11-05 16:40:36 +08:00
|
|
|
other: !isSelf,
|
|
|
|
userName: data.member.nickName,
|
|
|
|
chatTime: data.chatTime,
|
|
|
|
chatInfo: true,
|
|
|
|
inSimulation: false,
|
|
|
|
inRoom: true,
|
|
|
|
date: +new Date(`${myDate1} ${data.chatTime}`)
|
|
|
|
};
|
2019-11-08 18:15:52 +08:00
|
|
|
state.chatContent = param;
|
2019-07-26 13:32:43 +08:00
|
|
|
}
|
|
|
|
// 仿真内部聊天
|
|
|
|
function handleSimulationInfo(state, data) {
|
2020-07-06 18:00:44 +08:00
|
|
|
switch (data.messageType) {
|
|
|
|
case 'INVITE':
|
|
|
|
state.inviteSimulationConversition = data;
|
|
|
|
break;
|
|
|
|
case 'CONNECT':
|
|
|
|
state.acceptConversionInvite = data;
|
|
|
|
break;
|
|
|
|
case 'OVER':
|
|
|
|
state.overConversition = data;
|
|
|
|
break;
|
2020-07-07 09:39:27 +08:00
|
|
|
case 'MESSAGE':
|
|
|
|
state.conversationInfo = data;
|
2020-07-06 18:00:44 +08:00
|
|
|
break;
|
2020-07-14 16:51:22 +08:00
|
|
|
case 'CREATE':
|
|
|
|
state.createConversition = data;
|
|
|
|
break;
|
2019-11-05 16:40:36 +08:00
|
|
|
}
|
2020-05-15 16:54:31 +08:00
|
|
|
}
|
2020-04-27 18:50:15 +08:00
|
|
|
|
2020-05-15 16:54:31 +08:00
|
|
|
// 剧本提示
|
|
|
|
function handleSimulationScriptTipInfo(state, data) {
|
|
|
|
state.simulationScriptTip = data;
|
2019-07-26 13:32:43 +08:00
|
|
|
}
|
2019-11-08 18:15:52 +08:00
|
|
|
|
2019-07-26 13:32:43 +08:00
|
|
|
function handleUserinfo(state, data) {
|
2019-11-08 18:15:52 +08:00
|
|
|
state.roleList = (data instanceof Array) ? data : [data];
|
2019-07-26 13:32:43 +08:00
|
|
|
}
|
2019-11-08 18:15:52 +08:00
|
|
|
|
2020-05-13 18:05:48 +08:00
|
|
|
function handleSimulationUserinfo(state, data) {
|
|
|
|
state.simulationRoleList = (data instanceof Array) ? data : [data];
|
|
|
|
}
|
|
|
|
|
2020-08-06 19:34:13 +08:00
|
|
|
// (旧版可能在用,新版地图不用这个)
|
2019-07-26 13:32:43 +08:00
|
|
|
function handlePushMsgQueue(state, msg) {
|
2019-11-05 16:40:36 +08:00
|
|
|
if (msg instanceof Array) {
|
|
|
|
state.msgQueue.concat(msg);
|
|
|
|
} else {
|
|
|
|
state.msgQueue.push(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!state.msgHead) {
|
|
|
|
state.msgHead = state.msgQueue[0];
|
|
|
|
}
|
2019-07-26 13:32:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const socket = {
|
2019-11-05 16:40:36 +08:00
|
|
|
namespaced: true,
|
|
|
|
|
|
|
|
state: {
|
|
|
|
payOrder: {}, // 支付消息
|
|
|
|
jointRoomInfo: {}, // 受邀请房间信息
|
2019-11-08 18:15:52 +08:00
|
|
|
chatContent: {}, // 聊天室聊天内容
|
|
|
|
roleList: [], // 设置角色信息
|
2020-05-13 18:05:48 +08:00
|
|
|
simulationRoleList:[], // 设置仿真的聊天角色信息
|
2020-05-15 16:54:31 +08:00
|
|
|
simulationScriptTip:{}, // 剧本推送提示信息
|
2020-08-17 13:21:27 +08:00
|
|
|
simulationScriptTipFinish:0, // 剧本某一步完成的消息
|
2020-05-15 20:45:59 +08:00
|
|
|
scriptFinish:0, // 剧本执行完成提示信息
|
2020-07-03 17:13:24 +08:00
|
|
|
autoFaultTrigger:0, // 自动故障触发操作推送消息
|
2020-06-12 17:44:18 +08:00
|
|
|
scriptAction:{}, // 剧本编制添加指令的推送消息
|
2020-06-05 09:35:00 +08:00
|
|
|
playBackFinish:0, // 竞赛裁判系统裁判回放结束推送
|
2019-11-05 16:40:36 +08:00
|
|
|
jointRoomPrepare: false, // 演练房间准备状态
|
|
|
|
equipmentStatus: [], // 仿真-设备状态消息
|
|
|
|
trainStationList: [], // 仿真-列车实际到发车站消息
|
2020-07-01 18:52:29 +08:00
|
|
|
simulationError: 0, // 仿真-异常消息
|
2019-11-05 16:40:36 +08:00
|
|
|
simulationStart: '', // 仿真-开始消息
|
2020-05-22 09:32:48 +08:00
|
|
|
simulationOver:0, // 退出仿真推送消息
|
2020-07-10 10:52:31 +08:00
|
|
|
simulationReset: 0, // 仿真-异常消息
|
2020-05-12 16:46:41 +08:00
|
|
|
// coversitionList:{}, // 历史仿真-用户消息列表
|
2020-07-06 18:00:44 +08:00
|
|
|
inviteSimulationConversition: {}, // 仿真会话邀请消息
|
|
|
|
acceptConversionInvite:{}, // 仿真会话成员接收邀请
|
2020-07-14 16:51:22 +08:00
|
|
|
createConversition:{}, // 仿真创建会话
|
2020-07-06 18:00:44 +08:00
|
|
|
overConversition: {}, // 仿真会话结束
|
2020-07-07 09:39:27 +08:00
|
|
|
conversationInfo: {}, // 仿真会话消息
|
2019-11-08 18:15:52 +08:00
|
|
|
|
2019-11-05 16:40:36 +08:00
|
|
|
message: {}, // 仿真聊天
|
2020-08-06 19:34:13 +08:00
|
|
|
msgQueue: [], // 命令请求列表(旧版控制权转移可能在用,新版不用这个)
|
|
|
|
msgHead: null, // 消息头(旧版控制权转移可能在用,新版不用这个)
|
2019-11-05 16:40:36 +08:00
|
|
|
|
|
|
|
userPermit: {}, // 用户获取权限消息
|
|
|
|
userRoomKickOut: {}, // 用户被踢出房间消息
|
|
|
|
userInRoom: {}, // 用户从外部进入房间消息
|
|
|
|
userOutRoom: {}, // 用户退出房间消息
|
|
|
|
userInSimulation: {}, // 用户进入仿真消息
|
|
|
|
userBackRoom: {}, // 用户从仿真返回房间消息
|
2020-06-30 18:35:57 +08:00
|
|
|
simulationInvite: {}, // 用户扫码信息
|
2019-11-05 16:40:36 +08:00
|
|
|
|
|
|
|
permissionOver: {}, // 权限结束
|
|
|
|
|
2020-01-15 13:20:48 +08:00
|
|
|
roomIsSubscribe:false, // 房间是否订阅
|
2020-04-22 18:17:27 +08:00
|
|
|
assistantIsSubscribe:false, // 综合演练仿真聊天是否订阅
|
2020-01-16 15:08:03 +08:00
|
|
|
isInRoom:false, // 是否己经进入房间
|
2020-01-15 13:20:48 +08:00
|
|
|
|
2019-11-05 16:40:36 +08:00
|
|
|
tipOperateCount: 0, // 任务结束提示消息
|
2019-11-18 10:34:18 +08:00
|
|
|
realDeviceInfo: 0, // 真实设备信息
|
2020-04-21 15:08:27 +08:00
|
|
|
beLogoutCount: 0, // 被登出
|
2020-07-03 18:42:29 +08:00
|
|
|
runPlanReloadCount: 0, // 仿真运行图变更
|
2020-07-13 14:34:56 +08:00
|
|
|
memberChangeCount: 0, // 仿真成员变更
|
|
|
|
roomInvite: {}
|
2019-11-05 16:40:36 +08:00
|
|
|
},
|
|
|
|
getters: {
|
|
|
|
},
|
|
|
|
mutations: {
|
|
|
|
setJointRoomInfo: (state, jointRoomInfo) => {
|
|
|
|
state.jointRoomInfo = jointRoomInfo;
|
|
|
|
},
|
|
|
|
|
2019-11-08 18:15:52 +08:00
|
|
|
setChatContent: (state, chatContent) => {
|
|
|
|
state.chatContent = chatContent;
|
2019-11-05 16:40:36 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
setEquipmentStatus: (state, equipmentStatus) => {
|
|
|
|
state.equipmentStatus = equipmentStatus;
|
|
|
|
},
|
|
|
|
|
|
|
|
setTrainStationList: (state, trainStationList) => {
|
|
|
|
state.trainStationList = trainStationList;
|
|
|
|
},
|
|
|
|
|
|
|
|
setSimulationStart: (state, simulationStart) => {
|
|
|
|
state.simulationStart = simulationStart;
|
|
|
|
},
|
|
|
|
|
|
|
|
setSimulationReset: (state, simulationReset) => {
|
|
|
|
state.simulationReset = simulationReset;
|
|
|
|
},
|
|
|
|
|
|
|
|
setPayOrder: (state, payOrder) => {
|
|
|
|
state.payOrder = payOrder;
|
|
|
|
},
|
|
|
|
|
2020-08-06 19:34:13 +08:00
|
|
|
// (旧版可能在用,新版地图不用这个)
|
2019-11-05 16:40:36 +08:00
|
|
|
shiftMsgQueue: (state) => {
|
|
|
|
state.msgHead = null;
|
|
|
|
state.msgQueue.shift();
|
|
|
|
state.msgHead = state.msgQueue[0];
|
|
|
|
},
|
2020-08-06 19:34:13 +08:00
|
|
|
|
|
|
|
// (旧版可能在用,新版地图不用这个)
|
2019-11-05 16:40:36 +08:00
|
|
|
pushMsgQueue: (state, msg) => {
|
|
|
|
handlePushMsgQueue(state, msg);
|
|
|
|
},
|
|
|
|
|
2020-06-30 18:35:57 +08:00
|
|
|
setSimulationInvite: (state, simulationInvite) => {
|
|
|
|
state.simulationInvite = simulationInvite;
|
2020-01-15 13:20:48 +08:00
|
|
|
},
|
2020-07-13 14:34:56 +08:00
|
|
|
setRoomInvite: (state, roomInvite) => {
|
|
|
|
state.roomInvite = roomInvite;
|
|
|
|
},
|
2020-01-15 13:20:48 +08:00
|
|
|
setRoomSubscribe:(state, roomIsSubscribe)=>{
|
|
|
|
state.roomIsSubscribe = roomIsSubscribe;
|
2020-01-16 15:08:03 +08:00
|
|
|
},
|
2020-04-22 18:17:27 +08:00
|
|
|
setAssistantSubscribe:(state, assistantIsSubscribe)=>{
|
|
|
|
state.assistantIsSubscribe = assistantIsSubscribe;
|
|
|
|
},
|
2020-01-16 15:08:03 +08:00
|
|
|
setInRoom:(state, isInRoom)=>{
|
|
|
|
state.isInRoom = isInRoom;
|
2019-11-05 16:40:36 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
setStomp: ({ state }, res) => {
|
|
|
|
handle(state, res);
|
|
|
|
},
|
|
|
|
|
2019-11-08 18:15:52 +08:00
|
|
|
setChatContent: ({ commit }, chatContent) => {
|
|
|
|
commit('setChatContent', chatContent);
|
2019-11-05 16:40:36 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
setJointRoomInfo: ({ commit }) => {
|
|
|
|
commit('setJointRoomInfo', {});
|
|
|
|
},
|
|
|
|
|
|
|
|
setEquipmentStatus: ({ commit }) => {
|
|
|
|
commit('setEquipmentStatus', []);
|
|
|
|
},
|
|
|
|
|
|
|
|
setTrainStationList: ({ commit }) => {
|
|
|
|
commit('setTrainStationList', []);
|
|
|
|
},
|
|
|
|
|
|
|
|
setSimulationStart: ({ commit }) => {
|
|
|
|
commit('setSimulationStart', '');
|
|
|
|
},
|
|
|
|
|
|
|
|
setSimulationReset: ({ commit }) => {
|
2020-07-10 10:52:31 +08:00
|
|
|
commit('setSimulationReset', 0);
|
2019-11-05 16:40:36 +08:00
|
|
|
},
|
|
|
|
|
2020-06-30 18:35:57 +08:00
|
|
|
setSimulationInvite: ({ commit }) => {
|
|
|
|
commit('setSimulationInvite', {});
|
2019-11-05 16:40:36 +08:00
|
|
|
},
|
2020-07-13 14:34:56 +08:00
|
|
|
setRoomInvite: ({ commit }) => {
|
|
|
|
commit('setRoomInvite', {});
|
|
|
|
},
|
2019-11-05 16:40:36 +08:00
|
|
|
setMessage: ({ state }, data) => {
|
|
|
|
if (!state.message[data.key]) {
|
|
|
|
state.message[data.key] = [];
|
|
|
|
}
|
|
|
|
state.message[data.key].push(data.value);
|
|
|
|
},
|
|
|
|
|
|
|
|
setPayOrder: ({ commit }) => {
|
|
|
|
commit('setPayOrder', {});
|
|
|
|
},
|
|
|
|
|
|
|
|
shiftMsgQueue: ({ commit }) => {
|
|
|
|
commit('shiftMsgQueue');
|
|
|
|
},
|
|
|
|
|
2020-08-06 19:34:13 +08:00
|
|
|
// pushMsgQueue: ({ commit }, msg) => {
|
|
|
|
// commit('pushMsgQueue', msg);
|
|
|
|
// },
|
2020-01-15 13:20:48 +08:00
|
|
|
setRoomSubscribe:({ commit }, msg) => {
|
|
|
|
commit('setRoomSubscribe', msg);
|
2020-01-16 15:08:03 +08:00
|
|
|
},
|
2020-04-22 18:17:27 +08:00
|
|
|
setAssistantSubscribe:({ commit }, msg) => {
|
|
|
|
commit('setAssistantSubscribe', msg);
|
|
|
|
},
|
2020-01-16 15:08:03 +08:00
|
|
|
setInRoom:({ commit }, msg) => {
|
|
|
|
commit('setInRoom', msg);
|
2019-11-05 16:40:36 +08:00
|
|
|
}
|
|
|
|
}
|
2019-07-26 13:32:43 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export default socket;
|