Эх сурвалжийг харах

决策驾驶舱-时间选择修改

zhongxiaoyu 1 жил өмнө
parent
commit
f2e2afe179

+ 18 - 12
src/views/dashboard/arrival.vue

@@ -348,7 +348,6 @@
       <el-form :model="form" label-width="120px">
         <el-form-item label="开始日期">
           <el-date-picker
-            :disabled-date="disabledStartDate"
             v-model="form.startDate"
             type="date"
             placeholder="请选择开始日期"
@@ -359,8 +358,8 @@
         </el-form-item>
         <el-form-item label="结束日期">
           <el-date-picker
-            :disabled-date="disabledEndDate"
             v-model="form.endDate"
+            :disabled-date="disabledEndDate"
             type="date"
             placeholder="请选择结束日期"
             size="default"
@@ -384,6 +383,7 @@ import { usePublic, showTimeMsg, parseDate } from './hooks/usePublic'
 import { parseTime, isValue } from '@/utils/validate'
 import * as _ from 'lodash'
 import { useLoop } from '@/hooks/useLoop'
+import { ElMessage } from 'element-plus'
 
 const {
   optionLeft,
@@ -418,26 +418,32 @@ const weightNums = ref<number | string>(0)
 const specialGoods = ref('全部')
 const specialGoodsDatas = ref(['动', '贵', '邮', '鲜', '锂', '全部'])
 const weightType = ref('进港')
-const today = parseTime(Date.now(), '{y}-{m}-{d}')
+const today = parseTime(Date.now(), '{y}-{m}-{d}') as string
 const sevenDaysAgo = parseTime(
   Date.now() - 24 * 60 * 60 * 1000 * 7,
   '{y}-{m}-{d}'
-)
+) as string
 const form = reactive({
   startDate: sevenDaysAgo,
   endDate: today,
 })
 const listData = ref<any>([])
-const disabledStartDate = (time: Date) => {
-  const timer: any = form.endDate
-  const data = new Date(timer)
-  return time.getTime() > data.getTime()
-}
+
+watchEffect(() => {
+  const start = new Date(form.startDate).getTime()
+  const end = new Date(form.endDate).getTime()
+  if (start > end) {
+    ElMessage.warning('开始时间不能晚于结束时间')
+    form.endDate = ''
+    return
+  }
+})
 const disabledEndDate = (time: Date) => {
-  const timer: any = form.startDate
-  let data = new Date(timer)
-  return data.getTime() > time.getTime()
+  const start = new Date(form.startDate).setHours(0)
+  const end = time.setHours(0)
+  return start > end
 }
+
 const resetForm = () => {
   flag.value = false
 }

+ 18 - 12
src/views/dashboard/departure.vue

@@ -336,7 +336,6 @@
       <el-form :model="form" label-width="120px">
         <el-form-item label="开始日期">
           <el-date-picker
-            :disabled-date="disabledStartDate"
             v-model="form.startDate"
             type="date"
             placeholder="请选择开始日期"
@@ -347,8 +346,8 @@
         </el-form-item>
         <el-form-item label="结束日期">
           <el-date-picker
-            :disabled-date="disabledEndDate"
             v-model="form.endDate"
+            :disabled-date="disabledEndDate"
             type="date"
             placeholder="请选择结束日期"
             size="default"
@@ -372,6 +371,7 @@ import { usePublic, showTimeMsg, parseDate } from './hooks/usePublic'
 import { parseTime, isValue } from '@/utils/validate'
 import * as _ from 'lodash'
 import { useLoop } from '@/hooks/useLoop'
+import { ElMessage } from 'element-plus'
 
 const {
   optionLeft,
@@ -404,26 +404,32 @@ const stockNums = ref(0)
 const specialGoods = ref('全部')
 const specialGoodsDatas = ref(['动', '贵', '邮', '鲜', '锂', '全部'])
 const weightNums = ref<number | string>(0)
-const today = parseTime(Date.now(), '{y}-{m}-{d}')
+const today = parseTime(Date.now(), '{y}-{m}-{d}') as string
 const sevenDaysAgo = parseTime(
   Date.now() - 24 * 60 * 60 * 1000 * 7,
   '{y}-{m}-{d}'
-)
+) as string
 const form = reactive({
   startDate: sevenDaysAgo,
   endDate: today,
 })
 const listData = ref<any>([])
-const disabledStartDate = (time: Date) => {
-  const timer: any = form.endDate
-  const data = new Date(timer)
-  return time.getTime() > data.getTime()
-}
+
+watchEffect(() => {
+  const start = new Date(form.startDate).getTime()
+  const end = new Date(form.endDate).getTime()
+  if (start > end) {
+    ElMessage.warning('开始时间不能晚于结束时间')
+    form.endDate = ''
+    return
+  }
+})
 const disabledEndDate = (time: Date) => {
-  const timer: any = form.startDate
-  let data = new Date(timer)
-  return data.getTime() > time.getTime()
+  const start = new Date(form.startDate).setHours(0)
+  const end = time.setHours(0)
+  return start > end
 }
