From a1f2fab9815db0c5ce7e78b5a3ce49e6da357f32 Mon Sep 17 00:00:00 2001 From: fan Date: Fri, 1 Mar 2024 15:23:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=84=E5=88=86=E8=A7=84=E5=88=99=E8=B0=83?= =?UTF-8?q?=E6=95=B41?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/contest/scoreRule.vue | 37 +++++++------------ .../contestTaskScoreManage/edit.vue | 20 ---------- 2 files changed, 13 insertions(+), 44 deletions(-) diff --git a/src/views/contest/scoreRule.vue b/src/views/contest/scoreRule.vue index 367bed39b..f70891e55 100644 --- a/src/views/contest/scoreRule.vue +++ b/src/views/contest/scoreRule.vue @@ -12,10 +12,9 @@ style="width: 100%;margin-top: 10px;" > - - - + + @@ -43,29 +42,19 @@ export default { handleClose() { this.dialogVisible = false; }, - getSummaries(param) { - const { columns, data } = param; - const sums = []; - columns.forEach((column, index) => { - if (index === 0) { - sums[index] = '总分'; - return; - } - if (index === 3) { - const values = data.map(item => Number(item[column.property])); - sums[index] = values.reduce((prev, curr) => { - const value = Number(curr); - if (!isNaN(value)) { - return prev + curr; - } else { - return prev; - } - }, 0); - sums[index] += ''; - } else { - sums[index] = '/'; + handleSummaries(data, sums) { + data.forEach(item => { + sums[3] += Number(item.score); + if (item.children && item.children.length) { + this.handleSummaries(item.children, sums); } }); + }, + getSummaries(param) { + const { columns, data } = param; + const sums = ['总分', '/', '/', 0, '/']; + console.log(columns, '==='); + this.handleSummaries(data, sums); return sums; } } diff --git a/src/views/contestDataManage/contestTaskScoreManage/edit.vue b/src/views/contestDataManage/contestTaskScoreManage/edit.vue index b6fde75c7..f50876d86 100644 --- a/src/views/contestDataManage/contestTaskScoreManage/edit.vue +++ b/src/views/contestDataManage/contestTaskScoreManage/edit.vue @@ -167,26 +167,6 @@ export default { const sums = ['总分', '/', '/', 0, '/']; console.log(columns, '==='); this.handleSummaries(data, sums); - // columns.forEach((column, index) => { - // if (index === 0) { - // sums[index] = '总分'; - // return; - // } - // if (index === 3) { - // const values = data.map(item => Number(item[column.property])); - // sums[index] = values.reduce((prev, curr) => { - // const value = Number(curr); - // if (!isNaN(value)) { - // return prev + curr; - // } else { - // return prev; - // } - // }, 0); - // sums[index] += ''; - // } else { - // sums[index] = '/'; - // } - // }); return sums; } }