代码调整

This commit is contained in:
joylink_cuiweidong 2020-07-29 13:56:50 +08:00
parent edc9f4601c
commit c3e6cf2b56
2 changed files with 82 additions and 50 deletions

View File

@ -59,7 +59,9 @@
</template>
<script>
import { MapDeviceType, OperationEvent } from '@/scripts/ConstDic';
import {OperationEvent } from '@/scripts/ConstDic';
import {SimulationType} from '@/scripts/ConstDic';
import CMD from '@/scripts/cmdPlugin/CommandEnum';
import NoticeInfo from '@/jmapNew/theme/components/menus/childDialog/noticeInfo';
export default {
@ -74,8 +76,8 @@ export default {
disabledRefuse: false,
requestInfo: '调度员1工作站',
controlProps: {
'01': '中控',
'02': '站控'
'Center': this.$t('menu.passiveDialog.inTheControl'),
'Local': this.$t('menu.passiveDialog.stationControl')
},
selection: [],
tableData: [],
@ -87,10 +89,10 @@ export default {
computed: {
targetStatus() {
if (this.$store.state.training.prdType == '01') {
return '01';
return 'Center';
}
if (this.$store.state.training.prdType == '02') {
return '02';
return 'Local';
}
return '';
},
@ -115,9 +117,10 @@ export default {
deep: true
},
'$store.state.socket.msgHead': function (elem) {
if (elem && !elem.hasOwnProperty('success') && !elem.hasOwnProperty('timeout')) {
if (elem.stationControlCode) {
if (elem && (elem.operateType == 'CM_Apply_For_Station_Control' || elem.operateType == 'CM_Apply_For_Center_Control')) {
if (elem.params.stationCodes && elem.params.stationCodes.length) {
this.doShow(elem);
this.sourceMemberId = elem.sourceMemberId;
}
}
}
@ -161,48 +164,60 @@ export default {
this.disabledAgree = this.selection.length <= 0;
}
},
updateTableData(code) {
updateTableData(codes) {
this.tableData = [];
(codes || []).forEach(code=> {
const model = {
code: code,
operate: '',
control: { code: '', name: '' },
target: { code: '', name: '' },
agree: false,
disabled: false
};
const model = {
code: code,
operate: '',
control: { code: '', name: '' },
target: { code: '', name: '' },
agree: false,
disabled: false
};
const device = this.$store.getters['map/getDeviceByCode'](code);
if (device) {
const control = (device || {}).state;
if (control) {
model.control = { status: control.status, name: this.controlProps[control.status] };
model.target = { status: this.targetStatus, name: this.controlProps[this.targetStatus] };
const device = this.$store.getters['map/getDeviceByCode'](code);
if (device) {
const control = (device || {}).controlMode;
if (control) {
model.control = { status: control, name: this.controlProps[control] };
model.target = { status: this.targetStatus, name: this.controlProps[this.targetStatus] };
}
model.operate = device.name || '';
}
const station = this.$store.getters['map/getDeviceByCode'](device.stationCode);
if (station) {
model.operate = station.name || '';
}
}
this.tableData.push(model);
this.tableData.push(model);
});
},
doShow(msgHead) {
const member = this.$store.state.training.memberData[msgHead.sourceMemberId];
const simulationUserList = this.$store.state.training.simulationUserList;
if (member) {
let info = SimulationType[member.type];
if (member.deviceCode) {
const device = this.$store.getters['map/getDeviceByCode'](member.deviceCode);
info = info + `(${device.name})`;
}
if (member.userId) {
simulationUserList.forEach(item => {
if (item.userId === member.userId) {
info = info + '-' + item.nickName;
}
});
}
this.requestInfo = info;
}
this.dialogShow = true;
this.disabledAgree = true;
this.createTimer();
this.updateTableData(msgHead.stationControlCode);
this.updateTableData(msgHead.params.stationCodes);
const operate = {
start: true,
type: MapDeviceType.StationControl.type,
operation: OperationEvent.StationControl.controlResponse.menu.operation
};
this.$store.dispatch('training/emitTipFresh');
this.$store.dispatch('training/next', operate).then(({ valid }) => {
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
}
@ -234,7 +249,6 @@ export default {
this.selection = selection;
if (selection && selection.length) {
const operate = {
type: MapDeviceType.StationControl.type,
operation: OperationEvent.StationControl.controlResponse.choose.operation,
val: this.serializeCodeListWithSeparator('::')
};
@ -249,18 +263,27 @@ export default {
}
},
agree() {
const stationCodes = [];
this.tableData.forEach(item => {
if (item.agree) {
stationCodes.push(item.code);
}
});
const operate = {
send: true,
over: true,
type: MapDeviceType.StationControl.type,
start: true,
operation: OperationEvent.StationControl.controlResponse.agree.operation,
val: this.selection[0].code,
prdType: this.$store.state.training.prdType
send: true,
cmdType: this.$store.state.training.prdType == '01' ? CMD.ControlConvertMenu.CMD_CM_REPLY_CENTER_CONTROL : CMD.ControlConvertMenu.CMD_CM_REPLY_STATION_CONTROL,
param: {
sourceMemberId: this.sourceMemberId,
stationCodes: stationCodes,
agree: true
}
};
this.clearTimer();
this.disabledAgree = true;
this.$store.dispatch('training/next', operate).then(({ valid }) => {
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
this.doClose();
@ -270,18 +293,27 @@ export default {
});
},
refuse() {
const stationCodes = [];
this.tableData.forEach(item => {
if (item.agree) {
stationCodes.push(item.code);
}
});
const operate = {
send: true,
over: true,
type: MapDeviceType.StationControl.type,
start: true,
operation: OperationEvent.StationControl.controlResponse.refuse.operation,
val: this.tableData[0].code,
prdType: this.$store.state.training.prdType
send: true,
cmdType: this.$store.state.training.prdType == '01' ? CMD.ControlConvertMenu.CMD_CM_REPLY_CENTER_CONTROL : CMD.ControlConvertMenu.CMD_CM_REPLY_STATION_CONTROL,
param: {
sourceMemberId: this.sourceMemberId,
stationCodes: stationCodes,
agree: false
}
};
this.clearTimer();
this.disabledAgree = true;
this.$store.dispatch('training/next', operate).then(({ valid }) => {
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
if (valid) {
this.doClose();
}

View File

@ -59,9 +59,9 @@ export default {
/** 回复站控请求(同意/拒绝) */
CMD_CM_REPLY_STATION_CONTROL: {value:'CM_Reply_Station_Control', label: '回复站控请求'},
/** 回复中控请求(同意/拒绝) */
CMD_CM_REPLY_CENTER_CONTROL: {value:'CM_Reply_Center_Control', label: '回复中控请求'},
CMD_CM_RECEIVE_CONTROL: {value:'CM_Receive_Control', label: '接收控制'},
CMD_CM_SURRENDER_CONTROL: {value:'CM_Surrender_Control', label: '交出控制'},
CMD_CM_REPLY_CENTER_CONTROL: {value:'CM_Reply_Center_Control', label: '回复中控请求'},
CMD_CM_RECEIVE_CONTROL: {value:'CM_Receive_Control', label: '接收控制'},
CMD_CM_SURRENDER_CONTROL: {value:'CM_Surrender_Control', label: '交出控制'}
},
// 司机操作