From c54724b0590729c677057736bd2d04715dc0c3fb Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 22 一月 2020 14:43:24 +0800 Subject: [PATCH] 2020-01-22 --- src/templates/comtableconfig/index.jsx | 193 +++++++++++++++++++++++++---------------------- 1 files changed, 102 insertions(+), 91 deletions(-) diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index d382550..43894b4 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -36,12 +36,10 @@ class ComTableConfig extends Component { static propTpyes = { - type: PropTypes.string, menu: PropTypes.any, + supMenuList: PropTypes.array, reloadmenu: PropTypes.func, - handleConfig: PropTypes.func, - handleSubConfig: PropTypes.func, - supMenuList: PropTypes.array + handleView: PropTypes.func } state = { @@ -79,7 +77,7 @@ */ UNSAFE_componentWillMount () { const { menu } = this.props - + console.log(menu) let _LongParam = menu.LongParam let _config = '' @@ -91,6 +89,12 @@ } else { _config = _LongParam } + + // 閰嶇疆榛樿鍊硷紝鍏煎 + _config.tabs = _config.tabs || [] + _config.tabgroups = _config.tabgroups || ['tabs'] + _config.setting.subtabs = _config.setting.subtabs || [] + _config.Template = 'CommonTable' let _oriActions = [] if (_config.type === 'user') { @@ -106,14 +110,18 @@ } item.uuid = uuid - return item }) - } - _config.tabs = _config.tabs || [] - _config.tabgroups = _config.tabgroups || ['tabs'] - _config.setting.subtabs = _config.setting.subtabs || [] + // 閲嶇疆鏍囩ID + _config.tabgroups.forEach(group => { + _config[group] = _config[group].map(tab => { + tab.uuid = Utils.getuuid() + + return tab + }) + }) + } this.setState({ config: _config, @@ -438,7 +446,7 @@ { type: 'select', key: 'linkTab', - label: '鍏宠仈鏍囩', + label: this.state.dict['header.form.linkTab'], initVal: card.linkTab || '', required: false, options: [] @@ -469,7 +477,7 @@ { type: 'mutilselect', key: 'subtabs', - label: '涓嬬骇鏍囩', + label: this.state.dict['header.form.subTab'], initVal: subtabs, required: false, options: menus @@ -1271,7 +1279,7 @@ * @description 涓夌骇鑿滃崟鍒囨崲妯℃澘 */ changeTemplate = () => { - this.props.handleConfig('template') + this.props.handleView({tabview: 'template'}) } /** @@ -1579,7 +1587,7 @@ duration: 2 }) if (this.state.closeVisible) { - this.props.handleConfig('') + this.props.handleView() } else { this.setState({ menuloading: false, @@ -1620,7 +1628,7 @@ okText: this.state.dict['header.confirm'], cancelText: this.state.dict['header.cancel'], onOk() { - _this.props.handleConfig('') + _this.props.handleView() }, onCancel() {} }) @@ -1642,7 +1650,7 @@ closeVisible: true }) } else { - this.props.handleConfig('') + this.props.handleView() } }, () => { this.setState({ @@ -1973,25 +1981,14 @@ /** * @description 璁剧疆鍙厤缃寜閽� */ - setSubConfig = (btn, type) => { + setSubConfig = (item, type) => { const { menu } = this.props const { config, originMenu } = this.state - let isAdd = false - - if ( - (config.search[0] && config.search[0].origin) || - (config.action[0] && config.action[0].origin) || - (config.columns[0] && config.columns[0].origin) || - (config.tabs[0] && config.tabs[0].origin) - ) { - isAdd = true - } - - if (isAdd) { + if (!originMenu.MenuID) { // menuID涓嶅瓨鍦ㄦ椂锛屼负鏂板缓鑿滃崟锛屾彁绀鸿彍鍗曞皻鏈繚瀛� notification.warning({ top: 92, - message: '鑿滃崟灏氭湭淇濆瓨锛岃淇濆瓨鑿滃崟閰嶇疆锛�', + message: this.state.dict['header.menu.config.notsave'], duration: 10 }) } else { @@ -2007,74 +2004,88 @@ ParentID: res.parentId } - if (!is(fromJS(originMenu), fromJS(_originMenu))) { + if (!is(fromJS(originMenu), fromJS(_originMenu))) { // 鑿滃崟淇℃伅鍙樺寲鏃讹紝鎻愮ず淇濆瓨 notification.warning({ top: 92, - message: '鑿滃崟閰嶇疆宸蹭慨鏀癸紝璇蜂繚瀛橈紒', + message: this.state.dict['header.menu.config.update'], duration: 10 }) - } else { - this.setState({ - loading: true - }) - - let uuid = '' - let _type = type - if (type === 'button' && btn.OpenType === 'popview') { - _type = 'tab' - } else if (type === 'button' && (btn.OpenType === 'tab' || btn.OpenType === 'blank')) { - _type = 'tabview' - } - - if (_type === 'tab') { - uuid = btn.linkTab - } else { - uuid = btn.uuid - } - - Api.getSystemConfig({ - func: 'sPC_Get_LongParam', - MenuID: uuid - }).then(res => { - if (res.status) { - this.setState({ - loading: false - }) - let _LongParam = '' - if (res.LongParam) { - _LongParam = window.decodeURIComponent(window.atob(res.LongParam)) - try { - _LongParam = JSON.parse(_LongParam) - } catch (e) { - _LongParam = '' - } - } - - if (_type === 'tab' && !_LongParam) { - _LongParam = { - ...btn, - uuid: btn.linkTab, - create: true - } - } - - this.props.handleSubConfig(btn, originMenu, _LongParam, _type) - } else { - this.setState({ - loading: false - }) - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - } - }) + return } + console.log(item) + // 鑿滃崟淇℃伅楠岃瘉閫氳繃鍚庯紝璺宠浆瀛愰厤缃〉闈� + let _view = '' + let uuid = item.uuid + let isbutton = true + + if (type === 'button' && item.OpenType === 'pop') { + _view = 'Modal' // 琛ㄥ崟椤甸潰 + } else if (type === 'button' && (item.OpenType === 'tab' || item.OpenType === 'blank')) { + _view = item.tabTemplate // 鏂版爣绛鹃〉妯℃澘 + } else if (type === 'button' && item.OpenType === 'popview') { + _view = item.tabType // 鏂板脊绐楁爣绛炬ā鏉� + uuid = item.linkTab + isbutton = false + } else if (type === 'tab') { + _view = item.type // 鏍囩妯℃澘 + uuid = item.linkTab + isbutton = false + } + + let param = { + editMenu: _originMenu, + editTab: !isbutton ? item : '', + editAction: isbutton ? item : '', + subConfig: '', + tabview: _view + } + + this.setState({ + loading: true + }) + + Api.getSystemConfig({ + func: 'sPC_Get_LongParam', + MenuID: uuid + }).then(res => { + if (res.status) { + this.setState({ + loading: false + }) + let _LongParam = '' + if (res.LongParam) { + _LongParam = window.decodeURIComponent(window.atob(res.LongParam)) + try { + _LongParam = JSON.parse(_LongParam) + } catch (e) { + _LongParam = '' + } + } + + if (_LongParam && param.tabview === 'Modal' && _LongParam.type === 'Modal') { + param.subConfig = _LongParam + } else if (_LongParam && param.tabview === 'FormTab' && _LongParam.type === 'FormTab') { + param.subConfig = _LongParam + } else if (_LongParam && param.tabview === 'SubTable' && _LongParam.Template === 'SubTable') { + param.subConfig = _LongParam + } + + this.props.handleView(param) + } else { + this.setState({ + loading: false + }) + notification.warning({ + top: 92, + message: res.message, + duration: 10 + }) + } + }) }, () => { notification.warning({ top: 92, - message: '鑿滃崟鍩烘湰淇℃伅宸蹭慨鏀癸紝璇蜂繚瀛橈紒', + message: this.state.dict['header.menu.config.update'], duration: 10 }) }) @@ -2186,7 +2197,7 @@ } Api.getSystemConfig(_param) }) - this.props.handleConfig('') + this.props.handleView() } render () { -- Gitblit v1.8.0