From 344ad1d1f6c6cd7eb48086fec8f1dd40699389b7 Mon Sep 17 00:00:00 2001 From: Yexk Date: Fri, 13 Nov 2020 21:48:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DneedTotal=E6=B1=82?= =?UTF-8?q?=E5=92=8C=E7=9A=84=E6=97=B6=E5=80=99=E4=B8=8D=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=A4=9A=E7=BB=B4=E6=95=B0=E7=BB=84=E4=BB=A5=E5=8F=8A=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E4=B8=B2=E6=B1=82=E5=92=8C=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/table/StandardTable.vue | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/table/StandardTable.vue b/src/components/table/StandardTable.vue index 3f54e41..e8f6d48 100644 --- a/src/components/table/StandardTable.vue +++ b/src/components/table/StandardTable.vue @@ -95,7 +95,14 @@ export default { return { ...item, total: selectedRows.reduce((sum, val) => { - return sum + val[item.dataIndex] + let v + try{ + v = val[item.index] ? val[item.index] : eval(`val.${item.dataIndex}`); + }catch(_){ + v = val[item.index]; + } + v = !isNaN(parseFloat(v)) ? parseFloat(v) : 0; + return sum + v }, 0) } })