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; } }