From 545109f5b8fe240cb12ea613fc58aec1551b1b09 Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期二, 12 十一月 2024 11:53:39 +0800
Subject: [PATCH] 排序

---
 src/components/chat/chatComponents/summaryCom/components/recordSet/RecordSet.vue           |   90 ++++++++++++++++--------------
 vite.config.ts                                                                             |    2 
 src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue |   71 +++++++++++++++++------
 3 files changed, 100 insertions(+), 63 deletions(-)

diff --git a/src/components/chat/chatComponents/summaryCom/components/recordSet/RecordSet.vue b/src/components/chat/chatComponents/summaryCom/components/recordSet/RecordSet.vue
index 0adb614..34dcd70 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 && showFilter ">
+			<template v-if="visibleParams && visibleParams.length > 0 && showFilter">
 				<component
 					class="flex-0 m-2"
 					v-model="visibleParams[index].value"
@@ -14,7 +14,7 @@
 					:data="item"
 					:originData="originData"
 					@change="(val) => handleQueryChange(val, item)"
-					:disabled="chartLoading ||disabled"
+					:disabled="chartLoading || disabled"
 				></component>
 			</template>
 			<slot> </slot>
@@ -104,10 +104,10 @@
 		type: Boolean,
 		default: true,
 	},
-	disabled:{
-		type:Boolean,
-		default:false,
-	}
+	disabled: {
+		type: Boolean,
+		default: false,
+	},
 }) as {
 	data: any;
 	summaryIndex: number;
@@ -448,10 +448,49 @@
 	}
 };
 
+const getFilterList = () => {
+	const curAgentKey = props.data.agent_key;
+
+	// 鐩稿悓 agent_key 涓嬫墍鏈� filter 璇锋眰鍙傛暟
+	const filterList = ((props as any).originData?.content?.origin?.summary ?? []).reduce((preVal, curVal) => {
+		if (curVal.agent_key !== curAgentKey) return preVal;
+
+		const filter = (curVal.filter ?? []).reduce((subPreVal, subCurVal) => {
+			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 {
+				subPreVal.push({
+					update: subCurVal.update,
+					value: subCurVal.step_value,
+					path: subCurVal.step_path,
+				});
+			}
+
+			return subPreVal;
+		}, []);
+
+		preVal = preVal.concat(filter);
+
+		return preVal;
+	}, []);
+	return filterList;
+};
 const handleQueryChange = async (val: any, item: RecordSetParamsItem) => {
 	if (!val) return;
 	const historyId = (props as any).originData.historyId;
-	const curAgentKey = props.data.agent_key;
 	let res = null;
 
 	// 鏀瑰彉鍘熷鍊�
@@ -461,42 +500,9 @@
 	} else {
 		item.origin.step_value = val;
 	}
