From c5a78887cbcd9499787cd46d41812a092f441089 Mon Sep 17 00:00:00 2001 From: "@changcode" Date: Wed, 19 Oct 2022 09:57:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8A=A5=E5=91=8Abox=20Time=20limit=20?= =?UTF-8?q?=E4=B8=BA=20customize=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E9=80=89=E6=8B=A9=E5=99=A8=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/rightBox/report/ReportBox.vue | 52 +++++++++----------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/src/components/rightBox/report/ReportBox.vue b/src/components/rightBox/report/ReportBox.vue index 45664ed7..a7561629 100644 --- a/src/components/rightBox/report/ReportBox.vue +++ b/src/components/rightBox/report/ReportBox.vue @@ -74,6 +74,7 @@ size="small" :format="dateFormat" :disabled="!!editObject.id" + :disabled-date="disabledDate" prefix-icon="cn-icon cn-icon-shijian" type="datetime" placeholder=" " @@ -91,6 +92,8 @@ size="small" :format="dateFormat" :disabled="!!editObject.id" + :disabled-date="disabledDate" + @change="timeChange" prefix-icon="cn-icon cn-icon-shijian" type="datetime" placeholder=" " @@ -277,6 +280,7 @@ import { api } from '@/utils/api' import _ from 'lodash' import { get, post, put } from '@/utils/http' import { dateFormat, getMillisecond } from '@/utils/date-util' +import { ref } from 'vue' const paramValidator = (rule, value, callback) => { let validate = true if (value && value.length > 0) { @@ -305,6 +309,24 @@ export default { categoryList: Array, currentCategoryId: Number }, + setup () { + const picker = ref('') + function timeChange (val) { + picker.value = val + } + const disabledDate = (time) => { + if (time.getTime() > new Date()) { + return true + } + if (picker.value != '' && picker.value < time) { + return true + } + } + return { + disabledDate, + timeChange + } + }, data () { return { url: api.reportTemp, @@ -431,36 +453,6 @@ export default { } } }, - 'editObject.config.startTime': { - handler (n) { - const nowDate = new Date().getTime() - const starDate = new Date(this.editObject.config.startTime) - const endData = new Date(this.editObject.config.endTime) - if (this.editObject.config.endTime !== null && this.editObject.config.startTime !== null) { - if (starDate.getTime() > endData.getTime()) { - this.editObject.config.startTime = '' - } - } - if (this.editObject.config.startTime !== null && starDate.getTime() > nowDate) { - this.editObject.config.startTime = '' - } - } - }, - 'editObject.config.endTime': { - handler (n) { - const nowDate = new Date().getTime() - const starDate = new Date(this.editObject.config.startTime) - const endData = new Date(this.editObject.config.endTime) - if (this.editObject.config.endTime !== null && this.editObject.config.startTime !== null) { - if (starDate.getTime() > endData.getTime()) { - this.editObject.config.endTime = '' - } - } - if (this.editObject.config.startTime !== null && endData.getTime() > nowDate) { - this.editObject.config.endTime = '' - } - } - }, object: { deep: true, immediate: true,