From 240a964b1c20d32cdf1f6b981586a0baf6888c2e Mon Sep 17 00:00:00 2001 From: ctw <> Date: Wed, 22 Jan 2025 19:54:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=AD=E7=89=A9=E8=BD=A6=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=90=88=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/DepTree/index.vue | 4 +- src/views/admin/system/user/index.vue | 59 +++++++++++++------------- src/views/hard/components/shop-car.vue | 43 ++++++++++++++++++- 3 files changed, 73 insertions(+), 33 deletions(-) diff --git a/src/components/DepTree/index.vue b/src/components/DepTree/index.vue index b5e4234..7949122 100644 --- a/src/components/DepTree/index.vue +++ b/src/components/DepTree/index.vue @@ -162,7 +162,7 @@ defineExpose({ display: flex; align-items: center; padding-bottom: 10px; - box-shadow: 0 0 8px 0 rgba(0, 0, 0, 0.1); + box-shadow: 0 8px 8px -8px rgba(0, 0, 0, 0.1); z-index: 10; &-input { @@ -189,7 +189,7 @@ defineExpose({ justify-content: center; align-items: center; padding-top: 10px; - box-shadow: 0 0 8px 0 rgba(0, 0, 0, 0.1); + box-shadow: 0 -8px 8px -8px rgba(0, 0, 0, 0.1); z-index: 10; position: sticky; bottom: 0; diff --git a/src/views/admin/system/user/index.vue b/src/views/admin/system/user/index.vue index f57dc02..7954a28 100644 --- a/src/views/admin/system/user/index.vue +++ b/src/views/admin/system/user/index.vue @@ -3,35 +3,35 @@
- - - - - - + + + + + +
@@ -238,7 +238,6 @@ import { auth } from "/@/utils/authFunction" // 动态引入组件 const UserForm = defineAsyncComponent(() => import("./form.vue")) const FaceManage = defineAsyncComponent(() => import("./face-manage.vue")) -const QueryTree = defineAsyncComponent(() => import("/@/components/QueryTree/index.vue")) const PopoverInput = defineAsyncComponent(() => import("/@/components/PopoverInput/index.vue")) const { t } = useI18n() diff --git a/src/views/hard/components/shop-car.vue b/src/views/hard/components/shop-car.vue index 714beb8..2030b6d 100644 --- a/src/views/hard/components/shop-car.vue +++ b/src/views/hard/components/shop-car.vue @@ -7,6 +7,8 @@ :cell-style="tableStyle.cellStyle" :header-cell-style="tableStyle.headerCellStyle" @sort-change="sortChangeHandle" + show-summary + :summary-method="getSummaries" > @@ -14,7 +16,7 @@ - + @@ -39,6 +41,8 @@ import { BasicTableProps, useTable } from "/@/hooks/table" import * as hardCar from "/@/api/hard/hard-car" import { displayPrice } from "/@/utils/formatMoney" +import { TableColumnCtx } from "element-plus" +import { VNode } from "vue" // 定义变量内容 const visible = ref(false) @@ -62,6 +66,43 @@ const openDialog = (id: string) => { } } +interface SummaryMethodProps { + columns: TableColumnCtx[] + data: T[] +} + +const getSummaries = (param: SummaryMethodProps) => { + const { columns, data } = param + const sums: (string | VNode)[] = [] + columns.forEach((column, index) => { + if (index === 0) { + sums[index] = "合计" + return + } + if (column.property === "productPrice" || column.property === "totalPrice") { + const values = data.map((item) => Number(item[column.property])) + if (!values.every((value) => Number.isNaN(value))) { + sums[index] = displayPrice( + values.reduce((prev, curr) => { + const value = Number(curr) + if (!Number.isNaN(value)) { + return prev + curr + } else { + return prev + } + }, 0), + ) + } else { + sums[index] = "N/A" + } + } else { + sums[index] = "" + } + }) + + return sums +} + // 暴露变量 defineExpose({ openDialog,