From b8e1395f02c929eaa96b949cf6027ee2a43856a6 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 06 九月 2022 19:03:37 +0800 Subject: [PATCH] 2022-09-06 --- src/tabviews/zshare/actionList/exceloutbutton/index.jsx | 59 ++++++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 38 insertions(+), 21 deletions(-) diff --git a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx index 31c7d41..ed16f15 100644 --- a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx +++ b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx @@ -487,11 +487,22 @@ exportExcel = (data) => { const { btn } = this.props - let columns = btn.verify.columns.filter(col => col.output !== 'false') + let imgCol = false + let columns = btn.verify.columns.filter(col => { + if (col.output === 'false') return false + + if (col.type === 'image') { + imgCol = true + } + + if (col.type === 'number' && (col.decimal || col.decimal === 0) ) { + col.round = Math.pow(10, col.decimal) + } + + return col + }) try { - let imgCol = columns.filter(col => col.type === 'image')[0] - if (imgCol) { const column = columns.map(item => { let col = { @@ -515,11 +526,18 @@ item.$Index = index + 1 + '' columns.forEach((col, i) => { - if (item[col.Column] && col.abs === 'true') { - _row[col.Column] = Math.abs(item[col.Column]) - } else { - _row[col.Column] = item[col.Column] + let val = item[col.Column] + if (typeof(val) === 'number') { + if (col.abs === 'true') { + val = Math.abs(val) + } + if (col.round) { + val = Math.round(val * col.round) / col.round + val = val.toFixed(col.decimal) + } } + + _row[col.Column] = val }) table.push(_row) @@ -532,23 +550,14 @@ } else { this.execSuccess({ErrCode: 'S', ErrMesg: '瀵煎嚭鎴愬姛锛�'}) } - } else { let _header = [] let _topRow = {} let colwidth = [] - let abses = [] columns.forEach(col => { - if (_topRow[col.Column]) return - _header.push(col.Column) _topRow[col.Column] = col.Text - - if (col.abs === 'true') { - abses.push(col.Column) - } - colwidth.push({width: col.Width || 20}) }) @@ -561,12 +570,20 @@ item.$Index = index + 1 + '' - _header.forEach(field => { - if (item[field] && abses.includes(field)) { - _row[field] = Math.abs(item[field]) - } else { - _row[field] = item[field] + columns.forEach((col, i) => { + let val = item[col.Column] + + if (typeof(val) === 'number') { + if (col.abs === 'true') { + val = Math.abs(val) + } + if (col.round) { + val = Math.round(val * col.round) / col.round + val = val.toFixed(col.decimal) + } } + + _row[col.Column] = val }) table.push(_row) -- Gitblit v1.8.0