ylong 8 mesi fa
parent
commit
967a4087c3

+ 5 - 0
src/utils/validators.js

@@ -71,6 +71,11 @@ const validators = {
     pattern: /^(0\.\d{1,2}|0[1-9]\d{0,1}\.\d{1,2}|1)$/,
     message: '请输入大于0小于1且最多两位小数的数值'
   },
+  //大于 0 小于等于 10 且最多两位小数验证
+  decimalRange10: {
+    pattern: /^(0\.\d{1,2}|[1-9]\.\d{1,2}|[1-9]|10)$/,
+    message: '请输入大于0小于10且最多两位小数的数值'
+  },
 
   money:{
     pattern: /^(([1-9]{1}\d*)|([0]{1}))(\.\d{1,2})?$/,

+ 1 - 1
src/views/recycle/components/add-discount.vue

@@ -52,7 +52,7 @@ const items = reactive([
             placeholder: '请输入折扣',
         },
         itemProps: {
-            rules: [validators.decimalRange]
+            rules: [validators.decimalRange10]
         }
     }
 ]);

+ 1 - 1
src/views/recycle/components/modify-discount.vue

@@ -58,7 +58,7 @@ const items = reactive([
         type: 'input',
         required: true,
         itemProps: {
-            rules: [validators.decimalRange]
+            rules: [validators.decimalRange10]
         }
     }
 ]);

+ 1 - 1
src/views/recycle/components/set-params.vue

@@ -83,7 +83,7 @@
     const rules = {
         recycleDiscount: [
             { required: true, message: '请输入回收折扣', trigger: 'blur' },
-            validators.money
+            validators.decimalRange10
         ],
         recycleMax: [
             { required: true, message: '请输入最大回收数量', trigger: 'blur' },

+ 1 - 1
src/views/recycleOrder/detail/order-modify-discount.vue

@@ -59,7 +59,7 @@
       type: 'input',
       required: true,
       itemProps: {
-        rules: [validators.decimalRange]
+        rules: [validators.decimalRange10]
       }
     },
     {

+ 1 - 1
src/views/recycleOrder/detail/order-specified-discount.vue

@@ -56,7 +56,7 @@
       type: 'input',
       required: true,
       itemProps: {
-        rules: [validators.decimalRange]
+        rules: [validators.decimalRange10]
       }
     }
   ]);

+ 6 - 14
src/views/statistic/entry/components/page-search.vue

@@ -24,7 +24,7 @@
       {
         type: 'input',
         label: '审核员',
-        prop: 'auditName'
+        prop: 'sysUserName'
       },
       {
         type: 'daterange',
@@ -34,8 +34,8 @@
           format: 'YYYY-MM-DD',
           valueFormat: 'YYYY-MM-DD',
           onChange: (value) => {
-            initKeys.startTime = value ? value[0] : '';
-            initKeys.endTime = value ? value[1] : '';
+            initKeys.startDate = value ? value[0] : '';
+            initKeys.endDate = value ? value[1] : '';
             searchRef.value?.setData(initKeys);
           }
         },
@@ -47,18 +47,10 @@
   });
 
   const initKeys = reactive({
-    startTime: '',
-    endTime: '',
-    godownId: ''
+    startDate: '',
+    endDate: '',
+    sysUserName: ''
   });
