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/modalconfig/index.jsx | 38 +++- src/api/index.js | 8 src/locales/zh-CN/comtable.js | 4 src/templates/comtableconfig/source.jsx | 1 src/components/sidemenu/editthdmenu/index.jsx | 128 ++++++++------- src/locales/en-US/comtable.js | 4 src/templates/comtableconfig/index.jsx | 193 ++++++++++++----------- src/templates/subtableconfig/index.jsx | 85 +++++----- 8 files changed, 252 insertions(+), 209 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index 062999d..cc854e2 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -26,10 +26,10 @@ }) const setCurrentUrl = () => { - // if (!!(window.history && window.history.pushState)) { - // window.history.replaceState(null, null, window.location.href.split('#')[0] + '#/login') - // window.location.reload() - // } + if (!!(window.history && window.history.pushState)) { + window.history.replaceState(null, null, window.location.href.split('#')[0] + '#/login') + window.location.reload() + } } let GlobMap = new Map() diff --git a/src/components/sidemenu/editthdmenu/index.jsx b/src/components/sidemenu/editthdmenu/index.jsx index 65d02ee..de89cd2 100644 --- a/src/components/sidemenu/editthdmenu/index.jsx +++ b/src/components/sidemenu/editthdmenu/index.jsx @@ -41,23 +41,24 @@ state = { dict: (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS, - thawmenulist: null, // 宸插喕缁撶殑浜岀骇鑿滃崟 - type: '', // 鎿嶄綔绫诲瀷锛屾柊寤烘垨缂栬緫鑿滃崟 - tabview: '', // 閫夋嫨妯℃澘绐楀彛锛坱emplate锛夈�佸熀纭�琛ㄦ牸閰嶇疆锛圕ommonTable锛夈�佽〃鍗曪紙Modal锛夈�佸瓙琛紙SubTable锛� - editMenu: null, // 缂栬緫鑿滃崟 - editAction: null, // 缂栬緫鎸夐挳 - editTab: null, // 缂栬緫鏍囩 - thawMvisible: false, // 瑙i櫎鍐荤粨妯℃�佹 - confirmLoading: false, // 鎻愪氦涓�傘�傘�� - selectTemp: '', // 閫夋嫨妯℃澘 - usedTemplates: null, // 宸蹭娇鐢ㄦā鏉垮垪琛� - tempSearchKey: '', // 鑿滃崟鍚嶇О杩囨护鍊� - loading: false, // 缂栬緫鑿滃崟鎴栦娇鐢ㄥ凡浣跨敤妯℃澘鏃讹紝鑾峰彇閰嶇疆淇℃伅 - preview: null, // 鍥剧墖棰勮url - pretemplate: null, // 棰勮妯℃澘 - btnParam: null, // 缂栬緫鎸夐挳鐨勯厤缃俊鎭� - menulist: null, // 缂栬緫涓殑鑿滃崟 - sysTemplates: sysTemps // 绯荤粺妯℃澘 + thawmenulist: null, // 宸插喕缁撶殑浜岀骇鑿滃崟 + type: '', // 鎿嶄綔绫诲瀷锛屾柊寤烘垨缂栬緫鑿滃崟 + thawMvisible: false, // 瑙i櫎鍐荤粨妯℃�佹 + confirmLoading: false, // 鎻愪氦涓�傘�傘�� + selectTemp: '', // 閫夋嫨妯℃澘 + usedTemplates: null, // 宸蹭娇鐢ㄦā鏉垮垪琛� + tempSearchKey: '', // 鑿滃崟鍚嶇О杩囨护鍊� + loading: false, // 缂栬緫鑿滃崟鎴栦娇鐢ㄥ凡浣跨敤妯℃澘鏃讹紝鑾峰彇閰嶇疆淇℃伅 + preview: null, // 鍥剧墖棰勮url + pretemplate: null, // 棰勮妯℃澘 + btnParam: null, // 缂栬緫鎸夐挳鐨勯厤缃俊鎭� + menulist: null, // 缂栬緫涓殑鑿滃崟 + sysTemplates: sysTemps, // 绯荤粺妯℃澘 + tabview: '', // 閫夋嫨妯℃澘绐楀彛锛坱emplate锛夈�佸熀纭�琛ㄦ牸閰嶇疆锛圕ommonTable锛夈�佽〃鍗曪紙Modal锛夈�佸瓙琛紙SubTable锛� + editMenu: null, // 缂栬緫鑿滃崟 + editAction: null, // 缂栬緫鎸夐挳 + editTab: null, // 缂栬緫鏍囩 + subConfig: null // 瀛愰厤缃俊鎭� } /** @@ -177,7 +178,19 @@ }) return } - this.setState({tabview: 'template', type: 'add'}) + this.setState({ + tabview: 'template', + editMenu: { + MenuID: '', + MenuName: '', + MenuNo: '', + type: '', + PageParam: '', + LongParam: '', + isSubtable: '', // 鏄惁涓轰富瀛愯〃 + ParentID: this.props.supMenu.MenuID + } + }) document.getElementById('root').style.overflowY = 'hidden' } else if (type === 'thaw') { if (!is(fromJS(this.props.menulist), fromJS(this.state.menulist))) { @@ -325,8 +338,13 @@ }) } + /** + * @description 浣跨敤妯℃澘 + * 1銆佷娇鐢ㄧ郴缁熸ā鏉挎椂锛屼娇鐢ㄧ郴缁熼厤缃� + * 2銆佷娇鐢ㄥ凡鏈夎彍鍗曟ā鏉挎椂锛岃幏鍙栬彍鍗曢厤缃俊鎭紝鏍囪涓簎ser锛堝鍒惰彍鍗曟寜閽級 + */ useTemplate = (template, useType) => { - const { type, editMenu } = this.state + const { editMenu } = this.state new Promise(resolve => { if (useType === 'sys') { @@ -375,41 +393,30 @@ }) } }).then(res => { - if (!res) { + if (!res) { // 閿欒鏃讹紝閲嶇疆鐘舵�� this.setState({ loading: false }) return } - // 閫夋嫨妯℃澘锛氭坊鍔犺彍鍗曟椂 - if (type === 'add') { - this.setState({ - tabview: template.type, - loading: false, - editMenu: { - MenuID: Utils.getuuid(), - MenuName: '', - MenuNo: '', - id: this.props.menulist.length, - src: '', - text: '', - type: template.type, - PageParam: {OpenType: 'newtab', Template: template.type}, - LongParam: template.baseconfig, - isSubtable: template.isSubtable, // 鏄惁涓轰富瀛愯〃 - ParentID: this.props.supMenu.MenuID - } - }) - } else { - let _PageParam = {OpenType: editMenu.PageParam.OpenType || 'newtab', Template: template.type} - - this.setState({ - loading: false, - tabview: template.type, - editMenu: {...editMenu, LongParam: template.baseconfig, PageParam: _PageParam, type: template.type} - }) + // 閫夋嫨妯℃澘锛氭坊鍔犺彍鍗曟椂(涓嶅瓨鍦╩enuId) + let _PageParam = { + OpenType: editMenu.PageParam ? editMenu.PageParam.OpenType : 'newtab', + Template: template.type } + + this.setState({ + loading: false, + tabview: template.type, + editMenu: { + ...editMenu, + type: template.type, + PageParam: _PageParam, + LongParam: template.baseconfig, + isSubtable: template.isSubtable + } + }) document.getElementById('root').style.overflowY = 'hidden' }) } @@ -444,8 +451,17 @@ } } - tabHandleConfig = () => { - + handleView = (param) => { + this.setState({ + tabview: '' + }, () => { + if (param) { + this.setState(param) + document.getElementById('root').style.overflowY = 'hidden' + } else { + document.getElementById('root').style.overflowY = 'unset' + } + }) } handleSubConfig = (item, originMenu, config, type) => { @@ -636,12 +652,10 @@ </div>} {this.state.tabview === 'CommonTable' && <ComTableConfig - type={this.state.type} menu={this.state.editMenu} supMenuList={this.props.supMenuList} - handleConfig={this.handleConfig} reloadmenu={() => {this.props.reload()}} - handleSubConfig={this.handleSubConfig} + handleView={this.handleView} /> } {this.state.tabview === 'Modal' && @@ -649,16 +663,16 @@ menu={this.state.editMenu} editTab={this.state.editTab} editAction={this.state.editAction} - btnParam={this.state.btnParam} - handleConfig={this.handleConfig} + subConfig={this.state.subConfig} + handleView={this.handleView} /> } {this.state.tabview === 'SubTable' && <SubTable - config={this.state.editTab} menu={this.state.editMenu} - handleConfig={this.handleConfig} - handleSubConfig={this.handleSubConfig} + editTab={this.state.editTab} + config={this.state.subConfig} + handleView={this.handleView} /> } {this.state.tabview === 'FormTab' && diff --git a/src/locales/en-US/comtable.js b/src/locales/en-US/comtable.js index 19881e4..f332d0c 100644 --- a/src/locales/en-US/comtable.js +++ b/src/locales/en-US/comtable.js @@ -17,6 +17,8 @@ 'header.menu.table.add': 'Add tables', 'header.menu.table.placeholder': 'Please select a table', 'header.menu.config.placeholder': 'Configuration has been modified, do you want to save configuration information ?', + 'header.menu.config.notsave': '鑿滃崟灏氭湭淇濆瓨锛岃淇濆瓨鑿滃崟閰嶇疆锛�', + 'header.menu.config.update': '鑿滃崟閰嶇疆宸蹭慨鏀癸紝璇蜂繚瀛橈紒', 'header.menu.form': 'The form', 'header.menu.form.add': 'Add form', 'header.menu.form.configurable': 'Configuration of forms', @@ -116,6 +118,8 @@ 'header.form.popform': '寮圭獥锛堣〃鍗曪級', 'header.form.popview': '寮圭獥锛堥〉闈級', 'header.form.tab': '鏍囩椤�', + 'header.form.linkTab': '鍏宠仈鏍囩', + 'header.form.subTab': '涓嬬骇鏍囩', 'header.form.currenttab': '褰撳墠鑿滃崟', 'header.form.excelIn': 'Excel瀵煎叆', 'header.form.excelOut': 'Excel瀵煎嚭', diff --git a/src/locales/zh-CN/comtable.js b/src/locales/zh-CN/comtable.js index b5f9cd9..3accb74 100644 --- a/src/locales/zh-CN/comtable.js +++ b/src/locales/zh-CN/comtable.js @@ -17,6 +17,8 @@ 'header.menu.table.add': '娣诲姞琛ㄥ悕', 'header.menu.table.placeholder': '璇烽�夋嫨琛ㄥ悕', 'header.menu.config.placeholder': '閰嶇疆宸蹭慨鏀癸紝鏄惁淇濆瓨閰嶇疆淇℃伅锛�', + 'header.menu.config.notsave': '鑿滃崟灏氭湭淇濆瓨锛岃淇濆瓨鑿滃崟閰嶇疆锛�', + 'header.menu.config.update': '鑿滃崟閰嶇疆宸蹭慨鏀癸紝璇蜂繚瀛橈紒', 'header.menu.form': '琛ㄥ崟', 'header.menu.form.add': '娣诲姞琛ㄥ崟', 'header.menu.form.configurable': '琛ㄥ崟閰嶇疆', @@ -116,6 +118,8 @@ 'header.form.popform': '寮圭獥锛堣〃鍗曪級', 'header.form.popview': '寮圭獥锛堥〉闈級', 'header.form.tab': '鏍囩椤�', + 'header.form.linkTab': '鍏宠仈鏍囩', + 'header.form.subTab': '涓嬬骇鏍囩', 'header.form.currenttab': '褰撳墠鑿滃崟', 'header.form.excelIn': '瀵煎叆Excel', 'header.form.excelOut': '瀵煎嚭Excel', 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 () { diff --git a/src/templates/comtableconfig/source.jsx b/src/templates/comtableconfig/source.jsx index 4e35dcc..709cbf0 100644 --- a/src/templates/comtableconfig/source.jsx +++ b/src/templates/comtableconfig/source.jsx @@ -7,6 +7,7 @@ class CommonTableBaseData { baseConfig = { type: 'system', + Template: 'CommonTable', enabled: false, setting: { actionfixed: false, diff --git a/src/templates/modalconfig/index.jsx b/src/templates/modalconfig/index.jsx index 56e6cd4..c31c27e 100644 --- a/src/templates/modalconfig/index.jsx +++ b/src/templates/modalconfig/index.jsx @@ -28,9 +28,9 @@ static propTpyes = { menu: PropTypes.any, editTab: PropTypes.any, - btnParam: PropTypes.object, + subConfig: PropTypes.any, editAction: PropTypes.object, - handleConfig: PropTypes.func + handleView: PropTypes.func } state = { @@ -64,10 +64,10 @@ * 4銆佽缃寜閽熀鏈俊鎭� */ UNSAFE_componentWillMount () { - const {menu, editAction, editTab, btnParam} = this.props + const {menu, editAction, editTab, subConfig} = this.props let _config = '' - let _menu = { + let _menu = { // 涓婄骇鑿滃崟鏄笁绾ц彍鍗曟垨鏍囩椤� type: editTab ? editTab.Template : menu.type, tables: editTab ? editTab.tables : menu.LongParam.tables, MenuID: editTab ? editTab.uuid : menu.MenuID, @@ -75,8 +75,8 @@ MenuName: editTab ? editTab.tabName : menu.MenuName } - if (btnParam) { - _config = btnParam + if (subConfig) { + _config = subConfig } else { _config = JSON.parse(JSON.stringify((Source.baseConfig))) } @@ -208,9 +208,23 @@ * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 */ componentWillUnmount () { - this.setState = (state, callback) => { + this.setState = () => { return } + } + + // 椤甸潰杩斿洖 + handleViewBack = () => { + const {menu, editTab} = this.props + let param = { + editMenu: menu, + editTab: editTab, + editAction: '', + subConfig: '', + tabview: editTab ? editTab.Template : menu.LongParam.Template + } + + this.props.handleView(param) } /** @@ -733,7 +747,7 @@ } cancelConfig = () => { - const { menu, config, originConfig } = this.state + const { config, originConfig } = this.state let _this = this let isOrigin = config.fields.filter(item => item.origin).length > 0 @@ -743,7 +757,7 @@ okText: this.state.dict['header.confirm'], cancelText: this.state.dict['header.cancel'], onOk() { - _this.props.handleConfig(menu.type) + _this.handleViewBack() }, onCancel() {} }) @@ -754,7 +768,7 @@ closeVisible: true }) } else { - this.props.handleConfig(menu.type) + this.handleViewBack() } } } @@ -1138,7 +1152,7 @@ } render () { - const { menu, config } = this.state + const { config } = this.state return ( <div className="modal-form-board"> @@ -1313,7 +1327,7 @@ onCancel={() => { this.setState({closeVisible: false}) }} footer={[ <Button key="save" className="mk-btn mk-green" loading={this.state.closeloading} onClick={this.submitConfig}>{this.state.dict['header.save']}</Button>, - <Button key="confirm" className="mk-btn mk-yellow" onClick={() => {this.props.handleConfig(menu.type)}}>{this.state.dict['header.notsave']}</Button>, + <Button key="confirm" className="mk-btn mk-yellow" onClick={this.handleViewBack}>{this.state.dict['header.notsave']}</Button>, <Button key="cancel" onClick={() => { this.setState({closeVisible: false}) }}>{this.state.dict['header.cancel']}</Button> ]} destroyOnClose diff --git a/src/templates/subtableconfig/index.jsx b/src/templates/subtableconfig/index.jsx index 7877567..f9863eb 100644 --- a/src/templates/subtableconfig/index.jsx +++ b/src/templates/subtableconfig/index.jsx @@ -34,9 +34,9 @@ class SubTableConfig extends Component { static propTpyes = { - config: PropTypes.object, menu: PropTypes.any, - handleConfig: PropTypes.func, + editTab: PropTypes.any, + config: PropTypes.any, handleSubConfig: PropTypes.func, supMenuList: PropTypes.array } @@ -78,25 +78,24 @@ * 2銆佽缃搷浣滅被鍨嬨�佸師濮嬭彍鍗曚俊鎭紙姣忔淇濆瓨鍚庨噸缃級銆佸凡浣跨敤琛ㄥ強鍩烘湰淇℃伅琛ㄥ崟 */ UNSAFE_componentWillMount () { - const { config } = this.props + const { config, editTab } = this.props let _config = null - if (!config || config.create) { + if (!config) { _config = JSON.parse(JSON.stringify(Source.baseConfig)) - if (config.uuid) { - _config.uuid = config.uuid - _config.tabName = config.label - } + _config.uuid = editTab.linkTab + _config.tabName = editTab.label + _config.isAdd = true } else { _config = JSON.parse(JSON.stringify(config)) } let _oriActions = [] + if (_config.type === 'user') { _config.action = _config.action.map(item => { let uuid = Utils.getuuid() - if (item.OpenType === 'pop') { // 鍚湁瀛愰厤缃」鐨勬寜閽� _oriActions.push({ prebtn: JSON.parse(JSON.stringify(item)), @@ -106,7 +105,6 @@ } item.uuid = uuid - return item }) } @@ -267,6 +265,20 @@ this.setState = (state, callback) => { return } + } + + // 椤甸潰杩斿洖 + handleViewBack = () => { + const {menu} = this.props + let param = { + editMenu: menu, + editTab: '', + editAction: '', + subConfig: '', + tabview: menu ? menu.LongParam.Template : '' + } + + this.props.handleView(param) } /** @@ -1081,27 +1093,25 @@ }) } - // changeTemplate = () => { - // this.props.handleConfig('template') - // } - /** * @description 鏍囩椤典繚瀛� */ submitConfig = () => { - const { delActions } = this.state + const { delActions, originConfig } = this.state let config = JSON.parse(JSON.stringify(this.state.config)) this.menuformRef.handleConfirm().then(res => { - if (config.search[0] && config.search[0].origin) { - config.search = config.search.filter(item => !item.origin) - } - if (config.action[0] && config.action[0].origin) { - config.action = config.action.filter(item => !item.origin) - } - if (config.columns[0] && config.columns[0].origin) { - config.columns = config.columns.filter(item => !item.origin) + if (originConfig.isAdd) { + if (config.search[0] && config.search[0].origin) { + config.search = config.search.filter(item => !item.origin) + } + if (config.action[0] && config.action[0].origin) { + config.action = config.action.filter(item => !item.origin) + } + if (config.columns[0] && config.columns[0].origin) { + config.columns = config.columns.filter(item => !item.origin) + } } let _LongParam = '' @@ -1109,6 +1119,7 @@ // 淇濆瓨鏃跺垹闄ら厤缃被鍨嬶紝system 銆乽ser delete _config.type + delete _config.isAdd try { _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config))) @@ -1123,6 +1134,7 @@ let btnParam = { func: 'sPC_Button_AddUpt', + Type: 40, ParentID: _config.uuid, MenuNo: res.tabNo, Template: 'SubTable', @@ -1323,8 +1335,7 @@ duration: 2 }) if (this.state.closeVisible) { - let view = this.props.menu ? this.props.menu.type : '' - this.props.handleConfig(view) + this.handleViewBack() } else { this.setState({ menuloading: false, @@ -1344,24 +1355,14 @@ const { config, originConfig } = this.state let _this = this - 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) - ) { - isAdd = true - } - - if (isAdd) { + if (originConfig.isAdd) { confirm({ content: '鑿滃崟灏氭湭鎻愪氦锛岀‘瀹氭斁寮冧繚瀛樺悧锛�', okText: this.state.dict['header.confirm'], cancelText: this.state.dict['header.cancel'], onOk() { - let view = _this.props.menu ? _this.props.menu.type : '' - _this.props.handleConfig(view) + _this.handleViewBack() }, onCancel() {} }) @@ -1374,8 +1375,7 @@ closeVisible: true }) } else { - let view = this.props.menu ? this.props.menu.type : '' - this.props.handleConfig(view) + this.handleViewBack() } }, () => { this.setState({ @@ -1781,11 +1781,6 @@ }) } - dontsave = () => { - let view = this.props.menu ? this.props.menu.type : '' - this.props.handleConfig(view) - } - render () { const { modaltype } = this.state const configAction = this.state.config.action.filter(_action => @@ -2105,7 +2100,7 @@ onCancel={() => { this.setState({closeVisible: false}) }} footer={[ <Button key="save" className="mk-btn mk-green" loading={this.state.menucloseloading} onClick={this.submitConfig}>{this.state.dict['header.save']}</Button>, - <Button key="confirm" className="mk-btn mk-yellow" onClick={this.dontsave}>{this.state.dict['header.notsave']}</Button>, + <Button key="confirm" className="mk-btn mk-yellow" onClick={this.handleViewBack}>{this.state.dict['header.notsave']}</Button>, <Button key="cancel" onClick={() => { this.setState({closeVisible: false}) }}>{this.state.dict['header.cancel']}</Button> ]} destroyOnClose -- Gitblit v1.8.0