From 4590502dd26419fd190045d84fbf11eccb6093f7 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 07 五月 2022 15:53:12 +0800 Subject: [PATCH] 2022-05-07 --- src/tabviews/zshare/actionList/exceloutbutton/index.jsx | 119 ++++++++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 85 insertions(+), 34 deletions(-) diff --git a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx index cbc490b..3648ac6 100644 --- a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx +++ b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx @@ -138,24 +138,17 @@ return } - if (btn.intertype === 'system' && setting.interType !== 'system') { - notification.warning({ - top: 92, - message: '瀵煎嚭鎸夐挳閰嶇疆閿欒锛�', - duration: 5 - }) - return - } else if (btn.intertype === 'inner' && !btn.innerFunc) { - notification.warning({ - top: 92, - message: '瀵煎嚭鎸夐挳閰嶇疆閿欒锛�', - duration: 5 - }) - return - } else if (!btn.verify || !btn.verify.columns || btn.verify.columns.length === 0) { + if (!btn.verify || !btn.verify.columns || btn.verify.columns.length === 0) { notification.warning({ top: 92, message: '璇疯缃鍑哄垪锛�', + duration: 5 + }) + return + } else if (btn.intertype === 'system' && setting.interType !== 'system' && btn.verify.dataType !== 'custom') { + notification.warning({ + top: 92, + message: '瀵煎嚭鎸夐挳閰嶇疆閿欒锛�', duration: 5 }) return @@ -178,7 +171,7 @@ let name = `${viewParam.menuName}${moment().format('YYYYMMDDHHmmss')}.xlsx` let pageSize = 1000 - if (btn.search === 'true' && viewParam.search && viewParam.search.length > 0) { + if (((btn.intertype === 'system' && btn.verify.dataType === 'custom' && btn.verify.useSearch === 'true') || btn.intertype !== 'system' || btn.verify.dataType !== 'custom') && btn.search === 'true' && viewParam.search && viewParam.search.length > 0) { let valid = false viewParam.search.forEach(item => { if (item.value || item.value === 0) { @@ -196,16 +189,34 @@ } } - if (btn.intertype === 'system' && !viewParam.arr_field) { // 浣跨敤绯荤粺鍑芥暟 - notification.warning({ - top: 92, - message: '鏈缃樉绀哄垪锛�', - duration: 5 - }) - return - } else if (btn.intertype === 'system' && btn.verify && btn.verify.enable === 'true') { + if (btn.intertype === 'system') { // 浣跨敤绯荤粺鍑芥暟 + if (btn.verify.dataType !== 'custom' && !viewParam.arr_field) { + notification.warning({ + top: 92, + message: '鎸夐挳闇�鑷畾涔夊鍑烘暟鎹紒', + duration: 5 + }) + return + } else if (btn.verify.dataType === 'custom') { + viewParam.arr_field = [] + btn.verify.columns.forEach(col => { + if (col.Column && col.Column !== '$Index') { + viewParam.arr_field.push(col.Column) + } + }) + viewParam.arr_field = viewParam.arr_field.join(',') + + viewParam.orderBy = btn.verify.order || viewParam.orderBy + } + } + if (btn.intertype === 'system' && btn.verify.enable === 'true') { this.setState({search: fromJS(viewParam.search).toJS()}) } + if (btn.intertype === 'system' && btn.verify.dataType === 'custom' && btn.verify.useSearch === 'false') { + viewParam.search = [] + } + + viewParam.orderBy = viewParam.orderBy || viewParam.arr_field.split(',')[0] this.updateStatus('start', name) @@ -718,6 +729,41 @@ getExcelDefaultParam = (arr_field, orderBy, search, pagination = false, pageIndex = 1, pageSize = 100) => { const { setting, btn } = this.props + let defaultSql = setting.execute || setting.default || 'true' + let customScript = setting.customScript || '' + let _dataresource = setting.dataresource || '' + let queryType = setting.queryType + let transaction = setting.transaction + + if (btn.verify.dataType === 'custom') { + defaultSql = btn.verify.defaultSql || 'true' + _dataresource = btn.verify.dataresource || '' + queryType = btn.verify.queryType + transaction = btn.verify.transaction + + if (/\s/.test(_dataresource)) { + _dataresource = '(' + _dataresource + ') tb' + } + customScript = '' + btn.verify.scripts && btn.verify.scripts.forEach(script => { + if (script.status !== 'false') { + customScript += ` + ${script.sql} + ` + } + }) + + if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 + _dataresource = _dataresource.replace(/\$@/ig, '/*') + _dataresource = _dataresource.replace(/@\$/ig, '*/') + customScript = customScript.replace(/\$@/ig, '/*') + customScript = customScript.replace(/@\$/ig, '*/') + } else { + _dataresource = _dataresource.replace(/@\$|\$@/ig, '') + customScript = customScript.replace(/@\$|\$@/ig, '') + } + } + let _search = Utils.joinMainSearchkey(search) _search = _search ? 'where ' + _search : '' @@ -726,8 +772,8 @@ func: 'sPC_Get_TableData', obj_name: 'data', arr_field: arr_field, - custom_script: setting.customScript, - default_sql: setting.default || 'true', + custom_script: customScript, + default_sql: defaultSql, menuname: btn.logLabel } @@ -751,11 +797,9 @@ userName = sessionStorage.getItem('CloudUserName') || '' fullName = sessionStorage.getItem('CloudFullName') || '' } - - let _dataresource = setting.dataresource let regoptions = null - if (setting.queryType === 'statistics' || param.custom_script) { + if (queryType === 'statistics' || param.custom_script) { let allSearch = Utils.getAllSearchOptions(search) regoptions = allSearch.map(item => { @@ -776,7 +820,7 @@ value: fullName }, { reg: new RegExp('@orderBy@', 'ig'), - value: orderBy + value: orderBy || '' }, { reg: new RegExp('@pageSize@', 'ig'), value: pageSize @@ -786,7 +830,7 @@ }) } - if (setting.queryType === 'statistics') { // 缁熻鏁版嵁婧愶紝鍐呭鏇挎崲 + if (queryType === 'statistics') { // 缁熻鏁版嵁婧愶紝鍐呭鏇挎崲 regoptions.forEach(item => { _dataresource = _dataresource.replace(item.reg, item.value) }) @@ -795,9 +839,9 @@ let LText = '' - if (setting.default !== 'false' && !pagination) { + if (defaultSql !== '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 ` - } else if (setting.default !== 'false') { + } else if (defaultSql !== '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 ` } @@ -822,6 +866,10 @@ insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ ` } + } else if (LText) { + LText = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(50),@mk_organization nvarchar(50),@login_city nvarchar(50) select @ErrorCode='',@retmsg ='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @login_city='${city}' + ${LText} + ` } // 娴嬭瘯绯荤粺鎵撳嵃鏌ヨ璇彞 @@ -840,7 +888,7 @@ param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) } - if (setting.transaction === 'true') { + if (transaction === 'true') { param.func = 'sPC_Get_TableData_try' } @@ -880,7 +928,10 @@ MKEmitter.emit('popclose') } else if (btn.execSuccess !== 'never') { MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, '', []) + } else { + btn.syncComponentId && MKEmitter.emit('reloadData', btn.syncComponentId) } + if (btn.switchTab && btn.switchTab.length > 0) { let id = btn.switchTab[btn.switchTab.length - 1] let node = document.getElementById('tab' + id) -- Gitblit v1.8.0