修改 增加任务逻辑

This commit is contained in:
ival 2021-03-05 15:39:08 +08:00
parent e9997a2f7f
commit 96ad7becf2

View File

@ -171,6 +171,7 @@
<script> <script>
import { listUserRoutingData, addPlanTrip, getMapStationRunUser, getStationStopTime } from '@/api/runplan'; import { listUserRoutingData, addPlanTrip, getMapStationRunUser, getStationStopTime } from '@/api/runplan';
import { getRunplanConfig } from '@/api/jmap/mapdraft';
import { formatTime, formatName } from '@/utils/runPlan'; import { formatTime, formatName } from '@/utils/runPlan';
export default { export default {
@ -191,6 +192,7 @@ export default {
endStationFilters:[], endStationFilters:[],
// defaultStopTime: '30', // defaultStopTime: '30',
defaultSpeedLevel: 'l1', defaultSpeedLevel: 'l1',
reentryData: {},
addModel: { addModel: {
// forward: false, // forward: false,
routingCode: '', routingCode: '',
@ -203,6 +205,10 @@ export default {
planId: '', planId: '',
serviceNumber: '' serviceNumber: ''
}, },
frontModel: {
startTbFront: false,
endTbFront: false
},
tripNumberList: [{ value: '', label: this.$t('planMonitor.automatic') }], tripNumberList: [{ value: '', label: this.$t('planMonitor.automatic') }],
// defaultStopTimeList: [{ value: '30', label: this.$t('planMonitor.default') }, { value: '0', label: '0' }], // defaultStopTimeList: [{ value: '30', label: this.$t('planMonitor.default') }, { value: '0', label: '0' }],
defaultSpeedLevelList: [ defaultSpeedLevelList: [
@ -228,9 +234,6 @@ export default {
'addModel.startTime': function () { 'addModel.startTime': function () {
this.computedDetailList(); this.computedDetailList();
}, },
// 'defaultStopTime': function () {
// this.computedDetailList('defaultStopTime');
// },
'defaultSpeedLevel': function () { 'defaultSpeedLevel': function () {
this.computedDetailList('defaultSpeedLevel'); this.computedDetailList('defaultSpeedLevel');
} }
@ -241,9 +244,14 @@ export default {
this.addModel.serviceNumber = params.serviceNumber; this.addModel.serviceNumber = params.serviceNumber;
this.addModel.planId = this.$route.query.planId; this.addModel.planId = this.$route.query.planId;
this.addModel.arriveConfigList = []; this.addModel.arriveConfigList = [];
const planId = this.$route.query.planId;
if (planId) {
const mapId = this.$route.query.mapId; const mapId = this.$route.query.mapId;
if (mapId) {
getRunplanConfig(mapId).then(resp => {
const data = resp.data;
this.reentryData = data.config.reentryData;
});
listUserRoutingData(mapId).then(resp => { listUserRoutingData(mapId).then(resp => {
this.routingList = resp.data; this.routingList = resp.data;
const startStationFilterMap = {}; const startStationFilterMap = {};
@ -255,26 +263,11 @@ export default {
if (!endStationFilterMap[routing.endStationCode]) { if (!endStationFilterMap[routing.endStationCode]) {
endStationFilterMap[routing.endStationCode] = {text:formatName(routing.endStationCode), value:routing.endStationCode}; endStationFilterMap[routing.endStationCode] = {text:formatName(routing.endStationCode), value:routing.endStationCode};
} }
let length = routing.parkSectionCodeList.length;
if ( length >= 4) {
if (routing.parkSectionCodeList[0].stationCode == routing.parkSectionCodeList[1].stationCode) {
// routing.startSectionCode = routing.parkSectionCodeList[1].sectionCode;
routing.parkSectionCodeList.shift();
}
length = routing.parkSectionCodeList.length;
if (routing.parkSectionCodeList[length - 1].stationCode == routing.parkSectionCodeList[length - 2].stationCode) {
// routing.endSectionCode = routing.parkSectionCodeList[length - 2].sectionCode;
routing.parkSectionCodeList.pop();
}
}
}); });
this.startStationFilters = Object.values(startStationFilterMap); this.startStationFilters = Object.values(startStationFilterMap);
this.endStationFilters = Object.values(endStationFilterMap); this.endStationFilters = Object.values(endStationFilterMap);
}); });
}
const mapId = this.$route.query.mapId;
if (mapId) {
getMapStationRunUser(mapId).then(resp =>{ getMapStationRunUser(mapId).then(resp =>{
const list = resp.data.list; const list = resp.data.list;
list.forEach(elem => { list.forEach(elem => {
@ -286,18 +279,6 @@ export default {
this.stopTimeMap[element.stationCode] = {parkingTime:element.parkingTime}; this.stopTimeMap[element.stationCode] = {parkingTime:element.parkingTime};
}); });
}); });
// 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();
// }
// });
// }
// });
// }
}); });
} }
}, },
@ -325,6 +306,11 @@ export default {
}, },
compuntedRunTime(list, index, runLevel) { compuntedRunTime(list, index, runLevel) {
let runTime = 0; let runTime = 0;
if ((index == 0 || index == list.length-1) && String(this.frontModel.startTbFront) != 'undefined') {
return 0
}
if (index < list.length - 1) { if (index < list.length - 1) {
const stopStationObj = this.stopStationMap[[list[index].sectionCode, list[index + 1].sectionCode].toString()]; const stopStationObj = this.stopStationMap[[list[index].sectionCode, list[index + 1].sectionCode].toString()];
if (stopStationObj) { if (stopStationObj) {
@ -337,101 +323,50 @@ export default {
} }
} }
} }
return runTime; return runTime;
}, },
// 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);
// },
// changeStopTime(indexs, time) {
// let tempTime = this.computedTimeByString(this.addModel.startTime) / 1000;
// // const runLevel = this.defaultSpeedLevel || 'l3'; //
// const arriveConfigList = Object.assign([], this.addModel.arriveConfigList);
// arriveConfigList.forEach((elem, index) => {
// 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);
// }
// 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);
// },
computedDetailList(type = null) { computedDetailList(type = null) {
if (this.addModel.routingCode) { if (this.addModel.routingCode) {
const list = Object.assign([], this.addModel.arriveConfigList);
let tempTime = this.computedTimeByString(this.addModel.startTime) / 1000; let tempTime = this.computedTimeByString(this.addModel.startTime) / 1000;
const list = Object.assign([], this.addModel.arriveConfigList);
const runLevel = this.defaultSpeedLevel || 'l1'; // const runLevel = this.defaultSpeedLevel || 'l1'; //
list.forEach((elem, index) => { list.forEach((elem, index) => {
// type == 'defaultStopTime' ||
if (type == 'routingCode') { if (type == 'routingCode') {
// elem.stopTime = parseInt(this.defaultStopTime); if (index == 0 || index == list.length - 1) {
if (this.stopTimeMap[elem.stationCode]) { elem.stopTime = 0;
// if (index == 0 || index == list.length - 1) { } else if (this.stopTimeMap[elem.stationCode]) {
// elem.stopTime = 0;
// } else {
elem.stopTime = this.stopTimeMap[elem.stationCode].parkingTime; elem.stopTime = this.stopTimeMap[elem.stationCode].parkingTime;
// }
} else { } else {
elem.stopTime = 0; elem.stopTime = 0;
} }
} }
// elem.arriveTime = index ? formatTime(tempTime) : '';
if (index) { tempTime = tempTime? tempTime: this.computedTimeByString('23:59:59') / 1000 + 1;
elem.arriveTime = formatTime(tempTime); elem.arriveTime = formatTime(tempTime)
} else {
const time = tempTime || this.computedTimeByString('23:59:59') / 1000 + 1;
elem.arriveTime = formatTime(time - elem.stopTime);
}
if (index > 0) {
elem.departureTime = formatTime(tempTime + elem.stopTime); elem.departureTime = formatTime(tempTime + elem.stopTime);
// elem.departureTime = index == list.length - 1 ? '' : formatTime(tempTime + elem.stopTime);
} else {
elem.departureTime = formatTime(tempTime);
}
const runLevelObj = this.defaultSpeedLevelList.find(speedLevel=>{ return speedLevel.value == runLevel; }); const runLevelObj = this.defaultSpeedLevelList.find(speedLevel=>{ return speedLevel.value == runLevel; });
// if (!elem.speedLevelTime || type == 'defaultSpeedLevel') {
const realRunlevel = this.compuntedRunTime(list, index, runLevel); const realRunlevel = this.compuntedRunTime(list, index, runLevel);
elem.speedLevelTime = realRunlevel; elem.speedLevelTime = realRunlevel;
// }
// this.defaultSpeedLevel == 'l1' ? `(${runLevelObj.label})` : runLevelObj.label
elem.speedLevel = runLevelObj.label; elem.speedLevel = runLevelObj.label;
// elem.speedLevelTime = realRunlevel;
if (index > 0) {
tempTime = tempTime + elem.stopTime + elem.speedLevelTime; let fronTime = 0;
} else { if (index == 0 &&
tempTime = tempTime + elem.speedLevelTime; String(this.frontModel.startTbFront) == 'false') {
fronTime = this.reentryData[elem.stationCode].tbTo
} else if (index == list.length - 2 &&
String(this.frontModel.endTbFront) == 'false') {
fronTime = this.reentryData[list[index+1].stationCode].tbTo
} }
console.log(index, fronTime);
tempTime = tempTime + fronTime + elem.stopTime + elem.speedLevelTime;
}); });
this.addModel.endTime = formatTime(tempTime - list[list.length - 1].stopTime); this.addModel.endTime = formatTime(tempTime - list[list.length - 1].stopTime);
} }
}, },
@ -446,6 +381,9 @@ export default {
this.addModel.endSectionCode = row.endSectionCode; this.addModel.endSectionCode = row.endSectionCode;
this.addModel.startSectionCode = row.startSectionCode; this.addModel.startSectionCode = row.startSectionCode;
this.addModel.routingCode = row.code; this.addModel.routingCode = row.code;
this.frontModel.startTbFront = row.startTbFront;
this.frontModel.endTbFront = row.endTbFront;
console.log(row);
this.computedDetailList('routingCode'); this.computedDetailList('routingCode');
}, },
handleCommit() { handleCommit() {