Parcourir la source

feature 不良统计和售后统计的接口对接

ylong il y a 6 mois
Parent
commit
1c1ac76b30

+ 10 - 17
src/views/statistic/after-sales/components/page-search.vue

@@ -15,48 +15,41 @@
   import { reactive, ref, defineEmits } from 'vue';
   import ProSearch from '@/components/CommonPage/ProSearch2.vue';
 
-  let { proxy } = getCurrentInstance();
   const emit = defineEmits(['search']);
 
-  const godownList = ref([]);
   const formItems = computed(() => {
     return [
       {
         type: 'daterange',
-        label: ' ',
+        label: '统计日期',
         prop: 'time',
         props: {
           format: 'YYYY-MM-DD',
           valueFormat: 'YYYY-MM-DD',
           onChange: (value) => {
-            initKeys.startTime = value ? value[0] : '';
-            initKeys.endTime = value ? value[1] : '';
+            initKeys.statisticStart = value ? value[0] : '';
+            initKeys.statisticEnd = value ? value[1] : '';
             searchRef.value?.setData(initKeys);
           }
         },
         colProps: {
-          span: 5
+          span: 6
         }
       }
     ];
   });
 
   const initKeys = reactive({
-    startTime: '',
-    endTime: '',
-    godownId: ''
-  });
-
-  function getStoreList(name = '') {
-    return proxy.$http.post(`/baseinfo/godown/searchGodown?name=${name}`);
-  }
-  getStoreList().then((res) => {
-    godownList.value = res.data.data;
+    statisticStart: '',
+    statisticEnd: '',
+    time: []
   });
 
   const searchRef = ref(null);
   /** 搜索 */
   const search = (data) => {
-    emit('search', { ...data});
+    let params = JSON.parse(JSON.stringify(data));
+    delete params.time;
+    emit('search', { ...params });
   };
 </script>

+ 112 - 62
src/views/statistic/after-sales/index.vue

@@ -1,76 +1,126 @@
 <template>
-  <ele-page flex-table>
-    <page-search @search="reload"></page-search>
-    <common-table
-      ref="pageRef"
-      :pageConfig="pageConfig"
-      :columns="columns"
-      :tools="false"
-      show-summary
-      :flex-table="false"
-    >
-      <template #toolbar="{ row }">
-        <div>
-          <el-radio-group @change="handleStatusChange" v-model="useStatus">
-            <el-radio-button label="售后订单实时统计" value="1" />
-            <el-radio-button label="售后订单历史统计" value="2" />
-          </el-radio-group>
-          <el-button
-            style="margin-left: 40px"
-            type="success"
-            plain
-            v-permission="'statistic:afterSales:export'"
-            @click="handleExportExcel(row)"
-          >
-            导出EXCEL
-          </el-button>
-        </div>
-      </template>
-    </common-table>
-  </ele-page>
+    <ele-page flex-table>
+        <page-search @search="reload" v-if="historyData == '1'"></page-search>
+        <common-table
+            ref="pageRef"
+            :pageConfig="pageConfig"
+            :columns="columns"
+            :tools="false"
+            show-summary
+            :summary-method="getSummaries"
+            :flex-table="false"
+        >
+            <template #toolbar="{ row }">
+                <div>
+                    <el-radio-group
+                        @change="handleStatusChange"
+                        v-model="historyData"
+                    >
+                        <el-radio-button label="售后订单实时统计" value="0" />
+                        <el-radio-button label="售后订单历史统计" value="1" />
+                    </el-radio-group>
+                    <el-button
+                        style="margin-left: 40px"
+                        type="success"
+                        plain
+                        v-permission="'statistic:afterSales:export'"
+                        v-if="historyData == '1'"
+                        @click="handleExportExcel(row)"
+                    >
+                        导出EXCEL
+                    </el-button>
+                </div>
+            </template>
+        </common-table>
+    </ele-page>
 </template>
 
 <script setup>
-  import { ref, reactive } from 'vue';
-  import CommonTable from '@/components/CommonPage/CommonTable.vue';
-  import pageSearch from './components/page-search.vue';
-  import { useDictData } from '@/utils/use-dict-data';
+import { ref, reactive } from "vue";
+import CommonTable from "@/components/CommonPage/CommonTable.vue";
+import pageSearch from "./components/page-search.vue";
 
-  defineOptions({ name: 'afterSalesStatistic' });
+defineOptions({ name: "afterSalesStatistic" });
 
