From c7a16ca1b6fbcb0b82a4a09c2e75014624082e37 Mon Sep 17 00:00:00 2001
From: Riku <risaku@163.com>
Date: 星期四, 27 三月 2025 22:45:48 +0800
Subject: [PATCH] 修复走航融合功能bug
---
src/components/search/OptionTime.vue | 47 +++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/src/components/search/OptionTime.vue b/src/components/search/OptionTime.vue
index 29ccf19..bb11f85 100644
--- a/src/components/search/OptionTime.vue
+++ b/src/components/search/OptionTime.vue
@@ -7,20 +7,30 @@
start-placeholder="閫夋嫨寮�濮嬫椂闂�"
end-placeholder="閫夋嫨缁撴潫鏃堕棿"
size="small"
+ :disabled-date="diableData"
/>
</el-form-item>
</template>
<script>
+import moment from 'moment';
+import { ElMessage } from 'element-plus';
+
export default {
props: {
+ // 鏃ユ湡鍊�
modelValue: {
type: Array
},
+ // 鎺т欢绫诲瀷
type: {
type: String,
default: 'datetimerange'
- }
+ },
+ // 鍏佽寮�濮嬫椂闂�
+ startDate: Date,
+ // 鍏佽缁撴潫鏃堕棿
+ endDate: Date
},
emits: ['update:modelValue'],
data() {
@@ -28,7 +38,40 @@
},
methods: {
handleChange(value) {
- this.$emit('update:modelValue', value);
+ // 鏃堕棿涓嶈兘瓒呰繃璁惧畾鐨勫紑濮嬬粨鏉熸椂闂�
+ let outRange = false;
+ if (this.startDate) {
+ outRange =
+ outRange ||
+ moment(value[0]).isBefore(this.startDate) ||
+ moment(value[1]).isBefore(this.startDate);
+ }
+ if (this.endDate) {
+ outRange =
+ outRange ||
+ moment(value[0]).isAfter(this.endDate) ||
+ moment(value[1]).isAfter(this.endDate);
+ }
+ if (outRange) {
+ ElMessage({
+ message: '鎵�閫夋椂闂翠笉鑳借秴杩囪蛋鑸换鍔℃椂闂磋寖鍥�',
+ type: 'warning'
+ });
+ } else {
+ this.$emit('update:modelValue', value);
+ }
+ },
+ diableData(date) {
+ const time = moment(date);
+ let result1 = false;
+ let result2 = false;
+ if (this.startDate) {
+ result1 = time.isBefore(this.startDate);
+ }
+ if (this.endDate) {
+ result2 = time.isAfter(this.endDate);
+ }
+ return result1 || result2;
}
},
mounted() {
--
Gitblit v1.9.3