|
@@ -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>
|