From 0c9972b68aaee5ce0d536bb418ebcd2887012a28 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 29 六月 2020 14:35:47 +0800 Subject: [PATCH] 2020-06-29 --- src/tabviews/zshare/actionList/exceloutbutton/index.jsx | 65 +++++++++++++++++++++++++++++++- 1 files changed, 62 insertions(+), 3 deletions(-) diff --git a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx index c6cf2a8..1129358 100644 --- a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx +++ b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx @@ -31,6 +31,7 @@ state = { dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, excelName: '', + search: '', // 鎼滅储鏉′欢 loading: false } @@ -131,6 +132,8 @@ 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) @@ -312,8 +315,6 @@ } 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 @@ -456,7 +457,11 @@ 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鐢熸垚澶辫触锛�'}) } @@ -466,6 +471,60 @@ } /** + * @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) => { -- Gitblit v1.8.0