-  const useStatus = ref('1');
-  function handleStatusChange(val) {
-    useStatus.value = val;
+const historyData = ref("0");
+function handleStatusChange(val) {
+    historyData.value = val;
+    pageConfig.params = { history: val };
     pageRef.value?.reload();
-  }
+}
 
-  /** 表格列配置 */
-  const columns = ref([
-    { type: 'index', label: '#', align: 'center', width: 80 },
-    { label: '售后订单数', prop: 'orderNum', align: 'center' },
-    { label: '发出订单数', prop: 'bookNum', align: 'center' },
-    { label: '未发订单数', prop: 'price', align: 'center' },
-    { label: '客户申请时间', prop: 'createTime', align: 'center' },
-    { label: '仓库', prop: 'godownName', align: 'center' },
-  ]);
+/** 表格列配置 */
+const columns = ref([
+    { type: "index", label: "#", align: "center", width: 80 },
+    { label: "售后订单数", prop: "refundNum", align: "center" },
+    { label: "发出订单数", prop: "sendRefundNum", align: "center" },
+    { label: "未发订单数", prop: "noSendRefundNum", align: "center" },
+    { label: "客户申请时间", prop: "statDate", align: "center" },
+    { label: "仓库", prop: "godownName", align: "center" },
+]);
 
-  /** 页面组件实例 */
-  const pageRef = ref(null);
+/** 页面组件实例 */
+const pageRef = ref(null);
 
-  const pageConfig = reactive({
-    pageUrl: '/baseinfo/godown/pagelist',
-    exportUrl: '/baseinfo/godown/export',
-    fileName: '售后统计',
-    cacheKey: 'afterSalesStatisticTable'
-  });
+const pageConfig = reactive({
+    pageUrl: "/order/refundStat/pagelist",
+    params: { history: 0 }, // 默认查询实时数据
+    exportUrl: "/order/refundStat/listExport",
+    fileName: "售后统计",
+    cacheKey: "afterSalesStatisticTable",
+});
 
-  //刷新表格
-  function reload(where) {
+/**
+ * 自定义表格汇总计算方法
+ * @param {Object} param0 - 表格数据和列信息
+ * @returns {Array} - 汇总行显示的数据
+ */
+function getSummaries({ columns, data }) {
+    const sums = [];
+    columns.forEach((column, index) => {
+        if (index === 0) {
+            sums[index] = "合计";
+            return;
+        }
+
+        const values = data.map((item) => Number(item[column.property]));
+
+        if (!values.length) {
+            sums[index] = "N/A";
+            return;
+        }
+
+        switch (column.property) {
+            case "refundNum":
+            case "sendRefundNum":
+            case "noSendRefundNum": {
+                // 数量类字段求和
+                const sum = values.reduce((prev, curr) => {
+                    const value = Number(curr);
+                    if (!isNaN(value)) {
+                        return prev + value;
+                    } else {
+                        return prev;
+                    }
+                }, 0);
+                sums[index] = sum;
+                break;
+            }
+            default:
+                sums[index] = "";
+        }
+    });
+
+    return sums;
+}
+
+//刷新表格
+function reload(where) {
     pageRef.value?.reload(where);
-  }
+}
 
-  //导出excel
-  function handleExportExcel() {
-    pageRef.value?.exportData('售后统计');
-  }
+//导出excel
+function handleExportExcel() {
+    pageRef.value?.exportData("售后统计");
+}
 </script>

+ 23 - 10
src/views/statistic/defect/components/page-search.vue

@@ -12,7 +12,7 @@
 </template>
 
 <script setup>
-  import { reactive, ref, defineEmits } from 'vue';
+  import { reactive, ref, defineEmits, computed, getCurrentInstance } from 'vue';
   import ProSearch from '@/components/CommonPage/ProSearch2.vue';
 
   let { proxy } = getCurrentInstance();
