解决在非配置api情况下,列进行过滤时,合计行统计值未更新的问题

pull/1201/head
Juliefuling 2024-04-23 14:56:44 +08:00
parent ca1491a5c4
commit 443a4c43cc
2 changed files with 7 additions and 3 deletions

View File

@ -43,7 +43,7 @@
</template>
<template v-if="showSummaryRef" #summary="data">
<slot name="summary" v-bind="data || {}">
<TableSummary v-bind="getSummaryProps" />
<TableSummary :data="data || {}" v-bind="getSummaryProps" />
</slot>
</template>
</Table>

View File

@ -23,12 +23,16 @@ export default defineComponent({
rowKey: propTypes.string.def('key'),
// 是否有展开列
hasExpandedRow: propTypes.bool,
data: {
type: Object as PropType<Recordable>,
default: () => {}
}
},
setup(props) {
const table = useTableContext();
const getDataSource = computed((): Recordable[] => {
const { summaryFunc, summaryData } = props;
const { summaryFunc, summaryData, data: { pageData } } = props;
if (summaryData?.length) {
summaryData.forEach((item, i) => (item[props.rowKey] = `${i}`));
return summaryData;
@ -36,7 +40,7 @@ export default defineComponent({
if (!isFunction(summaryFunc)) {
return [];
}
let dataSource = cloneDeep(unref(table.getDataSource()));
let dataSource = cloneDeep(unref(pageData));
dataSource = summaryFunc(dataSource);
dataSource.forEach((item, i) => {
item[props.rowKey] = `${i}`;