巡检计划巡检执行时间校验

master
wws 11 months ago
parent 22cb5cb27c
commit 759f9254ae

@ -347,6 +347,7 @@
<el-col :span=12 :offset="1">
<el-form-item label-width="100px" label="巡检执行时间">
<el-date-picker
@change="changeArray"
v-model="form.planTimeArray"
type="datetimerange"
range-separator="至"
@ -744,6 +745,101 @@ export default {
}
},
methods: {
//
changeArray(e) {
console.log(e)
console.log(this.form.planTimeArray)
if (this.form.planLoop == null) {
this.$message({
message: '请输入循环周期!',
type: 'warning'
})
this.form.planTimeArray = [];
return
}
if (this.form.planLoopType == null) {
this.$message({
message: '请选择循环类型!',
type: 'warning'
})
this.form.planTimeArray = [];
return
}
//
if (this.form.planLoopType == 'day'){
//
let diff = this.form.planTimeArray[1].getTime() - this.form.planTimeArray[0].getTime();
//
let days = Math.floor(diff / (1000 * 60 * 60 * 24));
if (days > this.form.planLoop) {
this.$message({
message: '可执行时间范围为'+days+'天,循环周期为'+days+'天,超过循环周期'+(days-this.form.planLoop)+'天,请重新选择执行时间!',
type: 'warning'
})
this.form.planTimeArray = [];
return
}
}
if (this.form.planLoopType == 'week') {
//
let diff = this.form.planTimeArray[1].getTime() - this.form.planTimeArray[0].getTime();
//
let weeks = Math.floor(diff / (1000 * 60 * 60 * 24 * 7));
if (weeks > (this.form.planLoop/7)) {
this.$message({
message: '可执行时间范围为'+weeks+'周,循环周期为'+weeks+'周,超过循环周期'+(weeks*7-this.form.planLoop)+'天,请重新选择执行时间!',
type: 'warning'
})
this.form.planTimeArray = [];
return
}
}
if (this.form.planLoopType == 'month'){
let monthsDiff = (this.form.planTimeArray[1].getFullYear() - this.form.planTimeArray[0].getFullYear()) * 12 + this.form.planTimeArray[1].getMonth() - this.form.planTimeArray[0].getMonth();
if (monthsDiff > this.form.planLoop) {
this.$message({
message: '可执行时间范围为'+monthsDiff+'月,循环周期为'+monthsDiff+'月,超过循环周期'+(monthsDiff-this.form.planLoop)+'月,请重新选择执行时间!',
type: 'warning'
})
this.form.planTimeArray = [];
return
}
}
if (this.form.planLoopType == 'season'){
let monthsDiff = (this.form.planTimeArray[1].getFullYear() - this.form.planTimeArray[0].getFullYear()) * 12 + this.form.planTimeArray[1].getMonth() - this.form.planTimeArray[0].getMonth();
if (monthsDiff*3 > this.form.planLoop) {
this.$message({
message: '可执行时间范围为'+monthsDiff*3+'季度,循环周期为'+monthsDiff*3+'季度,超过循环周期'+(monthsDiff-this.form.planLoop)+'月,请重新选择执行时间!',
type: 'warning'
})
this.form.planTimeArray = [];
return
}
}
if (this.form.planLoopType == 'year'){
//
let yearsDiff = this.form.planTimeArray[1].getFullYear() - this.form.planTimeArray[0].getFullYear();
if (yearsDiff > this.form.planLoop) {
this.$message({
message: '可执行时间范围为'+yearsDiff+'年,循环周期为'+yearsDiff+'年,超过循环周期'+(yearsDiff-this.form.planLoop)+'年,请重新选择执行时间!',
type: 'warning'
})
this.form.planTimeArray = [];
return
}
}
},
// List-穿
setPerson() {
getPersonList().then(response => {

Loading…
Cancel
Save