解决在非配置api情况下,列进行过滤时,合计行统计值未更新的问题
parent
ca1491a5c4
commit
443a4c43cc
|
@ -43,7 +43,7 @@
|
||||||
</template>
|
</template>
|
||||||
<template v-if="showSummaryRef" #summary="data">
|
<template v-if="showSummaryRef" #summary="data">
|
||||||
<slot name="summary" v-bind="data || {}">
|
<slot name="summary" v-bind="data || {}">
|
||||||
<TableSummary v-bind="getSummaryProps" />
|
<TableSummary :data="data || {}" v-bind="getSummaryProps" />
|
||||||
</slot>
|
</slot>
|
||||||
</template>
|
</template>
|
||||||
</Table>
|
</Table>
|
||||||
|
|
|
@ -23,12 +23,16 @@ export default defineComponent({
|
||||||
rowKey: propTypes.string.def('key'),
|
rowKey: propTypes.string.def('key'),
|
||||||
// 是否有展开列
|
// 是否有展开列
|
||||||
hasExpandedRow: propTypes.bool,
|
hasExpandedRow: propTypes.bool,
|
||||||
|
data: {
|
||||||
|
type: Object as PropType<Recordable>,
|
||||||
|
default: () => {}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
const table = useTableContext();
|
const table = useTableContext();
|
||||||
|
|
||||||
const getDataSource = computed((): Recordable[] => {
|
const getDataSource = computed((): Recordable[] => {
|
||||||
const { summaryFunc, summaryData } = props;
|
const { summaryFunc, summaryData, data: { pageData } } = props;
|
||||||
if (summaryData?.length) {
|
if (summaryData?.length) {
|
||||||
summaryData.forEach((item, i) => (item[props.rowKey] = `${i}`));
|
summaryData.forEach((item, i) => (item[props.rowKey] = `${i}`));
|
||||||
return summaryData;
|
return summaryData;
|
||||||
|
@ -36,7 +40,7 @@ export default defineComponent({
|
||||||
if (!isFunction(summaryFunc)) {
|
if (!isFunction(summaryFunc)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
let dataSource = cloneDeep(unref(table.getDataSource()));
|
let dataSource = cloneDeep(unref(pageData));
|
||||||
dataSource = summaryFunc(dataSource);
|
dataSource = summaryFunc(dataSource);
|
||||||
dataSource.forEach((item, i) => {
|
dataSource.forEach((item, i) => {
|
||||||
item[props.rowKey] = `${i}`;
|
item[props.rowKey] = `${i}`;
|
||||||
|
|
Loading…
Reference in New Issue