yangyin
2024-10-25 e9060cf8f241536a896d69d0044769bd3b0e8d49
src/components/chat/chatComponents/summaryCom/components/recordSet/components/TimeRange.vue
@@ -47,7 +47,7 @@
<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 { ref, type PropType, computed, watch, nextTick, onMounted } from 'vue';
import type { TimeRangeParam } from '../types';
import type { TimeRangeEnum } from './types';
import { timeRangeEnumMapTitle, timeRangeEnumMapValue } from './types';
@@ -71,6 +71,11 @@
      type: Boolean,
      default: false,
   },
   quickActive: {
      type: Number as PropType<TimeRangeEnum>,
      required: false,
   },
});
const dateValue = defineModel({
   type: definePropType<[string, string]>(Array),
@@ -91,11 +96,16 @@
   quickPickValue.value = null;
};
const quickPickValue = ref<TimeRangeEnum>(null);
const quickPickRangeClick = (val: TimeRangeEnum) => {
   if (quickPickValue.value === val) return;
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 (quickPickValue.value === val) return;
   pickQuickRange(val);
   dateChange();
};
@@ -121,6 +131,12 @@
   dateChange();
};
onMounted(() => {
   if(props.quickActive !=null){
      pickQuickRange(props.quickActive);
   }
});
defineExpose({
   formatDateValue: dateValue,
});