浏览代码

Merge branch 'xinyan' into test

xinyan 9 月之前
父节点
当前提交
6210dc2620

+ 2 - 0
src/views/reportManage/dataCenter/combinedDisplay/components/DatePicker/index.vue

@@ -173,6 +173,7 @@ onMounted(() => {
               placeholder="选择开始周"
               type="week"
               @change="handleStartWeekChange"
+              style="width: 150px"
           />
         </el-config-provider>
       </div>
@@ -188,6 +189,7 @@ onMounted(() => {
               placeholder="选择结束周"
               type="week"
               @change="handleEndWeekChange"
+              style="width: 150px"
           />
         </el-config-provider>
       </div>

+ 3 - 1
src/views/reportManage/dataCenter/combinedDisplay/components/monthDatePicker/index.vue

@@ -117,7 +117,9 @@ const disabledDate = (time) => {
   margin: 10px 0;
 }
 .demonstration {
-  font-size: 14px;
   color: var(--el-text-color-secondary);
+  font-size: 14px;
+  margin: 8px;
+  white-space: nowrap;
 }
 </style>

+ 17 - 2
src/views/reportManage/dataCenter/combinedDisplay/components/tableData/mainData.vue

@@ -39,6 +39,7 @@ const dateType = ref('');
 const salesOrder = ref(null);
 const salesField = ref(null);
 const sortStatus = ref(false);
+const totalSales = ref(null);
 
 const gridOptions = reactive({
   border: 'inner',
@@ -167,6 +168,7 @@ async function fetchMainData(taskIds, resetPage = false) {
       sort: sortOrder.value,
       order_date: order_date.value,
       date_type: dateType.value,
+      order_total_sales_current_monthly: totalSales.value,
     });
     gridOptions.data = [totalRow.value, ...response.data];
     gridOptions.pagerConfig.total = response.total;
@@ -194,7 +196,7 @@ async function fetchMainData(taskIds, resetPage = false) {
 
         allColumns.forEach(key => {
           let isSortable = false;
-          if (key.includes('的销售额') && !key.includes('广告销售额') && !key.includes('增长率')) {
+          if (key.includes('的销售额') || key.includes('当月累计销售额')&& !key.includes('广告销售额') && !key.includes('增长率')) {
             isSortable = true;
           }
           const column = {
@@ -260,6 +262,11 @@ async function fetchMainData(taskIds, resetPage = false) {
   }
 }
 
+function clearSort() {
+  order_date.value = '';
+  salesOrder.value = null;
+}
+
 //排序
 function handleSortChange({ field, order }) {
   salesOrder.value = order;
@@ -269,15 +276,23 @@ function handleSortChange({ field, order }) {
     const match = field.match(/(\d{4}-\d{2}-\d{2})的销售额/);
     const matchRange = field.match(/(\d{4}-\d{2}-\d{2})~(\d{4}-\d{2}-\d{2})的销售额/);
     const matchMonth = field.match(/(\d{4}-\d{2})的销售额/);
+    const matchTotal = field.match(/当月累计销售额/);
     if (matchRange) {
       order_date.value = matchRange[1];
       dateType.value = 'week';
+      totalSales.value = '';
     } else if (match) {
       order_date.value = match[1];
       dateType.value = 'day';
+      totalSales.value = '';
     } else if (matchMonth) {
       order_date.value = `${ matchMonth[1] }-01`;
       dateType.value = 'month';
+      totalSales.value = '';
+    }else if (matchTotal) {
+      clearSort();
+      dateType.value = 'week';
+      totalSales.value = true;
     }
   }
   gridOptions.sortConfig.defaultSort.order = order;
@@ -414,7 +429,7 @@ onMounted(() => {
     </el-card>
     <el-card class="mt-3">
       <slot name="table-header"></slot>
-      <vxe-grid :cell-style="cellStyle" :header-cell-style="cellStyleHandler" :row-style="rowStyle" v-bind="gridOptions"
+      <vxe-grid :cell-style="cellStyle" :header-cell-style="cellStyleHandler" :row-style="rowStyle" v-bind="gridOptions" stripe
                 v-on="gridEvents" @sort-change="handleSortChange">
         <template #toolbar_buttons>
           <div class="mx-3.5">

+ 2 - 0
src/views/reportManage/dataCenter/normalDisplay/components/DatePicker/index.vue

@@ -191,6 +191,7 @@ watch(dateType, () => {
               placeholder="选择开始周"
               type="week"
               @change="handleStartWeekChange"
+              style="width: 150px"
           />
         </el-config-provider>
         <span class="demonstration">至</span>
@@ -205,6 +206,7 @@ watch(dateType, () => {
               placeholder="选择结束周"
               type="week"
               @change="handleEndWeekChange"
+              style="width: 150px"
           />
         </el-config-provider>
       </div>

+ 11 - 10
src/views/reportManage/dataCenter/normalDisplay/components/Selector/index.vue

@@ -151,9 +151,9 @@ defineExpose({ fetchFilteredData, filteredData, updateData });
   <div class="flex gap-2.5 flex-wrap">
     <el-input v-model="platformNumberList" class="flex-item" clearable placeholder="平台编号" style="width: 150px;"
               @change="emitChange"></el-input>
-    <el-input v-model="platformNameList" class="flex-item" clearable placeholder="平台名称" style="width: 200px;"
+    <el-input v-model="platformNameList" class="flex-item" clearable placeholder="平台名称" style="width: 150px;"
               @change="emitChange"></el-input>
-    <el-input v-model="operationList" class="flex-item" clearable placeholder="运营" @change="emitChange"></el-input>
+    <el-input v-model="operationList" class="flex-item" clearable placeholder="运营" style="width: 150px;" @change="emitChange"></el-input>
     <el-select
         v-model="usersList"
         class="flex-item"
@@ -162,7 +162,7 @@ defineExpose({ fetchFilteredData, filteredData, updateData });
         clearable
         collapse-tags
         placeholder="填写人"
-        style="width: 280px;"
+        style="width: 180px;"
     >
       <el-option
           v-for="item in usersOptions"
@@ -171,18 +171,18 @@ defineExpose({ fetchFilteredData, filteredData, updateData });
           :value="item.value"
       />
     </el-select>
-    <el-select v-model="countryList" class="flex-item" clearable collapse-tags collapse-tags-tooltip multiple placeholder="国家" style="width: 280px;">
+    <el-select v-model="countryList" class="flex-item" clearable collapse-tags collapse-tags-tooltip multiple placeholder="国家" style="width: 150px;">
       <el-option v-for="item in countryOptions" :key="item" :label="item" :value="item" />
       <template #footer>
         <el-button text size="small" @click="selectCommonGroup1">美洲区</el-button>
         <el-button text size="small" @click="selectCommonGroup2">欧洲+英国</el-button>
       </template>
     </el-select>
-    <el-select v-model="brandNameList" class="flex-item" clearable collapse-tags collapse-tags-tooltip multiple
+    <el-select v-model="brandNameList" class="flex-item" clearable collapse-tags collapse-tags-tooltip multiple style="width: 150px;"
                placeholder="品牌">
       <el-option v-for="item in brandNameOptions" :key="item" :label="item" :value="item" />
     </el-select>
-    <el-select v-model="platformList" class="flex-item" clearable collapse-tags collapse-tags-tooltip multiple
+    <el-select v-model="platformList" class="flex-item" clearable collapse-tags collapse-tags-tooltip multiple style="width: 150px;"
                placeholder="平台">
       <el-option v-for="item in platformOptions" :key="item" :label="item" :value="item" />
     </el-select>
@@ -197,13 +197,14 @@ defineExpose({ fetchFilteredData, filteredData, updateData });
 }
 
 .flex-item {
-  flex: 1 1 160px; /* 自适应大小并设定最小宽度 */
+  /* flex: 1 1 150px; !* 自适应大小并设定最小宽度 *! */
   min-width: 100px;
-  max-width: 300px; /* 设定最大宽度,确保不会变形 */
-  height: 30px;
+  /* max-width: 180px; !* 设定最大宽度,确保不会变形 *! */
+  /* height: 28px; */
+  /* padding-top: 4px; */
 }
 
 .el-select {
-  max-width: 300px; /* 确保下拉框宽度不超过最大宽度 */
+  /* max-width: 180px; !* 确保下拉框宽度不超过最大宽度 *! */
 }
 </style>

+ 37 - 21
src/views/reportManage/dataCenter/normalDisplay/components/TableDataDisplay.vue

@@ -4,7 +4,8 @@ import { useRouter } from 'vue-router';
 import {
   getDayData,
   getDayTotalData,
-  getMonthData, getMonthTotalData,
+  getMonthData,
+  getMonthTotalData,
   getWeekData,
   getWeekTotalData
 } from '/src/views/reportManage/dataCenter/api';
@@ -19,6 +20,9 @@ const props = defineProps({
   taskIds: Object,
 });
 
+const taskIds = ref(props.taskIds);
+const totalSales = ref(null);
+
 const dayStartDate = ref(null);
 const dayEndDate = ref(null);
 const weekStartDate = ref(null);
@@ -133,7 +137,7 @@ const loadSortState = () => {
 };
 const totalRow = ref({});
 
-async function fetchTotalData(taskIds, apiFunc,  startDate, endDate, dateTypeKey) {
+async function fetchTotalData(taskIds, apiFunc, startDate, endDate, dateTypeKey) {
   try {
     const resp = await apiFunc({
       data_start_date: startDate.value,
@@ -148,15 +152,15 @@ async function fetchTotalData(taskIds, apiFunc,  startDate, endDate, dateTypeKey
 }
 
 async function fetchDayTotal(taskIds) {
-  await fetchTotalData(taskIds, getDayTotalData, dayStartDate, dayEndDate,'day');
+  await fetchTotalData(taskIds, getDayTotalData, dayStartDate, dayEndDate, 'day');
 }
 
 async function fetchWeekTotal(taskIds) {
-  await fetchTotalData(taskIds, getWeekTotalData, weekStartDate, weekEndDate,'week');
+  await fetchTotalData(taskIds, getWeekTotalData, weekStartDate, weekEndDate, 'week');
 }
 
 async function fetchMonthTotal(taskIds) {
-  await fetchTotalData(taskIds, getMonthTotalData, monthStartDate, monthEndDate,'month');
+  await fetchTotalData(taskIds, getMonthTotalData, monthStartDate, monthEndDate, 'month');
 }
 
 async function fetchCurrentTotalData(taskIds) {
@@ -164,15 +168,14 @@ async function fetchCurrentTotalData(taskIds) {
     await fetchDayTotal(taskIds);
   } else if (dateType.value === 'week') {
     await fetchWeekTotal(taskIds);
-  }else if (dateType.value === 'month') {
+  } else if (dateType.value === 'month') {
     await fetchMonthTotal(taskIds);
   }
 }
 
-
 async function fetchData(taskIds, apiFunc, startDate, endDate, dataColumns, dateTypeKey) {
   try {
-    loadSortState();
+    //loadSortState();
     const resp = await apiFunc({
       page: gridOptions.pagerConfig.currentPage,
       limit: gridOptions.pagerConfig.pageSize,
@@ -181,6 +184,7 @@ async function fetchData(taskIds, apiFunc, startDate, endDate, dataColumns, date
       task_ids: taskIds,
       sort: sortOrder.value,
       order_date: order_date.value,
+      order_total_sales_current_monthly: totalSales.value,
     });
     gridOptions[dateType.value].data = [totalRow.value, ...resp.data];
     gridOptions.pagerConfig.total = resp.total;
@@ -203,7 +207,7 @@ async function fetchData(taskIds, apiFunc, startDate, endDate, dataColumns, date
         //"的销售额"字段可以排序
         allColumns.forEach(key => {
           let isSortable = false;
-          if (key.includes('的销售额') && !key.includes('增长率')) {
+          if (key.includes('的销售额') || key.includes('当月累计销售额') && !key.includes('增长率')) {
             isSortable = true;
           }
           const column = {
@@ -293,19 +297,31 @@ function handleSortChange({ field, order }) {
     const match = field.match(/(\d{4}-\d{2}-\d{2})的销售额/);
     const matchRange = field.match(/(\d{4}-\d{2}-\d{2})~(\d{4}-\d{2}-\d{2})的销售额/);
     const matchMonth = field.match(/(\d{4}-\d{2})的销售额/);
+    const matchTotal = field.match(/当月累计销售额/);
     if (matchRange) {
       order_date.value = matchRange[1];
+      totalSales.value = '';
     } else if (match) {
       order_date.value = match[1];
+      totalSales.value = '';
     } else if (matchMonth) {
       order_date.value = `${ matchMonth[1] }-01`;
+      totalSales.value = '';
+    } else if (matchTotal) {
+      clearSort();
+      totalSales.value = true;
     }
   }
   saveSortState(); // 保存排序状态
   gridOptions.sortConfig.defaultSort.order = order;
   gridOptions.sortConfig.defaultSort.field = field;
   sortStatus.value = false;
-  fetchCurrentData(props.taskIds, true)
+  fetchCurrentData(props.taskIds, true);
+}
+
+function clearSort() {
+  order_date.value = '';
+  salesOrder.value = null;
 }
 
 const handleImport = () => {
@@ -339,11 +355,12 @@ const cellStyle = (row) => {
       zIndex: 30,
       fontSize: '12px',
       fontWeight: '600',
-    }}
+    };
+  }
   return {
     fontSize: '12px',
     fontWeight: '600',
-    padding:0,
+    padding: 0,
   };
 };
 
@@ -355,18 +372,18 @@ const headerCellStyle = () => {
 
 const rowStyle = (row) => {
   if (row.$rowIndex === 0) {
-    return{
+    return {
       background: '#def6fe',
-      position:'sticky',
+      position: 'sticky',
       top: 0,
       zIndex: 1,
-    }
+    };
   }
-  return{
-    padding:0,
+  return {
+    padding: 0,
     height: '50px',
-  }
-}
+  };
+};
 
 watch([() => props.taskIds, currentDate], async ([newTaskIds, newCurrentDate]) => {
   sortStatus.value = true;
@@ -381,8 +398,7 @@ watch([() => props.taskIds, currentDate], async ([newTaskIds, newCurrentDate]) =
     monthStartDate.value = dayjs(newCurrentDate.startDate).format('YYYY-MM-DD');
     monthEndDate.value = dayjs(newCurrentDate.endDate).format('YYYY-MM-DD');
   }
-  sortOrder.value = '';
-  order_date.value = '';
+  clearSort();
   if (newTaskIds) {
     taskIdsAvailable.value = true;
   }