| | |
| | | if (setting.supModule && !BID) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: dict['sup_key_req'] || '需要上级主键值!', |
| | | message: setting.supModTip || dict['sup_key_req'] || '需要上级主键值!', |
| | | duration: 5 |
| | | }) |
| | | } else { |
| | |
| | | * @description Excel 生成 |
| | | */ |
| | | exportExcel = (data = [], ErrCode, msg, search) => { |
| | | const { btn } = this.props |
| | | const { btn, BID } = this.props |
| | | const { dict } = this.state |
| | | |
| | | let imgCol = false |
| | |
| | | }) |
| | | |
| | | return |
| | | } |
| | | } |
| | | |
| | | let excelName = btn.verify.excelName || '' |
| | | if (/@.*@/.test(excelName)) { |
| | | excelName = excelName.replace(/@bid@/ig, BID) |
| | | if (data[0]) { |
| | | Object.keys(data[0]).forEach(key => { |
| | | let reg = new RegExp('@' + key + '@', 'ig') |
| | | excelName = excelName.replace(reg, data[0][key]) |
| | | }) |
| | | } |
| | | } |
| | | |
| | |
| | | table.push(_row) |
| | | }) |
| | | |
| | | this.table2excel(column, table) |
| | | this.table2excel(column, table, btn, excelName) |
| | | |
| | | this.execSuccess({ErrCode: ErrCode || 'S', message: msg || dict['exc_success'] || '导出成功!'}) |
| | | } else { |
| | |
| | | const wb = XLSX.utils.book_new() |
| | | XLSX.utils.book_append_sheet(wb, ws, btn.verify.sheet || 'Sheet1') |
| | | |
| | | XLSX.writeFile(wb, `${btn.verify.excelName || btn.$menuName || ''}${moment().format('YYYYMMDDHHmmss')}.xlsx`) |
| | | XLSX.writeFile(wb, `${excelName || btn.$menuName || ''}${moment().format('YYYYMMDDHHmmss')}.xlsx`) |
| | | |
| | | this.execSuccess({ErrCode: ErrCode || 'S', message: msg || dict['exc_success'] || '导出成功!'}) |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | table2excel = (column, data) => { |
| | | table2excel = (column, data, btn, excelName) => { |
| | | let thead = column.reduce((result, item) => { |
| | | return result + `<th>${item.title}</th>` |
| | | }, '') |
| | |
| | | // let url = 'data:application/vnd.ms-excel;base64,' + window.btoa(unescape(encodeURIComponent(html))) |
| | | let link = document.createElement('a') |
| | | link.href = url |
| | | link.download = `${this.props.btn.$menuName || ''}${moment().format('YYYYMMDDHHmmss')}.xls` |
| | | link.download = `${excelName || btn.$menuName || ''}${moment().format('YYYYMMDDHHmmss')}.xls` |
| | | document.body.appendChild(link) |
| | | link.click() |
| | | document.body.removeChild(link) |
| | |
| | | _setting.dataresource = '' |
| | | } |
| | | |
| | | if (/\s/.test(_setting.dataresource)) { |
| | | _setting.dataresource = '(' + _setting.dataresource + ') tb' |
| | | } |
| | | |
| | | let _customScript = '' |
| | | let _tailScript = '' |
| | | btn.verify.scripts && btn.verify.scripts.forEach(script => { |
| | |
| | | _setting.tailScript = _tailScript // 后置自定义脚本 |
| | | |
| | | _setting.laypage = pagination |
| | | _setting.custompage = /@pageSize@|@orderBy@|@mk_total/i.test(_setting.dataresource + _setting.customScript) |
| | | _setting.custompage = false |
| | | |
| | | if (/order\s+by\s+sort_id\s*$/i.test(_setting.dataresource)) { |
| | | _setting.custompage = true |
| | | } else if (/@pageSize@|@orderBy@|@mk_total/i.test(_setting.dataresource + _setting.customScript)) { |
| | | _setting.custompage = true |
| | | } |
| | | |
| | | if (/\s/.test(_setting.dataresource)) { |
| | | _setting.dataresource = '(' + _setting.dataresource + ') tb' |
| | | } |
| | | |
| | | _setting.queryType = btn.verify.queryType |
| | | _setting.$name = btn.logLabel |
| | |
| | | } |
| | | |
| | | if (tabId && btn.$MenuID === tabId) { // 刷新当前菜单时,停止其他操作 |
| | | MKEmitter.emit('reloadMenuView', tabId) |
| | | MKEmitter.emit('reloadMenuView', tabId, btn.urlPar === 'true') |
| | | return |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | if (tabId) { |
| | | MKEmitter.emit('reloadMenuView', tabId) |
| | | MKEmitter.emit('reloadMenuView', tabId, btn.urlPar === 'true') |
| | | } |
| | | |
| | | if (btn.switchTab && btn.switchTab.length > 0) { |
| | |
| | | tabId = btn.refreshTab[btn.refreshTab.length - 1] |
| | | } |
| | | if (tabId && btn.$MenuID === tabId) { // 刷新当前菜单时,停止其他操作 |
| | | MKEmitter.emit('reloadMenuView', tabId) |
| | | MKEmitter.emit('reloadMenuView', tabId, btn.urlPar === 'true') |
| | | return |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | if (tabId) { |
| | | MKEmitter.emit('reloadMenuView', tabId) |
| | | MKEmitter.emit('reloadMenuView', tabId, btn.urlPar === 'true') |
| | | } |
| | | } |
| | | |