-
-  function getStoreList(name = '') {
-    return proxy.$http.post(`/baseinfo/godown/searchGodown?name=${name}`);
-  }
-  getStoreList().then((res) => {
-    godownList.value = res.data.data;
-  });
-
   const searchRef = ref(null);
   /** 搜索 */
   const search = (data) => {

+ 95 - 12
src/views/statistic/entry/index.vue

@@ -1,12 +1,13 @@
 <template>
   <ele-page flex-table>
-    <page-search @search="reload"></page-search>
+    <page-search @search="reload" v-if="useStatus==2"></page-search>
     <common-table
       ref="pageRef"
       :pageConfig="pageConfig"
       :columns="columns"
       :tools="false"
       show-summary
+      :summary-method="getSummaries"
       :flex-table="false"
     >
       <template #toolbar="{ row }">
@@ -41,33 +42,115 @@
   const useStatus = ref('1');
   function handleStatusChange(val) {
     useStatus.value = val;
+    // 根据选择的状态动态更新接口URL
+    if (val === '1') {
+      // 实时统计
+      pageConfig.pageUrl = '/order/recycleOrderStatistic/audit/todayList';
+    } else {
+      // 历史统计
+      pageConfig.pageUrl = '/order/recycleOrderStatistic/audit/historyPage';
+    }
     pageRef.value?.reload();
   }
 
   /** 表格列配置 */
   const columns = ref([
     { type: 'index', label: '#', align: 'center', width: 80 },
-    { label: '录入员', prop: 'godownName', align: 'center' },
-    { label: '录入审核订单', prop: 'orderNum', align: 'center' },
-    { label: '录入书籍数量', prop: 'bookNum', align: 'center' },
-    { label: '实际回收数量', prop: 'price', align: 'center' },
-    { label: '品相良好', prop: 'price', align: 'center' },
-    { label: '品相一般', prop: 'price', align: 'center' },
-    { label: '品相极差', prop: 'price', align: 'center' },
-    { label: '不良率', prop: 'auditNum', align: 'center' },
-    { label: '审核日期', prop: 'createTime', align: 'center' }
+    { label: '录入员', prop: 'sysUserName', align: 'center' },
+    { label: '录入审核订单', prop: 'orderCount', align: 'center' },
+    { label: '录入书籍数量', prop: 'totalNum', align: 'center' },
+    { label: '实际回收数量', prop: 'totalRecycleReal', align: 'center' },
+    { label: '品相良好', prop: 'totalGoodNum', align: 'center' },
+    { label: '品相一般', prop: 'totalGeneralNum', align: 'center' },
+    { label: '品相极差', prop: 'totalBadNum', align: 'center' },
+    { label: '不良率', prop: 'badRate', align: 'center' },
+    { label: '预估金额', prop: 'totalExpectMoney', align: 'center' },
+    { label: '审核金额', prop: 'totalAuditMoney', align: 'center' },
+    { label: '审核日期', prop: 'statisticDate', align: 'center' }
   ]);
 
   /** 页面组件实例 */
   const pageRef = ref(null);
 
   const pageConfig = reactive({
-    pageUrl: '/baseinfo/godown/pagelist',
-    exportUrl: '/baseinfo/godown/export',
+    pageUrl: '/order/recycleOrderStatistic/audit/todayList', // 默认使用实时统计接口
+    exportUrl: '/order/recycleOrderStatistic/audit/export',
     fileName: '录入统计',
     cacheKey: 'entryStatisticTable'
   });
 
+  /**
+   * 自定义表格汇总计算方法
+   * @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 'badRate': {
+          // 不良率计算平均值
+          const validValues = values.filter((value) => value && !isNaN(value));
+          if (validValues.length > 0) {
+            const sum = validValues.reduce((prev, curr) => prev + curr, 0);
+            sums[index] = (sum / validValues.length).toFixed(2) + '%';
+          } else {
+            sums[index] = '';
+          }
+          break;
+        }
+        case 'orderCount':
+        case 'totalNum':
+        case 'totalRecycleReal':
+        case 'totalGoodNum':
+        case 'totalGeneralNum':
+        case 'totalBadNum': {
+          // 数量类字段求和
+          const sum = values.reduce((prev, curr) => {
+            const value = Number(curr);
+            if (!isNaN(value)) {
+              return prev + value;
+            } else {
+              return prev;
+            }
+          }, 0);
+          sums[index] = sum;
+          break;
+        }
+        case 'totalExpectMoney':
+        case 'totalAuditMoney': {
+          // 金额类字段求和,保留两位小数
+          const sum = values.reduce((prev, curr) => {
+            const value = Number(curr);
+            if (!isNaN(value)) {
+              return prev + value;
+            } else {
+              return prev;
+            }
+          }, 0);
+          sums[index] = sum.toFixed(2);
+          break;
+        }
+        default:
+          sums[index] = '';
+      }
+    });
+
+    return sums;
+  }
+
   //刷新表格
   function reload(where) {
     pageRef.value?.reload(where);