diff --git a/src/views/device/inspectionPlan/index.vue b/src/views/device/inspectionPlan/index.vue index d403bc1..7494e84 100644 --- a/src/views/device/inspectionPlan/index.vue +++ b/src/views/device/inspectionPlan/index.vue @@ -347,6 +347,7 @@ 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 => {