소스 검색

🐛 perf<报表管理>: 数据中心筛选功能修改

xinyan 11 달 전
부모
커밋
f65b0c99f1

+ 3 - 1
src/views/reportManage/dataCenter/combinedDisplay/components/tableData/mainData.vue

@@ -2,6 +2,7 @@
 import { onMounted, reactive, ref, watch, defineProps, inject, Ref } from 'vue';
 import { exportData, getMainData } from '/@/views/reportManage/dataCenter/api';
 import dayjs from 'dayjs';
+import { ElMessage } from 'element-plus';
 
 const props = defineProps({
   dayDate: Object,
@@ -183,7 +184,7 @@ async function handleExport() {
     };
     // 调用后端导出数据接口
     const response = await exportData(params);
-    console.log(12, response);
+    //console.log(12, response);
     // 创建Blob对象表示二进制数据
     const url = window.URL.createObjectURL(new Blob([response.data]));
     // 创建隐藏的可下载链接
@@ -194,6 +195,7 @@ async function handleExport() {
     document.body.appendChild(link);
     // 触发点击下载
     link.click();
+    ElMessage.success('导出数据成功');
   } catch (error) {
     console.error('导出数据失败:', error);
   }

+ 3 - 0
src/views/reportManage/dataCenter/combinedDisplay/components/tableData/monthlyComparativeData.vue

@@ -24,6 +24,9 @@ const gridOptions = reactive({
   columnConfig: {
     resizable: true,
   },
+  rowConfig: {
+    isHover: true,
+  },
   pagerConfig: {
     enabled: true,
     total: 20,

+ 1 - 1
src/views/reportManage/dataCenter/normalDisplay/components/DatePicker/index.vue

@@ -142,7 +142,7 @@ function setDefaultDate() {
         dayjs().endOf('day').format('YYYY-MM-DD')
       ];
       dateChange();
-       console.log(dateRange.value);
+       //console.log(dateRange.value);
       break;
     case 'week':
       startWeek.value = dayjs().locale('en').subtract(2, 'week').startOf('week').format('YYYY-MM-DD');

+ 33 - 20
src/views/reportManage/dataCenter/normalDisplay/components/Selector/index.vue

@@ -15,31 +15,47 @@ const operationOptions = ref([]);
 const countryOptions = ref([]);
 const brandNameOptions = ref([]);
 
-async function fetchInitialData() {
-  try {
-    const response = await getTasks();
-    // console.log('response', response);
-    const data = response.data;
-    platformNumberOptions.value = [...new Set(data.map(item => item.platformNumber))];
-    platformNameOptions.value = [...new Set(data.map(item => item.platformName))];
-    countryOptions.value = [...new Set(data.map(item => item.country))];
-    brandNameOptions.value = [...new Set(data.map(item => item.brandName))];
-  } catch (error) {
-    console.error('Error fetching initial data:', error);
+function sortCountriesByInitial(countries) {
+  return countries.sort((a, b) => a.localeCompare(b));
+}
+
+async function fetchAllTasks() {
+  let page = 1;
+  const limit = 10;
+  let allData = [];
+  let hasNext = true;
+
+  while (hasNext) {
+    try {
+      const response = await getTasks({ page, limit });
+      const data = response.data;
+      allData = allData.concat(data);
+      hasNext = response.is_next;
+      page += 1;
+    } catch (error) {
+      console.error('Error fetching tasks data:', error);
+      hasNext = false;
+    }
   }
+
+  platformNumberOptions.value = [...new Set(allData.map(item => item.platformNumber))];
+  platformNameOptions.value = [...new Set(allData.map(item => item.platformName))];
+  countryOptions.value = sortCountriesByInitial([...new Set(allData.map(item => item.country))]);
+  brandNameOptions.value = [...new Set(allData.map(item => item.brandName))];
 }
 
 async function fetchOperationSelect() {
   try {
     const resp = await getOperationSelect();
     operationOptions.value = resp.data.map((item: any) => {
-      return {value: item.id, label: item.name};
+      return { value: item.id, label: item.name };
     });
   } catch (e) {
     console.error('Failed to fetch operation select:', e);
   }
 }
-const updateData = ref([])
+
+const updateData = ref([]);
 const filteredData = ref([]);
 
 async function fetchFilteredData() {
@@ -66,7 +82,7 @@ async function fetchFilteredData() {
   if (operationList.value.length > 0) {
     filters.users = operationList.value.join(',');
   }
-  // console.log('filters',filters);
+
   filteredData.value = filters;
   try {
     const response = await getTasksId(filters);
@@ -85,17 +101,14 @@ async function emitChange() {
 
 watch([countryList, brandNameList, operationList], () => {
   emitChange();
-
-})
+});
 
 onMounted(() => {
-  fetchInitialData();
+  fetchAllTasks();
   fetchOperationSelect();
 });
 
-defineExpose({fetchFilteredData, filteredData, updateData});
-
-
+defineExpose({ fetchFilteredData, filteredData, updateData });
 </script>
 
 <template>

+ 1 - 1
src/views/reportManage/dataCenter/utils/tools.ts

@@ -33,7 +33,7 @@ export function buildChartOpt(option: any, metrics: any[]) {
       opt.legend.selected[label] = true
     }
   }
-  console.log(opt)
+  //console.log(opt)
   return opt
 }