From 68e178709892cf8bf95573def01cf29cf243c6e4 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 31 十二月 2024 16:53:54 +0800 Subject: [PATCH] 2024-12-31 --- src/views/syscheck/index.jsx | 259 ++++++++++++++++++++++++++++++++++----------------- 1 files changed, 174 insertions(+), 85 deletions(-) diff --git a/src/views/syscheck/index.jsx b/src/views/syscheck/index.jsx index 3c8d786..acee1d2 100644 --- a/src/views/syscheck/index.jsx +++ b/src/views/syscheck/index.jsx @@ -2,7 +2,7 @@ import { fromJS } from 'immutable' import { Spin, notification, Button } from 'antd' import moment from 'moment' -// import { QuestionCircleOutlined } from '@ant-design/icons' +import { SwapOutlined } from '@ant-design/icons' import Api from '@/api' import Utils from '@/utils/utils.js' @@ -14,18 +14,19 @@ class SysCheck extends Component { state = { + stop: false, loading: false, menulist: [], - thdMenuList: [], - applist: [], + activeMenu: null, + remain: 0, lackmenus: [], outmenus: [], backmenus: [], + appbackmenus: [], unablemenus: [], } sqlmap = null - repmap = null UNSAFE_componentWillMount() { document.body.className = '' @@ -50,69 +51,66 @@ getMenus = () => { this.setState({ + stop: false, + activeMenu: null, + remain: 0, + menulist: [], + lackmenus: [], + outmenus: [], + backmenus: [], + appbackmenus: [], + unablemenus: [], loading: true }) Api.getCloudConfig({func: 's_get_pc_menus', systemType: window.GLOB.sysType, debug: 'Y'}).then(result => { if (result.status) { - let thdMenuList = [] - let menulist = result.fst_menu.map(fst => { - let fstItem = { - MenuID: fst.MenuID, - MenuName: fst.MenuName, - children: [] - } - + let menulist = [] + result.fst_menu.forEach(fst => { if (fst.snd_menu) { - fstItem.children = fst.snd_menu.map(snd => { - let sndItem = { - MenuID: snd.MenuID, - MenuName: snd.MenuName, - children: [] - } - + fst.snd_menu.forEach(snd => { if (snd.trd_menu) { - sndItem.children = snd.trd_menu.map(trd => { - let trdItem = { + snd.trd_menu.forEach(trd => { + if (trd.PageParam) { + let pass = false + try { + let PageParam = JSON.parse(trd.PageParam) + if (PageParam && PageParam.Template === 'RolePermission') { + pass = true + } + } catch (e) { + + } + if (pass) return + } + + menulist.push({ MenuID: trd.MenuID, MenuName: trd.MenuName, MenuNo: trd.MenuNo, pName: fst.MenuName + '-' + snd.MenuName, - type: 'CustomPage', - } - - if (trd.PageParam) { - try { - trd.PageParam = JSON.parse(trd.PageParam) - trdItem.type = trd.PageParam.Template || 'CustomPage' - } catch (e) { - - } - } - - thdMenuList.push(trdItem) - - return trdItem + }) }) } - return sndItem }) } - return fstItem }) - this.setState({ - menulist, - thdMenuList - }) - - if (thdMenuList.length === 0) { + if (menulist.length === 0) { this.setState({ loading: false }) + notification.warning({ + top: 92, + message: '鏈煡璇㈠埌鑿滃崟淇℃伅锛�', + duration: 5 + }) } else { + this.setState({ + menulist + }) + this.sqlmap = new Map() - this.repmap = new Map() - this.getMenuParam(fromJS(thdMenuList).toJS()) + this.getMenuParam(fromJS(menulist).toJS()) } } else { this.setState({ @@ -133,6 +131,15 @@ } this.setState({ + stop: false, + activeMenu: null, + remain: 0, + menulist: [], + lackmenus: [], + outmenus: [], + backmenus: [], + appbackmenus: [], + unablemenus: [], loading: true }) @@ -157,6 +164,11 @@ this.setState({ loading: false }) + notification.warning({ + top: 92, + message: '鏈煡璇㈠埌鑿滃崟淇℃伅锛�', + duration: 5 + }) } else { let deffers = applist.map((app, i) => new Promise(resolve => { @@ -173,15 +185,9 @@ setTimeout(() => { Api.getCloudConfig(param).then(result => { - delete result.ErrCode - delete result.ErrMesg - if (result.status) { - result = { - ...app, - status: true, - menus: [] - } + app.status = true + app.menus = [] result.menus.forEach(m => { if (m.menus_rolelist) { @@ -197,11 +203,12 @@ } delete m.menus_rolelist - result.menus.push(m) + app.menus.push(m) }) + resolve(app) + } else { + resolve(result) } - - resolve(result) }) }, 200 * i) }) @@ -219,11 +226,36 @@ loading: false }) } else { - let list = response.filter(cell => cell.menus.length > 0) - this.setState({ - loading: false, - applist: list + let list = [] + response.forEach(item => { + item.menus.forEach(cell => { + list.push({ + ...cell, + lang: item.lang, + kei_no: item.kei_no, + typename: item.typename, + pName: `${item.name}锛�${item.typename} / ${item.lang}锛塦, + }) + }) }) + + if (list.length === 0) { + this.setState({ + loading: false + }) + notification.warning({ + top: 92, + message: '鏈煡璇㈠埌鑿滃崟淇℃伅锛�', + duration: 5 + }) + } else { + this.setState({ + menulist: list + }) + + this.sqlmap = new Map() + this.getMenuParam(fromJS(list).toJS()) + } } }) } @@ -241,15 +273,25 @@ } getMenuParam = (menus) => { - const { lackmenus, outmenus, unablemenus, backmenus } = this.state + const { lackmenus, outmenus, unablemenus, backmenus, appbackmenus, stop } = this.state let menu = menus.shift() - const { MenuID } = menu let param = { func: 'sPC_Get_LongParam', - MenuID: MenuID + MenuID: menu.MenuID } + + if (menu.kei_no) { + param.TypeCharOne = menu.kei_no + param.typename = menu.typename + param.lang = menu.lang + } + + this.setState({ + activeMenu: menu, + remain: menus.length + }) Api.getCloudConfig(param).then(result => { if (result.status) { @@ -264,9 +306,9 @@ if (!config) { this.setState({lackmenus: [...lackmenus, menu]}) - } else if (!['CustomPage', 'BaseTable'].includes(config.Template)) { + } else if (!menu.kei_no && !['CustomPage', 'BaseTable'].includes(config.Template)) { this.setState({outmenus: [...outmenus, menu]}) - } else if (config.Template === 'CustomPage' && config.version !== 2.0) { + } else if (!menu.kei_no && config.Template === 'CustomPage' && config.version !== 2.0) { menu.version = config.version this.setState({outmenus: [...outmenus, menu]}) } else if (!config.enabled) { @@ -275,21 +317,40 @@ let sqls = getAllSqls(config) let keys = sqls.map(item => item.uuid) - sqls.forEach(item => { - if (this.sqlmap.has(item.uuid)) { - if (!this.repmap.has(item.uuid)) { - this.repmap.set(item.uuid, menu) - } - } else { - this.sqlmap.set(item.uuid, menu) - } - }) - if (keys.length > Array.from(new Set(keys)).length) { this.setState({backmenus: [...backmenus, menu]}) + } else { + let repeat = false + let premenu = null + sqls.forEach(item => { + if (this.sqlmap.has(item.uuid)) { + window.mkInfo(item) + if (repeat) return + repeat = true + premenu = this.sqlmap.get(item.uuid) + } else { + this.sqlmap.set(item.uuid, menu) + } + }) + if (premenu) { + this.setState({appbackmenus: [...appbackmenus, [premenu, menu]]}) + } } } + + if (menus.length > 0 && !stop) { + setTimeout(() => { + this.getMenuParam(menus) + }, 200) + } else { + this.setState({ + loading: false + }) + } } else { + this.setState({ + loading: false + }) notification.warning({ top: 92, message: result.message, @@ -300,23 +361,51 @@ } render () { - const { loading } = this.state + const { loading, activeMenu, menulist, remain, lackmenus, outmenus, unablemenus, backmenus, appbackmenus } = this.state if (!sessionStorage.getItem('UserID')) return null return ( <div className="mk-app-check"> <Header view="manage" /> - {loading ? - <div className="loading-mask"> - <Spin size="large" /> - </div> : null - } + {loading ? <Spin size="large" /> : null} <div className="view-wrap"> - <div> - <Button disabled={loading} type="primary" style={{marginRight: '15px'}} onClick={this.getMenus}>妫�鏌ョ鐞嗙郴缁熻彍鍗�</Button> - <Button disabled={loading} type="primary" onClick={this.getAppList}>妫�鏌ュ瓙搴旂敤鑿滃崟</Button> + <div className="action"> + <Button disabled={loading} style={{marginRight: '15px'}} onClick={this.getMenus}>妫�鏌ョ鐞嗙郴缁熻彍鍗�</Button> + <Button disabled={loading} style={{marginRight: '15px'}} onClick={this.getAppList}>妫�鏌ュ瓙搴旂敤鑿滃崟</Button> + <Button onClick={() => this.setState({stop: true})}>鍋滄</Button> </div> + {activeMenu ? <div className="menu-msg">褰撳墠鑿滃崟锛歿activeMenu.MenuName} <span></span> {activeMenu.pName} <span></span> 杩涘害锛坽menulist.length - remain} / {menulist.length}锛�</div> : null} + {lackmenus.length ? <div className="item-wrap"> + <div className="title">鑿滃崟閰嶇疆涓嶅瓨鍦�</div> + {lackmenus.map((item, i) => { + return <div key={i}>{item.MenuName} <span></span> {item.pName}</div> + })} + </div> : null} + {outmenus.length ? <div className="item-wrap"> + <div className="title">鑿滃崟閰嶇疆闇�瑕佸崌绾�</div> + {outmenus.map((item, i) => { + return <div key={i}>{item.MenuName} <span></span> {item.pName}</div> + })} + </div> : null} + {unablemenus.length ? <div className="item-wrap"> + <div className="title">鑿滃崟鏈惎鐢�</div> + {unablemenus.map((item, i) => { + return <div key={i}>{item.MenuName} <span></span> {item.pName}</div> + })} + </div> : null} + {backmenus.length ? <div className="item-wrap"> + <div className="title">鑿滃崟鍚庣鑴氭湰ID閲嶅</div> + {backmenus.map((item, i) => { + return <div key={i}>{item.MenuName} <span></span> {item.pName}</div> + })} + </div> : null} + {appbackmenus.length ? <div className="item-wrap"> + <div className="title">鑿滃崟鍚庣鑴氭湰ID閲嶅锛堣彍鍗曢棿锛�</div> + {appbackmenus.map((item, i) => { + return <div key={i}>{item[0].MenuName} <span></span> {item[0].pName} <SwapOutlined /> {item[1].MenuName} <span></span> {item[1].pName}</div> + })} + </div> : null} </div> </div> ) -- Gitblit v1.8.0