element [bug report] Table summary calculation value problem

x0fgdtte  于 5个月前  发布在  其他
关注(0)|答案(4)|浏览(63)

Element UI version

2.13.1

OS/Browsers version

macOS 10.15.4 / Chrome 81

Vue version

2.6.11

element/packages/table/src/config.js

Line 92 in d578b01

| | constvalue=property&&getPropByPath(row,property).v; |

Steps to reproduce

Table summary 计算取值时,直接使用column.prop做属性名读取data属性。
element/packages/table/src/table-footer.js

Line 19 in d578b01

| | constvalues=this.store.states.data.map(item=>Number(item[column.property])); |

而column自身render会通过getPropByPath方法(src/utils/util.js)将prop作为属性路径获取值。
element/packages/table/src/config.js

Line 92 in d578b01

| | constvalue=property&&getPropByPath(row,property).v; |

导致在上使用属性路径而非简单属性名作为prop值时,summary无法正确计算合计值。

What is Expected?

在上使用属性路径而非简单属性名作为prop值时,summary行能正确计算合计值。

What is actually happening?

在上使用属性路径而非简单属性名作为prop值时,summary行不能正确计算合计值。

gmxoilav

gmxoilav1#

Translation of this issue:

Element UI version

2.13.1

OS/Browsers version

macOS 10.15.4 / Chrome 81

Vue version

2.6.11

element/packages/table/src/config.js

Line 92 in d578b01

| | constvalue=property&&getPropByPath(row,property).v; |

Steps to reproduce

When calculating the value of table summary, directly use column.prop as the property name to read the data property.

element/packages/table/src/table-footer.js

Line 19 in d578b01

| | constvalues=this.store.states.data.map(item=>Number(item[column.property])); |

The column's own render will use the getpropbypath method (SRC / utils / util. JS) to get the value of prop as the property path.

element/packages/table/src/config.js

Line 92 in d578b01

| | constvalue=property&&getPropByPath(row,property).v; |

As a result, when using property path instead of simple property name as prop value on < El table column >, summary cannot calculate the total value correctly.

What is Expected?

When using the property path instead of the simple property name as the prop value on < El table column >, the summary line calculates the total value correctly.

What is actually happening?

When using the property path instead of the simple property name as the prop value on < El table column >, the summary line does not calculate the total value correctly.

1hdlvixo

1hdlvixo2#

@hejun200613224 我从新计算了values,支持prop对象嵌套属性
#20548

ltqd579y

ltqd579y3#

@hejun200613224 我从新计算了values,支持prop对象嵌套属性
#20548

我看了你的实现,好像是自行重新实现了该逻辑。可以参考我提出的问题,原来的utils里貌似是有该功能模块的,是否有重复造轮子?

mjqavswn

mjqavswn4#

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

相关问题