@@ -22,20 +22,28 @@
   const formItems = computed(() => {
     return [
       {
-        type: 'input',
-        label: '地区',
-        prop: 'auditName'
+        type: 'select',
+        label: '收货仓库',
+        prop: 'godownId',
+        options: godownList.value.map(item => ({
+          label: item.godownName,
+          value: item.id
+        })),
+        props: {
+          placeholder: '请选择收货仓库',
+          clearable: true
+        }
       },
       {
         type: 'daterange',
-        label: ' ',
+        label: '统计日期',
         prop: 'time',
         props: {
           format: 'YYYY-MM-DD',
           valueFormat: 'YYYY-MM-DD',
           onChange: (value) => {
-            initKeys.startTime = value ? value[0] : '';
-            initKeys.endTime = value ? value[1] : '';
+            initKeys.statDateStart = value ? value[0] : '';
+            initKeys.statDateEnd = value ? value[1] : '';
             searchRef.value?.setData(initKeys);
           }
         },
@@ -47,8 +55,8 @@
   });
 
   const initKeys = reactive({
-    startTime: '',
-    endTime: '',
+    statDateStart: '',
+    statDateEnd: '',
     godownId: ''
   });
 
@@ -62,6 +70,11 @@
   const searchRef = ref(null);
   /** 搜索 */
   const search = (data) => {
-    emit('search', { ...data});
+    const searchParams = {
+      godownId: data.godownId || 0,
+      statDateStart: data.statDateStart || initKeys.statDateStart,
+      statDateEnd: data.statDateEnd || initKeys.statDateEnd
+    };
+    emit('search', searchParams);
   };
 </script>

+ 56 - 52
src/views/statistic/defect/index.vue

@@ -1,63 +1,67 @@
 <template>
-  <ele-page flex-table>
-    <page-search @search="reload"></page-search>
-    <common-table
-      ref="pageRef"
-      :pageConfig="pageConfig"
-      :columns="columns"
-      :tools="false"
-      show-summary
-      :flex-table="false"
-    >
-      <template #toolbar="{ row }">
-        <div>
-          <el-button
-            type="success"
-            plain
-            v-permission="'statistic:defect:export'"
-            @click="handleExportExcel(row)"
-          >
-            导出EXCEL
-          </el-button>
-        </div>
-      </template>
-    </common-table>
-  </ele-page>
+    <ele-page flex-table>
+        <page-search @search="reload"></page-search>
+        <common-table
+            ref="pageRef"
+            :pageConfig="pageConfig"
+            :columns="columns"
+            :tools="false"
+            show-summary
+            :flex-table="false"
+        >
+            <template #toolbar="{ row }">
+                <div>
+                    <el-button
+                        type="success"
+                        plain
+                        v-permission="'statistic:defect:export'"
+                        @click="handleExportExcel(row)"
+                    >
+                        导出EXCEL
+                    </el-button>
+                </div>
+            </template>
+        </common-table>
+    </ele-page>
 </template>
 
 <script setup>
-  import { ref, reactive } from 'vue';
-  import CommonTable from '@/components/CommonPage/CommonTable.vue';
-  import pageSearch from './components/page-search.vue';
+    import { ref, reactive } from 'vue';
+    import CommonTable from '@/components/CommonPage/CommonTable.vue';
+    import pageSearch from './components/page-search.vue';
 
-  defineOptions({ name: 'arrivalSign' });
+    defineOptions({ name: 'statisticDefect' });
 
-  /** 表格列配置 */
-  const columns = ref([
-    { type: 'index', label: '#', align: 'center', width: 80 },
-    { label: '地区', prop: 'godownName', align: 'center' },
-    { label: '收货仓库', prop: 'godownName', align: 'center' },
-    { label: '不良率', prop: 'godownName', align: 'center' },
-    { label: '统计日期', prop: 'createTime', align: 'center' }
-  ]);
+    /** 表格列配置 */
+    const columns = ref([
+        { type: 'index', label: '#', align: 'center', width: 80 },
+        { label: '地区', prop: 'area', align: 'center' },
+        { label: '收货仓库', prop: 'godownName', align: 'center' },
+        {
+            label: '不良率',
+            prop: 'badRatio',
+            align: 'center'
+        },
+        { label: '统计日期', prop: 'statDate', align: 'center' }
+    ]);
 
-  /** 页面组件实例 */
-  const pageRef = ref(null);
+    /** 页面组件实例 */
+    const pageRef = ref(null);
 
-  const pageConfig = reactive({
-    pageUrl: '/baseinfo/godown/pagelist',
-    exportUrl: '/baseinfo/godown/export',
-    fileName: '不良统计',
-    cacheKey: 'arrivalSignTable'
-  });
+    const pageConfig = reactive({
+        pageUrl: '/order/ordercheck/stat/badRationStat',
+        exportUrl: '/order/ordercheck/stat/badRationStatExport',
+        fileName: '不良统计',
+        cacheKey: 'statisticDefectTable'
+    });
 
-  //刷新表格
-  function reload(where) {
-    pageRef.value?.reload(where);
-  }
+    //刷新表格
+    function reload(where) {
+        pageRef.value?.reload(where);
+    }
 
-  //导出excel
-  function handleExportExcel() {
-    pageRef.value?.exportData('不良统计');
-  }
+    //导出excel
+    function handleExportExcel() {
+        pageRef.value?.exportData('不良统计');
+    }
 </script>