| | |
| | | <div class="flex items-center"> |
| | | <div class="flex items-center space-x-1"> |
| | | <div |
| | | class="ywicon icon-pre" |
| | | class="ywifont ywicon-pre" |
| | | :class="{ 'cursor-not-allowed': !offsetClickIsAllow, 'cursor-pointer': offsetClickIsAllow }" |
| | | @click="preDayClick" |
| | | ></div> |
| | |
| | | :disabled-date="disabledDate" |
| | | :clearable="false" |
| | | :disabled="disabled" |
| | | @change="datePickerChange" |
| | | > |
| | | <template v-for="(value, name) in $slots" #[name]="slotData"> |
| | | <slot :name="name" v-bind="slotData || {}"></slot> |
| | | </template> |
| | | </el-date-picker> |
| | | <div |
| | | class="ywicon icon-next" |
| | | class="ywifont ywicon-next" |
| | | :class="{ 'cursor-not-allowed': !offsetClickIsAllow, 'cursor-pointer': offsetClickIsAllow }" |
| | | @click="nextDayClick" |
| | | ></div> |
| | |
| | | import { ElDatePicker } from 'element-plus'; |
| | | import { definePropType } from 'element-plus/es/utils/vue/props/runtime'; |
| | | import { ref, type PropType, computed, watch } from 'vue'; |
| | | import type { TimestampParam } from '../types'; |
| | | import type { TimeRangeParam } from '../types'; |
| | | import type { TimeRangeEnum } from './types'; |
| | | import { timeRangeEnumMapTitle, timeRangeEnumMapValue } from './types'; |
| | | import { |
| | |
| | | const valueFormat = DEFAULT_FORMATS_DATE + ' ' + DEFAULT_FORMATS_TIME; |
| | | const props = defineProps({ |
| | | data: { |
| | | type: Object as PropType<TimestampParam>, |
| | | type: Object as PropType<TimeRangeParam>, |
| | | }, |
| | | disabled: { |
| | | type: Boolean, |
| | |
| | | const disabledDate = (date: Date) => { |
| | | return date > CURRENT_DAY; |
| | | }; |
| | | |
| | | const resetQuickPickValue = () =>{ |
| | | quickPickValue.value = null; |
| | | } |
| | | const quickPickValue = ref<TimeRangeEnum>(null); |
| | | const quickPickRangeClick = (val: TimeRangeEnum) => { |
| | | if (quickPickValue.value === val) return; |
| | |
| | | if (!dateValue.value) return; |
| | | dateValue.value[0] = moment(dateValue.value[0]).subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss'); |
| | | dateValue.value = [...dateValue.value]; |
| | | resetQuickPickValue(); |
| | | |
| | | }; |
| | | |
| | | const nextDayClick = () => { |
| | | if (!dateValue.value) return; |
| | | dateValue.value[1] = moment(dateValue.value[1]).add(1, 'day').format('YYYY-MM-DD HH:mm:ss'); |
| | | dateValue.value = [...dateValue.value]; |
| | | resetQuickPickValue(); |
| | | }; |
| | | |
| | | const datePickerChange = (va) => { |
| | | resetQuickPickValue(); |
| | | }; |
| | | |
| | | watch( |
| | |
| | | emit('change', val); |
| | | } |
| | | ); |
| | | |
| | | defineExpose({ |
| | | formatDateValue |
| | | }) |
| | | </script> |
| | | <style scoped lang="scss"> |
| | | :deep(.el-date-editor .el-range__close-icon--hidden) { |