修改 增加任务逻辑

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