wujingjing
2024-11-12 545109f5b8fe240cb12ea613fc58aec1551b1b09
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,