|  | @@ -2,6 +2,7 @@
 | 
											
												
													
														|  |  import { computed, defineProps, inject, onMounted, reactive, ref, Ref, watch } from 'vue';
 |  |  import { computed, defineProps, inject, onMounted, reactive, ref, Ref, watch } from 'vue';
 | 
											
												
													
														|  |  import { useRouter } from 'vue-router';
 |  |  import { useRouter } from 'vue-router';
 | 
											
												
													
														|  |  import {
 |  |  import {
 | 
											
												
													
														|  | 
 |  | +  exportDayData, exportMonthData, exportWeekData,
 | 
											
												
													
														|  |    getDayData,
 |  |    getDayData,
 | 
											
												
													
														|  |    getDayTotalData,
 |  |    getDayTotalData,
 | 
											
												
													
														|  |    getMonthData,
 |  |    getMonthData,
 | 
											
										
											
												
													
														|  | @@ -11,6 +12,9 @@ import {
 | 
											
												
													
														|  |  } from '/src/views/reportManage/dataCenter/api';
 |  |  } from '/src/views/reportManage/dataCenter/api';
 | 
											
												
													
														|  |  import { dayDataColumns, monthDataColumns, weekDataColumns } from '../../utils/columns';
 |  |  import { dayDataColumns, monthDataColumns, weekDataColumns } from '../../utils/columns';
 | 
											
												
													
														|  |  import dayjs from 'dayjs';
 |  |  import dayjs from 'dayjs';
 | 
											
												
													
														|  | 
 |  | +import { exportTaskData } from '/@/views/reportManage/TaskManage/api';
 | 
											
												
													
														|  | 
 |  | +import { ElMessage } from 'element-plus';
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  const router = useRouter();
 |  |  const router = useRouter();
 | 
											
												
													
														|  |  const dateType = inject<Ref>('dateDimension');
 |  |  const dateType = inject<Ref>('dateDimension');
 | 
											
										
											
												
													
														|  | @@ -85,7 +89,8 @@ const gridOptions = reactive({
 | 
											
												
													
														|  |      },
 |  |      },
 | 
											
												
													
														|  |      slots: {
 |  |      slots: {
 | 
											
												
													
														|  |        buttons: 'toolbar_buttons',
 |  |        buttons: 'toolbar_buttons',
 | 
											
												
													
														|  | -    },
 |  | 
 | 
											
												
													
														|  | 
 |  | +      tools: 'toolbar_tools'
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  |    },
 |  |    },
 | 
											
												
													
														|  |    day: {
 |  |    day: {
 | 
											
												
													
														|  |      columns: dayDataColumns,
 |  |      columns: dayDataColumns,
 | 
											
										
											
												
													
														|  | @@ -334,6 +339,61 @@ const handleImport = () => {
 | 
											
												
													
														|  |    window.open(url, '_blank');
 |  |    window.open(url, '_blank');
 | 
											
												
													
														|  |  };
 |  |  };
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +async function handleExport(taskIds, apiFunc, startDate, endDate,dateTypeKey) {
 | 
											
												
													
														|  | 
 |  | +  try {
 | 
											
												
													
														|  | 
 |  | +    gridOptions.loading = true;
 | 
											
												
													
														|  | 
 |  | +    const response = await apiFunc({
 | 
											
												
													
														|  | 
 |  | +      [`${ dateTypeKey }_start_date`]: startDate.value,
 | 
											
												
													
														|  | 
 |  | +      [`${ dateTypeKey }_end_date`]: endDate.value,
 | 
											
												
													
														|  | 
 |  | +      task_ids: taskIds,
 | 
											
												
													
														|  | 
 |  | +      sort: sortOrder.value,
 | 
											
												
													
														|  | 
 |  | +      order_date: order_date.value,
 | 
											
												
													
														|  | 
 |  | +      order_total_sales_current_monthly: totalSales.value,
 | 
											
												
													
														|  | 
 |  | +    });
 | 
											
												
													
														|  | 
 |  | +    const url = window.URL.createObjectURL(new Blob([response.data]));
 | 
											
												
													
														|  | 
 |  | +    const link = document.createElement('a');
 | 
											
												
													
														|  | 
 |  | +    // 根据 dateTypeKey 设置文件名
 | 
											
												
													
														|  | 
 |  | +    let fileName = '';
 | 
											
												
													
														|  | 
 |  | +    if (dateTypeKey === 'day') {
 | 
											
												
													
														|  | 
 |  | +      fileName = `${startDate.value}~${endDate.value}日数据.xlsx`;  // 当为天时
 | 
											
												
													
														|  | 
 |  | +    } else if (dateTypeKey === 'week') {
 | 
											
												
													
														|  | 
 |  | +      fileName = `${startDate.value}~${endDate.value}周数据.xlsx`;  // 当为周时
 | 
											
												
													
														|  | 
 |  | +    } else if (dateTypeKey === 'month') {
 | 
											
												
													
														|  | 
 |  | +      fileName = `${startDate.value}~${endDate.value}月数据.xlsx`; // 当为月时
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +    link.href = url;
 | 
											
												
													
														|  | 
 |  | +    link.setAttribute('download', fileName);
 | 
											
												
													
														|  | 
 |  | +    document.body.appendChild(link);
 | 
											
												
													
														|  | 
 |  | +    link.click();
 | 
											
												
													
														|  | 
 |  | +    gridOptions.loading = false;
 | 
											
												
													
														|  | 
 |  | +    ElMessage.success('导出数据成功');
 | 
											
												
													
														|  | 
 |  | +  } catch (error) {
 | 
											
												
													
														|  | 
 |  | +    console.error('导出数据失败:', error);
 | 
											
												
													
														|  | 
 |  | +  }
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +async function handleExportDay() {
 | 
											
												
													
														|  | 
 |  | +  await handleExport(taskIds.value, exportDayData, dayStartDate, dayEndDate,'day');
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +async function handleExportWeek() {
 | 
											
												
													
														|  | 
 |  | +  await handleExport(taskIds.value, exportWeekData, weekStartDate, weekEndDate,'week');
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +async function handleExportMonth() {
 | 
											
												
													
														|  | 
 |  | +  await handleExport(taskIds.value, exportMonthData, monthStartDate, monthEndDate,'month');
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +async function handelExportCurrent() {
 | 
											
												
													
														|  | 
 |  | +  if (dateType.value === 'day') {
 | 
											
												
													
														|  | 
 |  | +    await handleExportDay();
 | 
											
												
													
														|  | 
 |  | +  } else if (dateType.value === 'week') {
 | 
											
												
													
														|  | 
 |  | +    await handleExportWeek();
 | 
											
												
													
														|  | 
 |  | +  } else if (dateType.value === 'month') {
 | 
											
												
													
														|  | 
 |  | +    await handleExportMonth();
 | 
											
												
													
														|  | 
 |  | +  }
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  function formatEmptyCell({ cellValue }) {
 |  |  function formatEmptyCell({ cellValue }) {
 | 
											
												
													
														|  |    if (cellValue === null || cellValue === undefined || cellValue === '') {
 |  |    if (cellValue === null || cellValue === undefined || cellValue === '') {
 | 
											
												
													
														|  |      return '--';
 |  |      return '--';
 | 
											
										
											
												
													
														|  | @@ -401,6 +461,7 @@ watch([() => props.taskIds, currentDate], async ([newTaskIds, newCurrentDate]) =
 | 
											
												
													
														|  |    clearSort();
 |  |    clearSort();
 | 
											
												
													
														|  |    if (newTaskIds) {
 |  |    if (newTaskIds) {
 | 
											
												
													
														|  |      taskIdsAvailable.value = true;
 |  |      taskIdsAvailable.value = true;
 | 
											
												
													
														|  | 
 |  | +    taskIds.value = newTaskIds;
 | 
											
												
													
														|  |    }
 |  |    }
 | 
											
												
													
														|  |    if (taskIdsAvailable.value && newTaskIds) {
 |  |    if (taskIdsAvailable.value && newTaskIds) {
 | 
											
												
													
														|  |      await fetchCurrentData(newTaskIds, true); // 使用 await 确保顺序
 |  |      await fetchCurrentData(newTaskIds, true); // 使用 await 确保顺序
 | 
											
										
											
												
													
														|  | @@ -421,6 +482,13 @@ onMounted(() => {
 | 
											
												
													
														|  |        <template #toolbar_buttons>
 |  |        <template #toolbar_buttons>
 | 
											
												
													
														|  |          <el-button icon="plus" target="_blank" type="primary" @click="handleImport">数据录入</el-button>
 |  |          <el-button icon="plus" target="_blank" type="primary" @click="handleImport">数据录入</el-button>
 | 
											
												
													
														|  |        </template>
 |  |        </template>
 | 
											
												
													
														|  | 
 |  | +      <template #toolbar_tools>
 | 
											
												
													
														|  | 
 |  | +        <div class="pr-2.5">
 | 
											
												
													
														|  | 
 |  | +          <el-tooltip content="下载表格" placement="top">
 | 
											
												
													
														|  | 
 |  | +            <vxe-button circle icon="vxe-icon-download" @click="handelExportCurrent"></vxe-button>
 | 
											
												
													
														|  | 
 |  | +          </el-tooltip>
 | 
											
												
													
														|  | 
 |  | +        </div>
 | 
											
												
													
														|  | 
 |  | +      </template>
 | 
											
												
													
														|  |        <template #platformNumber_default="{ row }">
 |  |        <template #platformNumber_default="{ row }">
 | 
											
												
													
														|  |          <div class="font-semibold" style="padding: 0">{{ row.platformNumber }}</div>
 |  |          <div class="font-semibold" style="padding: 0">{{ row.platformNumber }}</div>
 | 
											
												
													
														|  |        </template>
 |  |        </template>
 |