| | |
| | | <div> |
| | | <!-- <span v-if="data?.title" class="text-base font-bold flex-center mb-5">{{ data?.title }}</span> --> |
| | | <div class="w-full flex-column"> |
| | | <div class="flex-0 flex"> |
| | | <div class="flex-0 flex-items-center mb-1 h-[38px] "> |
| | | <template v-if="visibleParams && visibleParams.length > 0"> |
| | | <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]" |
| | | :data="item" |
| | | @change="(val) => handleQueryChange(val, item)" |
| | | :originData="originData" |
| | | ></component> |
| | | |
| | | </template> |
| | | |
| | | <ColFilter class="ml-auto" :columnList="colList" @change="colFilterChange" /> |
| | | </div> |
| | | <div class="flex-auto" ref="containerRef" v-resize="resizeHandler"> |
| | | <div class="flex-auto" ref="containerRef" v-resize="resizeHandler" v-loading="queryLoading"> |
| | | <el-table |
| | | ref="tableRef" |
| | | :maxHeight="tableHeight" |
| | |
| | | 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'; |
| | | |
| | | const props = defineProps({ |
| | | data: { |
| | | type: Object as PropType<any>, |
| | | }, |
| | | originData: { |
| | | type: Object as PropType<any>, |
| | | }, |
| | | summaryIndex: { |
| | | type: Number, |
| | | }, |
| | | }); |
| | | |
| | | const [DefineColumns, ReuseColumns] = createReusableTemplate<{ |
| | | cols: any[]; |
| | | }>(); |
| | | const emits = defineEmits<{ |
| | | (event: 'updateQuery', res: any): void; |
| | | }>(); |
| | | |
| | | const colList = ref([]); |
| | |
| | | * @param j å½åè®°å½æå¨è¡ä½ç½® |
| | | */ |
| | | const buildGroupData = (values, i = 0, j = 0) => { |
| | | if(!values || values.length===0) return []; |
| | | const curGroupIndex = filterGroupIndexList.value[i]; |
| | | // ä¸å¯ä»¥åç»ï¼ç´æ¥ return; |
| | | if (curGroupIndex == undefined || values.length === 1) { |
| | |
| | | return; |
| | | } |
| | | |
| | | if (props.data?.cols?.length > 0 && props.data?.values?.length > 0) { |
| | | if (props.data?.cols?.length > 0 ) { |
| | | cellRowSpanMap.clear(); |
| | | props.data.values = buildGroupData(props.data.values); |
| | | calcColWidth(width); |
| | |
| | | |
| | | // ä¸é¡µæ pager.sizeï¼æ¡è®°å½ |
| | | pager.size = Math.floor((limitHeight - headerHeight) / (cellHeight + THICK_BORDER_WIDTH)); |
| | | |
| | | const currentHeight = calcCellHeight(pager.size, cellHeight) + headerHeight; |
| | | |
| | | tableHeight.value = currentHeight; |
| | |
| | | |
| | | //#endregion |
| | | |
| | | const reloadTable = () => { |
| | | // éæ°è®¡ç®å®½åº¦ |
| | | |
| | | resizeEvent({ width: containerRef.value.clientWidth, height: containerRef.value.clientHeight }); |
| | | }; |
| | | const colFilterChange = () => { |
| | | // éæ°è®¡ç®å®½åº¦ |
| | | resizeEvent({ width: containerRef.value.clientWidth, height: containerRef.value.clientHeight }); |
| | | reloadTable(); |
| | | }; |
| | | |
| | | const tableHeight = ref(0.7 * document.body.clientHeight); |
| | |
| | | height: 0.7 * document.body.clientHeight, |
| | | }); |
| | | }); |
| | | |
| | | //#region ====================== è¡¨æ ¼è¿æ»¤åæ° ====================== |
| | | |
| | | const queryLoading = ref(false); |
| | | const queryUpdate = async (val: any, item: any) => { |
| | | const historyId = (props as any).originData.historyId; |
| | | const curAgentKey = props.data.agent_key; |
| | | let res = null; |
| | | |
| | | // æ¹ååå§å¼ |
| | | if (item.type === RecordSetTableType.StringInput) { |
| | | item.origin.value = val; |
| | | } |
| | | 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 === RecordSetTableType.StringInput) { |
| | | subPreVal.push({ |
| | | update: subCurVal.update, |
| | | value: subCurVal.value, |
| | | path: subCurVal.path, |
| | | }); |
| | | } |
| | | |
| | | return subPreVal; |
| | | }, []); |
| | | |
| | | preVal = preVal.concat(filter); |
| | | |
| | | return preVal; |
| | | }, []); |
| | | const params = { |
| | | history_id: historyId, |
| | | // æ¥è¯¢åå agent_key ä¸ä¼å |
| | | agent_key: props.data.agent_key, |
| | | filter_json: JSON.stringify(filterList), |
| | | }; |
| | | res = await curveQuery(params); |
| | | queryLoading.value = true; |
| | | } finally { |
| | | queryLoading.value = false; |
| | | } |
| | | |
| | | emits('updateQuery', res); |
| | | }; |
| | | |
| | | const debounceQueryUpdate = debounce(queryUpdate, 600); |
| | | |
| | | const handleQueryChange = async (val: any, item: any) => { |
| | | if (item.type === RecordSetTableType.StringInput) { |
| | | debounceQueryUpdate(val, item); |
| | | } |
| | | |
| | | // queryUpdate(val,item) |
| | | |
| | | return; |
| | | }; |
| | | |
| | | //#endregion |
| | | |
| | | const getVisibleParams = (data) => { |
| | | // const visibleList = props.data?.params?.filter((item) => !item?.hide) ?? []; |
| | | // index ä½ä¸º id |
| | | const visibleList = (data?.filter ?? []).map((item, index) => { |
| | | // ä¸ä¿®æ¹åå§å°å |
| | | item.id = index + ''; |
| | | |
| | | return item; |
| | | }); |
| | | const newList: any[] = []; |
| | | for (let index = 0; index < visibleList.length; index++) { |
| | | const current = visibleList[index]; |
| | | switch (current.type) { |
| | | case RecordSetTableType.StringInput: |
| | | newList.push({ |
| | | id: current.id, |
| | | type: RecordSetTableType.StringInput, |
| | | origin: current, |
| | | value: current?.value ?? '', |
| | | title: current.title, |
| | | }); |
| | | break; |
| | | |
| | | default: |
| | | break; |
| | | } |
| | | Reflect.deleteProperty(current, 'id'); |
| | | } |
| | | |
| | | return newList; |
| | | }; |
| | | const visibleParams = ref(getVisibleParams(props.data)); |
| | | |
| | | const updateFilterValue = (data) => { |
| | | const filter = data?.filter ?? []; |
| | | |
| | | filter.map((newItem, index) => { |
| | | const currentItem = visibleParams.value.find((item) => item.id === index + ''); |
| | | |
| | | if (currentItem) { |
| | | if (newItem.type === RecordSetTableType.StringInput) { |
| | | currentItem.value = newItem.value; |
| | | } |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | const resetPager = (data) => { |
| | | pager.index = 1; |
| | | pager.total = data?.values?.length ?? 0; |
| | | }; |
| | | const updateCurrent = (res) => { |
| | | const title = res?.title; |
| | | const values = res?.values ?? []; |
| | | props.data.title = title; |
| | | props.data.values = values; |
| | | // 䏿´æ°ï¼åç«¯åæ ¹æ²¡è¿å |
| | | // updateFilterValue(res); |
| | | resetPager(res); |
| | | |
| | | reloadTable(); |
| | | }; |
| | | // æ¥è¯¢ |
| | | const updateAll = (triggerIndex, res) => { |
| | | // å½å agent_key |
| | | const curAgentKey = props.data.agent_key; |
| | | const triggerAgentKey = (props as any).originData?.content?.origin?.summary?.[triggerIndex]?.agent_key; |
| | | if (curAgentKey !== triggerAgentKey) { |
| | | return; |
| | | } |
| | | if (!curAgentKey) { |
| | | return; |
| | | } |
| | | |
| | | // å½å项æå¨ç´¢å¼ |
| | | let currentIndex = -1; |
| | | for (let index = 0; index < (props as any).originData.content.origin.summary.length; index++) { |
| | | const item = (props as any).originData.content.origin.summary[index]; |
| | | if (item.agent_key === curAgentKey) { |
| | | currentIndex++; |
| | | if (index === props.summaryIndex) { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | // è¡¨æ ¼ summary å¯è½æ´ä¸ªè¿å为空ï¼ä¸ºç©ºæ¶ï¼values 设置为空 |
| | | const newSummary = res?.summary?.[currentIndex] ?? { |
| | | title: props.data.title, |
| | | values: [], |
| | | }; |
| | | |
| | | updateCurrent(newSummary); |
| | | }; |
| | | |
| | | defineExpose({ |
| | | updateAll, |
| | | }); |
| | | </script> |
| | | <style scoped lang="scss"> |
| | | // :deep(.el-table--striped .el-table__body tr.el-table__row--striped td.el-table__cell){ |