From 92664ef80a97a63fde223b14097ccda3ae6ff183 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 24 四月 2025 14:31:57 +0800 Subject: [PATCH] Merge branch 'positec' into dms --- src/views/menudesign/index.jsx | 304 ++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 241 insertions(+), 63 deletions(-) diff --git a/src/views/menudesign/index.jsx b/src/views/menudesign/index.jsx index 3a98723..d7d9dc1 100644 --- a/src/views/menudesign/index.jsx +++ b/src/views/menudesign/index.jsx @@ -4,16 +4,16 @@ 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, Spin } from 'antd' -import { DoubleLeftOutlined, DoubleRightOutlined, EyeOutlined, EyeInvisibleOutlined } from '@ant-design/icons' +import { notification, Modal, Collapse, Switch, Button, Typography, Spin, message, Dropdown } from 'antd' +import { DoubleLeftOutlined, DoubleRightOutlined, EyeOutlined, EyeInvisibleOutlined, CopyOutlined, DownOutlined } from '@ant-design/icons' import html2canvas from 'html2canvas' import md5 from 'md5' import Api from '@/api' -import Utils, { setGLOBFuncs } from '@/utils/utils.js' -import antdZhCN from 'antd/es/locale/zh_CN' +import Utils from '@/utils/utils.js' +import { langs } from '@/store/options' import MKEmitter from '@/utils/events.js' -import { getTables, getFuncsAndInters } from '@/utils/utils-custom.js' +import { getTables, getFuncsAndInters, getOutMessage, getLangTrans, getAllSqls } from '@/utils/utils-custom.js' import asyncComponent from '@/utils/asyncComponent' import '@/assets/css/design.scss' @@ -22,7 +22,6 @@ const { Panel } = Collapse const { confirm } = Modal const { Paragraph } = Typography -const _locale = antdZhCN const MenuForm = asyncComponent(() => import('./menuform')) const HomeForm = asyncComponent(() => import('./homeform')) @@ -36,8 +35,12 @@ const PasteController = asyncComponent(() => import('@/menu/pastecontroller')) const StyleController = asyncComponent(() => import('@/menu/stylecontroller')) const ReplaceField = asyncComponent(() => import('@/menu/replaceField')) +const DelExtraDb = asyncComponent(() => import('@/menu/delExtraDb')) +const LowerField = asyncComponent(() => import('@/menu/lowerField')) +const LowerText = asyncComponent(() => import('@/menu/lowerText')) const Debug = asyncComponent(() => import('@/menu/debug')) const NormalCss = asyncComponent(() => import('@/menu/normalCss')) +const NormalCopy = asyncComponent(() => import('@/menu/normalCopy')) const Versions = asyncComponent(() => import('@/menu/versions')) const TableNodes = asyncComponent(() => import('@/menu/tablenodes')) const SysInterface = asyncComponent(() => import('@/menu/sysinterface')) @@ -67,6 +70,7 @@ eyeopen: false, view: '', popConfig: null, + langName: '', needUpdate: false } @@ -98,12 +102,17 @@ sessionStorage.setItem('MenuType', param.MenuType || 'custom') + if (param.lang) { + sessionStorage.setItem('lang', param.lang) + } + this.setState({ MenuType: param.MenuType, MenuId: param.MenuId || param.MenuID, ParentId: param.ParentId || '', MenuName: param.MenuName || '', MenuNo: param.MenuNo || '', + langName: sessionStorage.getItem('lang') !== 'zh-CN' && langs[sessionStorage.getItem('lang')] ? `锛�${langs[sessionStorage.getItem('lang')]}锛塦 : '' }, () => { this.getMenuParam() }) @@ -125,9 +134,10 @@ MKEmitter.addListener('changePopview', this.initPopview) MKEmitter.addListener('triggerMenuSave', this.triggerMenuSave) + MKEmitter.addListener('changeEditMenu', this.changeEditMenu) setTimeout(() => { this.getRoleFields() - setGLOBFuncs() + // setGLOBFuncs() }, 1000) document.onkeydown = (event) => { @@ -196,6 +206,49 @@ } MKEmitter.removeListener('changePopview', this.initPopview) MKEmitter.removeListener('triggerMenuSave', this.triggerMenuSave) + MKEmitter.removeListener('changeEditMenu', this.changeEditMenu) + } + + changeEditMenu = (menu) => { + if (menu.MenuID && menu.MenuID.length === 3 && menu.MenuNo && !this.menuLoading) { + this.menuLoading = true + let param = { + func: 'sPC_Get_LongParam', + MenuID: menu.MenuID[2] + } + + Api.getCloudConfig(param).then(result => { + this.menuLoading = false + 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) { + let _param = { + MenuId: menu.MenuID[2], + MenuID: menu.MenuID[2], + ParentId: menu.MenuID[1], + MenuName: menu.MenuName, + MenuNo: menu.MenuNo + } + if (config.Template === 'BaseTable') { + _param = window.btoa(window.encodeURIComponent(JSON.stringify(_param))) + window.open(`#/tabledesign/${_param}`) + } else if (config.Template === 'CustomPage') { + _param.MenuType = 'custom' + _param = window.btoa(window.encodeURIComponent(JSON.stringify(_param))) + window.open(`#/menudesign/${_param}`) + } + } + } + }) + } } triggerMenuSave = () => { @@ -610,7 +663,7 @@ if (item.action && item.action.length > 0) { item.action.forEach(btn => { - if (btn.hidden === 'true') return + if (btn.hidden === 'true' || btn.permission === 'false') return buttons.push(`select '${btn.uuid}' as menuid, '${item.name + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`) _sort++ }) @@ -625,13 +678,13 @@ item.subcards.forEach(card => { card.elements && card.elements.forEach(cell => { if (cell.eleType !== 'button') return - if (cell.hidden === 'true') return + if (cell.hidden === 'true' || cell.permission === 'false') return buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`) _sort++ }) card.backElements && card.backElements.forEach(cell => { if (cell.eleType !== 'button') return - if (cell.hidden === 'true') return + if (cell.hidden === 'true' || cell.permission === 'false') return buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`) _sort++ }) @@ -639,7 +692,7 @@ } else if (item.type === 'balcony') { item.elements && item.elements.forEach(cell => { if (cell.eleType !== 'button') return - if (cell.hidden === 'true') return + if (cell.hidden === 'true' || cell.permission === 'false') return buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`) _sort++ }) @@ -650,7 +703,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 buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`) _sort++ }) @@ -728,6 +781,20 @@ duration: 5 }) return + } else if (this.checklog()) { + if (sessionStorage.getItem('langList') && !config.trans) { + + } else if (config.enabled && !config.allSqls) { + + } else { + notification.success({ + top: 92, + message: '褰撳墠閰嶇疆鏈慨鏀癸紝鏃犻渶淇濆瓨銆�', + duration: 5 + }) + MKEmitter.emit('completeSave') + return + } } this.setState({ @@ -745,16 +812,60 @@ delete config.force } + if (config.MenuID === 'home_page_id' || MenuType === 'billPrint') { + config.permission = 'false' + } + + 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 perm = true + if (config.permission === 'false' || config.sqlperm === 'false') { + perm = false + } + + config.allSqls = sqls.map(item => { + let v_id = _t + getguid() + + long_data.push(`${md5(window.GLOB.appkey + v_id)},${item.uuid},${v_id},${window.btoa(window.encodeURIComponent(item.LText))},${perm ? item.roleId || '' : ''}`) + + return { + uuid: item.uuid, + v_id: v_id, + type: item.type, + reps: item.reps, + luser: item.luser === true + } + }) + + long_data = long_data.join(';') + } else { + delete config.allSqls + } + if (config.cacheUseful !== 'true') { config.components = this.resetSyncQuery(config.components) } - if (config.MenuID === 'home_page_id') { - config.permission = 'false' - } - let tbs = [] let btns = this.getMenuMessage(config, tbs) + + if (config.permission === 'false') { + btns = [] + } + let arr = [] tbs = tbs.filter(tb => { let _tb = tb.toLowerCase() @@ -779,11 +890,23 @@ } else { let urlparam = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param))) urlparam.type = 'admin' + urlparam.lang = sessionStorage.getItem('lang') + url = window.btoa(window.encodeURIComponent(JSON.stringify(urlparam))) config.tbkey = key } let interfaces = getFuncsAndInters(config) + let msg = getOutMessage(config) + let urlFields = config.urlFields ? config.urlFields.join(',') : '' + let langSql = getLangTrans(config) + let pds = 'false' + if (config.interfaces && config.enabled) { + config.interfaces.forEach(item => { + if (item.status !== 'true') return + pds = 'true' + }) + } let param = { func: 'sPC_TrdMenu_AddUpt', @@ -795,19 +918,21 @@ EasyCode: config.easyCode || '', Template: 'CustomPage', MenuName: config.MenuName || '', - PageParam: JSON.stringify({Template: 'CustomPage', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false', menuColor: config.menuColor || '', interfaces}), + PageParam: JSON.stringify({Template: 'CustomPage', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false', menuColor: config.menuColor || '', interfaces, msg, pds, backend: 'level1', enabled: config.enabled, urlFields}), open_edition: config.open_edition, - LText: '', - LTexttb: '', + long_data: long_data, debug_md5: key, debug_url: url, debug_list: window.btoa(tbs), LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(config))) } - param.LText = Utils.formatOptions(param.LText) + if (langSql) { + param.lang_translation = window.btoa(window.encodeURIComponent(langSql)) + } + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) + param.secretkey = Utils.encrypt('', param.timestamp) let btnParam = { // 娣诲姞鑿滃崟鎸夐挳 func: 'sPC_Button_AddUpt', @@ -815,14 +940,14 @@ ParentID: config.uuid, MenuNo: config.MenuNo, Template: 'CustomPage', - button_proc_edition: 'Y' + button_proc_edition: 'Y', + exec_type: 'x' } btnParam.LText = btns.join(' union all ') - - btnParam.LText = Utils.formatOptions(btnParam.LText) + btnParam.LText = Utils.formatOptions(btnParam.LText, 'x') btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp) + btnParam.secretkey = Utils.encrypt('', btnParam.timestamp) new Promise(resolve => { if (MenuType === 'billPrint') { // 鎵撳嵃鐢熸垚椤甸潰鏁堟灉鍥� @@ -839,10 +964,21 @@ Api.fileuploadbase64(param).then(result => { if (result.status) { + let url = result.Images + let baseurl = '' + + if (window.GLOB.cloudServiceApi) { + baseurl = window.GLOB.cloudServiceApi.replace(/webapi(.*)$/, '') + } else { + baseurl = window.GLOB.baseurl + } + + url = url.match(/^http/) || url.match(/^\/\//) ? url : baseurl + url + Api.getCloudConfig({ func: 's_PrintTemplateMSub', ID: config.uuid, - Images: Utils.getcloudurl(result.Images), + Images: url, Remark: '', temp_type: 'billprint', }).then(response => { @@ -923,18 +1059,11 @@ }, 300 + (+sessionStorage.getItem('mkDelay'))) } - netError = (error) => { + netError = () => { this.setState({ menuloading: false }) - if (!error) { - notification.warning({ - top: 92, - message: '淇濆瓨澶辫触锛岃妫�鏌ョ綉缁滄槸鍚︽甯搞��', - duration: 5 - }) - } MKEmitter.emit('completeSave') } @@ -1087,16 +1216,19 @@ insert = (item) => { let config = fromJS(this.state.config).toJS() - config.components.push(item) + if (item.copyType === 'components') { + config.components.push(...item.components) + if (!config.interfaces) { + config.interfaces = item.interfaces + } else { + config.interfaces.push(...item.interfaces) + } + } else { + config.components.push(item) + } this.setState({config}) window.GLOB.customMenu = config - - notification.success({ - top: 92, - message: '绮樿创鎴愬姛锛�', - duration: 2 - }) } changeSetting = () => { @@ -1114,9 +1246,48 @@ return is(fromJS(oriConfig), fromJS(config)) } + copyMenu = () => { + const { config } = this.state + + if (!config.enabled) { + notification.warning({ + top: 92, + message: '鑿滃崟鏈惎鐢紝涓嶅彲澶嶅埗銆�', + duration: 5 + }) + } else if (config.components.length === 0) { + notification.warning({ + top: 92, + message: '鏈坊鍔犵粍浠讹紝涓嶅彲澶嶅埗銆�', + duration: 5 + }) + } else { + let msg = { copyType: 'components', type: 'admin' } + + msg.components = config.components || [] + msg.interfaces = config.interfaces || [] + + try { + msg = window.btoa(window.encodeURIComponent(JSON.stringify(msg))) + } catch (e) { + console.warn('Stringify Failure') + msg = '' + } + + let oInput = document.createElement('input') + oInput.value = msg + document.body.appendChild(oInput) + oInput.select() + document.execCommand('Copy') + document.body.removeChild(oInput) + message.success('澶嶅埗鎴愬姛銆�') + } + } + updateLogConfig = (config) => { config.fstMenuId = this.state.config.fstMenuId || config.fstMenuId || '' config.parentId = this.state.config.parentId || config.parentId || '' + config.open_edition = this.state.config.open_edition || '' this.setState({ config: null @@ -1130,11 +1301,11 @@ } render () { - const { view, comloading, MenuType, MenuId, config, settingshow, ParentId, menuloading, eyeopen, needUpdate } = this.state + const { view, comloading, MenuType, MenuId, config, settingshow, ParentId, menuloading, eyeopen, needUpdate, langName } = this.state return ( - <ConfigProvider locale={_locale}> - <Header menuName={config ? config.MenuName : ''}/> + <> + <Header menuName={config ? config.MenuName + langName : ''}/> <DndProvider backend={HTML5Backend}> {view !== 'popview' ? <div className={'pc-menu-view ' + (MenuType || '')}> <div className="menu-body"> @@ -1168,8 +1339,10 @@ /> {/* 琛ㄥ悕娣诲姞 */} <TableComponent config={config} updatetable={this.updateConfig}/> - <Paragraph style={{padding: '15px 0px 0px 18px'}} copyable={{ text: MenuId }}>鑿滃崟ID</Paragraph> + <Paragraph style={{padding: '15px 0px 0px 32px'}} copyable={{ text: MenuId }}>鑿滃崟ID锛�</Paragraph> <NormalCss config={config} updateConfig={this.updateConfig}/> + <Paragraph style={{padding: '0px 0px 0px 18px'}}>澶嶅埗鑿滃崟涓嬫墍鏈夌粍浠讹細<CopyOutlined onClick={this.copyMenu} style={{cursor: 'pointer', color: '#1890ff'}} /></Paragraph> + <NormalCopy /> </> : null} </Panel> {/* 缁勪欢娣诲姞 */} @@ -1185,24 +1358,29 @@ </Collapse> </div> <div className={'menu-view' + (menuloading ? ' saving' : '') + (eyeopen ? ' eye-open' : '')}> - <Card bordered={false} extra={ - <div className="mk-opeartion-list"> - {config ? <Debug config={config}/> : null} - <Button className="mk-border-purple" onClick={() => this.setState({eyeopen: !eyeopen})}>{!eyeopen ? <EyeOutlined /> : <EyeInvisibleOutlined />} 缁勪欢鍚�</Button> - {config ? <Versions MenuId={MenuId} Template="CustomPage" checklog={this.checklog} updateConfig={this.updateLogConfig}/> : null} - <TableNodes config={config} /> - <ReplaceField type="custom" config={config} updateConfig={this.resetConfig}/> - <SysInterface config={config} updateConfig={this.updateConfig}/> + <div className="mk-opeartion-list"> + {config ? <Debug config={config}/> : null} + <Button className="mk-border-purple" onClick={() => this.setState({eyeopen: !eyeopen})}>{!eyeopen ? <EyeOutlined /> : <EyeInvisibleOutlined />} 缁勪欢鍚�</Button> + {config ? <Versions MenuId={MenuId} Template="CustomPage" checklog={this.checklog} updateConfig={this.updateLogConfig}/> : null} + <TableNodes config={config} /> + <SysInterface config={config} updateConfig={this.updateConfig}/> + <StyleCombControlButton menu={config} /> + <PasteController vType="admin" insert={this.insert} /> + {config ? <Dropdown placement="bottomCenter" overlay={<div className="mk-opeartion-dropdown-wrap"> + <ReplaceField config={config} updateConfig={this.resetConfig}/> + <LowerField config={config} updateConfig={this.resetConfig}/> + <DelExtraDb config={config} updateConfig={this.resetConfig}/> + <LowerText /> <PictureController/> - <StyleCombControlButton menu={config} /> - <PasteController insert={this.insert} /> - {config ? <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" checked={config.enabled} onChange={this.onEnabledChange} /> : null} - <Button type="primary" id="save-config" className={needUpdate ? 'update-tip' : ''} 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} /> : <Spin className="loading-config" size="large" />} - </Card> + <Button onClick={() => window.open('#/ai')}>DeepSeek</Button> + </div>} trigger={['hover']}> + <div className="mk-button-more">鏇村<DownOutlined/></div> + </Dropdown> : null} + {config ? <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" checked={config.enabled} onChange={this.onEnabledChange} /> : null} + <Button type="primary" id="save-config" disabled={!config} className={needUpdate ? 'update-tip' : ''} onClick={this.submitConfig} loading={menuloading}>淇濆瓨</Button> + <Button type="default" disabled={menuloading} onClick={this.closeView}>鍏抽棴</Button> + </div> + {config && !comloading ? <MenuShell menu={config} handleList={this.updateConfig} /> : <Spin className="loading-config" size="large" />} </div> </div> </div> : <PopView btn={this.state.popConfig} save={this.submitPopConfig} cancel={this.closePop}/>} @@ -1210,7 +1388,7 @@ <ModalController /> <StyleController /> <StyleCombController /> - </ConfigProvider> + </> ) } } -- Gitblit v1.8.0