Browse Source

feat: 费用明细总计客户、单号相同的金额

lyc 1 week ago
parent
commit
72f3bd9e89

+ 23 - 2
src/composables/userMoneySumDetail/userMoneySumDetail.ts

@@ -10,7 +10,7 @@ import { usePersonnel } from '@/store/list_personnel';
 import { FeeReportTemplateType } from '@/type/BaseBusinessFeeseType';
 import { BaseFeesetAction } from '@/type/BaseFeesetAction';
 import { getMonthStartAndEndDates } from '@/utils/dateTimeStr';
-import { format, isArray, isBoolean, isNumber } from '@/utils/is';
+import { format, isArray, isArrayLength, isBoolean, isNumber, roundToDecimals } from '@/utils/is';
 import { useErrorConfirm } from '@/utils/useErrorConfirm';
 import { useReturnData } from '@/utils/useReturnData';
 import { Tickets, DocumentChecked } from "@element-plus/icons-vue";
@@ -240,6 +240,26 @@ function userMoneySumDetailList(usermoneyGridOptions: BasicTableProps) {
             usermoneyGridOptions.loading = false
         }
     }
+    // 获取客户、单号总计金额
+    const getFeeTotalAmount = computed(() => {
+        if (
+            usermoneyGridOptions.data &&
+            listParams.customerId
+        ) {
+            const isEvery = usermoneyGridOptions.data.every(item => item.customerId === Number(listParams.customerId))
+            return isEvery ? usermoneyGridOptions.data.reduce((acc, item) => roundToDecimals(acc + item.feeAmount, 2), 0) : 0;
+        }
+        if (
+            usermoneyGridOptions.data &&
+            listParams.orderIdList &&
+            isArrayLength(listParams.orderIdList)
+        ) {
+            const orderId = listParams.orderIdList ? listParams.orderIdList[0] : ''
+            const isEvery = usermoneyGridOptions.data.every(item => item.orderId === orderId)
+            return isEvery ? usermoneyGridOptions.data.reduce((acc, item) => roundToDecimals(acc + item.feeAmount, 2), 0) : 0
+        }
+        return 0
+    })
 
     // 扁平化起始结束时间
     const flatDate = async () => {
@@ -440,7 +460,8 @@ function userMoneySumDetailList(usermoneyGridOptions: BasicTableProps) {
         reportQueryDateTypeList,
         getSalesmanUsesList,
         accountPeriodTypeList,
-        allPaymentPlatformList
+        allPaymentPlatformList,
+        getFeeTotalAmount,
     }
 }
 

+ 11 - 0
src/utils/is.ts

@@ -123,4 +123,15 @@ export function format(str, splitor = ',') {
  */
 export function isFunction(val: unknown): val is Function {
     return typeof val === 'function';
+}
+
+/**
+ * 四舍五入小数点后几位的值
+ * @param {*} num
+ * @param {*} decimals
+ * @returns
+ */
+export function roundToDecimals(num, decimals) {
+    const factor = Math.pow(10, decimals)
+    return Math.round(num * factor) / factor
 }

+ 32 - 11
src/views/userMoneyDetail/userMoneyDetailList.vue

@@ -296,16 +296,28 @@
       </template>
     </VxeBasicTable>
     <!-- 分页 -->
-    <el-pagination
-      v-model:current-page="queryUserMoneySumDetailForm.pageNum"
-      :page-sizes="[10, 20, 40, 80, 100]"
-      :page-size="queryUserMoneySumDetailForm.pageSize"
-      layout="total, sizes, prev, pager, next, jumper"
-      :total="queryUserMoneySumDetailForm.total"
-      background
-      @size-change="sizeChange"
-      @current-change="currentChange"
-    />
+    <div class="flex align-center">
+      <el-pagination
+        v-model:current-page="queryUserMoneySumDetailForm.pageNum"
+        :page-sizes="[10, 20, 40, 80, 100]"
+        :page-size="queryUserMoneySumDetailForm.pageSize"
+        layout="total, sizes, prev, pager, next, jumper"
+        :total="queryUserMoneySumDetailForm.total"
+        background
+        @size-change="sizeChange"
+        @current-change="currentChange"
+      />
+      <div
+        v-show="getFeeTotalAmount > 0"
+        class="total-num inline-flex align-center"
+      >
+        <span>总计金额:</span>
+        <span class="price">
+          {{ getFeeTotalAmount }}
+        </span>
+        <span>CNY</span>
+      </div>
+    </div> 
   </el-main>
   <QueryExpenseItemDetail ref="queryExpenseItemDetailRef" />
 </template>
@@ -357,7 +369,8 @@ const {
   downLonading,
   getSalesmanUsesList,
   accountPeriodTypeList,
-  allPaymentPlatformList
+  allPaymentPlatformList,
+  getFeeTotalAmount
 } = userMoneySumDetailList(usermoneyGridOptions)
 
 // daterange 时间范围
@@ -390,5 +403,13 @@ const { defaultTime, isSelectDisabled, selectCalendar } = useTimeRange(62)
       margin-bottom: 6px;
     }
   }
+
+  .total-num {
+    padding-left: 16px;
+    .price {
+      padding: 0px 8px;
+      color: #67C23A;
+    }
+  }
 }
 </style>