zhongxiaoyu 2 жил өмнө
parent
commit
2315ebede0

+ 55 - 0
src/views/advancedQuery/views/advancedHome.vue

@@ -11,6 +11,7 @@
             type="date"
             value-format="yyyy-MM-dd"
             placeholder="选择开始日期时间"
+            @change="startDateChangeHandler"
           />
         </div>
         <div class="interfaceLog_head_time_end">
@@ -21,6 +22,7 @@
             type="date"
             value-format="yyyy-MM-dd"
             placeholder="选择结束日期时间"
+            @change="endDateChangeHandler"
           />
         </div>
       </div>
@@ -164,6 +166,7 @@
                       value-format="yyyy-MM-dd"
                       start-placeholder="开始日期"
                       end-placeholder="结束日期"
+                      :picker-options="dateRangePickerOptions"
                       @keyup.esc.native="dialogFocus"
                     />
                   </template>
@@ -463,6 +466,10 @@ export default {
         }
       ],
       FlightDate: [parseTime(new Date(), '{y}-{m}-{d}'), parseTime(new Date(), '{y}-{m}-{d}')],
+      dateRangePickerOptions: {
+        onPick: this.dateRangePickHandler,
+        disabledDate: this.dateRangeDisabled
+      },
       form: {
         FlightNO: '',
         destination: '',
@@ -646,6 +653,14 @@ export default {
     }
   },
   watch: {
+    FlightDate: {
+      handler(val) {
+        if (val === null) {
+          this.FlightDate = ['', '']
+        }
+      },
+      deep: true
+    },
     dealedTableData: {
       handler(val) {
         this.spanArr = []
@@ -749,6 +764,46 @@ export default {
     dialogFocus() {
       this.$refs['dialog'].focus()
     },
+    startDateChangeHandler(val) {
+      this.FlightDate[0] = val ?? ''
+      if (!val || !this.FlightDate[1]) {
+        return
+      }
+      const startDate = new Date(val)
+      const endDate = new Date(this.FlightDate[1])
+      if (startDate > endDate) {
+        this.FlightDate.splice(1, 1, '')
+        this.$message.info('结束时间不能早于开始时间,请重新选择')
+      } else if (endDate - startDate > 2 * 24 * 60 * 60 * 1000) {
+        this.FlightDate.splice(1, 1, '')
+        this.$message.info('时间跨度不能超过三天,请重新选择')
+      }
+    },
+    endDateChangeHandler(val) {
+      this.FlightDate[1] = val ?? ''
+      if (!val || !this.FlightDate[0]) {
+        return
+      }
+      const startDate = new Date(this.FlightDate[0])
+      const endDate = new Date(val)
+      if (startDate > endDate) {
+        this.FlightDate.splice(0, 1, '')
+        this.$message.info('开始时间不能晚于结束时间,请重新选择')
+      } else if (endDate - startDate > 2 * 24 * 60 * 60 * 1000) {
+        this.FlightDate.splice(0, 1, '')
+        this.$message.info('时间跨度不能超过三天,请重新选择')
+      }
+    },
+    dateRangePickHandler({ maxDate, minDate }) {
+      if (!maxDate) {
+        this.pickedDate = minDate
+      } else {
+        this.pickedDate = null
+      }
+    },
+    dateRangeDisabled(date) {
+      return this.pickedDate ? Math.abs(date - this.pickedDate) > 2 * 24 * 60 * 60 * 1000 : false
+    },
     objectSpanMethod({ row, column, rowIndex, columnIndex }) {
       if (['PassengerNameUpcase', 'BagWeight'].includes(column.property)) {
         const _row = this.spanArr[rowIndex]

+ 2 - 2
src/views/baggageManagement/components/arrival/index.vue

@@ -58,7 +58,7 @@
               type="date"
               value-format="yyyy-MM-dd"
               placeholder="开始时间"
-              @change="setStartDate"
+              @change="startDateChangeHandler"
             />
           </el-form-item>
           <el-form-item prop="endDate">
@@ -70,7 +70,7 @@
               type="date"
               value-format="yyyy-MM-dd"
               placeholder="结束时间"
-              @change="setEndDate"
+              @change="endDateChangeHandler"
             />
           </el-form-item>
           <el-form-item>

+ 2 - 2
src/views/baggageManagement/components/departure/index.vue

@@ -58,7 +58,7 @@
               type="date"
               value-format="yyyy-MM-dd"
               placeholder="开始时间"
-              @change="setStartDate"
+              @change="startDateChangeHandler"
             />
           </el-form-item>
           <el-form-item prop="endDate">
@@ -70,7 +70,7 @@
               type="date"
               value-format="yyyy-MM-dd"
               placeholder="结束时间"
-              @change="setEndDate"
+              @change="endDateChangeHandler"
             />
           </el-form-item>
           <el-form-item>

+ 2 - 2
src/views/baggageManagement/components/transferArrival/index.vue

@@ -88,7 +88,7 @@
               type="date"
               value-format="yyyy-MM-dd"
               placeholder="开始时间"
-              @change="setStartDate"
+              @change="startDateChangeHandler"
             />
           </el-form-item>
           <el-form-item prop="endDate">
@@ -100,7 +100,7 @@
               type="date"
               value-format="yyyy-MM-dd"
               placeholder="结束时间"
-              @change="setEndDate"
+              @change="endDateChangeHandler"
             />
           </el-form-item>
         </div>

+ 2 - 2
src/views/baggageManagement/components/transferDeparture/index.vue

@@ -88,7 +88,7 @@
               type="date"
               value-format="yyyy-MM-dd"
               placeholder="开始时间"
-              @change="setStartDate"
+              @change="startDateChangeHandler"
             />
           </el-form-item>
           <el-form-item prop="endDate">
@@ -100,7 +100,7 @@
               type="date"
               value-format="yyyy-MM-dd"
               placeholder="结束时间"
-              @change="setEndDate"
+              @change="endDateChangeHandler"
             />
           </el-form-item>
         </div>

+ 20 - 18
src/views/baggageManagement/mixins/form.js

@@ -1,7 +1,7 @@
 /*
  * @Author: Badguy
  * @Date: 2022-03-04 14:45:03
- * @LastEditTime: 2022-05-27 15:26:58
+ * @LastEditTime: 2022-06-07 16:15:27
  * @LastEditors: your name
  * @Description: 航站视图通用表单部分
  * have a nice day!
@@ -160,34 +160,36 @@ export default {
       this.getFormData(params)
     },
     // 日期限制
-    setStartDate(val) {
-      // this.formClear('all')
-      if (!val) {
+    startDateChangeHandler(val) {
+      if (!val || !this.endDate) {
         return
       }
-      if (this.formData.endDate && this.formData.endDate < val) {
+      const startDate = new Date(val)
+      const endDate = new Date(this.endDate)
+      if (startDate > endDate) {
         this.formData.endDate = ''
-        this.$message.error('结束时间不能小于开始时间,请重新选择')
-        return false
+        this.$message.info('结束时间不能早于开始时间,请重新选择')
+      } else if (endDate - startDate > 2 * 24 * 60 * 60 * 1000) {
+        this.formData.endDate = ''
+        this.$message.info('时间跨度不能超过三天,请重新选择')
       } else {
         this.getTableData()
-        // this.currentAirportQuery()
-        return true
       }
     },
-    setEndDate(val) {
-      // this.formClear('all')
-      if (!val) {
+    endDateChangeHandler(val) {
+      if (!val || !this.startDate) {
         return
       }
-      if (this.formData.startDate && this.formData.startDate > val) {
-        this.formData.endDate = ''
-        this.$message.error('结束时间不能小于开始时间,请重新选择')
-        return false
+      const startDate = new Date(this.startDate)
+      const endDate = new Date(val)
+      if (startDate > endDate) {
+        this.formData.startDate = ''
+        this.$message.info('开始时间不能晚于结束时间,请重新选择')
+      } else if (endDate - startDate > 2 * 24 * 60 * 60 * 1000) {
+        this.formData.startDate = ''
+        this.$message.info('时间跨度不能超过三天,请重新选择')
       } else {
         this.getTableData()
-        // this.currentAirportQuery()
-        return true
       }
     },
     // 搜索