This commit is contained in:
fan 2020-12-11 13:20:01 +08:00
commit 772c611704

View File

@ -19,8 +19,7 @@
</template> </template>
<script> <script>
import { getStationList, populatingGenericData } from '@/api/runplan'; import { listUserRoutingData, populatingGenericData } from '@/api/runplan';
export default { export default {
props: { props: {
loadRunPlanId: { loadRunPlanId: {
@ -33,7 +32,8 @@ export default {
data() { data() {
return { return {
dialogShow: false, dialogShow: false,
stationList: [], // stationList: [],
routingList: [],
loading: false, loading: false,
formModel: { formModel: {
stationRunningTime: 60, // stationRunningTime: 60, //
@ -41,10 +41,12 @@ export default {
beginTime: '', beginTime: '',
overTime: '', overTime: '',
departureTimeInterval: 180, // departureTimeInterval: 180, //
parkedTime: 30, // // parkedTime: 30, //
reentryTime: 60, // reentryTime: 60, //
startStationCode: '', runningRouting1:'', // code1
endStationCode: '' runningRouting2:'' // code2
// startStationCode: '',
// endStationCode: ''
}, },
rules: { rules: {
@ -57,18 +59,24 @@ export default {
departureTimeInterval: [ departureTimeInterval: [
{ required: true, message: '请填写发车间隔', trigger: 'blur' } { required: true, message: '请填写发车间隔', trigger: 'blur' }
], ],
parkedTime: [ // parkedTime: [
{ required: true, message: '请填写停站时间', trigger: 'blur' } // { required: true, message: '', trigger: 'blur' }
], // ],
reentryTime: [ reentryTime: [
{ required: true, message: '请填写折返时间', trigger: 'blur' } { required: true, message: '请填写折返时间', trigger: 'blur' }
], ],
startStationCode: [ runningRouting1: [
{ required: true, message: '请选择起始站', trigger: 'change' } { required: true, validator: this.validateRunningRouting, trigger: 'change' }
], ],
endStationCode: [ runningRouting2: [
{ required: true, message: '请选择终止站', trigger: 'change' } { required: true, validator: this.validateRunningRouting, trigger: 'change' }
] ]
// startStationCode: [
// { required: true, message: '', trigger: 'change' }
// ],
// endStationCode: [
// { required: true, message: '', trigger: 'change' }
// ]
} }
}; };
}, },
@ -82,34 +90,43 @@ export default {
items: [ items: [
{ prop: 'beginTime', label: '开始时间', type: 'timePicker'}, { prop: 'beginTime', label: '开始时间', type: 'timePicker'},
{ prop: 'overTime', label: '结束时间', type: 'timePicker'}, { prop: 'overTime', label: '结束时间', type: 'timePicker'},
{ prop: 'departureTimeInterval', label: '发车间隔', type: 'number', min:0, step:1, precisionFlag:true, precision:0 }, { prop: 'departureTimeInterval', label: '发车间隔', type: 'number', min:0, step:1, precisionFlag:true, precision:0, message:'s'},
{ prop: 'parkedTime', label: '停站时间', type: 'number', min:0, step:1, precisionFlag:true, precision:0}, // { prop: 'parkedTime', label: '', type: 'number', min:0, step:1, precisionFlag:true, precision:0},
{ prop: 'reentryTime', label: '折返时间', type: 'number', min:0, step:1, precisionFlag:true, precision:0}, { prop: 'reentryTime', label: '折返时间', type: 'number', min:0, step:1, precisionFlag:true, precision:0, message:'s'},
{ prop: 'right', label: '发车类型', type: 'checkBox', children: [ { prop: 'right', label: '发车类型', type: 'checkBox', children: [
{ name: '上行发车', value: 1 }, { name: '上行发车', value: 1 },
{ name: '下次发车', value: 2 }, { name: '下次发车', value: 2 },
{ name: '同时发车', value: 3 } { name: '同时发车', value: 3 }
] }, ] },
{ prop: 'startStationCode', label: '起始站', type: 'select', options: this.stationList }, { prop: 'runningRouting1', label: '环路交路1', type: 'select', show:true, options: this.covertRouting('LOOP'), noDataText:'请先设置交路', change:true, onChange:this.changeRoute2 },
{ prop: 'endStationCode', label: '终止站', type: 'select', options: this.stationList } { prop: 'runningRouting2', label: '环路交路2', type: 'select', show:true, options: this.covertRouting('LOOP'), noDataText:'请先设置交路', change:true, onChange:this.changeRoute1}
// { prop: 'startStationCode', label: '', type: 'select', options: this.stationList },
// { prop: 'endStationCode', label: '', type: 'select', options: this.stationList }
] ]
}; };
} }
}, },
created() { created() {
const mapId = this.$route.query.mapId; // const mapId = this.$route.query.mapId;
if (mapId) { // if (mapId) {
getStationList(mapId).then(response => { // getStationList(mapId).then(response => {
this.stationList = response.data.map(elem => { return { value: elem.code, label: elem.name }; }); // this.stationList = response.data.map(elem => { return { value: elem.code, label: elem.name }; });
}).catch(() => { // }).catch(() => {
this.$messageBox(`获取车站列表失败`); // this.$messageBox(``);
}); // });
} // }
}, },
methods: { methods: {
doShow(params) { doShow(params) {
this.loading = false; this.loading = false;
const mapId = this.$route.query.mapId;
if (mapId) {
listUserRoutingData(mapId).then(response => {
this.routingList = response.data.map(elem => { return { value: elem.code, label: elem.name, routingType:elem.routingType }; });
}).catch(() => {
this.$messageBox(`获取交路列表失败`);
});
}
this.dialogShow = true; this.dialogShow = true;
}, },
doClose() { doClose() {
@ -141,18 +158,29 @@ export default {
} }
}); });
}, },
// validateRunningRouting(rule, value, callback) {
formatDateTime(date) { if (value.trim().length == 0) {
console.log(date, 3333); return callback(new Error('请选择环路'));
let h = date.getHours(); } else {
h = h < 10 ? ('0' + h) : h; if (this.formModel.runningRouting1 == this.formModel.runningRouting2) {
let minute = date.getMinutes(); return callback(new Error('环路交路1和环路交路2不能相同'));
let second = date.getSeconds(); } else {
minute = minute < 10 ? ('0' + minute) : minute; return callback();
second = second < 10 ? ('0' + second) : second; }
return h + ':' + minute + ':' + second; }
},
changeRoute2() {
this.changeRoute('runningRouting2');
},
changeRoute1() {
this.changeRoute('runningRouting1');
},
changeRoute(runningRouting) {
if (this.formModel[runningRouting]) { this.$refs.dataform.validateField([runningRouting]); }
},
covertRouting(routingType) {
return this.routingList.filter(route=>{ return route.routingType == routingType; });
} }
} }
}; };
</script> </script>