| | |
| | | import React, {Component} from 'react' |
| | | import { withRouter } from 'react-router-dom' |
| | | import {connect} from 'react-redux' |
| | | import { Dropdown, Menu, Modal, notification, Switch, Button, Popover } from 'antd' |
| | | import { MenuFoldOutlined, SettingOutlined, AppstoreOutlined, DownOutlined, HomeOutlined, ApiOutlined, PlusOutlined, EditOutlined, MenuOutlined, DatabaseOutlined } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import { |
| | | modifyMenuTree, |
| | | modifyMainMenu, |
| | | resetEditLevel, |
| | | logout |
| | | } from '@/store/action' |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | import avatar from '@/assets/img/avatar.jpg' |
| | | import MainLogo from '@/assets/img/main-logo.png' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import './index.scss' |
| | | |
| | |
| | | const VersionsUp = asyncComponent(() => import('./versions')) |
| | | const ThawMenu = asyncComponent(() => import('@/components/thawmenu')) |
| | | const MenuForm = asyncComponent(() => import('./editfirstmenu/menuform')) |
| | | const TransMenu = asyncComponent(() => import('./transmenu')) |
| | | |
| | | const { confirm } = Modal |
| | | |
| | | class Header extends Component { |
| | |
| | | menulist: null, // 一级菜单 |
| | | userName: sessionStorage.getItem('CloudUserName'), |
| | | avatar: Utils.getrealurl(sessionStorage.getItem('CloudAvatar')), |
| | | memberLevel: Utils.getMemberLevel(), |
| | | logo: sessionStorage.getItem('CloudLogo') || MainLogo, |
| | | visible: false, |
| | | loading: false |
| | | } |
| | | |
| | | logout = () => { |
| | | // 退出登录 |
| | | let _this = this |
| | | let that = this |
| | | confirm({ |
| | | title: '您确定要退出吗?', |
| | | content: '', |
| | | onOk() { |
| | | sessionStorage.clear() |
| | | _this.props.logout() |
| | | _this.props.history.replace('/login') |
| | | that.props.history.replace('/login') |
| | | window.location.reload() |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | |
| | | EasyCode: trd.EasyCode, |
| | | type: 'CommonTable', // 默认值为常用表 |
| | | OpenType: 'newtab', // 打开方式 |
| | | up_action: window.GLOB.upStatus && trd.up_action === 'Y', |
| | | level: 'third' |
| | | } |
| | | |
| | |
| | | } catch (e) { |
| | | trdItem.PageParam = {OpenType: 'newtab'} |
| | | } |
| | | if (trdItem.PageParam.Template === 'RolePermission' || trdItem.PageParam.Template === 'NewPage') { |
| | | trdItem.PageParam.backend = 'level1' |
| | | } |
| | | |
| | | if (trdItem.type === 'CustomPage' && this.state.memberLevel < 20) { // 会员等级大于等于20时,有编辑权限 |
| | | if (trdItem.type === 'CustomPage' && window.GLOB.memberLevel < 20) { // 会员等级大于等于20时,有编辑权限 |
| | | trdItem.forbidden = true |
| | | } |
| | | |
| | |
| | | }, () => {}) |
| | | } |
| | | |
| | | setSystemFuncs = () => { |
| | | if (!window.GLOB.IndexDB) { |
| | | return |
| | | } |
| | | this.getfuncTime().then(res => { |
| | | Api.getSystemFuncs(res.createDate).then(result => { |
| | | if (!result.status) { |
| | | notification.error({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | } else if (result.func_detail && result.func_detail.length > 0) { |
| | | this.writeFuncs(result.func_detail) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | // setSystemFuncs = () => { |
| | | // if (!window.GLOB.IndexDB) { |
| | | // return |
| | | // } |
| | | // this.getfuncTime().then(res => { |
| | | // Api.getSystemFuncs(res.createDate).then(result => { |
| | | // if (!result.status) { |
| | | // notification.error({ |
| | | // top: 92, |
| | | // message: result.message, |
| | | // duration: 10 |
| | | // }) |
| | | // } else if (result.func_detail && result.func_detail.length > 0) { |
| | | // this.writeFuncs(result.func_detail) |
| | | // } |
| | | // }) |
| | | // }) |
| | | // } |
| | | |
| | | writeFuncs = (funcs) => { |
| | | let shim = +sessionStorage.getItem('sys_time_shim') |
| | | let timestamp = moment().add(shim, 'seconds').format('YYYY-MM-DD HH:mm:ss') |
| | | // writeFuncs = (funcs) => { |
| | | // let shim = +sessionStorage.getItem('sys_time_shim') |
| | | // let timestamp = moment().add(shim, 'seconds').format('YYYY-MM-DD HH:mm:ss') |
| | | |
| | | let objectStore = window.GLOB.IndexDB.transaction(['funcs'], 'readwrite').objectStore('funcs') |
| | | // let objectStore = window.GLOB.IndexDB.transaction(['funcs'], 'readwrite').objectStore('funcs') |
| | | |
| | | objectStore.clear() |
| | | // objectStore.clear() |
| | | |
| | | funcs.forEach(item => { |
| | | if (!item.key_sql) return |
| | | item.id = item.func_code |
| | | objectStore.add(item) |
| | | }) |
| | | // funcs.forEach(item => { |
| | | // if (!item.key_sql) return |
| | | // item.id = item.func_code |
| | | // objectStore.add(item) |
| | | // }) |
| | | |
| | | let funcStore = window.GLOB.IndexDB.transaction(['version'], 'readwrite').objectStore('version') |
| | | funcStore.put({id: 'funcs', version: '1.0', createDate: timestamp}) |
| | | } |
| | | // let funcStore = window.GLOB.IndexDB.transaction(['version'], 'readwrite').objectStore('version') |
| | | // funcStore.put({id: 'funcs', version: '1.0', createDate: timestamp}) |
| | | // } |
| | | |
| | | getfuncTime = () => { |
| | | return new Promise((resolve, reject) => { |
| | | let objectStore = window.GLOB.IndexDB.transaction(['version'], 'readwrite').objectStore('version') |
| | | let request = objectStore.get('funcs') |
| | | // getfuncTime = () => { |
| | | // return new Promise((resolve, reject) => { |
| | | // let objectStore = window.GLOB.IndexDB.transaction(['version'], 'readwrite').objectStore('version') |
| | | // let request = objectStore.get('funcs') |
| | | |
| | | request.onerror = (event) => { |
| | | console.warn(event) |
| | | reject() |
| | | } |
| | | // request.onerror = (event) => { |
| | | // console.warn(event) |
| | | // reject() |
| | | // } |
| | | |
| | | request.onsuccess = () => { |
| | | if (request.result) { |
| | | resolve(request.result) |
| | | } else { |
| | | let add = objectStore.add({id: 'funcs', version: '1.0', createDate: '1970-01-01 14:59:09.000'}) |
| | | // request.onsuccess = () => { |
| | | // if (request.result) { |
| | | // resolve(request.result) |
| | | // } else { |
| | | // let add = objectStore.add({id: 'funcs', version: '1.0', createDate: '1970-01-01 14:59:09.000'}) |
| | | |
| | | add.onerror = () => { |
| | | reject() |
| | | } |
| | | add.onsuccess = () => { |
| | | resolve({id: 'funcs', version: '1.0', createDate: '1970-01-01 14:59:09.000'}) |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | // add.onerror = () => { |
| | | // reject() |
| | | // } |
| | | // add.onsuccess = () => { |
| | | // resolve({id: 'funcs', version: '1.0', createDate: '1970-01-01 14:59:09.000'}) |
| | | // } |
| | | // } |
| | | // } |
| | | // }) |
| | | // } |
| | | |
| | | getSmStemp = () => { |
| | | if (!sessionStorage.getItem('msgTemplate')) { |
| | |
| | | inner join (select openid from sapp where id='${window.GLOB.appkey}') b |
| | | on a.openid=b.openid` |
| | | |
| | | _sql = Utils.formatOptions(_sql) |
| | | _sql = Utils.formatOptions(_sql, 'x') |
| | | |
| | | let param = { |
| | | func: 'sPC_Get_SelectedList', |
| | | LText: _sql, |
| | | obj_name: 'data', |
| | | arr_field: 'ID,TemplateCode,SignName' |
| | | arr_field: 'ID,TemplateCode,SignName', |
| | | exec_type: 'x' |
| | | } |
| | | |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) // 云端数据验证 |
| | | |
| | | Api.getCloudConfig(param).then(res => { |
| | |
| | | window.addEventListener('storage', (e) => { |
| | | if (e.key === 'menuUpdate') { |
| | | this.reload() |
| | | } else if (e.key === 'wxTemplates') { |
| | | if (e.newValue) { |
| | | sessionStorage.setItem('wxTemplates', e.newValue) |
| | | } |
| | | } |
| | | }) |
| | | MKEmitter.addListener('mkUpdateMenuList', this.reload) |
| | |
| | | }, 100) |
| | | |
| | | setTimeout(() => { |
| | | this.setSystemFuncs() |
| | | // this.setSystemFuncs() |
| | | this.getSmStemp() |
| | | }, 500) |
| | | } |
| | |
| | | |
| | | render () { |
| | | const { mainMenu, editLevel } = this.props |
| | | const { menulist, memberLevel, visible, loading } = this.state |
| | | const { menulist, visible, loading, logo } = this.state |
| | | |
| | | return ( |
| | | <header className={'sys-header-container ant-menu-dark ' + (['level2', 'level3'].includes(editLevel) ? 'mask' : '')} id="main-header-container"> |
| | | <div className="header-logo"><img src={MainLogo} alt=""/></div> |
| | | <div className="header-logo"><img src={logo} alt=""/></div> |
| | | <div className="header-collapse"> |
| | | <MenuFoldOutlined/> |
| | | </div> |
| | |
| | | <div className="icon"><HomeOutlined /></div> |
| | | <div className="title">首页</div> |
| | | <div className="detail">基于自定义页面的首页设计,可实现灵活的元素配置及样式调整,展现当前系统的风格。</div> |
| | | <Button type="primary" disabled={!(memberLevel >= 20)} title={memberLevel >= 20 ? '' : '会员等级不够,无开发权限。'} onClick={() => {window.open('#/menudesign/JTdCJTIyTWVudVR5cGUlMjIlM0ElMjJob21lJTIyJTJDJTIyTWVudUlkJTIyJTNBJTIyaG9tZV9wYWdlX2lkJTIyJTJDJTIyTWVudU5hbWUlMjIlM0ElMjIlRTklQTYlOTYlRTklQTElQjUlMjIlN0Q=')}}> |
| | | <Button type="primary" disabled={window.GLOB.memberLevel < 20} title={window.GLOB.memberLevel < 20 ? '会员等级不够,无开发权限。' : ''} onClick={() => {window.open('#/menudesign/JTdCJTIyTWVudVR5cGUlMjIlM0ElMjJob21lJTIyJTJDJTIyTWVudUlkJTIyJTNBJTIyaG9tZV9wYWdlX2lkJTIyJTJDJTIyTWVudU5hbWUlMjIlM0ElMjIlRTklQTYlOTYlRTklQTElQjUlMjIlN0Q=')}}> |
| | | 编辑 |
| | | </Button> |
| | | </div> : null |
| | |
| | | <div className="icon"><ApiOutlined /></div> |
| | | <div className="title">接口调试</div> |
| | | <div className="detail">可自动处理登录接口的参数加密,以及业务接口的签名计算,方便开发人员的接口测试工作。</div> |
| | | <Button type="primary" disabled={!(memberLevel >= 20)} title={memberLevel >= 20 ? '' : '会员等级不够,无开发权限。'} onClick={() => {window.open('#/interface')}}> |
| | | <Button type="primary" disabled={window.GLOB.memberLevel < 20} title={window.GLOB.memberLevel < 20 ? '会员等级不够,无开发权限。' : ''} onClick={() => {window.open('#/interface')}}> |
| | | 编辑 |
| | | </Button> |
| | | </div> |
| | |
| | | <div className="title">应用管理</div> |
| | | <div className="detail">可创建及管理PC、pad及移动端等不同设备的应用,实现明科云APP、微信公众号、小程序等多平台的应用共享。</div> |
| | | {window.GLOB.systemType !== 'production' ? |
| | | <Button type="primary" disabled={!(memberLevel >= 20)} title={memberLevel >= 20 ? '' : '会员等级不够,无开发权限。'} onClick={() => {window.open('#/appmanage')}}> |
| | | <Button type="primary" disabled={window.GLOB.memberLevel < 20} title={window.GLOB.memberLevel < 20 ? '会员等级不够,无开发权限。' : ''} onClick={() => {window.open('#/appmanage')}}> |
| | | 编辑 |
| | | </Button> : |
| | | <Button type="primary" disabled={!(memberLevel >= 20)} title={memberLevel >= 20 ? '' : '会员等级不够,无开发权限。'} onClick={() => {window.open('#/appcheck')}}> |
| | | <Button type="primary" disabled={window.GLOB.memberLevel < 20} title={window.GLOB.memberLevel < 20 ? '会员等级不够,无开发权限。' : ''} onClick={() => {window.open('#/appcheck')}}> |
| | | 查看 |
| | | </Button> |
| | | } |
| | |
| | | <Button type="primary" onClick={() => {window.open('#/proc')}}> |
| | | 编辑 |
| | | </Button> |
| | | </div> : null} |
| | | {window.GLOB.systemType !== 'production' && sessionStorage.getItem('lang') !== 'zh-CN' ? <div className="entrance"> |
| | | <div className="icon"><PlusOutlined /></div> |
| | | <div className="title">菜单转换</div> |
| | | <div className="detail">可选择母语系统的菜单,快速转换到当前语言。打印模板请在HS下复制后,在此处选择指定模板进行语言转换。</div> |
| | | <TransMenu reload={this.reload} menulist={menulist}/> |
| | | </div> : null} |
| | | </div> |
| | | {/* 编辑菜单 */} |
| | |
| | | } |
| | | } |
| | | |
| | | const mapStateToProps = (state) => { |
| | | return { |
| | | menuTree: state.menuTree, |
| | | mainMenu: state.mainMenu, |
| | | editLevel: state.editLevel |
| | | } |
| | | } |
| | | |
| | | const mapDispatchToProps = (dispatch) => { |
| | | return { |
| | | modifyMenuTree: (menuTree) => dispatch(modifyMenuTree(menuTree)), |
| | | modifyMainMenu: (mainMenu) => dispatch(modifyMainMenu(mainMenu)), |
| | | resetEditLevel: (level) => dispatch(resetEditLevel(level)), |
| | | logout: () => dispatch(logout()) |
| | | } |
| | | } |
| | | |
| | | export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Header)) |
| | | export default withRouter(Header) |