From 2bccb9ec7bdefe23292a22bc153463cfa1479a49 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 21 六月 2024 16:25:42 +0800 Subject: [PATCH] 2024-06-21 --- src/tabviews/zshare/actionList/excelInbutton/index.jsx | 180 +++++++++++++++++++++++++++-------------------------------- 1 files changed, 82 insertions(+), 98 deletions(-) diff --git a/src/tabviews/zshare/actionList/excelInbutton/index.jsx b/src/tabviews/zshare/actionList/excelInbutton/index.jsx index df4b7d4..1be21b1 100644 --- a/src/tabviews/zshare/actionList/excelInbutton/index.jsx +++ b/src/tabviews/zshare/actionList/excelInbutton/index.jsx @@ -29,6 +29,7 @@ disabled: false, hidden: false, primaryId: '', + dict: window.GLOB.dict } UNSAFE_componentWillMount () { @@ -106,57 +107,45 @@ /** * @description 瑙﹀彂鎸夐挳鎿嶄綔 */ - actionTrigger = (triggerId, record, type) => { - const { setting, BID, btn, selectedData } = this.props - const { loading, disabled } = this.state + actionTrigger = (triggerId, record, type, lid) => { + const { setting, BID, btn, selectedData, LID } = this.props + const { loading, disabled, dict } = this.state if (loading || disabled) return if (triggerId && btn.uuid !== triggerId) return + if (type === 'linkbtn' && !btn.$toolbtn && LID !== lid) return + + let data = record || selectedData || [] if (setting.supModule && !BID) { notification.warning({ top: 92, - message: '闇�瑕佷笂绾т富閿�硷紒', + message: dict['sup_key_req'] || '闇�瑕佷笂绾т富閿�硷紒', duration: 5 }) - return - } else if (type === 'linkbtn' && !btn.$toolbtn && !is(fromJS(selectedData || []), fromJS(record))) { - return - } - - let data = record || selectedData || [] - - if (btn.Ot === 'requiredSgl' && data.length !== 1) { + } else if (btn.Ot === 'requiredSgl' && data.length !== 1) { // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁 notification.warning({ top: 92, - message: '璇烽�夋嫨鍗曡鏁版嵁锛�', + message: dict['select_single_row'] || '璇烽�夋嫨鍗曡鏁版嵁锛�', duration: 5 }) - return - } else if (!btn.verify || !btn.verify.sheet || !btn.verify.columns || btn.verify.columns.length === 0) { - notification.warning({ - top: 92, - message: 'excel瀵煎叆楠岃瘉淇℃伅鏈缃紒', - duration: 5 + } else { + let primaryId = '' // 瀵煎叆鏃惰Id + if (btn.Ot === 'requiredSgl' && setting.primaryKey) { + primaryId = data[0][setting.primaryKey] || '' + } + + this.setState({ + selines: data, + primaryId: primaryId + }, () => { + this.refs.excelIn.exceltrigger() }) - return - } - - let primaryId = '' // 瀵煎叆鏃惰Id - if (btn.Ot === 'requiredSgl' && setting.primaryKey) { - primaryId = data[0][setting.primaryKey] || '' - } - - this.setState({ - selines: data, - primaryId: primaryId - }, () => { - this.refs.excelIn.exceltrigger() - }) - - if (window.GLOB.systemType === 'production') { - MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: '瀵煎叆Excel'}) + + if (window.GLOB.systemType === 'production') { + MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: '瀵煎叆Excel'}) + } } } @@ -170,16 +159,18 @@ */ execSuccess = (res = {}) => { const { btn } = this.props + const { dict } = this.state if (res.ErrCode === 'S' || !res.ErrCode) { // 鎵ц鎴愬姛 notification.success({ top: 92, - message: res.message || '鎵ц鎴愬姛锛�', + message: res.message || dict['exc_success'] || '鎵ц鎴愬姛锛�', duration: btn.verify && btn.verify.stime ? btn.verify.stime : 2 }) } else if (res.ErrCode === 'Y') { // 鎵ц鎴愬姛 Modal.success({ - title: res.message || '鎵ц鎴愬姛锛�' + title: res.message || dict['exc_success'] || '鎵ц鎴愬姛锛�', + okText: dict['got_it'] || '鐭ラ亾浜�', }) } else if (res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず @@ -232,6 +223,7 @@ */ execError = (res = {}) => { const { btn } = this.props + const { dict } = this.state if (!['LoginError', 'C', '-2', 'E', 'N', 'F', 'NM'].includes(res.ErrCode)) { res.ErrCode = 'E' @@ -239,23 +231,24 @@ if (res.ErrCode === 'E') { Modal.error({ - title: res.message || '鎵ц澶辫触锛�', + title: res.message || dict['exc_fail'] || '鎵ц澶辫触锛�', + okText: dict['got_it'] || '鐭ラ亾浜�' }) } else if (res.ErrCode === 'N') { notification.error({ top: 92, - message: res.message || '鎵ц澶辫触锛�', + message: res.message || dict['exc_fail'] || '鎵ц澶辫触锛�', 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 || '鎵ц澶辫触锛�', + message: res.message || dict['exc_fail'] || '鎵ц澶辫触锛�', duration: btn.verify && btn.verify.ftime ? btn.verify.ftime : 10 }) } else if (res.ErrCode === 'NM') { - message.error(res.message || '鎵ц澶辫触锛�') + message.error(res.message || dict['exc_fail'] || '鎵ц澶辫触锛�') } this.setState({ @@ -266,6 +259,24 @@ MKEmitter.emit('popclose') } else if (btn.execError !== 'never') { MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines) + + if (btn.syncComponentId) { + if (btn.syncComponentId === 'multiComponent') { + btn.syncComponentIds.forEach((id, i) => { + setTimeout(() => { + if (/\$focus/.test(id)) { + MKEmitter.emit('reloadData', id.split('$')[0], id.split('$')[1]) + } else { + MKEmitter.emit('reloadData', id) + } + }, 20 * i) + }) + } else if (/\$focus/.test(btn.syncComponentId)) { + MKEmitter.emit('reloadData', btn.syncComponentId.split('$')[0], btn.syncComponentId.split('$')[1]) + } else { + MKEmitter.emit('reloadData', btn.syncComponentId) + } + } } if (btn.execError === 'popclose' && btn.$tabId) { // 鏍囩鍏抽棴鍒锋柊 @@ -276,43 +287,21 @@ /** * @description Excel 瀵煎叆 */ - getexceldata = (data, errors, sheetName, errDetail) => { + getexceldata = (data, error) => { const { btn, BID } = this.props - if (errors) { - if (errors === 'notexit') { - notification.warning({ - top: 92, - message: '宸ヤ綔琛ㄣ��' + sheetName + '銆嬩笉瀛樺湪锛�', - duration: 5 - }) - } else if (errors === 'empty') { - notification.warning({ - top: 92, - message: '宸ヤ綔琛ㄣ��' + sheetName + '銆嬩负绌猴紒', - duration: 5 - }) - } else if (errors === 'headerError') { - notification.warning({ - top: 92, - message: `宸ヤ綔琛ㄣ��${sheetName}銆嬭〃澶撮敊璇紝${errDetail}`, - duration: 5 - }) - } + if (error) { + notification.warning({ + top: 92, + message: error, + duration: 5 + }) this.setState({ loading: false }) return } - - if (!data || data.length === 0) { - notification.warning({ - top: 92, - message: '鏈幏鍙栧埌宸ヤ綔琛ㄣ��' + sheetName + '銆嬫暟鎹紒', - duration: 5 - }) - this.setState({ loading: false }) - return - } else if (data.length * btn.verify.columns.length > 30000) { + + if (data.length * btn.verify.columns.length > 30000) { notification.warning({ top: 92, message: '褰撳墠瀵煎叆鏁版嵁閲忚繃澶э紝濡傞亣閿欒鎻愮ず锛岃鍒嗘壒瀵煎叆锛�', @@ -347,7 +336,7 @@ delete param.excel_in // param.excel_in_type = 'true' - param.exec_type = 'y' + param.exec_type = window.GLOB.execType || 'y' param.LText = result.sql param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') @@ -358,10 +347,14 @@ param.LText = param.LText.replace(/\$check@|@check\$/ig, '') } - param.LText = Utils.formatOptions(param.LText) + param.LText = Utils.formatOptions(param.LText, param.exec_type) param.secretkey = Utils.encrypt('', param.timestamp) if (window.GLOB.mkHS) { // 浜戠楠岃瘉 param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) + } + + if (btn.database === 'sso' && window.GLOB.mainSystemApi) { + param.rduri = window.GLOB.mainSystemApi } param.menuname = btn.logLabel @@ -372,7 +365,7 @@ if (unCheckParam) { unCheckParam.LText = unCheckParam.LText.replace(/\$check@/ig, '/*').replace(/@check\$/ig, '*/') - unCheckParam.LText = Utils.formatOptions(unCheckParam.LText) + unCheckParam.LText = Utils.formatOptions(unCheckParam.LText, unCheckParam.exec_type) unCheckParam.secretkey = Utils.encrypt('', unCheckParam.timestamp) unCheckParam.menuname = btn.logLabel @@ -386,8 +379,10 @@ } else if (res.ErrCode === 'C') { const _this = this confirm({ - title: '璇风‘璁�', + title: window.GLOB.dict['exec_sure'] || '璇风‘璁�', content: res.message, + okText: window.GLOB.dict['ok'] || '纭畾', + cancelText: window.GLOB.dict['cancel'] || '鍙栨秷', onOk() { return new Promise(resolve => { Api.genericInterface(unCheckParam).then(result => { @@ -429,6 +424,9 @@ if (btn.recordUser === 'true') { param.username = sessionStorage.getItem('User_Name') || '' param.fullname = sessionStorage.getItem('Full_Name') || '' + } + if (btn.dataM === 'true') { + param.dataM = sessionStorage.getItem('dataM') === 'true' ? 'Y' : '' } Api.genericInterface(param).then((res) => { @@ -556,38 +554,24 @@ if (hidden) return null let label = '' - let icon = '' - let type = 'link' - let className = '' - if (btn.show === 'button') { - label = btn.label - icon = btn.icon || '' - } else if (btn.show === 'link') { - label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span> - icon = '' + if (btn.show === 'link') { + label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon} /> : ''}</span> } else if (btn.show === 'icon') { - icon = btn.icon || 'upload' - } else if (!btn.$toolbtn) { - icon = btn.icon || '' - label = btn.label - className = 'mk-btn mk-' + btn.class + label = !loading ? <MkIcon type={btn.icon} /> : null } else { - type = '' - icon = btn.icon || '' - label = btn.label - className = 'mk-btn mk-' + btn.class + label = <span>{!loading && btn.icon ? <MkIcon style={{marginRight: '8px'}} type={btn.icon} /> : ''}{btn.label}</span> } return <> <Button - type={type} + type="link" + id={'button' + btn.uuid} title={disabled ? (btn.reason || '') : (btn.show === 'icon' ? btn.label : '')} loading={loading} disabled={disabled} style={btn.style} - icon={icon} - className={className} + className={btn.hover || ''} onClick={(e) => {e.stopPropagation(); this.actionTrigger()}} >{label}</Button> <ExcelIn btn={btn} triggerExcelIn={() => this.setState({ loading: true })} returndata={this.getexceldata} ref="excelIn" /> -- Gitblit v1.8.0