| | |
| | | state = { |
| | | dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | excelName: '', |
| | | search: '', // 搜索条件 |
| | | loading: false |
| | | } |
| | | |
| | |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (btn.intertype === 'inner' && !btn.innerFunc && btn.verify && btn.verify.enable === 'true') { |
| | | this.setState({search: fromJS(viewParam.search).toJS()}) |
| | | } |
| | | |
| | | this.updateStatus('start', name) |
| | |
| | | } |
| | | |
| | | param = this.getExcelDefaultParam(viewParam.arr_field, viewParam.orderBy, viewParam.search, true, pageIndex, pageSize) |
| | | |
| | | |
| | | } else if (btn.intertype === 'inner' && btn.innerFunc) { // 使用内部函数 |
| | | param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search, true, pageIndex, pageSize) |
| | | param.func = btn.innerFunc |
| | |
| | | |
| | | XLSX.writeFile(wb, this.state.excelName) |
| | | |
| | | this.execSuccess({ErrCode: 'S', ErrMesg: '导出成功!'}) |
| | | if (btn.verify && btn.verify.enable === 'true' && btn.verify.script) { |
| | | this.execCustomScript() |
| | | } else { |
| | | this.execSuccess({ErrCode: 'S', ErrMesg: '导出成功!'}) |
| | | } |
| | | } catch { |
| | | this.execError({ErrCode: 'N', message: 'Excel生成失败!'}) |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 执行自定义脚本 |
| | | */ |
| | | execCustomScript = () => { |
| | | const { btn } = this.props |
| | | const { search } = this.state |
| | | let script = btn.verify.script |
| | | |
| | | if (this.props.dataManager) { // 数据权限 |
| | | script = script.replace(/\$@/ig, '/*') |
| | | script = script.replace(/@\$/ig, '*/') |
| | | } else { |
| | | script = script.replace(/@\$|\$@/ig, '') |
| | | } |
| | | |
| | | let allSearch = Utils.getAllSearchOptions(search) |
| | | let regoptions = allSearch.map(item => { |
| | | return { |
| | | reg: new RegExp('@' + item.key + '@', 'ig'), |
| | | value: `'${item.value}'` |
| | | } |
| | | }) |
| | | |
| | | regoptions.forEach(item => { |
| | | script = script.replace(item.reg, item.value) |
| | | }) |
| | | |
| | | let param = { |
| | | func: 'sPC_TableData_InUpDe' |
| | | } |
| | | |
| | | if (this.props.BID) { |
| | | param.BID = this.props.BID |
| | | } |
| | | |
| | | param.LText = Utils.formatOptions(script) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | |
| | | if (this.props.menuType === 'HS') { // 函数 sPC_TableData_InUpDe 云端验证 |
| | | param.open_key = Utils.encrypt(param.secretkey, param.timestamp, true) |
| | | } |
| | | |
| | | Api.genericInterface(param).then((res) => { |
| | | if (res.status) { |
| | | this.execSuccess({ErrCode: 'S', ErrMesg: '导出成功!'}) |
| | | } else { |
| | | this.execError(res) |
| | | } |
| | | }, () => { |
| | | this.updateStatus('over') |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 获取用户自定义存储过程传参 |
| | | */ |
| | | getExcelCustomParam = (orderBy, search, pagination = false, pageIndex = 1, pageSize = 100) => { |