代码调整
This commit is contained in:
parent
9e9e7dbed3
commit
fda52feb52
326
src/jmapNew/theme/components/menus/passiveDialog/control.vue
Normal file
326
src/jmapNew/theme/components/menus/passiveDialog/control.vue
Normal file
@ -0,0 +1,326 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-dialogDrag
|
||||
:class="popClass+' passive-control'"
|
||||
title="控制模式请求"
|
||||
:visible.sync="show"
|
||||
width="700px"
|
||||
:before-close="doClose"
|
||||
:show-close="true"
|
||||
:z-index="2000"
|
||||
:modal="false"
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<span class="control-label">{{ `${requestInfo}请求如下区域的控制模式` }}</span>
|
||||
<el-table
|
||||
ref="multipleTable"
|
||||
:data="tableData"
|
||||
border
|
||||
row-key="code"
|
||||
style="width: 100%"
|
||||
height="250"
|
||||
center
|
||||
size="mini"
|
||||
highlight-current-row
|
||||
>
|
||||
<el-table-column prop="operate" label="操作区域">
|
||||
<template slot-scope="scope">
|
||||
<span :style="{color: scope.row.disabled ? '#CBCBCB':'unset'}">{{ scope.row.operate }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="control" label="当前控制模式" width="120">
|
||||
<template slot-scope="scope">
|
||||
<span :style="{color: scope.row.disabled ? '#CBCBCB':'unset'}">{{ scope.row.control.name }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="target" label="请求控制模式" width="120">
|
||||
<template slot-scope="scope">
|
||||
<span :style="{color: scope.row.disabled ? '#CBCBCB':'unset'}">{{ scope.row.target.name }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="agree" label="是否同意" width="140">
|
||||
<template slot-scope="scope">
|
||||
<el-checkbox ref="agree" v-model="scope.row.agree" :disabled="scope.row.disabled" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<span class="control-label">距离对话还有{{ count }}秒,请应答。</span>
|
||||
<el-row class="button-group">
|
||||
<el-col :span="10" :offset="3">
|
||||
<el-button :id="domAgree" :disabled="disabledAgree" @click="agree">同意
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="6" :offset="4">
|
||||
<el-button :id="domIdRefuse" :disabled="disabledRefuse" @click="refuse">拒绝</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<!-- ningbo-01__systerm -->
|
||||
<notice-info ref="noticeInfo" :pop-class="popClass" />
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {OperationEvent } from '@/scripts/ConstDic';
|
||||
import {SimulationType} from '@/scripts/ConstDic';
|
||||
import CMD from '@/scripts/cmdPlugin/CommandEnum';
|
||||
import NoticeInfo from '../childDialog/noticeInfo';
|
||||
|
||||
export default {
|
||||
name: 'RequestControl',
|
||||
components: {
|
||||
NoticeInfo
|
||||
},
|
||||
props: {
|
||||
popClass: {
|
||||
type: String,
|
||||
default() {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogShow: false,
|
||||
disabledAgree: false,
|
||||
disabledRefuse: false,
|
||||
requestInfo: '调度员1工作站',
|
||||
controlProps: {
|
||||
'Center': this.$t('menu.passiveDialog.inTheControl'),
|
||||
'Local': this.$t('menu.passiveDialog.stationControl'),
|
||||
'Emergency':this.$t('menu.passiveDialog.emergencyControl')
|
||||
},
|
||||
selection: [],
|
||||
tableData: [],
|
||||
timer: null,
|
||||
timeout: 61,
|
||||
count: 0,
|
||||
targetStatus:''
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
show() {
|
||||
return this.dialogShow && !this.$store.state.menuOperation.break;
|
||||
},
|
||||
domIdChoose() {
|
||||
return this.dialogShow ? OperationEvent.StationControl.controlResponse.choose.domId : '';
|
||||
},
|
||||
domAgree() {
|
||||
return this.dialogShow ? OperationEvent.StationControl.controlResponse.agree.domId : '';
|
||||
},
|
||||
domIdRefuse() {
|
||||
return this.dialogShow ? OperationEvent.StationControl.controlResponse.refuse.domId : '';
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
tableData: {
|
||||
handler(val, oldVal) {
|
||||
this.checkTableDataSelction(val);
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
'$store.state.map.controlTransfer':function (elem) {
|
||||
this.doShow(elem);
|
||||
},
|
||||
'$store.state.map.keyboardEnterCount': function (val) {
|
||||
if (this.show && !this.disabledAgree) {
|
||||
this.agree();
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$nextTick(() => {
|
||||
this.$store.dispatch('training/tipReload');
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
checkTableDataSelction(data) {
|
||||
const selection = [];
|
||||
if (data && data.length > 0) {
|
||||
data.forEach(row => {
|
||||
if (row.agree && !row.disabled) {
|
||||
selection.push(row);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.disabledSend = !selection.length;
|
||||
// JSON.stringify(selection) !== JSON.stringify(this.selection)
|
||||
let result = false;
|
||||
selection.forEach(select=>{
|
||||
if (select.control.status != select.target.status) {
|
||||
result = result || true;
|
||||
}
|
||||
});
|
||||
if (result) {
|
||||
this.handleChooseChange(selection);
|
||||
this.selection = selection;
|
||||
this.disabledAgree = this.selection.length <= 0;
|
||||
}
|
||||
},
|
||||
updateTableData(controlTransfer) {
|
||||
const code = controlTransfer.code;
|
||||
const device = this.$store.getters['map/getDeviceByCode'](code);
|
||||
this.tableData = [];
|
||||
const model = {
|
||||
code: code,
|
||||
operate: '',
|
||||
control: { code: '', name: '' },
|
||||
target: { code: '', name: '' },
|
||||
agree: true,
|
||||
disabled: false
|
||||
};
|
||||
if (device) {
|
||||
const control = (device || {}).controlMode;
|
||||
if (control) {
|
||||
model.control = { status: control, name: this.controlProps[control] };
|
||||
this.targetStatus = controlTransfer.apply2TheControlMode;
|
||||
model.target = { status: this.targetStatus, name: this.controlProps[this.targetStatus] };
|
||||
}
|
||||
model.operate = device.name || '';
|
||||
}
|
||||
this.tableData.push(model);
|
||||
},
|
||||
doShow(controlTransfer) {
|
||||
if (controlTransfer.applicantIdOfControlTransfer) {
|
||||
const member = this.$store.state.training.memberData[controlTransfer.applicantIdOfControlTransfer];
|
||||
const simulationUserList = this.$store.state.training.simulationUserList;
|
||||
// 不给自己弹窗,如果申请人是行值的话,只允许给所有行调弹窗,如果申请人是行调的话,只给特定的行值弹窗
|
||||
if (member && member.userId != this.$store.state.user.id &&
|
||||
((member.type == 'STATION_SUPERVISOR' && this.$store.state.training.roles == 'DISPATCHER') ||
|
||||
(member.type == 'DISPATCHER' && this.$store.state.training.roleDeviceCode == controlTransfer.code))) {
|
||||
if (!this.dialogShow) {
|
||||
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;
|
||||
}
|
||||
});
|
||||
}
|
||||
// 后端倒计时
|
||||
if (controlTransfer.validDurationOfControlTransferApplication) {
|
||||
this.count = controlTransfer.validDurationOfControlTransferApplication;
|
||||
this.dialogShow = true;
|
||||
this.requestInfo = info;
|
||||
this.disabledAgree = true;
|
||||
this.updateTableData(controlTransfer);
|
||||
const operate = {
|
||||
start: true,
|
||||
operation: OperationEvent.StationControl.controlResponse.menu.operation
|
||||
};
|
||||
this.$store.dispatch('training/emitTipFresh');
|
||||
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
|
||||
if (valid) {
|
||||
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// 后端倒计时
|
||||
this.count = controlTransfer.validDurationOfControlTransferApplication;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.doClose();
|
||||
}
|
||||
},
|
||||
doClose() {
|
||||
this.disabledAgree = false;
|
||||
this.count = 0;
|
||||
this.dialogShow = false;
|
||||
this.$store.dispatch('training/emitTipFresh');
|
||||
// this.$refs.multipleTable.setCurrentRow();
|
||||
},
|
||||
serializeCodeListWithSeparator(sep) {
|
||||
const codeList = [];
|
||||
if (this.selection && this.selection.length) {
|
||||
this.selection.forEach(elem => {
|
||||
codeList.push(elem.code);
|
||||
});
|
||||
}
|
||||
return codeList.join(sep);
|
||||
},
|
||||
handleChooseChange(selection) {
|
||||
this.selection = selection;
|
||||
if (selection && selection.length) {
|
||||
const operate = {
|
||||
operation: OperationEvent.StationControl.controlResponse.choose.operation,
|
||||
val: this.serializeCodeListWithSeparator('::')
|
||||
};
|
||||
|
||||
this.$store.dispatch('training/next', operate).then(({ valid }) => {
|
||||
if (valid) {
|
||||
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
|
||||
}
|
||||
});
|
||||
} else if (!selection) {
|
||||
this.$messageBox('请选择一条数据');
|
||||
}
|
||||
},
|
||||
agree() {
|
||||
const replyVOList = [];
|
||||
this.tableData.forEach(item => {
|
||||
if (item.agree) {
|
||||
replyVOList.push({stationCode:item.code, agree:true });
|
||||
}
|
||||
});
|
||||
const operate = {
|
||||
start: true,
|
||||
operation: OperationEvent.StationControl.controlResponse.agree.operation,
|
||||
send: true,
|
||||
cmdType: this.targetStatus == 'Center' ? CMD.ControlConvertMenu.CMD_CM_REPLY_CENTER_CONTROL : CMD.ControlConvertMenu.CMD_CM_REPLY_STATION_CONTROL,
|
||||
param: {
|
||||
replyVOList: replyVOList
|
||||
}
|
||||
};
|
||||
|
||||
this.disabledAgree = true;
|
||||
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
|
||||
if (valid) {
|
||||
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
|
||||
this.doClose();
|
||||
}
|
||||
}).catch(() => {
|
||||
this.$refs.noticeInfo.doShow();
|
||||
});
|
||||
},
|
||||
refuse() {
|
||||
const replyVOList = [];
|
||||
this.tableData.forEach(item => {
|
||||
if (item.agree) {
|
||||
replyVOList.push({stationCode:item.code, agree:false });
|
||||
}
|
||||
});
|
||||
const operate = {
|
||||
start: true,
|
||||
operation: OperationEvent.StationControl.controlResponse.refuse.operation,
|
||||
send: true,
|
||||
cmdType: this.targetStatus == 'Center' ? CMD.ControlConvertMenu.CMD_CM_REPLY_CENTER_CONTROL : CMD.ControlConvertMenu.CMD_CM_REPLY_STATION_CONTROL,
|
||||
param: {
|
||||
replyVOList: replyVOList
|
||||
}
|
||||
};
|
||||
this.disabledAgree = true;
|
||||
this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
|
||||
if (valid) {
|
||||
this.doClose();
|
||||
}
|
||||
}).catch(() => {
|
||||
this.$refs.noticeInfo.doShow();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
@import "src/styles/mixin.scss";
|
||||
|
||||
.control-label {
|
||||
line-height: 30px;
|
||||
font-size: 18px;
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue
Block a user