gerson
2024-08-25 9a8a56f6d2cfe0ab9ec9368d58d03d1cf10ade28
src/components/chat/chatComponents/summaryCom/components/recordSet/components/TimeRange.vue
@@ -2,7 +2,7 @@
   <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>
@@ -17,13 +17,14 @@
            :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>
@@ -47,7 +48,7 @@
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 {
@@ -64,7 +65,7 @@
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,
@@ -95,6 +96,10 @@
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;
@@ -108,12 +113,19 @@
   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(
@@ -122,6 +134,10 @@
      emit('change', val);
   }
);
defineExpose({
   formatDateValue
})
</script>
<style scoped lang="scss">
:deep(.el-date-editor .el-range__close-icon--hidden) {