2019-07-25 10:58:17 +08:00
|
|
|
|
import Vue from 'vue';
|
|
|
|
|
import { TrainingMode } from '@/scripts/ConstDic';
|
2019-11-18 14:44:01 +08:00
|
|
|
|
import OperateHandler from '@/scripts/plugin/OperateHandler';
|
2020-10-23 18:05:55 +08:00
|
|
|
|
import deviceType from '../../jmapNew/constant/deviceType';
|
2019-09-26 18:40:38 +08:00
|
|
|
|
import LangStorage from '@/utils/lang';
|
2019-12-31 17:10:52 +08:00
|
|
|
|
import Handler from '@/scripts/cmdPlugin/Handler';
|
2020-07-02 17:57:48 +08:00
|
|
|
|
import { deepAssign } from '@/utils/index';
|
2019-11-18 18:47:02 +08:00
|
|
|
|
|
2019-07-25 10:58:17 +08:00
|
|
|
|
/**
|
|
|
|
|
* 实训状态数据
|
|
|
|
|
*/
|
2019-11-18 18:47:02 +08:00
|
|
|
|
|
2019-07-25 10:58:17 +08:00
|
|
|
|
const training = {
|
2019-11-07 15:20:39 +08:00
|
|
|
|
namespaced: true,
|
|
|
|
|
|
|
|
|
|
state: {
|
2020-08-05 13:14:30 +08:00
|
|
|
|
mode: TrainingMode.NORMAL, // 模式 (教学系统中教学、练习、测验模式)
|
2020-08-05 09:05:26 +08:00
|
|
|
|
operatemode: null, // 操作模式 管理员(故障、指令、普通)
|
2019-11-07 15:20:39 +08:00
|
|
|
|
started: false, // 是否开始
|
|
|
|
|
switchcount: 0, // 开关标识
|
|
|
|
|
basicInfo: {}, // 实训基本信息数据
|
|
|
|
|
offsetStationCode: '', // 偏移到车站
|
|
|
|
|
rezoomCount: 0, // 车站变更标识
|
|
|
|
|
steps: [], // 实训步骤数据
|
|
|
|
|
order: -1, // 实训进行到第几步
|
|
|
|
|
orderCount: 0, // 步骤变更标识
|
|
|
|
|
operateErrMsg: '', // 操作错误提示信息
|
|
|
|
|
subscribeCount: 0, // 仿真订阅完成标识
|
|
|
|
|
score: 0, // 实训得分
|
|
|
|
|
usedTime: 0, // 实训所需时间
|
|
|
|
|
timeInterval: null, // 计时器
|
|
|
|
|
tipEvent: 0, // 提示刷新检测
|
|
|
|
|
operate: {}, // 操作model,
|
|
|
|
|
initTime: 0, // 当前系统时间
|
|
|
|
|
prdType: '', // 产品类型
|
|
|
|
|
roles: '', // 角色权限类型
|
2020-08-06 19:34:13 +08:00
|
|
|
|
roleDeviceCode:'', // 当前角色对应的deviceCode
|
2020-04-13 14:54:35 +08:00
|
|
|
|
group: '', // 设置全局 group
|
2020-07-02 17:57:48 +08:00
|
|
|
|
centerStationCode:'', // 当前居中的集中站code
|
|
|
|
|
memberList: [], // 综合仿真成员列表
|
|
|
|
|
memberData: {}, // 综合仿真成员列表
|
2020-08-21 14:16:44 +08:00
|
|
|
|
simulationUserList: [], // 综合仿真用户列表
|
2020-09-11 09:26:51 +08:00
|
|
|
|
orignalUserRoleId:'', // 设置旧的角色的id
|
2020-09-16 10:49:16 +08:00
|
|
|
|
scriptQuitCount: 0, // 主动退出剧本
|
2020-10-12 14:25:33 +08:00
|
|
|
|
scriptOperationType: '', // 剧本操作类型
|
|
|
|
|
triggerFaultCount: 0, // 触发故障计数器
|
|
|
|
|
triggerFaultDevice: '' // 触发故障目标设备
|
2019-11-07 15:20:39 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getters: {
|
2020-10-27 18:04:19 +08:00
|
|
|
|
steps: (state) => {
|
|
|
|
|
return state.steps;
|
|
|
|
|
},
|
|
|
|
|
order: (state) => {
|
|
|
|
|
return state.order;
|
|
|
|
|
},
|
2019-11-07 15:20:39 +08:00
|
|
|
|
basicInfo: (state) => {
|
|
|
|
|
return state.basicInfo;
|
|
|
|
|
},
|
2020-10-27 18:04:19 +08:00
|
|
|
|
mode: (state) => {
|
|
|
|
|
return state.mode;
|
|
|
|
|
},
|
|
|
|
|
operatemode: (state) => {
|
|
|
|
|
return state.operatemode;
|
|
|
|
|
},
|
|
|
|
|
started: (state) => {
|
|
|
|
|
return state.started;
|
|
|
|
|
},
|
|
|
|
|
score: (state) => {
|
|
|
|
|
return state.score;
|
|
|
|
|
},
|
|
|
|
|
usedTime: (state) => {
|
|
|
|
|
return state.usedTime;
|
|
|
|
|
},
|
|
|
|
|
memberList: (state) => {
|
|
|
|
|
return state.memberList;
|
|
|
|
|
},
|
2019-11-07 15:20:39 +08:00
|
|
|
|
// 视图中的列车列表
|
|
|
|
|
viewTrainList: (state) => () =>{
|
|
|
|
|
const trainList = [];
|
|
|
|
|
const mapDevice = Vue.prototype.$jlmap.mapDevice;
|
|
|
|
|
Object.values(mapDevice).forEach(device => {
|
|
|
|
|
if (device && device._type === deviceType.Train) {
|
|
|
|
|
trainList.push(device);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return trainList;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
mutations: {
|
|
|
|
|
changeMode: (state, mode) => {
|
|
|
|
|
state.mode = mode;
|
|
|
|
|
},
|
|
|
|
|
changeOperateMode: (state, mode) => {
|
|
|
|
|
state.operatemode = mode;
|
|
|
|
|
},
|
|
|
|
|
start: (state) => {
|
|
|
|
|
state.started = true;
|
|
|
|
|
state.switchcount += 1;
|
|
|
|
|
},
|
|
|
|
|
over: (state) => {
|
|
|
|
|
state.started = false;
|
2020-08-04 14:01:43 +08:00
|
|
|
|
state.switchcount += 1;
|
2019-11-07 15:20:39 +08:00
|
|
|
|
},
|
|
|
|
|
updateMapState: (state, deviceStatus) => {
|
|
|
|
|
Vue.prototype.$jlmap && Vue.prototype.$jlmap.update(deviceStatus);
|
|
|
|
|
},
|
|
|
|
|
setMapDefaultState: (state) =>{
|
|
|
|
|
Vue.prototype.$jlmap && Vue.prototype.$jlmap.setDefaultState();
|
|
|
|
|
},
|
|
|
|
|
setBasicInfo: (state, basicInfo) => {
|
|
|
|
|
state.basicInfo = basicInfo;
|
|
|
|
|
},
|
|
|
|
|
setOffsetStationCode: (state, offsetStationCode) => {
|
2020-07-30 18:42:41 +08:00
|
|
|
|
state.offsetStationCode = offsetStationCode || null;
|
2020-07-27 18:04:47 +08:00
|
|
|
|
state.rezoomCount += 1;
|
2019-11-07 15:20:39 +08:00
|
|
|
|
},
|
|
|
|
|
setSteps: (state, steps) => {
|
|
|
|
|
state.steps = steps;
|
|
|
|
|
},
|
|
|
|
|
addStep: (state, step) => {
|
|
|
|
|
state.steps.push(step);
|
|
|
|
|
},
|
|
|
|
|
next: (state) => {
|
|
|
|
|
state.order += 1;
|
|
|
|
|
state.orderCount += 1;
|
|
|
|
|
},
|
|
|
|
|
orderCountIncrement: (state) => {
|
|
|
|
|
state.orderCount += 1;
|
|
|
|
|
},
|
|
|
|
|
resetOrder: (state) => {
|
|
|
|
|
state.order = -1;
|
|
|
|
|
},
|
|
|
|
|
backOrder: (state, stepNum) => {
|
|
|
|
|
if (state.order > stepNum) {
|
|
|
|
|
state.order -= stepNum;
|
|
|
|
|
state.orderCount += 1;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
setOperateErrMsg: (state, errMsg) => {
|
|
|
|
|
state.operateErrMsg = errMsg;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
setHasSubscribed: (state) => {
|
|
|
|
|
state.subscribeCount++;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
setScore: (state, score) => {
|
|
|
|
|
state.score = score;
|
|
|
|
|
},
|
|
|
|
|
resetScore: (state) => {
|
|
|
|
|
state.score = '';
|
|
|
|
|
},
|
|
|
|
|
tipEventIncrement: (state) => {
|
|
|
|
|
state.tipEvent++;
|
|
|
|
|
},
|
|
|
|
|
resetUsedTime: (state) => {
|
|
|
|
|
state.usedTime = 0;
|
|
|
|
|
},
|
2020-08-03 10:53:44 +08:00
|
|
|
|
countTime: (state, type) => {
|
2019-11-07 15:20:39 +08:00
|
|
|
|
if (state.timeInterval) {
|
|
|
|
|
clearInterval(state.timeInterval);
|
|
|
|
|
state.timeInterval = null;
|
|
|
|
|
}
|
2020-08-03 10:53:44 +08:00
|
|
|
|
if (type == 'Lesson') {
|
|
|
|
|
state.timeInterval = setInterval(() => {
|
|
|
|
|
state.usedTime++;
|
|
|
|
|
}, 1000);
|
|
|
|
|
} else {
|
|
|
|
|
state.timeInterval = setInterval(() => {
|
|
|
|
|
state.initTime += 1000;
|
|
|
|
|
}, 1000);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
stopCountTime: (state) => {
|
|
|
|
|
if (state.timeInterval) {
|
|
|
|
|
clearInterval(state.timeInterval);
|
|
|
|
|
state.timeInterval = null;
|
|
|
|
|
}
|
|
|
|
|
},
|
2019-11-07 15:20:39 +08:00
|
|
|
|
setOperate: (state, operate) => {
|
|
|
|
|
state.operate = operate;
|
|
|
|
|
},
|
2020-05-18 11:04:39 +08:00
|
|
|
|
setInitTime: (state, initTime) => {
|
|
|
|
|
state.initTime = initTime;
|
2019-11-07 15:20:39 +08:00
|
|
|
|
},
|
|
|
|
|
setPrdType: (state, prdType) => {
|
|
|
|
|
state.prdType = prdType;
|
|
|
|
|
},
|
|
|
|
|
setRoles: (state, roles) => {
|
|
|
|
|
state.roles = roles;
|
|
|
|
|
},
|
|
|
|
|
setGroup: (state, group) => {
|
|
|
|
|
state.group = group;
|
2019-12-31 17:10:52 +08:00
|
|
|
|
},
|
|
|
|
|
notifyGetCommandDefinition: (state, lineCode) => {
|
|
|
|
|
Handler.notify(lineCode);
|
2020-04-13 14:54:35 +08:00
|
|
|
|
},
|
|
|
|
|
setCenterStationCode:(state, centerStationCode) => {
|
|
|
|
|
state.centerStationCode = centerStationCode;
|
2020-07-02 17:57:48 +08:00
|
|
|
|
},
|
2020-07-06 18:00:44 +08:00
|
|
|
|
setMemberList: (state, {memberList, userId}) => {
|
2020-07-02 17:57:48 +08:00
|
|
|
|
state.memberList = memberList;
|
|
|
|
|
state.memberData = {};
|
|
|
|
|
if (memberList && memberList.length) {
|
|
|
|
|
memberList.forEach(item => {
|
|
|
|
|
state.memberData[item.id] = deepAssign({userId: ''}, item);
|
2020-07-06 18:00:44 +08:00
|
|
|
|
state.memberData[item.id].disabled = userId == item.userId;
|
2020-07-02 17:57:48 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
setSimulationUserList: (state, simulationUserList) => {
|
|
|
|
|
state.simulationUserList = simulationUserList;
|
|
|
|
|
},
|
2020-07-23 17:57:35 +08:00
|
|
|
|
updateMemberTrust:(state, {deviceCode, trust}) => {
|
|
|
|
|
for (const k in state.memberData) {
|
|
|
|
|
if (state.memberData[k].deviceCode == deviceCode) {
|
|
|
|
|
state.memberData[k].trust = trust;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2020-07-14 15:03:31 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2020-08-17 19:11:59 +08:00
|
|
|
|
updateMemberListInScript:(state, {oldMemberId, newMemberId, userId, name}) => {
|
2020-07-10 16:40:42 +08:00
|
|
|
|
if (oldMemberId) {
|
|
|
|
|
// 重置旧数据
|
|
|
|
|
delete state.memberData[oldMemberId].userId;
|
2020-07-10 17:33:37 +08:00
|
|
|
|
delete state.memberData[oldMemberId].name;
|
2020-07-10 16:40:42 +08:00
|
|
|
|
state.memberData[oldMemberId].disabled = false;
|
|
|
|
|
}
|
2020-08-17 19:11:59 +08:00
|
|
|
|
// 更新新数据
|
|
|
|
|
state.memberData[newMemberId].userId = userId;
|
|
|
|
|
state.memberData[newMemberId].name = name;
|
|
|
|
|
state.memberData[newMemberId].disabled = true;
|
|
|
|
|
},
|
|
|
|
|
|
2020-07-06 18:00:44 +08:00
|
|
|
|
updateMemberAndUser: (state, {simulationUserList, userId}) => {
|
|
|
|
|
simulationUserList.forEach(item => {
|
2020-07-02 17:57:48 +08:00
|
|
|
|
let memberIndex = -1;
|
|
|
|
|
let memberId = '';
|
|
|
|
|
state.simulationUserList.forEach((user, index) =>{
|
|
|
|
|
if (user.userId === item.userId) {
|
|
|
|
|
memberId = user.memberId;
|
|
|
|
|
user.online = item.online;
|
|
|
|
|
user.memberId = item.memberId;
|
|
|
|
|
user.role = item.role;
|
|
|
|
|
memberIndex = index;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
try {
|
2020-07-03 18:42:29 +08:00
|
|
|
|
if (state.memberData && memberId !== item.memberId && memberId && state.memberData[memberId]) {
|
2020-07-02 17:57:48 +08:00
|
|
|
|
state.memberData[memberId].userId = '';
|
2020-07-06 18:00:44 +08:00
|
|
|
|
state.memberData[memberId].disabled = false;
|
2020-07-02 17:57:48 +08:00
|
|
|
|
}
|
2020-07-03 18:42:29 +08:00
|
|
|
|
if (state.memberData && memberId !== item.memberId && item.memberId && state.memberData[item.memberId]) {
|
2020-07-02 17:57:48 +08:00
|
|
|
|
state.memberData[item.memberId].userId = item.userId;
|
2020-07-06 18:00:44 +08:00
|
|
|
|
state.memberData[item.memberId].disabled = item.userId == userId;
|
2020-07-02 17:57:48 +08:00
|
|
|
|
}
|
|
|
|
|
if (item.messageType === 'ENTER' && memberIndex < 0) {
|
|
|
|
|
delete item.messageType;
|
|
|
|
|
state.simulationUserList.push(item);
|
|
|
|
|
} else if (item.messageType === 'KICK_OUT' && memberIndex > -1) {
|
|
|
|
|
state.simulationUserList.splice(memberIndex, 1);
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error(e);
|
|
|
|
|
}
|
|
|
|
|
});
|
2020-08-06 19:34:13 +08:00
|
|
|
|
},
|
|
|
|
|
setRoleDeviceCode :(state, roleDeviceCode) => {
|
|
|
|
|
state.roleDeviceCode = roleDeviceCode;
|
2020-08-21 15:41:46 +08:00
|
|
|
|
},
|
|
|
|
|
setOrignalUserRoleId:(state, orignalUserRoleId) => {
|
|
|
|
|
state.orignalUserRoleId = orignalUserRoleId;
|
2020-09-11 09:26:51 +08:00
|
|
|
|
},
|
|
|
|
|
setScriptQuit: (state) => {
|
|
|
|
|
state.scriptQuitCount++;
|
2020-09-16 10:49:16 +08:00
|
|
|
|
},
|
|
|
|
|
setScriptOperationType: (state, scriptOperationType) => {
|
|
|
|
|
state.scriptOperationType = scriptOperationType;
|
2020-10-12 14:25:33 +08:00
|
|
|
|
},
|
|
|
|
|
setTriggerFaultCount: (state, device) => {
|
|
|
|
|
state.triggerFaultCount++;
|
|
|
|
|
state.triggerFaultDevice = device;
|
2019-11-07 15:20:39 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 清除仿真所在组
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
clearSimulationGroup: ({ commit }, type) => {
|
|
|
|
|
commit('clearSimulationGroup', type);
|
|
|
|
|
},
|
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 设置socke已经连接
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
setHasSubscribed: ({ commit }) => {
|
|
|
|
|
commit('setHasSubscribed');
|
|
|
|
|
},
|
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 模式变更
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
changeMode: ({ commit }, opts) => {
|
|
|
|
|
commit('changeMode', opts.mode);
|
|
|
|
|
},
|
2019-07-25 10:58:17 +08:00
|
|
|
|
|
2019-11-07 15:20:39 +08:00
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 操作模式变更
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
changeOperateMode: ({ commit }, opts) => {
|
|
|
|
|
commit('changeOperateMode', opts.mode);
|
|
|
|
|
},
|
2019-07-25 10:58:17 +08:00
|
|
|
|
|
2019-11-07 15:20:39 +08:00
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 重置实训状态
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
reset: ({ commit }) => {
|
|
|
|
|
commit('over');
|
|
|
|
|
commit('resetOrder');
|
2020-07-31 18:49:35 +08:00
|
|
|
|
// commit('stopCountTime');
|
2019-11-07 15:20:39 +08:00
|
|
|
|
|
|
|
|
|
// 清空计时器以及得分
|
|
|
|
|
commit('resetUsedTime');
|
|
|
|
|
commit('resetScore');
|
|
|
|
|
// 设置其他属性状态
|
|
|
|
|
commit('setOffsetStationCode', null);
|
2020-08-27 18:41:33 +08:00
|
|
|
|
// commit('changeMode', null);
|
2019-11-07 15:20:39 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 开始
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
start: ({ commit }) => {
|
|
|
|
|
// 清空操作组
|
|
|
|
|
OperateHandler.cleanOperates();
|
2019-12-31 17:20:04 +08:00
|
|
|
|
Handler.clear(); // 两种方式
|
2019-11-07 15:20:39 +08:00
|
|
|
|
// 清空计时器以及得分
|
2020-07-31 18:49:35 +08:00
|
|
|
|
// commit('stopCountTime');
|
2019-11-07 15:20:39 +08:00
|
|
|
|
commit('resetUsedTime');
|
|
|
|
|
commit('resetScore');
|
|
|
|
|
commit('start');
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 结束
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
over: ({ commit }) => {
|
|
|
|
|
commit('over');
|
|
|
|
|
commit('resetOrder');
|
2020-07-31 18:49:35 +08:00
|
|
|
|
// commit('stopCountTime');
|
2019-11-07 15:20:39 +08:00
|
|
|
|
},
|
2019-07-25 10:58:17 +08:00
|
|
|
|
|
2019-11-07 15:20:39 +08:00
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* step步骤是否结束
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
isStepOver: ({ state }) => {
|
|
|
|
|
if (state.order >= state.steps.length) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
},
|
2019-07-25 10:58:17 +08:00
|
|
|
|
|
2019-11-07 15:20:39 +08:00
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 停止计时
|
|
|
|
|
*/
|
2020-08-03 10:53:44 +08:00
|
|
|
|
setStopCountTime: ({ commit }) => {
|
|
|
|
|
commit('stopCountTime');
|
|
|
|
|
},
|
2019-07-25 10:58:17 +08:00
|
|
|
|
|
2019-11-07 15:20:39 +08:00
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 主动判断是否结束
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
judgeFinish: ({ dispatch, commit, state }, rtn) => {
|
|
|
|
|
if (state.started) {
|
|
|
|
|
if (state.order >= state.steps.length) {
|
|
|
|
|
if (rtn && rtn.valid) {
|
|
|
|
|
commit('next');
|
|
|
|
|
commit('setOperateErrMsg', { errMsg: LangStorage.getLang() == 'en' ? 'Correct operation! Training is over!' : '操作正确!实训结束!', color: 'green' });
|
|
|
|
|
} else {
|
|
|
|
|
commit('setOperateErrMsg', { errMsg: LangStorage.getLang() == 'en' ? 'Operation error! Training is over!' : '操作错误!实训结束!', color: 'red' });
|
|
|
|
|
}
|
|
|
|
|
dispatch('over');
|
|
|
|
|
dispatch('changeMode', { mode: null });
|
|
|
|
|
if (rtn.hasOwnProperty('score')) {
|
|
|
|
|
commit('setScore', rtn.score || 0);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
rtn && rtn.valid && commit('next');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 开始实训(模式变更和开始的混合操作)
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
startTraining: ({ commit }, opts) => {
|
|
|
|
|
commit('resetOrder');
|
|
|
|
|
commit('changeMode', opts.mode);
|
|
|
|
|
if (opts.start) {
|
|
|
|
|
// 清空计时器以及得分
|
2020-07-31 18:49:35 +08:00
|
|
|
|
// commit('stopCountTime');
|
2019-11-07 15:20:39 +08:00
|
|
|
|
commit('resetUsedTime');
|
|
|
|
|
commit('resetScore');
|
|
|
|
|
// 开始实训
|
|
|
|
|
commit('start');
|
|
|
|
|
commit('next');
|
2020-07-31 18:49:35 +08:00
|
|
|
|
// // 开始计时
|
|
|
|
|
// commit('countUsedTime');
|
2019-11-07 15:20:39 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2020-08-03 10:53:44 +08:00
|
|
|
|
// 计时(教学正计时与仿真当前时间)
|
|
|
|
|
countTime({ commit }, type) {
|
|
|
|
|
commit('countTime', type);
|
2020-07-31 18:49:35 +08:00
|
|
|
|
},
|
2019-11-07 15:20:39 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 开始实训(模式变更和开始的混合操作)
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
backSteps: ({ commit }, stepNum) => {
|
|
|
|
|
if (Number.isInteger) {
|
|
|
|
|
commit('backOrder', stepNum);
|
|
|
|
|
}
|
|
|
|
|
},
|
2019-07-25 10:58:17 +08:00
|
|
|
|
|
2019-11-07 15:20:39 +08:00
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 下一步
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
next: ({ commit, state }, operate) => {
|
|
|
|
|
commit('setOperate', operate);
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
if (!state.started && !state.mode) {
|
|
|
|
|
commit('setOperateErrMsg', { errMsg: LangStorage.getLang() == 'en' ? 'Please click start, start training!' : '请点击开始,开始实训!', color: 'red' });
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 处理operation
|
|
|
|
|
OperateHandler.handle(operate).then(rtn => {
|
|
|
|
|
if (state.started) {
|
|
|
|
|
// 教学和联系模式需要给出过程步骤提示
|
|
|
|
|
if (TrainingMode.TEACH === state.mode || TrainingMode.PRACTICE === state.mode) {
|
|
|
|
|
if (rtn && rtn.valid) {
|
|
|
|
|
commit('next');
|
|
|
|
|
commit('setOperateErrMsg', { errMsg: LangStorage.getLang() == 'en' ? "Correct operation! That's great!" : '操作正确!真棒!', color: 'green' });
|
|
|
|
|
commit('tipEventIncrement');
|
|
|
|
|
} else {
|
|
|
|
|
if (!operate.repeat) {
|
|
|
|
|
commit('setOperateErrMsg', { errMsg: LangStorage.getLang() == 'en' ? 'operation mistake!' : '操作错误!', color: 'red' });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (TrainingMode.EXAM === state.mode || TrainingMode.TEST === state.mode) {
|
|
|
|
|
// 测试和考试不给提示
|
|
|
|
|
rtn && rtn.valid && commit('next');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
resolve(rtn);
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
reject(error);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2019-12-31 17:20:04 +08:00
|
|
|
|
/**
|
|
|
|
|
* 下一步
|
|
|
|
|
*/
|
|
|
|
|
nextNew: ({ commit, state }, operate) => {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
commit('setOperate', operate);
|
|
|
|
|
if (!state.started && !state.mode) {
|
|
|
|
|
commit('setOperateErrMsg', { errMsg: LangStorage.getLang() == 'en' ? 'Please click start, start training!' : '请点击开始,开始实训!', color: 'red' });
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
2020-07-23 17:57:35 +08:00
|
|
|
|
// 处理operation
|
2019-12-31 17:20:04 +08:00
|
|
|
|
Handler.handle(operate).then(rtn => {
|
|
|
|
|
if (state.started) {
|
2020-08-28 14:43:30 +08:00
|
|
|
|
// 教学和联系模式需要给出过程步骤提示
|
2019-12-31 17:20:04 +08:00
|
|
|
|
if (TrainingMode.TEACH === state.mode || TrainingMode.PRACTICE === state.mode) {
|
|
|
|
|
if (rtn && rtn.valid) {
|
|
|
|
|
commit('next');
|
|
|
|
|
commit('setOperateErrMsg', { errMsg: LangStorage.getLang() == 'en' ? "Correct operation! That's great!" : '操作正确!真棒!', color: 'green' });
|
|
|
|
|
commit('tipEventIncrement');
|
|
|
|
|
} else {
|
|
|
|
|
if (!operate.repeat) {
|
|
|
|
|
commit('setOperateErrMsg', { errMsg: LangStorage.getLang() == 'en' ? 'operation mistake!' : '操作错误!', color: 'red' });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (TrainingMode.EXAM === state.mode || TrainingMode.TEST === state.mode) {
|
|
|
|
|
// 测试和考试不给提示
|
|
|
|
|
rtn && rtn.valid && commit('next');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
resolve(rtn);
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
console.error(error);
|
|
|
|
|
reject(error);
|
|
|
|
|
});
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(error);
|
|
|
|
|
reject(error);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2019-11-07 15:20:39 +08:00
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 提示消息重新加载
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
tipReload: ({ commit }) => {
|
|
|
|
|
commit('orderCountIncrement');
|
|
|
|
|
},
|
2019-07-25 10:58:17 +08:00
|
|
|
|
|
2019-11-07 15:20:39 +08:00
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 更新偏移位置车站
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
updateOffsetStationCode: ({ commit }, payLoad) => {
|
|
|
|
|
commit('setOffsetStationCode', payLoad.offsetStationCode);
|
|
|
|
|
},
|
2019-07-25 10:58:17 +08:00
|
|
|
|
|
2019-11-07 15:20:39 +08:00
|
|
|
|
/**
|
2020-07-27 18:04:47 +08:00
|
|
|
|
* 设置教学相关数据
|
2019-07-25 10:58:17 +08:00
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
setTrainingData: ({ commit }, trainingData) => {
|
|
|
|
|
const basicInfo = {
|
|
|
|
|
id: trainingData.id,
|
|
|
|
|
name: trainingData.name,
|
|
|
|
|
remarks: trainingData.remarks,
|
|
|
|
|
prdType: trainingData.prdType,
|
|
|
|
|
minDuration: trainingData.minDuration,
|
|
|
|
|
maxDuration: trainingData.maxDuration
|
|
|
|
|
};
|
|
|
|
|
commit('setBasicInfo', basicInfo);
|
|
|
|
|
const steps = trainingData.steps;
|
|
|
|
|
commit('setSteps', steps);
|
2020-07-30 18:42:41 +08:00
|
|
|
|
const offsetStationCode = trainingData.locateDeviceCode;
|
2019-11-07 15:20:39 +08:00
|
|
|
|
commit('setOffsetStationCode', offsetStationCode);
|
2020-08-31 14:14:45 +08:00
|
|
|
|
// commit('setMapDefaultState');
|
2019-11-07 15:20:39 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 设置步骤数据
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
setSteps: ({ commit }, steps) => {
|
|
|
|
|
commit('setSteps', steps);
|
|
|
|
|
},
|
2019-07-25 10:58:17 +08:00
|
|
|
|
|
2019-11-07 15:20:39 +08:00
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 添加步骤数据
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
addStep: ({ state, commit }, step) => {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
try {
|
|
|
|
|
var valid = true;
|
|
|
|
|
const steps = state.steps;
|
|
|
|
|
if (steps && steps.length > 0) {
|
|
|
|
|
const last = steps.length - 1;
|
|
|
|
|
if (steps[last].type === step.type &&
|
2019-07-25 10:58:17 +08:00
|
|
|
|
steps[last].code === step.code &&
|
|
|
|
|
steps[last].operation === step.operation) {
|
2019-11-07 15:20:39 +08:00
|
|
|
|
steps.splice(last, 1);
|
|
|
|
|
step.order = step.order - 1;
|
|
|
|
|
valid = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
commit('addStep', step);
|
|
|
|
|
resolve(valid);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
reject(error);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 设置地图默认状态
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
setMapDefaultState: ({ commit }) => {
|
|
|
|
|
commit('setMapDefaultState');
|
|
|
|
|
},
|
2019-07-25 10:58:17 +08:00
|
|
|
|
|
2019-11-07 15:20:39 +08:00
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 更新地图设备状态数据
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
updateMapState: ({ commit }, deviceStatus) => {
|
|
|
|
|
commit('updateMapState', deviceStatus);
|
|
|
|
|
},
|
2019-07-25 10:58:17 +08:00
|
|
|
|
|
2019-11-07 15:20:39 +08:00
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 开始教学模式
|
|
|
|
|
*/
|
2020-08-20 20:27:19 +08:00
|
|
|
|
teachModeStart: ({ dispatch }, mode) => {
|
|
|
|
|
const payLoad = { start: true, mode: mode };
|
2019-11-07 15:20:39 +08:00
|
|
|
|
dispatch('startTraining', payLoad);
|
|
|
|
|
},
|
2019-07-25 10:58:17 +08:00
|
|
|
|
|
2019-11-07 15:20:39 +08:00
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 开始考试模式
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
examModeStart: ({ dispatch }) => {
|
|
|
|
|
const payLoad = { start: true, mode: TrainingMode.EXAM };
|
|
|
|
|
dispatch('startTraining', payLoad);
|
|
|
|
|
},
|
2019-07-25 10:58:17 +08:00
|
|
|
|
|
2019-11-07 15:20:39 +08:00
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 仿真和大屏和计划模式
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
simulationStart: ({ dispatch }) => {
|
|
|
|
|
const payLoad = { start: true, mode: TrainingMode.NORMAL };
|
|
|
|
|
dispatch('startTraining', payLoad);
|
|
|
|
|
},
|
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 结束模式
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
end: ({ commit }, mode) => {
|
|
|
|
|
commit('over');
|
|
|
|
|
commit('resetOrder');
|
2020-07-31 18:49:35 +08:00
|
|
|
|
// commit('stopCountTime');
|
2019-11-07 15:20:39 +08:00
|
|
|
|
commit('changeMode', mode);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 是否教学模式
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
isTeachMode: ({ state }) => {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
if (state.mode === TrainingMode.TEACH) {
|
|
|
|
|
resolve();
|
|
|
|
|
} else {
|
|
|
|
|
reject(new Error('not teach mode'));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 设置用户得分
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
setScore: ({ commit }, score) => {
|
|
|
|
|
commit('setScore', score);
|
|
|
|
|
},
|
2019-07-25 10:58:17 +08:00
|
|
|
|
|
2019-11-07 15:20:39 +08:00
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 设置tip变化事件
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
emitTipFresh: ({ commit }) => {
|
|
|
|
|
commit('tipEventIncrement');
|
|
|
|
|
},
|
2019-07-25 10:58:17 +08:00
|
|
|
|
|
2019-11-07 15:20:39 +08:00
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 设置WebSocket链接状态
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
setConnected: ({ commit }, isConnected) => {
|
|
|
|
|
commit('setConnected', isConnected);
|
|
|
|
|
},
|
2019-07-25 10:58:17 +08:00
|
|
|
|
|
2019-11-07 15:20:39 +08:00
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 设置系统时间
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
setInitTime: ({ commit }, initTime) => {
|
|
|
|
|
commit('setInitTime', initTime);
|
|
|
|
|
},
|
2019-07-25 10:58:17 +08:00
|
|
|
|
|
2019-11-07 15:20:39 +08:00
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 设置产品类型
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
setPrdType: ({ commit }, prdType) => {
|
|
|
|
|
commit('setPrdType', prdType);
|
|
|
|
|
},
|
2019-07-25 10:58:17 +08:00
|
|
|
|
|
2019-11-07 15:20:39 +08:00
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 设置角色列表
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
setRoles: ({ commit }, roles) => {
|
|
|
|
|
commit('setRoles', roles);
|
|
|
|
|
},
|
2019-07-25 10:58:17 +08:00
|
|
|
|
|
2019-11-07 15:20:39 +08:00
|
|
|
|
/**
|
2019-07-25 10:58:17 +08:00
|
|
|
|
* 设置仿真组
|
|
|
|
|
*/
|
2019-11-07 15:20:39 +08:00
|
|
|
|
setGroup: ({ commit }, group) => {
|
|
|
|
|
commit('setGroup', group);
|
2020-04-13 14:54:35 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/** 设置当前居中的集中站code */
|
|
|
|
|
setCenterStationCode:({ commit }, centerStationCode) => {
|
|
|
|
|
commit('setCenterStationCode', centerStationCode);
|
2020-07-02 17:57:48 +08:00
|
|
|
|
},
|
|
|
|
|
/** 设置综合演练仿真成员列表 */
|
2020-07-06 18:00:44 +08:00
|
|
|
|
setMemberList: ({ commit }, data) => {
|
|
|
|
|
commit('setMemberList', data);
|
2020-07-02 17:57:48 +08:00
|
|
|
|
},
|
|
|
|
|
/** 设置综合演练仿真用户列表 */
|
|
|
|
|
setSimulationUserList: ({ commit }, simulationUserList) => {
|
|
|
|
|
commit('setSimulationUserList', simulationUserList);
|
|
|
|
|
},
|
2020-07-14 15:03:31 +08:00
|
|
|
|
updateMemberTrust:({ commit }, data) => {
|
|
|
|
|
commit('updateMemberTrust', data);
|
|
|
|
|
},
|
2020-07-02 17:57:48 +08:00
|
|
|
|
/** 更新综合演练仿真成员和用户列表 */
|
2020-07-06 18:00:44 +08:00
|
|
|
|
updateMemberAndUser: ({ commit }, data) => {
|
|
|
|
|
commit('updateMemberAndUser', data);
|
2020-07-10 16:40:42 +08:00
|
|
|
|
},
|
|
|
|
|
/** 更新剧本所有成员列表 */
|
|
|
|
|
updateMemberListInScript:({ commit }, data) => {
|
|
|
|
|
commit('updateMemberListInScript', data);
|
2020-08-06 19:34:13 +08:00
|
|
|
|
},
|
|
|
|
|
/** 更新当前角色的deviceCode */
|
|
|
|
|
setRoleDeviceCode:({ commit }, roleDeviceCode) => {
|
|
|
|
|
commit('setRoleDeviceCode', roleDeviceCode);
|
2020-08-17 19:11:59 +08:00
|
|
|
|
},
|
2020-09-11 09:26:51 +08:00
|
|
|
|
/** 剧本仿真 主动退出*/
|
|
|
|
|
setScriptQuit:({ commit }) => {
|
|
|
|
|
commit('setScriptQuit');
|
|
|
|
|
},
|
2020-08-21 15:41:46 +08:00
|
|
|
|
/** 剧本仿真 设置旧的角色的id */
|
|
|
|
|
setOrignalUserRoleId:({ commit }, data) => {
|
|
|
|
|
commit('setOrignalUserRoleId', data);
|
2020-09-16 10:49:16 +08:00
|
|
|
|
},
|
|
|
|
|
/** 操作剧本类型(教学、练习、考试)*/
|
|
|
|
|
setScriptOperationType: ({ commit }, data) => {
|
|
|
|
|
commit('setScriptOperationType', data);
|
2020-10-12 14:25:33 +08:00
|
|
|
|
},
|
|
|
|
|
/** 触发故障计数器 */
|
|
|
|
|
setTriggerFaultCount: ({ commit }, device) => {
|
|
|
|
|
commit('setTriggerFaultCount', device);
|
2019-11-07 15:20:39 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-25 10:58:17 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default training;
|