From 9c81ad77ea847ab2f6fcc5a6257dda9abb200a1e Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期二, 22 十月 2024 12:07:06 +0800
Subject: [PATCH] 同步后台管理组件

---
 src/components/chat/chatComponents/summaryCom/components/recordSet/RecordSet.vue           |   52 +++++++++++------
 /dev/null                                                                                  |    8 --
 src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue |   95 +++++++++++++++++++++++++------
 src/components/chat/chatComponents/summaryCom/components/recordSet/types.ts                |    6 +
 4 files changed, 115 insertions(+), 46 deletions(-)

diff --git a/src/components/chat/chatComponents/summaryCom/components/recordSet/RecordSet.vue b/src/components/chat/chatComponents/summaryCom/components/recordSet/RecordSet.vue
index e2c5822..3f9c2d5 100644
--- a/src/components/chat/chatComponents/summaryCom/components/recordSet/RecordSet.vue
+++ b/src/components/chat/chatComponents/summaryCom/components/recordSet/RecordSet.vue
@@ -3,7 +3,7 @@
 	<div class="w-full flex-column">
 		<div class="flex mb-4 flex-wrap flex-0">
 			<!-- TimeRange v-model 璺� @change 涓殑鍊间細涓嶄竴鏍凤紝浠change 涓负鍑� -->
-			<template v-if="visibleParams && visibleParams.length > 0">
+			<template v-if="visibleParams && visibleParams.length > 0 && showFilter">
 				<component
 					class="flex-0 m-2"
 					v-model="visibleParams[index].value"
@@ -80,6 +80,7 @@
 // 		type: Object as PropType<RecordSet>,
 // 	},
 // });
+
 const emits = defineEmits<{
 	(event: 'updateQuery', res: any): void;
 }>();
@@ -98,10 +99,15 @@
 		type: String,
 		required: false,
 	},
+	showFilter: {
+		type: Boolean,
+		default: true,
+	},
 }) as {
 	data: any;
 	summaryIndex: number;
 };
+
 const tableLimitHeight = props.chartHeight == undefined ? undefined : document.body.clientHeight * 0.7;
 
 const chartLoading = ref(false);
@@ -393,32 +399,36 @@
 };
 const { chartContainerResize, chartInstance } = useDrawChatChart({ chartRef, drawChart });
 
-const updateCurrent = (res) => {
+const updateCurrent = (res, isNew = false) => {
 	const title = res?.title;
 	const values = res?.values ?? [];
 	//#region ====================== 鍒锋柊褰撳墠 filter ======================
 	// 鍙洿鏂� value锛屼笉鐩存帴瑕嗙洊锛岄槻姝涪澶卞搷搴旀��
-	updateVisibleParams(res);
+	// updateVisibleParams(res);
 	//#endregion
 	groupedValues = _.groupBy(values, (item) => item[nameIndex]);
 	if (isMultiCompare.value) {
 		handleMultiCompare();
 	} else {
-		(currentSeries.value =
-			groupedValues &&
-			Object.keys(groupedValues).map((item, index) => {
-				const values = groupedValues[item];
-				return {
-					name: currentSeries.value[index].name,
-					data: values.map((item) => [item[timeIndex], item[valueIndex]]),
-				};
-			})),
-			chartInstance.value.setOption({
-				title: {
-					text: title,
-				},
-				series: currentSeries.value,
-			});
+		if (isNew) {
+			setNewOption();
+		} else {
+			(currentSeries.value =
+				groupedValues &&
+				Object.keys(groupedValues).map((item, index) => {
+					const values = groupedValues[item];
+					return {
+						name: item === 'default' ? '' : item,
+						data: values.map((item) => [item[timeIndex], item[valueIndex]]),
+					};
+				})),
+				chartInstance.value?.setOption({
+					title: {
+						text: title,
+					},
+					series: currentSeries.value,
+				});
+		}
 	}
 };
 
@@ -698,12 +708,18 @@
 	updateCurrent(newSummary);
 };
 
+const updateIndexSummary = (summary) => {
+	updateCurrent(summary?.[props.summaryIndex],true);
+};
+
 defineExpose({
 	drawChart,
 	isMultiCompare,
 	handleMultiCompare,
 	handleData,
 	updateAll,
+
+	updateIndexSummary,
 });
 </script>
 <style scoped lang="scss"></style>
