From af0db2414ced6089cdb829304a4409ea4231d57a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 25 十二月 2019 17:56:36 +0800 Subject: [PATCH] 2019-12-25 --- src/templates/modalconfig/index.jsx | 50 +++++++++++++++++++++++++++++++++----------------- 1 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/templates/modalconfig/index.jsx b/src/templates/modalconfig/index.jsx index 2184437..8bf9967 100644 --- a/src/templates/modalconfig/index.jsx +++ b/src/templates/modalconfig/index.jsx @@ -27,11 +27,14 @@ class ComTableConfig extends Component { static propTpyes = { menu: PropTypes.any, + editTab: PropTypes.any, + btnParam: PropTypes.object, editAction: PropTypes.object, handleConfig: PropTypes.func } state = { + menu: null, // 涓婄骇鑿滃崟锛屼笁绾ц彍鍗曟垨鏍囩 dict: CommonDict, // 瀛楀吀 config: null, // 椤甸潰閰嶇疆锛屽寘鎷ā鏉跨被鍨嬨�佹ā鎬佹璁剧疆銆佹坊鍔犺〃鍚嶃�佽〃鍗曞垪琛� visible: false, // 琛ㄥ崟缂栬緫妯℃�佹锛屾樉绀烘帶鍒� @@ -48,7 +51,7 @@ closeVisible: false, // 鍏抽棴妯℃�佹 tables: [], // 鍙敤琛ㄥ悕 selectedTables: [], // 宸查�夎〃鍚� - originConfig: null, // 鍘熷鑿滃崟 + originConfig: null, // 鍘熷鑿滃崟 groupVisible: false, // 鍏ㄥ眬閰嶇疆妯℃�佹 curgroup: null // 褰撳墠缁勶紝鏂板缓鎴栫紪杈� } @@ -61,12 +64,19 @@ * 4銆佽缃寜閽熀鏈俊鎭� */ UNSAFE_componentWillMount () { - const {menu, editAction} = this.props - console.log(menu) - let _config = '' + const {menu, editAction, editTab, btnParam} = this.props - if (editAction.pageParam) { - _config = editAction.pageParam + let _config = '' + let _menu = { + type: editTab ? editTab.Template : menu.type, + tables: editTab ? editTab.tables : menu.LongParam.tables, + MenuID: editTab ? editTab.uuid : menu.MenuID, + MenuNo: editTab ? editTab.tabNo : menu.MenuNo, + MenuName: editTab ? editTab.tabName : menu.MenuName + } + + if (btnParam) { + _config = btnParam } else { _config = JSON.parse(JSON.stringify((Source.baseConfig))) } @@ -75,12 +85,11 @@ _config.setting.title = editAction.label } - if (menu.LongParam.tables && menu.LongParam.tables.length > 0 && _config.tables.length === 0) { - // 涓昏彍鍗曞凡鏈夐�夋嫨鐨勮〃鍚嶏紝妯℃�佹娌℃湁琛ㄥ悕鏃讹紝澶嶅埗涓昏彍鍗曡〃鍚� - _config.tables = menu.LongParam.tables - } + // 涓昏彍鍗曞凡鏈夐�夋嫨鐨勮〃鍚嶏紝妯℃�佹娌℃湁琛ㄥ悕鏃讹紝澶嶅埗涓昏彍鍗曡〃鍚� + _config.tables = _config.tables.length === 0 ? _menu.tables : _config.tables this.setState({ + menu: _menu, config: _config, selectedTables: _config.tables || [], originConfig: JSON.parse(JSON.stringify(_config)), @@ -89,7 +98,7 @@ type: 'text', key: 'supMenu', label: this.state.dict['header.menu.supMenu'], - initVal: menu.MenuName, + initVal: _menu.MenuName, required: true, readonly: true }, @@ -193,6 +202,15 @@ tableColumns: _columns }) }) + } + + /** + * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 + */ + componentWillUnmount () { + this.setState = (state, callback) => { + return + } } /** @@ -568,8 +586,8 @@ } submitConfig = () => { - const { menu, editAction } = this.props - const { config } = this.state + const { editAction } = this.props + const { config, menu } = this.state if ((!config.groups[0] && !config.fields[0]) || (config.fields[0] && config.fields[0].origin)) { notification.warning({ @@ -643,8 +661,7 @@ } cancelConfig = () => { - const { menu } = this.props - const { config, originConfig } = this.state + const { menu, config, originConfig } = this.state let _this = this let isOrigin = config.fields.filter(item => item.origin).length > 0 @@ -1046,8 +1063,7 @@ } render () { - const { menu } = this.props - const { config } = this.state + const { menu, config } = this.state return ( <div className="modal-form-board"> -- Gitblit v1.8.0