wujingjing
2025-03-05 4e394d1f4ed0928d5498083621966aba390a7642
src/components/chat/chatComponents/summaryCom/components/recordSet/components/TimeRange.vue
@@ -15,7 +15,7 @@
            :value-format="valueFormat"
            :format="DEFAULT_FORMATS_DATE"
            :disabled-date="disabledDate"
            :clearable="false"
            :clearable="true"
            :disabled="disabled"
            @change="datePickerChange"
         >
@@ -33,8 +33,15 @@
      <div class="ml-2 inline-flex items-center space-x-2 text-[14px]">
         <div
            @click="quickPickRangeClick(parseInt(item))"
            class="border border-solid rounded-md px-2 cursor-pointer"
            :class="{ 'bg-[#1677ff]': parseInt(item) === quickPickValue, 'text-white': parseInt(item) === quickPickValue }"
            class="border border-solid rounded-md px-2 py-1 cursor-pointer"
            :class="{
               'bg-[#1677ff]': parseInt(item) === quickPickValue,
               'text-white': parseInt(item) === quickPickValue,
               'bg-[#f5f7fa]': disabled,
               'text-[#a9acb3]': disabled,
               'border-[#dcdfe6]': disabled,
               '!cursor-not-allowed': disabled,
            }"
            v-for="item in Object.keys(timeRangeMapTitle)"
            :key="item"
         >
@@ -47,20 +54,19 @@
<script setup lang="ts">
import { ElDatePicker } from 'element-plus';
import { definePropType } from 'element-plus/es/utils/vue/props/runtime';
import { ref, type PropType, computed, watch, nextTick } from 'vue';
import moment from 'moment';
import { computed, nextTick, onMounted, ref, type PropType } from 'vue';
import type { TimeRangeParam } from '../types';
import { TimeRangeEnum, TimeStepValue, monthTimeRangeEnumMapTitle } from './types';
import { dayTimeRangeEnumMapTitle, timeRangeEnumMapValue } from './types';
import type { TimeRangeEnum } from './types';
import { TimeStepValue, dayTimeRangeEnumMapTitle, monthTimeRangeEnumMapTitle, timeRangeEnumMapValue } from './types';
import {
   CURRENT_DAY,
   DEFAULT_FORMATS_DATE,
   DEFAULT_FORMATS_TIME,
   END_PLACEHOLDER,
   RANGE_SEPARATOR,
   START_PLACEHOLDER,
} from '/@/components/form/datepicker/constants';
import { formatDate } from '/@/utils/formatTime';
import moment from 'moment';
const valueFormat = DEFAULT_FORMATS_DATE + ' ' + DEFAULT_FORMATS_TIME;
const props = defineProps({
@@ -70,6 +76,10 @@
   disabled: {
      type: Boolean,
      default: false,
   },
   quickActive: {
      type: Number as PropType<TimeRangeEnum>,
      required: false,
   },
});
@@ -92,6 +102,9 @@
const dateChange = () => {
   nextTick(() => {
      if (dateValue.value?.[1]) {
         dateValue.value[1] = dateValue.value[1].slice(0, 10) + ' 23:59:59';
      }
      emit('change', dateValue.value);
   });
};
@@ -104,12 +117,17 @@
   quickPickValue.value = null;
};
const quickPickValue = ref<TimeRangeEnum>(null);
const pickQuickRange = (val: TimeRangeEnum) => {
   // if(val==undefined) return;
   quickPickValue.value = val;
   dateValue.value = timeRangeEnumMapValue[val]().map((item) => formatDate(item)) as [string, string];
};
const quickPickRangeClick = (val: TimeRangeEnum) => {
   if (props.disabled) return;
   if (quickPickValue.value === val) return;
   quickPickValue.value = val;
   dateValue.value = timeRangeEnumMapValue[val]().map((item) => formatDate(item)) as [string, string];
   pickQuickRange(val);
   dateChange();
};
@@ -138,7 +156,11 @@
   resetQuickPickValue();
   dateChange();
};
onMounted(() => {
   if(props.quickActive !=null){
      pickQuickRange(props.quickActive);
   }
});
defineExpose({
   formatDateValue: dateValue,
});