From fa2c99a6ed8574878c1bdefae5dcb839fc4ebcf8 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 07 十一月 2024 21:10:43 +0800 Subject: [PATCH] 2024-11-07 --- src/views/pcdesign/index.jsx | 236 +++++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 189 insertions(+), 47 deletions(-) diff --git a/src/views/pcdesign/index.jsx b/src/views/pcdesign/index.jsx index 51d198e..d3a7101 100644 --- a/src/views/pcdesign/index.jsx +++ b/src/views/pcdesign/index.jsx @@ -3,15 +3,14 @@ import { withRouter } from 'react-router' import { is, fromJS } from 'immutable' import HTML5Backend from 'react-dnd-html5-backend' -import { ConfigProvider, notification, Modal, Collapse, Switch, Button, message, Spin, Typography } from 'antd' +import { notification, Modal, Collapse, Switch, Button, message, Spin, Typography } from 'antd' import { DoubleLeftOutlined, DoubleRightOutlined, HomeOutlined, LoginOutlined, ArrowLeftOutlined, EyeOutlined, EyeInvisibleOutlined } from '@ant-design/icons' import moment from 'moment' import md5 from 'md5' import Api from '@/api' -import Utils, { setGLOBFuncs } from '@/utils/utils.js' -import { getTables, getFuncsAndInters } from '@/utils/utils-custom.js' -import antdZhCN from 'antd/es/locale/zh_CN' +import Utils from '@/utils/utils.js' +import { getTables, getFuncsAndInters, getOutMessage, getLangTrans, getAllSqls } from '@/utils/utils-custom.js' import MKEmitter from '@/utils/events.js' import MenuUtils from '@/utils/utils-custom.js' import asyncComponent from '@/utils/asyncComponent' @@ -69,7 +68,9 @@ eyeopen: false, view: '', popConfig: null, - needUpdate: false + needUpdate: false, + appLoginId: '', + appHomeId: '' } UNSAFE_componentWillMount() { @@ -100,17 +101,49 @@ try { let param = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param))) + if (param.lang) { + sessionStorage.setItem('lang', param.lang) + } + if (param.type === 'app') { sessionStorage.setItem('appId', param.ID || '') sessionStorage.setItem('appName', param.remark || '') - sessionStorage.setItem('lang', param.lang || 'zh-CN') sessionStorage.setItem('kei_no', param.kei_no || '') sessionStorage.setItem('sysBgColor', param.sysBgColor || '#ffffff') + if (param.applangList) { + sessionStorage.setItem('applangList', param.applangList) + } else { + sessionStorage.removeItem('applangList') + } + + if (param.wxAppId) { + sessionStorage.setItem('wxAppId', param.wxAppId) + } + this.getAppMessage(param.MenuID) } else if (param.type === 'view') { + let appLoginId = '' + let appHomeId = '' + if (sessionStorage.getItem('appViewList')) { + try { + let appMenus = JSON.parse(sessionStorage.getItem('appViewList')) + appMenus.forEach(item => { + if (item.keys_type === 'login') { + appLoginId = item.keys_id + } else if (item.keys_type === 'index') { + appHomeId = item.keys_id + } + }) + } catch (e) { + + } + } + this.setState({ - MenuId: param.MenuID + MenuId: param.MenuID, + appLoginId: appLoginId, + appHomeId: appHomeId }, () => { this.getMenuParam(param) }) @@ -144,9 +177,13 @@ MKEmitter.addListener('changeEditMenu', this.changeEditMenu) MKEmitter.addListener('triggerMenuSave', this.triggerMenuSave) + if (sessionStorage.getItem('wxAppId')) { + window.GLOB.WXAppID = sessionStorage.getItem('wxAppId') + } + setTimeout(() => { this.getRoleFields() - setGLOBFuncs() + // setGLOBFuncs() }, 1000) document.onkeydown = (event) => { @@ -240,7 +277,8 @@ MenuID: menu.MenuID, copyMenuId: menu.copyMenuId || '', clearMenu: menu.clearMenu !== 'false', - type: 'view' + type: 'view', + lang: sessionStorage.getItem('lang') } // param.MenuNo = menu.MenuNo || '' @@ -287,7 +325,7 @@ let param = { func: 's_kei_link_keyids_addupt', BID: sessionStorage.getItem('appId'), - exec_type: 'y', + exec_type: 'x', LText: '' } @@ -302,7 +340,7 @@ param.LText = appViewList.map(item => `select '${item.keys_id}','${item.keys_type}','${item.kei_no}','${item.appkey}','${item.bid}','${sessionStorage.getItem('CloudUserID')}','${item.remark}'`) param.LText = param.LText.join(' union all ') - param.LText = Utils.formatOptions(param.LText) + param.LText = Utils.formatOptions(param.LText, 'x') param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt('', param.timestamp) @@ -316,12 +354,12 @@ }) } else { sessionStorage.setItem('appViewList', JSON.stringify(appViewList)) - this.props.history.replace('/pcdesign/' + window.btoa(window.encodeURIComponent(JSON.stringify({MenuID: homeId, type: 'view'})))) + this.props.history.replace('/pcdesign/' + window.btoa(window.encodeURIComponent(JSON.stringify({MenuID: homeId, type: 'view', lang: sessionStorage.getItem('lang')})))) } }) } else { sessionStorage.setItem('appViewList', JSON.stringify(appViewList)) - this.props.history.replace('/pcdesign/' + window.btoa(window.encodeURIComponent(JSON.stringify({MenuID: MenuID || homeId, type: 'view'})))) + this.props.history.replace('/pcdesign/' + window.btoa(window.encodeURIComponent(JSON.stringify({MenuID: MenuID || homeId, type: 'view', lang: sessionStorage.getItem('lang')})))) } }) } @@ -531,6 +569,7 @@ config.uuid = MenuId config.MenuID = MenuId + config.Template = 'webPage' config.open_edition = result.open_edition || '' window.GLOB.urlFields = config.urlFields || [] @@ -737,6 +776,7 @@ config.uuid = MenuId config.MenuID = MenuId + config.Template = 'webPage' config.open_edition = '' config.MenuName = urlParam.MenuName || '' config.MenuNo = '' @@ -875,7 +915,7 @@ return } else if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') { item.action && item.action.forEach(btn => { - if (btn.hidden === 'true') return + if (btn.hidden === 'true' || btn.permission === 'false') return m.children.push({ key: btn.uuid, @@ -884,7 +924,7 @@ }) item.subcards.forEach(card => { card.elements && card.elements.forEach(cell => { - if (cell.eleType !== 'button' || cell.hidden === 'true') return + if (cell.eleType !== 'button' || cell.hidden === 'true' || cell.permission === 'false') return m.children.push({ key: cell.uuid, @@ -893,7 +933,7 @@ }) card.backElements && card.backElements.forEach(cell => { - if (cell.eleType !== 'button' || cell.hidden === 'true') return + if (cell.eleType !== 'button' || cell.hidden === 'true' || cell.permission === 'false') return m.children.push({ key: cell.uuid, @@ -903,7 +943,7 @@ }) } else if (item.type === 'balcony') { item.elements && item.elements.forEach(cell => { - if (cell.eleType !== 'button' || cell.hidden === 'true') return + if (cell.eleType !== 'button' || cell.hidden === 'true' || cell.permission === 'false') return m.children.push({ key: cell.uuid, @@ -921,7 +961,7 @@ } } else if (item.type === 'table') { item.action.forEach(btn => { - if (btn.hidden === 'true') return + if (btn.hidden === 'true' || btn.permission === 'false') return m.children.push({ key: btn.uuid, @@ -934,7 +974,7 @@ loopCol(col.subcols) } else if (col.type === 'custom') { col.elements.forEach(cell => { - if (cell.eleType !== 'button' || cell.hidden === 'true') return + if (cell.eleType !== 'button' || cell.hidden === 'true' || cell.permission === 'false') return m.children.push({ key: cell.uuid, title: cell.label, @@ -1138,6 +1178,20 @@ if (!this.checkBase()) { return + } else if (this.checklog()) { + if (sessionStorage.getItem('applangList') && !config.trans) { + + } else if (config.enabled && !config.allSqls) { + + } else { + notification.success({ + top: 92, + message: '褰撳墠閰嶇疆鏈慨鏀癸紝鏃犻渶淇濆瓨銆�', + duration: 5 + }) + MKEmitter.emit('completeSave') + return + } } this.setState({ @@ -1153,6 +1207,52 @@ } else if (!config.enabled && config.force && _pass) { config.enabled = true delete config.force + } + + let long_data = '' + if (config.enabled) { + let sqls = getAllSqls(config) + let _t = moment().format('YYYYMMDDHHmmss') + let getguid = () => { + let uuid = '' + for (let i = 0; i < 18; i++) { + uuid += String.fromCharCode(Math.floor(Math.random() * 26) + 65) + } + uuid = uuid.replace(/minke/ig, 'MNKIE') + return uuid + } + + long_data = [] + // let oriIds = {} + // if (config.allSqls) { + // config.allSqls.forEach(item => { + // if (!item.md5) return + // oriIds[item.uuid + item.md5] = item.v_id + // }) + // } + + config.allSqls = sqls.map(item => { + let v_id = _t + getguid() + + // if (oriIds[item.uuid + item.md5]) { + // v_id = oriIds[item.uuid + item.md5] + // } + + long_data.push(`${md5(window.GLOB.appkey + v_id)},${item.uuid},${v_id},${window.btoa(window.encodeURIComponent(item.LText))},${config.sqlperm === 'false' ? '' : item.roleId || ''}`) + + return { + uuid: item.uuid, + v_id: v_id, + type: item.type, + reps: item.reps, + // md5: item.md5 || '', + luser: item.luser === true + } + }) + + long_data = long_data.join(';') + } else { + delete config.allSqls } if (config.cacheUseful !== 'true') { @@ -1205,7 +1305,19 @@ } let interfaces = getFuncsAndInters(config) + let msg = getOutMessage(config) roleParam.interfaces = interfaces + roleParam.msg = msg + roleParam.backend = 'level1' + let langSql = getLangTrans(config) + + roleParam.pds = 'false' + if (config.interfaces) { + config.interfaces.forEach(item => { + if (item.status !== 'true') return + roleParam.pds = 'true' + }) + } let param = { func: 'sPC_TrdMenu_AddUpt', @@ -1219,15 +1331,20 @@ TypeCharOne: sessionStorage.getItem('kei_no'), Typename: 'pc', MenuName: config.MenuName || '', - PageParam: JSON.stringify({Template: 'webPage', interfaces}), + PageParam: JSON.stringify({Template: 'webPage', interfaces, msg}), menus_rolelist: window.btoa(window.encodeURIComponent(JSON.stringify(roleParam))), open_edition: config.open_edition, - LText: '', - LTexttb: '', + long_data: long_data, + // LText: '', + // LTexttb: '', menus_used_list, debug_md5: key, debug_url: url, debug_list: window.btoa(tbs) + } + + if (langSql) { + param.lang_translation = window.btoa(window.encodeURIComponent(langSql)) } param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') @@ -1308,8 +1425,8 @@ PageParam: JSON.stringify({Template: NavBar.type}), menus_rolelist: window.btoa(window.encodeURIComponent(JSON.stringify(roles))), open_edition: NavBar.open_edition, - LText: '', - LTexttb: '' + // LText: '', + // LTexttb: '' } _param.LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(NavBar))) @@ -1350,13 +1467,13 @@ let kparam = { func: 's_kei_link_keyids_addupt', BID: sessionStorage.getItem('appId'), - exec_type: 'y', + exec_type: 'x', LText: '' } kparam.LText = _appViewList.map(item => `select '${item.keys_id}','${item.keys_type}','${item.kei_no}','${item.appkey}','${item.bid}','${sessionStorage.getItem('CloudUserID')}','${item.remark}'`) kparam.LText = kparam.LText.join(' union all ') - kparam.LText = Utils.formatOptions(kparam.LText) + kparam.LText = Utils.formatOptions(kparam.LText, 'x') kparam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') kparam.secretkey = Utils.encrypt('', kparam.timestamp) @@ -1405,10 +1522,10 @@ duration: 2 }) } else { - notification.warning({ - top: 92, - message: res.message, - duration: 5 + Modal.warning({ + width: 400, + title: res.message, + okText: '鐭ラ亾浜�' }) } MKEmitter.emit('completeSave') @@ -1548,12 +1665,6 @@ this.setState({config}) window.GLOB.customMenu = config - - notification.success({ - top: 92, - message: '绮樿创鎴愬姛锛�', - duration: 2 - }) } setHomeView = () => { @@ -1571,7 +1682,7 @@ let param = { func: 's_kei_link_keyids_addupt', BID: sessionStorage.getItem('appId'), - exec_type: 'y', + exec_type: 'x', LText: '' } @@ -1590,10 +1701,12 @@ param.LText = appViewList.map(item => `select '${item.keys_id}','${item.keys_type}','${item.kei_no}','${item.appkey}','${item.bid}','${sessionStorage.getItem('CloudUserID')}','${item.remark}'`) param.LText = param.LText.join(' union all ') - param.LText = Utils.formatOptions(param.LText) + param.LText = Utils.formatOptions(param.LText, 'x') param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt('', param.timestamp) + + const that = this confirm({ title: '纭畾璁剧疆鏈〉闈负棣栭〉鍚楋紵', @@ -1608,6 +1721,10 @@ }) } else { sessionStorage.setItem('appViewList', JSON.stringify(appViewList)) + + that.setState({ + appHomeId: config.MenuID + }) } }) }, @@ -1630,7 +1747,7 @@ let param = { func: 's_kei_link_keyids_addupt', BID: sessionStorage.getItem('appId'), - exec_type: 'y', + exec_type: 'x', LText: '' } @@ -1649,12 +1766,13 @@ param.LText = appViewList.map(item => `select '${item.keys_id}','${item.keys_type}','${item.kei_no}','${item.appkey}','${item.bid}','${sessionStorage.getItem('CloudUserID')}','${item.remark}'`) param.LText = param.LText.join(' union all ') - param.LText = Utils.formatOptions(param.LText) + param.LText = Utils.formatOptions(param.LText, 'x') param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt('', param.timestamp) let hasLogin = config.components.findIndex(item => item.type === 'login') > -1 + const that = this confirm({ title: '纭畾璁剧疆鏈〉闈负鐧诲綍椤靛悧锛�', @@ -1669,6 +1787,10 @@ }) } else { sessionStorage.setItem('appViewList', JSON.stringify(appViewList)) + + that.setState({ + appLoginId: config.MenuID + }) } }) }, @@ -1676,11 +1798,31 @@ }) } + checklog = () => { + const { oriConfig, config } = this.state + + return is(fromJS(oriConfig), fromJS(config)) + } + + updateLogConfig = (config) => { + config.open_edition = this.state.config.open_edition || '' + + this.setState({ + config: null + }, () => { + this.setState({ + config: config + }) + }) + + window.GLOB.customMenu = config + } + render () { - const { view, loading, comloading, activeKey, settingshow, controlshow, MenuId, config, menuloading, eyeopen, needUpdate } = this.state + const { view, loading, comloading, activeKey, settingshow, controlshow, MenuId, config, menuloading, eyeopen, needUpdate, appLoginId, appHomeId } = this.state return ( - <ConfigProvider locale={antdZhCN}> + <> <DndProvider backend={HTML5Backend}> {view !== 'popview' ? <div className={'mk-pc-view '} id="mk-pc-design-view"> {loading ? <Spin className="view-spin" size="large" /> : null} @@ -1725,7 +1867,7 @@ {!controlshow ? <DoubleLeftOutlined onClick={() => {sessionStorage.setItem('controlshow', 'true'); this.setState({controlshow: true})}}/> : null} </div> <div className="wrap"> - <Button type="primary" className={needUpdate ? 'update-tip' : ''} id="save-config" onClick={this.submitConfig} loading={menuloading}>淇濆瓨</Button> + <Button type="primary" className={needUpdate ? 'update-tip' : ''} disabled={!config} id="save-config" onClick={this.submitConfig} loading={menuloading}>淇濆瓨</Button> {config ? <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" checked={config.enabled} onChange={this.onEnabledChange} /> : null} <ArrowLeftOutlined title="鍚庨��" className="back-view" onClick={this.backView}/> {config ? <Debug config={config}/> : null} @@ -1738,11 +1880,11 @@ <PictureController/> <Quotecomponent config={config} updateConfig={this.updateConfig}/> <StyleCombControlButton menu={config} /> - <Button className="mk-border-green" onClick={this.setHomeView}><HomeOutlined /> 璁句负棣栭〉</Button> - <Button className="mk-border-purple" onClick={this.setLoginView}><LoginOutlined/> 璁句负鐧诲綍椤�</Button> + <Button className="mk-border-green" disabled={MenuId === appHomeId} data-title="褰撳墠鑿滃崟涓哄簲鐢ㄩ椤�" onClick={this.setHomeView}><HomeOutlined /> 璁句负棣栭〉</Button> + <Button className="mk-border-purple" disabled={MenuId === appLoginId} data-title="褰撳墠鑿滃崟涓哄簲鐢ㄧ櫥褰曢〉" onClick={this.setLoginView}><LoginOutlined/> 璁句负鐧诲綍椤�</Button> <ReplaceField type="custom" config={config} updateConfig={this.resetConfig}/> <Transfer MenuID={MenuId} /> - <Versions MenuId={MenuId} open_edition={config ? config.open_edition : ''}/> + {config ? <Versions MenuId={MenuId} Template="webPage" checklog={this.checklog} updateConfig={this.updateLogConfig}/> : null} <Button type="default" onClick={this.closeView}>鍏抽棴</Button> </div> </div> @@ -1757,7 +1899,7 @@ <StyleController /> <StyleCombController /> <ModalController /> - </ConfigProvider> + </> ) } } -- Gitblit v1.8.0