From 3ca91a731665962918a026f521c556f4745ebf35 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 16 十一月 2020 19:20:19 +0800 Subject: [PATCH] 2020-11-16 --- src/components/tabview/index.jsx | 86 +- src/tabviews/treepage/index.jsx | 86 +- src/utils/utils-datamanage.js | 21 src/tabviews/formtab/index.jsx | 137 +--- src/components/header/index.jsx | 178 ++--- src/tabviews/zshare/actionList/popupbutton/index.jsx | 3 src/tabviews/zshare/normalTable/index.jsx | 35 src/tabviews/custom/components/card/cardItem/index.jsx | 2 src/views/main/index.jsx | 32 + src/tabviews/commontable/secretKeyTable/index.jsx | 6 src/views/menudesign/homeform/index.jsx | 118 ++++ src/tabviews/calendar/index.jsx | 28 src/views/menudesign/menuform/index.jsx | 78 ++ src/locales/zh-CN/model.js | 4 src/views/billprint/index.scss | 7 src/store/action.js | 19 src/tabviews/zshare/actionList/index.jsx | 4 src/api/index.js | 2 src/locales/en-US/model.js | 2 src/tabviews/custom/index.scss | 2 src/views/billprint/index.jsx | 12 src/tabviews/subtable/index.jsx | 146 +++- src/tabviews/subtabtable/index.jsx | 39 src/views/menudesign/homeform/index.scss | 10 src/tabviews/commontable/index.jsx | 167 ++++- src/views/menudesign/index.jsx | 96 ++ src/views/menudesign/menuform/index.scss | 10 src/tabviews/custom/components/card/prop-card/index.jsx | 8 src/tabviews/custom/components/share/tabtransfer/index.jsx | 18 src/store/reducer.js | 15 src/templates/zshare/formconfig.jsx | 49 + src/templates/sharecomponent/actioncomponent/actionform/index.jsx | 4 src/store/action-type.js | 3 src/router/index.js | 19 src/templates/formtabconfig/actionform/index.jsx | 86 -- src/tabviews/custom/index.jsx | 66 + src/components/sidemenu/index.jsx | 6 src/tabviews/zshare/cardcomponent/index.jsx | 40 src/views/login/index.jsx | 10 39 files changed, 1,046 insertions(+), 608 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index c8a621d..be62de4 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -493,7 +493,7 @@ * @description 鑾峰彇鎴栦慨鏀规湰鍦伴厤缃紝澧炲姞appkey */ getLocalConfig (param) { - param.userid = sessionStorage.getItem('UserID') + param.userid = sessionStorage.getItem('UserID') || '' param.lang = localStorage.getItem('lang') || '' param.SessionUid = localStorage.getItem('SessionUid') || '' param.LoginUID = sessionStorage.getItem('LoginUID') || '' diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx index de4333e..0811001 100644 --- a/src/components/header/index.jsx +++ b/src/components/header/index.jsx @@ -12,7 +12,6 @@ modifyMainMenu, modifyTabview, resetState, - resetDebug, resetEditState, resetEditLevel, initPermission, @@ -169,10 +168,6 @@ if (!result) return if (result.status) { - if (result.debug === 'true') { // 鏄惁涓篸ebug妯″紡锛屽嵆鍙鍒惰彍鍗曞弬鏁� - this.props.resetDebug() - } - let MainMenuId = sessionStorage.getItem('MainMenu') // 鏄惁涓烘墦寮�鏂伴〉闈� if (MainMenuId) { // 閫氳繃url涓璵enuid绛涢�夊嚭閫変腑鐨勪富鑿滃崟 @@ -200,10 +195,6 @@ }), systems: result.Systems.filter(sys => sys.LinkUrl1 && sys.AppKey !== window.GLOB.appkey) }) - - if (result.dataM) { - this.props.modifyDataManager(true) - } } else { notification.error({ top: 92, @@ -216,20 +207,66 @@ async getRolesMenu () { // 鑾峰彇瑙掕壊鏉冮檺 let promiseRole = new Promise(resolve => { - Api.getSystemConfig({func: 'sPC_Get_RolesMenu'}).then(result => { - let _permAction = {} - let _permRoles = [] - if (result && result.status) { - if (result.UserRoles) { - result.UserRoles.forEach(role => { - _permRoles.push(role.RoleID) + Api.getSystemConfig({func: 's_Get_TrdMenu_Role', edition_type: 'Y'}).then(result => { + let _permAction = {} // 鎸夐挳鏉冮檺 + let _permMenus = {} // 鑿滃崟鏉冮檺锛屽瓧娈甸�忚绛� + let menulist = [] // 涓夌骇鑿滃崟鍒楄〃 - role.RoleMenu.forEach(menu => { - if (!menu.MenuID) return - _permAction[menu.MenuID] = true + if (result && result.status) { + if (result.UserRoles_Menu) { + result.UserRoles_Menu.forEach(menu => { + if (!menu.MenuID) return + _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, @@ -238,7 +275,7 @@ }) } - resolve({permAction: _permAction, permRoles: _permRoles}) + resolve({permAction: _permAction}) }) }) @@ -252,10 +289,6 @@ Api.getSystemConfig(_param).then(result => { let mainMenu = null if (result && result.status) { - if (result.debug === 'true') { // 鏄惁涓篸ebug妯″紡锛屽嵆鍙鍒惰彍鍗曞弬鏁� - this.props.resetDebug() - } - let MainMenuId = sessionStorage.getItem('MainMenu') // 鏄惁涓烘墦寮�鏂伴〉闈� if (MainMenuId) { // 閫氳繃url涓璵enuid绛涢�夊嚭閫変腑鐨勪富鑿滃崟 @@ -283,10 +316,6 @@ }), systems: result.Systems.filter(sys => sys.LinkUrl1 && sys.AppKey !== window.GLOB.appkey) }) - - if (result.dataM) { - this.props.modifyDataManager(true) - } } else if (result) { notification.error({ top: 92, @@ -306,7 +335,7 @@ let _role = await promiseRole - this.props.initActionPermission(_role.permRoles, _role.permAction) + this.props.initActionPermission(_role.permAction) } reload = () => { @@ -337,6 +366,9 @@ let _userName = sessionStorage.getItem('User_Name') let _avatar = avatar + 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')) { @@ -427,10 +459,15 @@ 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) // 澶村儚 + } + + if (res.dataM) { + this.props.modifyDataManager(true) } if (window.GLOB.systemType === 'production') { @@ -564,84 +601,22 @@ _avatar = Utils.getrealurl(_avatar) // 澶村儚 this.setState({avatar: _avatar}) } + this.getRolesMenu() } componentDidMount () { - // 鑾峰彇瑙掕壊鑿滃崟鏉冮檺 - Api.getSystemConfig({func: 's_Get_TrdMenu_Role'}).then(result => { - if (!result) return - if (result.status) { - let _permMenus = {} - let menulist = [] - - if (result.UserRoles) { - let iframes = ['Main/Index', 'bda/rdt', 'Home/rdt'] - let menukeys = [] - - result.UserRoles.forEach(role => { - role.RoleMenu.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 - }) - }) - }) - } - + // 鑾峰彇绯荤粺鐨勭増鏈俊鎭紝寤舵椂鏌ヨ + setTimeout(() => { + new Promise((resolve, reject) => { + Api.getAppVersion(resolve, reject) + }).then(res => { this.setState({ - thdMenuList: menulist + oriVersion: res.oldVersion, + newVersion: res.newVersion }) - - this.props.initMenuPermission(_permMenus) - } else { - notification.error({ - top: 92, - message: result.message, - duration: 10 - }) - } - }) - - // 鑾峰彇绯荤粺鐨勭増鏈俊鎭� - new Promise((resolve, reject) => { - Api.getAppVersion(resolve, reject) - }).then(res => { - this.setState({ - oriVersion: res.oldVersion, - newVersion: res.newVersion }) - }) + }, 1000) } shouldComponentUpdate (nextProps, nextState) { @@ -845,12 +820,11 @@ modifyMainMenu: (selectmenu) => dispatch(modifyMainMenu(selectmenu)), resetEditState: (state) => dispatch(resetEditState(state)), resetEditLevel: (level) => dispatch(resetEditLevel(level)), - initActionPermission: (permRoles, permAction) => dispatch(initActionPermission(permRoles, permAction)), + initActionPermission: (permAction) => dispatch(initActionPermission(permAction)), initPermission: (sysRoles, permFuncField) => dispatch(initPermission(sysRoles, permFuncField)), initMenuPermission: (permMenus) => dispatch(initMenuPermission(permMenus)), modifyDataManager: (dataManager) => dispatch(modifyDataManager(dataManager)), resetState: () => dispatch(resetState()), - resetDebug: () => dispatch(resetDebug()), logout: () => dispatch(logout()) } } diff --git a/src/components/sidemenu/index.jsx b/src/components/sidemenu/index.jsx index b65a490..79cf836 100644 --- a/src/components/sidemenu/index.jsx +++ b/src/components/sidemenu/index.jsx @@ -76,6 +76,12 @@ 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 diff --git a/src/components/tabview/index.jsx b/src/components/tabview/index.jsx index 386daec..7829c68 100644 --- a/src/components/tabview/index.jsx +++ b/src/components/tabview/index.jsx @@ -6,12 +6,13 @@ import moment from 'moment' import 'moment/locale/zh-cn' -import {modifyTabview, toggleIsiframe, refreshTabView} from '@/store/action' +import { modifyTabview, toggleIsiframe } from '@/store/action' import asyncComponent from '@/utils/asyncLoadComponent' import NotFount from '@/components/404' import options from '@/store/options.js' import mzhCN from '@/locales/zh-CN/main.js' import menUS from '@/locales/en-US/main.js' +import MKEmitter from '@/utils/events.js' import './index.scss' @@ -42,6 +43,7 @@ } state = { + activeId: '', tabviews: null, // 鏍囩闆� iFrameHeight: 0, dict: localStorage.getItem('lang') !== 'en-US' ? mzhCN : menUS @@ -55,8 +57,15 @@ return tab.MenuID !== menu.MenuID }) - if (menu.selected) { - tabs[0] && (tabs[0].selected = true) + if (menu.selected && tabs[0]) { + tabs[0].selected = true + this.setState({ + activeId: tabs[0].MenuID || '' + }) + + if (this.props.isiframe) { + this.props.toggleIsiframe(false) + } } this.props.modifyTabview(tabs) @@ -66,11 +75,7 @@ e.stopPropagation() window.GLOB.CacheMap = new Map() - let _menu = { - MenuID: menu.MenuID, - position: 'view' - } - this.props.refreshTabView(_menu) + MKEmitter.emit('reloadMenuView', menu.MenuID) } changeTab = (e, menu) => { @@ -87,8 +92,26 @@ return tab }) + if (menu) { + let _isiframe = this.props.isiframe + if (menu.type === 'iframe') { + _isiframe = true + } else { + _isiframe = false + } + + if (_isiframe !== this.props.isiframe) { + this.props.toggleIsiframe(_isiframe) + } + } + this.setState({ - tabviews: tabs + tabviews: tabs, + activeId: menu.MenuID || '' + }, () => { + if (menu.MenuID) { + MKEmitter.emit('resetActiveMenu', menu.MenuID) + } }) this.props.modifyTabview(tabs) @@ -120,21 +143,6 @@ return (<Iframe key={view.MenuID} title={view.MenuName} MenuName={view.MenuName} url={service + view.LinkUrl}/>) } else { return (<NotFount key={view.MenuID} />) - } - } - - resetWindow = (view) => { - // 绐楀彛鍦╥frame涓庢櫘閫氶〉闈㈠垏鎹㈡椂锛屼慨鏀瑰乏渚ц彍鍗曟爮鏍峰紡 - if (!view) return - let _isiframe = this.props.isiframe - if (view && view.type === 'iframe') { - _isiframe = true - } else { - _isiframe = false - } - - if (_isiframe !== this.props.isiframe) { - this.props.toggleIsiframe(_isiframe) } } @@ -173,9 +181,29 @@ UNSAFE_componentWillReceiveProps (nextProps) { if (nextProps.tabviews && !is(fromJS(this.state.tabviews), fromJS(nextProps.tabviews))) { + let view = nextProps.tabviews.filter(tab => tab.selected)[0] + + // 绐楀彛鍦╥frame涓庢櫘閫氶〉闈㈠垏鎹㈡椂锛屼慨鏀瑰乏渚ц彍鍗曟爮鏍峰紡 + let activeId = '' + if (view) { + let _isiframe = this.props.isiframe + if (view.type === 'iframe') { + _isiframe = true + } else { + _isiframe = false + } + + if (_isiframe !== this.props.isiframe) { + this.props.toggleIsiframe(_isiframe) + } + + activeId = view.MenuID + } + // 淇濆瓨淇敼鏍囩闆� this.setState({ - tabviews: nextProps.tabviews + tabviews: nextProps.tabviews, + activeId }) let node = document.getElementById('root').parentNode.parentNode @@ -196,16 +224,13 @@ render () { const { menuType } = this.props - const { tabviews } = this.state - let view = tabviews.filter(tab => tab.selected)[0] - this.resetWindow(view) - let selectedTabId = view ? view.MenuID : '' + const { tabviews, activeId } = this.state return ( <section className={'flex-container content-box' + (this.props.collapse ? ' collapsed' : '')}> <div className="content-header"> {tabviews && tabviews.length > 0 && - <Tabs activeKey={selectedTabId}> + <Tabs activeKey={activeId}> {tabviews.map(view => { return ( <Tabs.TabPane @@ -264,7 +289,6 @@ const mapDispatchToProps = (dispatch) => { return { modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews)), - refreshTabView: (refreshTab) => dispatch(refreshTabView(refreshTab)), toggleIsiframe: (isiframe) => dispatch(toggleIsiframe(isiframe)) } } diff --git a/src/locales/en-US/model.js b/src/locales/en-US/model.js index cc1d782..d769ab7 100644 --- a/src/locales/en-US/model.js +++ b/src/locales/en-US/model.js @@ -94,10 +94,8 @@ 'header.form.errorTime': 'Residence time', 'header.form.refresh': 'Refresh', 'header.form.refresh.never': 'Don\'t refresh', - 'header.form.refresh.view': 'Refresh the page', 'header.form.refresh.grid': 'Refresh the table', 'header.form.refresh.maingrid': 'Refresh the main table', - 'header.form.refresh.mainline': 'Refresh the main table (rows)', 'header.form.refresh.equaltab': 'Refresh sibling tag', 'header.form.refresh.subgrid': 'Refresh the child table', 'header.form.popClose': 'Label closing', diff --git a/src/locales/zh-CN/model.js b/src/locales/zh-CN/model.js index 1c8f910..bd33160 100644 --- a/src/locales/zh-CN/model.js +++ b/src/locales/zh-CN/model.js @@ -94,10 +94,8 @@ 'header.form.errorTime': '鍋滅暀鏃堕棿', 'header.form.refresh': '鍒锋柊', 'header.form.refresh.never': '涓嶅埛鏂�', - 'header.form.refresh.view': '鍒锋柊椤甸潰', 'header.form.refresh.grid': '鍒锋柊琛ㄦ牸', - 'header.form.refresh.maingrid': '鍒锋柊涓昏〃', - 'header.form.refresh.mainline': '鍒锋柊涓昏〃锛堣锛�', + 'header.form.refresh.maingrid': '鍒锋柊涓昏〃锛堣锛�', 'header.form.refresh.equaltab': '鍒锋柊鍚岀骇鏍囩', 'header.form.refresh.subgrid': '鍒锋柊瀛愯〃', 'header.form.popClose': '鏍囩鍏抽棴', diff --git a/src/router/index.js b/src/router/index.js index 7b67105..46c93e1 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -40,15 +40,16 @@ let _param = JSON.parse(window.decodeURIComponent(window.atob(props.match.params.param))) if (typeof(_param) === 'object') { - if (_param.UserID && !sessionStorage.getItem('UserID')) { - sessionStorage.setItem('UserID', _param.UserID) - } - if (_param.LoginUID && !sessionStorage.getItem('LoginUID')) { - sessionStorage.setItem('LoginUID', _param.LoginUID) - } - if (_param.User_Name && !sessionStorage.getItem('User_Name')) { - sessionStorage.setItem('User_Name', _param.User_Name) - } + _param.UserID && sessionStorage.setItem('UserID', _param.UserID) + _param.LoginUID && sessionStorage.setItem('LoginUID', _param.LoginUID) + _param.User_Name && sessionStorage.setItem('User_Name', _param.User_Name) + _param.Full_Name && sessionStorage.setItem('Full_Name', _param.Full_Name) + _param.debug && sessionStorage.setItem('debug', _param.debug) + _param.dataM && sessionStorage.setItem('dataM', _param.dataM) + _param.avatar && sessionStorage.setItem('avatar', _param.avatar) + _param.role_id && sessionStorage.setItem('role_id', _param.role_id) + _param.Member_Level && sessionStorage.setItem('Member_Level', _param.Member_Level) + if (_param.mainlogo) { window.GLOB.mainlogo = _param.mainlogo } diff --git a/src/store/action-type.js b/src/store/action-type.js index 5f7fdb2..41b42ef 100644 --- a/src/store/action-type.js +++ b/src/store/action-type.js @@ -25,6 +25,9 @@ // 閲嶇疆缂栬緫绾у埆 export const RESET_EDITLEVEL = 'RESET_EDITLEVEL' +// 鍒濆鍖栬鑹叉潈闄� +export const INIT_ROLESPERMISSION = 'INIT_ROLESPERMISSION' + // 鍒濆鍖栨寜閽潈闄� export const INIT_ACTIONPERMISSION = 'INIT_ACTIONPERMISSION' diff --git a/src/store/action.js b/src/store/action.js index 4ed50ec..49e1192 100644 --- a/src/store/action.js +++ b/src/store/action.js @@ -46,14 +46,6 @@ } } -// 鍒锋柊tab椤甸潰 -export const refreshTabView = (refreshTab) => { - return { - type: user.REFRESH_TABVIEW, - refreshTab - } -} - // 閲嶇疆缂栬緫鐘舵�� export const resetEditState = (editState) => { return { @@ -71,10 +63,17 @@ } // 鍒濆鍖栨寜閽潈闄� -export const initActionPermission = (permRoles, permAction) => { +export const initRolesPermission = (permRoles) => { + return { + type: user.INIT_ROLESPERMISSION, + permRoles: permRoles + } +} + +// 鍒濆鍖栨寜閽潈闄� +export const initActionPermission = (permAction) => { return { type: user.INIT_ACTIONPERMISSION, - permRoles: permRoles, permAction: permAction } } diff --git a/src/store/reducer.js b/src/store/reducer.js index 9877f9d..d936e55 100644 --- a/src/store/reducer.js +++ b/src/store/reducer.js @@ -24,7 +24,6 @@ debug: false, // 鐭ュ惁鍙互澶嶅埗鑿滃崟鍙傛暟, 鏄惁鍙繘鍏ョ紪杈戞ā寮� editState: false, // 鏄惁涓虹紪杈戠姸鎬侊紝鍊间负false銆乼rue editLevel: null, // 缂栬緫鑿滃崟绾у埆锛屽�间负level1銆乴evel2銆乴evel3銆丠S - refreshTab: null, // 鍒锋柊tabview椤甸潰淇℃伅 permRoles: [], // 鐢ㄦ埛瑙掕壊鍒楄〃 permAction: {}, // 鐢ㄦ埛鎸夐挳鏉冮檺 permMenus: {}, // 鐢ㄦ埛涓夌骇鑿滃崟鏉冮檺 @@ -79,12 +78,6 @@ ...state, debug: true } - case Type.REFRESH_TABVIEW: - // 鍒锋柊tab椤甸潰 - return { - ...state, - refreshTab: action.refreshTab - } case Type.RESET_EDITSTATE: // 閲嶇疆缂栬緫鐘舵�� if (action.editState) { @@ -108,11 +101,16 @@ ...state, editLevel: action.editLevel } + case Type.INIT_ROLESPERMISSION: + // 鍒濆鍖栨寜閽潈闄� + return { + ...state, + permRoles: action.permRoles + } case Type.INIT_ACTIONPERMISSION: // 鍒濆鍖栨寜閽潈闄� return { ...state, - permRoles: action.permRoles, permAction: action.permAction } case Type.INIT_PERMISSION: @@ -155,7 +153,6 @@ debug: false, editState: false, editLevel: null, - refreshTab: null, permAction: {}, permFuncField: [], sysRoles: [], diff --git a/src/tabviews/calendar/index.jsx b/src/tabviews/calendar/index.jsx index dabdafc..ee5cbdd 100644 --- a/src/tabviews/calendar/index.jsx +++ b/src/tabviews/calendar/index.jsx @@ -11,7 +11,7 @@ import enUS from '@/locales/en-US/main.js' import Utils from '@/utils/utils.js' import asyncSpinComponent from '@/utils/asyncSpinComponent' -import { refreshTabView } from '@/store/action' +import MKEmitter from '@/utils/events.js' import MainSearch from '@/tabviews/zshare/topSearch' import NotFount from '@/components/404' @@ -515,16 +515,21 @@ }) } + reloadMenuView = (menuId) => { + const { MenuID } = this.props + + if (MenuID !== menuId) return + + this.reloadview() + } + UNSAFE_componentWillMount () { // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁 this.loadconfig() } UNSAFE_componentWillReceiveProps(nextProps) { - if (nextProps.refreshTab && nextProps.refreshTab.MenuID === this.props.MenuID) { - this.reloadview() - this.props.refreshTabView('') - } else if (nextProps.param && !is(fromJS(this.props.param), fromJS(nextProps.param))) { + if (nextProps.param && !is(fromJS(this.props.param), fromJS(nextProps.param))) { let search = this.state.search.map(item => { if (item.type === 'text' && item.key === nextProps.param.searchkey) { item.value = nextProps.param.searchval @@ -539,6 +544,10 @@ return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) } + componentDidMount () { + MKEmitter.addListener('reloadMenuView', this.reloadMenuView) + } + /** * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 */ @@ -546,6 +555,7 @@ this.setState = () => { return } + MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) } changeDate = (value) => { @@ -646,18 +656,14 @@ const mapStateToProps = (state) => { return { menuType: state.editLevel, - tabviews: state.tabviews, - refreshTab: state.refreshTab, permAction: state.permAction, permRoles: state.permRoles, dataManager: state.dataManager } } -const mapDispatchToProps = (dispatch) => { - return { - refreshTabView: (refreshTab) => dispatch(refreshTabView(refreshTab)) - } +const mapDispatchToProps = () => { + return {} } export default connect(mapStateToProps, mapDispatchToProps)(NormalTable) \ No newline at end of file diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx index 6b8431d..0541d72 100644 --- a/src/tabviews/commontable/index.jsx +++ b/src/tabviews/commontable/index.jsx @@ -13,7 +13,6 @@ import UtilsUpdate from '@/utils/utils-update.js' import asyncComponent from '@/utils/asyncComponent' import asyncSpinComponent from '@/utils/asyncSpinComponent' -import { refreshTabView } from '@/store/action' import MKEmitter from '@/utils/events.js' import MainSearch from '@/tabviews/zshare/topSearch' @@ -66,7 +65,6 @@ BIDs: {}, // 涓婄骇琛╥d pickup: false, // 涓昏〃鏁版嵁闅愯棌鏄剧ず鍒囨崲 treevisible: false, // 鑿滃崟缁撴瀯鏍戝脊妗嗘樉绀洪殣钘忔帶鍒� - refreshtabs: null, // 闇�瑕佸埛鏂扮殑鏍囩闆� tabActive: null, // 鏍囩椤靛睍寮�鎺у埗 chartId: '', // 灞曞紑鍥捐〃ID statFields: [], // 鍚堣瀛楁 @@ -545,6 +543,59 @@ } /** + * @description 鑾峰彇鍗曡鏁版嵁 + */ + async loadmainLinedata (id) { + const { setting, arr_field, search, orderBy, BID, pageIndex, pageSize } = this.state + + this.setState({ + loading: true + }) + + let _orderBy = orderBy || setting.order + let param = UtilsDM.getQueryDataParams(setting, arr_field, search, _orderBy, pageIndex, pageSize, BID, this.props.menuType, this.props.dataManager, id) + + if (param.func === 'sPC_Get_TableData') { + param.menuname = this.props.MenuName || '' + } + + let result = await Api.genericInterface(param) + if (result.status) { + let data = fromJS(this.state.data).toJS() + if (result.data && result.data[0]) { + let _data = result.data[0] + + try { + data = data.map(item => { + if (item[setting.primaryKey] === _data[setting.primaryKey]) { + _data.key = item.key + return _data + } else { + return item + } + }) + } catch { + console.warn('鏁版嵁鏌ヨ閿欒') + } + } + + this.setState({ + data: data, + loading: false + }) + } else { + this.setState({ + loading: false + }) + notification.error({ + top: 92, + message: result.message, + duration: 10 + }) + } + } + + /** * @description 鑾峰彇鍚堣瀛楁鍊� */ getStatFieldsValue = () => { @@ -649,21 +700,27 @@ /** * @description 琛ㄦ牸鍒锋柊 */ - reloadtable = () => { - MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 鍒楄〃閲嶇疆 - this.setState({ - pageIndex: 1 - }, () => { + reloadtable = (btn) => { + if (!btn || btn.resetPageIndex !== 'false') { + MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 鍒楄〃閲嶇疆 + this.setState({ + pageIndex: 1 + }, () => { + this.loadmaindata() + this.getStatFieldsValue() + }) + } else { + MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable', 'false') // 鍒楄〃閲嶇疆 this.loadmaindata() this.getStatFieldsValue() - }) + } } /** * @description 椤甸潰鍒锋柊锛岄噸鏂拌幏鍙栭厤缃� */ reloadview = () => { - this.setState({ loadingview: true, viewlost: false, lostmsg: '', + this.setState({ loadingview: true, viewlost: false, config: {}, setting: null, data: null, total: 0, loading: false, pageIndex: 1, pageSize: 10, orderBy: '', search: '', BIDs: {}, pickup: false }, () => { @@ -674,38 +731,9 @@ /** * @description 鎸夐挳鎿嶄綔瀹屾垚鍚庯紙鎴愬姛鎴栧け璐ワ級锛岄〉闈㈠埛鏂帮紝閲嶇疆椤电爜鍙婇�夋嫨椤� */ - refreshbyaction = (position) => { - if (position === 'grid') { - this.reloadtable() - } else if (position === 'view') { - this.reloadview() - } - } - - /** - * @description 瀛愯〃鎿嶄綔瀹屾垚鍚庡埛鏂颁富琛� - */ - handleMainTable = (type, tab) => { - if (type === 'maingrid' && tab.supMenu === 'mainTable') { - this.reloadtable() - } else if (type === 'mainline' && tab.supMenu === 'mainTable') { - this.reloadtable() - } else if ((type === 'maingrid' || type === 'mainline') && tab.supMenu) { - this.setState({ - refreshtabs: [type, tab.supMenu] - }, () => { - this.setState({ - refreshtabs: null - }) - }) - } else if (type === 'equaltab' && tab.equalTab && tab.equalTab.length > 0) { - this.setState({ - refreshtabs: tab.equalTab - }, () => { - this.setState({ - refreshtabs: null - }) - }) + refreshbyaction = (position, btn) => { + if (position === 'grid' || position === 'view') { + this.reloadtable(btn) } } @@ -822,16 +850,47 @@ this.setState({chartId: uuid}) } + reloadData = (menuId, id, btn) => { + const { MenuID } = this.props + + if (MenuID !== menuId) return + if (id === 'empty') return + + if (id === 'formtab') { // 琛ㄥ崟鏍囩椤靛埛鏂� + this.reloadtable(btn) + return + } + + if (!id) { + this.reloadtable() + } else { + this.loadmainLinedata(id) + } + } + + reloadMenuView = (menuId) => { + const { MenuID } = this.props + + if (MenuID !== menuId) return + + this.reloadview() + } + + resetActiveMenu = (menuId) => { + const { MenuID } = this.props + + if (MenuID !== menuId) return + + this.setShortcut() + } + UNSAFE_componentWillMount () { // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁 this.loadconfig() } UNSAFE_componentWillReceiveProps(nextProps) { - if (nextProps.refreshTab && nextProps.refreshTab.MenuID === this.props.MenuID) { - this.reloadview() - this.props.refreshTabView('') - } else if (!is(fromJS(this.props.tabviews), fromJS(nextProps.tabviews))) { + if (!is(fromJS(this.props.tabviews), fromJS(nextProps.tabviews))) { let selectTab = nextProps.tabviews.filter(tab => tab.selected)[0] if (selectTab && selectTab.MenuID === this.props.MenuID) { this.setShortcut() @@ -851,6 +910,12 @@ return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) } + componentDidMount () { + MKEmitter.addListener('reloadData', this.reloadData) + MKEmitter.addListener('reloadMenuView', this.reloadMenuView) + MKEmitter.addListener('resetActiveMenu', this.resetActiveMenu) + } + /** * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 */ @@ -859,6 +924,9 @@ return } document.onkeydown = () => {} + MKEmitter.removeListener('reloadData', this.reloadData) + MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) + MKEmitter.removeListener('resetActiveMenu', this.resetActiveMenu) } render() { @@ -1001,12 +1069,10 @@ mainSearch={_tab.searchPass === 'true' ? search : null} userConfig={userConfig ? userConfig[_tab.uuid] : null} SupMenuID={this.props.MenuID} - refreshtabs={this.state.refreshtabs} ContainerId={this.state.ContainerId} BID={this.state.BIDs[_tab.supMenu] || ''} BData={this.state.BIDs[_tab.supMenu + 'data'] || ''} handleTableId={this.handleTableId} - handleMainTable={(type) => this.handleMainTable(type, _tab)} /> </TabPane> ) @@ -1050,7 +1116,6 @@ return { menuType: state.editLevel, tabviews: state.tabviews, - refreshTab: state.refreshTab, permAction: state.permAction, permMenus: state.permMenus, permRoles: state.permRoles, @@ -1058,10 +1123,8 @@ } } -const mapDispatchToProps = (dispatch) => { - return { - refreshTabView: (refreshTab) => dispatch(refreshTabView(refreshTab)) - } +const mapDispatchToProps = () => { + return {} } export default connect(mapStateToProps, mapDispatchToProps)(NormalTable) \ No newline at end of file diff --git a/src/tabviews/commontable/secretKeyTable/index.jsx b/src/tabviews/commontable/secretKeyTable/index.jsx index 98ce131..982cd31 100644 --- a/src/tabviews/commontable/secretKeyTable/index.jsx +++ b/src/tabviews/commontable/secretKeyTable/index.jsx @@ -8,6 +8,7 @@ import enUS from '@/locales/en-US/main.js' import options from '@/store/options.js' import { buttonConfig, tabConfig, refCodes } from './config' +import MKEmitter from '@/utils/events.js' import asyncSpinComponent from '@/utils/asyncSpinComponent' import SubAction from './actionList' @@ -37,7 +38,6 @@ setting: null, // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑 data: null, // 鍒楄〃鏁版嵁闆� selectedData: [], // 宸查�夎〃鏍兼暟鎹� - resetTable: false, // 琛ㄦ牸閲嶇疆锛屽�煎湪true涓巉alse涔嬮棿鍒囨崲锛屽垏鎹㈡椂琛ㄦ牸閲嶇疆 loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� visible: false, // 寮规鏄剧ず闅愯棌鎺у埗 pickup: false, // 瀛愯〃鏁版嵁闅愯棌鏄剧ず鍒囨崲 @@ -48,10 +48,10 @@ */ UNSAFE_componentWillReceiveProps(nextProps) { if (this.state.config && this.props.Tab.supMenu && !is(fromJS(this.props.BID), fromJS(nextProps.BID))) { + MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 鍒楄〃閲嶇疆 this.setState({ pageIndex: 1, selectedData: [], - resetTable: !this.state.resetTable, }, () => { this.loadmaindata(nextProps.BID, 'refresh') }) @@ -253,10 +253,10 @@ * @description 琛ㄦ牸鍒锋柊 */ reloadtable = () => { + MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 鍒楄〃閲嶇疆 this.setState({ loading: true, selectedData: [], - resetTable: !this.state.resetTable }, () => { this.loadmaindata() }) diff --git a/src/tabviews/custom/components/card/cardItem/index.jsx b/src/tabviews/custom/components/card/cardItem/index.jsx index 8d32c35..b33fc40 100644 --- a/src/tabviews/custom/components/card/cardItem/index.jsx +++ b/src/tabviews/custom/components/card/cardItem/index.jsx @@ -32,7 +32,7 @@ } shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.state), fromJS(nextState)) + return !is(fromJS(this.state), fromJS(nextState)) || !is(fromJS(this.props), fromJS(nextProps)) } /** diff --git a/src/tabviews/custom/components/card/prop-card/index.jsx b/src/tabviews/custom/components/card/prop-card/index.jsx index 7987e98..54c3194 100644 --- a/src/tabviews/custom/components/card/prop-card/index.jsx +++ b/src/tabviews/custom/components/card/prop-card/index.jsx @@ -26,7 +26,7 @@ loading: false, // 鏁版嵁鍔犺浇鐘舵�� activeKey: '', // 閫変腑鏁版嵁 sync: false, // 鏄惁缁熶竴璇锋眰鏁版嵁 - data: null, // 鏁版嵁 + data: {} // 鏁版嵁 } UNSAFE_componentWillMount () { @@ -34,7 +34,7 @@ let _config = fromJS(this.props.config).toJS() let _cols = new Map() - let _data = null + let _data = {} let _sync = false if (_config.setting && _config.wrap.datatype !== 'static') { _sync = _config.setting.sync === 'true' @@ -219,13 +219,13 @@ <Spin /> </div> : null } - {data ? <div className="card-row-list"> + <div className="card-row-list"> {config.subcards.map((item, index) => ( <Col className={activeKey === index ? 'active' : ''} key={index} span={item.setting.width || 6} onClick={() => {this.changeCard(index, item)}}> <CardItem BID={BID} card={item} cards={config} data={data} updateStatus={this.updateStatus}/> </Col> ))} - </div> : null} + </div> </div> ) } diff --git a/src/tabviews/custom/components/share/tabtransfer/index.jsx b/src/tabviews/custom/components/share/tabtransfer/index.jsx index 56ab3e9..827ed94 100644 --- a/src/tabviews/custom/components/share/tabtransfer/index.jsx +++ b/src/tabviews/custom/components/share/tabtransfer/index.jsx @@ -4,6 +4,7 @@ import { is, fromJS } from 'immutable' import { Row, Col, Empty, notification } from 'antd' import moment from 'moment' +import md5 from 'md5' import Api from '@/api' import options from '@/store/options.js' @@ -84,7 +85,10 @@ }) this.setState({mainSearch: _mainSearch, self}) - this.loadmaindata(params) + + if (params.length > 0) { + this.loadmaindata(params) + } } UNSAFE_componentWillReceiveProps(nextProps) { @@ -172,7 +176,7 @@ * @description 涓昏〃鏁版嵁鍔犺浇 */ loadmaindata = (params) => { - if (!params || params.length === 0) return + const { config } = this.props let LText_field = [] let LText = params.map((item, index) => { let _sql = item.sql @@ -198,6 +202,16 @@ param.LText = Utils.formatOptions(param.LText) param.LText_field = Utils.formatOptions(param.LText_field) + + if (config.cacheUseful === 'true') { + param.time_type = config.timeUnit + param.time_limit = config.cacheTime + if (config.diffUser) { + param.userid = sessionStorage.getItem('UserID') + } + param.data_md5 = md5(JSON.stringify(param)) + } + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt(param.LText, param.timestamp) diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index 5d699e3..e9aae8a 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -4,6 +4,7 @@ import { is, fromJS } from 'immutable' import { notification, Spin, Row, Col, Button, message } from 'antd' import moment from 'moment' +import md5 from 'md5' import Api from '@/api' import options from '@/store/options.js' @@ -11,8 +12,7 @@ import enUS from '@/locales/en-US/main.js' import Utils from '@/utils/utils.js' import asyncComponent from '@/utils/asyncComponent' -import { refreshTabView } from '@/store/action' - +import MKEmitter from '@/utils/events.js' import NotFount from '@/components/404' import './index.scss' @@ -101,6 +101,15 @@ return } + // 鏁版嵁缂撳瓨璁剧疆 + if (config.cacheUseful === 'true') { + config.diffUser = config.diffUser !== 'false' + if (!['day', 'hour'].includes(config.timeUnit)) { + config.timeUnit = 'day' + } + config.cacheTime = config.cacheTime || 1 + } + // 鏉冮檺杩囨护 if (this.props.menuType !== 'HS') { config.components = this.filterComponent(config.components) @@ -141,7 +150,16 @@ let params = [] let BID = param && param.BID ? param.BID : '' - config.components = this.formatSetting(config.components, params, mainSearch, permAction) + let inherit = {} + + if (config.cacheUseful === 'true') { // 缂撳瓨缁ф壙 + 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) this.setState({ BID: BID, @@ -209,11 +227,12 @@ } // 鏍煎紡鍖栭粯璁よ缃� - formatSetting = (components, params, mainSearch, permAction) => { + formatSetting = (components, params, mainSearch, permAction, inherit) => { return components.map(component => { if (component.type === 'tabs') { component.subtabs = component.subtabs.map(tab => { - tab.components = this.formatSetting(tab.components, [], [], permAction) + tab.components = this.formatSetting(tab.components, [], [], permAction, inherit) + tab = {...tab, ...inherit} return tab }) } @@ -354,6 +373,7 @@ * @description 涓昏〃鏁版嵁鍔犺浇 */ loadmaindata = (params) => { + const { config } = this.state let LText_field = [] let LText = params.map((item, index) => { let _sql = item.sql @@ -380,6 +400,16 @@ param.LText = Utils.formatOptions(param.LText) param.LText_field = Utils.formatOptions(param.LText_field) + + if (config.cacheUseful === 'true') { + param.time_type = config.timeUnit + param.time_limit = config.cacheTime + if (config.diffUser) { + param.userid = sessionStorage.getItem('UserID') + } + param.data_md5 = md5(JSON.stringify(param)) + } + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt(param.LText, param.timestamp) @@ -431,20 +461,25 @@ } } + reloadMenuView = (menuId) => { + const { MenuID } = this.props + + if (MenuID !== menuId) return + + this.reloadview() + } + UNSAFE_componentWillMount () { // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁 this.loadconfig() } - UNSAFE_componentWillReceiveProps(nextProps) { - if (nextProps.refreshTab && nextProps.refreshTab.MenuID === this.props.MenuID) { - this.reloadview() - this.props.refreshTabView('') - } - } - shouldComponentUpdate (nextProps, nextState) { return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + } + + componentDidMount () { + MKEmitter.addListener('reloadMenuView', this.reloadMenuView) } /** @@ -454,6 +489,7 @@ this.setState = () => { return } + MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) } reloadview = () => { @@ -557,10 +593,8 @@ } } -const mapDispatchToProps = (dispatch) => { - return { - refreshTabView: (refreshTab) => dispatch(refreshTabView(refreshTab)) - } +const mapDispatchToProps = () => { + return {} } export default connect(mapStateToProps, mapDispatchToProps)(CustomPage) \ No newline at end of file diff --git a/src/tabviews/custom/index.scss b/src/tabviews/custom/index.scss index a5e974e..6164b26 100644 --- a/src/tabviews/custom/index.scss +++ b/src/tabviews/custom/index.scss @@ -28,7 +28,7 @@ > .ant-spin { position: absolute; z-index: 10; - left: calc(50% - 22px); + left: calc(50% - 16px); top: calc(50vh - 70px); } diff --git a/src/tabviews/formtab/index.jsx b/src/tabviews/formtab/index.jsx index 719b1c0..89ab064 100644 --- a/src/tabviews/formtab/index.jsx +++ b/src/tabviews/formtab/index.jsx @@ -11,11 +11,12 @@ import Utils from '@/utils/utils.js' import options from '@/store/options.js' import asyncComponent from '@/utils/asyncLoadComponent' +import MKEmitter from '@/utils/events.js' import FormGroup from './formgroup' import FormAction from './actionList' import NotFount from '@/components/404' -import {refreshTabView, modifyTabview} from '@/store/action' +import {modifyTabview} from '@/store/action' import './index.scss' const { TabPane } = Tabs @@ -25,7 +26,6 @@ static propTpyes = { MenuID: PropTypes.string, // 鑿滃崟Id param: PropTypes.any, // 涓昏〃浼犻�掑弬鏁� - refresh: PropTypes.any // 鍒锋柊涓昏〃椤甸潰 } state = { @@ -40,14 +40,8 @@ arr_field: '', // 浣跨敤 sPC_Get_TableData 鏃剁殑鏌ヨ瀛楁闆� setting: null, // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑 data: null, // 鍒楄〃鏁版嵁闆� - configMap: {}, // 椤甸潰閰嶇疆淇℃伅锛氫笅鎷夈�佹寜閽瓑 BIDs: {}, // 涓婄骇琛╥d - setsingle: false, // 涓昏〃鍗曢�夊閫夊垏鎹� - pickup: false, // 涓昏〃鏁版嵁闅愯棌鏄剧ず鍒囨崲 - popData: false, // 寮规椤甸潰锛屾墍閫夌殑琛ㄦ牸鏁版嵁 - visible: false, // 寮规鏄剧ず闅愯棌鎺у埗 primaryId: null, - refreshtabs: null } /** @@ -503,7 +497,7 @@ this.setState({ primaryId: primaryId }, () => { - if (btn.execSuccess === 'refresh') { + if (btn.execSuccess === 'refresh' || btn.execSuccess === 'grid') { this.loadmaindata() } else { let data = {} @@ -524,53 +518,39 @@ } }) } else if (type === 'success' && btn.afterExecSuccess === 'close') { - if (this.props.refresh) { - this.props.refresh(btn.execSuccess) - } else { - if (btn.execSuccess !== 'never') { - let PMenu = { - MenuID: this.props.param.parentId || '' - } - this.props.refreshTabView(PMenu) + if (btn.execSuccess !== 'never') { + MKEmitter.emit('reloadData', this.props.param.parentId, 'formtab', btn) + } + + let tabs = this.props.tabviews.filter(tab => { + tab.selected = false + if (tab.MenuID === this.props.param.parentId) { + tab.selected = true } - let tabs = this.props.tabviews.filter(tab => { - tab.selected = false - if (tab.MenuID === this.props.param.parentId) { - tab.selected = true - } + return tab.MenuID !== this.props.MenuID + }) - return tab.MenuID !== this.props.MenuID - }) - - this.props.modifyTabview(tabs) - } + this.props.modifyTabview(tabs) } else if (type === 'error' && btn.afterExecError === 'notclose') { if (btn.execError === 'refresh') { this.loadmaindata() } } else if (type === 'error' && btn.afterExecError === 'close') { - if (this.props.refresh) { - this.props.refresh(btn.execError) - } else { - if (btn.execError !== 'never') { - let PMenu = { - MenuID: this.props.param.parentId || '', - } - this.props.refreshTabView(PMenu) + if (btn.execError !== 'never') { + MKEmitter.emit('reloadData', this.props.param.parentId, 'formtab', btn) + } + + let tabs = this.props.tabviews.filter(tab => { + tab.selected = false + if (tab.MenuID === this.props.param.parentId) { + tab.selected = true } - let tabs = this.props.tabviews.filter(tab => { - tab.selected = false - if (tab.MenuID === this.props.param.parentId) { - tab.selected = true - } + return tab.MenuID !== this.props.MenuID + }) - return tab.MenuID !== this.props.MenuID - }) - - this.props.modifyTabview(tabs) - } + this.props.modifyTabview(tabs) } } @@ -590,31 +570,6 @@ } /** - * @description 瀛愯〃鎿嶄綔瀹屾垚鍚庡埛鏂颁富琛� - */ - handleMainTable = (type, tab) => { - if ((type === 'maingrid' || type === 'mainline') && tab.supMenu === 'mainTable') { - this.loadmaindata() - } else if ((type === 'maingrid' || type === 'mainline') && tab.supMenu) { - this.setState({ - refreshtabs: [type, tab.supMenu] - }, () => { - this.setState({ - refreshtabs: null - }) - }) - } else if (type === 'equaltab' && tab.equalTab && tab.equalTab.length > 0) { - this.setState({ - refreshtabs: tab.equalTab - }, () => { - this.setState({ - refreshtabs: null - }) - }) - } - } - - /** * @description 鑾峰彇琛ㄥ崟鍙傛暟 */ getFormData = () => { @@ -629,20 +584,29 @@ config: {}, groups: null, actions: null, - arr_field: '', setting: null, data: null, - configMap: {}, BIDs: {}, - setsingle: false, - pickup: false, - popData: false, - visible: false, primaryId: null, - refreshtabs: null }, () => { this.loadconfig() }) + } + + reloadMenuView = (menuId) => { + const { MenuID } = this.props + + if (MenuID !== menuId) return + + this.reloadview() + } + + reloadData = (menuId) => { + const { MenuID } = this.props + + if (MenuID !== menuId) return + + this.loadmaindata() } UNSAFE_componentWillMount () { @@ -650,15 +614,13 @@ this.loadconfig() } - UNSAFE_componentWillReceiveProps(nextProps) { - if (nextProps.refreshTab && nextProps.refreshTab.MenuID === this.props.MenuID) { - this.reloadview() - this.props.refreshTabView('') - } - } - shouldComponentUpdate (nextProps, nextState) { return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + } + + componentDidMount () { + MKEmitter.addListener('reloadMenuView', this.reloadMenuView) + MKEmitter.addListener('reloadData', this.reloadData) } /** @@ -668,6 +630,9 @@ this.setState = () => { return } + + MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) + MKEmitter.removeListener('reloadData', this.reloadData) } render() { @@ -722,12 +687,10 @@ Tab={_tab} MenuID={_tab.linkTab} SupMenuID={this.props.MenuID} - refreshtabs={this.state.refreshtabs} ContainerId={this.state.ContainerId} BID={this.state.BIDs[_tab.supMenu] || ''} BData={this.state.BIDs[_tab.supMenu + 'data'] || ''} handleTableId={this.handleTableId} - handleMainTable={(type) => this.handleMainTable(type, _tab)} /> : null} </TabPane> ) @@ -746,7 +709,6 @@ return { menuType: state.editLevel, tabviews: state.tabviews, - refreshTab: state.refreshTab, permAction: state.permAction, dataManager: state.dataManager, permRoles: state.permRoles @@ -755,7 +717,6 @@ const mapDispatchToProps = (dispatch) => { return { - refreshTabView: (refreshTab) => dispatch(refreshTabView(refreshTab)), modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews)) } } diff --git a/src/tabviews/subtable/index.jsx b/src/tabviews/subtable/index.jsx index cb53311..f59e1da 100644 --- a/src/tabviews/subtable/index.jsx +++ b/src/tabviews/subtable/index.jsx @@ -36,8 +36,6 @@ mainSearch: PropTypes.any, // 涓昏〃鎼滅储鏉′欢 ContainerId: PropTypes.any, // 涓夌骇鑿滃崟Container(html) ID handleTableId: PropTypes.func, // 鎺у埗琛ㄦ牸鏁版嵁鍒囨崲鏃讹紝鏇存柊鍦ㄤ富琛ㄤ腑鐨刬d - handleMainTable: PropTypes.func, // 鍒锋柊涓昏〃 - refreshtabs: PropTypes.any, // 鏍囩鍒锋柊鎺у埗 userConfig: PropTypes.any, // 鐢ㄦ埛鑷畾涔夎缃� } @@ -81,8 +79,6 @@ this.getStatFieldsValue(nextProps.BID, 'refresh') } }) - } else if (this.state.config && nextProps.refreshtabs && nextProps.refreshtabs.includes(this.props.Tab.uuid)) { - this.reloadtable() } else if (!this.props.Tab.supMenu && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { if (this.state.setting) { this.setState({}, () => { @@ -464,6 +460,65 @@ } /** + * @description 鑾峰彇鍗曡鏁版嵁 + */ + async loadmainLinedata (id) { + const { mainSearch, BID } = this.props + const { setting, arr_field, search, orderBy, pageIndex, pageSize } = this.state + + let searches = fromJS(search).toJS() + if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 + searches = [...mainSearch, ...searches] + } + + this.setState({ + loading: true + }) + + let _orderBy = orderBy || setting.order + let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, this.props.menuType, this.props.dataManager, id) + + if (param.func === 'sPC_Get_TableData') { + param.menuname = this.props.Tab.label || '' + } + + let result = await Api.genericInterface(param) + if (result.status) { + let data = fromJS(this.state.data).toJS() + if (result.data && result.data[0]) { + let _data = result.data[0] + + try { + data = data.map(item => { + if (item[setting.primaryKey] === _data[setting.primaryKey]) { + _data.key = item.key + return _data + } else { + return item + } + }) + } catch { + console.warn('鏁版嵁鏌ヨ閿欒') + } + } + + this.setState({ + data: data, + loading: false + }) + } else { + this.setState({ + loading: false + }) + notification.error({ + top: 92, + message: result.message, + duration: 10 + }) + } + } + + /** * @description 鑾峰彇鍚堣瀛楁鍊� */ getStatFieldsValue = (bid, type) => { @@ -573,49 +628,44 @@ /** * @description 琛ㄦ牸鍒锋柊 */ - reloadtable = () => { - MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 鍒楄〃閲嶇疆 - this.setState({ - pageIndex: 1 - }, () => { + reloadtable = (btn) => { + if (!btn || btn.resetPageIndex !== 'false') { + MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 鍒楄〃閲嶇疆 + this.setState({ + pageIndex: 1 + }, () => { + this.loadmaindata() + this.getStatFieldsValue() + }) + } else { + MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid, 'false') // 鍒楄〃閲嶇疆 this.loadmaindata() this.getStatFieldsValue() - }) - } - - /** - * @description 椤甸潰鍒锋柊锛岄噸鏂拌幏鍙栭厤缃� - */ - reloadview = () => { - this.setState({ loadingview: true, viewlost: false, lostmsg: '', config: null, searchlist: null, actions: null, - columns: null, arr_field: '', setting: null, data: null, total: 0, loading: false, pageIndex: 1, pageSize: 10, - orderBy: '', search: [] - }, () => { - this.loadconfig() - }) + } } /** * @description 鎸夐挳鎿嶄綔瀹屾垚鍚庯紙鎴愬姛鎴栧け璐ワ級锛岄〉闈㈠埛鏂帮紝閲嶇疆椤电爜鍙婇�夋嫨椤� */ - refreshbyaction = (position) => { - const { Tab } = this.props + refreshbyaction = (position, btn) => { + const { Tab, SupMenuID, BID } = this.props - if (position === 'grid') { - this.reloadtable() - } else if (position === 'view') { - this.reloadview() - } else if (position === 'maingrid') { - if (Tab.isTreeNode) { - this.reloadtable() + if (position === 'grid' || position === 'view') { + this.reloadtable(btn) + } else if (position === 'maingrid' || position === 'mainline') { + this.reloadtable(btn) + if (Tab.supMenu === 'mainTable') { + MKEmitter.emit('reloadData', SupMenuID, (BID || 'empty')) // 涓昏〃閲嶇疆 + } else if (Tab.supMenu) { + MKEmitter.emit('reloadData', Tab.supMenu, (BID || 'empty')) // 涓昏〃閲嶇疆 + } else if (!Tab.supMenu && Tab.level === 0) { + MKEmitter.emit('reloadData', SupMenuID, (BID || 'empty')) // 鏍戝舰缁撴瀯锛�0绾ф爣绛� } - this.props.handleMainTable('maingrid') } else if (position === 'equaltab') { - this.reloadtable() - this.props.handleMainTable('equaltab') - } else if (position === 'mainline') { - this.reloadtable() - this.props.handleMainTable('mainline') + this.reloadtable(btn) + if (Tab.equalTab && Tab.equalTab.length > 0) { + MKEmitter.emit('reloadData', Tab.equalTab.join(',')) // 鍚岀骇鏍囩閲嶇疆 + } } } @@ -671,13 +721,30 @@ this.setState({chartId: uuid}) } + reloadData = (menuId, id) => { + const { MenuID } = this.props + + if (menuId.indexOf(MenuID) === -1) return + if (id === 'empty') return + + if (!id) { + this.reloadtable() + } else { + this.loadmainLinedata(id) + } + } + UNSAFE_componentWillMount() { // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁 this.loadconfig() } - shouldComponentUpdate (nextProps, nextState) { // handleMainTable 鍑芥暟鍒ゆ柇鏃朵笉鐩哥瓑 - return !is(fromJS({...this.props, handleMainTable: '', handleTableId: ''}), fromJS({...nextProps, handleMainTable: '', handleTableId: ''})) || !is(fromJS(this.state), fromJS(nextState)) + shouldComponentUpdate (nextProps, nextState) { // handleTableId 鍑芥暟鍒ゆ柇鏃朵笉鐩哥瓑 + return !is(fromJS({...this.props, handleTableId: ''}), fromJS({...nextProps, handleTableId: ''})) || !is(fromJS(this.state), fromJS(nextState)) + } + + componentDidMount () { + MKEmitter.addListener('reloadData', this.reloadData) } /** @@ -687,6 +754,7 @@ this.setState = () => { return } + MKEmitter.removeListener('reloadData', this.reloadData) } render() { diff --git a/src/tabviews/subtabtable/index.jsx b/src/tabviews/subtabtable/index.jsx index 971d1d8..9d8409f 100644 --- a/src/tabviews/subtabtable/index.jsx +++ b/src/tabviews/subtabtable/index.jsx @@ -473,14 +473,21 @@ /** * @description 琛ㄦ牸鍒锋柊 */ - reloadtable = () => { - MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 鍒楄〃閲嶇疆 - this.setState({ - pageIndex: 1 - }, () => { + reloadtable = (btn) => { + if (!btn || btn.resetPageIndex !== 'false') { + MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 鍒楄〃閲嶇疆 + this.setState({ + pageIndex: 1 + }, () => { + this.loadmaindata() + this.getStatFieldsValue() + }) + } else { + MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid, 'false') // 鍒楄〃閲嶇疆 this.loadmaindata() this.getStatFieldsValue() - }) + } + } /** @@ -491,25 +498,11 @@ } /** - * @description 椤甸潰鍒锋柊锛岄噸鏂拌幏鍙栭厤缃� - */ - reloadview = () => { - this.setState({ loadingview: true, viewlost: false, lostmsg: '', config: null, searchlist: null, actions: null, columns: null, - arr_field: '', setting: null, data: null, total: 0, loading: false, pageIndex: 1, pageSize: 10, orderBy: '', search: '' - }, () => { - this.loadconfig() - }) - } - - /** * @description 鎸夐挳鎿嶄綔瀹屾垚鍚庯紙鎴愬姛鎴栧け璐ワ級锛岄〉闈㈠埛鏂帮紝閲嶇疆椤电爜鍙婇�夋嫨椤� */ - refreshbyaction = (position) => { - if (position === 'grid' || position === 'maingrid') { - this.reloadtable() - this.props.refreshSupView() - } else if (position === 'view') { - this.reloadview() + refreshbyaction = (position, btn) => { + if (position === 'grid' || position === 'view' || position === 'maingrid') { + this.reloadtable(btn) this.props.refreshSupView() } else if (position === 'trigger') { // 鏃ュ巻瀛愯〃瑙﹀彂鏍囩鐐瑰嚮浜嬩欢 this.props.closeModalView && this.props.closeModalView() diff --git a/src/tabviews/treepage/index.jsx b/src/tabviews/treepage/index.jsx index d90534d..579c736 100644 --- a/src/tabviews/treepage/index.jsx +++ b/src/tabviews/treepage/index.jsx @@ -13,8 +13,6 @@ import MKEmitter from '@/utils/events.js' import asyncComponent from '@/utils/asyncComponent' import asyncSpinComponent from '@/utils/asyncSpinComponent' -import {refreshTabView, modifyTabview} from '@/store/action' - import NotFount from '@/components/404' import './index.scss' @@ -51,7 +49,6 @@ BIDs: {}, // 涓婄骇琛╥d visible: false, // 寮规鏄剧ず闅愯棌鎺у埗 treevisible: false, // 鑿滃崟缁撴瀯鏍戝脊妗嗘樉绀洪殣钘忔帶鍒� - refreshtabs: null, // 闇�瑕佸埛鏂扮殑鏍囩闆� confirmLoading: false,// 鑷畾涔夎缃ā鎬佹鍔犺浇涓� revertLoading: false, // 鎭㈠榛樿璁剧疆 settingVisible: false,// 鑷畾涔夎缃ā鎬佹 @@ -483,33 +480,6 @@ } /** - * @description 瀛愯〃鎿嶄綔瀹屾垚鍚庡埛鏂颁富琛� - */ - handleMainTable = (type, tab) => { - if (type === 'maingrid' && (tab.supMenu === 'mainTable' || (!tab.supMenu && tab.level === 0))) { - this.loadmaindata() - } else if (type === 'mainline' && (tab.supMenu === 'mainTable' || (!tab.supMenu && tab.level === 0))) { - this.loadmaindata() - } else if ((type === 'maingrid' || type === 'mainline') && tab.supMenu) { - this.setState({ - refreshtabs: [type, tab.supMenu] - }, () => { - this.setState({ - refreshtabs: null - }) - }) - } else if (type === 'equaltab' && tab.equalTab && tab.equalTab.length > 0) { - this.setState({ - refreshtabs: tab.equalTab - }, () => { - this.setState({ - refreshtabs: null - }) - }) - } - } - - /** * @description 琛ㄦ牸Id鍙樺寲 */ handleTableId = (type, id, data) => { @@ -676,25 +646,43 @@ }) } + reloadData = (menuId) => { + const { MenuID } = this.props + + if (MenuID !== menuId) return + + this.loadmaindata() + } + + reloadMenuView = (menuId) => { + const { MenuID } = this.props + + if (MenuID !== menuId) return + + this.reloadview() + } + + resetActiveMenu = (menuId) => { + const { MenuID } = this.props + + if (MenuID !== menuId) return + + this.setShortcut() + } + UNSAFE_componentWillMount () { // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁 this.loadconfig() } - UNSAFE_componentWillReceiveProps(nextProps) { - if (nextProps.refreshTab && nextProps.refreshTab.MenuID === this.props.MenuID) { - this.reloadview() - this.props.refreshTabView('') - } else if (!is(fromJS(this.props.tabviews), fromJS(nextProps.tabviews))) { - let selectTab = nextProps.tabviews.filter(tab => tab.selected)[0] - if (selectTab && selectTab.MenuID === this.props.MenuID) { - this.setShortcut() - } - } - } - shouldComponentUpdate (nextProps, nextState) { return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + } + + componentDidMount () { + MKEmitter.addListener('reloadData', this.reloadData) + MKEmitter.addListener('reloadMenuView', this.reloadMenuView) + MKEmitter.addListener('resetActiveMenu', this.resetActiveMenu) } /** @@ -705,6 +693,9 @@ return } document.onkeydown = () => {} + MKEmitter.removeListener('reloadData', this.reloadData) + MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) + MKEmitter.removeListener('resetActiveMenu', this.resetActiveMenu) } changeExpandedKeys = (expandedKeys) => { @@ -791,12 +782,10 @@ mainSearch={null} userConfig={userConfig ? userConfig[_tab.uuid] : null} SupMenuID={this.props.MenuID} - refreshtabs={this.state.refreshtabs} ContainerId={this.state.ContainerId} BID={this.state.BIDs[_tab.supMenu] || ''} BData={this.state.BIDs[_tab.supMenu + 'data'] || ''} handleTableId={this.handleTableId} - handleMainTable={(type) => this.handleMainTable(type, _tab)} /> : null} </TabPane> ) @@ -868,8 +857,6 @@ const mapStateToProps = (state) => { return { menuType: state.editLevel, - tabviews: state.tabviews, - refreshTab: state.refreshTab, permAction: state.permAction, permRoles: state.permRoles, memberLevel: state.memberLevel, @@ -877,11 +864,8 @@ } } -const mapDispatchToProps = (dispatch) => { - return { - refreshTabView: (refreshTab) => dispatch(refreshTabView(refreshTab)), - modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews)) - } +const mapDispatchToProps = () => { + return {} } export default connect(mapStateToProps, mapDispatchToProps)(TreePage) \ No newline at end of file diff --git a/src/tabviews/zshare/actionList/index.jsx b/src/tabviews/zshare/actionList/index.jsx index 3d00fe4..6fa7ed5 100644 --- a/src/tabviews/zshare/actionList/index.jsx +++ b/src/tabviews/zshare/actionList/index.jsx @@ -41,9 +41,9 @@ return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) } - updateStatus = (type, positon) => { + updateStatus = (type, positon, btn) => { if (type === 'refresh') { - this.props.refreshdata(positon) + this.props.refreshdata(positon, btn) } else if (type === 'trigger') { // 鏃ュ巻涓殑鏂版爣绛鹃〉瑙﹀彂浜嬩欢 this.props.refreshdata('trigger') } diff --git a/src/tabviews/zshare/actionList/popupbutton/index.jsx b/src/tabviews/zshare/actionList/popupbutton/index.jsx index 7368167..cc2f838 100644 --- a/src/tabviews/zshare/actionList/popupbutton/index.jsx +++ b/src/tabviews/zshare/actionList/popupbutton/index.jsx @@ -115,7 +115,8 @@ // 鎿嶄綔鍚庡埛鏂颁富琛� reloadtable = () => { - this.props.updateStatus('refresh', 'grid') + const { btn } = this.props + this.props.updateStatus('refresh', 'grid', btn) } /** diff --git a/src/tabviews/zshare/cardcomponent/index.jsx b/src/tabviews/zshare/cardcomponent/index.jsx index d3283a3..c611f51 100644 --- a/src/tabviews/zshare/cardcomponent/index.jsx +++ b/src/tabviews/zshare/cardcomponent/index.jsx @@ -147,7 +147,7 @@ columns={logcolumns} selectedData={[data]} ContainerId={ContainerId} - updateStatus={this.updateStatus} + updateStatus={this.props.refreshdata} /> ) } else if (item.OpenType === 'popview') { @@ -161,7 +161,7 @@ BData={BData} setting={setting} selectedData={[data]} - updateStatus={this.updateStatus} + updateStatus={this.props.refreshdata} /> ) } else if (item.OpenType === 'tab' || item.OpenType === 'blank') { @@ -173,7 +173,7 @@ MenuID={MenuID} setting={setting} selectedData={[data]} - updateStatus={this.updateStatus} + updateStatus={this.props.refreshdata} /> ) } else if (item.OpenType === 'innerpage' || item.OpenType === 'outerpage') { @@ -184,7 +184,7 @@ show={show} setting={setting} selectedData={[data]} - updateStatus={this.updateStatus} + updateStatus={this.props.refreshdata} /> ) } else if (item.OpenType === 'funcbutton') { @@ -197,7 +197,7 @@ show={show} setting={setting} selectedData={[data]} - updateStatus={this.updateStatus} + updateStatus={this.props.refreshdata} /> ) } else if (item.funcType === 'print') { @@ -212,7 +212,7 @@ setting={setting} selectedData={[data]} ContainerId={ContainerId} - updateStatus={this.updateStatus} + updateStatus={this.props.refreshdata} /> ) } @@ -220,15 +220,6 @@ return null }) - } - - /** - * @description 鎿嶄綔瀹屾垚鍚庯紝鏁版嵁鍒锋柊 - */ - updateStatus = (type, positon) => { - if (type === 'refresh') { - this.props.refreshdata(positon) - } } /** @@ -511,7 +502,7 @@ columns={this.props.logcolumns} selectedData={[]} ContainerId={this.props.ContainerId} - updateStatus={this.updateStatus} + updateStatus={this.props.refreshdata} /> </div> </Card> : null} @@ -761,6 +752,15 @@ this.props.handleTableId(this.props.tableId, _id, data) } + /** + * @description 鎿嶄綔瀹屾垚鍚庯紝鏁版嵁鍒锋柊 + */ + updateStatus = (type, positon, btn) => { + if (type === 'refresh') { + this.props.refreshdata(positon, btn) + } + } + render() { const { plot, data, loading, BID, BData, Tab, MenuID, config, logcolumns, ContainerId, MenuName } = this.props const { card, colMap, selectKey, actionList } = this.state @@ -787,7 +787,7 @@ show="icon" MenuName={MenuName} setting={config.setting} - updateStatus={() => {}} + updateStatus={this.updateStatus} /> ) } else { @@ -801,7 +801,7 @@ MenuName={MenuName} setting={config.setting} getexceloutparam={this.props.getexceloutparam} - updateStatus={() => {}} + updateStatus={this.updateStatus} /> ) } @@ -826,7 +826,7 @@ setting={config.setting} ContainerId={ContainerId} switchCard={this.switchCard} - refreshdata={this.props.refreshdata} + refreshdata={this.updateStatus} /> )) } @@ -844,7 +844,7 @@ setting={config.setting} ContainerId={ContainerId} switchCard={() => {}} - refreshdata={this.props.refreshdata} + refreshdata={this.updateStatus} /> : null } {(loading || !card.insertAction) && (!data || data.length === 0) ? <Empty description={false}/> : null} diff --git a/src/tabviews/zshare/normalTable/index.jsx b/src/tabviews/zshare/normalTable/index.jsx index bde034c..1de6ca6 100644 --- a/src/tabviews/zshare/normalTable/index.jsx +++ b/src/tabviews/zshare/normalTable/index.jsx @@ -45,7 +45,7 @@ refreshdata: PropTypes.func, // 琛ㄦ牸涓帓搴忓垪銆侀〉鐮佺殑鍙樺寲鏃跺埛鏂� handleTableId: PropTypes.func, // 鏁版嵁鍒囨崲 chgSelectData: PropTypes.func, // 鏁版嵁鍒囨崲 - refreshbyaction: PropTypes.func, // 鏁版嵁鍒囨崲 + refreshbyaction: PropTypes.func, // 鎸夐挳鎵ц瀹屾垚鍚庡埛鏂� } state = { @@ -200,6 +200,12 @@ return } MKEmitter.removeListener('resetTable', this.resetTable) + } + + updateStatus = (type, positon, btn) => { + if (type === 'refresh') { + this.props.refreshbyaction(positon, btn) + } } // 瀛楁閫忚 @@ -604,7 +610,7 @@ MenuName={this.props.MenuName} columns={this.props.logcolumns} ContainerId={this.props.ContainerId} - updateStatus={this.props.refreshbyaction} + updateStatus={this.updateStatus} /> ) } else if (btn.OpenType === 'popview') { @@ -616,7 +622,7 @@ selectedData={[record]} BData={this.props.BData} setting={this.props.setting} - updateStatus={this.props.refreshbyaction} + updateStatus={this.updateStatus} /> ) } else if (btn.OpenType === 'tab' || btn.OpenType === 'blank') { @@ -627,7 +633,7 @@ selectedData={[record]} MenuID={this.props.MenuID} setting={this.props.setting} - updateStatus={this.props.refreshbyaction} + updateStatus={this.updateStatus} /> ) } else if (btn.OpenType === 'innerpage' || btn.OpenType === 'outerpage') { @@ -637,7 +643,7 @@ btn={btn} selectedData={[record]} setting={this.props.setting} - updateStatus={this.props.refreshbyaction} + updateStatus={this.updateStatus} /> ) } @@ -988,16 +994,23 @@ this.props.handleTableId(this.props.tableId, _id, _data) } - resetTable = (id) => { + resetTable = (id, repage) => { const { MenuID, tableId } = this.props if (id !== (MenuID + tableId)) return - this.setState({ - pageIndex: 1, - selectedRowKeys: [], - activeIndex: null - }) + if (repage === 'false') { + this.setState({ + selectedRowKeys: [], + activeIndex: null + }) + } else { + this.setState({ + pageIndex: 1, + selectedRowKeys: [], + activeIndex: null + }) + } } render() { diff --git a/src/templates/formtabconfig/actionform/index.jsx b/src/templates/formtabconfig/actionform/index.jsx index c6adf76..798f054 100644 --- a/src/templates/formtabconfig/actionform/index.jsx +++ b/src/templates/formtabconfig/actionform/index.jsx @@ -38,10 +38,7 @@ text: this.props.dict['header.form.refresh.never'] }, { value: 'grid', - text: this.props.dict['header.form.refresh.grid'] - }, { - value: 'view', - text: this.props.dict['header.form.refresh.view'] + text: this.props.dict['header.form.refresh'] }], currentoptions: [{ // 涓嶈繑鍥炴椂-涓嶅埛鏂般�佸埛鏂� value: 'never', @@ -56,8 +53,6 @@ UNSAFE_componentWillMount () { const { card } = this.props let _intertype = '' - let _success = 'close' - let _error = 'notclose' this.props.formlist.forEach(form => { if (form.key === 'intertype') { @@ -65,10 +60,6 @@ if (card.btnType !== 'confirm') { form.options = form.options.filter(op => op.value !== 'system') } - } else if (form.key === 'afterExecSuccess') { - _success = form.initVal - } else if (form.key === 'afterExecError') { - _error = form.initVal } }) @@ -80,6 +71,8 @@ item.options = btnClasses } else if (item.key === 'icon') { item.options = btnIcons + } else if (item.key === 'resetPageIndex') { + item.tooltip = '椤甸潰鍏抽棴锛屼笖鎵ц鍒锋柊鏃剁敓鏁�' } else if (item.key === 'sqlType') { item.options = this.state.insertUpdateOptions } else if (item.key === 'OpenType') { @@ -97,18 +90,9 @@ } } else if (item.key === 'execSuccess' && card.btnType === 'cancel') { item.label = '鍏抽棴鍚�' - } else if (item.key === 'execSuccess' && card.btnType !== 'cancel') { - if (_success === 'close') { - item.options = this.state.returnoptions - } else { - item.options = this.state.currentoptions - } - } else if (item.key === 'execError') { - if (_error === 'close') { - item.options = this.state.returnoptions - } else { - item.options = this.state.currentoptions - } + item.options[1].text = '鍒锋柊' + } else if (item.key === 'execSuccess' || item.key === 'execError') { + item.options[1].text = '鍒锋柊' } else if (item.key === 'innerFunc' && card.btnType !== 'confirm' && _intertype === 'inner') { item.required = true } @@ -136,62 +120,24 @@ let _options = [] if (btnType === 'cancel') { - _options = ['label', 'OpenType', 'icon', 'class', 'execSuccess'] + _options = ['label', 'OpenType', 'icon', 'class', 'execSuccess', 'resetPageIndex'] } else if (btnType === 'confirm') { if (intertype === 'outer') { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'interface', 'outerFunc', 'callbackFunc', 'sysInterface', 'icon', 'class', 'execSuccess', 'execError', 'afterExecSuccess', 'afterExecError'] + _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'interface', 'outerFunc', 'callbackFunc', 'sysInterface', 'icon', 'class', 'execSuccess', 'execError', 'afterExecSuccess', 'afterExecError', 'resetPageIndex'] } else if (intertype === 'system') { - _options = ['label', 'OpenType', 'intertype', 'icon', 'class', 'execSuccess', 'execError', 'sql', 'sqlType', 'afterExecSuccess', 'afterExecError'] + _options = ['label', 'OpenType', 'intertype', 'icon', 'class', 'execSuccess', 'execError', 'sql', 'sqlType', 'afterExecSuccess', 'afterExecError', 'resetPageIndex'] } else { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError', 'afterExecSuccess', 'afterExecError'] + _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError', 'afterExecSuccess', 'afterExecError', 'resetPageIndex'] } } else { if (intertype === 'outer') { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'interface', 'outerFunc', 'callbackFunc', 'sysInterface', 'icon', 'class', 'execSuccess', 'execError', 'afterExecSuccess', 'afterExecError'] + _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'interface', 'outerFunc', 'callbackFunc', 'sysInterface', 'icon', 'class', 'execSuccess', 'execError', 'afterExecSuccess', 'afterExecError', 'resetPageIndex'] } else { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError', 'afterExecSuccess', 'afterExecError'] + _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError', 'afterExecSuccess', 'afterExecError', 'resetPageIndex'] } } return _options - } - - selectChange = (key, value) => { - if (key === 'afterExecSuccess') { - this.setState({ - formlist: this.state.formlist.map(item => { - if (item.key === 'execSuccess') { - if (value === 'close') { - item.options = this.state.returnoptions - } else { - item.options = this.state.currentoptions - } - } - - return item - }) - }) - this.props.form.setFieldsValue({ - execSuccess: 'never' - }) - } else if (key === 'afterExecError') { - this.setState({ - formlist: this.state.formlist.map(item => { - if (item.key === 'execError') { - if (value === 'close') { - item.options = this.state.returnoptions - } else { - item.options = this.state.currentoptions - } - } - - return item - }) - }) - this.props.form.setFieldsValue({ - execError: 'never' - }) - } } onChange = (e, key) => { @@ -339,7 +285,6 @@ showSearch filterOption={(input, option) => option.props.children[2].toLowerCase().indexOf(input.toLowerCase()) >= 0} getPopupContainer={() => document.getElementById('winter')} - onChange={(val) => this.selectChange(item.key, val)} disabled={!!item.readonly} > {item.options.map((option, index) => @@ -355,7 +300,12 @@ } else if (item.type === 'radio') { fields.push( <Col span={12} key={index}> - <Form.Item label={item.label}> + <Form.Item label={item.tooltip ? + <Tooltip placement="topLeft" title={item.tooltip}> + <Icon type="question-circle" /> + {item.label} + </Tooltip> : item.label + }> {getFieldDecorator(item.key, { initialValue: item.initVal, rules: [ diff --git a/src/templates/sharecomponent/actioncomponent/actionform/index.jsx b/src/templates/sharecomponent/actioncomponent/actionform/index.jsx index 3ee5f04..9138958 100644 --- a/src/templates/sharecomponent/actioncomponent/actionform/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/actionform/index.jsx @@ -204,6 +204,10 @@ } } + if (_options.includes('execSuccess') || _options.includes('popClose')) { + _options.push('resetPageIndex') + } + return _options } diff --git a/src/templates/zshare/formconfig.jsx b/src/templates/zshare/formconfig.jsx index 11d1285..bffa047 100644 --- a/src/templates/zshare/formconfig.jsx +++ b/src/templates/zshare/formconfig.jsx @@ -633,6 +633,16 @@ tabTems = [] } + if (card.execSuccess === 'view' || card.execSuccess === 'refresh') { // refresh涓鸿〃鍗曟爣绛鹃〉 + card.execSuccess = 'grid' + } + if (card.execError === 'view' || card.execSuccess === 'refresh') { + card.execError = 'grid' + } + if (card.popClose === 'view') { + card.popClose = 'grid' + } + let refresh = [] if (type === 'subtable') { // 瀛愯〃椤甸潰锛屽彲璁剧疆鍒锋柊涓昏〃鍙婂悓绾ф爣绛� refresh.push({ @@ -641,9 +651,6 @@ }, { value: 'equaltab', text: Formdict['header.form.refresh.equaltab'] - // }, { - // value: 'mainline', - // text: Formdict['header.form.refresh.mainline'] }) } @@ -878,7 +885,7 @@ options: menulist }, { - type: 'select', + type: 'radio', key: 'afterExecSuccess', label: Formdict['header.form.afterExecSuccess'], initVal: card.afterExecSuccess || 'close', @@ -892,7 +899,7 @@ }] }, { - type: 'select', + type: 'radio', key: 'afterExecError', label: Formdict['header.form.afterExecError'], initVal: card.afterExecError || 'notclose', @@ -906,7 +913,7 @@ }] }, { - type: 'select', + type: refresh.length === 0 ? 'radio' : 'select', key: 'execSuccess', label: Formdict['model.form.afterSuccess'], initVal: card.execSuccess || 'never', @@ -917,14 +924,11 @@ }, { value: 'grid', text: Formdict['header.form.refresh.grid'] - }, { - value: 'view', - text: Formdict['header.form.refresh.view'] }, ...refresh] }, { - type: 'select', + type: refresh.length === 0 ? 'radio' : 'select', key: 'execError', label: Formdict['model.form.afterError'], initVal: card.execError || 'never', @@ -935,13 +939,11 @@ }, { value: 'grid', text: Formdict['header.form.refresh.grid'] - }, { - value: 'view', - text: Formdict['header.form.refresh.view'] - }] + }, + ...refresh] }, { - type: 'select', + type: refresh.length === 0 ? 'radio' : 'select', key: 'popClose', label: Formdict['header.form.popClose'], initVal: card.popClose || 'never', @@ -952,13 +954,24 @@ }, { value: 'grid', text: Formdict['header.form.refresh.grid'] - }, { - value: 'view', - text: Formdict['header.form.refresh.view'] }, ...refresh] }, { + type: 'radio', + key: 'resetPageIndex', + label: '鍒锋柊鏃�', + initVal: card.resetPageIndex || 'true', + required: false, + options: [{ + value: 'true', + text: '閲嶇疆椤电爜' + }, { + value: 'false', + text: '涓嶉噸缃�' + }] + }, + { type: 'select', key: 'icon', label: Formdict['model.icon'], diff --git a/src/utils/utils-datamanage.js b/src/utils/utils-datamanage.js index d214736..a107fdc 100644 --- a/src/utils/utils-datamanage.js +++ b/src/utils/utils-datamanage.js @@ -16,13 +16,13 @@ * @param {Boolean} dataManager 鏁版嵁鏉冮檺 * @return {Object} param */ - static getQueryDataParams (setting, arrFields, search = [], orderBy = '', pageIndex = 1, pageSize = 10, BID, menuType, dataManager) { + static getQueryDataParams (setting, arrFields, search = [], orderBy = '', pageIndex = 1, pageSize = 10, BID, menuType, dataManager, id) { let param = null if (setting.interType === 'system' || (setting.interType === 'inner' && !setting.innerFunc)) { - param = this.getDefaultQueryParam(setting, arrFields, search, orderBy, pageIndex, pageSize, menuType) + param = this.getDefaultQueryParam(setting, arrFields, search, orderBy, pageIndex, pageSize, menuType, id) } else { - param = this.getCustomQueryParam(setting, search, orderBy, pageIndex, pageSize, menuType) + param = this.getCustomQueryParam(setting, search, orderBy, pageIndex, pageSize, menuType, id) } if (BID) { @@ -39,14 +39,16 @@ /** * @description 鑾峰彇鐢ㄦ埛鑷畾涔夊瓨鍌ㄨ繃绋嬩紶鍙� */ - static getCustomQueryParam (setting, search, orderBy, pageIndex, pageSize, menuType) { + static getCustomQueryParam (setting, search, orderBy, pageIndex, pageSize, menuType, id) { let param = Utils.formatCustomMainSearch(search) if (orderBy) { param.OrderCol = orderBy } - if (setting.laypage) { + if (id) { + param.ID = id + } else if (setting.laypage) { param.PageIndex = pageIndex param.PageSize = pageSize } @@ -79,7 +81,7 @@ /** * @description 鑾峰彇绯荤粺瀛樺偍杩囩▼ sPC_Get_TableData 鐨勫弬鏁� */ - static getDefaultQueryParam (setting, arrFields, search, orderBy, pageIndex, pageSize, menuType) { + static getDefaultQueryParam (setting, arrFields, search, orderBy, pageIndex, pageSize, menuType, id) { let param = { func: 'sPC_Get_TableData', obj_name: 'data', @@ -137,11 +139,14 @@ regoptions.forEach(item => { _dataresource = _dataresource.replace(item.reg, item.value) }) - } else if (_dataresource) { + } else if (_dataresource && !id) { _search = Utils.joinMainSearchkey(search) if (_search) { _search = 'where ' + _search } + } else if (_dataresource && id) { + _search = Utils.joinMainSearchkey(search) + _search = `where ${_search ? _search + ' AND ' : ''} ${setting.primaryKey || 'ID'}='${id}'` } if (_customScript) { @@ -153,7 +158,7 @@ let LText = '' let DateCount = '' - if (_dataresource && setting.laypage && orderBy) { + if (_dataresource && setting.laypage && orderBy && !id) { LText = ` select top ${pageSize} ${arrFields} from (select ${arrFields} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${_dataresource} ${_search}) tmptable where rows > ${pageSize * (pageIndex - 1)} order by tmptable.rows ` DateCount = `select count(1) as total from ${_dataresource} ${_search}` } else if (_dataresource && orderBy) { diff --git a/src/views/billprint/index.jsx b/src/views/billprint/index.jsx index 33a6125..eda3914 100644 --- a/src/views/billprint/index.jsx +++ b/src/views/billprint/index.jsx @@ -225,6 +225,17 @@ }) } + reload = () => { + this.setState({ + loadingview: true, + pages: null, + data: '', + config: null + }, () => { + this.getMenuParam() + }) + } + /** * @description 鑾峰彇绯荤粺瀛樺偍杩囩▼ sPC_Get_TableData 鐨勫弬鏁� */ @@ -553,6 +564,7 @@ </div> : null} {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} {pages && !loadingview && !viewlost ? <div className="print-button"><Button icon="printer" size="large" shape="circle" onClick={this.print}></Button></div> : null} + {!loadingview && !viewlost ? <div className="refresh-button"><Button icon="reload" size="large" shape="circle" onClick={this.reload}></Button></div> : null} </div> ) } diff --git a/src/views/billprint/index.scss b/src/views/billprint/index.scss index a42978b..2185279 100644 --- a/src/views/billprint/index.scss +++ b/src/views/billprint/index.scss @@ -14,6 +14,11 @@ .print-button { position: fixed; right: 10px; - top: 45vh; + top: 40vh; + } + .refresh-button { + position: fixed; + right: 10px; + top: calc(40vh + 70px); } } diff --git a/src/views/login/index.jsx b/src/views/login/index.jsx index ff7281e..ddee480 100644 --- a/src/views/login/index.jsx +++ b/src/views/login/index.jsx @@ -70,6 +70,10 @@ }) } + /** + * @description 璐﹀彿瀵嗙爜鐧诲綍 + * @param {Object} param 鐢ㄦ埛鍚嶅瘑鐮佺瓑淇℃伅 + */ async loginsubmit (param) { if (options.sysType === 'local' && !window.GLOB.mainSystemApi) { // 涓氬姟绯荤粺蹇呴』璁剧疆鍗曠偣鍦板潃 Modal.warning({ @@ -86,6 +90,9 @@ sessionStorage.setItem('User_Name', res.UserName) sessionStorage.setItem('Full_Name', res.FullName) sessionStorage.setItem('avatar', res.icon || '') + sessionStorage.setItem('dataM', res.dataM ? 'true' : '') + sessionStorage.setItem('debug', res.debug || '') + sessionStorage.setItem('role_id', res.role_id || '') localStorage.setItem('lang', param.lang || 'zh-CN') @@ -141,6 +148,9 @@ sessionStorage.setItem('User_Name', res.UserName) sessionStorage.setItem('Full_Name', res.FullName) sessionStorage.setItem('avatar', res.icon || '') + sessionStorage.setItem('dataM', res.dataM ? 'true' : '') + sessionStorage.setItem('debug', res.debug || '') + sessionStorage.setItem('role_id', res.role_id || '') localStorage.setItem('lang', param.lang || 'zh-CN') diff --git a/src/views/main/index.jsx b/src/views/main/index.jsx index dab2cfa..2e3af47 100644 --- a/src/views/main/index.jsx +++ b/src/views/main/index.jsx @@ -1,15 +1,33 @@ import React, {Component} from 'react' import { ConfigProvider } from 'antd' +import { connect } from 'react-redux' import enUS from 'antd/es/locale/en_US' import zhCN from 'antd/es/locale/zh_CN' import Header from '@/components/header' import Sidemenu from '@/components/sidemenu' import Tabview from '@/components/tabview' +import { resetDebug, modifyDataManager, initRolesPermission } from '@/store/action' + import './index.scss' const _locale = localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS class Main extends Component { + UNSAFE_componentWillMount() { + if (sessionStorage.getItem('dataM') === 'true') { + this.props.modifyDataManager(true) + } + if (sessionStorage.getItem('debug') === 'true') { + this.props.resetDebug() + } + if (sessionStorage.getItem('role_id')) { + let roles = sessionStorage.getItem('role_id') + roles = roles.split(',') + + this.props.initRolesPermission(roles) + } + } + render () { return ( <div className="flex-container"> @@ -23,4 +41,16 @@ } } -export default Main \ No newline at end of file +const mapStateToProps = () => { + return {} +} + +const mapDispatchToProps = (dispatch) => { + return { + resetDebug: () => dispatch(resetDebug()), + initRolesPermission: (roles) => dispatch(initRolesPermission(roles)), + modifyDataManager: (dataManager) => dispatch(modifyDataManager(dataManager)) + } +} + +export default connect(mapStateToProps, mapDispatchToProps)(Main) \ No newline at end of file diff --git a/src/views/menudesign/homeform/index.jsx b/src/views/menudesign/homeform/index.jsx new file mode 100644 index 0000000..d16f9b4 --- /dev/null +++ b/src/views/menudesign/homeform/index.jsx @@ -0,0 +1,118 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { Form, Row, Col, Radio, Icon, Tooltip, InputNumber } from 'antd' + +import './index.scss' + +class CustomMenuForm extends Component { + static propTpyes = { + dict: PropTypes.object, // 瀛楀吀椤� + config: PropTypes.object, + updateConfig: PropTypes.func + } + + // 涓�浜岀骇鑿滃崟鍒囨崲 + selectChange = (key, value) => { + const { config } = this.props + + 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}) + } + } + + changeCacheDay = (val) => { + if (typeof(val) !== 'number') { + val = '' + } + this.props.updateConfig({...this.props.config, cacheTime: val}) + } + + render() { + const { dict, config } = this.props + const { getFieldDecorator } = this.props.form + const formItemLayout = { + labelCol: { + xs: { span: 24 }, + sm: { span: 8 } + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 16 } + } + } + + return ( + <Form {...formItemLayout} className="custom-menu-form"> + <Row> + <Col span={24}> + <Form.Item label={ + <Tooltip placement="topLeft" title="瀵逛簬涓嶇粡甯告�у彉鍔ㄧ殑淇℃伅锛岀紦瀛樻暟鎹湁鍔╀簬鎻愰珮鏌ヨ鏁堢巼銆�"> + <Icon type="question-circle" /> + 缂撳瓨鏁版嵁 + </Tooltip> + }> + {getFieldDecorator('cacheUseful', { + initialValue: config.cacheUseful || 'false' + })( + <Radio.Group onChange={(e) => {this.selectChange('cacheUseful', e.target.value)}}> + <Radio value="true">浣跨敤</Radio> + <Radio value="false">涓嶄娇鐢�</Radio> + </Radio.Group> + )} + </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', { + initialValue: config.timeUnit || 'day' + })( + <Radio.Group onChange={(e) => {this.selectChange('timeUnit', e.target.value)}}> + <Radio value="day">澶�</Radio> + <Radio value="hour">灏忔椂</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> : null} + {config.cacheUseful === 'true' ? <Col span={24}> + <Form.Item label="鏃堕暱"> + {getFieldDecorator('cacheTime', { + initialValue: config.cacheTime, + rules: [ + { + required: true, + message: dict['mob.required.input'] + '鏃堕暱!' + } + ] + })( + <InputNumber min={1} max={config.timeUnit !== 'hour' ? 7 : 23} precision={0} onChange={this.changeCacheDay}/> + )} + </Form.Item> + </Col> : null} + </Row> + </Form> + ) + } +} + +export default Form.create()(CustomMenuForm) \ No newline at end of file diff --git a/src/views/menudesign/homeform/index.scss b/src/views/menudesign/homeform/index.scss new file mode 100644 index 0000000..71a1a33 --- /dev/null +++ b/src/views/menudesign/homeform/index.scss @@ -0,0 +1,10 @@ +.custom-menu-form { + .anticon-question-circle { + color: #c49f47; + position: relative; + left: -3px; + } + .ant-input-number { + width: 100%; + } +} \ No newline at end of file diff --git a/src/views/menudesign/index.jsx b/src/views/menudesign/index.jsx index 4dceaa3..b491da0 100644 --- a/src/views/menudesign/index.jsx +++ b/src/views/menudesign/index.jsx @@ -23,6 +23,7 @@ const _locale = localStorage.getItem('lang') !== 'en-US' ? antdZhCN : antdEnUS const MenuForm = asyncComponent(() => import('./menuform')) +const HomeForm = asyncComponent(() => import('./homeform')) const PrintMenuForm = asyncComponent(() => import('./printmenuform')) const Header = asyncComponent(() => import('@/menu/header')) const SourceWrap = asyncComponent(() => import('@/menu/modelsource')) @@ -187,6 +188,46 @@ }) } + getMenuMessage = () => { + const { config } = this.state + let buttons = [] + let _sort = 1 + + let traversal = (components) => { + components.forEach(item => { + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + traversal(tab.components) + }) + } else if (item.type === 'card' || (item.type === 'table' && item.subtype === 'tablecard')) { + item.subcards.forEach(card => { + card.elements && card.elements.forEach(cell => { + if (cell.eleType !== 'button') return + + buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort`) + _sort++ + }) + card.backElements && card.backElements.forEach(cell => { + if (cell.eleType !== 'button') return + + buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort`) + _sort++ + }) + }) + } else if (item.type === 'line' || item.type === 'bar') { + item.action && item.action.forEach(btn => { + buttons.push(`select '${btn.uuid}' as menuid, '${item.name + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`) + _sort++ + }) + } + }) + } + + traversal(config.components) + + return buttons + } + submitConfig = () => { const { config, openEdition } = this.state @@ -197,7 +238,14 @@ duration: 5 }) return - } else if (config.MenuType === 'custom' && (!config.MenuName || !config.MenuNo || !config.fstMenuId || !config.parentId)) { + } else if (config.MenuType === 'home' && (config.cacheUseful === 'true' && !config.cacheTime)) { + notification.warning({ + top: 92, + message: '璇峰畬鍠勮彍鍗曞熀鏈俊鎭紒', + duration: 5 + }) + return + } else if (config.MenuType === 'custom' && (!config.MenuName || !config.MenuNo || !config.fstMenuId || !config.parentId || (config.cacheUseful === 'true' && !config.cacheTime))) { notification.warning({ top: 92, message: '璇峰畬鍠勮彍鍗曞熀鏈俊鎭紒', @@ -216,21 +264,6 @@ delete _config.sysRoles delete _config.tableFields - let funcs = [] - if (config.MenuType !== 'billPrint') { - _config.components.forEach(component => { - if (component.setting && component.setting.innerFunc) { - funcs.push(`select '${_config.uuid}' as MenuID,'${component.setting.innerFunc}' as ProcName,'${component.setting.name}' as MenuName`) - } - if (component.action) { - component.action.forEach(item => { - if (!item.innerFunc) return - funcs.push(`select '${_config.uuid}' as MenuID,'${item.innerFunc}' as ProcName,'${item.label}' as MenuName`) - }) - } - }) - } - let param = { func: 'sPC_TrdMenu_AddUpt', FstID: _config.fstMenuId || '', @@ -243,8 +276,8 @@ MenuName: _config.MenuName || '', PageParam: JSON.stringify({Template: 'CustomPage', OpenType: 'newtab'}), LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(_config))), - LText: funcs.join(' union all '), - LTexttb: '' // 琛ㄥ悕 + LText: '', + LTexttb: '' } param.LText = Utils.formatOptions(param.LText) @@ -253,6 +286,28 @@ if (openEdition) { // 鐗堟湰绠$悊 param.open_edition = openEdition + } + + let btnParam = { // 娣诲姞鑿滃崟鎸夐挳 + func: 'sPC_Button_AddUpt', + Type: 40, // 娣诲姞鑿滃崟涓嬬殑鎸夐挳type涓�40锛屾寜閽笅鐨勬寜閽畉ype涓�60 + ParentID: _config.uuid, + MenuNo: _config.MenuNo, + Template: 'CustomPage', + PageParam: '', + LongParam: '', + LText: [] + } + + if (config.MenuType !== 'billPrint') { + btnParam.LText = this.getMenuMessage() + + btnParam.LText = btnParam.LText.join(' union all ') + btnParam.LText = Utils.formatOptions(btnParam.LText) + btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp) + } else { + btnParam.LText = '' } this.setState({ @@ -468,6 +523,11 @@ initMenuList={this.initMenuList} updateConfig={this.updateConfig} /> : null} + {config && MenuType === 'home' ? <HomeForm + dict={dict} + config={config} + updateConfig={this.updateConfig} + /> : null} {config && MenuType === 'billPrint' ? <PrintMenuForm dict={dict} config={config} diff --git a/src/views/menudesign/menuform/index.jsx b/src/views/menudesign/menuform/index.jsx index 8c4594c..a52cd68 100644 --- a/src/views/menudesign/menuform/index.jsx +++ b/src/views/menudesign/menuform/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { fromJS } from 'immutable' -import { Form, Row, Col, Input, Select, notification } from 'antd' +import { Form, Row, Col, Input, Select, notification, Radio, Icon, Tooltip, InputNumber } from 'antd' import Api from '@/api' import './index.scss' @@ -108,6 +108,12 @@ }) } else if (key === 'parentId') { 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}) } } @@ -126,6 +132,13 @@ this.props.updateConfig({...this.props.config, easyCode: e.target.value}) } + changeCacheDay = (val) => { + if (typeof(val) !== 'number') { + val = '' + } + this.props.updateConfig({...this.props.config, cacheTime: val}) + } + render() { const { dict, MenuName, MenuNo, config } = this.props const { menulist, smenulist } = this.state @@ -142,7 +155,7 @@ } return ( - <Form {...formItemLayout} className="ant-advanced-search-form"> + <Form {...formItemLayout} className="custom-menu-form"> <Row> <Col span={24}> <Form.Item label={dict['mob.menu.first'] + dict['mob.menu']}> @@ -213,6 +226,67 @@ </Form.Item> </Col> <Col span={24}> + <Form.Item label={ + <Tooltip placement="topLeft" title="瀵逛簬涓嶇粡甯告�у彉鍔ㄧ殑淇℃伅锛岀紦瀛樻暟鎹湁鍔╀簬鎻愰珮鏌ヨ鏁堢巼銆�"> + <Icon type="question-circle" /> + 缂撳瓨鏁版嵁 + </Tooltip> + }> + {getFieldDecorator('cacheUseful', { + initialValue: config.cacheUseful || 'false' + })( + <Radio.Group onChange={(e) => {this.selectChange('cacheUseful', e.target.value)}}> + <Radio value="true">浣跨敤</Radio> + <Radio value="false">涓嶄娇鐢�</Radio> + </Radio.Group> + )} + </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', { + initialValue: config.timeUnit || 'day' + })( + <Radio.Group onChange={(e) => {this.selectChange('timeUnit', e.target.value)}}> + <Radio value="day">澶�</Radio> + <Radio value="hour">灏忔椂</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> : null} + {config.cacheUseful === 'true' ? <Col span={24}> + <Form.Item label="鏃堕暱"> + {getFieldDecorator('cacheTime', { + initialValue: config.cacheTime, + rules: [ + { + required: true, + message: dict['mob.required.input'] + '鏃堕暱!' + } + ] + })( + <InputNumber min={1} max={config.timeUnit !== 'hour' ? 7 : 23} precision={0} onChange={this.changeCacheDay}/> + )} + </Form.Item> + </Col> : null} + <Col span={24}> <Form.Item label={dict['mob.menu.easycode']}> {getFieldDecorator('easyCode', { initialValue: config.easyCode diff --git a/src/views/menudesign/menuform/index.scss b/src/views/menudesign/menuform/index.scss index e69de29..71a1a33 100644 --- a/src/views/menudesign/menuform/index.scss +++ b/src/views/menudesign/menuform/index.scss @@ -0,0 +1,10 @@ +.custom-menu-form { + .anticon-question-circle { + color: #c49f47; + position: relative; + left: -3px; + } + .ant-input-number { + width: 100%; + } +} \ No newline at end of file -- Gitblit v1.8.0