Explorar o código

✨ feat<任务管理>:查询组件方法修改

xinyan hai 6 meses
pai
achega
073d813c38

+ 10 - 0
src/views/reportManage/TaskManage/api.ts

@@ -67,6 +67,14 @@ export function getOperationSelect(query) {
   });
 }
 
+export function getSelect(query) {
+  return request({
+    url: '/api/report_manage/summary-tasks/box/data/',
+    method: 'GET',
+    params: query,
+  });
+}
+
 export function getCurrencyCodeSelect(query) {
   return request({
     url: '/api/report_manage/summary-tasks/currency_code_select/',
@@ -107,3 +115,5 @@ export function getPlanList(query) {
     params: query,
   });
 }
+
+

+ 48 - 34
src/views/reportManage/dataCenter/normalDisplay/components/Selector/index.vue

@@ -1,6 +1,6 @@
 <script lang="ts" setup>
 import { onMounted, ref, watch } from 'vue';
-import { getOperationSelect, getTasks, getTasksId } from '/@/views/reportManage/TaskManage/api';
+import { getOperationSelect, getSelect, getTasks, getTasksId } from '/@/views/reportManage/TaskManage/api';
 
 
 const props = defineProps({
@@ -20,45 +20,48 @@ const countryList = ref(JSON.parse(localStorage.getItem('countryList') || '[]'))
 const brandNameList = ref(JSON.parse(localStorage.getItem('brandNameList') || '[]'));
 const platformList = ref(JSON.parse(localStorage.getItem('platformList') || '[]'));
 
-const platformNumberOptions = ref([]);
-const platformNameOptions = ref([]);
+// const platformNumberOptions = ref([]);
+// const platformNameOptions = ref([]);
 const usersOptions = ref([]);
-const operationOptions = ref([]);
+// const operationOptions = ref([]);
 const countryOptions = ref([]);
 const brandNameOptions = ref([]);
 const platformOptions = ref([]);
 
+const updateData = ref([]);
+const filteredData = ref([]);
+
 function sortCountriesByInitial(countries) {
   return countries.sort((a, b) => a.localeCompare(b));
 }
 
-async function fetchAllTasks() {
-  let page = 1;
-  const limit = 9999;
-  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))];
-  operationOptions.value = [...new Set(allData.map(item => item.operater))];
-  countryOptions.value = sortCountriesByInitial([...new Set(allData.map(item => item.country))]);
-  brandNameOptions.value = [...new Set(allData.map(item => item.brandName))];
-  platformOptions.value = [...new Set(allData.map(item => item.platform).filter(platform => platform !== null && platform !== undefined && platform !== ''))];
-}
-
+// async function fetchAllTasks() {
+//   let page = 1;
+//   const limit = 9999;
+//   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))];
+//   operationOptions.value = [...new Set(allData.map(item => item.operater))];
+//   countryOptions.value = sortCountriesByInitial([...new Set(allData.map(item => item.country))]);
+//   brandNameOptions.value = [...new Set(allData.map(item => item.brandName))];
+//   platformOptions.value = [...new Set(allData.map(item => item.platform).filter(platform => platform !== null && platform !== undefined && platform !== ''))];
+// }
+//
 async function fetchUsersSelect() {
   try {
     const resp = await getOperationSelect();
@@ -70,8 +73,18 @@ async function fetchUsersSelect() {
   }
 }
 
-const updateData = ref([]);
-const filteredData = ref([]);
+async function fetchSelectData() {
+  try {
+    const resp = await getSelect();
+    countryOptions.value = sortCountriesByInitial(resp.data.country)
+    brandNameOptions.value = resp.data.brandName;
+    platformOptions.value = resp.data.platform;
+  } catch (e) {
+    console.error('Failed to fetch select data:', e);
+  }
+}
+
+
 
 async function fetchFilteredData() {
   const filters: any = {};
@@ -141,7 +154,8 @@ watch([countryList, brandNameList, usersList, platformList], () => {
 });
 
 onMounted(() => {
-  fetchAllTasks();
+  // fetchAllTasks();
+  fetchSelectData();
   fetchUsersSelect();
   emitChange();
 });