From f8c3c53f9e29541f8c0e3fcbf682c301fd17e06a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 23 十一月 2020 17:49:23 +0800 Subject: [PATCH] 2020-11-23 --- src/templates/menuconfig/editfirstmenu/menuform/index.jsx | 78 + src/templates/menuconfig/editfirstmenu/menuform/index.scss | 0 src/templates/menuconfig/editfirstmenu/dragelement/itemtypes.js | 0 src/components/header/index.jsx | 515 ++++++----- src/menu/actioncomponent/actionform/index.jsx | 56 - src/menu/actioncomponent/index.jsx | 90 - src/views/menudesign/homeform/index.jsx | 19 src/views/menudesign/menuform/index.jsx | 104 +- src/views/menudesign/printmenuform/index.jsx | 20 src/templates/menuconfig/editfirstmenu/dragelement/index.jsx | 25 src/templates/sharecomponent/columncomponent/index.jsx | 88 - src/store/action.js | 12 src/templates/menuconfig/editthdmenu/index.jsx | 143 -- src/views/billprint/index.jsx | 118 +- src/components/sidemenu/config.jsx | 491 +++++------ src/templates/menuconfig/editfirstmenu/dragelement/card.jsx | 6 src/utils/utils.js | 4 src/components/header/index.scss | 8 src/tabviews/custom/components/card/cardcellList/index.jsx | 4 src/templates/comtableconfig/menuform/index.jsx | 6 src/tabviews/custom/components/share/tabtransfer/index.jsx | 9 src/menu/components/card/cardcellcomponent/index.jsx | 91 - src/store/reducer.js | 28 src/templates/sharecomponent/actioncomponent/actionform/index.jsx | 59 - src/store/action-type.js | 3 src/templates/menuconfig/editfirstmenu/index.jsx | 34 src/templates/menuconfig/menuform/index.jsx | 4 src/templates/menuconfig/editfirstmenu/index.scss | 0 src/templates/menuconfig/editfirstmenu/dragelement/index.scss | 6 src/templates/menuconfig/menuelement/card.jsx | 6 src/templates/menuconfig/editsecmenu/index.jsx | 37 src/templates/sharecomponent/actioncomponent/index.jsx | 83 - src/tabviews/custom/index.jsx | 11 src/templates/menuconfig/editthdmenu/menuform/index.jsx | 12 src/menu/components/card/data-card/wrapsetting/settingform/index.jsx | 4 src/templates/menuconfig/menuelement/index.jsx | 6 src/components/sidemenu/index.jsx | 328 +++---- src/templates/sharecomponent/columncomponent/columnform/index.jsx | 56 - 38 files changed, 1,076 insertions(+), 1,488 deletions(-) diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx index 61d8f47..7d2eb82 100644 --- a/src/components/header/index.jsx +++ b/src/components/header/index.jsx @@ -9,6 +9,7 @@ import asyncComponent from '@/utils/asyncComponent' import { toggleCollapse, + modifyMenuTree, modifyMainMenu, modifyTabview, resetState, @@ -30,17 +31,13 @@ import LoginForm from './loginform' import './index.scss' -const EditMenu = asyncComponent(() => import('@/templates/headerconfig')) +const EditMenu = asyncComponent(() => import('@/templates/menuconfig/editfirstmenu')) const { confirm } = Modal const { Search } = Input class Header extends Component { static propTpyes = { - collapse: PropTypes.bool, - mainMenu: PropTypes.oneOfType([ - PropTypes.string, - PropTypes.object - ]) + collapse: PropTypes.bool } state = { menulist: null, // 涓�绾ц彍鍗� @@ -51,7 +48,7 @@ logourl: window.GLOB.mainlogo, loginVisible: false, loginLoading: false, - avatar: avatar, + avatar: Utils.getrealurl(sessionStorage.getItem('avatar')), systems: [], searchkey: '', thdMenuList: [], @@ -79,42 +76,37 @@ this.setState({ confirmLoading: true }) - this.resetPwdSubmitexec(res) + + let _param = { + func: 's_PwdUpt', + LText: `select '${res.originpwd}','${res.password}'` + } + + _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') // 鏃堕棿鎴� + _param.LText = Utils.formatOptions(_param.LText) // 鍏抽敭瀛楃鏇挎崲锛宐ase64鍔犲瘑 + _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) // md5瀵嗛挜 + + Api.getSystemConfig(_param).then(result => { + this.setState({ + visible: !result.status, + confirmLoading: false + }) + + if (result.status) { + notification.success({ + top: 92, + message: this.state.dict['main.password.resetsuccess'], + duration: 2 + }) + } else { + notification.warning({ + top: 92, + message: result.message, + duration: 5 + }) + } + }) }, () => {}) - } - - async resetPwdSubmitexec (param) { - let _param = { - func: 's_PwdUpt', - LText: `select '${param.originpwd}','${param.password}'` - } - - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') // 鏃堕棿鎴� - _param.LText = Utils.formatOptions(_param.LText) // 鍏抽敭瀛楃鏇挎崲锛宐ase64鍔犲瘑 - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) // md5瀵嗛挜 - - let result = await Api.getSystemConfig(_param) // 鍙栨秷淇敼鏈湴瀵嗙爜锛屽彧淇敼鍗曠偣鏈嶅姟鍣� - - if (result.status) { - this.setState({ - visible: false, - confirmLoading: false - }) - notification.success({ - top: 92, - message: this.state.dict['main.password.resetsuccess'], - duration: 2 - }) - } else { - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - this.setState({ - confirmLoading: false - }) - } } handleCancel = () => { @@ -154,13 +146,14 @@ async loadmenu () { // 鑾峰彇涓昏彍鍗� - let _param = {func: 'sPC_Get_MainMenu', systemType: options.sysType} - if (sessionStorage.getItem('isEditState') === 'true') { // 缂栬緫鐘舵�佹椂锛岃幏鍙栦竴绾ц彍鍗曪紝澧炲姞鍙傛暟debug + let _param = {func: 's_get_pc_menus', systemType: options.sysType} + if (sessionStorage.getItem('isEditState') === 'true') { // 缂栬緫鐘舵�佹椂锛屽鍔犲弬鏁癲ebug _param.debug = 'Y' } if (options.sysType !== 'cloud' && window.GLOB.systemType !== 'production') { _param.linkurl = window.GLOB.linkurl } + _param.pro_sys = window.GLOB.systemType === 'production' ? 'Y' : '' let result = await Api.getSystemConfig(_param) @@ -168,33 +161,15 @@ if (!result) return if (result.status) { - let MainMenuId = sessionStorage.getItem('MainMenu') // 鏄惁涓烘墦寮�鏂伴〉闈� - if (MainMenuId) { - // 閫氳繃url涓璵enuid绛涢�夊嚭閫変腑鐨勪富鑿滃崟 - let _menu = result.data.filter(item => item.MenuID === MainMenuId)[0] - sessionStorage.removeItem('MainMenu') - this.props.modifyMainMenu(_menu || result.data[0]) - } else { - this.props.modifyMainMenu(result.data[0]) - } + let res = this.getMenulist(result) this.setState({ - menulist: result.data.map((item, index) => { - item.id = index - item.text = item.MenuName - if (item.PageParam) { - try { - item.PageParam = JSON.parse(item.PageParam) - } catch (e) { - item.PageParam = {OpenType: 'menu', linkUrl: ''} - } - } else { - item.PageParam = {OpenType: 'menu', linkUrl: ''} - } - return item - }), - systems: sessionStorage.getItem('isEditState') === 'true' ? [] : result.Systems.filter(sys => sys.LinkUrl1 && sys.AppName && sys.AppKey !== window.GLOB.appkey) + menulist: res.menulist, + systems: [] }) + + this.props.modifyMenuTree(res.menulist) + this.props.modifyMainMenu(res.menulist[0] || null) } else { notification.error({ top: 92, @@ -204,13 +179,16 @@ } } - async getRolesMenu () { + getRolesMenu () { // 鑾峰彇瑙掕壊鏉冮檺 - let promiseRole = new Promise(resolve => { - Api.getSystemConfig({func: 's_Get_TrdMenu_Role', edition_type: 'Y'}).then(result => { + let roledefer = new Promise(resolve => { + // edition_type 鎺ュ彛鐗堟湰鎺у埗 ''銆�'Y'銆�'A' + Api.getSystemConfig({ + func: 's_Get_TrdMenu_Role', + edition_type: 'A', + pro_sys: window.GLOB.systemType === 'production' ? 'Y' : '' + }).then(result => { let _permAction = {} // 鎸夐挳鏉冮檺 - let _permMenus = {} // 鑿滃崟鏉冮檺锛屽瓧娈甸�忚绛� - let menulist = [] // 涓夌骇鑿滃崟鍒楄〃 if (result && result.status) { if (result.UserRoles_Menu) { @@ -219,54 +197,6 @@ _permAction[menu.MenuID] = true }) } - - if (result.UserRoles) { - let iframes = ['Main/Index', 'bda/rdt', 'Home/rdt'] - let menukeys = [] - - result.UserRoles.forEach(menu => { - if (!menu.MenuID) return - if (menukeys.includes(menu.MenuID)) { - console.warn('s_Get_TrdMenu_Role閲嶅鐨勮彍鍗旾D锛�' + menu.MenuID) - return - } - _permMenus[menu.MenuID] = true - - let _type = '' - if (menu.LinkUrl === 'CommonTable') { - _type = 'CommonTable' - } else if (menu.LinkUrl && iframes.includes(menu.LinkUrl.split('?')[0])) { - _type = 'iframe' - } - - if (_type !== 'iframe') { - let pageParam = {} - try { - pageParam = JSON.parse(menu.PageParam) - } catch (e) { - pageParam = {} - } - _type = pageParam.Template || _type - } - - menukeys.push(menu.MenuID) - - menulist.push({ - MenuID: menu.MenuID, - MenuName: menu.MenuName, - MenuNo: menu.MenuNo || '', - EasyCode: menu.EasyCode || '', - LinkUrl: menu.LinkUrl, - type: _type - }) - }) - } - - this.setState({ - thdMenuList: menulist - }) - - this.props.initMenuPermission(_permMenus) } else if (result) { notification.error({ top: 92, @@ -275,79 +205,207 @@ }) } - resolve(_permAction) + this.props.initActionPermission(_permAction) + resolve() }) }) // 鑾峰彇涓昏彍鍗曞弬鏁� - let promiseMenu = new Promise(resolve => { - let _param = {func: 'sPC_Get_MainMenu', systemType: options.sysType} + let menudefer = new Promise(resolve => { + let _param = {func: 's_get_pc_menus', systemType: options.sysType} if (options.sysType !== 'cloud' && window.GLOB.systemType !== 'production') { _param.linkurl = window.GLOB.linkurl } - + _param.pro_sys = window.GLOB.systemType === 'production' ? 'Y' : '' + Api.getSystemConfig(_param).then(result => { - let mainMenu = null - if (result && result.status) { - let MainMenuId = sessionStorage.getItem('MainMenu') // 鏄惁涓烘墦寮�鏂伴〉闈� - if (MainMenuId) { - // 閫氳繃url涓璵enuid绛涢�夊嚭閫変腑鐨勪富鑿滃崟 - let _menu = result.data.filter(item => item.MenuID === MainMenuId)[0] - sessionStorage.removeItem('MainMenu') - mainMenu = _menu || result.data[0] - } else { - mainMenu = result.data[0] - } - - this.setState({ - menulist: result.data.map((item, index) => { - item.id = index - item.text = item.MenuName - if (item.PageParam) { - try { - item.PageParam = JSON.parse(item.PageParam) - } catch (e) { - item.PageParam = {OpenType: 'menu', linkUrl: ''} - } - } else { - item.PageParam = {OpenType: 'menu', linkUrl: ''} - } - return item - }), - systems: result.Systems.filter(sys => sys.LinkUrl1 && sys.AppName && sys.AppKey !== window.GLOB.appkey) - }) - } else if (result) { + if (!result.status || !result.fst_menu) { notification.error({ top: 92, - message: result.message, + message: result.message || '鏈煡璇㈠埌鑿滃崟淇℃伅锛�', duration: 10 }) + return } - resolve(mainMenu) + let res = this.getMenulist(result) + + this.setState({ + menulist: res.menulist, + thdMenuList: res.thdMenuList, + systems: window.GLOB.systemType === 'production' || options.sysType === 'SSO' ? (result.sys_list || []) : [] + }) + + let mainMenu = res.menulist[0] || null + let _menu = null + + if (sessionStorage.getItem('ThirdMenu')) { // 鏄惁涓烘墦寮�鏂伴〉闈� + let ThirdMenuId = sessionStorage.getItem('ThirdMenu') + _menu = res.thdMenuList.filter(item => item.MenuID === ThirdMenuId)[0] // 閫氳繃url涓璵enuid绛涢�夊嚭閫変腑鐨勪富鑿滃崟 + + if (_menu) { + mainMenu = res.menulist.filter(item => item.MenuID === _menu.FstId)[0] + mainMenu = fromJS(mainMenu).toJS() + mainMenu.openId = _menu.ParentId + } + + sessionStorage.removeItem('ThirdMenu') + } + + this.props.modifyMenuTree(res.menulist) + this.props.modifyMainMenu(mainMenu) + this.props.initMenuPermission(res.permMenus) + + resolve(_menu) }) }) - let _mainMenu = await promiseMenu - if (_mainMenu) { - this.props.modifyMainMenu(_mainMenu) - } + Promise.all([roledefer, menudefer]).then(response => { + if (response[1]) { + let tabs = fromJS(this.props.tabviews).toJS() + let menu = fromJS(response[1]).toJS() - let permAction = await promiseRole + tabs = tabs.map(tab => { + tab.selected = false + return tab + }) - this.props.initActionPermission(permAction) + menu.selected = true + tabs.push(menu) + this.props.modifyTabview(tabs) + } + }) + } + + getMenulist = (result) => { + let thdMenuList = [] + let permMenus = {} + let iframes = ['Main/Index', 'bda/rdt', 'Home/rdt'] + let menulist = result.fst_menu.map(fst => { + let fstItem = { + MenuID: fst.MenuID, + MenuName: fst.MenuName, + PageParam: {OpenType: 'menu', linkUrl: ''}, + children: [] + } + if (fst.PageParam) { + try { + fstItem.PageParam = JSON.parse(fst.PageParam) + } catch (e) { + fstItem.PageParam = {OpenType: 'menu', linkUrl: ''} + } + } + + if (fst.snd_menu) { + fstItem.children = fst.snd_menu.map(snd => { + let sndItem = { + ParentId: fst.MenuID, + MenuID: snd.MenuID, + MenuName: snd.MenuName, + PageParam: {Icon: 'folder'}, + children: [] + } + + if (snd.PageParam) { + try { + sndItem.PageParam = JSON.parse(snd.PageParam) + } catch (e) { + sndItem.PageParam = {Icon: 'folder'} + } + } + + let msg = { + UserID: sessionStorage.getItem('UserID'), + LoginUID: sessionStorage.getItem('LoginUID'), + User_Name: sessionStorage.getItem('User_Name'), + Full_Name: sessionStorage.getItem('Full_Name'), + Member_Level: sessionStorage.getItem('Member_Level'), + dataM: sessionStorage.getItem('dataM'), + avatar: sessionStorage.getItem('avatar'), + debug: sessionStorage.getItem('debug'), + role_id: sessionStorage.getItem('role_id'), + mainlogo: window.GLOB.mainlogo, + mstyle: window.GLOB.style + } + + if (snd.trd_menu) { + sndItem.children = snd.trd_menu.map(trd => { + let trdItem = { + FstId: fst.MenuID, + ParentId: snd.MenuID, + MenuID: trd.MenuID, + MenuName: trd.MenuName, + MenuNo: trd.MenuNo, + EasyCode: trd.EasyCode, + type: 'CommonTable', // 榛樿鍊间负甯哥敤琛� + OpenType: 'newtab' // 鎵撳紑鏂瑰紡 + } + + if (trd.LinkUrl && iframes.includes(trd.LinkUrl.split('?')[0])) { + trdItem.type = 'iframe' + trdItem.LinkUrl = trd.LinkUrl + trdItem.forbidden = true + } else { + try { + trdItem.PageParam = trd.PageParam ? JSON.parse(trd.PageParam) : {OpenType: 'newtab'} + } catch (e) { + trdItem.PageParam = {OpenType: 'newtab'} + } + + trdItem.type = trdItem.PageParam.Template || trdItem.type + trdItem.OpenType = trdItem.PageParam.OpenType || trdItem.OpenType + + if (trdItem.type === 'CustomPage' && this.props.memberLevel < 20) { // 浼氬憳绛夌骇澶т簬绛変簬20鏃讹紝鏈夌紪杈戞潈闄� + trdItem.forbidden = true + } + if (trdItem.type === 'NewPage') { + trdItem.src = trdItem.PageParam.url || '' + + if (trdItem.src.indexOf('paramsmain/') > -1) { + try { + let _url = trdItem.src.split('paramsmain/')[0] + 'paramsmain/' + let _param = JSON.parse(window.decodeURIComponent(window.atob(trdItem.src.split('paramsmain/')[1]))) + _param.UserID = sessionStorage.getItem('UserID') + _param.LoginUID = sessionStorage.getItem('LoginUID') + _param.User_Name = sessionStorage.getItem('User_Name') + _param.Full_Name = sessionStorage.getItem('Full_Name') + + trdItem.src = _url + window.btoa(window.encodeURIComponent(JSON.stringify(_param))) + } catch { + console.warn('鑿滃崟鍙傛暟瑙f瀽閿欒锛�') + } + } + } else { + // 鎵撳紑鏂伴〉闈㈤摼鎺� + trdItem.src = '#/paramsmain/' + window.btoa(window.encodeURIComponent(JSON.stringify({ + ...msg, + ThirdMenu: trd.MenuID + }))) + } + } + + permMenus[trd.MenuID] = true + thdMenuList.push(trdItem) + + return trdItem + }) + } + + return sndItem + }) + } + + return fstItem + }) + + return { menulist, thdMenuList, permMenus} } reload = () => { - this.setState({ - menulist: null - }) this.loadmenu() } changeEditState = (state) => { - const { menulist } = this.state - if (!state) { // 閫�鍑虹紪杈戯紝椤甸潰鍒锋柊 window.location.reload() return @@ -357,48 +415,23 @@ let UserID = sessionStorage.getItem('CloudUserID') let LoginUID = sessionStorage.getItem('CloudLoginUID') - if (state && (!UserID || !LoginUID)) { + if (!UserID || !LoginUID) { this.setState({ loginVisible: true }) } else { - sessionStorage.setItem('isEditState', state) - let _userName = sessionStorage.getItem('User_Name') - let _avatar = avatar + sessionStorage.setItem('isEditState', 'true') + this.props.modifyDataManager(sessionStorage.getItem('cloudDataM') === 'true') - if (sessionStorage.getItem('cloudDataM') === 'true') { - this.props.modifyDataManager(true) - } - if (!state && sessionStorage.getItem('avatar')) { - _avatar = Utils.getrealurl(sessionStorage.getItem('avatar')) // 澶村儚 - } else if (state && sessionStorage.getItem('CloudAvatar')) { - _avatar = Utils.getrealurl(sessionStorage.getItem('CloudAvatar')) // 澶村儚 - } - - if (state) { - _userName = sessionStorage.getItem('CloudUserName') - } - - if (window.GLOB.systemType === 'production' && state) { + if (window.GLOB.systemType === 'production') { this.props.resetEditLevel('HS') this.props.modifyMainMenu({ MenuID: 'systemManageView' }) this.setState({ - userName: _userName, - avatar: _avatar - }) - this.props.resetEditState(state) - - return - } else if (window.GLOB.systemType === 'production' && !state) { - this.props.resetEditLevel(false) - this.props.modifyMainMenu(menulist[0] || '') - - this.setState({ - userName: _userName, - avatar: _avatar + userName: sessionStorage.getItem('CloudUserName'), + avatar: Utils.getrealurl(sessionStorage.getItem('CloudAvatar')) }) this.props.resetEditState(state) @@ -407,15 +440,15 @@ this.setState({ menulist: null, - userName: _userName, - avatar: _avatar + userName: sessionStorage.getItem('CloudUserName'), + avatar: Utils.getrealurl(sessionStorage.getItem('CloudAvatar')) }) this.loadmenu() - this.props.modifyMainMenu('') + this.props.modifyMainMenu(null) this.props.resetEditState(state) } - if (state && this.props.sysRoles.length === 0 && this.props.permFuncField.length === 0 && window.GLOB.systemType !== 'production') { + if (window.GLOB.systemType !== 'production') { Api.getSystemConfig({func: 'sPC_Get_Roles_sModular'}).then(res => { if (res.status) { let _permFuncField = [] @@ -458,13 +491,9 @@ sessionStorage.setItem('CloudUserName', res.UserName) sessionStorage.setItem('CloudFullName', res.FullName) sessionStorage.setItem('CloudAvatar', res.icon) - sessionStorage.setItem('isEditState', 'true') sessionStorage.setItem('cloudDataM', res.dataM ? 'true' : '') - - let _avatar = avatar - if (res.icon) { - _avatar = Utils.getrealurl(res.icon) // 澶村儚 - } + + sessionStorage.setItem('isEditState', 'true') if (res.dataM) { this.props.modifyDataManager(true) @@ -480,7 +509,7 @@ loginVisible: false, loginLoading: false, userName: res.UserName, - avatar: _avatar + avatar: res.icon }) this.props.resetEditState(true) @@ -492,10 +521,10 @@ loginVisible: false, loginLoading: false, userName: res.UserName, - avatar: _avatar + avatar: res.icon }) this.loadmenu() - this.props.modifyMainMenu('') + this.props.modifyMainMenu(null) this.props.resetEditState(true) } else { this.setState({ @@ -531,14 +560,15 @@ * @description 閫�鍑虹鐞嗙晫闈㈣彍鍗� */ exitManage = () => { + const { menulist } = this.state + if (window.GLOB.systemType === 'production') { // 姝e紡绯荤粺鐗堟湰鍗囩骇鍚庯紝椤甸潰鍒锋柊 window.location.reload() return } - this.props.resetEditState(true) + this.props.modifyMainMenu(menulist[0] || null) this.props.resetEditLevel(false) - this.reload() } exitEdit = () => { @@ -576,40 +606,36 @@ } selectMenu = (item) => { - const { tabviews } = this.props - - let menu = JSON.parse(JSON.stringify(item)) + let tabs = fromJS(this.props.tabviews).toJS() + let menu = fromJS(item).toJS() menu.selected = true - let index = 0 - let isexit = false - let tabs = tabviews.map((tab, i) => { + tabs = tabs.filter(tab => { tab.selected = false - - if (tab.MenuID === menu.MenuID) { - tab.selected = true - isexit = true - } - - return tab + return tab.MenuID !== menu.MenuID }) - if (!isexit) { - tabs.splice(index + 1, 0, menu) + if (this.props.tabviews.length !== tabs.length) { + this.props.modifyTabview(fromJS(tabs).toJS()) } - this.props.modifyTabview(tabs) + this.setState({}, () => { + tabs.push(menu) + this.props.modifyTabview(tabs) + }) } UNSAFE_componentWillMount () { // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁 - let _avatar = sessionStorage.getItem('avatar') - if (_avatar) { - _avatar = Utils.getrealurl(_avatar) // 澶村儚 - this.setState({avatar: _avatar}) - } - this.getRolesMenu() + } + + UNSAFE_componentWillReceiveProps (nextProps) { + if (!is(fromJS(this.props.menuTree), fromJS(nextProps.menuTree)) && !is(fromJS(this.state.menulist), fromJS(nextProps.menuTree))) { + this.setState({ + menulist: nextProps.menuTree + }) + } } componentDidMount () { @@ -675,6 +701,7 @@ } render () { + const { mainMenu, collapse } = this.props const { thdMenuList, searchkey, oriVersion, newVersion } = this.state const menu = ( @@ -699,16 +726,16 @@ return ( <header className="header-container ant-menu-dark" id="main-header-container"> - <div className={this.props.collapse ? "collapse header-logo" : "header-logo"}><img src={this.state.logourl} alt=""/></div> - <div className={this.props.collapse ? "collapse header-collapse" : "header-collapse"} onClick={this.handleCollapse}> - <Icon type={this.props.collapse ? 'menu-unfold' : 'menu-fold'} /> + <div className={collapse ? "collapse header-logo" : "header-logo"}><img src={this.state.logourl} alt=""/></div> + <div className={collapse ? "collapse header-collapse" : "header-collapse"} onClick={this.handleCollapse}> + <Icon type={collapse ? 'menu-unfold' : 'menu-fold'} /> </div> {/* 姝e父鑿滃崟 */} {this.props.editLevel !== 'level1' && this.state.menulist ? <ul className={'header-menu ' + this.props.editLevel}>{ this.state.menulist.map(item => { return ( - <li key={item.MenuID} onClick={() => {this.changeMenu(item)}} className={this.props.selectmenu.MenuID === item.MenuID ? 'active' : ''}> + <li key={item.MenuID} onClick={() => {this.changeMenu(item)}} className={mainMenu && mainMenu.MenuID === item.MenuID ? 'active' : ''}> <span>{item.MenuName}</span> </li> ) @@ -737,7 +764,7 @@ {/* 澶村儚銆佺敤鎴峰悕 */} <Dropdown className="header-setting" overlay={menu}> <div> - <img src={this.state.avatar} alt=""/> + <img src={this.state.avatar || avatar} alt=""/> <span> <span className="username">{this.state.userName}</span> <Icon type="down" /> </span> @@ -811,7 +838,8 @@ return { tabviews: state.tabviews, collapse: state.collapse, - selectmenu: state.selectedMainMenu, + menuTree: state.menuTree, + mainMenu: state.mainMenu, debug: state.debug, editState: state.editState, editLevel: state.editLevel, @@ -826,7 +854,8 @@ return { toggleCollapse: (collapse) => dispatch(toggleCollapse(collapse)), modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews)), - modifyMainMenu: (selectmenu) => dispatch(modifyMainMenu(selectmenu)), + modifyMenuTree: (menuTree) => dispatch(modifyMenuTree(menuTree)), + modifyMainMenu: (mainMenu) => dispatch(modifyMainMenu(mainMenu)), resetEditState: (state) => dispatch(resetEditState(state)), resetEditLevel: (level) => dispatch(resetEditLevel(level)), initActionPermission: (permAction) => dispatch(initActionPermission(permAction)), diff --git a/src/components/header/index.scss b/src/components/header/index.scss index 2f21768..cfb1926 100644 --- a/src/components/header/index.scss +++ b/src/components/header/index.scss @@ -31,9 +31,10 @@ .header-collapse { float: left; - width: 80px; + width: 35px; line-height: 48px; - padding-left: 20px; + padding-left: 10px; + margin: 0 10px; cursor: pointer; transition: padding-left 0.15s; i { @@ -44,7 +45,8 @@ } } .header-collapse.collapse { - padding-left: 30px; + width: 60px; + padding-left: 20px; } .header-menu { float: left; diff --git a/src/components/sidemenu/config.jsx b/src/components/sidemenu/config.jsx index 553511e..688344c 100644 --- a/src/components/sidemenu/config.jsx +++ b/src/components/sidemenu/config.jsx @@ -1,267 +1,236 @@ // 绯荤粺鑿滃崟 -export const SySMenuList = { - systemManageView: [{ - MenuID: 'systemManageViewConfig', - text: '閰嶇疆', - PageParam: {Icon: 'folder'}, - children: [{ - src: '', - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '1581067625930haged11ieaivpavv77k', - MenuNo: 'sDatasM', - MenuName: '鏁版嵁瀛楀吀', - text: '鏁版嵁瀛楀吀' - }, { - src: '', - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '1581734956310scks442ul2d955g9tu5', - MenuNo: 'sVersionM', - MenuName: '浼犺緭鍙风鐞�', - text: '浼犺緭鍙风鐞�' - }, { - src: '', - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '1583991994144ndddg0bhh0is6shi0v1', - MenuNo: 'sVersionQueryM', - MenuName: '浼犺緭鍙锋煡璇�', - text: '浼犺緭鍙锋煡璇�' - }, { - src: '', - systems: ['production', 'local', 'SSO', 'cloud'], - PageParam: {OpenType: 'newtab', Template: 'VerupTable'}, - type: 'VerupTable', - MenuID: '1583979633842550imkchl4qt4qppsiv', - MenuNo: 'sVersionMUpgrade', - MenuName: '鐗堟湰鍗囩骇', - text: '鐗堟湰鍗囩骇' - }, { - src: '', - PageParam: {OpenType: 'newtab', Template: 'TabManage'}, - type: 'TabManage', - MenuID: 'TabManageView', - MenuNo: 'TabManage', - MenuName: '鏍囩椤电鐞�', - text: '鏍囩椤电鐞�' - }, { - src: '', - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '1578900109100np8aqd0a77q3na46oas', - MenuNo: 'sPrintTemplateM', - MenuName: '鏍囩鎵撳嵃妯℃澘', - text: '鏍囩鎵撳嵃妯℃澘' - }, { - src: '', - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '16044812935562g807p3p12huk8kokmb', - MenuNo: 'sPrintTemplate_webM', - MenuName: '鍗曟嵁鎵撳嵃妯℃澘', - text: '鍗曟嵁鎵撳嵃妯℃澘' - }, { - src: '', - systems: ['SSO', 'cloud'], - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '1585192949946f3et2ts8tn82krmumdf', - MenuNo: 'MyAppManage', - MenuName: '绯荤粺UI', - text: '绯荤粺UI' - }, { - src: '', - systems: ['SSO', 'cloud'], - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '15855615451212m12ip23vpcm79kloro', - MenuNo: 'sUsersAppM', - MenuName: '绯荤粺鐢ㄦ埛绠$悊', - text: '绯荤粺鐢ㄦ埛绠$悊' - }, { - src: '', - PageParam: {OpenType: 'newtab', Template: 'ScriptTable'}, - type: 'ScriptTable', - MenuID: '1587005717541lov40vg61q7l1rbveon', - MenuNo: 's_custom_scriptM', - MenuName: '鑷畾涔夊嚱鏁�', - text: '鑷畾涔夊嚱鏁�' - }, { - src: '', - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '1590458676585agbbr63t6ihighg2i1g', - MenuNo: 'LdropdownmenuNewM', - MenuName: '閫氱敤涓嬫媺鑿滃崟', - text: '閫氱敤涓嬫媺鑿滃崟' - }, { - src: '', - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '1602315375262ikd33ii0nii34pt861o', - MenuNo: 's_worksflow_roleM', - MenuName: '鍏抽敭瑙掕壊绠$悊', - text: '鍏抽敭瑙掕壊绠$悊' - }] +export const SySMenuList = [{ + MenuID: 'systemManageViewConfig', + MenuName: '閰嶇疆', + PageParam: {Icon: 'folder'}, + children: [{ + src: '', + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '1581067625930haged11ieaivpavv77k', + MenuNo: 'sDatasM', + MenuName: '鏁版嵁瀛楀吀', }, { - MenuID: 'systemManageViewInterface', - text: '鎺ュ彛', - PageParam: {Icon: 'folder'}, - children: [{ - src: '', - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '1582771068837vsv54a089lgp45migbg', - MenuNo: 'KUNTitleM', - MenuName: '鎺ュ彛涓绘暟鎹�', - text: '鎺ュ彛涓绘暟鎹�' - }, { - src: '', - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '1582777675954ifu05upurs465omoth7', - MenuNo: 'KUNMainM', - MenuName: '鏌ヨ鎺ュ彛', - text: '鏌ヨ鎺ュ彛' - }, { - src: '', - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '158294809668898cklbv6c5bou8e1fpu', - MenuNo: 'KUNMainMOut_advanced', - MenuName: '楂橀樁鏌ヨ', - text: '楂橀樁鏌ヨ' - }, { - src: '', - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '1584676379094iktph45fb8imhg96bql', - MenuNo: 'KUNMainM_Out_usual', - MenuName: '閫氱敤鏌ヨ鎺ュ彛', - text: '閫氱敤鏌ヨ鎺ュ彛' - }, { - src: '', - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '1584695125339vo5g7iqgfn01qmrd6s2', - MenuNo: 'KUNMainM_In_usual', - MenuName: '閫氱敤鍐欏叆鎺ュ彛', - text: '閫氱敤鍐欏叆鎺ュ彛' - }, { - src: '', - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '1584699661372vhmpp9dn9foo0eob722', - MenuNo: 'KUNMainM_In', - MenuName: '鍐欏叆鎺ュ彛', - text: '鍐欏叆鎺ュ彛' - }, { - src: '', - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '15848421131551gg04ie8sitsd3f7467', - MenuNo: 'KUNOsMainM', - MenuName: '澶栭儴鎺ュ彛', - text: '澶栭儴鎺ュ彛' - }] + src: '', + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '1581734956310scks442ul2d955g9tu5', + MenuNo: 'sVersionM', + MenuName: '浼犺緭鍙风鐞�', }, { - MenuID: 'systemManageViewCommunication', - text: '閫氫俊', - PageParam: {Icon: 'folder'}, - children: [{ - src: '', - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '1589782279158ngr675kk3oksin35sul', - MenuNo: 'bd_msn_emailM', - MenuName: '閭欢鏈嶅姟鍣�', - text: '閭欢鏈嶅姟鍣�' - }, { - src: '', - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '1589788042787ffdt9hle4s45k9r1nvs', - MenuNo: 'bd_msn_email_tempM', - MenuName: '閭欢妯℃澘', - text: '閭欢妯℃澘' - }, { - src: '', - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '15900310928174dro07ihfckghpb5h13', - MenuNo: 'bd_msn_sms_tempM', - MenuName: '澶т簬鐭俊妯℃澘', - text: '澶т簬鐭俊妯℃澘' - // }, { - // src: '', - // PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - // type: 'ManageTable', - // MenuID: '1599613340050c8nu6rbst9d4emnnbsq', - // MenuNo: 's_sms_qxM', - // MenuName: '濂囦簯鐭俊妯℃澘', - // text: '濂囦簯鐭俊妯℃澘' - }] + src: '', + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '1583991994144ndddg0bhh0is6shi0v1', + MenuNo: 'sVersionQueryM', + MenuName: '浼犺緭鍙锋煡璇�', }, { - MenuID: 'systemPayManage', - text: '鏀粯', - PageParam: {Icon: 'folder'}, - children: [{ - src: '', - systems: ['local', 'cloud'], - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '1594095599055qicg2eb642v5qglhnuo', - MenuNo: 's_weixin_pay_bdM', - MenuName: '寰俊鏀粯', - text: '寰俊鏀粯' - }] + src: '', + systems: ['production', 'local', 'SSO', 'cloud'], + PageParam: {OpenType: 'newtab', Template: 'VerupTable'}, + type: 'VerupTable', + MenuID: '1583979633842550imkchl4qt4qppsiv', + MenuNo: 'sVersionMUpgrade', + MenuName: '鐗堟湰鍗囩骇', }, { - MenuID: 'systemManageViewParam', - text: '绯荤粺鍙傛暟', - PageParam: {Icon: 'folder'}, - children: [{ - src: '', - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '1577972969199lei1g0qkvlh4tkc908m', - MenuNo: 'sModularM', - MenuName: '绯荤粺妯″潡', - text: '绯荤粺妯″潡' - }, { - src: '', - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '1578479100252lfbp29v1kafk4s4q4ig', - MenuNo: 'BDLanguagePacksM', - MenuName: '璇█鍖�', - text: '璇█鍖�' - }, { - src: '', - systems: ['production', 'local', 'SSO', 'cloud'], - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '1577971621421tg4v0i1ur8873k7e0ob', - MenuNo: 'sSystemParametersM', - MenuName: '鎺ュ彛鍦板潃', - text: '鎺ュ彛鍦板潃' - }, { - src: '', - systems: ['production', 'local', 'SSO', 'cloud'], - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '1577929944419lgc5h3hepum765e2k7u', - MenuNo: 'sProcExcepM', - MenuName: '鎶ラ敊鏃ュ織', - text: '鎶ラ敊鏃ュ織' - }, { - src: '', - PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, - type: 'ManageTable', - MenuID: '1588493493409k9guqp067d31lu7blsv', - MenuNo: 's_job_stepM', - MenuName: '璁″垝浠诲姟', - text: '璁″垝浠诲姟' - }] + src: '', + PageParam: {OpenType: 'newtab', Template: 'TabManage'}, + type: 'TabManage', + MenuID: 'TabManageView', + MenuNo: 'TabManage', + MenuName: '鏍囩椤电鐞�', + }, { + src: '', + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '1578900109100np8aqd0a77q3na46oas', + MenuNo: 'sPrintTemplateM', + MenuName: '鏍囩鎵撳嵃妯℃澘', + }, { + src: '', + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '16044812935562g807p3p12huk8kokmb', + MenuNo: 'sPrintTemplate_webM', + MenuName: '鍗曟嵁鎵撳嵃妯℃澘', + }, { + src: '', + systems: ['SSO', 'cloud'], + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '1585192949946f3et2ts8tn82krmumdf', + MenuNo: 'MyAppManage', + MenuName: '绯荤粺UI', + }, { + src: '', + systems: ['SSO', 'cloud'], + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '15855615451212m12ip23vpcm79kloro', + MenuNo: 'sUsersAppM', + MenuName: '绯荤粺鐢ㄦ埛绠$悊', + }, { + src: '', + PageParam: {OpenType: 'newtab', Template: 'ScriptTable'}, + type: 'ScriptTable', + MenuID: '1587005717541lov40vg61q7l1rbveon', + MenuNo: 's_custom_scriptM', + MenuName: '鑷畾涔夊嚱鏁�', + }, { + src: '', + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '1590458676585agbbr63t6ihighg2i1g', + MenuNo: 'LdropdownmenuNewM', + MenuName: '閫氱敤涓嬫媺鑿滃崟', + }, { + src: '', + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '1602315375262ikd33ii0nii34pt861o', + MenuNo: 's_worksflow_roleM', + MenuName: '鍏抽敭瑙掕壊绠$悊', }] -} +}, { + MenuID: 'systemManageViewInterface', + MenuName: '鎺ュ彛', + PageParam: {Icon: 'folder'}, + children: [{ + src: '', + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '1582771068837vsv54a089lgp45migbg', + MenuNo: 'KUNTitleM', + MenuName: '鎺ュ彛涓绘暟鎹�', + }, { + src: '', + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '1582777675954ifu05upurs465omoth7', + MenuNo: 'KUNMainM', + MenuName: '鏌ヨ鎺ュ彛', + }, { + src: '', + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '158294809668898cklbv6c5bou8e1fpu', + MenuNo: 'KUNMainMOut_advanced', + MenuName: '楂橀樁鏌ヨ', + }, { + src: '', + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '1584676379094iktph45fb8imhg96bql', + MenuNo: 'KUNMainM_Out_usual', + MenuName: '閫氱敤鏌ヨ鎺ュ彛', + }, { + src: '', + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '1584695125339vo5g7iqgfn01qmrd6s2', + MenuNo: 'KUNMainM_In_usual', + MenuName: '閫氱敤鍐欏叆鎺ュ彛', + }, { + src: '', + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '1584699661372vhmpp9dn9foo0eob722', + MenuNo: 'KUNMainM_In', + MenuName: '鍐欏叆鎺ュ彛', + }, { + src: '', + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '15848421131551gg04ie8sitsd3f7467', + MenuNo: 'KUNOsMainM', + MenuName: '澶栭儴鎺ュ彛', + }] +}, { + MenuID: 'systemManageViewCommunication', + MenuName: '閫氫俊', + PageParam: {Icon: 'folder'}, + children: [{ + src: '', + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '1589782279158ngr675kk3oksin35sul', + MenuNo: 'bd_msn_emailM', + MenuName: '閭欢鏈嶅姟鍣�', + }, { + src: '', + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '1589788042787ffdt9hle4s45k9r1nvs', + MenuNo: 'bd_msn_email_tempM', + MenuName: '閭欢妯℃澘', + }, { + src: '', + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '15900310928174dro07ihfckghpb5h13', + MenuNo: 'bd_msn_sms_tempM', + MenuName: '澶т簬鐭俊妯℃澘', + // }, { + // src: '', + // PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + // type: 'ManageTable', + // MenuID: '1599613340050c8nu6rbst9d4emnnbsq', + // MenuNo: 's_sms_qxM', + // MenuName: '濂囦簯鐭俊妯℃澘', + }] +}, { + MenuID: 'systemPayManage', + MenuName: '鏀粯', + PageParam: {Icon: 'folder'}, + children: [{ + src: '', + systems: ['local', 'cloud'], + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '1594095599055qicg2eb642v5qglhnuo', + MenuNo: 's_weixin_pay_bdM', + MenuName: '寰俊鏀粯', + }] +}, { + MenuID: 'systemManageViewParam', + MenuName: '绯荤粺鍙傛暟', + PageParam: {Icon: 'folder'}, + children: [{ + src: '', + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '1577972969199lei1g0qkvlh4tkc908m', + MenuNo: 'sModularM', + MenuName: '绯荤粺妯″潡', + }, { + src: '', + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '1578479100252lfbp29v1kafk4s4q4ig', + MenuNo: 'BDLanguagePacksM', + MenuName: '璇█鍖�', + }, { + src: '', + systems: ['production', 'local', 'SSO', 'cloud'], + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '1577971621421tg4v0i1ur8873k7e0ob', + MenuNo: 'sSystemParametersM', + MenuName: '鎺ュ彛鍦板潃', + }, { + src: '', + systems: ['production', 'local', 'SSO', 'cloud'], + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '1577929944419lgc5h3hepum765e2k7u', + MenuNo: 'sProcExcepM', + MenuName: '鎶ラ敊鏃ュ織', + }, { + src: '', + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '1588493493409k9guqp067d31lu7blsv', + MenuNo: 's_job_stepM', + MenuName: '璁″垝浠诲姟', + }] +}] diff --git a/src/components/sidemenu/index.jsx b/src/components/sidemenu/index.jsx index 79cf836..90b0d6b 100644 --- a/src/components/sidemenu/index.jsx +++ b/src/components/sidemenu/index.jsx @@ -6,7 +6,7 @@ import { Menu, Icon, notification } from 'antd' import asyncComponent from '@/utils/asyncComponent' -import { modifyTabview, resetEditLevel } from '@/store/action' +import { modifyTabview, resetEditLevel, modifyMenuTree, modifyMainMenu } from '@/store/action' import { SySMenuList } from './config' import options from '@/store/options.js' import zhCN from '@/locales/zh-CN/main.js' @@ -20,16 +20,11 @@ class Sidemenu extends Component { static propTypes = { - collapse: PropTypes.bool, - mainMenu: PropTypes.oneOfType([ - PropTypes.string, - PropTypes.object - ]) + collapse: PropTypes.bool } state = { dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, - mainMenuList: null, // 涓�绾ц彍鍗曪紝缂栬緫璋冩暣涓婄骇鑿滃崟鏃惰幏鍙� subMenulist: [], // 浜岀骇鑿滃崟 editMenu: null, // 缂栬緫涓夌骇鑿滃崟鏃惰缃� rootSubmenuKeys: null, @@ -49,179 +44,23 @@ return } - let _param = {func: 'sPC_Get_FunMenu', ParentID: menu.MenuID, systemType: options.sysType} + menu = fromJS(menu).toJS() + let openKey = '' - if (sessionStorage.getItem('isEditState') === 'true') { // 缂栬緫鐘舵�佹椂锛岃幏鍙栬彍鍗曪紝澧炲姞鍙傛暟debug - _param.debug = 'Y' + if (menu.children[0]) { + openKey = menu.openId || menu.children[0].MenuID } - let result = await Api.getSystemConfig(_param) - if (result.status) { - if (this.props.editState && this.props.editLevel === 'HS') return - - if (result.data.length === 0) { // 鏌ヨ鑿滃崟涓虹┖ - this.setState({ - subMenulist: [], - rootSubmenuKeys: [], - openKeys: [] - }) - return - } - - let SubMenuId = sessionStorage.getItem('SubMenu') // 鏄惁涓烘墦寮�鏂伴〉闈� - let ThirdMenuId = sessionStorage.getItem('ThirdMenu') // 鏄惁涓烘墦寮�鏂伴〉闈� - let submenuId = '' // 灞曞紑浜岀骇鑿滃崟ID - let tabId = '' // 鎵撳紑鐨則ab椤礽d - let msg = { - UserID: sessionStorage.getItem('UserID'), - LoginUID: sessionStorage.getItem('LoginUID'), - User_Name: sessionStorage.getItem('User_Name'), - Full_Name: sessionStorage.getItem('Full_Name'), - Member_Level: sessionStorage.getItem('Member_Level'), - dataM: sessionStorage.getItem('dataM'), - avatar: sessionStorage.getItem('avatar'), - debug: sessionStorage.getItem('debug'), - role_id: sessionStorage.getItem('role_id'), - mainlogo: window.GLOB.mainlogo, - mstyle: window.GLOB.style, - MainMenu: menu.MenuID - } - - if (SubMenuId && ThirdMenuId) { - submenuId = SubMenuId - let submenu = result.data.filter(item => item.ParentID === SubMenuId)[0] - - if (!submenu) { - submenuId = '' - } else { - tabId = ThirdMenuId - let tabmenu = submenu.FunMenu.filter(item => item.MenuID === ThirdMenuId)[0] - if (!tabmenu) { - submenuId = '' - tabId = '' - } - } - sessionStorage.removeItem('SubMenu') - sessionStorage.removeItem('ThirdMenu') - } - let parentID = submenuId ? submenuId : result.data[0].ParentID // 灞曞紑浜岀骇鑿滃崟ID - - let iframes = ['Main/Index', 'bda/rdt', 'Home/rdt'] - - let menulist = result.data.map(item => { - let _smenu = {} - _smenu.id = item.ParentID - _smenu.MenuID = item.ParentID - _smenu.text = item.MenuNameP - - try { - _smenu.PageParam = JSON.parse(item.PageParamP) - } catch (e) { - _smenu.PageParam = {Icon: 'folder'} - } - - if (item.FunMenu) { - _smenu.children = item.FunMenu.map(child => { - let _tmenu = { - ParentId: item.ParentID, - OpenType: 'newtab' - } - - if (child.LinkUrl === 'CommonTable') { - _tmenu.type = 'CommonTable' - } else if (iframes.includes(child.LinkUrl.split('?')[0])) { - _tmenu.type = 'iframe' - _tmenu.forbidden = true - } - - if (_tmenu.type !== 'iframe') { - try { - _tmenu.PageParam = JSON.parse(child.PageParam) - } catch (e) { - _tmenu.PageParam = {OpenType: 'newtab'} - } - _tmenu.type = _tmenu.PageParam.Template || _tmenu.type - _tmenu.OpenType = _tmenu.PageParam.OpenType - } - - if (_tmenu.type === 'NewPage') { - _tmenu.src = _tmenu.PageParam.url - if (this.props.memberLevel < 20) { // 浼氬憳绛夌骇澶т簬绛変簬20鏃讹紝鏈夌紪杈戞潈闄� - _tmenu.forbidden = true - } - if (_tmenu.src.indexOf('paramsmain/') > -1) { - try { - let _url = _tmenu.src.split('paramsmain/')[0] + 'paramsmain/' - let _param = JSON.parse(window.decodeURIComponent(window.atob(_tmenu.src.split('paramsmain/')[1]))) - _param.UserID = sessionStorage.getItem('UserID') - _param.LoginUID = sessionStorage.getItem('LoginUID') - _param.User_Name = sessionStorage.getItem('User_Name') - _tmenu.src = _url + window.btoa(window.encodeURIComponent(JSON.stringify(_param))) - } catch { - console.warn('鑿滃崟鍙傛暟瑙f瀽閿欒锛�') - } - } - } else { - // 鎵撳紑鏂伴〉闈㈤摼鎺� - _tmenu.src = '#/paramsmain/' + window.btoa(window.encodeURIComponent(JSON.stringify({ - ...msg, - SubMenu: _smenu.MenuID, - ThirdMenu: child.MenuID - }))) - } - - _tmenu.id = child.MenuID - _tmenu.MenuID = child.MenuID - _tmenu.MenuNo = child.MenuNo - _tmenu.MenuName = child.MenuName - _tmenu.text = child.MenuName - return _tmenu - }) - } - return _smenu - }) - - this.setState({ - subMenulist: menulist, - rootSubmenuKeys: result.data.map(item => item.ParentID), - openKeys: this.props.collapse ? [] : [parentID], - editMenu: this.props.editLevel === 'level3' && menulist.filter(menu => menu.MenuID === this.state.editMenu.MenuID)[0] - }) - if (tabId) { - let _menu = menulist.filter(menu => menu.MenuID === submenuId)[0] - let opentab = _menu && _menu.children.filter(tab => tab.MenuID === tabId)[0] - if (opentab) { - if (sessionStorage.getItem('MenuParam')) { - try { - let thParam = JSON.parse(sessionStorage.getItem('MenuParam')) - - if (tabId === thParam.ThirdMenu) { - delete thParam.ThirdMenu - opentab.param = thParam - } - } catch { - console.warn('鑿滃崟鍙傛暟瑙f瀽閿欒锛�') - } - sessionStorage.removeItem('MenuParam') - } - - opentab.selected = true - let home = this.props.tabviews[0] - home.selected = false - this.props.modifyTabview([home, opentab]) - } - } - } else { - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - } + this.setState({ + subMenulist: menu.children, + rootSubmenuKeys: menu.children.map(item => item.MenuID), + openKeys: this.props.collapse ? [] : [openKey], + editMenu: this.props.editLevel === 'level3' ? menu.children.filter(_menu => _menu.MenuID === this.state.editMenu.MenuID)[0] : null + }) } - enterManageView = (type) => { - let menulist = SySMenuList[type] + enterManageView = () => { + let menulist = SySMenuList if (window.GLOB.systemType === 'production') { menulist.forEach(menu => { @@ -252,10 +91,7 @@ let menu = JSON.parse(e.target.dataset.item) - if (menu.OpenType === 'newpage') { - e.preventDefault() - window.open(menu.src) - } else if (menu.OpenType === 'NewPage') { + if (menu.OpenType === 'newpage' || menu.OpenType === 'NewPage') { e.preventDefault() window.open(menu.src) } else if (menu.OpenType === 'blank') { @@ -285,7 +121,7 @@ UNSAFE_componentWillReceiveProps (nextProps) { if (!is(fromJS(this.props.mainMenu), fromJS(nextProps.mainMenu)) && nextProps.mainMenu && nextProps.mainMenu.MenuID === 'systemManageView') { - this.enterManageView(nextProps.mainMenu.MenuID) + this.enterManageView() } else if (!is(fromJS(this.props.mainMenu), fromJS(nextProps.mainMenu))) { // 涓昏彍鍗曞垏鎹紝璇锋眰2銆�3绾ц彍鍗曟暟鎹� this.loadsubmenu(nextProps.mainMenu) @@ -316,17 +152,6 @@ // 缂栬緫浜岀骇鑿滃崟 e.stopPropagation() this.props.resetEditLevel('level2') - // 鑾峰彇涓�绾ц彍鍗曞垪琛� - Api.getSystemConfig({func: 'sPC_Get_MainMenu', debug: 'Y'}).then(res => { - this.setState({ - mainMenuList: res.data.map(item => { - return { - MenuID: item.MenuID, - text: item.MenuName - } - }) - }) - }) } enterThrEdit = (e, menu) => { @@ -337,7 +162,113 @@ } reload = () => { - this.loadsubmenu(this.props.mainMenu) + const { mainMenu } = this.props + let _param = {func: 's_get_pc_menus', systemType: options.sysType, debug: 'Y'} + if (options.sysType !== 'cloud' && window.GLOB.systemType !== 'production') { + _param.linkurl = window.GLOB.linkurl + } + _param.pro_sys = window.GLOB.systemType === 'production' ? 'Y' : '' + + Api.getSystemConfig(_param).then(result => { + // 鐧诲綍瓒呮椂 + if (!result) return + + if (result.status) { + let res = this.getMenulist(result) + let _mainMenu = res.menulist.filter(item => item.MenuID === mainMenu.MenuID)[0] + + this.props.modifyMenuTree(res.menulist) + this.props.modifyMainMenu(_mainMenu || null) + } else { + notification.error({ + top: 92, + message: result.message, + duration: 10 + }) + } + this.loadsubmenu(this.props.mainMenu) + }) + } + + getMenulist = (result) => { + let iframes = ['Main/Index', 'bda/rdt', 'Home/rdt'] + let menulist = result.fst_menu.map(fst => { + let fstItem = { + MenuID: fst.MenuID, + MenuName: fst.MenuName, + PageParam: {OpenType: 'menu', linkUrl: ''}, + children: [] + } + if (fst.PageParam) { + try { + fstItem.PageParam = JSON.parse(fst.PageParam) + } catch (e) { + fstItem.PageParam = {OpenType: 'menu', linkUrl: ''} + } + } + + if (fst.snd_menu) { + fstItem.children = fst.snd_menu.map(snd => { + let sndItem = { + ParentId: fst.MenuID, + MenuID: snd.MenuID, + MenuName: snd.MenuName, + PageParam: {Icon: 'folder'}, + children: [] + } + + if (snd.PageParam) { + try { + sndItem.PageParam = JSON.parse(snd.PageParam) + } catch (e) { + sndItem.PageParam = {Icon: 'folder'} + } + } + + if (snd.trd_menu) { + sndItem.children = snd.trd_menu.map(trd => { + let trdItem = { + FstId: fst.MenuID, + ParentId: snd.MenuID, + MenuID: trd.MenuID, + MenuName: trd.MenuName, + MenuNo: trd.MenuNo, + EasyCode: trd.EasyCode, + type: 'CommonTable', // 榛樿鍊间负甯哥敤琛� + OpenType: 'newtab' // 鎵撳紑鏂瑰紡 + } + + if (trd.LinkUrl && iframes.includes(trd.LinkUrl.split('?')[0])) { + trdItem.type = 'iframe' + trdItem.LinkUrl = trd.LinkUrl + trdItem.forbidden = true + } else { + try { + trdItem.PageParam = trd.PageParam ? JSON.parse(trd.PageParam) : {OpenType: 'newtab'} + } catch (e) { + trdItem.PageParam = {OpenType: 'newtab'} + } + + trdItem.type = trdItem.PageParam.Template || trdItem.type + trdItem.OpenType = trdItem.PageParam.OpenType || trdItem.OpenType + + if (trdItem.type === 'CustomPage' && this.props.memberLevel < 20) { // 浼氬憳绛夌骇澶т簬绛変簬20鏃讹紝鏈夌紪杈戞潈闄� + trdItem.forbidden = true + } + } + + return trdItem + }) + } + + return sndItem + }) + } + + return fstItem + }) + + return { menulist } } exitEdit = () => { @@ -362,7 +293,7 @@ title={ <span className={editShow && index === 0 ? 'edit-control' : ''}> <Icon type={item.PageParam.Icon} /> - <span>{item.text}</span> + <span>{item.MenuName}</span> </span> } > @@ -372,7 +303,7 @@ {item.children.map(cell => { return ( <Menu.Item key={cell.MenuID}> - <a href={cell.src} id={cell.MenuID} data-item={JSON.stringify(cell)} onClick={this.changemenu.bind(this)}>{cell.text}</a> + <a href={cell.src} id={cell.MenuID} data-item={JSON.stringify(cell)} onClick={this.changemenu.bind(this)}>{cell.MenuName}</a> </Menu.Item> ) })} @@ -383,13 +314,13 @@ {this.props.editLevel === 'level2' ? <EditSecMenu menulist={this.state.subMenulist} - supMenuList={this.state.mainMenuList} + menuTree={this.props.menuTree} supMenu={this.props.mainMenu} reload={this.reload} exitEdit={this.exitEdit} /> : null } - {this.props.editLevel === 'level3' && this.state.subMenulist && this.state.editMenu ? + {this.props.editLevel === 'level3' && this.state.editMenu ? <EditThdMenu menulist={this.state.editMenu.children} supMenuList={this.state.subMenulist} @@ -408,7 +339,8 @@ tabviews: state.tabviews, collapse: state.collapse, isiframe: state.isiframe, - mainMenu: state.selectedMainMenu, + mainMenu: state.mainMenu, + menuTree: state.menuTree, memberLevel: state.memberLevel, editState: state.editState, editLevel: state.editLevel @@ -417,6 +349,8 @@ const mapDispatchToProps = (dispatch) => { return { + modifyMenuTree: (menuTree) => dispatch(modifyMenuTree(menuTree)), + modifyMainMenu: (mainMenu) => dispatch(modifyMainMenu(mainMenu)), modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews)), resetEditLevel: (level) => dispatch(resetEditLevel(level)) } diff --git a/src/menu/actioncomponent/actionform/index.jsx b/src/menu/actioncomponent/actionform/index.jsx index 9b0df0c..a9758c6 100644 --- a/src/menu/actioncomponent/actionform/index.jsx +++ b/src/menu/actioncomponent/actionform/index.jsx @@ -4,8 +4,6 @@ import { Form, Row, Col, Input, Select, Icon, Radio, notification, Tooltip, InputNumber, Cascader } from 'antd' import { btnIcons, btnCustomClasses, formRule } from '@/utils/option.js' -import Api from '@/api' -import options from '@/store/options.js' import './index.scss' const { TextArea } = Input @@ -157,7 +155,7 @@ _options.push('execMode', 'intertype', 'innerFunc', 'Ot', 'execSuccess', 'execError') } } - } else { + } else if (_opentype === 'popview' && _opentype === 'tab') { if (_intertype === 'outer') { _options.push('innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc') } else if (_intertype === 'inner') { @@ -548,7 +546,6 @@ })( <Cascader options={this.state.menulist} - loadData={this.loadData} placeholder="" /> )} @@ -570,57 +567,6 @@ } }) return fields - } - - loadData = selectedOptions => { - const { MenuID } = this.props - const targetOption = selectedOptions[selectedOptions.length - 1] - targetOption.loading = true - - let _param = { - func: 'sPC_Get_FunMenu', - ParentID: targetOption.value, - systemType: options.sysType, - debug: 'Y' - } - - Api.getSystemConfig(_param).then(result => { - if (result.status) { - targetOption.loading = false - targetOption.children = result.data.map(item => { - let submenu = { - value: item.ParentID, - label: item.MenuNameP, - children: item.FunMenu.map(cell => { - return { - value: cell.MenuID, - label: cell.MenuName, - MenuID: cell.MenuID, - MenuName: cell.MenuName, - MenuNo: cell.MenuNo, - Ot: cell.Ot, - PageParam: cell.PageParam, - LinkUrl: cell.LinkUrl, - disabled: cell.MenuID === MenuID - } - }) - } - - return submenu - }) - - this.setState({ - menulist: [...this.state.menulist] - }) - } else { - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - targetOption.loading = false - } - }) } handleConfirm = () => { diff --git a/src/menu/actioncomponent/index.jsx b/src/menu/actioncomponent/index.jsx index 364806f..4e070de 100644 --- a/src/menu/actioncomponent/index.jsx +++ b/src/menu/actioncomponent/index.jsx @@ -4,8 +4,6 @@ import { is, fromJS } from 'immutable' import { Modal, notification, Button } from 'antd' -import Api from '@/api' -import options from '@/store/options.js' import Utils from '@/utils/utils.js' import DevUtils from '@/utils/devutils.js' import zhCN from '@/locales/zh-CN/model.js' @@ -169,75 +167,37 @@ </div> let menulist = [] + if (menu.fstMenuList) { - menulist = menu.fstMenuList.map(item => { - return { - value: item.MenuID, - label: item.text, - isLeaf: false - } + let trees = fromJS(menu.fstMenuList).toJS() + + menulist = trees.map(fst => { + fst.value = fst.MenuID + fst.label = fst.MenuName + fst.isLeaf = false + fst.children = fst.children.map(snd => { + snd.value = snd.MenuID + snd.label = snd.MenuName + + snd.children = snd.children.map(thd => { + thd.value = thd.MenuID + thd.label = thd.MenuName + thd.disabled = thd.MenuID === menu.MenuID + return thd + }) + return snd + }) + return fst }) } let modules = this.getModules(menu.components, config.uuid) - if (menu.fstMenuList && card.linkmenu && card.linkmenu.length > 0) { - let _param = { - func: 'sPC_Get_FunMenu', - ParentID: card.linkmenu[0], - systemType: options.sysType, - debug: 'Y' - } - - Api.getSystemConfig(_param).then(result => { - if (result.status) { - menulist = menulist.map(item => { - if (item.value === card.linkmenu[0]) { - item.children = result.data.map(item => { - let submenu = { - value: item.ParentID, - label: item.MenuNameP, - children: item.FunMenu.map(cell => { - return { - value: cell.MenuID, - label: cell.MenuName, - MenuID: cell.MenuID, - MenuName: cell.MenuName, - MenuNo: cell.MenuNo, - Ot: cell.Ot, - PageParam: cell.PageParam, - LinkUrl: cell.LinkUrl, - disabled: cell.MenuID === menu.MenuID - } - }) - } - - return submenu - }) - } - return item - }) - } else { - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - } - - this.setState({ - visible: true, - card: card, - formlist: getActionForm(card, functip, config.setting, menu.permFuncField, this.props.type, menulist, modules) - }) - }) - } else { - this.setState({ - visible: true, - card: card, - formlist: getActionForm(card, functip, config.setting, menu.permFuncField, this.props.type, menulist, modules) - }) - } + this.setState({ + visible: true, + card: card, + formlist: getActionForm(card, functip, config.setting, menu.permFuncField, this.props.type, menulist, modules) + }) } /** diff --git a/src/menu/components/card/cardcellcomponent/index.jsx b/src/menu/components/card/cardcellcomponent/index.jsx index 3d80bc4..36d0659 100644 --- a/src/menu/components/card/cardcellcomponent/index.jsx +++ b/src/menu/components/card/cardcellcomponent/index.jsx @@ -2,10 +2,8 @@ import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' import {connect} from 'react-redux' -import { Modal, Button, notification } from 'antd' +import { Modal, Button } from 'antd' -import Api from '@/api' -import options from '@/store/options.js' import zhCN from '@/locales/zh-CN/model.js' import enUS from '@/locales/en-US/model.js' import asyncComponent from '@/utils/asyncComponent' @@ -254,74 +252,35 @@ let menulist = [] if (menu.fstMenuList) { - menulist = menu.fstMenuList.map(item => { - return { - value: item.MenuID, - label: item.text, - isLeaf: false - } + let trees = fromJS(menu.fstMenuList).toJS() + + menulist = trees.map(fst => { + fst.value = fst.MenuID + fst.label = fst.MenuName + fst.isLeaf = false + fst.children = fst.children.map(snd => { + snd.value = snd.MenuID + snd.label = snd.MenuName + + snd.children = snd.children.map(thd => { + thd.value = thd.MenuID + thd.label = thd.MenuName + thd.disabled = thd.MenuID === menu.MenuID + return thd + }) + return snd + }) + return fst }) } let modules = this.getModules(menu.components, cards.uuid) - if (menu.fstMenuList && card.linkmenu && card.linkmenu.length > 0) { - let _param = { - func: 'sPC_Get_FunMenu', - ParentID: card.linkmenu[0], - systemType: options.sysType, - debug: 'Y' - } - - Api.getSystemConfig(_param).then(result => { - if (result.status) { - menulist = menulist.map(item => { - if (item.value === card.linkmenu[0]) { - item.children = result.data.map(item => { - let submenu = { - value: item.ParentID, - label: item.MenuNameP, - children: item.FunMenu.map(cell => { - return { - value: cell.MenuID, - label: cell.MenuName, - MenuID: cell.MenuID, - MenuName: cell.MenuName, - MenuNo: cell.MenuNo, - Ot: cell.Ot, - PageParam: cell.PageParam, - LinkUrl: cell.LinkUrl, - disabled: cell.MenuID === menu.MenuID - } - }) - } - - return submenu - }) - } - return item - }) - } else { - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - } - - this.setState({ - actvisible: true, - card: card, - formlist: getActionForm(card, functip, cards.setting, menu.permFuncField, 'card', menulist, modules) - }) - }) - } else { - this.setState({ - actvisible: true, - card: card, - formlist: getActionForm(card, functip, cards.setting, menu.permFuncField, 'card', menulist, modules) - }) - } + this.setState({ + actvisible: true, + card: card, + formlist: getActionForm(card, functip, cards.setting, menu.permFuncField, 'card', menulist, modules) + }) } getModules = (components, selfId) => { diff --git a/src/menu/components/card/data-card/wrapsetting/settingform/index.jsx b/src/menu/components/card/data-card/wrapsetting/settingform/index.jsx index 67fcd12..60d2469 100644 --- a/src/menu/components/card/data-card/wrapsetting/settingform/index.jsx +++ b/src/menu/components/card/data-card/wrapsetting/settingform/index.jsx @@ -133,9 +133,9 @@ </Col> : null} {MenuType !== 'billPrint' && config.subtype !== 'tablecard' ? <Col span={12}> <Form.Item label={ - <Tooltip placement="topLeft" title="閫夋嫨鍗$墖鍒囨崲鏃讹紝鍙悜鍏朵粬缁勪欢浼犻�掍富閿�笺��"> + <Tooltip placement="topLeft" title="鍗$墖鐐瑰嚮鏃讹紝鏄惁鍚戝叾浠栫粍浠朵紶閫掍富閿�笺��"> <Icon type="question-circle" /> - 鏄惁鍒囨崲 + 浼犻�掍富閿� </Tooltip> }> {getFieldDecorator('switch', { diff --git a/src/store/action-type.js b/src/store/action-type.js index 41b42ef..c636928 100644 --- a/src/store/action-type.js +++ b/src/store/action-type.js @@ -1,3 +1,6 @@ +// 鍒濆鍖栬彍鍗曚俊鎭� +export const MODIFY_MENUTREE = 'MODIFY_MENUTREE' + // 鍒囨崲涓昏彍鍗� export const MODIFY_MAINMENU = 'MODIFY_MAINMENU' diff --git a/src/store/action.js b/src/store/action.js index 49e1192..946142b 100644 --- a/src/store/action.js +++ b/src/store/action.js @@ -8,11 +8,19 @@ } } +// 鍒濆鍖栬彍鍗曚俊鎭� +export const modifyMenuTree = (menuTree) => { + return { + type: user.MODIFY_MENUTREE, + menuTree + } +} + // 鍒囨崲涓昏彍鍗� -export const modifyMainMenu = (selectedMainMenu) => { +export const modifyMainMenu = (mainMenu) => { return { type: user.MODIFY_MAINMENU, - selectedMainMenu + mainMenu } } diff --git a/src/store/reducer.js b/src/store/reducer.js index d936e55..63fe9bb 100644 --- a/src/store/reducer.js +++ b/src/store/reducer.js @@ -17,7 +17,8 @@ } let defaultState = { - selectedMainMenu: '', // 宸查�変富鑿滃崟 + menuTree: null, // 鑿滃崟缁撴瀯鏍� + mainMenu: null, // 宸查�変富鑿滃崟 tabviews: [], // 瀵艰埅鏍� collapse: _collapse, // 鏄惁鏀惰捣渚ц竟鏍忓鑸� isiframe: false, // 鏄惁涓篿frame绐楀彛 @@ -43,11 +44,17 @@ ...state, collapse: action.collapse } + case Type.MODIFY_MENUTREE: + // 鍒濆鍖栬彍鍗曚俊鎭� + return { + ...state, + menuTree: action.menuTree + } case Type.MODIFY_MAINMENU: // 鍒囨崲涓昏彍鍗� return { ...state, - selectedMainMenu: action.selectedMainMenu + mainMenu: action.mainMenu } case Type.MODIFY_TABVIEW: // tab椤垫敼鍙� @@ -66,7 +73,7 @@ return { ...state, ...{ - selectedMainMenu: '', + mainMenu: null, tabviews: [], collapse: false, isiframe: false @@ -80,18 +87,9 @@ } case Type.RESET_EDITSTATE: // 閲嶇疆缂栬緫鐘舵�� - if (action.editState) { - state.tabviews = [] - } else { - state.tabviews = [{ - MenuID: 'home_page_id', - MenuName: '棣栭〉', - selected: true, - type: 'Home' - }] - } return { ...state, + tabviews: [], editState: action.editState, collapse: false } @@ -99,6 +97,7 @@ // 閲嶇疆缂栬緫绾у埆 return { ...state, + editState: true, editLevel: action.editLevel } case Type.INIT_ROLESPERMISSION: @@ -146,7 +145,8 @@ } case Type.LOGOUT: return { - selectedMainMenu: '', + menuTree: null, + mainMenu: null, tabviews: [], collapse: localStorage.getItem('collapse') === 'true', isiframe: false, diff --git a/src/tabviews/custom/components/card/cardcellList/index.jsx b/src/tabviews/custom/components/card/cardcellList/index.jsx index a9d29e5..e971fce 100644 --- a/src/tabviews/custom/components/card/cardcellList/index.jsx +++ b/src/tabviews/custom/components/card/cardcellList/index.jsx @@ -159,7 +159,9 @@ val = '' + val } - if (card.format === 'thdSeparator') { + if (card.format === 'percent') { + val = val + '%' + } else if (card.format === 'thdSeparator') { val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') } } diff --git a/src/tabviews/custom/components/share/tabtransfer/index.jsx b/src/tabviews/custom/components/share/tabtransfer/index.jsx index 827ed94..3d94645 100644 --- a/src/tabviews/custom/components/share/tabtransfer/index.jsx +++ b/src/tabviews/custom/components/share/tabtransfer/index.jsx @@ -178,8 +178,8 @@ loadmaindata = (params) => { const { config } = this.props let LText_field = [] + let diffUser = false let LText = params.map((item, index) => { - let _sql = item.sql let _script = item.script if (index === 0) { @@ -187,11 +187,14 @@ ${_script} ` } + if (!diffUser && (/@userid@/ig.test(item.sql) || /@userid@/ig.test(_script))) { + diffUser = true + } item.columns.forEach(cell => { LText_field.push(`Select '${item.name}' as tablename,'${cell.field}' as fieldname,'${cell.datatype}' as field_type`) }) - return `Select '${item.name}' as tablename,'${window.btoa(window.encodeURIComponent(_sql))}' as LText,'${window.btoa(window.encodeURIComponent(_script))}' as Lcustomize,'${item.type}' as table_type,'${item.primaryKey}' as primary_key,'${item.par_tablename}' as par_tablename,'${item.foreign_key}' as foreign_key,'${index}' as Sort` + return `Select '${item.name}' as tablename,'${window.btoa(window.encodeURIComponent(item.sql))}' as LText,'${window.btoa(window.encodeURIComponent(_script))}' as Lcustomize,'${item.type}' as table_type,'${item.primaryKey}' as primary_key,'${item.par_tablename}' as par_tablename,'${item.foreign_key}' as foreign_key,'${index}' as Sort` }) let param = { @@ -206,7 +209,7 @@ if (config.cacheUseful === 'true') { param.time_type = config.timeUnit param.time_limit = config.cacheTime - if (config.diffUser) { + if (diffUser) { param.userid = sessionStorage.getItem('UserID') } param.data_md5 = md5(JSON.stringify(param)) diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index e9aae8a..9392a96 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -103,7 +103,6 @@ // 鏁版嵁缂撳瓨璁剧疆 if (config.cacheUseful === 'true') { - config.diffUser = config.diffUser !== 'false' if (!['day', 'hour'].includes(config.timeUnit)) { config.timeUnit = 'day' } @@ -156,7 +155,6 @@ inherit.cacheUseful = config.cacheUseful inherit.timeUnit = config.timeUnit inherit.cacheTime = config.cacheTime - inherit.diffUser = config.diffUser } config.components = this.formatSetting(config.components, params, mainSearch, permAction, inherit) @@ -375,8 +373,8 @@ loadmaindata = (params) => { const { config } = this.state let LText_field = [] + let diffUser = false let LText = params.map((item, index) => { - let _sql = item.sql let _script = item.script if (index === 0) { @@ -384,11 +382,14 @@ ${_script} ` } + if (!diffUser && (/@userid@/ig.test(item.sql) || /@userid@/ig.test(_script))) { + diffUser = true + } item.columns.forEach(cell => { LText_field.push(`Select '${item.name}' as tablename,'${cell.field}' as fieldname,'${cell.datatype}' as field_type`) }) - return `Select '${item.name}' as tablename,'${window.btoa(window.encodeURIComponent(_sql))}' as LText,'${window.btoa(window.encodeURIComponent(_script))}' as Lcustomize,'${item.type}' as table_type,'${item.primaryKey}' as primary_key,'${item.par_tablename}' as par_tablename,'${item.foreign_key}' as foreign_key,'${index}' as Sort` + return `Select '${item.name}' as tablename,'${window.btoa(window.encodeURIComponent(item.sql))}' as LText,'${window.btoa(window.encodeURIComponent(_script))}' as Lcustomize,'${item.type}' as table_type,'${item.primaryKey}' as primary_key,'${item.par_tablename}' as par_tablename,'${item.foreign_key}' as foreign_key,'${index}' as Sort` }) let param = { @@ -404,7 +405,7 @@ if (config.cacheUseful === 'true') { param.time_type = config.timeUnit param.time_limit = config.cacheTime - if (config.diffUser) { + if (diffUser) { param.userid = sessionStorage.getItem('UserID') } param.data_md5 = md5(JSON.stringify(param)) diff --git a/src/templates/comtableconfig/menuform/index.jsx b/src/templates/comtableconfig/menuform/index.jsx index 6fea3d2..617e4c2 100644 --- a/src/templates/comtableconfig/menuform/index.jsx +++ b/src/templates/comtableconfig/menuform/index.jsx @@ -33,7 +33,7 @@ if (key === 'fstMenuId') { let _menu = menulist.filter(cell => cell.MenuID === value)[0] - let options = _menu ? _menu.options : [] + let options = _menu ? _menu.children : [] let ParentId = options[0] ? options[0].MenuID : '' this.setState({ @@ -111,7 +111,7 @@ <Select onChange={(value) => {this.selectChange('fstMenuId', value)}}> {this.state.menulist.map(option => <Select.Option key={option.MenuID} value={option.MenuID}> - {option.text} + {option.text || option.MenuName} </Select.Option> )} </Select> @@ -132,7 +132,7 @@ <Select onChange={(value) => {this.selectChange('ParentId', value)}}> {this.state.submenulist.map(option => <Select.Option key={option.MenuID} value={option.MenuID}> - {option.text} + {option.text || option.MenuName} </Select.Option> )} </Select> diff --git a/src/templates/headerconfig/dragelement/card.jsx b/src/templates/menuconfig/editfirstmenu/dragelement/card.jsx similarity index 92% rename from src/templates/headerconfig/dragelement/card.jsx rename to src/templates/menuconfig/editfirstmenu/dragelement/card.jsx index 951f711..6a51699 100644 --- a/src/templates/headerconfig/dragelement/card.jsx +++ b/src/templates/menuconfig/editfirstmenu/dragelement/card.jsx @@ -14,9 +14,9 @@ }) const [, drop] = useDrop({ accept: ItemTypes.CARD, - canDrop: () => false, - hover({ id: draggedId }) { - if (draggedId !== id) { + canDrop: () => true, + drop: ({ id: draggedId }) => { + if (draggedId && draggedId !== id) { const { index: overIndex } = findCard(id) moveCard(draggedId, overIndex) } diff --git a/src/templates/headerconfig/dragelement/index.jsx b/src/templates/menuconfig/editfirstmenu/dragelement/index.jsx similarity index 72% rename from src/templates/headerconfig/dragelement/index.jsx rename to src/templates/menuconfig/editfirstmenu/dragelement/index.jsx index 365437c..bf3872f 100644 --- a/src/templates/headerconfig/dragelement/index.jsx +++ b/src/templates/menuconfig/editfirstmenu/dragelement/index.jsx @@ -1,6 +1,7 @@ import React, { useState } from 'react' import { useDrop } from 'react-dnd' import { Icon, Button } from 'antd' +import { is, fromJS } from 'immutable' import update from 'immutability-helper' import Card from './card' import ItemTypes from './itemtypes' @@ -15,8 +16,12 @@ handlePreviewList(_cards) } + if (!is(fromJS(cards), fromJS(list))) { + setCards(list) + } + const findCard = id => { - const card = cards.filter(c => `${c.id}` === id)[0] + const card = cards.filter(c => c.MenuID === id)[0] return { card, index: cards.indexOf(card), @@ -58,23 +63,21 @@ <div ref={drop} className="dragdashboard"> {cards.map(card => ( <Card - key={card.id} - id={`${card.id}`} - text={card.text} + key={card.MenuID} + id={`${card.MenuID}`} + text={card.MenuName} moveCard={moveCard} editCard={editCard} delCard={delCard} findCard={findCard} /> ))} - <div className="btn-group"> - <div className="card-add" onClick={add}> - <Icon type="plus" /> - </div> - <Button type="primary" onClick={thawmenu}>{dict['model.thaw'] + dict['model.menu']}</Button> - <Button type="primary" onClick={confirm}>{dict['model.confirm']}</Button> - <Button onClick={cancel}>{dict['model.close']}</Button> + <div className="card-add" onClick={add}> + <Icon type="plus" /> </div> + <Button type="primary" onClick={thawmenu}>{dict['model.thaw'] + dict['model.menu']}</Button> + <Button type="primary" onClick={confirm}>{dict['model.confirm']}</Button> + <Button onClick={cancel}>{dict['model.close']}</Button> </div> ) } diff --git a/src/templates/headerconfig/dragelement/index.scss b/src/templates/menuconfig/editfirstmenu/dragelement/index.scss similarity index 92% rename from src/templates/headerconfig/dragelement/index.scss rename to src/templates/menuconfig/editfirstmenu/dragelement/index.scss index aceb422..27d0004 100644 --- a/src/templates/headerconfig/dragelement/index.scss +++ b/src/templates/menuconfig/editfirstmenu/dragelement/index.scss @@ -1,14 +1,14 @@ .dragdashboard { position: relative; z-index: 1; - width: calc(100vw - 400px); + width: calc(100vw - 350px); float: left; background: #001529; padding-bottom: 5px; .card-add { border: 1px dashed gray; - padding: 2px; - margin-top: 13px; + padding: 4px; + margin-top: 9px; margin-left: 10px; width: 50px; float: left; diff --git a/src/templates/headerconfig/dragelement/itemtypes.js b/src/templates/menuconfig/editfirstmenu/dragelement/itemtypes.js similarity index 100% rename from src/templates/headerconfig/dragelement/itemtypes.js rename to src/templates/menuconfig/editfirstmenu/dragelement/itemtypes.js diff --git a/src/templates/headerconfig/index.jsx b/src/templates/menuconfig/editfirstmenu/index.jsx similarity index 92% rename from src/templates/headerconfig/index.jsx rename to src/templates/menuconfig/editfirstmenu/index.jsx index 0d2f1fb..1c5c46d 100644 --- a/src/templates/headerconfig/index.jsx +++ b/src/templates/menuconfig/editfirstmenu/index.jsx @@ -22,7 +22,6 @@ import card5 from '@/assets/img/card-bg6.jpg' const { confirm } = Modal -let previewList = null class EditMenu extends Component { static propTpyes = { @@ -34,6 +33,7 @@ state = { thawmenulist: null, // 宸插喕缁撶殑涓�绾ц彍鍗� addMvisible: null, + menulist: null, editMenu: null, // 缂栬緫鑿滃崟 editMvisible: false, // 缂栬緫鑿滃崟妯℃�佹 thawMvisible: false, // 瑙i櫎鍐荤粨妯℃�佹 @@ -43,13 +43,13 @@ handlePreviewList = (List) => { // 鑿滃崟椤哄簭鏀瑰彉鏃讹紝淇濆瓨涓棿鐘舵�� - previewList = List + this.setState({menulist: List}) } editMenuModal = (Menu) => { // 鑿滃崟缂栬緫锛氫慨鏀� const menu = fromJS(Menu).toJS() - if (previewList && !is(fromJS(previewList), fromJS(this.props.menulist))) { + if (!is(fromJS(this.state.menulist), fromJS(this.props.menulist))) { notification.warning({ top: 92, message: this.state.dict['model.menu.presave'], @@ -219,7 +219,8 @@ handleButton = (type) => { // 鑿滃崟缂栬緫锛氭坊鍔狅紝纭畾锛屽彇娑� - let _menuchange = previewList && !is(fromJS(previewList), fromJS(this.props.menulist)) + let _menuchange = !is(fromJS(this.state.menulist), fromJS(this.props.menulist)) + if ((type === 'add' || type === 'thawmenu') && _menuchange) { notification.warning({ top: 92, @@ -234,7 +235,7 @@ let _this = this let param = { func: 'sPC_Menu_SortUpt', - LText: previewList.map((item, index) => { + LText: this.state.menulist.map((item, index) => { return 'select \'' + item.MenuID + '\' as Menuid,' + (index + 1) * 10 + ' as sort' }) } @@ -259,6 +260,17 @@ }) } }) + }, + onCancel() {} + }) + } else if (type === 'cancel' && _menuchange) { + let _this = this + + confirm({ + title: '鑿滃崟椤哄簭宸茶皟鏁达紝鏀惧純淇濆瓨鍚楋紵', + content: '', + onOk() { + _this.props.exitEdit() }, onCancel() {} }) @@ -294,17 +306,17 @@ } UNSAFE_componentWillMount () { - previewList = null + this.setState({menulist: fromJS(this.props.menulist).toJS()}) } UNSAFE_componentWillReceiveProps (nextProps) { if (!is(fromJS(this.props.menulist), fromJS(nextProps.menulist))) { - previewList = null + this.setState({menulist: fromJS(nextProps.menulist).toJS()}) } } render () { - const { dict } = this.state + const { dict, menulist } = this.state return ( <div className="header-edit-box"> @@ -328,16 +340,16 @@ </div> </div> </div> - {this.props.menulist && <DndProvider backend={HTML5Backend}> + <DndProvider backend={HTML5Backend}> <DragElement dict={dict} - list={this.props.menulist} + list={menulist} handlePreviewList={this.handlePreviewList} handleMenu={this.editMenuModal} deleteMemu={this.deleteMemu} handleButton={this.handleButton} /> - </DndProvider>} + </DndProvider> {/* 鏂板缓鑿滃崟妯℃�佹 */} <Modal title={dict['model.add'] + dict['model.menu']} diff --git a/src/templates/headerconfig/index.scss b/src/templates/menuconfig/editfirstmenu/index.scss similarity index 100% rename from src/templates/headerconfig/index.scss rename to src/templates/menuconfig/editfirstmenu/index.scss diff --git a/src/templates/headerconfig/menuform/index.jsx b/src/templates/menuconfig/editfirstmenu/menuform/index.jsx similarity index 71% rename from src/templates/headerconfig/menuform/index.jsx rename to src/templates/menuconfig/editfirstmenu/menuform/index.jsx index 88760c9..23993be 100644 --- a/src/templates/headerconfig/menuform/index.jsx +++ b/src/templates/menuconfig/editfirstmenu/menuform/index.jsx @@ -1,6 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Row, Col, Input, Select } from 'antd' +import { Form, Row, Col, Input, Select, Radio } from 'antd' import Utils from '@/utils/utils.js' import './index.scss' @@ -23,7 +23,7 @@ readonly: false }, { - type: 'select', + type: 'radio', key: 'openType', label: this.props.dict['model.openway'], initVal: 'menu', @@ -31,44 +31,45 @@ options: [{ id: 'menu', text: this.props.dict['model.menu'] - // }, { - // id: 'newpage', - // text: this.props.dict['model.new'] + this.props.dict['model.window'] + }, { + id: 'outpage', + text: '澶栭儴椤甸潰' }] }, { - type: 'select', + type: 'text', key: 'linkUrl', + label: '椤甸潰鍦板潃', + initVal: '', hidden: true, - label: this.props.dict['model.new'] + this.props.dict['model.window'], - initVal: 'service', - required: true, - options: [] + required: true } ] } UNSAFE_componentWillMount () { + const { menu } = this.props + if (this.props.type === 'add') { this.setState({ formlist: this.state.defaultMenu }) } else { this.setState({ - formlist: this.state.defaultMenu.map(menu => { - if (menu.key === 'menuName') { - menu.initVal = this.props.menu.MenuName - } else if (menu.key === 'openType') { - menu.initVal = this.props.menu.PageParam.OpenType - } else if (menu.key === 'linkUrl') { - menu.initVal = this.props.menu.PageParam.linkUrl - if (this.props.menu.PageParam.OpenType === 'menu') { - menu.hidden = true - } else if (this.props.menu.PageParam.OpenType === 'newpage') { - menu.hidden = false + formlist: this.state.defaultMenu.map(item => { + if (item.key === 'menuName') { + item.initVal = menu.MenuName + } else if (item.key === 'openType') { + item.initVal = menu.PageParam.OpenType + } else if (item.key === 'linkUrl') { + item.initVal = menu.PageParam.linkUrl + if (menu.PageParam.OpenType === 'menu') { + item.hidden = true + } else if (menu.PageParam.OpenType === 'outpage') { + item.hidden = false } } - return menu + return item }) }) } @@ -77,11 +78,11 @@ openTypeChange = (key, value) => { if (key === 'openType') { let formlist = this.state.formlist - if (value === 'newpage') { + if (value === 'outpage') { formlist.forEach(item => { if (item.key === 'linkUrl') { item.hidden = false - item.initVal = 'service' + item.initVal = '' } }) } else { @@ -91,6 +92,7 @@ } }) } + this.setState({formlist}) } } @@ -137,13 +139,39 @@ getPopupContainer={() => document.getElementById('form-box')} > {item.options.map(option => - <Select.Option id={option.id} title={option.text} key={option.id} value={option.id}>{option.text}</Select.Option> + <Select.Option key={option.id} value={option.id}>{option.text}</Select.Option> )} </Select> )} </Form.Item> </Col> ) + } else if (item.type === 'radio') { // 涓嬫媺鎼滅储 + fields.push( + <Col span={24} key={index}> + <Form.Item label={item.label}> + {getFieldDecorator(item.key, { + initialValue: item.initVal || '', + rules: [ + { + required: !!item.required, + message: this.props.dict['form.required.select'] + item.label + '!' + } + ] + })( + <Radio.Group onChange={(e) => {this.openTypeChange(item.key, e.target.value)}}> + { + item.options.map(option => { + return ( + <Radio key={option.id} value={option.id}>{option.text}</Radio> + ) + }) + } + </Radio.Group> + )} + </Form.Item> + </Col> + ) } }) diff --git a/src/templates/headerconfig/menuform/index.scss b/src/templates/menuconfig/editfirstmenu/menuform/index.scss similarity index 100% rename from src/templates/headerconfig/menuform/index.scss rename to src/templates/menuconfig/editfirstmenu/menuform/index.scss diff --git a/src/templates/menuconfig/editsecmenu/index.jsx b/src/templates/menuconfig/editsecmenu/index.jsx index 4aa7c4b..fcafd48 100644 --- a/src/templates/menuconfig/editsecmenu/index.jsx +++ b/src/templates/menuconfig/editsecmenu/index.jsx @@ -25,7 +25,7 @@ class EditMenu extends Component { static propTpyes = { menulist: PropTypes.any, // 浜岀骇鑿滃崟鍒楄〃 - supMenuList: PropTypes.array, // 涓�绾ц彍鍗曞垪琛� + menuTree: PropTypes.array, // 涓�绾ц彍鍗曞垪琛� supMenu: PropTypes.object, // 浜岀骇鑿滃崟鎵�瀵瑰簲鐨勪竴绾ц彍鍗� reload: PropTypes.func, // 鍒锋柊浜岀骇鑿滃崟鏁版嵁 exitEdit: PropTypes.func // 閫�鍑虹紪杈� @@ -63,7 +63,7 @@ }) } else if (menu.type === 'close') { confirm({ - title: dict['model.menu.close'].replace('@M', menu.card.text), + title: dict['model.menu.close'].replace('@M', menu.card.MenuName), content: '', onOk() { let param = { @@ -97,13 +97,13 @@ label: dict['model.super'] + dict['model.menu'], initVal: this.props.supMenu.MenuID, required: true, - options: this.props.supMenuList + options: this.props.menuTree }, { // 鑿滃崟鍚嶇О type: 'text', key: 'menuName', label: dict['model.menu'] + dict['model.name'], - initVal: menu.card.text, + initVal: menu.card.MenuName, required: true, readonly: false }, @@ -142,7 +142,7 @@ label: dict['model.super'] + dict['model.menu'], initVal: this.props.supMenu.MenuID, required: true, - options: this.props.supMenuList + options: this.props.menuTree }, { // 鑿滃崟鍚嶇О type: 'text', @@ -231,7 +231,20 @@ this.props.exitEdit() } } else if (type === 'close') { // 閫�鍑虹紪杈� - this.props.exitEdit() + if (!is(fromJS(this.props.menulist), fromJS(this.state.menulist))) { + let _this = this + + confirm({ + title: '鑿滃崟椤哄簭宸茶皟鏁达紝鏀惧純淇濆瓨鍚楋紵', + content: '', + onOk() { + _this.props.exitEdit() + }, + onCancel() {} + }) + } else { + this.props.exitEdit() + } } } @@ -428,12 +441,12 @@ confirmLoading={this.state.confirmLoading} onCancel={this.memuHandleCancel} > - {this.state.formlist && - <MenuForm - dict={dict} - formlist={this.state.formlist} - wrappedComponentRef={(inst) => this.menuFormRef = inst} - />} + {this.state.formlist ? + <MenuForm + dict={dict} + formlist={this.state.formlist} + wrappedComponentRef={(inst) => this.menuFormRef = inst} + /> : null} </Modal> <Modal title={dict['model.thaw'] + dict['model.menu']} diff --git a/src/templates/menuconfig/editthdmenu/index.jsx b/src/templates/menuconfig/editthdmenu/index.jsx index 60f1ace..11d4b2b 100644 --- a/src/templates/menuconfig/editthdmenu/index.jsx +++ b/src/templates/menuconfig/editthdmenu/index.jsx @@ -78,8 +78,6 @@ btnTabConfig: null, // 鎵撳紑鏂版爣绛炬寜閽厤缃� handleMVisible: false, // 娣诲姞鎴栦慨鏀硅彍鍗曟ā鎬佹锛堣鑹叉潈闄愬垎閰嶇瓑锛� sysMenu: false, // 娣诲姞鎴栫紪杈戣彍鍗曪紙瑙掕壊鏉冮檺鍒嗛厤绛夛級 - fstMenuId: null, // 涓�绾ц彍鍗旾d - fstMenuList: null // 涓�绾ц彍鍗曞垪琛� } /** @@ -117,7 +115,7 @@ }) } else if (menu.type === 'close') { confirm({ - title: this.state.dict['model.menu.close'].replace('@M', menu.card.text), + title: this.state.dict['model.menu.close'].replace('@M', menu.card.MenuName), content: '', onOk() { let param = { @@ -141,26 +139,13 @@ } else if (menu.type === 'edit') { let _menu = fromJS(menu.card).toJS() - delete _menu.id - delete _menu.src - delete _menu.text - if (_menu.PageParam && (_menu.PageParam.Template === 'RolePermission' || _menu.PageParam.Template === 'NewPage')) { // 鍗曢〉闈慨鏀� _menu.Template = _menu.PageParam.Template _menu.url = _menu.PageParam.url - if (!this.state.fstMenuId) { - notification.warning({ - top: 92, - message: '鑿滃崟鍔犺浇涓紝璇风◢鍚庨噸璇曪紒', - duration: 5 - }) - return - } - + _menu.fstMenuId = _menu.FstId _menu.supMenuList = this.props.supMenuList - _menu.fstMenuId = this.state.fstMenuId || '' - _menu.fstMenuList = this.state.fstMenuList || [] + _menu.fstMenuList = this.props.menuTree this.setState({ handleMVisible: true, @@ -193,9 +178,9 @@ } _menu.LongParam = _LongParam + _menu.fstMenuId = _menu.FstId _menu.supMenuList = this.props.supMenuList - _menu.fstMenuId = this.state.fstMenuId || '' - _menu.fstMenuList = this.state.fstMenuList || [] + _menu.fstMenuList = this.props.menuTree _menu.open_edition = res.open_edition || '' // 妫�娴嬫ā鏉挎槸鍚﹀瓨鍦� @@ -217,7 +202,7 @@ }, () => { document.getElementById('root').style.overflowY = 'hidden' }) - } else if (_menu.fstMenuId) { + } else { this.setState({ type: 'edit', editMenu: _menu, @@ -225,12 +210,6 @@ tabview: _menu.PageParam.Template }, () => { document.getElementById('root').style.overflowY = 'hidden' - }) - } else { - _menu.loadingFstMenuId = true - this.setState({ - type: 'edit', - editMenu: _menu }) } } else { @@ -259,15 +238,6 @@ return } - if (!this.state.fstMenuId) { - notification.warning({ - top: 92, - message: '鑿滃崟鍔犺浇涓紝璇风◢鍚庨噸璇曪紒', - duration: 5 - }) - return - } - this.setState({ tabview: 'template', editMenu: { @@ -280,8 +250,8 @@ isSubtable: '', // 鏄惁涓轰富瀛愯〃 ParentId: this.props.supMenu.MenuID, supMenuList: this.props.supMenuList, - fstMenuId: this.state.fstMenuId, - fstMenuList: this.state.fstMenuList, + fstMenuId: this.props.mainMenu.MenuID, + fstMenuList: this.props.menuTree, menuSort: (this.props.menulist.length + 1) * 10 // 鏂板缓鑿滃崟璁剧疆鎺掑簭 } }, () => { @@ -358,7 +328,20 @@ this.props.exitEdit() } } else if (type === 'close') { - this.props.exitEdit() + if (!is(fromJS(this.props.menulist), fromJS(this.state.menulist))) { + let _this = this + + confirm({ + title: '鑿滃崟椤哄簭宸茶皟鏁达紝鏀惧純淇濆瓨鍚楋紵', + content: '', + onOk() { + _this.props.exitEdit() + }, + onCancel() {} + }) + } else { + this.props.exitEdit() + } } } @@ -439,19 +422,8 @@ useTemplate = (template, useType) => { let editMenu = fromJS(this.state.editMenu).toJS() - if (!this.state.fstMenuId) { - notification.warning({ - top: 92, - message: '鑿滃崟鍔犺浇涓紝璇风◢鍚庨噸璇曪紒', - duration: 5 - }) - return - } - - if (!editMenu.fstMenuId) { - editMenu.fstMenuId = this.state.fstMenuId - editMenu.fstMenuList = this.state.fstMenuList - } + editMenu.fstMenuId = this.props.mainMenu.MenuID + editMenu.fstMenuList = this.props.menuTree if (useType === 'sys' && (template.type === 'RolePermission' || template.type === 'NewPage')) { // 鐙珛椤甸潰 let _menu = { @@ -722,69 +694,6 @@ }) } - componentDidMount () { - let _param = { - func: 's_Get_FSMenusForOpen', - SndMenuID: this.props.supMenu.MenuID, - TYPE: 20, - TypeCharOne: 'PC' - } - this.setState({ - loading: true - }) - - Api.getSystemConfig(_param).then(result => { - if (result.status) { - this.setState({ - loading: false, - fstMenuId: result.FstIDSeleted, - fstMenuList: result.data.map(smenu => { - let _smenu = { - MenuID: smenu.FstID, - text: smenu.FstName, - options: smenu.SndData.map(menu => { - return { - MenuID: menu.SndID, - text: menu.SndName, - } - }) - } - - return _smenu - }) - }, () => { - let _menu = this.state.editMenu ? fromJS(this.state.editMenu).toJS() : null - - if (!_menu || !_menu.loadingFstMenuId) { - return - } - - delete _menu.loadingFstMenuId - _menu.fstMenuId = this.state.fstMenuId - _menu.fstMenuList = this.state.fstMenuList - - this.setState({ - type: 'edit', - editMenu: _menu, - loading: false, - tabview: _menu.PageParam.Template - }, () => { - document.getElementById('root').style.overflowY = 'hidden' - }) - }) - } else { - this.setState({ - loading: false - }) - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - } - }) - } - UNSAFE_componentWillReceiveProps (nextProps) { if (!is(fromJS(this.props.menulist), fromJS(nextProps.menulist))) { this.setState({ @@ -821,7 +730,7 @@ } <div className="cus-submenu-title"> <Icon type={this.props.supMenu.PageParam.Icon} /> - <span>{this.props.supMenu.text}</span> + <span>{this.props.supMenu.MenuName}</span> </div> <DndProvider backend={HTML5Backend}> <DragElement @@ -985,6 +894,8 @@ const mapStateToProps = (state) => { return { + mainMenu: state.mainMenu, + menuTree: state.menuTree, memberLevel: state.memberLevel } } diff --git a/src/templates/menuconfig/editthdmenu/menuform/index.jsx b/src/templates/menuconfig/editthdmenu/menuform/index.jsx index 5eea673..e7b5f02 100644 --- a/src/templates/menuconfig/editthdmenu/menuform/index.jsx +++ b/src/templates/menuconfig/editthdmenu/menuform/index.jsx @@ -28,9 +28,9 @@ if (submenu) { this.setState({ - menu: {...menu, supMenuList: submenu.options} + menu: {...menu, supMenuList: submenu.children} }, () => { - this.props.form.setFieldsValue({ParentID: submenu.options[0] ? submenu.options[0].MenuID : ''}) + this.props.form.setFieldsValue({ParentID: submenu.children[0] ? submenu.children[0].MenuID : ''}) }) } } @@ -82,7 +82,7 @@ onChange={this.changeMenu} > {menu.fstMenuList.map(option => - <Select.Option id={option.MenuID} title={option.text} key={option.MenuID} value={option.MenuID}>{option.text}</Select.Option> + <Select.Option key={option.MenuID} value={option.MenuID}>{option.text || option.MenuName}</Select.Option> )} </Select> )} @@ -104,7 +104,7 @@ filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} > {menu.supMenuList.map(option => - <Select.Option id={option.MenuID} title={option.text} key={option.MenuID} value={option.MenuID}>{option.text}</Select.Option> + <Select.Option key={option.MenuID} value={option.MenuID}>{option.text || option.MenuName}</Select.Option> )} </Select> )} @@ -144,6 +144,10 @@ { required: true, message: this.props.dict['form.required.input'] + '椤甸潰鍦板潃!' + }, + { + max: 1024, + message: '鍦板潃鏈�闀夸负1024涓瓧绗�!' } ] })(<Input placeholder="" autoComplete="off" />)} diff --git a/src/templates/menuconfig/menuelement/card.jsx b/src/templates/menuconfig/menuelement/card.jsx index 52ec9f3..3777966 100644 --- a/src/templates/menuconfig/menuelement/card.jsx +++ b/src/templates/menuconfig/menuelement/card.jsx @@ -14,8 +14,8 @@ }) const [, drop] = useDrop({ accept: ItemTypes.CARD, - canDrop: () => false, - hover({ id: draggedId }) { + canDrop: () => true, + drop({ id: draggedId }) { if (draggedId !== id) { const { index: overIndex } = findCard(id) moveCard(draggedId, overIndex) @@ -48,7 +48,7 @@ <div className="side-card" style={{ opacity }}> <div ref={node => drag(drop(node))}> {card.PageParam && card.PageParam.Icon && <Icon type={card.PageParam.Icon} />} - {card.text} + {card.MenuName} </div> {/* 鑷畾涔夋ā鏉匡紝鍦ㄦ柊椤甸潰缂栬緫 */} {!card.forbidden && card.type !== 'CustomPage' ? <Icon className="edit" type="edit" onClick={edit} /> : null} diff --git a/src/templates/menuconfig/menuelement/index.jsx b/src/templates/menuconfig/menuelement/index.jsx index 05fc86d..cf31fe6 100644 --- a/src/templates/menuconfig/menuelement/index.jsx +++ b/src/templates/menuconfig/menuelement/index.jsx @@ -19,7 +19,7 @@ } const findCard = id => { - const card = cards.filter(c => `${c.id}` === id)[0] + const card = cards.filter(c => c.MenuID === id)[0] return { card, index: cards.indexOf(card), @@ -49,8 +49,8 @@ <div ref={drop} className="sidemenu-dragboard"> {cards.map(card => ( <Card - key={card.id} - id={card.id} + key={card.MenuID} + id={card.MenuID} card={card} moveCard={moveCard} editCard={editCard} diff --git a/src/templates/menuconfig/menuform/index.jsx b/src/templates/menuconfig/menuform/index.jsx index df67ec6..5c6727a 100644 --- a/src/templates/menuconfig/menuform/index.jsx +++ b/src/templates/menuconfig/menuform/index.jsx @@ -70,8 +70,8 @@ getPopupContainer={() => document.getElementById('form-box')} > {item.options.map(option => - <Select.Option id={option.MenuID} title={option.text} key={option.MenuID} value={option.MenuID}> - {item.key === 'icon' && <Icon type={option.text} />} {option.text} + <Select.Option id={option.MenuID} key={option.MenuID} value={option.MenuID}> + {item.key === 'icon' && <Icon type={option.text} />} {option.text || option.MenuName} </Select.Option> )} </Select> diff --git a/src/templates/sharecomponent/actioncomponent/actionform/index.jsx b/src/templates/sharecomponent/actioncomponent/actionform/index.jsx index 9138958..6d94404 100644 --- a/src/templates/sharecomponent/actioncomponent/actionform/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/actionform/index.jsx @@ -4,8 +4,6 @@ import { Form, Row, Col, Input, Select, Icon, Radio, notification, Tooltip, InputNumber, Cascader } from 'antd' import { btnIcons, btnClasses, formRule } from '@/utils/option.js' -import Api from '@/api' -import options from '@/store/options.js' import Utils from '@/utils/utils.js' import './index.scss' @@ -629,11 +627,7 @@ } ] })( - <Cascader - options={this.state.menulist} - loadData={this.loadData} - placeholder="" - /> + <Cascader options={this.state.menulist} placeholder="" /> )} </Form.Item> </Col> @@ -641,57 +635,6 @@ } }) return fields - } - - loadData = selectedOptions => { - const { MenuID } = this.props - const targetOption = selectedOptions[selectedOptions.length - 1] - targetOption.loading = true - - let _param = { - func: 'sPC_Get_FunMenu', - ParentID: targetOption.value, - systemType: options.sysType, - debug: 'Y' - } - - Api.getSystemConfig(_param).then(result => { - if (result.status) { - targetOption.loading = false - targetOption.children = result.data.map(item => { - let submenu = { - value: item.ParentID, - label: item.MenuNameP, - children: item.FunMenu.map(cell => { - return { - value: cell.MenuID, - label: cell.MenuName, - MenuID: cell.MenuID, - MenuName: cell.MenuName, - MenuNo: cell.MenuNo, - Ot: cell.Ot, - PageParam: cell.PageParam, - LinkUrl: cell.LinkUrl, - disabled: cell.MenuID === MenuID - } - }) - } - - return submenu - }) - - this.setState({ - menulist: [...this.state.menulist] - }) - } else { - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - targetOption.loading = false - } - }) } handleConfirm = () => { diff --git a/src/templates/sharecomponent/actioncomponent/index.jsx b/src/templates/sharecomponent/actioncomponent/index.jsx index 4302d09..11d168b 100644 --- a/src/templates/sharecomponent/actioncomponent/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/index.jsx @@ -5,7 +5,6 @@ import moment from 'moment' import Api from '@/api' -import options from '@/store/options.js' import Utils from '@/utils/utils.js' import DevUtils from '@/utils/devutils.js' import zhCN from '@/locales/zh-CN/model.js' @@ -146,73 +145,35 @@ </div> let menulist = [] + if (menu.fstMenuList) { - menulist = menu.fstMenuList.map(item => { - return { - value: item.MenuID, - label: item.text, - isLeaf: false - } - }) - } + let trees = fromJS(menu.fstMenuList).toJS() - if (menu.fstMenuList && card.linkmenu && card.linkmenu.length > 0) { - let _param = { - func: 'sPC_Get_FunMenu', - ParentID: card.linkmenu[0], - systemType: options.sysType, - debug: 'Y' - } - - Api.getSystemConfig(_param).then(result => { - if (result.status) { - menulist = menulist.map(item => { - if (item.value === card.linkmenu[0]) { - item.children = result.data.map(item => { - let submenu = { - value: item.ParentID, - label: item.MenuNameP, - children: item.FunMenu.map(cell => { - return { - value: cell.MenuID, - label: cell.MenuName, - MenuID: cell.MenuID, - MenuName: cell.MenuName, - MenuNo: cell.MenuNo, - Ot: cell.Ot, - PageParam: cell.PageParam, - LinkUrl: cell.LinkUrl, - disabled: cell.MenuID === menu.MenuID - } - }) - } + menulist = trees.map(fst => { + fst.value = fst.MenuID + fst.label = fst.MenuName + fst.isLeaf = false + fst.children = fst.children.map(snd => { + snd.value = snd.MenuID + snd.label = snd.MenuName - return submenu - }) - } - return item + snd.children = snd.children.map(thd => { + thd.value = thd.MenuID + thd.label = thd.MenuName + thd.disabled = thd.MenuID === menu.MenuID + return thd }) - } else { - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - } - - this.setState({ - visible: true, - card: card, - formlist: getActionForm(card, functip, this.props.config, this.props.usefulFields, this.props.type, menulist, this.state.printTemps) + return snd }) - }) - } else { - this.setState({ - visible: true, - card: card, - formlist: getActionForm(card, functip, this.props.config, this.props.usefulFields, this.props.type, menulist, this.state.printTemps) + return fst }) } + + this.setState({ + visible: true, + card: card, + formlist: getActionForm(card, functip, this.props.config, this.props.usefulFields, this.props.type, menulist, this.state.printTemps) + }) } /** diff --git a/src/templates/sharecomponent/columncomponent/columnform/index.jsx b/src/templates/sharecomponent/columncomponent/columnform/index.jsx index 4d1d544..c7ff675 100644 --- a/src/templates/sharecomponent/columncomponent/columnform/index.jsx +++ b/src/templates/sharecomponent/columncomponent/columnform/index.jsx @@ -1,10 +1,8 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Row, Col, Input, Select, InputNumber, Radio, Tooltip, Icon, Cascader, notification } from 'antd' +import { Form, Row, Col, Input, Select, InputNumber, Radio, Tooltip, Icon, Cascader } from 'antd' import { formRule } from '@/utils/option.js' -import options from '@/store/options.js' -import Api from '@/api' import './index.scss' const columnTypeOptions = { @@ -289,7 +287,6 @@ })( <Cascader options={this.state.menulist} - loadData={this.loadData} placeholder="" getPopupContainer={() => document.getElementById('columnwinter')} /> @@ -300,57 +297,6 @@ } }) return fields - } - - loadData = selectedOptions => { - const { MenuID } = this.props - const targetOption = selectedOptions[selectedOptions.length - 1] - targetOption.loading = true - - let _param = { - func: 'sPC_Get_FunMenu', - ParentID: targetOption.value, - systemType: options.sysType, - debug: 'Y' - } - - Api.getSystemConfig(_param).then(result => { - if (result.status) { - targetOption.loading = false - targetOption.children = result.data.map(item => { - let submenu = { - value: item.ParentID, - label: item.MenuNameP, - children: item.FunMenu.map(cell => { - return { - value: cell.MenuID, - label: cell.MenuName, - MenuID: cell.MenuID, - MenuName: cell.MenuName, - MenuNo: cell.MenuNo, - Ot: cell.Ot, - PageParam: cell.PageParam, - LinkUrl: cell.LinkUrl, - disabled: cell.MenuID === MenuID - } - }) - } - - return submenu - }) - - this.setState({ - menulist: [...this.state.menulist] - }) - } else { - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - targetOption.loading = false - } - }) } handleConfirm = () => { diff --git a/src/templates/sharecomponent/columncomponent/index.jsx b/src/templates/sharecomponent/columncomponent/index.jsx index 8afc68f..a1e0242 100644 --- a/src/templates/sharecomponent/columncomponent/index.jsx +++ b/src/templates/sharecomponent/columncomponent/index.jsx @@ -3,8 +3,6 @@ import { is, fromJS } from 'immutable' import { Icon, Tooltip, Modal, notification, Switch, message, Spin } from 'antd' -import Api from '@/api' -import options from '@/store/options.js' import zhCN from '@/locales/zh-CN/model.js' import enUS from '@/locales/en-US/model.js' import { getColumnForm } from '@/templates/zshare/formconfig' @@ -91,76 +89,36 @@ const { menu } = this.props if (card.type !== 'colspan') { - let menulist = menu.fstMenuList.map(item => { - return { - value: item.MenuID, - label: item.text, - isLeaf: false - } - }) + let menulist = [] - if ((card.type === 'text' || card.type === 'number') && card.linkmenu && card.linkmenu.length > 0) { - let _param = { - func: 'sPC_Get_FunMenu', - ParentID: card.linkmenu[0], - systemType: options.sysType, - debug: 'Y' - } + if (menu.fstMenuList) { + let trees = fromJS(menu.fstMenuList).toJS() - this.setState({ - loading: true - }) - - Api.getSystemConfig(_param).then(result => { - if (result.status) { - menulist = menulist.map(item => { - if (item.value === card.linkmenu[0]) { - item.children = result.data.map(item => { - let submenu = { - value: item.ParentID, - label: item.MenuNameP, - children: item.FunMenu.map(cell => { - return { - value: cell.MenuID, - label: cell.MenuName, - MenuID: cell.MenuID, - MenuName: cell.MenuName, - MenuNo: cell.MenuNo, - Ot: cell.Ot, - PageParam: cell.PageParam, - LinkUrl: cell.LinkUrl, - disabled: cell.MenuID === menu.MenuID - } - }) - } + menulist = trees.map(fst => { + fst.value = fst.MenuID + fst.label = fst.MenuName + fst.isLeaf = false + fst.children = fst.children.map(snd => { + snd.value = snd.MenuID + snd.label = snd.MenuName - return submenu - }) - } - return item + snd.children = snd.children.map(thd => { + thd.value = thd.MenuID + thd.label = thd.MenuName + thd.disabled = thd.MenuID === menu.MenuID + return thd }) - } else { - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - } - - this.setState({ - loading: false, - modaltype: 'columns', - card: card, - formlist: getColumnForm(card, this.props.sysRoles, menulist) + return snd }) - }) - } else { - this.setState({ - modaltype: 'columns', - card: card, - formlist: getColumnForm(card, this.props.sysRoles, menulist) + return fst }) } + + this.setState({ + modaltype: 'columns', + card: card, + formlist: getColumnForm(card, this.props.sysRoles, menulist) + }) } else { this.setState({ modaltype: 'colspan', diff --git a/src/utils/utils.js b/src/utils/utils.js index 8df4de7..4deb649 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -642,9 +642,7 @@ } else { baseurl = window.GLOB.location + window.GLOB.service } - // if (!/Content\/images\/upload\//.test(url)) { - // baseurl = baseurl + 'Content/images/upload/' - // } + let realurl = url.match(/^http/) || url.match(/^\/\//) ? url : baseurl + url return realurl } diff --git a/src/views/billprint/index.jsx b/src/views/billprint/index.jsx index eda3914..0800086 100644 --- a/src/views/billprint/index.jsx +++ b/src/views/billprint/index.jsx @@ -107,29 +107,39 @@ } config.style = config.style || {} - config.zoom = 1 + config.pageSize = ['A4', 'A3', 'A5'].includes(config.pageSize) ? config.pageSize : 'A4' + config.pageLayout = config.pageLayout !== 'horizontal' ? 'vertical' : 'horizontal' + config.pagePadding = config.pagePadding !== 'without' ? 'default' : 'without' - if (config.pageSize === 'A3') { - if (config.pageLayout === 'horizontal') { - config.zoom = 1.35 - config.style.height = 845 - } else { - config.style.height = 1695 - } - } else if (config.pageSize === 'A5') { - config.zoom = 0.7 - if (config.pageLayout === 'horizontal') { - config.style.height = 840 - } else { - config.style.height = 1700 - } - } else { - if (config.pageLayout === 'horizontal') { - config.style.height = 845 - } else { - config.style.height = 1680 + let pageParam = { + A4: { + vertical: 1000, + horizontal: 1200, + verticaldefault: 1.45789, + verticalwithout: 1.41428, + horizontaldefault: 0.685, + horizontalwithout: 0.705, + }, + A3: { + vertical: 1200, + horizontal: 1600, + verticaldefault: 1.44404, + verticalwithout: 1.41414, + horizontaldefault: 0.6923, + horizontalwithout: 0.707, + }, + A5: { + vertical: 700, + horizontal: 1000, + verticaldefault: 1.482, + verticalwithout: 1.417, + horizontaldefault: 0.6736, + horizontalwithout: 0.7047, } } + + config.width = pageParam[config.pageSize][config.pageLayout] + config.style.height = Math.floor(config.width * pageParam[config.pageSize][config.pageLayout + config.pagePadding]) let params = [] let _pars = [] @@ -457,55 +467,35 @@ print = () => { const { config } = this.state - let jubuData = document.getElementById('bill-print').innerHTML - window.document.body.innerHTML = jubuData - document.getElementsByTagName('body')[0].style.width = '1200px' - document.getElementsByTagName('body')[0].style.margin = '0 auto' - document.getElementsByTagName('body')[0].style.zoom = config.zoom - + try { - if (window.ActiveXObject) { - let hkeyRoot - let hkeyPath - let hkeyKey - // eslint-disable-next-line - let RegWsh = new ActiveXObject('WScript.Shell') + let iframe = document.createElement('IFRAME') + let linkList = document.getElementsByTagName('link') // 鑾峰彇鐖剁獥鍙ink鏍囩瀵硅薄鍒楄〃 + let styleList = document.getElementsByTagName('style') // 鑾峰彇鐖剁獥鍙tyle鏍囩瀵硅薄鍒楄〃 - hkeyRoot = 'HKEY_CURRENT_USER' - hkeyPath = '\\Software\\Microsoft\\Internet Explorer\\PageSetup\\' - - // 璁剧疆椤电湁/鑴氱殑瀛椾綋鏍峰紡 - hkeyKey = 'font' - RegWsh.RegWrite(hkeyRoot + hkeyPath + hkeyKey, 'font-size: 12px; font-family: 榛戜綋; line-height: 24px') - - // 璁剧疆椤电湁 - hkeyKey = 'header' - RegWsh.RegWrite(hkeyRoot + hkeyPath + hkeyKey, '鎵撳嵃缂栧彿') - - // 璁剧疆椤佃剼 - hkeyKey = 'footer' - RegWsh.RegWrite(hkeyRoot + hkeyPath + hkeyKey, '&b绗� &p 椤�/鍏� &P 椤�') - - // 璁剧疆椤佃竟璺�(0.6 瑕佷箻浠� 2.5涓哄疄闄呮墦鍗扮殑灏哄) - hkeyKey = 'margin_bottom' - RegWsh.RegWrite(hkeyRoot + hkeyPath + hkeyKey, '0.6') - - hkeyKey = 'margin_left' - RegWsh.RegWrite(hkeyRoot + hkeyPath + hkeyKey, '0.6') - - hkeyKey = 'margin_right' - RegWsh.RegWrite(hkeyRoot + hkeyPath + hkeyKey, '0.6') - - hkeyKey = 'margin_top' - RegWsh.RegWrite(hkeyRoot + hkeyPath + hkeyKey, '0.6') - - window.print() - } else { - window.print() + document.body.appendChild(iframe) + let doc = iframe.contentWindow.document + + doc.open() + doc.write(`<!DOCTYPE html><html lang="en"><head>`) + for (let i = 0;i < linkList.length;i++) { + if (linkList[i].type === 'text/css') { + doc.write(`<LINK rel="stylesheet" type="text/css" href="${linkList[i].href}">`) + } } + doc.write(`<style>body{width: ${config.width}px!important;}</style>`) + for (let i = 0;i < styleList.length;i++) { + doc.write('<style>' + styleList[i].innerHTML + '</style>') + } + doc.write(`</head><body>`) + doc.write(jubuData) + doc.write(`</body></html>`) + doc.close() + iframe.contentWindow.focus() + iframe.contentWindow.print() - document.getElementsByTagName('body')[0].style.zoom = 1 + document.body.removeChild(iframe) setTimeout(() => { window.close() diff --git a/src/views/menudesign/homeform/index.jsx b/src/views/menudesign/homeform/index.jsx index d16f9b4..6ca64be 100644 --- a/src/views/menudesign/homeform/index.jsx +++ b/src/views/menudesign/homeform/index.jsx @@ -17,8 +17,6 @@ if (key === 'cacheUseful') { this.props.updateConfig({...config, cacheUseful: value}) - } else if (key === 'diffUser') { - this.props.updateConfig({...config, diffUser: value}) } else if (key === 'timeUnit') { this.props.updateConfig({...config, timeUnit: value}) } @@ -65,23 +63,6 @@ )} </Form.Item> </Col> - {config.cacheUseful === 'true' ? <Col span={24}> - <Form.Item label={ - <Tooltip placement="topLeft" title="瀵逛簬涓嶅悓鐢ㄦ埛锛屾煡璇俊鎭槸鍚﹀瓨鍦ㄥ樊寮傘��"> - <Icon type="question-circle" /> - 鍖哄垎鐢ㄦ埛 - </Tooltip> - }> - {getFieldDecorator('diffUser', { - initialValue: config.diffUser || 'true' - })( - <Radio.Group onChange={(e) => {this.selectChange('diffUser', e.target.value)}}> - <Radio value="true">鏄�</Radio> - <Radio value="false">鍚�</Radio> - </Radio.Group> - )} - </Form.Item> - </Col> : null} {config.cacheUseful === 'true' ? <Col span={24}> <Form.Item label="鍗曚綅"> {getFieldDecorator('timeUnit', { diff --git a/src/views/menudesign/menuform/index.jsx b/src/views/menudesign/menuform/index.jsx index a52cd68..8944632 100644 --- a/src/views/menudesign/menuform/index.jsx +++ b/src/views/menudesign/menuform/index.jsx @@ -4,6 +4,7 @@ import { Form, Row, Col, Input, Select, notification, Radio, Icon, Tooltip, InputNumber } from 'antd' import Api from '@/api' +import options from '@/store/options.js' import './index.scss' class CustomMenuForm extends Component { @@ -25,48 +26,72 @@ } UNSAFE_componentWillMount () { - const { parentId } = this.props - let param = { - func: 's_Get_FSMenusForOpen', - SndMenuID: parentId, - TYPE: 20, - TypeCharOne: 'PC' + const { MenuId } = this.props + let _param = {func: 's_get_pc_menus', systemType: options.sysType, debug: 'Y'} + if (options.sysType !== 'cloud' && window.GLOB.systemType !== 'production') { + _param.linkurl = window.GLOB.linkurl } + _param.pro_sys = window.GLOB.systemType === 'production' ? 'Y' : '' - Api.getSystemConfig(param).then(result => { + Api.getSystemConfig(_param).then(result => { if (result.status) { - let menulist = result.data.map(smenu => { - let _smenu = { - value: smenu.FstID, - text: smenu.FstName, - options: smenu.SndData.map(menu => { - return { - value: menu.SndID, - text: menu.SndName, + let thdMenu = null + let menulist = result.fst_menu.map(fst => { + let fstItem = { + MenuID: fst.MenuID, + MenuName: fst.MenuName, + children: [] + } + + if (fst.snd_menu) { + fstItem.children = fst.snd_menu.map(snd => { + let sndItem = { + ParentId: fst.MenuID, + MenuID: snd.MenuID, + MenuName: snd.MenuName, + children: [] } + + if (snd.trd_menu) { + sndItem.children = snd.trd_menu.map(trd => { + let trdItem = { + FstId: fst.MenuID, + ParentId: snd.MenuID, + MenuID: trd.MenuID, + MenuName: trd.MenuName, + MenuNo: trd.MenuNo, + EasyCode: trd.EasyCode + } + + if (MenuId === trd.MenuID) { + thdMenu = trdItem + } + return trdItem + }) + } + return sndItem }) } - - return _smenu + return fstItem }) let smenulist = [] menulist.forEach(item => { - if (item.value === result.FstIDSeleted) { - smenulist = item.options + if (thdMenu && (item.MenuID === thdMenu.FstId)) { + smenulist = item.children } }) - this.props.initMenuList({fstMenuList: fromJS(menulist).toJS(), fstMenuId: result.FstIDSeleted}) + this.props.initMenuList({fstMenuList: fromJS(menulist).toJS(), fstMenuId: thdMenu ? thdMenu.FstId : ''}) this.setState({ - fstMenuId: result.FstIDSeleted, + fstMenuId: thdMenu ? thdMenu.FstId : '', menulist, smenulist }, () => { this.props.form.setFieldsValue({ - fstMenuId: result.FstIDSeleted, - parentId: parentId + fstMenuId: thdMenu ? thdMenu.FstId : '', + parentId: thdMenu ? thdMenu.ParentId : '' }) }) } else { @@ -94,15 +119,15 @@ if (key === 'fstMenuId') { let smenulist = [] menulist.forEach(item => { - if (item.value === value) { - smenulist = item.options + if (item.MenuID === value) { + smenulist = item.children } }) this.setState({ smenulist }, () => { - let _id = smenulist[0] ? smenulist[0].value : '' + let _id = smenulist[0] ? smenulist[0].MenuID : '' this.props.form.setFieldsValue({parentId: _id}) this.props.updateConfig({...config, fstMenuId: value, parentId: _id}) }) @@ -110,8 +135,6 @@ this.props.updateConfig({...config, parentId: value}) } else if (key === 'cacheUseful') { this.props.updateConfig({...config, cacheUseful: value}) - } else if (key === 'diffUser') { - this.props.updateConfig({...config, diffUser: value}) } else if (key === 'timeUnit') { this.props.updateConfig({...config, timeUnit: value}) } @@ -170,8 +193,8 @@ })( <Select onChange={(value) => {this.selectChange('fstMenuId', value)}}> {menulist.map(option => - <Select.Option key={option.value} value={option.value}> - {option.text} + <Select.Option key={option.MenuID} value={option.MenuID}> + {option.MenuName} </Select.Option> )} </Select> @@ -191,8 +214,8 @@ })( <Select onChange={(value) => {this.selectChange('parentId', value)}}> {smenulist.map(option => - <Select.Option key={option.value} value={option.value}> - {option.text} + <Select.Option key={option.MenuID} value={option.MenuID}> + {option.MenuName} </Select.Option> )} </Select> @@ -242,23 +265,6 @@ )} </Form.Item> </Col> - {config.cacheUseful === 'true' ? <Col span={24}> - <Form.Item label={ - <Tooltip placement="topLeft" title="瀵逛簬涓嶅悓鐢ㄦ埛锛屾煡璇俊鎭槸鍚﹀瓨鍦ㄥ樊寮傘��"> - <Icon type="question-circle" /> - 鍖哄垎鐢ㄦ埛 - </Tooltip> - }> - {getFieldDecorator('diffUser', { - initialValue: config.diffUser || 'true' - })( - <Radio.Group onChange={(e) => {this.selectChange('diffUser', e.target.value)}}> - <Radio value="true">鏄�</Radio> - <Radio value="false">鍚�</Radio> - </Radio.Group> - )} - </Form.Item> - </Col> : null} {config.cacheUseful === 'true' ? <Col span={24}> <Form.Item label="鍗曚綅"> {getFieldDecorator('timeUnit', { diff --git a/src/views/menudesign/printmenuform/index.jsx b/src/views/menudesign/printmenuform/index.jsx index 7f45e96..04dab01 100644 --- a/src/views/menudesign/printmenuform/index.jsx +++ b/src/views/menudesign/printmenuform/index.jsx @@ -83,7 +83,7 @@ rules: [ { required: true, - message: dict['mob.required.input'] + '鎵撳嵃甯冨眬!' + message: dict['mob.required.select'] + '鎵撳嵃甯冨眬!' } ] })( @@ -95,6 +95,24 @@ </Form.Item> </Col> <Col span={24}> + <Form.Item label="鎵撳嵃杈硅窛"> + {getFieldDecorator('pagePadding', { + initialValue: config.pagePadding || 'default', + rules: [ + { + required: true, + message: dict['mob.required.select'] + '鎵撳嵃杈硅窛!' + } + ] + })( + <Radio.Group onChange={(e) => {this.onRadioChange(e.target.value)}}> + <Radio value="default">榛樿</Radio> + <Radio value="without">鏃�</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> + <Col span={24}> <Form.Item label="棣栭〉鏁�(鏉�)"> {getFieldDecorator('firstCount', { initialValue: config.firstCount, -- Gitblit v1.8.0