+
+	const filterList = getFilterList();
 	try {
-		// 鐩稿悓 agent_key 涓嬫墍鏈� filter 璇锋眰鍙傛暟
-		const filterList = ((props as any).originData?.content?.origin?.summary ?? []).reduce((preVal, curVal) => {
-			if (curVal.agent_key !== curAgentKey) return preVal;
-
-			const filter = (curVal.filter ?? []).reduce((subPreVal, subCurVal) => {
-				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 {
-					subPreVal.push({
-						update: subCurVal.update,
-						value: subCurVal.step_value,
-						path: subCurVal.step_path,
-					});
-				}
-
-				return subPreVal;
-			}, []);
-
-			preVal = preVal.concat(filter);
-
-			return preVal;
-		}, []);
 		const params = {
 			history_id: historyId,
 			// 鏌ヨ鍓嶅悗 agent_key 涓嶄細鍙�
diff --git a/src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue b/src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue
index 1ada828..6a6d0e2 100644
--- a/src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue
+++ b/src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue
@@ -28,6 +28,7 @@
 					:header-cell-style="tableHeaderCellStyle"
 					:data="tableData"
 					@row-click="recordSelectChange"
+					@sort-change="sortChange"
 					:spanMethod="objectSpanMethod"
 					class="w-full h-full"
 					highlightCurrentRow
@@ -42,9 +43,10 @@
 								:type="item.type"
 								:label="item.label"
 								:width="item.width"
-								:sortable="item.sortable"
+								:sortable="item.sortable?'custom':false"
 								:key="item.prop"
 								:prop="item.prop"
+								@sortChange="sortChange"
 								show-overflow-tooltip
 							/>
 						</template>
@@ -57,9 +59,10 @@
 									:type="item.type"
 									:label="item.label"
 									:width="item.width"
-									:sortable="item.sortable"
+									:sortable="item.sortable?'custom':false"
 									:key="item.prop"
 									:prop="item.prop"
+									
 									show-overflow-tooltip
 								/>
 							</template>
@@ -114,6 +117,7 @@
 import { ChartTypeEnum } from '../../../types';
 import { axisLabelFormatter } from '/@/utils/chart';
 import { LocalPlus } from '/@/utils/storage';
+import { af } from 'element-plus/es/locale';
 
 const props = defineProps({
 	data: {
@@ -254,7 +258,7 @@
 				...item,
 				width: 0,
 				label: item.title,
-				// sortable: item.type === 'time',
+				sortable: !!item.name,
 				prop: index + '',
 				isShow: isShow,
 			} as TableCol;
@@ -590,25 +594,11 @@
 });
 
 //#region ====================== 琛ㄦ牸杩囨护鍙傛暟 ======================
-
-const queryLoading = ref(false);
-const queryUpdate = async (val: any, item: any) => {
-	const historyId = (props as any).originData.historyId;
+const getFilterList = () =>{
 	const curAgentKey = props.data.agent_key;
-	let res = null;
 
-	// 鏀瑰彉鍘熷鍊�
-	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 璇锋眰鍙傛暟
-		const filterList = ((props as any).originData?.content?.origin?.summary ?? []).reduce((preVal, curVal) => {
+	// 鐩稿悓 agent_key 涓嬫墍鏈� filter 璇锋眰鍙傛暟
+	const filterList = ((props as any).originData?.content?.origin?.summary ?? []).reduce((preVal, curVal) => {
 			if (curVal.agent_key !== curAgentKey) return preVal;
 
 			const filter = (curVal.filter ?? []).reduce((subPreVal, subCurVal) => {
@@ -648,11 +638,37 @@
 
 			return preVal;
 		}, []);
+
+		return filterList;
+}
+const queryLoading = ref(false);
+let orderDimName = '';
+const queryUpdate = async (val?: any, item?: any) => {
+	const historyId = (props as any).originData.historyId;
+	let res = null;
+
+	if(item){
+	// 鏀瑰彉鍘熷鍊�
+		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;
+		}
+	}
+
+
+	const filterList = getFilterList();
+	try {
+	
 		const params = {
 			history_id: historyId,
 			// 鏌ヨ鍓嶅悗 agent_key 涓嶄細鍙�
 			agent_key: props.data.agent_key,
 			filter_json: JSON.stringify(filterList),
+			order_dim_name:orderDimName
 		};
 		res = await curveQuery(params);
 		queryLoading.value = true;
@@ -1056,6 +1072,21 @@
 };
 //#endregion
 
+const sortChange = ({column,prop,order}) =>{
+	let sendOrder ;
+	if(order==='descending'){
+		sendOrder = 'desc'
+	}else if(order==='ascending'){
+		sendOrder = 'asc'
+	}else{
+		sendOrder = '';
+	}
+	const colName = colList.value[prop].name;
+	const sendOrderName = sendOrder ?`${colName},${sendOrder}`:'';
+	orderDimName = sendOrderName;
+	queryUpdate()
+}
+
 defineExpose({
 	updateAll,
 	updateCurrent,
diff --git a/vite.config.ts b/vite.config.ts
index 0b2943c..8721d31 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -41,7 +41,7 @@
 			host: '0.0.0.0',
 			port: env.VITE_PORT as unknown as number,
 			open: JSON.parse(env.VITE_OPEN),
-			hmr: true,
+			hmr: false,
 		},
 		build: {
 			// outDir: 'dist/' + mode.mode,

--
Gitblit v1.9.3