From 8e8f505f37ecc4e6945e7d0d6e9883e4e9352437 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 10 十一月 2022 23:59:47 +0800 Subject: [PATCH] 2022-11-10 --- src/tabviews/zshare/actionList/excelInbutton/index.jsx | 183 ++++++++++++++++++++++++++------------------- 1 files changed, 107 insertions(+), 76 deletions(-) diff --git a/src/tabviews/zshare/actionList/excelInbutton/index.jsx b/src/tabviews/zshare/actionList/excelInbutton/index.jsx index 36f0a62..97a19f4 100644 --- a/src/tabviews/zshare/actionList/excelInbutton/index.jsx +++ b/src/tabviews/zshare/actionList/excelInbutton/index.jsx @@ -1,7 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import moment from 'moment' -import {connect} from 'react-redux' import { is, fromJS } from 'immutable' import { Button, Modal, notification, message } from 'antd' @@ -17,13 +16,12 @@ class ExcelInButton extends Component { static propTpyes = { - show: PropTypes.any, // 鏄剧ず鏍峰紡 - position: PropTypes.any, // 鎸夐挳浣嶇疆锛屽伐鍏锋爮涓簍oolbar BID: PropTypes.string, // 涓昏〃ID + BData: PropTypes.any, // 涓昏〃鏁版嵁 selectedData: PropTypes.any, // 瀛愯〃涓�夋嫨鏁版嵁 - Tab: PropTypes.any, // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭� btn: PropTypes.object, // 鎸夐挳 setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 + disabled: PropTypes.any, // 琛屾寜閽鐢� } state = { @@ -36,17 +34,32 @@ } UNSAFE_componentWillMount () { - const { btn, selectedData } = this.props + const { btn, selectedData, BData } = this.props let disabled = false if (btn.controlField && selectedData && selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒� selectedData.forEach(item => { - let s = item[btn.controlField] + '' + let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : '' if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { disabled = true } }) - this.setState({disabled, hidden: disabled && btn.control === 'hidden'}) + this.setState({hidden: disabled && btn.control === 'hidden'}) + } else if (btn.control === 'parent') { + if (!BData || !BData.hasOwnProperty(btn.controlField)) { + this.setState({hidden: true}) + } else { + let s = BData[btn.controlField] + '' + if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { + this.setState({hidden: true}) + } else { + this.setState({hidden: false}) + } + } + } + + if (this.props.disabled || disabled) { + this.setState({disabled: true}) } } @@ -59,20 +72,36 @@ } UNSAFE_componentWillReceiveProps (nextProps) { - const { btn, selectedData } = this.props + const { btn, selectedData, BData } = this.props + let disabled = false if (btn.controlField && !is(fromJS(nextProps.selectedData || []), fromJS(selectedData || []))) { - let disabled = false - if (nextProps.selectedData && nextProps.selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒� nextProps.selectedData.forEach(item => { - let s = item[btn.controlField] + '' + let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : '' if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { disabled = true } }) } this.setState({disabled, hidden: disabled && btn.control === 'hidden'}) + } else if (btn.control === 'parent' && !is(fromJS(nextProps.BData || {}), fromJS(BData || {}))) { + if (!nextProps.BData || !nextProps.BData.hasOwnProperty(btn.controlField)) { + this.setState({hidden: true}) + } else { + let s = nextProps.BData[btn.controlField] + '' + if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { + this.setState({hidden: true}) + } else { + this.setState({hidden: false}) + } + } + } + + if (nextProps.disabled || disabled) { + this.setState({disabled: true}) + } else { + this.setState({disabled: false}) } } @@ -87,22 +116,21 @@ * @description 瑙﹀彂鎸夐挳鎿嶄綔 */ actionTrigger = (triggerId, record, type) => { - const { setting, Tab, BID, btn, selectedData } = this.props + const { setting, BID, btn, selectedData } = this.props const { loading, disabled } = this.state - if ((triggerId && btn.uuid !== triggerId) || loading || disabled) return + if (loading || disabled) return + if (triggerId && btn.uuid !== triggerId) return - if (((Tab && Tab.supMenu) || setting.supModule) && !BID) { + if (setting.supModule && !BID) { notification.warning({ top: 92, message: '闇�瑕佷笂绾т富閿�硷紒', duration: 5 }) return - } else if (type === 'linkbtn' && selectedData && selectedData.length === 1) { - if (record[0].$Index !== selectedData[0].$Index) { - return - } + } else if (type === 'linkbtn' && !btn.$toolbtn && !is(fromJS(selectedData || []), fromJS(record))) { + return } let data = record || selectedData || [] @@ -152,7 +180,7 @@ execSuccess = (res) => { const { btn } = this.props - if (res && res.ErrCode === 'S') { // 鎵ц鎴愬姛 + if (res && (res.ErrCode === 'S' || !res.ErrCode)) { // 鎵ц鎴愬姛 notification.success({ top: 92, message: res.ErrMesg || this.state.dict['main.action.confirm.success'], @@ -175,6 +203,9 @@ } else if (btn.execSuccess !== 'never') { MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, '', this.state.selines) } + + 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) @@ -310,7 +341,7 @@ param.LText = Utils.formatOptions(result.sql) param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt(param.LText, param.timestamp) - if (this.props.menuType === 'HS' && param.timestamp) { // 浜戠楠岃瘉 + if (window.GLOB.mkHS && param.timestamp) { // 浜戠楠岃瘉 param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) } @@ -377,9 +408,11 @@ // 澶栭儴璇锋眰 _outParam = fromJS(res).toJS() - if (this.props.menuType === 'HS') { + if (window.GLOB.mkHS) { if (btn.sysInterface === 'true' && options.cloudServiceApi) { param.rduri = options.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 @@ -388,13 +421,25 @@ } } } else { - if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { - param.rduri = window.GLOB.mainSystemApi - } else if (btn.sysInterface !== 'true') { + 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 || '' + } + } 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 } } } @@ -403,7 +448,7 @@ res.func = btn.outerFunc } - if (this.props.menuType === 'HS' && res.func === 's_sDataDictb_excelIn') { // s_sDataDictb_excelIn 浜戠楠岃瘉 + if (window.GLOB.mkHS && res.func === 's_sDataDictb_excelIn') { // s_sDataDictb_excelIn 浜戠楠岃瘉 param.LText = Utils.formatOptions(result.sql) param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt(param.LText, param.timestamp) @@ -443,63 +488,49 @@ } render() { - const { btn, show } = this.props + const { btn } = this.props const { loading, disabled, hidden } = this.state if (hidden) return null - if (show === 'actionList') { - return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}> - <Button - icon={btn.icon} - loading={loading} - disabled={disabled} - className={'mk-btn mk-' + btn.class} - onClick={() => {this.actionTrigger()}} - >{btn.label}</Button> - <ExcelIn btn={btn} triggerExcelIn={() => this.setState({ loading: true })} returndata={this.getexceldata} ref="excelIn" /> - </div> - } else { // icon銆乼ext銆� all 鍗$墖 - let label = '' - let icon = '' + let label = '' + let icon = '' + let type = 'link' + let className = '' - if (show === 'button') { - label = btn.label - icon = btn.icon || '' - } else if (show === 'link') { - label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span> - icon = '' - } else if (show === 'icon') { - icon = btn.icon || 'upload' - // } else if (show === 'text') { - } else { - label = btn.label - } - - return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}> - <Button - type="link" - title={show === 'icon' ? btn.label : ''} - loading={loading} - disabled={disabled} - style={btn.style} - icon={icon} - onClick={() => {this.actionTrigger()}} - >{label}</Button> - <ExcelIn btn={btn} triggerExcelIn={() => this.setState({ loading: true })} returndata={this.getexceldata} ref="excelIn" /> - </div> + 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 = '' + } 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 + } else { + type = '' + icon = btn.icon || '' + label = btn.label + className = 'mk-btn mk-' + btn.class } + + return <> + <Button + type={type} + title={disabled ? (btn.reason || '') : (btn.show === 'icon' ? btn.label : '')} + loading={loading} + disabled={disabled} + style={btn.style} + icon={icon} + className={className} + onClick={(e) => {e.stopPropagation(); this.actionTrigger()}} + >{label}</Button> + <ExcelIn btn={btn} triggerExcelIn={() => this.setState({ loading: true })} returndata={this.getexceldata} ref="excelIn" /> + </> } } -const mapStateToProps = (state) => { - return { - menuType: state.editLevel - } -} - -const mapDispatchToProps = () => { - return {} -} - -export default connect(mapStateToProps, mapDispatchToProps)(ExcelInButton) \ No newline at end of file +export default ExcelInButton \ No newline at end of file -- Gitblit v1.8.0