From 91e232bb0b910f3670bdbccd65cc218d55e1eda9 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 06 十二月 2022 16:08:20 +0800 Subject: [PATCH] Merge branch 'develop' --- src/tabviews/custom/components/form/simple-form/index.jsx | 78 +++++++++++++++++++++++--------------- 1 files changed, 47 insertions(+), 31 deletions(-) diff --git a/src/tabviews/custom/components/form/simple-form/index.jsx b/src/tabviews/custom/components/form/simple-form/index.jsx index 35fd004..b29ce9c 100644 --- a/src/tabviews/custom/components/form/simple-form/index.jsx +++ b/src/tabviews/custom/components/form/simple-form/index.jsx @@ -1,8 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { connect } from 'react-redux' -import { Spin, notification } from 'antd' +import { Spin, notification, Modal, Button } from 'antd' import Api from '@/api' import UtilsDM from '@/utils/utils-datamanage.js' @@ -19,7 +18,6 @@ class SimpleForm extends Component { static propTpyes = { - BID: PropTypes.any, // 鐖剁骇Id data: PropTypes.array, // 缁熶竴鏌ヨ鏁版嵁 config: PropTypes.object, // 缁勪欢閰嶇疆淇℃伅 mainSearch: PropTypes.any, // 澶栧眰鎼滅储鏉′欢 @@ -38,17 +36,29 @@ } UNSAFE_componentWillMount () { - const { data, BID, BData } = this.props + const { data } = this.props let config = fromJS(this.props.config).toJS() let _data = null let _sync = false + let BID = '' + let BData = '' + + if (config.setting.supModule) { + BData = window.GLOB.CacheData.get(config.setting.supModule) + } else { + BData = window.GLOB.CacheData.get(config.$pageId) + } + if (BData) { + BID = BData.$BID || '' + } + if (config.wrap.datatype !== 'static') { _sync = config.setting.sync === 'true' - if (_sync && data && data[config.dataName]) { - _data = data[config.dataName] + if (_sync && data) { + _data = data[config.dataName] || {$$empty: true} if (Array.isArray(_data)) { _data = _data[0] || {$$empty: true} } @@ -60,7 +70,7 @@ let _group = config.subcards[0] - if (_group.subButton.enable === 'false') { + if (_group.subButton.enable === 'false' && (!_group.closeButton || _group.closeButton.enable !== 'true')) { _group.subButton.style.display = 'none' _group.$button = 'no-button' } @@ -119,7 +129,7 @@ } this.setState({sync: false, data: _data}) - } else if (config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { + } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { this.setState({}, () => { this.loadData() }) @@ -185,7 +195,7 @@ execSuccess = (btn, id) => { if (btn.linkmenu && btn.linkmenu.length > 0) { let menu_id = btn.linkmenu[btn.linkmenu.length - 1] - let menu = this.props.permMenus.filter(m => m.MenuID === menu_id)[0] || '' + let menu = window.GLOB.mkThdMenus.filter(m => m.MenuID === menu_id)[0] || '' if (!menu) return @@ -194,11 +204,7 @@ param: {$BID: id || ''} } - if (['linkage_navigation', 'linkage', 'menu_board'].includes(window.GLOB.navBar)) { - MKEmitter.emit('modifyTabs', newtab, 'replace') - } else { - MKEmitter.emit('modifyTabs', newtab, 'plus', true) - } + MKEmitter.emit('modifyTabs', newtab, true) } } @@ -206,7 +212,12 @@ const { mainSearch } = this.props const { config, arr_field, BID } = this.state - if (config.wrap.datatype === 'static' || (config.setting.supModule && !BID)) { + if (config.wrap.datatype === 'static') { + this.setState({ + data: {$$empty: true} + }) + return + } else if (config.setting.supModule && !BID) { this.setState({ data: null }, () => { @@ -243,11 +254,18 @@ this.setState({ loading: false, }) - notification.error({ - top: 92, - message: result.message, - duration: 10 - }) + + if (result.ErrCode === 'N') { + Modal.error({ + title: result.message, + }) + } else { + notification.error({ + top: 92, + message: result.message, + duration: 10 + }) + } } } @@ -259,6 +277,12 @@ this.formRef.handleConfirm().then(res => { MKEmitter.emit('triggerFormSubmit', {menuId: btnId, form: res}) }) + } + + closeTab = () => { + const { group } = this.state + + MKEmitter.emit('closeTabView', group.subButton.$MenuID) } render() { @@ -279,6 +303,7 @@ dict={dict} data={data} action={group} + unload={config.setting.supModule && !BID} inputSubmit={() => this.mkFormSubmit(group.uuid)} wrappedComponentRef={(inst) => this.formRef = inst} /> : null} @@ -290,20 +315,11 @@ columns={config.columns} selectedData={data.$$empty ? [] : [data]} /> + {group.closeButton && group.closeButton.enable === 'true' ? <Button type="link" onClick={this.closeTab} style={group.closeButton.style}>{group.closeButton.label}</Button> : null} </div> : null} </div> ) } } -const mapStateToProps = (state) => { - return { - permMenus: state.permMenus, - } -} - -const mapDispatchToProps = () => { - return {} -} - -export default connect(mapStateToProps, mapDispatchToProps)(SimpleForm) \ No newline at end of file +export default SimpleForm \ No newline at end of file -- Gitblit v1.8.0