Selaa lähdekoodia

feat<计划销售额-展示>:添加汇总行

xinyan 5 kuukautta sitten
vanhempi
commit
b5c14e2163

+ 1 - 0
src/auto-imports.d.ts

@@ -6,6 +6,7 @@
 export {}
 declare global {
   const EffectScope: typeof import('vue')['EffectScope']
+  const ElMessage: typeof import('element-plus/es')['ElMessage']
   const acceptHMRUpdate: typeof import('pinia')['acceptHMRUpdate']
   const computed: typeof import('vue')['computed']
   const createApp: typeof import('vue')['createApp']

+ 9 - 0
src/views/reportManage/dataCenter/api.ts

@@ -299,4 +299,13 @@ export function exportPlanSalesData(query) {
     params: query,
     responseType: 'blob'
   });
+}
+
+// 计划销售额汇总
+export function getPlanSalesTotalData(query) {
+  return request({
+    url: '/api/report_manage/summary-tasks/data/plan/all/sum/',
+    method: 'GET',
+    params: query,
+  });
 }

+ 43 - 4
src/views/reportManage/dataCenter/combinedDisplay/components/tableData/planInfo.vue

@@ -5,7 +5,12 @@
  * @Author: xinyan
  */
 
-import { exportPlanSalesData } from '/src/views/reportManage/dataCenter/api';
+import {
+  exportPlanSalesData,
+  getDayTotalData,
+  getMonthTotalData, getPlanSalesTotalData,
+  getWeekTotalData
+} from '/src/views/reportManage/dataCenter/api';
 import { reactive, ref } from 'vue';
 import dayjs from 'dayjs';
 import Selector from '/src/views/reportManage/dataCenter/normalDisplay/components/Selector/index.vue';
@@ -18,6 +23,7 @@ const currentYear = ref('');
 // 筛选查询
 const selectorRef = ref(null);
 const taskIds = ref({});
+const totalRow = ref([]);// 汇总数据
 
 const gridOptions = reactive({
   border: 'inner',
@@ -76,16 +82,32 @@ const gridEvents = {
   }
 };
 
+
+async function fetchTotalData(taskIds) {
+  try {
+    const resp = await getPlanSalesTotalData({
+      year_date: currentYear.value,
+      task_ids: taskIds,
+    });
+    totalRow.value = resp.data;
+    totalRow.value.platformNumber = '汇总';
+  } catch (error) {
+    console.error('Error fetching total data:', error);
+  }
+}
+
 async function getList() {
   try {
     gridOptions.loading = true;
+    await fetchTotalData(taskIds.value);
     const response = await getPlanList({
       page: gridOptions.pagerConfig.currentPage,
       limit: gridOptions.pagerConfig.pageSize,
       year_date: currentYear.value,
       task_ids: taskIds.value,
     });
-    gridOptions.data = response.data;
+    // gridOptions.data = response.data;
+    gridOptions.data = [totalRow.value, ...response.data];
     gridOptions.pagerConfig.total = response.total;
   } catch (error) {
     console.error('Error fetching task data:', error);
@@ -131,7 +153,16 @@ watch(currentYear, (newVal, oldVal) => {
   }
 });
 
-const cellStyle = () => {
+const cellStyle = (row) => {
+  if (row.$rowIndex === 0 && row.$columnIndex < 5) {
+    return {
+      position: 'sticky',
+      top: 0,
+      zIndex: 30,
+      fontSize: '12px',
+      fontWeight: '600',
+    };
+  }
   return {
     fontSize: '12px',
     fontWeight: '600',
@@ -145,7 +176,15 @@ const headerCellStyle = () => {
   };
 };
 
-const rowStyle = () => {
+const rowStyle = (row) => {
+  if (row.$rowIndex === 0) {
+    return {
+      background: '#def6fe',
+      position: 'sticky',
+      top: 0,
+      zIndex: 1,
+    };
+  }
   return {
     padding: 0,
     height: '50px',