From 4e394d1f4ed0928d5498083621966aba390a7642 Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期三, 05 三月 2025 16:05:15 +0800
Subject: [PATCH] 图表查询

---
 src/components/chat/chatComponents/summaryCom/components/recordSet/components/TimeRange.vue |   49 ++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 38 insertions(+), 11 deletions(-)

diff --git a/src/components/chat/chatComponents/summaryCom/components/recordSet/components/TimeRange.vue b/src/components/chat/chatComponents/summaryCom/components/recordSet/components/TimeRange.vue
index 005ad19..29ab49d 100644
--- a/src/components/chat/chatComponents/summaryCom/components/recordSet/components/TimeRange.vue
+++ b/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,16 +117,24 @@
 	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 (props.disabled) return;
+	if (quickPickValue.value === val) return;
+
+	pickQuickRange(val);
 	dateChange();
 };
 
 const offsetClickIsAllow = computed(() => !!dateValue.value && !props.disabled);
 const preDayClick = () => {
+	if (props.disabled) return;
+
 	if (!dateValue.value) return;
 	dateValue.value[0] = moment(dateValue.value[0]).subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss');
 	dateChange();
@@ -122,6 +143,8 @@
 };
 
 const nextDayClick = () => {
+	if (props.disabled) return;
+
 	if (!dateValue.value) return;
 	dateValue.value[1] = moment(dateValue.value[1]).add(1, 'day').format('YYYY-MM-DD HH:mm:ss');
 	dateChange();
@@ -133,7 +156,11 @@
 	resetQuickPickValue();
 	dateChange();
 };
-
+onMounted(() => {
+	if(props.quickActive !=null){
+		pickQuickRange(props.quickActive);
+	}
+});
 defineExpose({
 	formatDateValue: dateValue,
 });

--
Gitblit v1.9.3