+
 const resetForm = () => {
   flag.value = false
 }

+ 18 - 12
src/views/dashboard/internationalArrival.vue

@@ -350,7 +350,6 @@
       <el-form :model="form" label-width="120px">
         <el-form-item label="开始日期">
           <el-date-picker
-            :disabled-date="disabledStartDate"
             v-model="form.startDate"
             type="date"
             placeholder="请选择开始日期"
@@ -361,8 +360,8 @@
         </el-form-item>
         <el-form-item label="结束日期">
           <el-date-picker
-            :disabled-date="disabledEndDate"
             v-model="form.endDate"
+            :disabled-date="disabledEndDate"
             type="date"
             placeholder="请选择结束日期"
             size="default"
@@ -386,6 +385,7 @@ import { usePublic, showTimeMsg, parseDate } from './hooks/usePublic'
 import { parseTime, isValue } from '@/utils/validate'
 import * as _ from 'lodash'
 import { useLoop } from '@/hooks/useLoop'
+import { ElMessage } from 'element-plus'
 
 const {
   optionLeft,
@@ -429,26 +429,32 @@ const specialGoodsDatas = ref([
   '全部',
 ])
 const weightType = ref('进港')
-const today = parseTime(Date.now(), '{y}-{m}-{d}')
+const today = parseTime(Date.now(), '{y}-{m}-{d}') as string
 const sevenDaysAgo = parseTime(
   Date.now() - 24 * 60 * 60 * 1000 * 7,
   '{y}-{m}-{d}'
-)
+) as string
 const form = reactive({
   startDate: sevenDaysAgo,
   endDate: today,
 })
 const listData = ref<any>([])
-const disabledStartDate = (time: Date) => {
-  const timer: any = form.endDate
-  const data = new Date(timer)
-  return time.getTime() > data.getTime()
-}
+
+watchEffect(() => {
+  const start = new Date(form.startDate).getTime()
+  const end = new Date(form.endDate).getTime()
+  if (start > end) {
+    ElMessage.warning('开始时间不能晚于结束时间')
+    form.endDate = ''
+    return
+  }
+})
 const disabledEndDate = (time: Date) => {
-  const timer: any = form.startDate
-  let data = new Date(timer)
-  return data.getTime() > time.getTime()
+  const start = new Date(form.startDate).setHours(0)
+  const end = time.setHours(0)
+  return start > end
 }
+
 const resetForm = () => {
   flag.value = false
 }

+ 18 - 12
src/views/dashboard/internationalDeparture.vue

@@ -338,7 +338,6 @@
       <el-form :model="form" label-width="120px">
         <el-form-item label="开始日期">
           <el-date-picker
-            :disabled-date="disabledStartDate"
             v-model="form.startDate"
             type="date"
             placeholder="请选择开始日期"
@@ -349,8 +348,8 @@
         </el-form-item>
         <el-form-item label="结束日期">
           <el-date-picker
-            :disabled-date="disabledEndDate"
             v-model="form.endDate"
+            :disabled-date="disabledEndDate"
             type="date"
             placeholder="请选择结束日期"
             size="default"
@@ -374,6 +373,7 @@ import { usePublic, showTimeMsg, parseDate } from './hooks/usePublic'
 import { parseTime, isValue } from '@/utils/validate'
 import * as _ from 'lodash'
 import { useLoop } from '@/hooks/useLoop'
+import { ElMessage } from 'element-plus'
 
 const {
   optionLeft,
@@ -415,26 +415,32 @@ const specialGoodsDatas = ref([
   '全部',
 ])
 const weightNums = ref<number | string>(0)
-const today = parseTime(Date.now(), '{y}-{m}-{d}')
+const today = parseTime(Date.now(), '{y}-{m}-{d}') as string
 const sevenDaysAgo = parseTime(
   Date.now() - 24 * 60 * 60 * 1000 * 7,
   '{y}-{m}-{d}'
-)
+) as string
 const form = reactive({
   startDate: sevenDaysAgo,
   endDate: today,
 })
 const listData = ref<any>([])
-const disabledStartDate = (time: Date) => {
-  const timer: any = form.endDate
-  const data = new Date(timer)
-  return time.getTime() > data.getTime()
-}
+
+watchEffect(() => {
+  const start = new Date(form.startDate).getTime()
+  const end = new Date(form.endDate).getTime()
+  if (start > end) {
+    ElMessage.warning('开始时间不能晚于结束时间')
+    form.endDate = ''
+    return
+  }
+})
 const disabledEndDate = (time: Date) => {
-  const timer: any = form.startDate
-  let data = new Date(timer)
-  return data.getTime() > time.getTime()
+  const start = new Date(form.startDate).setHours(0)
+  const end = time.setHours(0)
+  return start > end
 }
+
 const resetForm = () => {
   flag.value = false
 }