rt-sim-training-client/src/views/planMonitor/editTool/menus/addTask.vue

440 lines
19 KiB
Vue
Raw Normal View History

2019-07-26 13:32:43 +08:00
<template>
2019-08-09 18:29:08 +08:00
<el-dialog
v-dialogDrag
class="planEdit__tool add-task"
:title="title"
:visible.sync="dialogShow"
width="880px"
2019-08-09 18:29:08 +08:00
:before-close="doClose"
:z-index="2000"
top="50px"
2019-08-09 18:29:08 +08:00
:modal="false"
:close-on-click-modal="false"
>
2019-09-17 13:16:49 +08:00
<el-row>
<el-col :span="3" style="height: 28px;line-height: 28px;">
2020-10-20 17:21:02 +08:00
<el-radio v-model="addModel.forward" :label="true">{{ $t('planMonitor.addToTheFront') }}</el-radio>
2019-09-17 13:16:49 +08:00
</el-col>
<el-col :span="3" style="margin-left: 10px;height: 28px;line-height: 28px;">
<span>{{ $t('planMonitor.tripNumber')+$t('global.colon') }}</span>
2019-09-17 13:16:49 +08:00
</el-col>
<el-col :span="5">
2019-09-19 16:12:05 +08:00
<el-select v-model="addModel.tripNumber" size="mini" :placeholder="this.$t('global.choose')">
2019-09-17 13:16:49 +08:00
<el-option
v-for="item in tripNumberList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-col>
<el-col :span="3" style="margin-left: 20px;height: 28px;line-height: 28px;">
<span>{{ $t('global.startTime')+$t('global.colon') }}</span>
2019-09-17 13:16:49 +08:00
</el-col>
<el-col :span="5">
<el-time-picker v-model="addModel.startTime" size="mini" value-format="HH:mm:ss" :clearable="false" />
</el-col>
</el-row>
<el-row style="margin-top: 5px;height: 28px;line-height: 28px;">
<el-col :span="3">
2020-10-20 17:21:02 +08:00
<el-radio v-model="addModel.forward" :label="false">{{ $t('planMonitor.addToTheEnd') }}</el-radio>
2019-09-17 13:16:49 +08:00
</el-col>
<el-col :span="3" style="margin-left: 10px;height: 28px;line-height: 28px;">
<span>{{ $t('planMonitor.defaultStopTime') }}</span>
2019-09-17 13:16:49 +08:00
</el-col>
<el-col :span="5">
2020-10-21 11:07:10 +08:00
<el-input-number v-model="defaultStopTime" placeholder="请输入时间" size="mini" :controls="false" :min="0" />
<!-- <el-select v-model="defaultStopTime" size="mini" :placeholder="this.$t('global.choose')">
2019-09-17 13:16:49 +08:00
<el-option
v-for="item in defaultStopTimeList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
2020-10-21 11:07:10 +08:00
</el-select> -->
2019-09-17 13:16:49 +08:00
</el-col>
<el-col :span="3" style="margin-left: 20px;height: 28px;line-height: 28px;">
<span>{{ $t('planMonitor.defaultRunLevel') }}</span>
2019-09-17 13:16:49 +08:00
</el-col>
<el-col :span="5">
2020-10-20 17:21:02 +08:00
<el-select v-model="defaultSpeedLevel" size="mini" :placeholder="this.$t('global.choose')">
2019-09-17 13:16:49 +08:00
<el-option
v-for="item in defaultSpeedLevelList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-col>
2019-07-26 13:32:43 +08:00
2019-08-09 18:29:08 +08:00
</el-row>
2019-09-17 13:16:49 +08:00
<el-row style="margin-bottom: 5px;">
{{ $t('planMonitor.crossRailway')+$t('global.colon') }}
2019-09-17 13:16:49 +08:00
</el-row>
<el-row>
<el-table
2020-10-20 17:21:02 +08:00
:data="routingList"
2019-09-17 13:16:49 +08:00
border
highlight-current-row
2020-10-19 15:08:30 +08:00
:height="230"
2019-09-17 13:16:49 +08:00
@row-click="handleClick"
>
2019-09-19 16:12:05 +08:00
<el-table-column prop="startStationCode" :label="this.$t('planMonitor.startingStation')">
2019-09-17 13:16:49 +08:00
<template slot-scope="scope">
{{ formatName(scope.row.startStationCode) }}
</template>
</el-table-column>
<el-table-column prop="startSectionCode" :label="this.$t('planMonitor.startingSection')" width="95">
2019-09-17 13:16:49 +08:00
<template slot-scope="scope">
{{ formatName(scope.row.startSectionCode) }}
</template>
</el-table-column>
2019-09-19 16:12:05 +08:00
<el-table-column prop="endStationCode" :label="this.$t('planMonitor.terminal')">
2019-09-17 13:16:49 +08:00
<template slot-scope="scope">
{{ formatName(scope.row.endStationCode) }}
</template>
</el-table-column>
<el-table-column prop="endSectionCode" :label="this.$t('planMonitor.endingSection')" width="95">
2019-09-17 13:16:49 +08:00
<template slot-scope="scope">
{{ formatName(scope.row.endSectionCode) }}
</template>
</el-table-column>
<el-table-column prop="remarks" :label="this.$t('planMonitor.description')" width="315" />
2019-09-17 13:16:49 +08:00
</el-table>
</el-row>
<el-row style=" margin-bottom: 5px;margin-top: 10px;">
{{ $t('global.details')+$t('global.colon') }}
2019-09-17 13:16:49 +08:00
</el-row>
<el-row>
2020-10-19 15:08:30 +08:00
<el-table :data="addModel.arriveConfigList" border :height="230">
2019-09-19 16:12:05 +08:00
<el-table-column prop="stationCode" :label="this.$t('planMonitor.station')">
2019-09-17 13:16:49 +08:00
<template slot-scope="scope">
{{ formatName(scope.row.stationCode) }}
</template>
</el-table-column>
2019-09-19 16:12:05 +08:00
<el-table-column prop="sectionCode" :label="this.$t('planMonitor.section')">
2019-09-17 13:16:49 +08:00
<template slot-scope="scope">
{{ formatName(scope.row.sectionCode) }}
</template>
</el-table-column>
2019-09-19 16:12:05 +08:00
<el-table-column prop="arriveTime" :label="this.$t('planMonitor.arriveTime')" />
<!-- prop="stopTime" -->
<el-table-column :label="this.$t('planMonitor.stopTime')">
<template slot-scope="scope">
<el-input v-model="scope.row.stopTime" placeholder="请输入时间" size="mini" @input="changeStopTime(scope.$index, scope.row.stopTime)" />
</template>
</el-table-column>
2019-09-19 16:12:05 +08:00
<el-table-column prop="departureTime" :label="this.$t('planMonitor.departureTime')" />
2020-10-20 17:21:02 +08:00
<el-table-column :label="this.$t('planMonitor.runLevel')">
<template slot-scope="scope">
{{ scope.row.speedLevel }}
<el-input v-model="scope.row.speedLevelTime" placeholder="请输入运行等级" size="mini" @input="changeSpeedLevelTime(scope.$index, scope.row.speedLevelTime)" />
</template>
</el-table-column>
2019-09-17 13:16:49 +08:00
</el-table>
</el-row>
<el-row>
<el-col :offset="16">
<el-checkbox v-model="showDefault">{{ $t('planMonitor.showDefaultStopTimeAndRunLevel') }}</el-checkbox>
2019-09-17 13:16:49 +08:00
</el-col>
</el-row>
<span slot="footer" class="dialog-footer">
<el-button size="medium" @click="doClose">{{ $t('global.cancel') }}</el-button>
<el-button type="primary" size="medium" @click="handleCommit">{{ $t('global.confirm') }}</el-button>
2019-09-17 13:16:49 +08:00
</span>
2019-08-09 18:29:08 +08:00
</el-dialog>
2019-07-26 13:32:43 +08:00
</template>
<script>
2020-10-19 15:08:30 +08:00
import { getRoutingList, getStationRunning, addPlanTrip, getMapStationRun } from '@/api/runplan';
2019-08-09 18:29:08 +08:00
import { formatTime, formatName } from '@/utils/runPlan';
2020-10-20 17:21:02 +08:00
// import { getUID } from '@/jmap/utils/Uid';
2019-07-26 13:32:43 +08:00
2019-08-09 18:29:08 +08:00
export default {
2019-11-11 15:54:04 +08:00
name: 'AddTask',
components: {
},
data() {
return {
dialogShow: false,
loading: false,
isPlan: false,
showDefault: true,
stopStationMap: {},
params: {},
2020-10-20 17:21:02 +08:00
routingList: [],
2020-10-19 15:08:30 +08:00
parkSectionCodeList:[],
2020-10-20 17:21:02 +08:00
defaultStopTime: '30',
defaultSpeedLevel: 'l3',
2019-11-11 15:54:04 +08:00
addModel: {
2020-10-20 17:21:02 +08:00
forward: false,
2019-11-11 15:54:04 +08:00
routingCode: '',
endStationCode: '',
startStationCode: '',
startTime: '00:00:00',
endTime: '',
2020-10-21 11:07:10 +08:00
arriveConfigList: [],
tripNumber: '',
planId: '',
serviceNumber: ''
2019-11-11 15:54:04 +08:00
},
tripNumberList: [{ value: '', label: this.$t('planMonitor.automatic') }],
2020-10-21 11:07:10 +08:00
// defaultStopTimeList: [{ value: '30', label: this.$t('planMonitor.default') }, { value: '0', label: '0' }],
2020-10-19 15:08:30 +08:00
defaultSpeedLevelList: [
{ value: 'l1', label: '等级一' },
{ value: 'l2', label: '等级二' },
{ value: 'l3', label: '等级三'},
{ value: 'l4', label: '等级四' },
{ value: 'l5', label: '等级五' }
]
2019-11-11 15:54:04 +08:00
};
},
computed: {
title() {
return this.$t('planMonitor.addTask');
2020-08-14 18:30:04 +08:00
},
drawWay() {
return this.$route.query.drawWay + '';
2019-11-11 15:54:04 +08:00
}
},
watch: {
2020-10-21 11:07:10 +08:00
'addModel.routingCode': function (val) {
if (val) {
this.computedDetailList('routingCode');
}
2019-11-11 15:54:04 +08:00
},
'addModel.startTime': function () {
this.computedDetailList();
},
2020-10-20 17:21:02 +08:00
'defaultStopTime': function () {
this.computedDetailList('defaultStopTime');
2019-11-11 15:54:04 +08:00
},
2020-10-20 17:21:02 +08:00
'defaultSpeedLevel': function () {
this.computedDetailList('defaultSpeedLevel');
2019-11-11 15:54:04 +08:00
}
},
methods: {
loadInitData(params) {
2020-10-21 11:07:10 +08:00
debugger;
2019-11-11 15:54:04 +08:00
this.isPlan = params.isPlan;
2020-10-20 17:21:02 +08:00
// this.addModel.taskIndex = getUID('task_');
2020-10-21 11:07:10 +08:00
this.addModel.serviceNumber = params.serviceNumber;
this.addModel.planId = this.$route.query.planId;
2020-10-20 17:21:02 +08:00
this.addModel.arriveConfigList = [];
2019-11-11 15:54:04 +08:00
const planId = this.$route.query.planId;
if (planId) {
getRoutingList(planId).then(resp => {
2020-10-20 17:21:02 +08:00
this.routingList = resp.data;
2019-11-11 15:54:04 +08:00
});
}
2019-07-26 13:32:43 +08:00
2019-11-11 15:54:04 +08:00
const mapId = this.$route.query.mapId;
if (mapId && this.drawWay == 'false') {
2019-11-11 15:54:04 +08:00
getStationRunning(mapId).then(resp => { // 查询是否有站间运行时间
const list = resp.data;
list.forEach(elem => {
this.stopStationMap[[elem.startSectionCode, elem.endSectionCode].toString()] = elem;
});
if (list && list.length) {
list.forEach(elem => {
if (!elem.runPlanLevelVO) {
this.$alert(`${this.$t('planMonitor.tipOperationTime')}`, {
confirmButtonText: this.$t('global.confirm'),
callback: action => {
this.doClose();
}
});
}
});
2020-08-14 18:30:04 +08:00
}
});
} else if (mapId && this.drawWay == 'true') {
2020-08-14 18:30:04 +08:00
getMapStationRun(mapId).then(resp =>{
const list = resp.data;
list.forEach(elem => {
this.stopStationMap[[elem.startSectionCode, elem.endSectionCode].toString()] = elem;
});
2020-10-19 10:25:36 +08:00
// if (list && list.length) {
// list.forEach(elem => {
// if (!elem.runPlanLevelVO) {
// this.$alert(`${this.$t('planMonitor.tipOperationTime')}`, {
// confirmButtonText: this.$t('global.confirm'),
// callback: action => {
// this.doClose();
// }
// });
// }
// });
// }
2019-11-11 15:54:04 +08:00
});
}
},
doShow(params) {
this.loadInitData(params);
this.dialogShow = true;
},
doClose() {
this.loading = false;
this.dialogShow = false;
},
formatName(code) {
return formatName(code);
},
computedTimeByString(timeStr) {
const bTime = +new Date(`2019-01-01 00:00:00`);
const eTime = +new Date(`2019-01-01 ${timeStr}`);
return Number(eTime) - Number(bTime);
},
compuntedRunTime(list, index, runLevel) {
let runTime = 0;
if (index < list.length - 1) {
const stopStationObj = this.stopStationMap[[list[index].sectionCode, list[index + 1].sectionCode].toString()];
if (stopStationObj) {
if (stopStationObj.runPlanLevelVO) {
runTime = parseInt(stopStationObj.runPlanLevelVO[runLevel]);
2020-10-19 15:08:30 +08:00
} else if (stopStationObj[runLevel]) {
runTime = parseInt(stopStationObj[runLevel]);
2019-11-11 15:54:04 +08:00
} else {
this.$messageBox(this.$t('planMonitor.addTaskHint1') + stopStationObj.startSectionCode + this.$t('planMonitor.addTaskHint2') + stopStationObj.endSectionCode + this.$t('planMonitor.addTaskHint3'));
}
}
}
return runTime;
},
2020-10-20 17:21:02 +08:00
changeSpeedLevelTime(indexs, speedLevelTime) {
const arriveConfigList = Object.assign([], this.addModel.arriveConfigList);
let tempTime = this.computedTimeByString(this.addModel.startTime) / 1000;
arriveConfigList.forEach((elem, index) => {
elem.arriveTime = index ? formatTime(tempTime) : '';
if (index == indexs) { elem.speedLevelTime = speedLevelTime ? Number(speedLevelTime) : 0; }
elem.arriveTime = index ? formatTime(tempTime) : '';
if (index > 0) {
elem.departureTime = index == arriveConfigList.length - 1 ? '' : formatTime(tempTime + elem.stopTime);
} else {
elem.departureTime = formatTime(tempTime);
}
const realRunlevel = elem.speedLevelTime;
if (index > 0) {
tempTime = tempTime + elem.stopTime + realRunlevel;
} else {
tempTime = tempTime + realRunlevel;
}
});
this.addModel.arriveConfigList = arriveConfigList;
this.addModel.endTime = formatTime(tempTime - this.addModel.arriveConfigList[this.addModel.arriveConfigList.length - 1].stopTime);
},
2019-11-11 15:54:04 +08:00
changeStopTime(indexs, time) {
let tempTime = this.computedTimeByString(this.addModel.startTime) / 1000;
2020-10-20 17:21:02 +08:00
// const runLevel = this.defaultSpeedLevel || 'l3'; // 默认等级三
const arriveConfigList = Object.assign([], this.addModel.arriveConfigList);
arriveConfigList.forEach((elem, index) => {
2020-10-20 17:21:02 +08:00
if (index == indexs) { elem.stopTime = time ? Number(time) : 0; }
elem.arriveTime = index ? formatTime(tempTime) : '';
// const runLevelObj = this.defaultSpeedLevelList.find(speedLevel=>{ return speedLevel.value == runLevel; });
// elem.speedLevel = this.defaultSpeedLevel == 'l3' ? `${this.$t('planMonitor.default')}(${runLevelObj.label})` : runLevelObj.label;
if (index > 0) {
elem.departureTime = index == arriveConfigList.length - 1 ? '' : formatTime(tempTime + elem.stopTime);
} else {
elem.departureTime = formatTime(tempTime);
}
2020-10-20 17:21:02 +08:00
const realRunlevel = elem.speedLevelTime;
if (index > 0) {
tempTime = tempTime + elem.stopTime + realRunlevel;
} else {
tempTime = tempTime + realRunlevel;
2019-11-11 15:54:04 +08:00
}
});
this.addModel.arriveConfigList = arriveConfigList;
2019-11-11 15:54:04 +08:00
this.addModel.endTime = formatTime(tempTime - this.addModel.arriveConfigList[this.addModel.arriveConfigList.length - 1].stopTime);
},
computedDetailList(type = null) {
2019-11-11 15:54:04 +08:00
if (this.addModel.routingCode) {
2020-10-20 17:21:02 +08:00
const list = Object.assign([], this.addModel.arriveConfigList);
let tempTime = this.computedTimeByString(this.addModel.startTime) / 1000;
2020-10-20 17:21:02 +08:00
const runLevel = this.defaultSpeedLevel || 'l3'; // 默认等级三
2020-10-19 15:08:30 +08:00
list.forEach((elem, index) => {
2020-10-20 17:21:02 +08:00
if (type == 'defaultStopTime' || type == 'routingCode') {
2020-10-21 11:07:10 +08:00
elem.stopTime = parseInt(this.defaultStopTime);
}
2020-10-19 15:08:30 +08:00
elem.arriveTime = index ? formatTime(tempTime) : '';
2020-10-20 17:21:02 +08:00
if (index > 0) {
elem.departureTime = index == list.length - 1 ? '' : formatTime(tempTime + elem.stopTime);
} else {
elem.departureTime = formatTime(tempTime);
}
2020-10-19 15:08:30 +08:00
const runLevelObj = this.defaultSpeedLevelList.find(speedLevel=>{ return speedLevel.value == runLevel; });
2020-10-20 17:21:02 +08:00
if (!elem.speedLevelTime || type == 'defaultSpeedLevel') {
const realRunlevel = this.compuntedRunTime(list, index, runLevel);
elem.speedLevelTime = realRunlevel;
}
elem.speedLevel = this.defaultSpeedLevel == 'l3' ? `${this.$t('planMonitor.default')}(${runLevelObj.label})` : runLevelObj.label;
if (index > 0) {
tempTime = tempTime + elem.stopTime + elem.speedLevelTime;
} else {
tempTime = tempTime + elem.speedLevelTime;
}
2020-10-19 15:08:30 +08:00
2020-10-20 17:21:02 +08:00
});
2020-10-19 15:08:30 +08:00
this.addModel.endTime = formatTime(tempTime - list[list.length - 1].stopTime);
2019-11-11 15:54:04 +08:00
}
},
handleClick(row, column, event) {
2020-10-20 17:21:02 +08:00
const arriveConfigList = [];
row.parkSectionCodeList.forEach(parkSectionCode=>{
arriveConfigList.push({arriveTime:'', departureTime:'', sectionCode:parkSectionCode.sectionCode, stationCode:parkSectionCode.stationCode});
});
this.$set(this.addModel, 'arriveConfigList', arriveConfigList);
2019-11-11 15:54:04 +08:00
this.addModel.startStationCode = row.startStationCode;
this.addModel.endStationCode = row.endStationCode;
2020-10-20 20:25:45 +08:00
this.addModel.endSectionCode = row.endSectionCode;
this.addModel.startSectionCode = row.startSectionCode;
2019-11-11 15:54:04 +08:00
this.addModel.routingCode = row.code;
},
handleCommit() {
2020-10-21 11:07:10 +08:00
debugger;
2019-11-11 15:54:04 +08:00
if (this.isPlan) {
// 计划添加任务
this.$emit('dispatchOperate', { dialogName: 'editPlanningTrain', operate: 'handleConfirmAddTask', params: Object.assign({}, this.addModel) });
2020-10-21 11:07:10 +08:00
this.addModel.routingCode = '';
2019-11-11 15:54:04 +08:00
} else {
// 直接添加任务
2020-10-21 11:07:10 +08:00
delete this.addModel.tripNumber;
2019-11-11 15:54:04 +08:00
addPlanTrip(this.addModel).then(resp => {
// this.$emit('dispatchOperate', {
// dialogName: 'openRunPlan', operate: 'loadRunPlanData', params: Object.assign({refresh: true}, this.$route.query)
// });
this.$emit('refresh');
this.$message.success(this.$t('tip.addTaskSuccessfully'));
}).catch(() => {
this.$messageBox(this.$t('tip.addTaskFailed'));
});
}
2019-07-26 13:32:43 +08:00
2019-11-11 15:54:04 +08:00
this.doClose();
}
}
2019-08-09 18:29:08 +08:00
};
2019-07-26 13:32:43 +08:00
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
/deep/ {
.el-row {
margin-bottom: 5px !important;
}
}
2019-09-17 13:16:49 +08:00
.add-task{
/deep/ {
.el-dialog__body{
padding: 0 20px;
}
.dialog-footer{
display: flex;
justify-content: center;
}
}
}
2019-08-09 18:29:08 +08:00
</style>