|
@@ -1,19 +1,26 @@
|
|
|
<script lang="ts" setup>
|
|
|
-import { defineProps, onMounted, reactive, ref, watch } from 'vue';
|
|
|
-import { exportData, getMainData } from '/@/views/reportManage/dataCenter/api';
|
|
|
+import { defineProps, inject, onMounted, reactive, Ref, ref, watch } from 'vue';
|
|
|
+import {
|
|
|
+ exportData,
|
|
|
+ getDayTotalData,
|
|
|
+ getMainData,
|
|
|
+ getMonthTotalData,
|
|
|
+ getWeekTotalData
|
|
|
+} from '/@/views/reportManage/dataCenter/api';
|
|
|
import { universal } from '../../../utils/columns';
|
|
|
import { ElMessage } from 'element-plus';
|
|
|
|
|
|
const props = defineProps({
|
|
|
+ taskIds: Object,
|
|
|
dayDate: Object,
|
|
|
weekDate: Object,
|
|
|
monthDate: Object,
|
|
|
- taskIds: Object,
|
|
|
});
|
|
|
|
|
|
const taskIds = ref(null);
|
|
|
const tableColumns = ref([]);
|
|
|
const tableData = ref([]);
|
|
|
+const totalRow = ref([]);// 汇总数据
|
|
|
|
|
|
const dayStartDate = ref(null);
|
|
|
const dayEndDate = ref(null);
|
|
@@ -93,6 +100,8 @@ const loadSortState = () => {
|
|
|
gridOptions.sortConfig.defaultSort.field = localStorage.getItem('salesField') || '';
|
|
|
};
|
|
|
|
|
|
+
|
|
|
+
|
|
|
// 分页
|
|
|
const gridEvents = {
|
|
|
pageChange({ currentPage, pageSize }) {
|
|
@@ -105,6 +114,36 @@ const gridEvents = {
|
|
|
},
|
|
|
};
|
|
|
|
|
|
+// 获取汇总数据
|
|
|
+async function fetchTotalData(taskIds) {
|
|
|
+ try {
|
|
|
+ const dayTotalData = await getDayTotalData({
|
|
|
+ data_start_date: dayStartDate.value,
|
|
|
+ data_end_date: dayEndDate.value,
|
|
|
+ task_ids: taskIds,
|
|
|
+ });
|
|
|
+ const weekTotalData = await getWeekTotalData({
|
|
|
+ data_start_date: weekStart.value,
|
|
|
+ data_end_date: weekEnd.value,
|
|
|
+ task_ids: taskIds,
|
|
|
+ });
|
|
|
+ const monthTotalData = await getMonthTotalData({
|
|
|
+ data_start_date: monthStartDate.value,
|
|
|
+ data_end_date: monthEndDate.value,
|
|
|
+ task_ids: taskIds,
|
|
|
+ });
|
|
|
+ totalRow.value = {
|
|
|
+ ...dayTotalData.data[0],
|
|
|
+ ...weekTotalData.data[0],
|
|
|
+ ...monthTotalData.data[0],
|
|
|
+ };
|
|
|
+ totalRow.value.platformNumber = '汇总';
|
|
|
+ } catch (error) {
|
|
|
+ console.error('Error fetching total data:', error);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
// 获取数据
|
|
|
async function fetchMainData(taskIds, resetPage = false) {
|
|
|
if (resetPage) {
|
|
@@ -112,7 +151,7 @@ async function fetchMainData(taskIds, resetPage = false) {
|
|
|
}
|
|
|
try {
|
|
|
gridOptions.loading = true;
|
|
|
- //loadSortState()
|
|
|
+ await fetchTotalData(taskIds);
|
|
|
const response = await getMainData({
|
|
|
page: gridOptions.pagerConfig.currentPage,
|
|
|
limit: gridOptions.pagerConfig.pageSize,
|
|
@@ -127,7 +166,7 @@ async function fetchMainData(taskIds, resetPage = false) {
|
|
|
order_date: order_date.value,
|
|
|
date_type: dateType.value,
|
|
|
});
|
|
|
- gridOptions.data = response.data;
|
|
|
+ gridOptions.data = [totalRow.value, ...response.data];
|
|
|
gridOptions.pagerConfig.total = response.total;
|
|
|
if (!sortStatus.value) {
|
|
|
if (response.data && response.data.length > 0) {
|