From 876947c79e1d663d08010b7ecf6aec702ad94cac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B1=E7=9C=A0=E5=84=80=E5=BC=8F?= <854085467@qq.com> Date: Tue, 19 Jul 2022 05:01:43 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(component):=20=E6=96=B0=E5=A2=9E=20ta?= =?UTF-8?q?ble=20=E7=BB=84=E4=BB=B6=20columns=20=E9=85=8D=E7=BD=AE=20total?= =?UTF-8?q?Row=20=E5=B1=9E=E6=80=A7,=20=E7=94=A8=E4=BA=8E=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=88=97=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/component/datePicker/index.vue | 1 - .../component/src/component/table/index.vue | 41 ++++++++++++- package/component/src/provider/index.vue | 7 ++- .../src/document/zh-CN/components/table.md | 59 +++++++++++++++++++ .../src/document/zh-CN/guide/changelog.md | 1 + .../src/document/zh-CN/guide/theme.md | 32 +++++----- 6 files changed, 121 insertions(+), 20 deletions(-) diff --git a/package/component/src/component/datePicker/index.vue b/package/component/src/component/datePicker/index.vue index 10999161..0c94a0a2 100644 --- a/package/component/src/component/datePicker/index.vue +++ b/package/component/src/component/datePicker/index.vue @@ -112,7 +112,6 @@ import { watch, defineProps, defineEmits, - onMounted, reactive, provide, } from "vue"; diff --git a/package/component/src/component/table/index.vue b/package/component/src/component/table/index.vue index 979bbf1a..4574ff5c 100644 --- a/package/component/src/component/table/index.vue +++ b/package/component/src/component/table/index.vue @@ -12,7 +12,6 @@ import { useSlots, withDefaults, onMounted, - onUpdated, StyleValue, WritableComputedRef, computed, @@ -319,6 +318,30 @@ const renderFixedClassName = (column: any, columnIndex: number) => { } } }; + +const hasTotalRow = computed(() => { + let b = false; + props.columns.forEach(item => { + if(item.totalRow) { + b = true; + } + }) + return b; +}) + +const renderTotalRowCell = (column: any) => { + if(column.totalRow) { + if(column.totalRow != true) { + return column.totalRow; + } else { + let total = 0; + tableDataSource.value.forEach(item => { + total = total + item[column.key]; + }) + return total; + } + } +}