diff --git a/src/views/planMonitor/editTool/menus/addPlanningTrain.vue b/src/views/planMonitor/editTool/menus/addPlanningTrain.vue index 392e4513c..681f2fc87 100644 --- a/src/views/planMonitor/editTool/menus/addPlanningTrain.vue +++ b/src/views/planMonitor/editTool/menus/addPlanningTrain.vue @@ -45,7 +45,7 @@ export default { rules:{ serviceNumber:[ {required: true, validator: this.validateServiceNumber, trigger: 'blur'}, - {required: true, validator: this.validateServiceNumber, trigger: 'change'} + {required: true, validator: this.validateServiceNo, trigger: 'change'} ] } }; @@ -65,15 +65,30 @@ export default { this.loading = false; this.dialogShow = false; }, + validateServiceNo(rule, value, callback) { + if (typeof value == 'string' && value.trim().length == 0) { + return callback(new Error('请填写服务号')); + } else { + const serviceNumberList = Object.keys(this.$store.state.runPlan.editData); + if (serviceNumberList.includes(value)) { + return callback(new Error('该服务号已存在,请重新填写')); + } else { + return callback(); + } + } + }, validateServiceNumber(rule, value, callback) { if (typeof value == 'string' && value.trim().length == 0) { return callback(new Error('请填写服务号')); } else { - const newValue = parseInt(value); + let newValue = parseInt(value); if (newValue) { - if (newValue.toString() != value) { - this.formModel.serviceNumber = newValue; + if (newValue > 0 & newValue < 9) { + newValue = '00' + newValue; + } else if (newValue > 10 & newValue < 99) { + newValue = '0' + newValue; } + this.formModel.serviceNumber = newValue; const serviceNumberList = Object.keys(this.$store.state.runPlan.editData); if (serviceNumberList.includes(value)) { return callback(new Error('该服务号已存在,请重新填写')); diff --git a/src/views/planMonitor/editTool/menus/addTask.vue b/src/views/planMonitor/editTool/menus/addTask.vue index 75d20a557..1e3c82af8 100644 --- a/src/views/planMonitor/editTool/menus/addTask.vue +++ b/src/views/planMonitor/editTool/menus/addTask.vue @@ -54,7 +54,8 @@ --> - {{ $t('planMonitor.defaultRunLevel') }} + + 运行等级 diff --git a/src/views/planMonitor/editTool/menus/modifyingStationIntervalTime.vue b/src/views/planMonitor/editTool/menus/modifyingStationIntervalTime.vue index c72874879..ca413edf8 100644 --- a/src/views/planMonitor/editTool/menus/modifyingStationIntervalTime.vue +++ b/src/views/planMonitor/editTool/menus/modifyingStationIntervalTime.vue @@ -49,7 +49,7 @@ {{ formatName(scope.row.startStationCode) }} - + @@ -59,7 +59,7 @@ {{ formatName(scope.row.endStationCode) }} - + @@ -69,9 +69,10 @@ {{ scope.row.right?'上行':'下行' }} - +
diff --git a/src/views/planMonitor/newEditTool/menus/addPlanningTrain.vue b/src/views/planMonitor/newEditTool/menus/addPlanningTrain.vue index a1161d719..91ff1ac32 100644 --- a/src/views/planMonitor/newEditTool/menus/addPlanningTrain.vue +++ b/src/views/planMonitor/newEditTool/menus/addPlanningTrain.vue @@ -10,12 +10,17 @@ :modal="false" :close-on-click-modal="false" > - + + + + + + {{ $t('global.cancel') }} {{ $t('global.confirm') }} @@ -40,7 +45,15 @@ export default { return { dialogShow: false, loading: false, - serviceNumber: '' + formModel:{ + serviceNumber: '' + }, + rules:{ + serviceNumber:[ + {required: true, validator: this.validateServiceNumber, trigger: 'blur'}, + {required: true, validator: this.validateServiceNo, trigger: 'change'} + ] + } }; }, computed: { @@ -58,37 +71,73 @@ export default { this.loading = false; this.dialogShow = false; }, + validateServiceNo(rule, value, callback) { + if (typeof value == 'string' && value.trim().length == 0) { + return callback(new Error('请填写服务号')); + } else { + const serviceNumberList = Object.keys(this.$store.state.runPlan.editData); + if (serviceNumberList.includes(value)) { + return callback(new Error('该服务号已存在,请重新填写')); + } else { + return callback(); + } + } + }, + validateServiceNumber(rule, value, callback) { + if (typeof value == 'string' && value.trim().length == 0) { + return callback(new Error('请填写服务号')); + } else { + let newValue = parseInt(value); + if (newValue) { + if (newValue > 0 & newValue < 9) { + newValue = '00' + newValue; + } else if (newValue > 10 & newValue < 99) { + newValue = '0' + newValue; + } + this.formModel.serviceNumber = newValue; + const serviceNumberList = Object.keys(this.$store.state.runPlan.editData); + if (serviceNumberList.includes(value)) { + return callback(new Error('该服务号已存在,请重新填写')); + } else { + return callback(); + } + } else { + this.formModel.serviceNumber = ''; + } + + } + }, handleCommit() { if (this.$route.query.planId || this.loadRunPlanId) { - if (this.serviceNumber.length >= 2 && this.serviceNumber.length <= 3) { - checkServiceNumberExist({ planId: this.$route.query.planId || this.loadRunPlanId, serviceNumber: this.serviceNumber }).then(resp => { - if (resp.data) { - this.$emit('dispatchDialog', { - name: 'offLine', - params: { - type: 'warning', - operate: 'AddPlanningTrain', - width: 460, - message: this.$t('tip.serviceNumberExistHint') - } - }); + checkServiceNumberExist({ planId: this.$route.query.planId || this.loadRunPlanId, serviceNumber: this.formModel.serviceNumber }).then(resp => { + if (resp.data) { + this.$emit('dispatchDialog', { + name: 'offLine', + params: { + type: 'warning', + operate: 'AddPlanningTrain', + width: 460, + message: this.$t('tip.serviceNumberExistHint') + } + }); - this.doClose(); - } else { - this.handleConfirm(true); - } - }); - } else { - this.$messageBox('长度在二到三位'); - } + this.doClose(); + } else { + this.handleConfirm(true); + } + }); + // if (this.serviceNumber.length >= 2 && this.serviceNumber.length <= 3) { + // } else { + // this.$messageBox('长度在二到三位'); + // } } else { this.$messageBox(this.$t('tip.chooseToOpenTheRunGraph')); } }, handleConfirm(isNew = false) { this.doClose(); - this.$store.dispatch('runPlan/addserviceNumber', this.serviceNumber); - this.$emit('dispatchDialog', { name: 'editPlanningTrain', params: { serviceNumber: this.serviceNumber, isNew:isNew } }); + this.$store.dispatch('runPlan/addserviceNumber', this.formModel.serviceNumber); + this.$emit('dispatchDialog', { name: 'editPlanningTrain', params: { serviceNumber: this.formModel.serviceNumber, isNew:isNew } }); } } }; diff --git a/src/views/planMonitor/newEditTool/menus/addTask.vue b/src/views/planMonitor/newEditTool/menus/addTask.vue index 25ce168e2..5db8a7e8f 100644 --- a/src/views/planMonitor/newEditTool/menus/addTask.vue +++ b/src/views/planMonitor/newEditTool/menus/addTask.vue @@ -54,7 +54,7 @@ --> - {{ $t('planMonitor.defaultRunLevel') }} + 运行等级