[update 日期单侧范围] 选单侧传参补充

This commit is contained in:
danshihao
2024-07-16 14:54:25 +08:00
parent 0481774270
commit 30b22cfb71
+11 -1
View File
@@ -30,6 +30,8 @@
</template> </template>
<script> <script>
const minDate = '2000-01-01'
const maxDate = '3000-01-01'
export default { export default {
name: 'JDatePicker', name: 'JDatePicker',
props: { props: {
@@ -59,6 +61,14 @@ export default {
if (Array.isArray(val)) { if (Array.isArray(val)) {
this.startDate = val[0] || '' this.startDate = val[0] || ''
this.endDate = val[1] || '' this.endDate = val[1] || ''
// 如果开始日期是搜索最小日期就不显示
if (this.startDate === minDate) {
this.startDate = ''
}
// 如果结束日期是搜索最小日期就不显示
if (this.endDate === maxDate) {
this.endDate = ''
}
this.dateValue = val this.dateValue = val
} else { } else {
this.lastSelectDate = '' this.lastSelectDate = ''
@@ -102,7 +112,7 @@ export default {
}, },
// 触发change事件 // 触发change事件
triggerChange () { triggerChange () {
this.$emit('change', [this.startDate, this.endDate]) this.$emit('change', [this.startDate || minDate, this.endDate || maxDate])
}, },
// 记录最后一次点击的日期 // 记录最后一次点击的日期
clickCalendarDate (val) { clickCalendarDate (val) {