import React from 'react'; import { connect } from 'dva'; import { Modal, Form } from 'antd'; import ImportPage from '../../components/common/ImportPage'; import { initFilter, extendRule } from '../../utils/common'; class ImportModal extends React.Component { constructor(props) { super(props); this.state = { visible: false, loading: false } }; doShow=()=>{ this.setState({ visible: true },()=>{ const {key}=this.props; this.props.dispatch({ type: 'custom/save', payload: { [key]: true }, }); }); } showModal = () => { // 显示弹窗 const { dispatch,login,formCode,click } = this.props; if(!this.isGetConfig&&formCode){ const json=initFilter(login.OrgId); extendRule(json,'EDIT_FORM_CODE',1,formCode); extendRule(json,'ENABLE_STATUS',1,0); dispatch({ type: 'app/getDataByPost', payload: json, url: 'FM/ImportConfig/Get', onComplete: (ret) => { if (ret) { this.setState({ importConfigCode:ret.CODE, },()=>{ this.doShow(); }) } this.isGetConfig=true; } }); } else if(this.state.importConfigCode){ this.doShow(); } if (typeof click === 'function') { click(); } }; handleCancel = () => { // 退出弹窗 this.props.form.resetFields(); this.setState({ visible: false }); if(typeof this.destroyCacheDataFunc==='function'){ this.destroyCacheDataFunc(); } }; onRegDestroyCacheDataFunc=(destroyCacheDataFunc)=>{ this.destroyCacheDataFunc=destroyCacheDataFunc; }; render() { const { key, } = this.props; const { importConfigCode, } = this.state; return (
{this.props.children} { importConfigCode ? : '请配置导入配置信息' }
); } } export default connect(({ app, editPage, loading, login }) => ({ app, editPage, loading, login }))(Form.create()(ImportModal));