| | |
| | | class ExcelOutButton extends Component { |
| | | static propTpyes = { |
| | | BID: PropTypes.string, // 主表ID |
| | | BData: PropTypes.any, // 主表数据 |
| | | show: PropTypes.any, // 显示样式 |
| | | Tab: PropTypes.any, // 如果当前元素为标签时,tab为标签信息 |
| | | MenuID: PropTypes.string, // 菜单ID |
| | | btn: PropTypes.object, // 按钮 |
| | | columns: PropTypes.array, // 字段列 |
| | | setting: PropTypes.any, // 页面通用设置 |
| | | ContainerId: PropTypes.any, // tab页面ID,用于弹窗控制 |
| | | updateStatus: PropTypes.func, // 按钮状态更新 |
| | | getexceloutparam: PropTypes.func, // 获取表格中参数 |
| | | triggerBtn: PropTypes.any, |
| | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '导出按钮配置错误!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (!btn.verify || !btn.verify.columns || btn.verify.columns.length === 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请设置导出列!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | |
| | | delete res.message |
| | | delete res.status |
| | | |
| | | if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { |
| | | res.rduri = window.GLOB.mainSystemApi |
| | | } else if (btn.sysInterface !== 'true') { |
| | | res.rduri = btn.interface |
| | | if (this.props.menuType === 'HS') { |
| | | if (btn.sysInterface === 'true' && options.cloudServiceApi) { |
| | | res.rduri = options.cloudServiceApi |
| | | } else if (btn.sysInterface !== 'true') { |
| | | res.rduri = btn.interface |
| | | } |
| | | } else { |
| | | if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { |
| | | res.rduri = window.GLOB.mainSystemApi |
| | | } else if (btn.sysInterface !== 'true') { |
| | | res.rduri = btn.interface |
| | | } |
| | | } |
| | | |
| | | if (btn.outerFunc) { |
| | |
| | | |
| | | if (this.props.menuType === 'HS') { |
| | | if (btn.sysInterface === 'true' && options.cloudServiceApi) { |
| | | param.rduri = options.cloudServiceApi |
| | | res.rduri = options.cloudServiceApi |
| | | } else if (btn.sysInterface !== 'true') { |
| | | param.rduri = btn.interface |
| | | res.rduri = btn.interface |
| | | } |
| | | } else { |
| | | if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { |
| | | param.rduri = window.GLOB.mainSystemApi |
| | | res.rduri = window.GLOB.mainSystemApi |
| | | } else if (btn.sysInterface !== 'true') { |
| | | param.rduri = btn.interface |
| | | res.rduri = btn.interface |
| | | } |
| | | } |
| | | |
| | |
| | | * @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 = [] |
| | |
| | | param.BID = this.props.BID |
| | | } |
| | | |
| | | param.LText = Utils.formatOptions(script) |
| | | let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(script) |
| | | |
| | | param.LText2 = LText2 |
| | | param.LText1 = LText1 |
| | | param.LText = LText |
| | | |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | |
| | |
| | | ..._search |
| | | } |
| | | |
| | | // 数据管理权限 |
| | | if (this.props.dataManager) { |
| | | param.dataM = 'Y' |
| | | } |
| | | |
| | | if (this.props.BID) { |
| | | param.BID = this.props.BID |
| | | } |
| | |
| | | obj_name: 'data', |
| | | arr_field: arr_field, |
| | | custom_script: setting.customScript || '', |
| | | default_sql: setting.default || 'true', |
| | | dataM: this.props.dataManager ? 'Y' : '' |
| | | default_sql: setting.default || 'true' |
| | | } |
| | | |
| | | // 数据管理权限 |
| | | if (this.props.dataManager) { |
| | | param.dataM = 'Y' |
| | | } |
| | | |
| | | if (this.props.BID) { |
| | |
| | | let LText = '' |
| | | |
| | | if (setting.default !== 'false' && !pagination) { |
| | | LText = `select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows` |
| | | LText = ` select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows ` |
| | | } else if (setting.default !== 'false') { |
| | | LText = `select top ${pageSize} ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${_dataresource} ${_search}) tmptable where rows > ${pageSize * (pageIndex - 1)} order by tmptable.rows` |
| | | LText = ` select top ${pageSize} ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${_dataresource} ${_search}) tmptable where rows > ${pageSize * (pageIndex - 1)} order by tmptable.rows ` |
| | | } |
| | | |
| | | if (param.custom_script) { |
| | |
| | | LText += ` |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ |
| | | ` |
| | | } else { |
| | | param.custom_script += ` |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { btn } = this.props |
| | | const { btn, show } = this.props |
| | | const { loading } = this.state |
| | | |
| | | return ( |
| | | <div className="mk-btn-wrap"> |
| | | <Button |
| | | {!show ? <Button |
| | | className={'mk-btn mk-' + btn.class} |
| | | icon={btn.icon} |
| | | onClick={() => {this.actionTrigger()}} |
| | | loading={loading} |
| | | >{btn.label}</Button> |
| | | >{btn.label}</Button> : null} |
| | | {show === 'icon' ? <Button |
| | | className="export-icon" |
| | | icon="download" |
| | | onClick={() => {this.actionTrigger()}} |
| | | loading={loading} |
| | | title={btn.label} |
| | | ></Button> : null} |
| | | </div> |
| | | ) |
| | | } |