From b6c698c8833836971184a0a9c2645a15f8174d37 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 08 五月 2025 16:31:18 +0800 Subject: [PATCH] Merge branch 'master' into positec --- src/components/header/index.jsx | 187 +++++++++++++++++++++++++++++++++++----------- 1 files changed, 142 insertions(+), 45 deletions(-) diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx index 7db59b7..187b7fa 100644 --- a/src/components/header/index.jsx +++ b/src/components/header/index.jsx @@ -10,6 +10,8 @@ import MKEmitter from '@/utils/events.js' import Utils from '@/utils/utils.js' import avatar from '@/assets/img/avatar.jpg' +import wxicon from '@/assets/img/wx-icon.png' +import mkpublic from '@/assets/img/mkpublic.jpg' import './index.scss' const { confirm } = Modal @@ -17,6 +19,7 @@ const Resetpwd = asyncComponent(() => import('@/components/resetPassword')) const QrCode = asyncComponent(() => import('@/components/qrcode')) const LoginForm = asyncSpinComponent(() => import('./loginform')) +const SysIcon = asyncComponent(() => import('./sysmessage/icon')) class Header extends Component { state = { @@ -24,6 +27,8 @@ userName: '', fullName: '', logourl: window.GLOB.mainlogo, + wxVisible: false, + wxStep: 1, loginVisible: false, loginLoading: false, avatar: Utils.getrealurl(sessionStorage.getItem('avatar')), @@ -31,7 +36,9 @@ searchkey: '', thdMenuList: [], debug: sessionStorage.getItem('debug') === 'true' && window.GLOB.memberLevel > 0, - collapse: sessionStorage.getItem('collapse') === 'true' + collapse: sessionStorage.getItem('collapse') === 'true', + lang: sessionStorage.getItem('lang') || '', + dict: window.GLOB.dict } UNSAFE_componentWillMount () { @@ -52,7 +59,9 @@ componentDidMount () { // 鑾峰彇绯荤粺鐨勭増鏈俊鎭紝寤舵椂鏌ヨ setTimeout(() => { - Api.getAppVersion() + if (!window.GLOB.$error) { + Api.getAppVersion() + } }, 1000) // sessionStorage 璺ㄩ〉闈㈠叡浜� @@ -60,7 +69,7 @@ if (e.key === 'getSessionStorage' && e.newValue === window.GLOB.appkey) { localStorage.setItem('sessionStorage', JSON.stringify(sessionStorage)) } else if (e.key === 'getSysPermission' && e.newValue === window.GLOB.appkey) { - localStorage.setItem('sysPermissions', JSON.stringify({mkThdMenus: window.GLOB.mkThdMenus, mkActions: window.GLOB.mkActions})) + localStorage.setItem('sysPermissions', JSON.stringify({mkThdMenus: this.state.thdMenuList, mkActions: window.GLOB.mkActions})) } else if (e.key === 'menuUpdate') { let vals = e.newValue.split(',') let menuId = vals[1] @@ -74,6 +83,24 @@ } } }) + + if (sessionStorage.getItem('local_error')) { + try { + let param = JSON.parse(sessionStorage.getItem('local_error')) + setTimeout(() => { + Api.genericInterface({ + func: 's_special_error_note_log', + ...param + }).then(res => { + if (res.status) { + sessionStorage.removeItem('local_error') + } + }) + }, 3000) + } catch (e) { + sessionStorage.removeItem('local_error') + } + } } shouldComponentUpdate (nextProps, nextState) { @@ -105,21 +132,26 @@ setTimeout(() => { sessionStorage.clear() this.props.history.replace('/login') + window.location.reload() }, 2000) }) } logout = () => { + const { dict } = this.state // 閫�鍑虹櫥褰� - let _this = this + let that = this confirm({ - title: '鎮ㄧ‘瀹氳閫�鍑哄悧?', + title: dict['logout_query'] || '鎮ㄧ‘瀹氳閫�鍑哄悧锛�', content: '', - okText: '纭畾', - cancelText: '鍙栨秷', + okText: dict['ok'] || '纭畾', + cancelText: dict['cancel'] || '鍙栨秷', onOk() { sessionStorage.clear() - _this.props.history.replace('/login') + setTimeout(() => { + that.props.history.replace('/login') + window.location.reload() + }, 100) }, onCancel() {} }) @@ -180,13 +212,22 @@ } window.GLOB.mainMenu = mainMenu - window.GLOB.mkThdMenus = [...thdMenuList, {MenuID: 'home_page_id', EasyCode: '', MenuName: 'home', type: 'CustomPage'}] + + thdMenuList.forEach(item => { + window.GLOB.mkThdMenus.set(item.MenuID, item) + }) + + window.GLOB.mkThdMenus.set('home_page_id', {MenuID: 'home_page_id', EasyCode: '', MenuName: 'home', type: 'CustomPage'}) MKEmitter.emit('mainMenuChange') if (_menu) { this.openTab(_menu, 0) } + + setTimeout(() => { + this.getwork() + }, 100) }) // 鑾峰彇瑙掕壊鏉冮檺, edition_type 鎺ュ彛鐗堟湰鎺у埗 ''銆�'Y'銆�'A' @@ -205,7 +246,7 @@ _permAction[menu.MenuID] = true }) } - } else { + } else if (!/PRIMARY KEY/ig.test(result.message)) { notification.error({ top: 92, message: result.message, @@ -218,6 +259,29 @@ }, 50) } + getwork = () => { + if (sessionStorage.getItem('work_grade')) return + + let param = {func: 's_get_local_my_worker_v1'} + + if (window.GLOB.forcedUpdate) { + param.s_version_up = 'true' + } + + Api.genericInterface(param).then(result => { + sessionStorage.setItem('work_grade', result.work_grade || 0) + sessionStorage.setItem('work_group', result.work_group || '') + + if (!result.status && sessionStorage.getItem('debug') === 'true') { + notification.error({ + top: 92, + message: /s_get_local_my_worker_v1/.test(result.message) ? '鑱屽憳淇℃伅鑾峰彇澶辫触锛岃鑱旂郴绠$悊鍛樸��' : result.message, + duration: 10 + }) + } + }) + } + openTab = (menu, times) => { if (times > 50) return times++ @@ -228,7 +292,7 @@ MKEmitter.emit('modifyTabs', menu) } else { setTimeout(() => { - this.openTab(times) + this.openTab(menu, times) }, 200) } } @@ -251,9 +315,10 @@ if (PageParam.OpenType === 'outpage' && PageParam.linkUrl) { fstItem.OpenType = 'newpage' - fstItem.src = PageParam.linkUrl + fstItem.src = window.GLOB.systemType === 'production' && PageParam.linkProUrl ? PageParam.linkProUrl : PageParam.linkUrl + fstItem.src = fstItem.src.replace(/@loginuid@/ig, sessionStorage.getItem('LoginUID')) + fstItem.src = fstItem.src.replace(/@userid@/ig, sessionStorage.getItem('UserID')) if (/#\/iframe\//.test(fstItem.src)) { - fstItem.src = fstItem.src.replace(/@loginuid@/ig, sessionStorage.getItem('LoginUID')) fstItem.type = 'iframe' fstItem.OpenType = 'newtab' } @@ -290,7 +355,7 @@ ParentNames: [fst.MenuName, snd.MenuName], MenuNo: trd.MenuNo, EasyCode: trd.EasyCode, - type: 'CommonTable', + type: 'CustomPage', OpenType: 'newtab', hidden: 'false' } @@ -299,15 +364,18 @@ try { let PageParam = JSON.parse(trd.PageParam) - trdItem.type = PageParam.Template || 'CommonTable' + trdItem.type = PageParam.Template || 'CustomPage' trdItem.OpenType = PageParam.OpenType || 'newtab' trdItem.hidden = PageParam.hidden || 'false' + trdItem.menuColor = PageParam.menuColor || '' + trdItem.urlFields = PageParam.urlFields || '' if (trdItem.type === 'NewPage') { trdItem.OpenType = 'newpage' - trdItem.src = PageParam.url || '' + trdItem.src = window.GLOB.systemType === 'production' && PageParam.proUrl ? PageParam.proUrl : PageParam.url || '' + trdItem.src = trdItem.src.replace(/@loginuid@/ig, sessionStorage.getItem('LoginUID')) + trdItem.src = trdItem.src.replace(/@userid@/ig, sessionStorage.getItem('UserID')) if (/#\/iframe\//.test(trdItem.src)) { - trdItem.src = trdItem.src.replace(/@loginuid@/ig, sessionStorage.getItem('LoginUID')) trdItem.type = 'iframe' trdItem.OpenType = 'newtab' } @@ -387,7 +455,7 @@ if (!isNaN(s) && s > 90) { Modal.warning({ width: 520, - title: <span>绯荤粺妫�娴嬪埌鎮ㄧ殑璐︽埛瀛樺湪椋庨櫓锛岃鍙婃椂鍒�<a target="_blank" rel="noopener noreferrer" href="https://cloud.mk9h.cn/admin/index.html">浜戜腑蹇�</a>淇敼瀵嗙爜锛�</span>, + title: <span>绯荤粺妫�娴嬪埌鎮ㄧ殑璐︽埛瀛樺湪椋庨櫓锛岃鍙婃椂鍒�<a target="_blank" rel="noopener noreferrer" href="https://cloud.positecgroup.com/admin/index.html">浜戜腑蹇�</a>淇敼瀵嗙爜锛�</span>, okText: '鐭ラ亾浜�' }) return @@ -402,11 +470,12 @@ sessionStorage.setItem('cloudDataM', res.dataM ? 'true' : '') sessionStorage.setItem('cloudRole_id', res.role_id || '') - let _url = window.location.href.split('#')[0] + 'cloud' + sessionStorage.setItem('CloudLogo', res.open_logo || '') + if (param.remember) { - localStorage.setItem(_url, window.btoa(window.encodeURIComponent(JSON.stringify({time: new Date().getTime(), username: param.username, password: param.password})))) + localStorage.setItem(window.GLOB.sysSign + 'cloud', window.btoa(window.encodeURIComponent(JSON.stringify({time: new Date().getTime(), username: param.username, password: param.password})))) } else { - localStorage.setItem(_url, window.btoa(window.encodeURIComponent(JSON.stringify({time: new Date().getTime(), username: param.username, password: ''})))) + localStorage.setItem(window.GLOB.sysSign + 'cloud', window.btoa(window.encodeURIComponent(JSON.stringify({time: new Date().getTime(), username: param.username, password: ''})))) } window.GLOB.mainMenu = null @@ -524,25 +593,31 @@ } verup = () => { + const { dict } = this.state + confirm({ - title: '椤甸潰鏇存柊', - content: '閲嶆柊鍔犺浇搴旂敤淇℃伅', + title: dict['page_upd'] || '椤甸潰鏇存柊', + content: dict['reload_app'] || '閲嶆柊鍔犺浇搴旂敤淇℃伅', + okText: dict['ok'] || '纭畾', + cancelText: dict['cancel'] || '鍙栨秷', onOk() { return new Promise(resolve => { if (!window.GLOB.IndexDB) { notification.warning({ top: 92, - message: '鏇存柊澶辫触锛岃鍒锋柊椤甸潰閲嶈瘯锛�', + message: dict['exc_fail'] || '鏇存柊澶辫触锛岃鍒锋柊椤甸潰閲嶈瘯锛�', duration: 2 }) resolve() } else { Api.updateAppVersion() Api.delCacheConfig('all') + localStorage.removeItem(window.location.href.split('#')[0] + 'AuthCode') + setTimeout(() => { notification.success({ top: 92, - message: '鏇存柊鎴愬姛锛�', + message: dict['exc_success'] || '鏇存柊鎴愬姛锛�', duration: 2 }) resolve() @@ -556,15 +631,8 @@ about = () => { Modal.success({ - title: '绯荤粺鐗堟湰v' + window.GLOB.appVersion - }) - } - - wxnotice = () => { - Modal.success({ - className: 'mk-wx-notice', - title: <QrCode card={{qrWidth: 320, color: '#000000'}} value={window.GLOB.baseurl + 'mob/wxnotice.html?userid=' + sessionStorage.getItem('UserID') + '&loginuid=' + sessionStorage.getItem('LoginUID')}/>, - okText: '鍏抽棴' + title: (window.GLOB.dict['sys_ver'] || '绯荤粺鐗堟湰') + ' v' + window.GLOB.appVersion, + okText: window.GLOB.dict['got_it'] || '鐭ラ亾浜�', }) } @@ -575,32 +643,32 @@ } render () { - const { thdMenuList, searchkey, debug, menulist, collapse } = this.state + const { thdMenuList, searchkey, debug, menulist, collapse, dict } = this.state const navBar = window.GLOB.navBar const menu = ( <Menu className="header-dropdown"> {debug && <Menu.Item key="switch"> - 缂栬緫 + {dict['edit'] || '缂栬緫'} <Switch size="small" style={{marginLeft: '7px'}} checked={false} onChange={this.changeEditState} /> </Menu.Item>} - <Menu.Item key="password" onClick={this.changePassword}>淇敼瀵嗙爜</Menu.Item> - {this.state.systems.length ? <Menu.SubMenu style={{minWidth: '110px'}} title="鍒囨崲绯荤粺"> + <Menu.Item key="password" onClick={this.changePassword}>{dict['ch_pwd'] || '淇敼瀵嗙爜'}</Menu.Item> + {this.state.systems.length ? <Menu.SubMenu style={{minWidth: '110px'}} title={dict['swt_sys'] || '鍒囨崲绯荤粺'}> {this.state.systems.map((system, index) => ( <Menu.Item style={{minWidth: '100px', lineHeight: '30px'}} key={'sub' + index} onClick={() => {this.changeSystem(system)}}> {system.AppName} </Menu.Item> ))} </Menu.SubMenu> : null} - <Menu.Item key="doc" onClick={this.gotoDoc}>鏂囨。涓績</Menu.Item> + <Menu.Item key="doc" onClick={this.gotoDoc}>{dict['doc_center'] || '鏂囨。涓績'}</Menu.Item> <Menu.Item key="verup" onClick={this.verup}> - 椤甸潰鏇存柊 + {dict['page_upd'] || '椤甸潰鏇存柊'} </Menu.Item> - {window.GLOB.WXNotice ? <Menu.Item key="wxnotice" onClick={this.wxnotice}> + {window.GLOB.WXNotice ? <Menu.Item key="wxnotice" onClick={() => this.setState({wxVisible: true, wxStep: 1})}> 寰俊娑堟伅 </Menu.Item> : null} {window.GLOB.appVersion ? <Menu.Item key="version" onClick={this.about}> - 鍏充簬 + {dict['about'] || '鍏充簬'} </Menu.Item> : null} - <Menu.Item key="logout" onClick={this.logout}>閫�鍑�</Menu.Item> + <Menu.Item key="logout" onClick={this.logout}>{dict['logout'] || '閫�鍑�'}</Menu.Item> </Menu> ) @@ -680,7 +748,7 @@ <div className="title" onClick={e => e.stopPropagation()}>{cell.MenuName}</div> <div className="menu-detail"> {cell.children && cell.children.map(m => ( - <div key={m.MenuID} title={m.MenuName} onClick={() => {this.changeVerMenu(m)}}> + <div key={m.MenuID} title={m.MenuName} style={m.menuColor ? {color: m.menuColor} : null} onClick={() => {this.changeVerMenu(m)}}> {m.MenuName} </div> ))} @@ -744,6 +812,7 @@ <SearchOutlined className="search-menu" /> </Dropdown> : null } + {window.GLOB.SysNotice ? <SysIcon /> : null} {/* 澶村儚銆佺敤鎴峰悕 */} <Dropdown className="header-setting" overlay={menu}> <div> @@ -755,7 +824,7 @@ </Dropdown> {/* 缂栬緫鐘舵�佺櫥褰� */} <Modal - title="鐧诲綍寮�鍙戞満" + title={<span>鐧诲綍寮�鍙戞満{this.state.lang === 'en-US' ? <span style={{color: 'red'}}>锛堣嫳鏂囷級</span> : ''}</span>} visible={this.state.loginVisible} onOk={this.loginSubmit} width={'430px'} @@ -767,6 +836,34 @@ </Modal> {/* 淇敼瀵嗙爜 */} <Resetpwd /> + {/* 寰俊娑堟伅 */} + <Modal + wrapClassName="mk-wx-sms-modal" + visible={this.state.wxVisible} + title="鎵爜鍏虫敞 鎺ユ敹娑堟伅" + width={400} + centered={true} + onCancel={() => this.setState({wxVisible: false})} + footer={null} + destroyOnClose + > + {this.state.wxStep !== 2 ? <div className="wx-sms-wrap"> + <img className="mk-img" src={mkpublic} alt=""/> + <div className="mk-tip"> + <span>寰俊鎵爜</span> + <span>鍏虫敞鍏紬鍙�</span> + <span>鍏虫敞鍏紬鍙蜂笖鎺堟潈鍚庢柟鍙帴鏀舵秷鎭��</span> + <span onClick={() => this.setState({wxStep: 2})}>涓嬩竴姝�</span> + </div> + </div> : <div className="wx-sms-wrap"> + <QrCode card={{qrWidth: 200, color: '#000000'}} value={window.GLOB.baseurl + 'mob/wxnotice.html?userid=' + sessionStorage.getItem('UserID') + '&loginuid=' + sessionStorage.getItem('LoginUID')}/> + <div className="tip"> + <img src={wxicon} alt=""/> + <span>寰俊鎵爜</span> + <span>鑾峰彇鐢ㄦ埛鎺堟潈</span> + </div> + </div>} + </Modal> </header> ) } -- Gitblit v1.8.0