From faf99ae37eea8905ef181eaddae48d9a1457d92a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 07 七月 2020 16:19:32 +0800 Subject: [PATCH] 2020-07-07 --- src/tabviews/zshare/actionList/exceloutbutton/index.jsx | 74 +++++++------------------------------ 1 files changed, 14 insertions(+), 60 deletions(-) diff --git a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx index d967530..c1c6dc0 100644 --- a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx +++ b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx @@ -91,6 +91,13 @@ duration: 5 }) return + } else if (!btn.verify || !btn.verify.columns || btn.verify.columns.length === 0) { + notification.warning({ + top: 92, + message: '璇疯缃鍑哄垪锛�', + duration: 5 + }) + return } this.triggerExcelout() @@ -373,74 +380,21 @@ * @description Excel 鐢熸垚 */ exportExcel = (data) => { - const { columns, btn } = this.props + const { btn } = this.props if (data && data.length > 0) { try { let _header = [] let _topRow = {} let colwidth = [] - let hidecolumns = [] + btn.verify.columns.forEach(col => { + if (!data[0].hasOwnProperty(col.Column)) return + if (_topRow[col.Column]) return - let verifyColumn = {} // 璁板綍楠岃瘉淇℃伅涓殑Excel鍒楅厤缃� - if (btn.verify && btn.verify.columns && btn.verify.columns.length > 0) { - btn.verify.columns.forEach(col => { - if (col.export === 'false') { - hidecolumns.push(col.Column) - return - } - verifyColumn[col.Column] = col - }) - } + _header.push(col.Column) + _topRow[col.Column] = col.Text - columns.forEach(col => { - if (col.Hide === 'true' || hidecolumns.includes(col.field)) { - hidecolumns.push(col.field) - return - } - if (!data[0].hasOwnProperty(col.field)) return - if (_topRow[col.field]) return - - if (verifyColumn[col.field]) { // 浼樺厛浣跨敤楠岃瘉淇℃伅涓殑鍒楄缃� - _header.push(col.field) - _topRow[col.field] = verifyColumn[col.field].Text - - colwidth.push({width: verifyColumn[col.field].Width}) - } else { - _header.push(col.field) - _topRow[col.field] = col.label - - let _colwidth = Math.floor(col.Width / 6) - - if (!_colwidth || _colwidth < 5) { - _colwidth = 5 - } - - colwidth.push({width: _colwidth}) - } - }) - - if (btn.verify && btn.verify.columns && btn.verify.columns.length > 0) { - btn.verify.columns.forEach(col => { - if (hidecolumns.includes(col.Column)) return - if (!data[0].hasOwnProperty(col.Column)) return - if (_topRow[col.Column]) return - - _header.push(col.Column) - _topRow[col.Column] = col.Text - - colwidth.push({width: col.Width}) - }) - } - - Object.keys(data[0]).forEach(key => { - if (hidecolumns.includes(key)) return - if (_topRow[key]) return - - _header.push(key) - _topRow[key] = key - - colwidth.push({width: 12}) + colwidth.push({width: col.Width}) }) let table = [] -- Gitblit v1.8.0