From 87c445887fe8d724ea124535234df974d3e1d58e Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 19 六月 2021 13:17:48 +0800 Subject: [PATCH] 2021-06-19 --- src/tabviews/custom/components/card/cardcellList/index.jsx | 7 src/tabviews/zshare/actionList/tabbutton/index.jsx | 37 ++++ src/tabviews/custom/components/chart/antv-bar-line/index.jsx | 64 -------- src/tabviews/zshare/actionList/popupbutton/index.jsx | 38 ++++ src/templates/zshare/formconfig.jsx | 19 ++ src/templates/zshare/modalform/datatable/index.jsx | 4 src/menu/components/share/actioncomponent/formconfig.jsx | 8 src/templates/sharecomponent/actioncomponent/actionform/index.jsx | 37 +++- src/menu/components/share/actioncomponent/index.jsx | 2 src/tabviews/zshare/actionList/excelInbutton/index.jsx | 38 ++++ src/tabviews/zshare/actionList/printbutton/index.jsx | 38 ++++ src/menu/components/share/actioncomponent/actionform/index.jsx | 51 ++++-- src/tabviews/custom/index.jsx | 2 src/tabviews/zshare/actionList/newpagebutton/index.jsx | 37 ++++ src/tabviews/zshare/actionList/normalbutton/index.jsx | 38 ++++ src/tabviews/zshare/actionList/changeuserbutton/index.jsx | 38 ++++ src/assets/css/main.scss | 13 + 17 files changed, 360 insertions(+), 111 deletions(-) diff --git a/src/assets/css/main.scss b/src/assets/css/main.scss index c5c13e3..5462cd5 100644 --- a/src/assets/css/main.scss +++ b/src/assets/css/main.scss @@ -390,4 +390,17 @@ .ant-input[disabled] { background-color: #fafafa!important; +} +.ant-btn[disabled] { + background-color: transparent!important; + border-color: rgba(0, 0, 0, 0.35)!important; + color: rgba(0, 0, 0, 0.35)!important; +} +.ant-btn.ant-btn-link { + border-width: 0; +} +.button-list { + .ant-btn.ant-btn-link { + border-width: 1px; + } } \ No newline at end of file diff --git a/src/menu/components/share/actioncomponent/actionform/index.jsx b/src/menu/components/share/actioncomponent/actionform/index.jsx index ba4c550..a4060b9 100644 --- a/src/menu/components/share/actioncomponent/actionform/index.jsx +++ b/src/menu/components/share/actioncomponent/actionform/index.jsx @@ -8,15 +8,15 @@ const { TextArea } = Input const actionTypeOptions = { - pop: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'icon', 'class', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'width', 'controlField', 'controlVal'], - prompt: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'icon', 'class', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'width', 'controlField', 'controlVal'], - exec: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'icon', 'class', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'width', 'controlField', 'controlVal'], - excelIn: ['label', 'Ot', 'OpenType', 'intertype', 'show', 'icon', 'class', 'sheet', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'width', 'controlField', 'controlVal'], - excelOut: ['label', 'OpenType', 'intertype', 'show', 'icon', 'class', 'execSuccess', 'execError', 'syncComponent', 'resetPageIndex', 'pagination', 'search', 'width', 'controlField', 'controlVal'], - popview: ['label', 'Ot', 'OpenType', 'show', 'icon', 'class', 'popClose', 'resetPageIndex', 'width', 'controlField', 'controlVal'], - tab: ['label', 'Ot', 'OpenType', 'show', 'icon', 'class', 'linkmenu', 'width', 'controlField', 'controlVal'], - innerpage: ['label', 'Ot', 'OpenType', 'pageTemplate', 'show', 'icon', 'class', 'width', 'open', 'controlField', 'controlVal'], - funcbutton: ['label', 'OpenType', 'funcType', 'show', 'icon', 'class', 'width', 'controlField', 'controlVal'] + pop: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'icon', 'class', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'width'], + prompt: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'icon', 'class', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'width'], + exec: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'icon', 'class', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'width'], + excelIn: ['label', 'Ot', 'OpenType', 'intertype', 'show', 'icon', 'class', 'sheet', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'width'], + excelOut: ['label', 'OpenType', 'intertype', 'show', 'icon', 'class', 'execSuccess', 'execError', 'syncComponent', 'resetPageIndex', 'pagination', 'search', 'width'], + popview: ['label', 'Ot', 'OpenType', 'show', 'icon', 'class', 'popClose', 'resetPageIndex', 'width'], + tab: ['label', 'Ot', 'OpenType', 'show', 'icon', 'class', 'linkmenu', 'width'], + innerpage: ['label', 'Ot', 'OpenType', 'pageTemplate', 'show', 'icon', 'class', 'width', 'open'], + funcbutton: ['label', 'OpenType', 'funcType', 'show', 'icon', 'class', 'width'] } class ActionForm extends Component { @@ -35,6 +35,7 @@ interType: null, // 鎺ュ彛绫诲瀷锛氬唴閮ㄣ�佸閮� funcType: null, // 鍔熻兘绫诲瀷 procMode: null, // 鍙傛暟鏂瑰紡 + Ot: null, requireOptions: [{ value: 'notRequired', text: this.props.dict['header.form.notRequired'] @@ -91,10 +92,12 @@ let _intertype = card.intertype || 'system' // 鎺ュ彛绫诲瀷 let _funcType = card.funcType || '' // 鍔熻兘鎸夐挳榛樿绫诲瀷 let _procMode = card.procMode || 'system' // 鍙傛暟璇锋眰鏂瑰紡 + let _Ot = card.Ot || 'requiredSgl' // 鍙傛暟璇锋眰鏂瑰紡 - let _options = this.getOptions(_opentype, _intertype, _funcType, card.pageTemplate, _procMode) + let _options = this.getOptions(_opentype, _intertype, _funcType, card.pageTemplate, _procMode, _Ot) this.setState({ + Ot: _Ot, openType: _opentype, interType: _intertype, procMode: _procMode, @@ -137,7 +140,7 @@ }) } - getOptions = (_opentype, _intertype, _funcType, _pageTemplate, _procMode) => { + getOptions = (_opentype, _intertype, _funcType, _pageTemplate, _procMode, _Ot) => { let _options = actionTypeOptions[_opentype] ? fromJS(actionTypeOptions[_opentype]).toJS() : [] // 閫夐」鍒楄〃 if (_opentype === 'innerpage') { // 鏂伴〉闈紝鍙�夋ā鏉�(鑷畾涔夋椂锛屽彲濉叆澶栭儴閾炬帴) @@ -186,6 +189,10 @@ } } + if (_Ot !== 'notRequired' && _opentype !== 'excelOut') { + _options.push('controlField', 'controlVal') + } + return _options } @@ -210,10 +217,10 @@ */ optionChange = (key, value) => { const { card, type } = this.props - const { openType, procMode } = this.state + const { openType, procMode, Ot } = this.state if (key === 'OpenType') { - let _options = this.getOptions(value, 'system', this.state.funcType, card.pageTemplate, 'system') + let _options = this.getOptions(value, 'system', this.state.funcType, card.pageTemplate, 'system', Ot) let _fieldval = {} @@ -270,7 +277,7 @@ this.props.form.setFieldsValue(_fieldval) }) } else if (key === 'funcType') { - let _options = this.getOptions(openType, this.state.interType, value, card.pageTemplate, procMode) + let _options = this.getOptions(openType, this.state.interType, value, card.pageTemplate, procMode, Ot) let _fieldval = {} this.setState({ @@ -334,7 +341,7 @@ }) } else if (key === 'pageTemplate') { let _fieldval = {} - let _options = this.getOptions(openType, this.state.interType, this.state.funcType, value, procMode) + let _options = this.getOptions(openType, this.state.interType, this.state.funcType, value, procMode, Ot) this.setState({ formlist: this.state.formlist.map(item => { @@ -357,7 +364,7 @@ this.props.form.setFieldsValue(_fieldval) }) } else if (key === 'intertype') { - let _options = this.getOptions(openType, value, this.state.funcType, '', procMode) + let _options = this.getOptions(openType, value, this.state.funcType, '', procMode, Ot) this.setState({ interType: value, @@ -379,7 +386,7 @@ }) }) } else if (key === 'procMode') { - let _options = this.getOptions(openType, this.state.interType, this.state.funcType, '', value) + let _options = this.getOptions(openType, this.state.interType, this.state.funcType, '', value, Ot) this.setState({ procMode: value, @@ -392,6 +399,16 @@ return item }) }) + } else if (key === 'Ot') { + let _options = this.getOptions(openType, this.state.interType, this.state.funcType, '', procMode, value) + + this.setState({ + Ot: value, + formlist: this.state.formlist.map(item => { + item.hidden = !_options.includes(item.key) + return item + }) + }) } else if (key === 'sysInterface') { if (value === 'true') { this.props.form.setFieldsValue({ diff --git a/src/menu/components/share/actioncomponent/formconfig.jsx b/src/menu/components/share/actioncomponent/formconfig.jsx index c4b7f0f..5ddd19f 100644 --- a/src/menu/components/share/actioncomponent/formconfig.jsx +++ b/src/menu/components/share/actioncomponent/formconfig.jsx @@ -520,19 +520,19 @@ type: 'select', key: 'controlField', label: '鎺у埗瀛楁', - tooltip: '鏄剧ず鎺у埗瀛楁锛屽彲鏍规嵁琛屾暟鎹帶鍒舵寜閽槸鍚︽樉绀恒��', + tooltip: '绂佺敤鎺у埗瀛楁锛屽彲鏍规嵁鏁版嵁鎺у埗鎸夐挳鏄惁绂佺敤銆�', initVal: card.controlField || '', required: false, - forbid: card.$type !== 'tableButton', + // forbid: card.$type !== 'tableButton', options: [{label: '鏃�', field: ''}, ...columns] }, { type: 'text', key: 'controlVal', label: '鎺у埗鍊�', - tooltip: '褰撻�夋嫨鎺у埗瀛楁锛屼笖瀛楁鍊间笌鎺у埗鍊肩浉绛夋椂锛屾寜閽細闅愯棌锛屽涓�肩敤閫楀彿鍒嗛殧銆�', + tooltip: '褰撻�夋嫨鎺у埗瀛楁锛屼笖瀛楁鍊间笌鎺у埗鍊肩浉绛夋椂锛屾寜閽細绂佺敤锛屽涓�肩敤閫楀彿鍒嗛殧銆�', initVal: card.controlVal || '', - forbid: card.$type !== 'tableButton', + // forbid: card.$type !== 'tableButton', required: false } ] diff --git a/src/menu/components/share/actioncomponent/index.jsx b/src/menu/components/share/actioncomponent/index.jsx index 38ae2a2..43dabb7 100644 --- a/src/menu/components/share/actioncomponent/index.jsx +++ b/src/menu/components/share/actioncomponent/index.jsx @@ -187,7 +187,7 @@ this.setState({ visible: true, card: card, - formlist: getActionForm(card, functip, config.setting, usefulFields, this.props.type, menulist, modules) + formlist: getActionForm(card, functip, config.setting, usefulFields, this.props.type, menulist, modules, config.columns) }) } diff --git a/src/tabviews/custom/components/card/cardcellList/index.jsx b/src/tabviews/custom/components/card/cardcellList/index.jsx index 2f26876..8b5fa84 100644 --- a/src/tabviews/custom/components/card/cardcellList/index.jsx +++ b/src/tabviews/custom/components/card/cardcellList/index.jsx @@ -550,13 +550,6 @@ </Col> ) } else if (card.eleType === 'button') { - if (card.$type === 'tableButton' && card.controlField) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒� - if (data[card.controlField] === card.controlVal) { - return null - } else if (card.controlVal && card.controlVal.split(',').includes(data[card.controlField])) { - return null - } - } let _data = data.$$type === 'extendCard' ? [] : [data] if (['exec', 'prompt', 'pop'].includes(card.OpenType)) { diff --git a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx index cd01883..12c5a83 100644 --- a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx +++ b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx @@ -2,7 +2,6 @@ import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' import { Chart } from '@antv/g2' -// import { connect } from 'react-redux' import DataSet from '@antv/data-set' import { Spin, Empty, notification } from 'antd' import moment from 'moment' @@ -12,7 +11,6 @@ import Api from '@/api' import Utils from '@/utils/utils.js' import UtilsDM from '@/utils/utils-datamanage.js' -// import { modifyTabview } from '@/store/action' import MKEmitter from '@/utils/events.js' import './index.scss' @@ -1618,54 +1616,6 @@ MKEmitter.emit('resetSelectLine', config.uuid, (data ? data.$$uuid : ''), null) }) - // if (plot.linkmenu && plot.linkmenu.length > 0) { - // let menu_id = plot.linkmenu.slice(-1)[0] - // let menu = this.props.permMenus.filter(m => m.MenuID === menu_id)[0] || '' - - // chart.on('element:dblclick', (ev) => { - // if (!menu) { - // notification.warning({ - // top: 92, - // message: '鑿滃崟宸插垹闄ゆ垨娌℃湁璁块棶鏉冮檺锛�', - // duration: 5 - // }) - // return - // } - - // try { - // let data = ev.data.data - // let primaryId = '' - // if (this.state.config.setting.primaryKey && data) { - // primaryId = data[this.state.config.setting.primaryKey] || '' - // } - - // let newtab = { - // ...menu, - // selected: true, - // param: { - // $BID: primaryId - // } - // } - - // let tabs = this.props.tabviews.filter(tab => { - // tab.selected = false - // return tab.MenuID !== newtab.MenuID - // }) - - // if (this.props.tabviews.length > tabs.length) { - // this.props.modifyTabview(fromJS(tabs).toJS()) - // } - - // this.setState({}, () => { - // tabs.push(newtab) - // this.props.modifyTabview(tabs) - // }) - // } catch { - // console.warn('鑿滃崟鎵撳紑澶辫触锛�') - // } - // }) - // } - if (plot.interaction && plot.interaction.length) { plot.interaction.forEach(t => { chart.interaction(t) @@ -1727,18 +1677,4 @@ } } -// const mapStateToProps = (state) => { -// return { -// tabviews: state.tabviews, -// permMenus: state.permMenus, -// } -// } - -// const mapDispatchToProps = (dispatch) => { -// return { -// modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews)) -// } -// } - -// export default connect(mapStateToProps, mapDispatchToProps)(LineChart) export default LineChart \ No newline at end of file diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index 26cde23..b37e55b 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -737,7 +737,7 @@ return component } - if (component.wrap.datatype === 'static') { + if (component.wrap && component.wrap.datatype === 'static') { component.format = '' } diff --git a/src/tabviews/zshare/actionList/changeuserbutton/index.jsx b/src/tabviews/zshare/actionList/changeuserbutton/index.jsx index 4c1a3a7..454d8a1 100644 --- a/src/tabviews/zshare/actionList/changeuserbutton/index.jsx +++ b/src/tabviews/zshare/actionList/changeuserbutton/index.jsx @@ -23,7 +23,23 @@ state = { dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, + disabled: false, loading: false + } + + UNSAFE_componentWillMount () { + const { btn, selectedData } = this.props + let disabled = false + + if (btn.controlField && selectedData && selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒� + selectedData.forEach(item => { + let s = item[btn.controlField] + '' + if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { + disabled = true + } + }) + this.setState({disabled}) + } } shouldComponentUpdate (nextProps, nextState) { @@ -35,6 +51,24 @@ if (position === 'toolbar') { MKEmitter.addListener('triggerBtnId', this.actionTrigger) + } + } + + UNSAFE_componentWillReceiveProps (nextProps) { + const { btn, selectedData } = this.props + + 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] + '' + if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { + disabled = true + } + }) + } + this.setState({disabled}) } } @@ -149,13 +183,14 @@ render() { const { btn, show } = this.props - const { loading } = this.state + const { loading, disabled } = this.state if (show === 'actionList') { return ( <Button icon={btn.icon} loading={loading} + disabled={disabled} className={'mk-btn mk-' + btn.class} onClick={(e) => {e.stopPropagation(); this.actionTrigger()}} >{btn.label}</Button> @@ -166,6 +201,7 @@ type="link" title={show === 'icon' ? btn.label : ''} loading={loading} + disabled={disabled} style={btn.style} icon={show === 'text' ? '' : (btn.icon || '')} onClick={(e) => {e.stopPropagation(); this.actionTrigger()}} diff --git a/src/tabviews/zshare/actionList/excelInbutton/index.jsx b/src/tabviews/zshare/actionList/excelInbutton/index.jsx index 1d3ea4f..2fc88ba 100644 --- a/src/tabviews/zshare/actionList/excelInbutton/index.jsx +++ b/src/tabviews/zshare/actionList/excelInbutton/index.jsx @@ -28,7 +28,23 @@ state = { dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, loading: false, + disabled: false, primaryId: '', + } + + UNSAFE_componentWillMount () { + const { btn, selectedData } = this.props + let disabled = false + + if (btn.controlField && selectedData && selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒� + selectedData.forEach(item => { + let s = item[btn.controlField] + '' + if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { + disabled = true + } + }) + this.setState({disabled}) + } } shouldComponentUpdate (nextProps, nextState) { @@ -40,6 +56,24 @@ if (position === 'toolbar') { MKEmitter.addListener('triggerBtnId', this.actionTrigger) + } + } + + UNSAFE_componentWillReceiveProps (nextProps) { + const { btn, selectedData } = this.props + + 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] + '' + if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { + disabled = true + } + }) + } + this.setState({disabled}) } } @@ -408,13 +442,14 @@ render() { const { btn, show } = this.props - const { loading } = this.state + const { loading, disabled } = this.state 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> @@ -426,6 +461,7 @@ type="link" title={show === 'icon' ? btn.label : ''} loading={loading} + disabled={disabled} style={btn.style} icon={show === 'text' ? '' : (show === 'icon' ? (btn.icon || 'upload') : (btn.icon || ''))} onClick={() => {this.actionTrigger()}} diff --git a/src/tabviews/zshare/actionList/newpagebutton/index.jsx b/src/tabviews/zshare/actionList/newpagebutton/index.jsx index 1ee735a..2ff034c 100644 --- a/src/tabviews/zshare/actionList/newpagebutton/index.jsx +++ b/src/tabviews/zshare/actionList/newpagebutton/index.jsx @@ -21,7 +21,23 @@ state = { dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, + disabled: false, visible: false + } + + UNSAFE_componentWillMount () { + const { btn, selectedData } = this.props + let disabled = false + + if (btn.controlField && selectedData && selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒� + selectedData.forEach(item => { + let s = item[btn.controlField] + '' + if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { + disabled = true + } + }) + this.setState({disabled}) + } } shouldComponentUpdate (nextProps, nextState) { @@ -33,6 +49,24 @@ if (position === 'toolbar') { MKEmitter.addListener('triggerBtnId', this.actionTrigger) + } + } + + UNSAFE_componentWillReceiveProps (nextProps) { + const { btn, selectedData } = this.props + + 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] + '' + if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { + disabled = true + } + }) + } + this.setState({disabled}) } } @@ -156,12 +190,14 @@ render() { const { btn, show } = this.props + const { disabled } = this.state if (show === 'actionList') { return ( <Button className={'mk-btn mk-' + btn.class} icon={btn.icon} + disabled={disabled} onClick={(e) => {e.stopPropagation(); this.actionTrigger()}} >{btn.label}</Button> ) @@ -171,6 +207,7 @@ type="link" title={show === 'icon' ? btn.label : ''} style={btn.style} + disabled={disabled} icon={show === 'text' ? '' : (btn.icon || '')} onClick={(e) => {e.stopPropagation(); this.actionTrigger()}} >{show === 'icon' && btn.icon ? '' : btn.label}</Button> diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx index 03857a3..9802db7 100644 --- a/src/tabviews/zshare/actionList/normalbutton/index.jsx +++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx @@ -42,10 +42,26 @@ btnconfig: null, loading: false, loadingNumber: '', + disabled: false, checkParam: null } moduleParams = null + + UNSAFE_componentWillMount () { + const { btn, selectedData } = this.props + let disabled = false + + if (btn.controlField && selectedData && selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒� + selectedData.forEach(item => { + let s = item[btn.controlField] + '' + if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { + disabled = true + } + }) + this.setState({disabled}) + } + } shouldComponentUpdate (nextProps, nextState) { return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) @@ -60,6 +76,24 @@ MKEmitter.addListener('triggerFormSubmit', this.actionSubmit) } MKEmitter.addListener('returnModuleParam', this.resetModuleParam) + } + + UNSAFE_componentWillReceiveProps (nextProps) { + const { btn, selectedData } = this.props + + 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] + '' + if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { + disabled = true + } + }) + } + this.setState({disabled}) + } } componentWillUnmount () { @@ -1698,7 +1732,7 @@ render() { const { btn, show, style } = this.props - const { loadingNumber, loading, visible } = this.state + const { loadingNumber, loading, visible, disabled } = this.state if (show === 'actionList') { return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}> @@ -1706,6 +1740,7 @@ style={style} icon={btn.icon} loading={loading} + disabled={disabled} className={'mk-btn mk-' + btn.class} onClick={() => {this.actionTrigger()}} >{(loadingNumber ? `(${loadingNumber})` : '') + btn.label}</Button> @@ -1728,6 +1763,7 @@ type="link" title={show === 'icon' ? btn.label : ''} loading={loading} + disabled={disabled} style={btn.style || style} icon={show === 'text' ? '' : (btn.icon || '')} onClick={() => {this.actionTrigger()}} diff --git a/src/tabviews/zshare/actionList/popupbutton/index.jsx b/src/tabviews/zshare/actionList/popupbutton/index.jsx index 8861cad..c519a94 100644 --- a/src/tabviews/zshare/actionList/popupbutton/index.jsx +++ b/src/tabviews/zshare/actionList/popupbutton/index.jsx @@ -31,7 +31,23 @@ visible: false, popData: null, primaryId: '', + disabled: false, loading: false, + } + + UNSAFE_componentWillMount () { + const { btn, selectedData } = this.props + let disabled = false + + if (btn.controlField && selectedData && selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒� + selectedData.forEach(item => { + let s = item[btn.controlField] + '' + if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { + disabled = true + } + }) + this.setState({disabled}) + } } shouldComponentUpdate (nextProps, nextState) { @@ -46,6 +62,24 @@ } MKEmitter.addListener('openNewTab', this.openNewTab) MKEmitter.addListener('refreshPopButton', this.refreshPopButton) + } + + UNSAFE_componentWillReceiveProps (nextProps) { + const { btn, selectedData } = this.props + + 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] + '' + if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { + disabled = true + } + }) + } + this.setState({disabled}) + } } componentWillUnmount () { @@ -160,13 +194,14 @@ render() { const { btn, show } = this.props - const { loading, popData, primaryId } = this.state + const { loading, popData, primaryId, disabled } = this.state return ( <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}> {show === 'actionList' ? <Button className={'mk-btn mk-' + btn.class} icon={btn.icon} + disabled={disabled} onClick={() => {this.actionTrigger()}} loading={loading} >{btn.label}</Button> : null} @@ -174,6 +209,7 @@ type="link" title={show === 'icon' ? btn.label : ''} loading={loading} + disabled={disabled} style={btn.style} icon={show === 'text' ? '' : (btn.icon || '')} onClick={() => {this.actionTrigger()}} diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx index 3b79606..3a412a3 100644 --- a/src/tabviews/zshare/actionList/printbutton/index.jsx +++ b/src/tabviews/zshare/actionList/printbutton/index.jsx @@ -40,7 +40,23 @@ tabledata: null, btnconfig: null, loading: false, + disabled: false, loadingNumber: '' + } + + UNSAFE_componentWillMount () { + const { btn, selectedData } = this.props + let disabled = false + + if (btn.controlField && selectedData && selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒� + selectedData.forEach(item => { + let s = item[btn.controlField] + '' + if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { + disabled = true + } + }) + this.setState({disabled}) + } } shouldComponentUpdate (nextProps, nextState) { @@ -52,6 +68,24 @@ if (position === 'toolbar') { MKEmitter.addListener('triggerBtnId', this.actionTrigger) + } + } + + UNSAFE_componentWillReceiveProps (nextProps) { + const { btn, selectedData } = this.props + + 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] + '' + if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { + disabled = true + } + }) + } + this.setState({disabled}) } } @@ -1250,13 +1284,14 @@ render() { const { btn, show } = this.props - const { loadingNumber, loading } = this.state + const { loadingNumber, loading, disabled } = this.state 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()}} >{loadingNumber ? `(${loadingNumber})` : '' + btn.label}</Button> @@ -1268,6 +1303,7 @@ type="link" title={show === 'icon' ? btn.label : ''} loading={loading} + disabled={disabled} style={btn.style} icon={show === 'text' ? '' : (btn.icon || '')} onClick={() => {this.actionTrigger()}} diff --git a/src/tabviews/zshare/actionList/tabbutton/index.jsx b/src/tabviews/zshare/actionList/tabbutton/index.jsx index 6cdf44d..fdb9d78 100644 --- a/src/tabviews/zshare/actionList/tabbutton/index.jsx +++ b/src/tabviews/zshare/actionList/tabbutton/index.jsx @@ -22,7 +22,23 @@ state = { dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, + disabled: false, primaryId: '' + } + + UNSAFE_componentWillMount () { + const { btn, selectedData } = this.props + let disabled = false + + if (btn.controlField && selectedData && selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒� + selectedData.forEach(item => { + let s = item[btn.controlField] + '' + if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { + disabled = true + } + }) + this.setState({disabled}) + } } shouldComponentUpdate (nextProps, nextState) { @@ -34,6 +50,24 @@ if (position === 'toolbar') { MKEmitter.addListener('triggerBtnId', this.actionTrigger) + } + } + + UNSAFE_componentWillReceiveProps (nextProps) { + const { btn, selectedData } = this.props + + 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] + '' + if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { + disabled = true + } + }) + } + this.setState({disabled}) } } @@ -148,12 +182,14 @@ render() { const { btn, show } = this.props + const { disabled } = this.state if (show === 'actionList') { return ( <Button className={'mk-btn mk-' + btn.class} icon={btn.icon} + disabled={disabled} onClick={(e) => {e.stopPropagation(); this.actionTrigger()}} >{btn.label}</Button> ) @@ -163,6 +199,7 @@ type="link" title={show === 'icon' ? btn.label : ''} style={btn.style} + disabled={disabled} icon={show === 'text' ? '' : (btn.icon || '')} onClick={(e) => {e.stopPropagation(); this.actionTrigger()}} >{show === 'icon' && btn.icon ? '' : btn.label}</Button> diff --git a/src/templates/sharecomponent/actioncomponent/actionform/index.jsx b/src/templates/sharecomponent/actioncomponent/actionform/index.jsx index 1addfe3..53a733a 100644 --- a/src/templates/sharecomponent/actioncomponent/actionform/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/actionform/index.jsx @@ -38,6 +38,7 @@ position: null, // 鎸夐挳浣嶇疆 procMode: null, // 澶栭儴鎺ュ彛鍙傛暟澶勭悊鏂瑰紡 pageTemplate: null, + Ot: null, requireOptions: [{ value: 'notRequired', text: this.props.dict['header.form.notRequired'] @@ -97,6 +98,7 @@ let _funcType = card.funcType || '' // 鍔熻兘鎸夐挳榛樿绫诲瀷 let _tabTemplate = card.tabTemplate // 鎸夐挳涓烘爣绛鹃〉鏃讹紝鏍囩绫诲瀷锛氫笁绾ц彍鍗曟垨琛ㄥ崟鏍囩椤� let _pageTemplate = card.pageTemplate // 鏂伴〉闈㈢被鍨� + let _Ot = card.Ot || 'requiredSgl' if (_opentype === 'outerpage') { card.pageTemplate = 'custom' @@ -104,9 +106,10 @@ } let _tabs = this.props.tabs.filter(tab => tab.type === 'SubTable') - let _options = this.getOptions(_opentype, _intertype, _funcType, _pageTemplate, _tabTemplate, _procMode) + let _options = this.getOptions(_opentype, _intertype, _funcType, _pageTemplate, _tabTemplate, _procMode, _Ot) this.setState({ + Ot: _Ot, openType: _opentype, pageTemplate: _pageTemplate, interType: _intertype, @@ -172,7 +175,7 @@ } } - getOptions = (_opentype, _intertype, _funcType, _pageTemplate, _tabTemplate, _procMode) => { + getOptions = (_opentype, _intertype, _funcType, _pageTemplate, _tabTemplate, _procMode, _Ot) => { let _options = fromJS(actionTypeOptions[_opentype]).toJS() // 閫夐」鍒楄〃 if (_opentype === 'innerpage') { // 鏂伴〉闈紝鍙�夋ā鏉�(鑷畾涔夋椂锛屽彲濉叆澶栭儴閾炬帴) @@ -227,6 +230,10 @@ _options.push('resetPageIndex') } + if (_Ot !== 'notRequired' && _opentype !== 'excelOut') { + _options.push('controlField', 'controlVal') + } + return _options } @@ -234,11 +241,11 @@ * @description 鍒囨崲 */ optionChange = (key, value) => { - const { openType, funcType, procMode } = this.state + const { openType, funcType, procMode, Ot } = this.state const { card } = this.props if (key === 'OpenType') { - let _options = this.getOptions(value, 'system', '', this.state.pageTemplate, card.tabTemplate, 'system') + let _options = this.getOptions(value, 'system', '', this.state.pageTemplate, card.tabTemplate, 'system', Ot) let _fieldval = {} let _formlist = this.state.formlist.map(item => { item.hidden = !_options.includes(item.key) @@ -343,7 +350,7 @@ // this.props.form.setFieldsValue(_fieldval) // }) } else if (key === 'funcType') { - let _options = this.getOptions('funcbutton', this.state.interType, value, card.pageTemplate, card.tabTemplate, procMode) + let _options = this.getOptions('funcbutton', this.state.interType, value, card.pageTemplate, card.tabTemplate, procMode, Ot) let _fieldval = {} this.setState({ @@ -397,7 +404,7 @@ this.props.form.setFieldsValue(_fieldval) }) } else if (key === 'pageTemplate') { - let _options = this.getOptions('innerpage', this.state.interType, this.state.funcType, value, card.tabTemplate, procMode) + let _options = this.getOptions('innerpage', this.state.interType, this.state.funcType, value, card.tabTemplate, procMode, Ot) let _fieldval = {} this.setState({ @@ -438,7 +445,7 @@ }) }) } else if (key === 'intertype') { - let _options = this.getOptions(openType, value, funcType, '', '', procMode) + let _options = this.getOptions(openType, value, funcType, '', '', procMode, Ot) this.setState({ interType: value, @@ -458,7 +465,7 @@ }) }) } else if (key === 'procMode') { - let _options = this.getOptions(openType, this.state.interType, funcType, '', '', value) + let _options = this.getOptions(openType, this.state.interType, funcType, '', '', value, Ot) this.setState({ procMode: value, @@ -468,6 +475,16 @@ if (item.key === 'innerFunc') { item.required = true } + return item + }) + }) + } else if (key === 'Ot') { + let _options = this.getOptions(openType, this.state.interType, funcType, this.state.pageTemplate, card.tabTemplate, procMode, value) + + this.setState({ + Ot: value, + formlist: this.state.formlist.map(item => { + item.hidden = !_options.includes(item.key) return item }) }) @@ -599,8 +616,8 @@ getPopupContainer={() => document.getElementById('winter')} > {item.options.map((option, index) => - <Select.Option id={`${index}`} title={option.text} key={`${index}`} value={option.value}> - {item.key === 'icon' && option.value && <Icon type={option.value} />} {option.text} + <Select.Option id={`${index}`} title={option.text} key={`${index}`} value={option.value || option.field}> + {item.key === 'icon' && option.value ? <Icon type={option.value} /> : null} {option.text || option.label} </Select.Option> )} </Select> diff --git a/src/templates/zshare/formconfig.jsx b/src/templates/zshare/formconfig.jsx index a312d0d..aa1b34a 100644 --- a/src/templates/zshare/formconfig.jsx +++ b/src/templates/zshare/formconfig.jsx @@ -615,6 +615,8 @@ * @param {*} type 鎸夐挳绫诲瀷锛岀敤浜庡尯鍒嗗彲閫夌殑鎵撳紑鏂瑰紡 */ export function getActionForm (card, functip, config, usefulFields, type, menulist = [], printTemps = []) { + let columns = (config.columns || []).filter(col => col.field) + let opentypes = [ { value: 'pop', @@ -1125,6 +1127,23 @@ value: 'false', text: '闈炲繀濉�' }] + }, + { + type: 'select', + key: 'controlField', + label: '鎺у埗瀛楁', + tooltip: '绂佺敤鎺у埗瀛楁锛屽彲鏍规嵁鏁版嵁鎺у埗鎸夐挳鏄惁绂佺敤銆�', + initVal: card.controlField || '', + required: false, + options: [{label: '鏃�', field: ''}, ...columns] + }, + { + type: 'text', + key: 'controlVal', + label: '鎺у埗鍊�', + tooltip: '褰撻�夋嫨鎺у埗瀛楁锛屼笖瀛楁鍊间笌鎺у埗鍊肩浉绛夋椂锛屾寜閽細绂佺敤锛屽涓�肩敤閫楀彿鍒嗛殧銆�', + initVal: card.controlVal || '', + required: false } ] } diff --git a/src/templates/zshare/modalform/datatable/index.jsx b/src/templates/zshare/modalform/datatable/index.jsx index e7a12a1..21ae904 100644 --- a/src/templates/zshare/modalform/datatable/index.jsx +++ b/src/templates/zshare/modalform/datatable/index.jsx @@ -297,10 +297,10 @@ handleAdd = () => { const { fields, type } = this.props - if (this.state.data.length >= 20) { + if (this.state.data.length >= 100) { notification.warning({ top: 92, - message: '鏈�澶氬彲娣诲姞20椤癸紒', + message: '鏈�澶氬彲娣诲姞100椤癸紒', duration: 5 }) return -- Gitblit v1.8.0