| | |
| | | |
| | | const setCurrentUrl = (res) => { |
| | | if (!!(window.history && window.history.pushState)) { |
| | | if (window.location.href.indexOf('paramsmain') > -1) { |
| | | let _href = window.location.href.split('#') |
| | | localStorage.setItem(_href[0] + 'paramsmain', _href[1]) |
| | | } |
| | | |
| | | sessionStorage.clear() |
| | | sessionStorage.setItem('loginError', JSON.stringify({url: res.config ? res.config.url : '', request: res.config ? res.config.data : '', response: JSON.stringify(res.data)})) |
| | | window.history.replaceState(null, null, window.location.href.split('#')[0] + '#/login') |
| | |
| | | let ThirdMenuId = sessionStorage.getItem('ThirdMenu') |
| | | _menu = thdMenuList.filter(item => item.MenuID === ThirdMenuId)[0] // 通过url中menuid筛选出选中的主菜单 |
| | | |
| | | if (_menu) { |
| | | mainMenu = menulist.filter(item => item.MenuID === _menu.FstId)[0] |
| | | mainMenu = fromJS(mainMenu).toJS() |
| | | mainMenu.openId = _menu.ParentId |
| | | } |
| | | |
| | | sessionStorage.removeItem('ThirdMenu') |
| | | } |
| | | |
| | |
| | | |
| | | getMenulist = (result) => { |
| | | let thdMenuList = [] |
| | | let iframes = ['Main/Index', 'bda/rdt', 'Home/rdt'] |
| | | let menulist = [] |
| | | result.fst_menu && result.fst_menu.forEach(fst => { |
| | | let fstItem = { |
| | |
| | | } |
| | | if (fst.PageParam) { |
| | | try { |
| | | fstItem.PageParam = JSON.parse(fst.PageParam) |
| | | } catch (e) { |
| | | fstItem.PageParam = null |
| | | } |
| | | if (fstItem.PageParam && fstItem.PageParam.OpenType === 'outpage' && fstItem.PageParam.linkUrl) { |
| | | let PageParam = JSON.parse(fst.PageParam) |
| | | |
| | | if (PageParam.OpenType === 'outpage' && PageParam.linkUrl) { |
| | | fstItem.OpenType = 'outpage' |
| | | fstItem.linkUrl = fstItem.PageParam.linkUrl |
| | | fstItem.linkUrl = PageParam.linkUrl |
| | | } |
| | | } catch (e) {} |
| | | } |
| | | |
| | | if (fst.snd_menu) { |
| | |
| | | ParentId: fst.MenuID, |
| | | MenuID: snd.MenuID, |
| | | MenuName: snd.MenuName, |
| | | PageParam: {Icon: 'folder'}, |
| | | Icon: 'folder', |
| | | children: [] |
| | | } |
| | | |
| | | if (snd.PageParam) { |
| | | try { |
| | | sndItem.PageParam = JSON.parse(snd.PageParam) |
| | | } catch (e) { |
| | | sndItem.PageParam = {Icon: 'folder'} |
| | | } |
| | | } |
| | | let PageParam = JSON.parse(snd.PageParam) |
| | | |
| | | let msg = { |
| | | UserID: sessionStorage.getItem('UserID'), |
| | | LoginUID: sessionStorage.getItem('LoginUID'), |
| | | User_Name: sessionStorage.getItem('User_Name'), |
| | | Full_Name: sessionStorage.getItem('Full_Name'), |
| | | Member_Level: sessionStorage.getItem('Member_Level'), |
| | | dataM: sessionStorage.getItem('dataM'), |
| | | avatar: sessionStorage.getItem('avatar'), |
| | | debug: sessionStorage.getItem('debug'), |
| | | role_id: sessionStorage.getItem('role_id'), |
| | | mainlogo: window.GLOB.mainlogo, |
| | | navBar: window.GLOB.navBar || '', |
| | | mstyle: window.GLOB.style |
| | | sndItem.Icon = PageParam.Icon || 'folder' |
| | | } catch (e) {} |
| | | } |
| | | |
| | | if (snd.trd_menu) { |
| | |
| | | hidden: 'false' |
| | | } |
| | | |
| | | if (trd.LinkUrl && iframes.includes(trd.LinkUrl.split('?')[0])) { |
| | | trdItem.type = 'iframe' |
| | | trdItem.LinkUrl = trd.LinkUrl.replace('&', '&') |
| | | } else { |
| | | if (trd.PageParam) { |
| | | try { |
| | | trdItem.PageParam = trd.PageParam ? JSON.parse(trd.PageParam) : {OpenType: 'newtab'} |
| | | } catch (e) { |
| | | trdItem.PageParam = {OpenType: 'newtab'} |
| | | } |
| | | let PageParam = JSON.parse(trd.PageParam) |
| | | |
| | | trdItem.type = trdItem.PageParam.Template || trdItem.type |
| | | trdItem.OpenType = trdItem.PageParam.OpenType || trdItem.OpenType |
| | | trdItem.hidden = trdItem.PageParam.hidden || trdItem.hidden |
| | | trdItem.type = PageParam.Template || trdItem.type |
| | | trdItem.OpenType = PageParam.OpenType || trdItem.OpenType |
| | | trdItem.hidden = PageParam.hidden || trdItem.hidden |
| | | |
| | | if (trdItem.type === 'NewPage') { |
| | | trdItem.src = trdItem.PageParam.url || '' |
| | | |
| | | if (trdItem.src.indexOf('paramsmain/') > -1) { |
| | | try { |
| | | let _url = trdItem.src.split('paramsmain/')[0] + 'paramsmain/' |
| | | let _param = JSON.parse(window.decodeURIComponent(window.atob(trdItem.src.split('paramsmain/')[1]))) |
| | | _param.UserID = sessionStorage.getItem('UserID') |
| | | _param.LoginUID = sessionStorage.getItem('LoginUID') |
| | | _param.User_Name = sessionStorage.getItem('User_Name') |
| | | _param.Full_Name = sessionStorage.getItem('Full_Name') |
| | | |
| | | trdItem.src = _url + window.btoa(window.encodeURIComponent(JSON.stringify(_param))) |
| | | } catch (e) { |
| | | console.warn('菜单参数解析错误!') |
| | | trdItem.src = PageParam.url || '' |
| | | } |
| | | } catch (e) {} |
| | | } |
| | | } else { |
| | | |
| | | // 打开新页面链接 |
| | | trdItem.src = '#/paramsmain/' + window.btoa(window.encodeURIComponent(JSON.stringify({ |
| | | ...msg, |
| | | ThirdMenu: trd.MenuID |
| | | }))) |
| | | } |
| | | } |
| | | trdItem.src = '#/mainparams/' + trd.MenuID |
| | | |
| | | thdMenuList.push(trdItem) |
| | | |
| | |
| | | localStorage.setItem(_url, window.btoa(window.encodeURIComponent(JSON.stringify({time: new Date().getTime(), username: param.username, password: param.password})))) |
| | | } |
| | | |
| | | this.setSystemFuncs() |
| | | this.props.modifyMainMenu(null) |
| | | this.props.history.replace('/design') |
| | | } else { |
| | |
| | | }) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | setSystemFuncs = () => { |
| | | if (!window.GLOB.WebSql && !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 timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | |
| | | let sys_datetime = sessionStorage.getItem('sys_datetime') |
| | | let app_datetime = sessionStorage.getItem('app_datetime') |
| | | if (sys_datetime && app_datetime) { |
| | | let seconds = Math.floor((new Date().getTime() - app_datetime) / 1000) |
| | | timestamp = moment(sys_datetime, 'YYYY-MM-DD HH:mm:ss').add(seconds, 'seconds').format('YYYY-MM-DD HH:mm:ss') |
| | | } |
| | | |
| | | if (window.GLOB.WebSql) { |
| | | window.GLOB.WebSql.transaction(tx => { |
| | | tx.executeSql('DELETE FROM FUNCS') |
| | | |
| | | funcs.forEach(item => { |
| | | if (!item.key_sql) return |
| | | tx.executeSql('INSERT INTO FUNCS (func_code, key_sql) VALUES (?, ?)', [item.func_code, item.key_sql]) |
| | | }) |
| | | tx.executeSql(`UPDATE VERSIONS SET createDate='${timestamp}' where CDefine1='funcs'`) |
| | | }) |
| | | } else { |
| | | let objectStore = window.GLOB.IndexDB.transaction(['funcs'], 'readwrite').objectStore('funcs') |
| | | |
| | | objectStore.clear() |
| | | |
| | | 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}) |
| | | } |
| | | } |
| | | |
| | | getfuncTime = () => { |
| | | return new Promise((resolve, reject) => { |
| | | if (window.GLOB.WebSql) { |
| | | window.GLOB.WebSql.transaction(tx => { |
| | | tx.executeSql("SELECT * FROM VERSIONS where CDefine1='funcs'", [], (tx, results) => { |
| | | let rows = results.rows |
| | | if (rows.length === 0) { |
| | | tx.executeSql('DELETE FROM FUNCS') |
| | | tx.executeSql('INSERT INTO VERSIONS (version, createDate, CDefine1) VALUES (?, ?, ?)', ['1.0', '1970-01-01 14:59:09.000', 'funcs']) |
| | | resolve({createDate: '1970-01-01 14:59:09.000'}) |
| | | } else { |
| | | resolve(rows[0]) |
| | | } |
| | | }, (tx, results) => { |
| | | reject() |
| | | console.warn(results) |
| | | }) |
| | | }) |
| | | } else { |
| | | let objectStore = window.GLOB.IndexDB.transaction(['version'], 'readwrite').objectStore('version') |
| | | let request = objectStore.get('funcs') |
| | | |
| | | 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'}) |
| | | |
| | | add.onerror = () => { |
| | | reject() |
| | | } |
| | | add.onsuccess = () => { |
| | | resolve({id: 'funcs', version: '1.0', createDate: '1970-01-01 14:59:09.000'}) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | |
| | |
| | | // search_type: '' |
| | | // }).then(res => { |
| | | // }) |
| | | |
| | | // sessionStorage 跨页面共享 |
| | | window.addEventListener('storage', (e) => { |
| | | if (e.key === 'getSessionStorage' && e.newValue) { |
| | | localStorage.setItem('sessionStorage', JSON.stringify(sessionStorage)) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | key={item.MenuID} |
| | | title={ |
| | | <span> |
| | | <MkIcon type={item.PageParam.Icon} /> |
| | | <MkIcon type={item.Icon} /> |
| | | <span>{item.MenuName}</span> |
| | | </span> |
| | | } |
| | |
| | | <div style={{display: 'inline-block'}}> |
| | | <Button className="mk-border-purple" onClick={this.trigger}><PictureOutlined /> 资源管理</Button> |
| | | <Modal |
| | | title="粘贴" |
| | | title="资源管理" |
| | | wrapClassName="picture-control-model" |
| | | visible={visible} |
| | | width={1200} |
| | |
| | | .ant-modal-body { |
| | | max-height: calc(100vh - 120px); |
| | | min-height: 510px; |
| | | padding-top: 5px; |
| | | padding: 10px 5px 24px; |
| | | } |
| | | } |
| | | .ant-tabs-tabpane { |
| | |
| | | import {HashRouter, Switch, Route, Redirect} from 'react-router-dom' |
| | | import md5 from 'md5' |
| | | import moment from 'moment' |
| | | import { styles } from '@/store/options.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import asyncLoadComponent from '@/utils/asyncLoadComponent' |
| | | |
| | | const Pay = asyncLoadComponent(() => import('@/views/pay')) |
| | | const Sso = asyncLoadComponent(() => import('@/views/sso')) |
| | | const Main = asyncLoadComponent(() => import('@/views/main')) |
| | | const Design = asyncLoadComponent(() => import('@/views/design')) |
| | | const Login = asyncLoadComponent(() => import('@/views/login')) |
| | | const Main = asyncLoadComponent(() => import('@/views/main')) |
| | | const Sso = asyncLoadComponent(() => import('@/views/sso')) |
| | | const Pay = asyncLoadComponent(() => import('@/views/pay')) |
| | | const MainParams = asyncLoadComponent(() => import('@/views/mainparams')) |
| | | const Design = asyncLoadComponent(() => import('@/views/design')) |
| | | const NotFound = asyncComponent(() => import('@/views/404')) |
| | | const AppManage = asyncLoadComponent(() => import('@/views/appmanage')) |
| | | const AppCheck = asyncLoadComponent(() => import('@/views/appcheck')) |
| | |
| | | |
| | | const routers = [ |
| | | {path: '/login', name: 'login', component: Login, auth: false}, |
| | | {path: '/main', name: 'main', component: Main, auth: true}, |
| | | {path: '/pay/:param', name: 'pay', component: Pay, auth: false}, |
| | | {path: '/print/:param', name: 'print', component: PrintT, auth: false}, |
| | | {path: '/ssologin/:param', name: 'ssologin', component: Sso, auth: false}, |
| | | {path: '/main', name: 'main', component: Main, auth: true}, |
| | | {path: '/design', name: 'design', component: Design, auth: true}, |
| | | {path: '/appmanage', name: 'appmanage', component: AppManage, auth: true}, |
| | | {path: '/appcheck', name: 'appcheck', component: AppCheck, auth: true}, |
| | |
| | | {path: '/billprint/:param', name: 'billprint', component: BillPrint, auth: true}, |
| | | {path: '/docprint/:menuId', name: 'docprint', component: BillPrint, auth: false}, |
| | | {path: '/docprint/:menuId/:id', name: 'docprint', component: BillPrint, auth: false}, |
| | | {path: '/paramsmain/:param', name: 'pmain', component: Main, auth: true}, |
| | | {path: '/mainparams/:menuId', name: 'mainparams', component: MainParams, auth: false}, |
| | | {path: '/role/:param', name: 'role', component: RoleManage, auth: true}, |
| | | {path: '/hs', name: 'hs', component: SystemFunc, auth: true}, |
| | | {path: '/interface', name: 'interface', component: Interface, auth: true} |
| | |
| | | return (<item.component {...props}/>) |
| | | } |
| | | |
| | | if (item.name === 'pmain') { // 新窗口打开,取url参数放入sessionStorage |
| | | try { |
| | | let _param = JSON.parse(window.decodeURIComponent(window.atob(props.match.params.param))) |
| | | |
| | | if (typeof(_param) === 'object') { |
| | | _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.dataM && sessionStorage.setItem('localDataM', _param.dataM) |
| | | _param.avatar && sessionStorage.setItem('avatar', _param.avatar) |
| | | _param.role_id && sessionStorage.setItem('role_id', _param.role_id) |
| | | _param.dataM && sessionStorage.setItem('localRole_id', _param.dataM) |
| | | _param.Member_Level && sessionStorage.setItem('Member_Level', _param.Member_Level) |
| | | _param.ThirdMenu && sessionStorage.setItem('ThirdMenu', _param.ThirdMenu) |
| | | |
| | | window.GLOB.mainlogo = _param.mainlogo || '' |
| | | window.GLOB.navBar = _param.navBar || '' |
| | | |
| | | if (_param.mstyle && styles[_param.mstyle]) { |
| | | document.body.className = styles[_param.mstyle] |
| | | } |
| | | } |
| | | } catch (e) { |
| | | console.warn('菜单参数解析错误!') |
| | | } |
| | | |
| | | return (<item.component {...props}/>) |
| | | } |
| | | |
| | | let userId = sessionStorage.getItem('UserID') // 判断是否存在userid |
| | | |
| | | let authCode = localStorage.getItem(window.location.href.split('#')[0] + 'AuthCode') // 判断系统是否在授权期限内 |
| | | let _s = md5('mksoft' + moment().format('YYYYMMDD')) |
| | | let isauth = authCode && authCode.includes(_s) |
| | |
| | | isauth = true |
| | | } |
| | | |
| | | if (userId && isauth) { |
| | | if (isauth) { |
| | | return (<item.component {...props}/>) |
| | | } else { |
| | | // return (<Redirect to={{ pathname: '/login', state: {from: props.location}}}/>) |
| | | return (<Redirect to={{ pathname: '/login'}}/>) |
| | | } |
| | | } |
| | |
| | | } else if (item.linkurl) { |
| | | let src = item.linkurl |
| | | |
| | | if (src.indexOf('paramsmain/') > -1) { |
| | | try { |
| | | let _url = item.linkurl.split('paramsmain/')[0] + 'paramsmain/' |
| | | let _param = JSON.parse(window.decodeURIComponent(window.atob(item.linkurl.split('paramsmain/')[1]))) |
| | | _param.UserID = sessionStorage.getItem('UserID') |
| | | _param.LoginUID = sessionStorage.getItem('LoginUID') |
| | | _param.User_Name = sessionStorage.getItem('User_Name') |
| | | _param.param = __param |
| | | src = _url + window.btoa(window.encodeURIComponent(JSON.stringify(_param))) |
| | | } catch (e) { |
| | | console.warn('菜单参数解析错误!') |
| | | } |
| | | } else { |
| | | let con = '?' |
| | | |
| | | if (/\?/ig.test(src)) { |
| | |
| | | } |
| | | |
| | | src = src + `${con}id=${record.$$uuid}&appkey=${window.GLOB.appkey}&userid=${sessionStorage.getItem('UserID')}&LoginUID=${sessionStorage.getItem('LoginUID') || ''}` |
| | | } |
| | | |
| | | window.open(src) |
| | | } |
| | |
| | | } else if (item.linkurl) { |
| | | let src = item.linkurl |
| | | |
| | | if (src.indexOf('paramsmain/') > -1) { |
| | | try { |
| | | let _url = item.linkurl.split('paramsmain/')[0] + 'paramsmain/' |
| | | let _param = JSON.parse(window.decodeURIComponent(window.atob(item.linkurl.split('paramsmain/')[1]))) |
| | | _param.UserID = sessionStorage.getItem('UserID') |
| | | _param.LoginUID = sessionStorage.getItem('LoginUID') |
| | | _param.User_Name = sessionStorage.getItem('User_Name') |
| | | _param.param = __param |
| | | src = _url + window.btoa(window.encodeURIComponent(JSON.stringify(_param))) |
| | | } catch (e) { |
| | | console.warn('菜单参数解析错误!') |
| | | } |
| | | } else { |
| | | let con = '?' |
| | | |
| | | if (/\?/ig.test(src)) { |
| | |
| | | } |
| | | |
| | | src = src + `${con}id=${record.$$uuid}&appkey=${window.GLOB.appkey}&userid=${sessionStorage.getItem('UserID')}&LoginUID=${sessionStorage.getItem('LoginUID') || ''}` |
| | | } |
| | | |
| | | window.open(src) |
| | | } |
| | |
| | | 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 } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import { |
| | |
| | | |
| | | async loadmenu () { |
| | | // 获取主菜单 |
| | | let _param = {func: 's_get_pc_menus', systemType: options.sysType, debug: 'Y'} |
| | | _param.pro_sys = window.GLOB.systemType === 'production' ? 'Y' : '' |
| | | let _param = { |
| | | func: 's_get_pc_menus', |
| | | systemType: options.sysType, |
| | | pro_sys: window.GLOB.systemType === 'production' ? 'Y' : '', |
| | | debug: 'Y' |
| | | } |
| | | |
| | | let result = await Api.getSystemConfig(_param) |
| | | |
| | |
| | | } |
| | | |
| | | getMenulist = (result) => { |
| | | let iframes = ['Main/Index', 'bda/rdt', 'Home/rdt'] |
| | | let menulist = [] |
| | | let thdMenuList = [] |
| | | result.fst_menu && result.fst_menu.forEach(fst => { |
| | |
| | | level: 'third' |
| | | } |
| | | |
| | | if (trd.LinkUrl && iframes.includes(trd.LinkUrl.split('?')[0])) { |
| | | trdItem.type = 'iframe' |
| | | trdItem.LinkUrl = trd.LinkUrl.replace('&', '&') |
| | | trdItem.forbidden = true |
| | | } else { |
| | | try { |
| | | trdItem.PageParam = trd.PageParam ? JSON.parse(trd.PageParam) : {OpenType: 'newtab'} |
| | | |
| | | trdItem.type = trdItem.PageParam.Template || trdItem.type |
| | | trdItem.OpenType = trdItem.PageParam.OpenType |
| | | } catch (e) { |
| | | trdItem.PageParam = {OpenType: 'newtab'} |
| | | } |
| | | |
| | | trdItem.type = trdItem.PageParam.Template || trdItem.type |
| | | trdItem.OpenType = trdItem.PageParam.OpenType || trdItem.OpenType |
| | | |
| | | if (trdItem.type === 'CustomPage' && this.state.memberLevel < 20) { // 会员等级大于等于20时,有编辑权限 |
| | | trdItem.forbidden = true |
| | | } |
| | | } |
| | | |
| | | thdMenuList.push(trdItem) |
| | |
| | | this.props.modifyMainMenu(this.state.menulist[0] || null) |
| | | } |
| | | |
| | | |
| | | addMemuSubmit = () => { |
| | | // 新建菜单:提交 |
| | | this.addMenuFormRef.handleConfirm().then(param => { |
| | |
| | | }, () => {}) |
| | | } |
| | | |
| | | setSystemFuncs = () => { |
| | | if (!window.GLOB.WebSql && !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 timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | |
| | | let sys_datetime = sessionStorage.getItem('sys_datetime') |
| | | let app_datetime = sessionStorage.getItem('app_datetime') |
| | | if (sys_datetime && app_datetime) { |
| | | let seconds = Math.floor((new Date().getTime() - app_datetime) / 1000) |
| | | timestamp = moment(sys_datetime, 'YYYY-MM-DD HH:mm:ss').add(seconds, 'seconds').format('YYYY-MM-DD HH:mm:ss') |
| | | } |
| | | |
| | | if (window.GLOB.WebSql) { |
| | | window.GLOB.WebSql.transaction(tx => { |
| | | tx.executeSql('DELETE FROM FUNCS') |
| | | |
| | | funcs.forEach(item => { |
| | | if (!item.key_sql) return |
| | | tx.executeSql('INSERT INTO FUNCS (func_code, key_sql) VALUES (?, ?)', [item.func_code, item.key_sql]) |
| | | }) |
| | | tx.executeSql(`UPDATE VERSIONS SET createDate='${timestamp}' where CDefine1='funcs'`) |
| | | }) |
| | | } else { |
| | | let objectStore = window.GLOB.IndexDB.transaction(['funcs'], 'readwrite').objectStore('funcs') |
| | | |
| | | objectStore.clear() |
| | | |
| | | 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}) |
| | | } |
| | | } |
| | | |
| | | getfuncTime = () => { |
| | | return new Promise((resolve, reject) => { |
| | | if (window.GLOB.WebSql) { |
| | | window.GLOB.WebSql.transaction(tx => { |
| | | tx.executeSql("SELECT * FROM VERSIONS where CDefine1='funcs'", [], (tx, results) => { |
| | | let rows = results.rows |
| | | if (rows.length === 0) { |
| | | tx.executeSql('DELETE FROM FUNCS') |
| | | tx.executeSql('INSERT INTO VERSIONS (version, createDate, CDefine1) VALUES (?, ?, ?)', ['1.0', '1970-01-01 14:59:09.000', 'funcs']) |
| | | resolve({createDate: '1970-01-01 14:59:09.000'}) |
| | | } else { |
| | | resolve(rows[0]) |
| | | } |
| | | }, (tx, results) => { |
| | | reject() |
| | | console.warn(results) |
| | | }) |
| | | }) |
| | | } else { |
| | | let objectStore = window.GLOB.IndexDB.transaction(['version'], 'readwrite').objectStore('version') |
| | | let request = objectStore.get('funcs') |
| | | |
| | | 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'}) |
| | | |
| | | add.onerror = () => { |
| | | reject() |
| | | } |
| | | add.onsuccess = () => { |
| | | resolve({id: 'funcs', version: '1.0', createDate: '1970-01-01 14:59:09.000'}) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | sessionStorage.setItem('isEditState', 'true') |
| | | document.body.className = '' |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | 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) |
| | | |
| | | if (window.GLOB.systemType !== 'production') { |
| | | setTimeout(() => { |
| | | Api.getSystemConfig({func: 'sPC_Get_Roles_sModular'}).then(res => { |
| | |
| | | sessionStorage.setItem('permFuncField', JSON.stringify(_permFuncField)) |
| | | } |
| | | }) |
| | | }, 50) |
| | | } |
| | | }, 100) |
| | | |
| | | window.addEventListener('storage', (e) => { |
| | | if (e.key === 'menuUpdate') { |
| | | this.reload() |
| | | } else if (e.key === 'wxTemplates') { |
| | | if (e.newValue) { |
| | | sessionStorage.setItem('wxTemplates', e.newValue) |
| | | setTimeout(() => { |
| | | this.setSystemFuncs() |
| | | }, 200) |
| | | } |
| | | } |
| | | }) |
| | | MKEmitter.addListener('mkUpdateMenuList', this.reload) |
| | | } |
| | | |
| | | /** |
| | |
| | | const iszhCN = sessionStorage.getItem('lang') !== 'en-US' |
| | | |
| | | const _href = window.location.href.split('#')[0] |
| | | if (localStorage.getItem(_href + 'paramsmain')) { |
| | | sessionStorage.setItem('history', localStorage.getItem(_href + 'paramsmain')) |
| | | localStorage.removeItem(_href + 'paramsmain') |
| | | } |
| | | |
| | | class Login extends Component { |
| | | state = { |
New file |
| | |
| | | import React, {Component} from 'react' |
| | | import { Spin } from 'antd' |
| | | |
| | | import './index.scss' |
| | | |
| | | class MainParams extends Component { |
| | | UNSAFE_componentWillMount() { |
| | | sessionStorage.setItem('ThirdMenu', this.props.match.params.menuId) |
| | | } |
| | | |
| | | componentDidMount() { |
| | | if (sessionStorage.getItem('UserID')) { |
| | | this.props.history.replace('/main') |
| | | } else { |
| | | localStorage.setItem('getSessionStorage', Date.now()) |
| | | |
| | | window.addEventListener('storage', function(event) { |
| | | if (event.key === 'sessionStorage' && event.newValue && !sessionStorage.getItem('UserID')) { |
| | | let values = event.newValue |
| | | values = JSON.parse(values) |
| | | |
| | | Object.keys(values).forEach(key => { |
| | | sessionStorage.setItem(key, values[key]) |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | setTimeout(() => { |
| | | localStorage.removeItem('getSessionStorage') |
| | | localStorage.removeItem('sessionStorage') |
| | | |
| | | if (sessionStorage.getItem('UserID')) { |
| | | this.props.history.replace('/main') |
| | | } else { |
| | | this.props.history.replace('/login') |
| | | } |
| | | }, 20) |
| | | } |
| | | } |
| | | |
| | | render () { |
| | | return ( |
| | | <div className="main-params-login"> |
| | | <Spin size="large" /> |
| | | </div> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | export default MainParams |
New file |
| | |
| | | .main-params-login { |
| | | .ant-spin { |
| | | position: absolute; |
| | | left: calc(50vw - 22px); |
| | | top: 45vh; |
| | | } |
| | | } |
| | |
| | | |
| | | return ( |
| | | <ConfigProvider locale={_locale}> |
| | | <div className={'pc-menu-view ' + (MenuType || '')} id="mk-menu-design-view"> |
| | | <div className={'pc-menu-view ' + (MenuType || '')}> |
| | | <Header /> |
| | | <DndProvider backend={HTML5Backend}> |
| | | <div className="menu-body"> |
| | |
| | | body { |
| | | overflow-x: hidden; |
| | | overflow-y: hidden; |
| | | } |
| | | .pc-menu-view { |
| | | background: #000; |
| | |
| | | background: transparent!important; |
| | | border-radius: 0!important; |
| | | } |
| | | } |
| | | body { |
| | | overflow-y: hidden; |
| | | } |
| | |
| | | import React, {Component} from 'react' |
| | | import { notification, Spin, ConfigProvider } from 'antd' |
| | | import enUS from 'antd/es/locale/en_US' |
| | | import zhCN from 'antd/es/locale/zh_CN' |
| | | import { DndProvider } from 'react-dnd' |
| | | import { withRouter } from 'react-router' |
| | | import { is, fromJS } from 'immutable' |
| | | import moment from 'moment' |
| | | import HTML5Backend from 'react-dnd-html5-backend' |
| | | import { ConfigProvider, notification, Modal, Collapse, Card, Switch, Button, Typography } from 'antd' |
| | | import { DoubleLeftOutlined, DoubleRightOutlined } from '@ant-design/icons' |
| | | |
| | | import Api from '@/api' |
| | | import Utils, { setGLOBFuncs } from '@/utils/utils.js' |
| | | import antdZhCN from 'antd/es/locale/zh_CN' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import asyncLoadComponent from '@/utils/asyncLoadComponent' |
| | | |
| | | import './index.scss' |
| | | |
| | | const _locale = sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS |
| | | const Header = asyncComponent(() => import('@/menu/header')) |
| | | const ComTableConfig = asyncLoadComponent(() => import('@/templates/comtableconfig')) |
| | | const ModalConfig = asyncLoadComponent(() => import('@/templates/modalconfig')) |
| | | const { Panel } = Collapse |
| | | const { confirm } = Modal |
| | | const { Paragraph } = Typography |
| | | const _locale = antdZhCN |
| | | |
| | | document.body.className = '' |
| | | const MenuForm = asyncComponent(() => import('./menuform')) |
| | | const Header = asyncComponent(() => import('@/menu/header')) |
| | | const MenuShell = asyncComponent(() => import('@/menu/menushell')) |
| | | const BgController = asyncComponent(() => import('@/pc/bgcontroller')) |
| | | const StyleController = asyncComponent(() => import('@/menu/stylecontroller')) |
| | | const ReplaceField = asyncComponent(() => import('@/menu/replaceField')) |
| | | const Versions = asyncComponent(() => import('@/menu/versions')) |
| | | const SysInterface = asyncComponent(() => import('@/menu/sysinterface')) |
| | | const UrlFieldComponent = asyncComponent(() => import('@/menu/urlfieldcomponent')) |
| | | const PictureController = asyncComponent(() => import('@/menu/picturecontroller')) |
| | | const ModalController = asyncComponent(() => import('@/menu/modalconfig/controller')) |
| | | const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent')) |
| | | |
| | | sessionStorage.setItem('isEditState', 'true') |
| | | sessionStorage.setItem('appType', '') // 应用类型 |
| | | document.body.className = '' |
| | | |
| | | class TableDesign extends Component { |
| | | state = { |
| | | loading: false, // 编辑菜单或使用已使用模板时,获取配置信息 |
| | | btnParam: null, // 编辑按钮的配置信息 |
| | | menulist: null, // 编辑中的菜单 |
| | | tabview: '', // 选择模板窗口(template)、基础表格配置(CommonTable)、表单(Modal)、子表(SubTable) |
| | | editMenu: null, // 编辑菜单 |
| | | editAction: null, // 编辑按钮 |
| | | editTab: null, // 编辑标签 |
| | | tabConfig: null, // 标签配置信息 |
| | | editSubTab: null, // 编辑子标签(标签中的标签) |
| | | subTabConfig: null, // 子标签配置信息 |
| | | subConfig: null, // 子配置信息 |
| | | btnTab: null, // 打开新标签或当前页面刷新的按钮 |
| | | btnTabConfig: null, // 打开新标签按钮配置 |
| | | handleMVisible: false, // 添加或修改菜单模态框(角色权限分配等) |
| | | sysMenu: null, // 添加或编辑菜单(角色权限分配等) |
| | | change: false |
| | | MenuId: '', |
| | | ParentId: '', |
| | | MenuName: '', |
| | | MenuNo: '', |
| | | delButtons: [], |
| | | activeKey: 'basedata', |
| | | menuloading: false, |
| | | oriConfig: null, |
| | | config: null, |
| | | customComponents: [], |
| | | comloading: false, |
| | | settingshow: true, |
| | | modalStatus: false // 弹窗是否开启,判断ctrl+s是否可用 |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | sessionStorage.setItem('editMenuType', 'menu') // 编辑菜单类型 |
| | | |
| | | window.GLOB.UserComponentMap = new Map() // 缓存用户自定义组件 |
| | | window.GLOB.TabsMap = new Map() // 缓存用户操作的标签页 |
| | | window.GLOB.urlFields = [] // url变量 |
| | | window.GLOB.customMenu = null // 保存菜单信息 |
| | | |
| | | try { |
| | | let param = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param))) |
| | | |
| | | this.getMenuParam(param) |
| | | this.setState({ |
| | | MenuId: param.MenuID, |
| | | ParentId: param.ParentId || '', |
| | | MenuName: param.MenuName || '', |
| | | MenuNo: param.MenuNo || '', |
| | | }, () => { |
| | | this.getMenuParam() |
| | | }) |
| | | } catch (e) { |
| | | notification.warning({ |
| | | top: 92, |
| | |
| | | } |
| | | } |
| | | |
| | | getMenuParam = (editMenu) => { |
| | | editMenu.fstMenuId = editMenu.FstId |
| | | editMenu.supMenuList = [] |
| | | editMenu.fstMenuList = [] |
| | | |
| | | let tree = sessionStorage.getItem('menuTree') |
| | | if (tree) { |
| | | tree = JSON.parse(tree) |
| | | editMenu.fstMenuList = tree |
| | | |
| | | tree.forEach(item => { |
| | | if (item.MenuID === editMenu.FstId) { |
| | | editMenu.supMenuList = item.children |
| | | } |
| | | }) |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | let param = { |
| | | func: 'sPC_Get_LongParam', |
| | | MenuID: editMenu.MenuID |
| | | } |
| | | componentDidMount () { |
| | | MKEmitter.addListener('delButtons', this.delButtons) |
| | | MKEmitter.addListener('modalStatus', this.modalStatus) |
| | | MKEmitter.addListener('changePopview', this.initPopview) |
| | | MKEmitter.addListener('triggerMenuSave', this.triggerMenuSave) |
| | | MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle) |
| | | MKEmitter.addListener('updateCustomComponent', this.updateCustomComponent) |
| | | setTimeout(() => { |
| | | if (sessionStorage.getItem('app_custom_components')) { |
| | | let list = sessionStorage.getItem('app_custom_components') |
| | | list = JSON.parse(list) |
| | | |
| | | this.setState({ |
| | | loading: true |
| | | }) |
| | | |
| | | Api.getSystemConfig(param).then(res => { |
| | | if (res.status) { |
| | | editMenu.open_edition = res.open_edition || '' |
| | | editMenu.LongParam = '' |
| | | |
| | | if (res.LongParam) { |
| | | let _LongParam = '' |
| | | try { |
| | | _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam))) |
| | | } catch (e) { |
| | | console.warn('Parse Failure') |
| | | _LongParam = '' |
| | | } |
| | | editMenu.LongParam = _LongParam |
| | | } else if (editMenu.PageParam.copyMenuId) { |
| | | let _param = { |
| | | func: 'sPC_Get_LongParam', |
| | | MenuID: editMenu.PageParam.copyMenuId |
| | | } |
| | | |
| | | Api.getSystemConfig(_param).then(res => { |
| | | if (res.status) { |
| | | if (res.LongParam) { |
| | | let _LongParam = '' |
| | | try { |
| | | _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam))) |
| | | _LongParam.type = 'user' |
| | | } catch (e) { |
| | | console.warn('Parse Failure') |
| | | _LongParam = '' |
| | | } |
| | | editMenu.LongParam = _LongParam |
| | | } |
| | | |
| | | this.setState({ |
| | | editMenu: editMenu, |
| | | loading: false, |
| | | tabview: editMenu.type |
| | | }) |
| | | this.setCustomComponent(list) |
| | | } else { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | this.updateCustomComponent() |
| | | } |
| | | this.getAppPictures() |
| | | this.getPrintTemp() |
| | | this.getRoleFields() |
| | | setGLOBFuncs() |
| | | }, 1000) |
| | | |
| | | document.onkeydown = (event) => { |
| | | let e = event || window.event |
| | | let keyCode = e.keyCode || e.which || e.charCode |
| | | let preKey = '' |
| | | |
| | | if (e.ctrlKey) { |
| | | preKey = 'ctrl' |
| | | } |
| | | if (e.shiftKey) { |
| | | preKey = 'shift' |
| | | } else if (e.altKey) { |
| | | preKey = 'alt' |
| | | } |
| | | |
| | | if (!preKey || !keyCode) return |
| | | |
| | | let _shortcut = `${preKey}+${keyCode}` |
| | | |
| | | if (_shortcut === 'ctrl+83') { |
| | | if (this.state.modalStatus) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | message: '请保存' + this.state.modalStatus, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | return |
| | | return false |
| | | } |
| | | |
| | | this.setState({ |
| | | editMenu: editMenu, |
| | | loading: false, |
| | | tabview: editMenu.type |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | let node = document.getElementById('save-modal-config') |
| | | if (!node) { |
| | | node = document.getElementById('save-config') |
| | | } |
| | | }) |
| | | |
| | | if (node) { |
| | | node.click() |
| | | } |
| | | return false |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('delButtons', this.delButtons) |
| | | MKEmitter.removeListener('modalStatus', this.modalStatus) |
| | | MKEmitter.removeListener('changePopview', this.initPopview) |
| | | MKEmitter.removeListener('triggerMenuSave', this.triggerMenuSave) |
| | | MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle) |
| | | MKEmitter.removeListener('updateCustomComponent', this.updateCustomComponent) |
| | | } |
| | | |
| | | handleView = (param) => { |
| | | this.setState({ |
| | | tabview: '' |
| | | }, () => { |
| | | if (param) { |
| | | this.setState(param) |
| | | modalStatus = (val) => { |
| | | this.setState({modalStatus: val}) |
| | | } |
| | | |
| | | triggerMenuSave = () => { |
| | | this.submitConfig() |
| | | } |
| | | |
| | | getPrintTemp = () => { |
| | | if (!sessionStorage.getItem('printTemps')) { |
| | | let _sql = `select ID,Images,PrintTempNO+PrintTempName as PN from sPrintTemplate |
| | | where appkey= @appkey@ and Deleted=0 and typechartwo='web_print' |
| | | union select ID,Images,a.PrintTempNO+PrintTempName as PN |
| | | from (select * from sPrintTemplate where appkey= '' and Deleted=0 and typechartwo='web_print') a |
| | | left join (select PrintTempNO from sPrintTemplate where appkey= @appkey@ and Deleted=0 ) b |
| | | on a.PrintTempNO=b.PrintTempNO |
| | | left join (select Srcid from sPrintTemplate_Log where appkey='' and apicode= @appkey@ and Deleted=0 ) c |
| | | on a.ID=c.Srcid where b.PrintTempNO is null and c.Srcid is null` |
| | | |
| | | let param = { |
| | | func: 'sPC_Get_SelectedList', |
| | | LText: Utils.formatOptions(_sql), |
| | | obj_name: 'data', |
| | | arr_field: 'PN,ID,Images' |
| | | } |
| | | |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | |
| | | param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) // 云端数据验证 |
| | | |
| | | Api.getSystemConfig(param).then(res => { |
| | | if (res.status) { |
| | | let temps = res.data.map(temp => { |
| | | return { |
| | | value: temp.ID, |
| | | text: temp.PN |
| | | } |
| | | }) |
| | | |
| | | sessionStorage.setItem('printTemps', JSON.stringify(temps)) |
| | | } else { |
| | | window.close() |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | getAppPictures = () => { |
| | | if (sessionStorage.getItem('app_videos') || sessionStorage.getItem('app_pictures')) return |
| | | |
| | | Api.getSystemConfig({ |
| | | func: 's_url_db_adduptdel', |
| | | PageIndex: 0, // 0 代表全部 |
| | | PageSize: 0, // 0 代表全部 |
| | | typecharone: 'image', |
| | | type: 'search' |
| | | }).then(res => { |
| | | if (res.status) { |
| | | sessionStorage.setItem('app_pictures', JSON.stringify(res.data || [])) |
| | | } |
| | | |
| | | Api.getSystemConfig({ |
| | | func: 's_url_db_adduptdel', |
| | | PageIndex: 0, // 0 代表全部 |
| | | PageSize: 0, // 0 代表全部 |
| | | typecharone: 'video', |
| | | type: 'search' |
| | | }).then(res => { |
| | | if (res.status) { |
| | | sessionStorage.setItem('app_videos', JSON.stringify(res.data || [])) |
| | | } |
| | | }) |
| | | Api.getSystemConfig({ |
| | | func: 's_url_db_adduptdel', |
| | | PageIndex: 0, // 0 代表全部 |
| | | PageSize: 0, // 0 代表全部 |
| | | typecharone: 'color', |
| | | type: 'search' |
| | | }).then(res => { |
| | | if (res.status) { |
| | | sessionStorage.setItem('app_colors', JSON.stringify(res.data || [])) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | updateCustomComponent = () => { |
| | | Api.getSystemConfig({ |
| | | func: 's_get_custom_components', |
| | | typename: '', |
| | | typecharone: '' |
| | | }).then(res => { |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | } else if (res.cus_list) { |
| | | sessionStorage.setItem('app_custom_components', JSON.stringify(res.cus_list)) |
| | | this.setCustomComponent(res.cus_list) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | setCustomComponent = (cus_list) => { |
| | | let coms = [] |
| | | |
| | | cus_list.forEach(item => { |
| | | let config = '' |
| | | |
| | | try { |
| | | config = JSON.parse(window.decodeURIComponent(window.atob(item.long_param))) |
| | | } catch (e) { |
| | | console.warn('Parse Failure') |
| | | config = '' |
| | | } |
| | | |
| | | if (!config || !item.c_name) return |
| | | |
| | | window.GLOB.UserComponentMap.set(item.c_id, item.c_name) |
| | | coms.push({ |
| | | uuid: item.c_id, |
| | | type: 'menu', |
| | | title: item.c_name, |
| | | url: item.images, |
| | | component: config.type, |
| | | subtype: config.subtype, |
| | | config |
| | | }) |
| | | }) |
| | | this.setState({customComponents: coms}) |
| | | } |
| | | |
| | | updateComponentStyle = (parentId, keys, style) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.uuid !== parentId) return |
| | | |
| | | let components = config.components.map(item => { |
| | | if (keys.includes(item.uuid)) { |
| | | item.style = {...item.style, ...style} |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | this.setState({ |
| | | config: {...config, components}, |
| | | comloading: true |
| | | }, () => { |
| | | this.setState({ |
| | | comloading: false |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | delButtons = (items) => { |
| | | this.setState({ delButtons: [...this.state.delButtons, ...items] }) |
| | | } |
| | | |
| | | initPopview = (card, btn) => { |
| | | const { oriConfig, config } = this.state |
| | | |
| | | if (!is(fromJS(oriConfig), fromJS(config))) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '配置已修改,请保存!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let _btn = fromJS(btn).toJS() |
| | | _btn.MenuName = config.MenuName + '-' + card.name + '-' + btn.label |
| | | _btn.ParentMenuID = config.uuid |
| | | |
| | | this.props.history.push('/popdesign/' + window.btoa(window.encodeURIComponent((JSON.stringify(_btn))))) |
| | | } |
| | | |
| | | closeView = () => { |
| | | const { oriConfig, config } = this.state |
| | | |
| | | if (!config) { |
| | | window.close() |
| | | return |
| | | } |
| | | |
| | | if (!is(fromJS(oriConfig), fromJS(config))) { |
| | | confirm({ |
| | | title: '配置已修改,放弃保存吗?', |
| | | content: '', |
| | | onOk() { |
| | | window.close() |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | } else { |
| | | window.close() |
| | | } |
| | | } |
| | | |
| | | getMenuParam = () => { |
| | | const { MenuId, ParentId, MenuName, MenuNo } = this.state |
| | | |
| | | let param = { |
| | | func: 'sPC_Get_LongParam', |
| | | MenuID: MenuId |
| | | } |
| | | |
| | | Api.getSystemConfig(param).then(result => { |
| | | if (result.status) { |
| | | let config = null |
| | | |
| | | try { |
| | | config = result.LongParam ? JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) : null |
| | | } catch (e) { |
| | | console.warn('Parse Failure') |
| | | config = null |
| | | } |
| | | |
| | | if (!config) { |
| | | config = { |
| | | version: 1.0, |
| | | uuid: MenuId, |
| | | MenuID: MenuId, |
| | | parentId: ParentId, |
| | | Template: 'BaseTable', |
| | | easyCode: '', |
| | | enabled: false, |
| | | MenuName: MenuName, |
| | | MenuNo: MenuNo, |
| | | tables: [], |
| | | components: [], |
| | | viewType: 'menu', |
| | | style: { |
| | | backgroundColor: '#ffffff', backgroundImage: '', |
| | | paddingTop: '16px', paddingBottom: '80px', paddingLeft: '16px', paddingRight: '16px' |
| | | }, |
| | | } |
| | | } else { |
| | | config.uuid = MenuId |
| | | config.MenuID = MenuId |
| | | config.Template = 'BaseTable' |
| | | } |
| | | |
| | | config.open_edition = result.open_edition || '' |
| | | window.GLOB.urlFields = config.urlFields || [] |
| | | |
| | | this.setState({ |
| | | oriConfig: config, |
| | | config: fromJS(config).toJS() |
| | | }) |
| | | window.GLOB.customMenu = config |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | getMenuMessage = (delButtons) => { |
| | | 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 === 'group') { |
| | | traversal(item.components) |
| | | } else if (item.type === 'card' || (item.type === 'table' && item.subtype === 'tablecard')) { |
| | | item.action && item.action.forEach(btn => { |
| | | if (btn.hidden === 'true') { |
| | | delButtons.push(btn.uuid) |
| | | return |
| | | } |
| | | buttons.push(`select '${btn.uuid}' as menuid, '${item.name + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`) |
| | | _sort++ |
| | | }) |
| | | item.subcards.forEach(card => { |
| | | card.elements && card.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | | if (cell.hidden === 'true') { |
| | | delButtons.push(cell.uuid) |
| | | 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 |
| | | if (cell.hidden === 'true') { |
| | | delButtons.push(cell.uuid) |
| | | return |
| | | } |
| | | buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort`) |
| | | _sort++ |
| | | }) |
| | | }) |
| | | } else if (item.type === 'carousel' || item.type === 'timeline') { |
| | | item.subcards.forEach(card => { |
| | | card.elements && card.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | | if (cell.hidden === 'true') { |
| | | delButtons.push(cell.uuid) |
| | | return |
| | | } |
| | | buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort`) |
| | | _sort++ |
| | | }) |
| | | }) |
| | | } else if (item.type === 'balcony') { |
| | | item.elements && item.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | | if (cell.hidden === 'true') { |
| | | delButtons.push(cell.uuid) |
| | | 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.type === 'chart') { |
| | | item.action && item.action.forEach(btn => { |
| | | if (btn.hidden === 'true') { |
| | | delButtons.push(btn.uuid) |
| | | return |
| | | } |
| | | buttons.push(`select '${btn.uuid}' as menuid, '${item.name + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`) |
| | | _sort++ |
| | | }) |
| | | } else if (item.type === 'table' && (item.subtype === 'normaltable' || item.subtype === 'editable')) { |
| | | item.action && item.action.forEach(btn => { |
| | | if (btn.hidden === 'true') { |
| | | delButtons.push(btn.uuid) |
| | | return |
| | | } |
| | | buttons.push(`select '${btn.uuid}' as menuid, '${item.name + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`) |
| | | _sort++ |
| | | }) |
| | | item.cols && item.cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.hidden === 'true') { |
| | | delButtons.push(btn.uuid) |
| | | return |
| | | } |
| | | buttons.push(`select '${btn.uuid}' as menuid, '${item.name + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`) |
| | | _sort++ |
| | | }) |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | traversal(config.components) |
| | | |
| | | return buttons |
| | | } |
| | | |
| | | submitConfig = () => { |
| | | let config = fromJS(this.state.config).toJS() |
| | | |
| | | if (!config.MenuName || !config.MenuNo || !config.fstMenuId || !config.parentId) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请完善菜单基本信息!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | this.setState({ |
| | | menuloading: true |
| | | }) |
| | | |
| | | setTimeout(() => { |
| | | if (config.enabled && this.verifyConfig()) { |
| | | config.enabled = false |
| | | } |
| | | |
| | | let param = { |
| | | func: 'sPC_TrdMenu_AddUpt', |
| | | FstID: config.fstMenuId || '', |
| | | SndID: config.parentId, |
| | | ParentID: config.parentId, |
| | | MenuID: config.uuid, |
| | | MenuNo: config.MenuNo || '', |
| | | EasyCode: config.easyCode || '', |
| | | Template: 'BaseTable', |
| | | MenuName: config.MenuName || '', |
| | | PageParam: JSON.stringify({Template: 'BaseTable', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false'}), |
| | | LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(config))), |
| | | open_edition: config.open_edition, |
| | | LText: '', |
| | | LTexttb: '' |
| | | } |
| | | |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | |
| | | let btnParam = { // 添加菜单按钮 |
| | | func: 'sPC_Button_AddUpt', |
| | | Type: 40, // 添加菜单下的按钮type为40,按钮下的按钮type为60 |
| | | ParentID: config.uuid, |
| | | MenuNo: config.MenuNo, |
| | | Template: 'BaseTable', |
| | | PageParam: '', |
| | | LongParam: '', |
| | | LText: [] |
| | | } |
| | | |
| | | let delButtons = fromJS(this.state.delButtons).toJS() |
| | | |
| | | btnParam.LText = this.getMenuMessage(delButtons) |
| | | 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) |
| | | |
| | | new Promise(resolve => { |
| | | resolve(true) |
| | | }).then(res => { // 按钮删除 |
| | | if (delButtons.length === 0) { |
| | | return { |
| | | status: true |
| | | } |
| | | } else { |
| | | let _param = { |
| | | func: 'sPC_MainMenu_Del', |
| | | MenuID: delButtons.join(',') |
| | | } |
| | | return Api.getSystemConfig(_param) |
| | | } |
| | | }).then(res => { // 页面保存 |
| | | if (!res) return |
| | | |
| | | if (res.status) { |
| | | return Api.getSystemConfig(param) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | return false |
| | | } |
| | | }).then(res => { // 页面按钮关系保存 |
| | | if (!res) return |
| | | |
| | | if (res.status) { |
| | | let ori = this.state.oriConfig |
| | | if (config.MenuName !== ori.MenuName || config.MenuNo !== ori.MenuNo || config.parentId !== ori.parentId) { |
| | | localStorage.setItem('menuUpdate', new Date().getTime()) |
| | | } |
| | | config.open_edition = res.open_edition || '' |
| | | this.setState({ |
| | | config, |
| | | oriConfig: fromJS(config).toJS(), |
| | | }) |
| | | |
| | | if (btnParam.LText) { |
| | | return Api.getSystemConfig(btnParam) |
| | | } else { |
| | | return { |
| | | status: true |
| | | } |
| | | } |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | return false |
| | | } |
| | | }).then(res => { // 按钮复制 |
| | | if (!res) return |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | return false |
| | | } |
| | | }).then(res => { |
| | | if (res && res.status) { |
| | | this.setState({ |
| | | delButtons: [], |
| | | menuloading: false |
| | | }) |
| | | notification.success({ |
| | | top: 92, |
| | | message: '保存成功', |
| | | duration: 2 |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | | menuloading: false |
| | | }) |
| | | } |
| | | MKEmitter.emit('completeSave') |
| | | }) |
| | | }, 300 + (+sessionStorage.getItem('mkDelay'))) |
| | | } |
| | | |
| | | getRoleFields = () => { |
| | | if (sessionStorage.getItem('sysRoles')) return |
| | | Api.getSystemConfig({func: 'sPC_Get_Roles_sModular'}).then(res => { |
| | | if (res.status) { |
| | | let _permFuncField = [] |
| | | let _sysRoles = [] |
| | | |
| | | if (res.Roles && res.Roles.length > 0) { |
| | | _sysRoles = res.Roles.map(role => { |
| | | return { |
| | | uuid: Utils.getuuid(), |
| | | value: role.RoleID, |
| | | text: role.RoleName |
| | | } |
| | | }) |
| | | } |
| | | |
| | | if (res.sModular && res.sModular.length > 0) { |
| | | res.sModular.forEach(field => { |
| | | if (field.ModularNo) { |
| | | _permFuncField.push(field.ModularNo) |
| | | } |
| | | }) |
| | | _permFuncField = _permFuncField.sort() |
| | | } |
| | | |
| | | sessionStorage.setItem('sysRoles', JSON.stringify(_sysRoles)) |
| | | sessionStorage.setItem('permFuncField', JSON.stringify(_permFuncField)) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | onEnabledChange = () => { |
| | | const { config } = this.state |
| | | |
| | | if (!config || (!config.enabled && this.verifyConfig(true))) { |
| | | return |
| | | } |
| | | |
| | | this.setState({ |
| | | config: {...config, enabled: !config.enabled} |
| | | }) |
| | | } |
| | | |
| | | verifyConfig = (show) => { |
| | | const { config } = this.state |
| | | let error = '' |
| | | |
| | | let check = (components) => { |
| | | components.forEach(item => { |
| | | if (error) return |
| | | |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | | check(tab.components) |
| | | }) |
| | | return |
| | | } else if (item.type === 'group') { |
| | | check(item.components) |
| | | return |
| | | } else if (!item.errors || item.errors.length === 0) { |
| | | return |
| | | } |
| | | |
| | | item.errors.forEach(err => { |
| | | if (err.level !== 0 || error) return |
| | | error = `组件《${item.name}》${err.detail}` |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | check(config.components) |
| | | |
| | | if (show && error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: error, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | |
| | | return error |
| | | } |
| | | |
| | | // 更新配置信息 |
| | | updateConfig = (config) => { |
| | | this.setState({ |
| | | config: config |
| | | }) |
| | | window.GLOB.customMenu = config |
| | | } |
| | | |
| | | resetConfig = (config) => { |
| | | this.setState({ |
| | | config, |
| | | comloading: true |
| | | }, () => { |
| | | this.setState({ |
| | | comloading: false |
| | | }) |
| | | }) |
| | | window.GLOB.customMenu = config |
| | | } |
| | | |
| | | insert = (item) => { |
| | | let config = fromJS(this.state.config).toJS() |
| | | |
| | | config.components.push(item) |
| | | |
| | | this.setState({config}) |
| | | window.GLOB.customMenu = config |
| | | |
| | | notification.success({ |
| | | top: 92, |
| | | message: '粘贴成功!', |
| | | duration: 2 |
| | | }) |
| | | } |
| | | |
| | | changeSetting = () => { |
| | | this.setState({settingshow: !this.state.settingshow}) |
| | | |
| | | setTimeout(() => { |
| | | MKEmitter.emit('tabsChange', 'all') |
| | | }, 400) |
| | | } |
| | | |
| | | render () { |
| | | const { loading } = this.state |
| | | const { activeKey, comloading, MenuId, config, settingshow, ParentId, menuloading } = this.state |
| | | |
| | | return ( |
| | | <div className="mk-base-design-wrap"> |
| | | <ConfigProvider locale={_locale}> |
| | | <div className="pc-table-view"> |
| | | <Header/> |
| | | {this.state.tabview === 'CommonTable' ? |
| | | <ComTableConfig |
| | | menu={this.state.editMenu} |
| | | reloadmenu={() => {localStorage.setItem('menuUpdate', new Date().getTime())}} |
| | | handleView={this.handleView} |
| | | /> : null |
| | | } |
| | | {this.state.tabview === 'Modal' ? |
| | | <ModalConfig |
| | | menu={this.state.editMenu} |
| | | editTab={this.state.editTab} |
| | | tabConfig={this.state.tabConfig} |
| | | editSubTab={this.state.editSubTab} |
| | | subTabConfig={this.state.subTabConfig} |
| | | btnTab={this.state.btnTab} |
| | | btnTabConfig={this.state.btnTabConfig} |
| | | editAction={this.state.editAction} |
| | | subConfig={this.state.subConfig} |
| | | handleView={this.handleView} |
| | | /> : null |
| | | } |
| | | {loading ? <Spin className="loading-view" size="large"/> : null} |
| | | </ConfigProvider> |
| | | <DndProvider backend={HTML5Backend}> |
| | | <div className="menu-body"> |
| | | <div className={'menu-setting ' + (!settingshow ? 'hidden' : '')}> |
| | | <div className="draw"> |
| | | {settingshow ? <DoubleLeftOutlined onClick={this.changeSetting}/> : <DoubleRightOutlined onClick={this.changeSetting}/>} |
| | | </div> |
| | | <Collapse accordion activeKey={activeKey} bordered={false} onChange={(key) => this.setState({activeKey: key})}> |
| | | {/* 基本信息 */} |
| | | <Panel header="基本信息" key="basedata"> |
| | | {/* 菜单信息 */} |
| | | {config ? <MenuForm |
| | | config={config} |
| | | MenuId={MenuId} |
| | | parentId={ParentId} |
| | | MenuName={config.MenuName} |
| | | MenuNo={config.MenuNo} |
| | | updateConfig={this.updateConfig} |
| | | /> : null} |
| | | {config ? <UrlFieldComponent |
| | | config={config} |
| | | updateConfig={this.updateConfig} |
| | | /> : null} |
| | | {/* 表名添加 */} |
| | | {config ? <TableComponent config={config} updatetable={this.updateConfig}/> : null} |
| | | {config ? <Paragraph style={{padding: '15px 0px 0px 18px'}} copyable={{ text: MenuId }}>菜单ID</Paragraph> : null} |
| | | </Panel> |
| | | <Panel header="页面样式" key="background"> |
| | | {config ? <BgController config={config} updateConfig={this.updateConfig} /> : null} |
| | | </Panel> |
| | | </Collapse> |
| | | </div> |
| | | <div className={'menu-view' + (menuloading ? ' saving' : '')}> |
| | | <Card title={ |
| | | <div style={{paddingLeft: '15px'}}> {config && config.MenuName} </div> |
| | | } bordered={false} extra={ |
| | | <div> |
| | | <Versions MenuId={MenuId} open_edition={config ? config.open_edition : ''}/> |
| | | <ReplaceField type="custom" config={config} updateConfig={this.resetConfig}/> |
| | | <SysInterface config={config} updateConfig={this.updateConfig}/> |
| | | <PictureController/> |
| | | <Switch className="big" checkedChildren="启" unCheckedChildren="停" checked={config && config.enabled} onChange={this.onEnabledChange} /> |
| | | <Button type="primary" id="save-config" onClick={this.submitConfig} loading={menuloading}>保存</Button> |
| | | <Button type="default" onClick={this.closeView}>关闭</Button> |
| | | </div> |
| | | } style={{ width: '100%' }}> |
| | | {config && !comloading ? <MenuShell menu={config} handleList={this.updateConfig} /> : null} |
| | | </Card> |
| | | </div> |
| | | </div> |
| | | </DndProvider> |
| | | <StyleController /> |
| | | <ModalController /> |
| | | </div> |
| | | </ConfigProvider> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | export default TableDesign |
| | | export default withRouter(TableDesign) |
| | |
| | | .mk-base-design-wrap { |
| | | .loading-view { |
| | | body { |
| | | overflow-x: hidden; |
| | | overflow-y: hidden; |
| | | } |
| | | .pc-table-view { |
| | | background: #000; |
| | | min-height: 100vh; |
| | | .mk-hidden { |
| | | text-decoration: line-through!important; |
| | | span { |
| | | text-decoration: line-through!important; |
| | | } |
| | | } |
| | | .eye-open { |
| | | .component-name { |
| | | display: block; |
| | | } |
| | | .anticon-tool { |
| | | display: none; |
| | | } |
| | | } |
| | | .component-name { |
| | | position: absolute; |
| | | left: calc(50vw - 22px); |
| | | top: calc(30vh + 48px); |
| | | z-index: 9; |
| | | display: none; |
| | | left: 0; |
| | | right: 0; |
| | | top: 0; |
| | | bottom: 0; |
| | | background: rgba(255, 255, 255, 0.9); |
| | | border: 1px solid #1890ff; |
| | | .center { |
| | | position: absolute; |
| | | font-size: 16px; |
| | | left: 50%; |
| | | top: 50%; |
| | | color: #1890ff; |
| | | transform: translate(-50%, -50%); |
| | | max-width: 70%; |
| | | .title { |
| | | text-align: center; |
| | | } |
| | | } |
| | | .error { |
| | | text-align: center; |
| | | color: red; |
| | | display: block; |
| | | } |
| | | .waring { |
| | | color: orange; |
| | | } |
| | | } |
| | | >.menu-body { |
| | | width: 100vw; |
| | | height: 100vh; |
| | | overflow-x: hidden; |
| | | position: relative; |
| | | background: #ffffff; |
| | | padding: 50px 0px 0px 0px; |
| | | |
| | | .menu-setting { |
| | | position: fixed; |
| | | left: 0; |
| | | top: 48px; |
| | | z-index: 10; |
| | | height: calc(100vh - 48px); |
| | | width: 300px; |
| | | background: #ffffff; |
| | | box-shadow: 0px 2px 5px #bcbcbc; |
| | | transition: left 0.3s; |
| | | |
| | | .draw { |
| | | position: absolute; |
| | | z-index: 11; |
| | | background: #ffffff; |
| | | right: -20px; |
| | | top: 0px; |
| | | box-shadow: 0 0 1px #959595; |
| | | border-radius: 0 2px 2px 0px; |
| | | |
| | | .anticon { |
| | | padding: 12px 3px; |
| | | } |
| | | } |
| | | > .ant-collapse { |
| | | height: 100%; |
| | | overflow-y: auto; |
| | | overflow-x: hidden; |
| | | background-color: #ffffff; |
| | | border-radius: 0px; |
| | | padding-bottom: 30px; |
| | | .ant-collapse-item.ant-collapse-item-active { |
| | | border-bottom: 1px solid #d9d9d9; |
| | | } |
| | | .ant-collapse-header { |
| | | padding: 11px 16px 10px 40px; |
| | | border-bottom: 1px solid #d9d9d9; |
| | | background: #1890ff; |
| | | color: #ffffff; |
| | | } |
| | | .ant-collapse-content-box { |
| | | .ant-form-item { |
| | | margin-bottom: 10px; |
| | | } |
| | | .model-table-tablemanage-view { |
| | | >.ant-list { |
| | | margin-top: 20px; |
| | | .ant-list-item { |
| | | display: -webkit-box; |
| | | padding-right: 20px; |
| | | position: relative; |
| | | padding-left: 5px; |
| | | overflow: hidden; |
| | | text-overflow: ellipsis; |
| | | -webkit-line-clamp: 2; |
| | | -webkit-box-orient: vertical; |
| | | min-height: 55px; |
| | | width: 100%; |
| | | .anticon { |
| | | position: absolute; |
| | | top: 0px; |
| | | right: 0px; |
| | | padding: 3px 3px 10px 10px; |
| | | cursor: pointer; |
| | | } |
| | | } |
| | | } |
| | | >.tables { |
| | | width: 66.66666667%!important; |
| | | } |
| | | >.ant-form-item-label { |
| | | width: 33.33333333%; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | >.ant-tabs { |
| | | >.ant-tabs-bar { |
| | | border-bottom: 1px solid #181F29; |
| | | margin-bottom: 0px; |
| | | min-height: 48px; |
| | | .ant-tabs-tab { |
| | | padding: 14px 16px; |
| | | color: rgba(255, 255, 255, 0.85); |
| | | } |
| | | .ant-tabs-tab-active.ant-tabs-tab { |
| | | color: #1890ff; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | .menu-setting >.ant-collapse::-webkit-scrollbar { |
| | | width: 4px; |
| | | } |
| | | .menu-setting >.ant-collapse::-webkit-scrollbar-thumb { |
| | | border-radius: 5px; |
| | | box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.08); |
| | | background: rgba(0, 0, 0, 0.08); |
| | | } |
| | | .menu-setting >.ant-collapse::-webkit-scrollbar-track { |
| | | box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); |
| | | border-radius: 3px; |
| | | border: 1px solid rgba(0, 0, 0, 0.07); |
| | | background: rgba(0, 0, 0, 0); |
| | | } |
| | | |
| | | .menu-setting.hidden { |
| | | left: -300px; |
| | | } |
| | | .menu-setting.hidden + .menu-view { |
| | | width: 100vw; |
| | | margin-left: 0px; |
| | | } |
| | | |
| | | .menu-view { |
| | | position: relative; |
| | | width: calc(100vw - 300px); |
| | | margin-left: 300px; |
| | | height: calc(100vh - 50px); |
| | | overflow-y: auto; |
| | | transition: all 0.3s; |
| | | |
| | | > .ant-card { |
| | | >.ant-card-head { |
| | | margin-bottom: 0px; |
| | | position: relative; |
| | | .ant-card-head-title { |
| | | color: #1890ff; |
| | | padding: 5px 0; |
| | | } |
| | | .ant-card-extra { |
| | | padding: 5px 0; |
| | | button { |
| | | margin-left: 10px; |
| | | } |
| | | >div >div >button, .style-control-button { |
| | | padding: 0px 7px; |
| | | } |
| | | .ant-switch.big { |
| | | min-width: 60px; |
| | | height: 28px; |
| | | line-height: 28px; |
| | | margin-top: -2px; |
| | | .ant-switch-inner { |
| | | font-size: 14px; |
| | | } |
| | | } |
| | | .ant-switch.big:after { |
| | | width: 24px; |
| | | height: 24px; |
| | | } |
| | | } |
| | | } |
| | | >.ant-card-body { |
| | | padding: 0px; |
| | | } |
| | | } |
| | | } |
| | | .menu-view.saving { |
| | | .anticon-tool { |
| | | display: none; |
| | | } |
| | | } |
| | | .menu-view::-webkit-scrollbar { |
| | | width: 7px; |
| | | } |
| | | .menu-view::-webkit-scrollbar-thumb { |
| | | border-radius: 5px; |
| | | box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.08); |
| | | background: rgba(0, 0, 0, 0.08); |
| | | } |
| | | .menu-view::-webkit-scrollbar-track { |
| | | box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); |
| | | border-radius: 3px; |
| | | border: 1px solid rgba(0, 0, 0, 0.07); |
| | | background: rgba(0, 0, 0, 0); |
| | | } |
| | | } |
| | | } |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Row, Col, Input, Select } from 'antd' |
| | | import { Form, Row, Col, Input, Select, notification, Radio, Tooltip, Switch } from 'antd' |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | |
| | | import Api from '@/api' |
| | | import options from '@/store/options.js' |
| | | import './index.scss' |
| | | |
| | | const { TextArea } = Input |
| | | |
| | | class MainSearch extends Component { |
| | | class CustomMenuForm extends Component { |
| | | static propTpyes = { |
| | | menu: PropTypes.object, // 菜单信息 |
| | | inputSubmit: PropTypes.func // 回车提交 |
| | | config: PropTypes.object, |
| | | MenuId: PropTypes.string, |
| | | MenuName: PropTypes.string, |
| | | MenuNo: PropTypes.string, |
| | | parentId: PropTypes.string, |
| | | updateConfig: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | | supMenuList: [] |
| | | fstMenuId: '', |
| | | menulist: [], |
| | | smenulist: [] |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | this.setState({ |
| | | supMenuList: this.props.menu.supMenuList |
| | | }) |
| | | const { MenuId, config } = this.props |
| | | Api.getSystemConfig({func: 's_get_pc_menus', systemType: options.sysType, debug: 'Y'}).then(result => { |
| | | if (result.status) { |
| | | let thdMenu = null |
| | | let thdMenuList = [] |
| | | let menulist = result.fst_menu.map(fst => { |
| | | let fstItem = { |
| | | MenuID: fst.MenuID, |
| | | MenuName: fst.MenuName, |
| | | value: fst.MenuID, |
| | | label: fst.MenuName, |
| | | isLeaf: false, |
| | | children: [] |
| | | } |
| | | |
| | | changeMenu = (val) => { |
| | | const { menu } = this.state |
| | | if (fst.snd_menu) { |
| | | fstItem.children = fst.snd_menu.map(snd => { |
| | | let sndItem = { |
| | | ParentId: fst.MenuID, |
| | | MenuID: snd.MenuID, |
| | | MenuName: snd.MenuName, |
| | | value: snd.MenuID, |
| | | label: snd.MenuName, |
| | | children: [] |
| | | } |
| | | |
| | | let submenu = menu.fstMenuList.filter(item => item.MenuID === val)[0] |
| | | if (snd.trd_menu) { |
| | | sndItem.children = snd.trd_menu.map(trd => { |
| | | let trdItem = { |
| | | FstId: fst.MenuID, |
| | | ParentId: snd.MenuID, |
| | | MenuID: trd.MenuID, |
| | | MenuName: trd.MenuName, |
| | | MenuNo: trd.MenuNo, |
| | | EasyCode: trd.EasyCode, |
| | | value: trd.MenuID, |
| | | label: trd.MenuName, |
| | | type: 'CommonTable', |
| | | // disabled: trd.MenuID === MenuId |
| | | disabled: false |
| | | } |
| | | |
| | | if (submenu) { |
| | | if (MenuId === trd.MenuID) { |
| | | thdMenu = trdItem |
| | | } |
| | | |
| | | if (trd.PageParam) { |
| | | try { |
| | | trd.PageParam = JSON.parse(trd.PageParam) |
| | | trdItem.type = trd.PageParam.Template || 'CommonTable' |
| | | } catch (e) { |
| | | |
| | | } |
| | | } |
| | | |
| | | thdMenuList.push(trdItem) |
| | | |
| | | return trdItem |
| | | }) |
| | | } |
| | | return sndItem |
| | | }) |
| | | } |
| | | return fstItem |
| | | }) |
| | | |
| | | let smenulist = [] |
| | | menulist.forEach(item => { |
| | | if (thdMenu && (item.MenuID === thdMenu.FstId)) { |
| | | smenulist = item.children |
| | | } |
| | | }) |
| | | sessionStorage.setItem('fstMenuList', JSON.stringify(menulist)) |
| | | sessionStorage.setItem('thdMenuList', JSON.stringify(thdMenuList)) |
| | | this.props.updateConfig({...config, fstMenuId: thdMenu ? thdMenu.FstId : ''}) |
| | | |
| | | this.setState({ |
| | | supMenuList: submenu.children |
| | | fstMenuId: thdMenu ? thdMenu.FstId : '', |
| | | menulist, |
| | | smenulist |
| | | }, () => { |
| | | this.props.form.setFieldsValue({ParentID: submenu.children[0] ? submenu.children[0].MenuID : ''}) |
| | | this.props.form.setFieldsValue({ |
| | | fstMenuId: thdMenu ? thdMenu.FstId : '', |
| | | parentId: thdMenu ? thdMenu.ParentId : '' |
| | | }) |
| | | }) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | // 一二级菜单切换 |
| | | selectChange = (key, value) => { |
| | | const { config } = this.props |
| | | const { menulist } = this.state |
| | | |
| | | if (key === 'fstMenuId') { |
| | | let smenulist = [] |
| | | menulist.forEach(item => { |
| | | if (item.MenuID === value) { |
| | | smenulist = item.children |
| | | } |
| | | }) |
| | | |
| | | this.setState({ |
| | | supMenuList: [] |
| | | smenulist |
| | | }, () => { |
| | | this.props.form.setFieldsValue({ParentID: ''}) |
| | | let _id = smenulist[0] ? smenulist[0].MenuID : '' |
| | | this.props.form.setFieldsValue({parentId: _id}) |
| | | this.props.updateConfig({...config, fstMenuId: value, parentId: _id}) |
| | | }) |
| | | } else if (key === 'parentId') { |
| | | this.props.updateConfig({...config, parentId: value}) |
| | | } else if (key === 'timeUnit') { |
| | | this.props.updateConfig({...config, timeUnit: value}) |
| | | } else if (key === 'OpenType') { |
| | | this.props.updateConfig({...config, OpenType: value}) |
| | | } else if (key === 'hidden') { |
| | | this.props.updateConfig({...config, hidden: value}) |
| | | } else if (key === 'permission') { |
| | | this.props.updateConfig({...config, permission: value}) |
| | | } |
| | | } |
| | | |
| | | handleConfirm = () => { |
| | | // 表单提交时检查输入值是否正确 |
| | | return new Promise((resolve, reject) => { |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | resolve(values) |
| | | } else { |
| | | reject(err) |
| | | } |
| | | }) |
| | | }) |
| | | // 菜单名称 |
| | | changeName = (e) => { |
| | | this.props.updateConfig({...this.props.config, MenuName: e.target.value}) |
| | | } |
| | | |
| | | onEnterSubmit = (e) => { |
| | | // 表单回车提交 |
| | | if (e.key !== 'Enter') return |
| | | // 菜单参数 |
| | | changeNo = (e) => { |
| | | this.props.updateConfig({...this.props.config, MenuNo: e.target.value}) |
| | | } |
| | | |
| | | this.props.inputSubmit && this.props.inputSubmit() |
| | | // 助记码 |
| | | changeEasyCode = (e) => { |
| | | this.props.updateConfig({...this.props.config, easyCode: e.target.value}) |
| | | } |
| | | |
| | | changeRemark = (e) => { |
| | | this.props.updateConfig({...this.props.config, Remark: e.target.value}) |
| | | } |
| | | |
| | | changeCacheDay = (val) => { |
| | | if (typeof(val) !== 'number') { |
| | | val = '' |
| | | } |
| | | this.props.updateConfig({...this.props.config, cacheTime: val}) |
| | | } |
| | | |
| | | render() { |
| | | const { MenuName, MenuNo, config } = this.props |
| | | const { menulist, smenulist } = this.state |
| | | const { getFieldDecorator } = this.props.form |
| | | const { menu } = this.state |
| | | const formItemLayout = { |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | |
| | | } |
| | | |
| | | return ( |
| | | <Form {...formItemLayout} style={{paddingRight: '20px'}} onKeyDown={this.onEnterSubmit}> |
| | | <Row gutter={24}> |
| | | <Col span={22}> |
| | | <Form.Item label={'一级菜单'}> |
| | | <Form {...formItemLayout} className="custom-menu-form"> |
| | | <Row> |
| | | <Col span={24}> |
| | | <Form.Item label="一级菜单"> |
| | | {getFieldDecorator('fstMenuId', { |
| | | initialValue: menu.fstMenuId, |
| | | initialValue: '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请选择上级菜单!' |
| | | message: '请选择一级菜单!' |
| | | } |
| | | ] |
| | | })( |
| | | <Select |
| | | showSearch |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | onChange={this.changeMenu} |
| | | > |
| | | {menu.fstMenuList.map(option => |
| | | <Select.Option key={option.MenuID} value={option.MenuID}>{option.text || option.MenuName}</Select.Option> |
| | | <Select onChange={(value) => {this.selectChange('fstMenuId', value)}}> |
| | | {menulist.map(option => |
| | | <Select.Option key={option.MenuID} value={option.MenuID}> |
| | | {option.MenuName} |
| | | </Select.Option> |
| | | )} |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={22}> |
| | | <Form.Item label={'二级菜单'}> |
| | | {getFieldDecorator('ParentID', { |
| | | initialValue: menu.ParentId, |
| | | <Col span={24}> |
| | | <Form.Item label="二级菜单"> |
| | | {getFieldDecorator('parentId', { |
| | | initialValue: '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请选择上级菜单!' |
| | | message: '请选择二级菜单!' |
| | | } |
| | | ] |
| | | })( |
| | | <Select |
| | | showSearch |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | > |
| | | {menu.supMenuList.map(option => |
| | | <Select.Option key={option.MenuID} value={option.MenuID}>{option.text || option.MenuName}</Select.Option> |
| | | <Select onChange={(value) => {this.selectChange('parentId', value)}}> |
| | | {smenulist.map(option => |
| | | <Select.Option key={option.MenuID} value={option.MenuID}> |
| | | {option.MenuName} |
| | | </Select.Option> |
| | | )} |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={22}> |
| | | <Form.Item label={'菜单名称'}> |
| | | <Col span={24}> |
| | | <Form.Item label="菜单名称"> |
| | | {getFieldDecorator('MenuName', { |
| | | initialValue: menu.MenuName || '', |
| | | initialValue: MenuName, |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请输入菜单名称!' |
| | | } |
| | | ] |
| | | })(<Input placeholder="" autoFocus autoComplete="off" />)} |
| | | })(<Input placeholder="" autoComplete="off" onChange={this.changeName}/>)} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={22}> |
| | | <Form.Item label={'菜单参数'}> |
| | | <Col span={24}> |
| | | <Form.Item label="菜单参数"> |
| | | {getFieldDecorator('MenuNo', { |
| | | initialValue: menu.MenuNo || '', |
| | | initialValue: MenuNo, |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请输入菜单参数!' |
| | | } |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" />)} |
| | | })(<Input placeholder="" autoComplete="off" onChange={this.changeNo}/>)} |
| | | </Form.Item> |
| | | </Col> |
| | | {menu.Template === 'NewPage' ? <Col span={22}> |
| | | <Form.Item label={'链接地址'}> |
| | | {getFieldDecorator('url', { |
| | | initialValue: menu.url || '', |
| | | <Col span={24}> |
| | | <Form.Item label="打开方式"> |
| | | {getFieldDecorator('OpenType', { |
| | | initialValue: config.OpenType || 'newtab', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请输入页面地址!' |
| | | }, |
| | | { |
| | | max: 1024, |
| | | message: '地址最长为1024个字符!' |
| | | message: '请选择打开方式!' |
| | | } |
| | | ] |
| | | })(<TextArea rows={2} />)} |
| | | })( |
| | | <Radio.Group onChange={(e) => {this.selectChange('OpenType', e.target.value)}}> |
| | | <Radio value="newtab">标签页</Radio> |
| | | <Radio value="newpage">新页面</Radio> |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | </Col> |
| | | <Col span={24}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="跳过权限验证时,页面中组件及按钮不在进行权限控制。"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 权限验证 |
| | | </Tooltip> |
| | | }> |
| | | {getFieldDecorator('permission', { |
| | | initialValue: config.permission || 'true' |
| | | })( |
| | | <Radio.Group onChange={(e) => {this.selectChange('permission', e.target.value)}}> |
| | | <Radio value="true">使用</Radio> |
| | | <Radio value="false">不使用</Radio> |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={24}> |
| | | <Form.Item label="助记码"> |
| | | {getFieldDecorator('easyCode', { |
| | | initialValue: config.easyCode |
| | | })(<Input placeholder="" autoComplete="off" onChange={this.changeEasyCode}/>)} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={24}> |
| | | <Form.Item label={'隐藏菜单'}> |
| | | <Switch checkedChildren={'是'} checked={config.hidden === 'true'} unCheckedChildren={'否'} onChange={(value) => { |
| | | this.selectChange('hidden', value + '') |
| | | }} /> |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={24}> |
| | | <Form.Item label="备注"> |
| | | {getFieldDecorator('Remark', { |
| | | initialValue: config.Remark || '', |
| | | rules: [ |
| | | { |
| | | max: 512, |
| | | message: '备注最多512个字符!' |
| | | } |
| | | ] |
| | | })(<TextArea rows={2} placeholder={''} onChange={this.changeRemark} />)} |
| | | </Form.Item> |
| | | </Col> |
| | | </Row> |
| | | </Form> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | export default Form.create()(MainSearch) |
| | | export default Form.create()(CustomMenuForm) |
| | |
| | | .custom-menu-form { |
| | | .ant-form-item { |
| | | height: 50px; |
| | | .ant-form-explain { |
| | | font-size: 12px; |
| | | } |
| | | } |
| | | } |