修改运行时间校验错误的问题

This commit is contained in:
lVAL 2020-10-23 09:03:05 +08:00
parent fdeaabb699
commit b49c1c29d1
6 changed files with 6 additions and 174 deletions

View File

@ -1,158 +0,0 @@
<template>
<el-dialog v-dialogDrag append-to-body title="Modify area parameters" :visible.sync="dialogShow" width="30%" :close-on-click-modal="false" :before-close="doClose">
<el-form ref="form" label-width="160px" :model="formModel" :rules="rules">
<el-form-item label="Start station" prop="startStationCode">
<el-select v-model="formModel.startStationCode" placeholder="请选择">
<el-option
v-for="(el,i) in stations"
:key="i"
:label="el.name"
:value="el.code">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="End station" prop="endStationCode">
<el-select v-model="formModel.endStationCode" placeholder="请选择">
<el-option
v-for="(el,i) in stations"
:key="i"
:label="el.name"
:value="el.code">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="Start time" prop="startTime">
<el-time-picker value-format="HH:mm:ss" v-model="formModel.startTime" />
</el-form-item>
<el-form-item label="End time" prop="endTime">
<el-time-picker value-format="HH:mm:ss" v-model="formModel.endTime" />
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogShow = false">{{ $t('map.cancel') }}</el-button>
<el-button type="primary" @click="doConfirm">{{ $t('map.confirm') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { MenuEnum } from '../utils.js';
import { getRpConfig } from '@/api/rpTools';
import { toTimeStamp } from '@/utils/date';
export default {
props: {
stations: {
type: Array,
required: true
},
target: {
type: Object,
default() {
return null
}
}
},
data() {
var startTimeValidator = (rule, value, callback) => {
const startTime = toTimeStamp(value);
const endTime = toTimeStamp(this.formModel.endTime);
if (startTime >= endTime) {
callback(new Error('The start time is greater than the end time.'));
} else if (Math.abs(startTime - endTime) < 10*60) {
callback(new Error('The time interval shall not be less than 10 min.'));
} else {
callback()
}
}
var endTimeValidator = (rule, value, callback) => {
const startTime = toTimeStamp(this.formModel.startTime);
const endTime = toTimeStamp(value);
if (endTime <= startTime) {
callback(new Error('The end time is less than the start time.'));
} else if (Math.abs(startTime - endTime) < 10*60) {
callback(new Error('The time interval shall not be less than 10 min.'));
} else {
callback()
}
}
return {
dialogShow: false,
formModel: {
areaNo: '',
startStationCode: '',
endStationCode: '',
startTime: 0,
endTime: 0
},
rules: {
startStationCode: [
{
required: true, message: 'Please select the farther station.', trigger: 'blur'
},
],
endStationCode: [
{
required: true, message: 'Please select the closer station.', trigger: 'blur'
},
],
startTime: [
{
required: true, message: 'Please select the start time.', trigger: 'blur'
},
{
validator: startTimeValidator, trigger: 'blur'
}
],
endTime: [
{
required: true, message: 'Please select the end time.', trigger: 'blur'
},
{
validator: endTimeValidator, trigger: 'blur'
}
]
}
};
},
watch: {
'$store.state.menuOperation.menuCount': function (val) {
if (this.$store.getters['menuOperation/checkDialogIsOpen'](MenuEnum.planModifyArea)) {
this.doShow(this.$store.state.menuOperation.menuPosition);
} else {
this.doClose();
}
}
},
methods: {
doShow() {
if (this.target &&
this.target.model) {
const model = this.target.model;
this.formModel = {
areaNo: model.areaNo,
startStationCode: model.fartherStationCode,
endStationCode: model.closerStationCode,
startTime: model.startTime,
endTime: model.endTime
}
}
this.dialogShow = true;
},
doClose() {
this.dialogShow = false;
},
doConfirm() {
this.$refs.form.validate((valid) => {
if(valid) {
this.$emit('modifyArea', this.formModel);
this.doClose();
}
});
}
}
};
</script>

View File

@ -39,8 +39,8 @@ export default {
var validator = (rule, value, callback) => {
const stations = this.stations;
const offset = Math.abs(
this.stations[this.selected.dataIndex].kmRange -
this.stations[this.selected.dataIndex+1].kmRange
this.stations[this.selected.stationIndex].kmRange -
this.stations[this.selected.stationIndex+1].kmRange
)
const min = Math.floor(offset / (this.config.maxSpeed * 1000/3600));
const max = Math.floor(offset / 1);

View File

@ -24,12 +24,6 @@ export default {
return null
}
},
stations: {
type: Array,
default() {
return []
}
},
config: {
type: Object,
required: true

View File

@ -24,12 +24,6 @@ export default {
return null
}
},
stations: {
type: Array,
default() {
return []
}
},
config: {
type: Object,
required: true

View File

@ -34,8 +34,8 @@
</template>
</schedule>
<plan-just-running :config="config" :selected="selected" :stations="stations" @justRunning="doJustRunning" />
<plan-just-stop :config="config" :selected="selected" :stations="stations" @justStop="doJustStop"/>
<plan-just-turnback :config="config" :selected="selected" :stations="stations" @justTurnBack="doJustTurnback"/>
<plan-just-stop :config="config" :selected="selected" @justStop="doJustStop"/>
<plan-just-turnback :config="config" :selected="selected" @justTurnBack="doJustTurnback"/>
<plan-set-params :config="config" @setParams="doSetPlanParams" />
<plan-set-area-note :target="target" @setAreaNote="doSetAreaNote" />
</div>

View File

@ -343,7 +343,9 @@ export default {
this.myChart.setOption(option, {notMerge: true});
}
const obj = (dataList[e.dataIndex]||[])[2]||{};
this.selected = {
stationIndex: this.stations.findIndex(el => { return el.code == obj.stationCode; }),
dataIndex: e.dataIndex,
seriesIndex: e.seriesIndex,
seriesName: isService? e.seriesName: 'service-trip',