diff --git a/src/components/chat/chatComponents/summaryCom/components/recordSet/types.ts b/src/components/chat/chatComponents/summaryCom/components/recordSet/types.ts
index b106015..92a6939 100644
--- a/src/components/chat/chatComponents/summaryCom/components/recordSet/types.ts
+++ b/src/components/chat/chatComponents/summaryCom/components/recordSet/types.ts
@@ -2,12 +2,13 @@
 import Timestamp from './components/Timestamp.vue';
 import TimeRange from './components/TimeRange.vue';
 import { ChartTypeEnum } from '../../../types';
-
+import StringInput from '../recordSetTable/components/StringInput.vue'
 export const enum RecordSetParamsType {
 	Step = 'time_step',
 
-	/** @description start 鍜� end 鍚堝苟涓轰竴涓� range */
 	TimeRange = 'time_range',
+	StringInput='string',
+
 }
 
 export type BaseParam = {
@@ -45,6 +46,7 @@
 export const recordSetMapCom = {
 	[RecordSetParamsType.Step]: List,
 	[RecordSetParamsType.TimeRange]: TimeRange,
+	[RecordSetParamsType.StringInput]:StringInput
 };
 
 export const scoreMap = {
diff --git a/src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue b/src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue
index 17d4558..8200f5c 100644
--- a/src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue
+++ b/src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue
@@ -2,14 +2,14 @@
 <template>
 	<div class="w-full flex-column">
 		<div class="flex-0 flex-items-center mb-1 h-[38px]">
-			<template v-if="visibleParams && visibleParams.length > 0">
+			<template v-if="visibleParams && visibleParams.length > 0 && showFilter">
 				<component
 					class="flex-0 m-2"
 					v-model="visibleParams[index].value"
 					v-for="(item, index) in visibleParams as any"
 					:key="item.id"
 					:id="item.id"
-					:is="recordSetTableMap[item.type]"
+					:is="recordSetMapCom[item.type]"
 					:data="item"
 					@change="(val) => handleQueryChange(val, item)"
 					:originData="originData"
@@ -97,9 +97,9 @@
 import { TableCol } from '/@/components/table/colFilter/types';
 import { debounce, getTextWidth } from '/@/utils/util';
 import InfoDetail from './infoDetail/InfoDetail.vue';
-import { RecordSetTableType, recordSetTableMap } from './types';
 import StringInput from './components/StringInput.vue';
 import { curveQuery } from '/@/api/ai/chat';
+import { RecordSetParamsType, recordSetMapCom } from '../recordSet/types';
 
 const props = defineProps({
 	data: {
@@ -111,9 +111,13 @@
 	summaryIndex: {
 		type: Number,
 	},
-	tableLimitHeight:{
-		type:Number,
-		required:false
+	tableLimitHeight: {
+		type: Number,
+		required: false,
+	},
+	showFilter:{
+		type:Boolean,
+		default:true
 	}
 });
 
@@ -394,7 +398,7 @@
 	const headerHeight = tableRef.value.$el.querySelector('.el-table__header-wrapper').clientHeight;
 
 	// 闄愬埗楂樺害
-	const limitHeight =props.tableLimitHeight ??containerRef.value.clientHeight;
+	const limitHeight = props.tableLimitHeight ?? containerRef.value.clientHeight;
 
 	// 姹� size
 	// size*cellHeight + size*THICK_BORDER_WIDTH + headerHeight <= limitHeight;
@@ -453,8 +457,13 @@
 	let res = null;
 
 	// 鏀瑰彉鍘熷鍊�
-	if (item.type === RecordSetTableType.StringInput) {
+	if (item.type === RecordSetParamsType.StringInput) {
 		item.origin.value = val;
+	} else if (item.type === RecordSetParamsType.TimeRange) {
+		item.origin.start_value = val[0];
+		item.origin.end_value = val[1];
+	} else if (item.type === RecordSetParamsType.Step) {
+		item.origin.step_value = val;
 	}
 	try {
 		// 鐩稿悓 agent_key 涓嬫墍鏈� filter 璇锋眰鍙傛暟
@@ -462,11 +471,32 @@
 			if (curVal.agent_key !== curAgentKey) return preVal;
 
 			const filter = (curVal.filter ?? []).reduce((subPreVal, subCurVal) => {
-				if (subCurVal.type === RecordSetTableType.StringInput) {
+				if (subCurVal.type === RecordSetParamsType.StringInput) {
 					subPreVal.push({
 						update: subCurVal.update,
 						value: subCurVal.value,
 						path: subCurVal.path,
+					});
+				} else if (subCurVal.type === RecordSetParamsType.TimeRange) {
+					subPreVal.push(
+						...[
+							{
+								update: subCurVal.update,
+								value: subCurVal.start_value,
+								path: subCurVal.start_path,
+							},
+							{
+								update: subCurVal.update,
+								value: subCurVal.end_value,
+								path: subCurVal.end_path,
+							},
+						]
+					);
+				} else if (subCurVal.type === RecordSetParamsType.Step) {
+					subPreVal.push({
+						update: subCurVal.update,
+						value: subCurVal.step_value,
+						path: subCurVal.step_path,
 					});
 				}
 
@@ -495,17 +525,21 @@
 const debounceQueryUpdate = debounce(queryUpdate, 600);
 
 const handleQueryChange = async (val: any, item: any) => {
-	if (item.type === RecordSetTableType.StringInput) {
+	if (item.type === RecordSetParamsType.StringInput) {
 		debounceQueryUpdate(val, item);
+	}else{
+		queryUpdate(val, item);
 	}
-
-	// queryUpdate(val,item)
-
-	return;
 };
 
 //#endregion
-
+const stepOptions = [
+	{ title: '5鍒嗛挓', value: '5 minutes' },
+	{ title: '10鍒嗛挓', value: '10 minutes' },
+	{ title: '鍗婂皬鏃�', value: '30 minutes' },
+	{ title: '1灏忔椂', value: '1 hours' },
+	{ title: '1澶�', value: '1 days' },
+];
 const getVisibleParams = (data) => {
 	// const visibleList = props.data?.params?.filter((item) => !item?.hide) ?? [];
 	// index 浣滀负 id
@@ -516,13 +550,33 @@
 		return item;
 	});
 	const newList: any[] = [];
+
 	for (let index = 0; index < visibleList.length; index++) {
 		const current = visibleList[index];
 		switch (current.type) {
-			case RecordSetTableType.StringInput:
+			case RecordSetParamsType.TimeRange:
 				newList.push({
 					id: current.id,
-					type: RecordSetTableType.StringInput,
+					type: RecordSetParamsType.TimeRange,
+					origin: current,
+					value: [current.start_value, current.end_value],
+					title: current.title,
+				});
+				break;
+			case RecordSetParamsType.Step:
+				newList.push({
+					id: current.id,
+					type: RecordSetParamsType.Step,
+					origin: current,
+					value: current.step_value,
+					list: stepOptions,
+					title: current.title,
+				});
+				break;
+			case RecordSetParamsType.StringInput:
+				newList.push({
+					id: current.id,
+					type: RecordSetParamsType.StringInput,
 					origin: current,
 					value: current?.value ?? '',
 					title: current.title,
@@ -546,7 +600,7 @@
 		const currentItem = visibleParams.value.find((item) => item.id === index + '');
 
 		if (currentItem) {
-			if (newItem.type === RecordSetTableType.StringInput) {
+			if (newItem.type === RecordSetParamsType.StringInput) {
 				currentItem.value = newItem.value;
 			}
 		}
@@ -599,9 +653,14 @@
 
 	updateCurrent(newSummary);
 };
+const updateIndexSummary = (summary)=>{
+	updateCurrent(summary?.[props.summaryIndex])
+}
 
 defineExpose({
 	updateAll,
+	updateCurrent,
+	updateIndexSummary
 });
 </script>
 <style scoped lang="scss">
diff --git a/src/components/chat/chatComponents/summaryCom/components/recordSetTable/types.ts b/src/components/chat/chatComponents/summaryCom/components/recordSetTable/types.ts
deleted file mode 100644
index 591b063..0000000
--- a/src/components/chat/chatComponents/summaryCom/components/recordSetTable/types.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import StringInput from './components/StringInput.vue'
-
-export const enum RecordSetTableType {
-	StringInput = 'string',
-}
-export const recordSetTableMap = {
-	[RecordSetTableType.StringInput]: StringInput,
-};

--
Gitblit v1.9.3