Merge branch 'dev' of https://git.qcloud.com/joylink/jl-nclient into dev
This commit is contained in:
commit
c264b61f65
@ -3,6 +3,6 @@ import OperateHandler2 from './OperateHandler2.js';
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
const OPERATEHANDLER_KEY = 'OperateHandler';
|
||||
Cookies.set(OPERATEHANDLER_KEY, 1);
|
||||
Cookies.set(OPERATEHANDLER_KEY, '');
|
||||
|
||||
export default Cookies.get(OPERATEHANDLER_KEY) ? OperateHandler1 : OperateHandler2;
|
||||
|
@ -1,11 +1,9 @@
|
||||
import store from '@/store';
|
||||
import router from '@/router';
|
||||
import CommandHandler from './CommandHandler.js';
|
||||
import { TrainingMode } from '@/scripts/ConstDic';
|
||||
import ValidateHandler from './ValidateHandler.js';
|
||||
import { sendTrainingNextStep } from '@/api/jmap/training';
|
||||
import { Message } from 'element-ui';
|
||||
import { OperationEvent } from '@/scripts/ConstDic';
|
||||
import LangStorage from '@/utils/lang';
|
||||
|
||||
class OperateHandler {
|
||||
constructor() {
|
||||
@ -22,24 +20,6 @@ class OperateHandler {
|
||||
this.operates.splice(0, this.operates.length);
|
||||
}
|
||||
|
||||
/** 判断操作步骤是否正确 */
|
||||
judge (operate) {
|
||||
const steps = this.getSteps();
|
||||
const order = this.getOrder();
|
||||
|
||||
let valid = false;
|
||||
if (order < steps.length) {
|
||||
const standard = steps[order];
|
||||
if (operate && standard && operate.code == standard.code && operate.type == standard.type &&
|
||||
operate.operation == standard.operation &&
|
||||
operate.val == standard.val) {
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
getCommand(operate) {
|
||||
let command = null;
|
||||
if (operate.send) {
|
||||
@ -63,8 +43,11 @@ class OperateHandler {
|
||||
return command;
|
||||
}
|
||||
|
||||
/** 步骤前处理*/
|
||||
preProcessor(operate) {
|
||||
execute(command) {
|
||||
return CommandHandler.execute(command);
|
||||
}
|
||||
|
||||
storeOperate(operate) {
|
||||
// 按钮操作之后,第二步错误操作菜单的情况,需要直接返回
|
||||
if ((this.operates.length && operate.start === true) && (this.operates[0].type === 'mbm')) {
|
||||
return false;
|
||||
@ -79,8 +62,7 @@ class OperateHandler {
|
||||
this.operates.push(operate);
|
||||
}
|
||||
|
||||
/** 步骤后处理*/
|
||||
postProcessor(operate, valid) {
|
||||
afterAalid(operate, valid) {
|
||||
const basicInfo = store.getters['training/basicInfo'];
|
||||
if (basicInfo.id && valid) {
|
||||
// 发送记录步骤数据
|
||||
@ -97,48 +79,16 @@ class OperateHandler {
|
||||
}
|
||||
}
|
||||
|
||||
/** 根据模式验证操作步骤 */
|
||||
validate(operate) {
|
||||
this.preProcessor(operate);
|
||||
|
||||
let valid = true;
|
||||
if (TrainingMode.EDIT === this.getTrainingMode()) {
|
||||
// 编辑制作模式
|
||||
if (this.getOperateBreakStatus()) {
|
||||
valid = false;
|
||||
const tip = LangStorage.getLang() == 'en' ? 'Please enter a hint and click next' : '请输入提示并点击下一步';
|
||||
Message.error(tip);
|
||||
this.operates.pop();
|
||||
return valid;
|
||||
}
|
||||
|
||||
if (this.getTrainingStart()) {
|
||||
store.dispatch('training/setTempStep', operate);
|
||||
}
|
||||
|
||||
} else if (TrainingMode.TEACH === this.getTrainingMode() || TrainingMode.PRACTICE === this.getTrainingMode()) {
|
||||
// 教学模式/练习模式
|
||||
if (this.getTrainingStart()) {
|
||||
valid = this.judge(operate);
|
||||
} else {
|
||||
this.cleanOperates();
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
this.postProcessor(operate, valid);
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
handle(operate) {
|
||||
this.storeOperate(operate);
|
||||
return new Promise((resolve, reject) => {
|
||||
const rtn = { valid: false, response: null };
|
||||
const valid = this.validate(operate);
|
||||
const valid = ValidateHandler.vaildate(this.getTrainingMode(), operate);
|
||||
const command = this.getCommand(operate);
|
||||
|
||||
rtn.valid = valid;
|
||||
|
||||
this.afterAalid(operate, valid);
|
||||
|
||||
if (valid && command) {
|
||||
CommandHandler.execute(command).then(response => {
|
||||
rtn.response = response;
|
||||
@ -152,10 +102,6 @@ class OperateHandler {
|
||||
});
|
||||
}
|
||||
|
||||
getTrainingMode () {
|
||||
return store.state.training.mode;
|
||||
}
|
||||
|
||||
getSteps() {
|
||||
return store.state.training.steps;
|
||||
}
|
||||
@ -164,6 +110,10 @@ class OperateHandler {
|
||||
return store.state.training.order;
|
||||
}
|
||||
|
||||
getTrainingMode () {
|
||||
return store.state.training.mode;
|
||||
}
|
||||
|
||||
getTrainingStart() {
|
||||
return store.state.training.started;
|
||||
}
|
||||
|
71
src/scripts/plugin/ValidateHandler.js
Normal file
71
src/scripts/plugin/ValidateHandler.js
Normal file
@ -0,0 +1,71 @@
|
||||
import store from '@/store';
|
||||
import LangStorage from '@/utils/lang';
|
||||
import OperateHandler from './OperateHandler.js';
|
||||
import { TrainingMode } from '@/scripts/ConstDic';
|
||||
import { Message } from 'element-ui';
|
||||
|
||||
class ValidateHandler {
|
||||
vaildate(mode, operate) {
|
||||
switch (mode) {
|
||||
case TrainingMode.EDIT: // 编辑制作模式
|
||||
return this.vaildate_edit(operate);
|
||||
case TrainingMode.PRACTICE: // 练习模式
|
||||
return this.vaildate_tips(operate);
|
||||
case TrainingMode.TEACH: // 教学模式
|
||||
return this.vaildate_tips(operate);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
vaildate_edit(operate) {
|
||||
let vaild = true;
|
||||
if (OperateHandler.getOperateBreakStatus()) {
|
||||
const tip = LangStorage.getLang() == 'en' ? 'Please enter a hint and click next' : '请输入提示并点击下一步';
|
||||
Message.error(tip);
|
||||
OperateHandler.operates.pop();
|
||||
vaild = false;
|
||||
}
|
||||
|
||||
if (OperateHandler.getTrainingStart()) {
|
||||
store.dispatch('training/setTempStep', operate);
|
||||
}
|
||||
|
||||
return vaild;
|
||||
}
|
||||
|
||||
vaildate_tips(operate) {
|
||||
let valid = true;
|
||||
if (OperateHandler.getTrainingStart()) {
|
||||
valid = this.judge(operate);
|
||||
} else {
|
||||
OperateHandler.cleanOperates();
|
||||
valid = false;
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
/** 判断操作步骤是否正确 */
|
||||
judge (operate) {
|
||||
const steps = OperateHandler.getSteps();
|
||||
const order = OperateHandler.getOrder();
|
||||
|
||||
let valid = false;
|
||||
if (order < steps.length) {
|
||||
const standard = steps[order];
|
||||
if (operate && standard &&
|
||||
operate.code == standard.code &&
|
||||
operate.type == standard.type &&
|
||||
operate.operation == standard.operation &&
|
||||
operate.val == standard.val) {
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default new ValidateHandler();
|
@ -13,20 +13,6 @@
|
||||
<el-button type="text" class="mapEdit_box" @click="showMap">{{ $t('map.viewLayer') }}</el-button>
|
||||
</div>
|
||||
<el-tabs v-model="enabledTab" type="card" class="map_card" @tab-click="changePane">
|
||||
<el-tab-pane label="站台屏蔽门" class="tab_pane_box" name="safetyDoor">
|
||||
<safety-door-operate
|
||||
ref="routeOperate"
|
||||
:map-info="mapInfo"
|
||||
:selected="selected"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="站台紧急停车按钮" class="tab_pane_box" name="park">
|
||||
<park-operate
|
||||
ref="routeOperate"
|
||||
:map-info="mapInfo"
|
||||
:selected="selected"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('map.routeID')" class="tab_pane_box" name="route">
|
||||
<route-operate
|
||||
ref="routeOperate"
|
||||
@ -67,6 +53,20 @@
|
||||
@setCenter="setCenter"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="站台屏蔽门" class="tab_pane_box" name="safetyDoor">
|
||||
<safety-door-operate
|
||||
ref="routeOperate"
|
||||
:map-info="mapInfo"
|
||||
:selected="selected"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="站台紧急停车按钮" class="tab_pane_box" name="park">
|
||||
<park-operate
|
||||
ref="routeOperate"
|
||||
:map-info="mapInfo"
|
||||
:selected="selected"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -197,12 +197,12 @@ export default {
|
||||
return option.label;
|
||||
} else if (label == 'name&&code') {
|
||||
if (option.code) {
|
||||
return option.name + ' (' + option.code+ ')';
|
||||
return option.name + ' (' + option.code + ')';
|
||||
} else {
|
||||
return option.name;
|
||||
}
|
||||
} else if (label == 'code&&name') {
|
||||
return option.code + ' (' + option.name+ ')';
|
||||
return option.code + ' (' + option.name + ')';
|
||||
} else {
|
||||
return option.label;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@
|
||||
<template v-if="checkFieldType(item, 'number')">
|
||||
<el-form-item v-if="!item.isHidden" :key="item.prop" :label="item.label" :prop="item.prop" :required="item.required">
|
||||
<div v-if="!item.firstLevel">
|
||||
<el-input-number v-model="formModel[item.prop]" :min="item.min" :max="item.max" :label="item.label" :disabled="item.disabled" />
|
||||
<el-input-number v-model="formModel[item.prop]" :min="item.min" :max="item.max" :label="item.label" :disabled="item.disabled" style="width: 140px" />
|
||||
<span style="padding-left: 1px;">{{ item.placeholder }}</span>
|
||||
</div>
|
||||
<div v-else>
|
||||
@ -212,12 +212,12 @@ export default {
|
||||
return option.label;
|
||||
} else if (label == 'name&&code') {
|
||||
if (option.code) {
|
||||
return option.name + ' (' + option.code+ ')';
|
||||
return option.name + ' (' + option.code + ')';
|
||||
} else {
|
||||
return option.name;
|
||||
}
|
||||
} else if (label == 'code&&name') {
|
||||
return option.code + ' (' + option.name+ ')';
|
||||
return option.code + ' (' + option.name + ')';
|
||||
} else {
|
||||
return option.label;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user