From da64ab0923bf8817fc8599a6e37b953ce38f64c8 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 27 八月 2023 18:37:36 +0800 Subject: [PATCH] 2023-08-27 --- src/tabviews/zshare/actionList/excelInbutton/index.jsx | 111 ++++++++++++++++++++++++++++--------------------------- 1 files changed, 57 insertions(+), 54 deletions(-) diff --git a/src/tabviews/zshare/actionList/excelInbutton/index.jsx b/src/tabviews/zshare/actionList/excelInbutton/index.jsx index 2abe56f..2a9e4a7 100644 --- a/src/tabviews/zshare/actionList/excelInbutton/index.jsx +++ b/src/tabviews/zshare/actionList/excelInbutton/index.jsx @@ -6,10 +6,7 @@ import ExcelIn from './excelin' import Utils, { getExcelInSql } from '@/utils/utils.js' -import options from '@/store/options.js' import Api from '@/api' -import zhCN from '@/locales/zh-CN/main.js' -import enUS from '@/locales/en-US/main.js' import MKEmitter from '@/utils/events.js' import MkIcon from '@/components/mk-icon' // import './index.scss' @@ -27,7 +24,6 @@ } state = { - dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, loading: false, selines: null, disabled: false, @@ -134,7 +130,7 @@ // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁 notification.warning({ top: 92, - message: this.state.dict['main.action.confirm.selectSingleLine'], + message: '璇烽�夋嫨鍗曡鏁版嵁锛�', duration: 5 }) return @@ -172,20 +168,20 @@ * 4銆佹ā鎬佹鎵ц鎴愬姛鍚庢槸鍚﹀叧闂� * 5銆侀�氱煡涓诲垪琛ㄥ埛鏂� */ - execSuccess = (res) => { + execSuccess = (res = {}) => { const { btn } = this.props - if (res && (res.ErrCode === 'S' || !res.ErrCode)) { // 鎵ц鎴愬姛 + if (res.ErrCode === 'S' || !res.ErrCode) { // 鎵ц鎴愬姛 notification.success({ top: 92, - message: res.ErrMesg || this.state.dict['main.action.confirm.success'], + message: res.message || '鎵ц鎴愬姛锛�', duration: btn.verify && btn.verify.stime ? btn.verify.stime : 2 }) - } else if (res && res.ErrCode === 'Y') { // 鎵ц鎴愬姛 + } else if (res.ErrCode === 'Y') { // 鎵ц鎴愬姛 Modal.success({ - title: res.ErrMesg || this.state.dict['main.action.confirm.success'] + title: res.message || '鎵ц鎴愬姛锛�' }) - } else if (res && res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず + } else if (res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず } @@ -216,6 +212,10 @@ let node = document.getElementById('tab' + id) node && node.click() } + + if (btn.execSuccess === 'popclose' && btn.$tabId) { // 鏍囩鍏抽棴鍒锋柊 + MKEmitter.emit('refreshPopButton', btn.$tabId) + } } /** @@ -224,28 +224,32 @@ * 2銆乪xcel瀵煎嚭锛屽け璐ュ悗鍙栨秷瀵煎嚭鎸夐挳鍔犺浇涓姸鎬� * 3銆侀�氱煡涓诲垪琛ㄥ埛鏂� */ - execError = (res) => { + execError = (res = {}) => { const { btn } = this.props + + if (!['LoginError', 'C', '-2', 'E', 'N', 'F', 'NM'].includes(res.ErrCode)) { + res.ErrCode = 'E' + } if (res.ErrCode === 'E') { Modal.error({ - title: res.message || res.ErrMesg, + title: res.message || '鎵ц澶辫触锛�', }) } else if (res.ErrCode === 'N') { notification.error({ top: 92, - message: res.message || res.ErrMesg, + message: res.message || '鎵ц澶辫触锛�', duration: btn.verify && btn.verify.ntime ? btn.verify.ntime : 10 }) } else if (res.ErrCode === 'F') { notification.error({ className: 'notification-custom-error', top: 92, - message: res.message || res.ErrMesg, + message: res.message || '鎵ц澶辫触锛�', duration: btn.verify && btn.verify.ftime ? btn.verify.ftime : 10 }) } else if (res.ErrCode === 'NM') { - message.error(res.message || res.ErrMesg) + message.error(res.message || '鎵ц澶辫触锛�') } this.setState({ @@ -257,13 +261,17 @@ } else if (btn.execError !== 'never') { MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines) } + + if (btn.execError === 'popclose' && btn.$tabId) { // 鏍囩鍏抽棴鍒锋柊 + MKEmitter.emit('refreshPopButton', btn.$tabId) + } } /** * @description Excel 瀵煎叆 */ getexceldata = (data, errors, sheetName, errDetail) => { - const { btn } = this.props + const { btn, BID } = this.props if (errors) { if (errors === 'notexit') { @@ -306,7 +314,7 @@ }) } - let result = getExcelInSql(btn, data, (this.props.BID || ''), this.state.primaryId) + let result = getExcelInSql(btn, data, (BID || ''), this.state.primaryId) if (result.errors) { notification.warning({ @@ -323,40 +331,29 @@ excel_in: result.lines } - if (this.props.BID) { - param.BID = this.props.BID + if (BID) { + param.BID = BID } if (btn.intertype === 'system') { // 绯荤粺瀛樺偍杩囩▼ param.func = 'sPC_TableData_InUpDe' - - if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 - result.sql = result.sql.replace(/\$@/ig, '/*') - result.sql = result.sql.replace(/@\$/ig, '*/') - result.bottom = result.bottom.replace(/\$@/ig, '/*') - result.bottom = result.bottom.replace(/@\$/ig, '*/') - } else { - result.sql = result.sql.replace(/@\$|\$@/ig, '') - result.bottom = result.bottom.replace(/@\$|\$@/ig, '') - } - - param.excel_in_type = 'true' - param.LText1 = Utils.formatOptions(result.insert) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.LText2 = result.bottom + + delete param.excel_in + + // param.excel_in_type = 'true' + param.exec_type = 'y' param.LText = result.sql + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') let unCheckParam = null - if (/\$check@|@check\$/ig.test(param.LText2) || /\$check@|@check\$/ig.test(param.LText)) { + if (/\$check@|@check\$/ig.test(param.LText)) { unCheckParam = fromJS(param).toJS() param.LText = param.LText.replace(/\$check@|@check\$/ig, '') - param.LText2 = param.LText2.replace(/\$check@|@check\$/ig, '') } - param.LText2 = Utils.formatOptions(param.LText2) param.LText = Utils.formatOptions(param.LText) - param.secretkey = Utils.encrypt(param.LText, param.timestamp) + param.secretkey = Utils.encrypt('', param.timestamp) if (window.GLOB.mkHS && param.timestamp) { // 浜戠楠岃瘉 param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) } @@ -370,11 +367,7 @@ if (unCheckParam) { unCheckParam.LText = unCheckParam.LText.replace(/\$check@/ig, '/*').replace(/@check\$/ig, '*/') unCheckParam.LText = Utils.formatOptions(unCheckParam.LText) - unCheckParam.LText2 = unCheckParam.LText2.replace(/\$check@/ig, '/*').replace(/@check\$/ig, '*/') - unCheckParam.LText2 = Utils.formatOptions(unCheckParam.LText2) - - unCheckParam.secretkey = Utils.encrypt(unCheckParam.LText, unCheckParam.timestamp) - + unCheckParam.secretkey = Utils.encrypt('', unCheckParam.timestamp) unCheckParam.menuname = btn.logLabel if (window.GLOB.probation) { @@ -387,7 +380,7 @@ } else if (res.ErrCode === 'C') { const _this = this confirm({ - title: '缁х画鎵ц锛�', + title: '璇风‘璁�', content: res.message, onOk() { return new Promise(resolve => { @@ -408,7 +401,8 @@ } else { this.execError(res) } - }, () => { + }, (error) => { + if (error && error.ErrCode === 'LoginError') return this.execError({}) }) } else { @@ -418,12 +412,18 @@ } else { this.execError(res) } - }, () => { + }, (error) => { + if (error && error.ErrCode === 'LoginError') return this.execError({}) }) } } else if (btn.intertype === 'inner' && btn.innerFunc) { // 鑷畾涔夊瓨鍌ㄨ繃绋� param.func = btn.innerFunc + + if (btn.recordUser === 'true') { + param.username = sessionStorage.getItem('User_Name') || '' + param.fullname = sessionStorage.getItem('Full_Name') || '' + } Api.genericInterface(param).then((res) => { if (res.status) { @@ -431,7 +431,8 @@ } else { this.execError(res) } - }, () => { + }, (error) => { + if (error && error.ErrCode === 'LoginError') return this.execError({}) }) } else if (btn.intertype === 'outer') { // 澶栭儴鎺ュ彛 @@ -460,7 +461,8 @@ this.execError(res) resolve(false) } - }, () => { + }, (error) => { + if (error && error.ErrCode === 'LoginError') return this.execError({}) }) } else { @@ -472,8 +474,8 @@ _outParam = fromJS(res).toJS() if (window.GLOB.mkHS) { - if (btn.sysInterface === 'true' && options.cloudServiceApi) { - param.rduri = options.cloudServiceApi + if (btn.sysInterface === 'true' && window.GLOB.cloudServiceApi) { + param.rduri = window.GLOB.cloudServiceApi param.userid = sessionStorage.getItem('CloudUserID') || '' param.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' } else if (btn.sysInterface !== 'true') { @@ -513,7 +515,8 @@ } if (window.GLOB.mkHS && res.func === 's_sDataDictb_excelIn') { // s_sDataDictb_excelIn 浜戠楠岃瘉 - param.LText = Utils.formatOptions(result.sql) + let sql = `Declare @UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@tbid Nvarchar(512)` + param.LText = Utils.formatOptions(sql) param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt(param.LText, param.timestamp) param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) @@ -521,7 +524,7 @@ return Api.genericInterface(res) }).then(response => { - if (!response) return + if (!response || response.ErrCode === 'LoginError') return // 鍥炶皟璇锋眰 if (ver_token && response.ErrMesg === 'token_error') { this.execError(response) @@ -542,7 +545,7 @@ } } }).then(res => { - if (!res) return + if (!res || res.ErrCode === 'LoginError') return if (res.status) { this.execSuccess(res) -- Gitblit v1.8.0