From b69b5f6329ca5f87932436b7a6c1ddfc3377e10f Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 16 五月 2024 10:56:41 +0800 Subject: [PATCH] 2024-05-16 --- src/tabviews/zshare/actionList/excelInbutton/index.jsx | 225 ++++++++++++++++++++++--------------------------------- 1 files changed, 90 insertions(+), 135 deletions(-) diff --git a/src/tabviews/zshare/actionList/excelInbutton/index.jsx b/src/tabviews/zshare/actionList/excelInbutton/index.jsx index 0104e10..ab1cc80 100644 --- a/src/tabviews/zshare/actionList/excelInbutton/index.jsx +++ b/src/tabviews/zshare/actionList/excelInbutton/index.jsx @@ -106,12 +106,15 @@ /** * @description 瑙﹀彂鎸夐挳鎿嶄綔 */ - actionTrigger = (triggerId, record, type) => { - const { setting, BID, btn, selectedData } = this.props + actionTrigger = (triggerId, record, type, lid) => { + const { setting, BID, btn, selectedData, LID } = this.props const { loading, disabled } = 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({ @@ -119,44 +122,35 @@ message: '闇�瑕佷笂绾т富閿�硷紒', 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: '璇烽�夋嫨鍗曡鏁版嵁锛�', 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 }) - 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'}) + } 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() + }) + + if (window.GLOB.systemType === 'production') { + MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: '瀵煎叆Excel'}) + } } } @@ -199,9 +193,15 @@ if (btn.syncComponentId === 'multiComponent') { btn.syncComponentIds.forEach((id, i) => { setTimeout(() => { - MKEmitter.emit('reloadData', id) + 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) } @@ -270,43 +270,21 @@ /** * @description Excel 瀵煎叆 */ - getexceldata = (data, errors, sheetName, errDetail) => { - const { btn } = this.props + 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: '褰撳墠瀵煎叆鏁版嵁閲忚繃澶э紝濡傞亣閿欒鎻愮ず锛岃鍒嗘壒瀵煎叆锛�', @@ -314,7 +292,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({ @@ -331,31 +309,30 @@ 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' - 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 = window.GLOB.execType || '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) - if (window.GLOB.mkHS && param.timestamp) { // 浜戠楠岃瘉 + 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) } @@ -367,12 +344,8 @@ 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.LText = Utils.formatOptions(unCheckParam.LText, unCheckParam.exec_type) + unCheckParam.secretkey = Utils.encrypt('', unCheckParam.timestamp) unCheckParam.menuname = btn.logLabel if (window.GLOB.probation) { @@ -425,6 +398,14 @@ } 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') || '' + } + if (btn.dataM === 'true') { + param.dataM = sessionStorage.getItem('dataM') === 'true' ? 'Y' : '' + } + Api.genericInterface(param).then((res) => { if (res.status) { this.execSuccess(res) @@ -473,40 +454,26 @@ // 澶栭儴璇锋眰 _outParam = fromJS(res).toJS() - if (window.GLOB.mkHS) { - 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') { - if (window.GLOB.systemType === 'production' && btn.proInterface) { - param.rduri = btn.proInterface - } else { - param.rduri = btn.interface - } + if (btn.sysInterface === 'true') { + if (window.GLOB.mainSystemApi) { + param.rduri = window.GLOB.mainSystemApi } - } else { - if (btn.sysInterface === 'true') { - if (window.GLOB.mainSystemApi) { - param.rduri = window.GLOB.mainSystemApi - } - } else if (btn.sysInterface === 'external') { - if (window.GLOB.systemType === 'production') { - param.$token = btn.exProInterface || '' - } else { - param.$token = btn.exInterface || '' - } - ver_token = true + } else if (btn.sysInterface === 'external') { + if (window.GLOB.systemType === 'production') { + param.$token = btn.exProInterface || '' } else { - if (window.GLOB.systemType === 'production' && btn.proInterface) { - param.rduri = btn.proInterface - } else { - param.rduri = btn.interface - } - let host = window.GLOB.baseurl.replace(/http(s):\/\//, '') - if (param.rduri.indexOf(host) === -1 && /\/dostars/.test(param.rduri)) { - param.$login = true - } + param.$token = btn.exInterface || '' + } + ver_token = true + } else { + if (window.GLOB.systemType === 'production' && btn.proInterface) { + param.rduri = btn.proInterface + } else { + param.rduri = btn.interface + } + let host = window.GLOB.baseurl.replace(/http(s):\/\//, '') + if (param.rduri.indexOf(host) === -1 && /\/dostars/.test(param.rduri)) { + param.$login = true } } @@ -515,7 +482,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) @@ -525,7 +493,8 @@ }).then(response => { if (!response || response.ErrCode === 'LoginError') return // 鍥炶皟璇锋眰 - if (ver_token && response.ErrMesg === 'token_error') { + if (ver_token && response.ErrCode === 'token_error') { + response.ErrCode = 'E' this.execError(response) } else if (btn.callbackFunc ) { // 瀛樺湪鍥炶皟鍑芥暟鏃讹紝璋冪敤 @@ -562,38 +531,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