| | |
| | | import { is, fromJS } from 'immutable' |
| | | import moment from 'moment' |
| | | import HTML5Backend from 'react-dnd-html5-backend' |
| | | import { 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' |
| | | |
| | |
| | | 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')) |
| | |
| | | delete config.force |
| | | } |
| | | |
| | | if (config.MenuID === 'home_page_id' || MenuType === 'billPrint') { |
| | | config.permission = 'false' |
| | | } |
| | | |
| | | let long_data = '' |
| | | if (config.enabled) { |
| | | let sqls = getAllSqls(config) |
| | |
| | | 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 |
| | | }) |
| | | |
| | | let perm = true |
| | | if (config.permission === 'false' || config.sqlperm === 'false') { |
| | | perm = false |
| | | } |
| | | |
| | | 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))}`) |
| | | 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, |
| | | md5: item.md5 || '', |
| | | luser: item.luser === true |
| | | } |
| | | }) |
| | |
| | | |
| | | if (config.cacheUseful !== 'true') { |
| | | config.components = this.resetSyncQuery(config.components) |
| | | } |
| | | |
| | | if (config.MenuID === 'home_page_id') { |
| | | config.permission = 'false' |
| | | } |
| | | |
| | | let tbs = [] |
| | |
| | | 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', |
| | |
| | | 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, msg, backend: 'level1', urlFields}), |
| | | 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, |
| | | long_data: long_data, |
| | | debug_md5: key, |
| | |
| | | }, 300 + (+sessionStorage.getItem('mkDelay'))) |
| | | } |
| | | |
| | | netError = (error) => { |
| | | netError = () => { |
| | | this.setState({ |
| | | menuloading: false |
| | | }) |
| | | |
| | | if (!error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '保存失败,请检查网络是否正常。', |
| | | duration: 5 |
| | | }) |
| | | } |
| | | MKEmitter.emit('completeSave') |
| | | } |
| | | |
| | |
| | | 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 |
| | |
| | | const { oriConfig, config } = this.state |
| | | |
| | | 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) => { |
| | |
| | | /> |
| | | {/* 表名添加 */} |
| | | <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> |
| | | {/* 组件添加 */} |
| | |
| | | </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" disabled={menuloading} 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}/>} |