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

View File

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