From 00c73bd934ed0ca87a2fc91b5bdcdb5e33f99b3c Mon Sep 17 00:00:00 2001 From: wyw <571921741@qq.com> Date: Fri, 2 Feb 2024 11:49:18 +0800 Subject: [PATCH] =?UTF-8?q?git=E6=96=87=E4=BB=B6=E5=BA=93=E7=BC=BA?= =?UTF-8?q?=E5=A4=B1=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Custom/CustomPage.js | 74 +++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/components/Custom/CustomPage.js diff --git a/src/components/Custom/CustomPage.js b/src/components/Custom/CustomPage.js new file mode 100644 index 0000000..1fb6309 --- /dev/null +++ b/src/components/Custom/CustomPage.js @@ -0,0 +1,74 @@ +import React from 'react' +import { connect } from 'dva' +import { initFilter, getCustomParams } from "../../utils/common" +//import loadPage from '../../utils/customConfigwjn'//便捷开发 请勿提交 +import loadPage from '../../utils/customConfig1' +// import loadPage from '../../utils/customConfig' + +class CustomPage extends React.Component { + constructor(props) { + super(props) + this.state = { + pageCustom: {}, + formData: {}, + customParams: {}, + CustomComponentDispatch: null + } + }; + + componentDidMount() { + this.getCustomConfig(this.props.formCode); + } + + componentWillReceiveProps(NextProps) { + if (NextProps.formCode && this.props.formCode != NextProps.formCode) { + this.getCustomConfig(NextProps.formCode) + } + } + + getCustomConfig = (formCode) => { + const { login } = this.props + const { OrgId: ORG_ID } = login + const params = initFilter(ORG_ID, formCode) + this.props.dispatch({ + type: 'customPage/getCustomPageConfigInfo', + payload: params, + onComplete: (ret) => { + if (ret) { + this.setCustomConfig(ret) + } + } + }) + } + + setCustomConfig = (ret) => { + if (ret) { + let customParams = ""; + if (ret.Nav_PageCustom) + customParams = ret.Nav_PageCustom.CUSTOM_PARAMS; + this.setState({ + pageCustom: ret.Nav_PageCustom, + formData: ret.Nav_Form, + customParams: getCustomParams(customParams) + }, () => { + + }) + } + }; + + render() { + const { formParam, data, formCode } = this.props + const { COMPONENT_NAME, PAGE_FORM_ID } = this.state.pageCustom ? this.state.pageCustom : {} + return ( + + { + COMPONENT_NAME + ? loadPage(COMPONENT_NAME, PAGE_FORM_ID, formParam, { ...data, ...this.state.customParams }, formCode, this.state.formData) + : null + } + + ) + } +} + +export default connect(({ login, loading, customPage }) => ({ login, loading, customPage }))(CustomPage)