| | |
| | | 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 md5 from 'md5' |
| | | |
| | | import Api from '@/api' |
| | | import Utils, { setGLOBFuncs } from '@/utils/utils.js' |
| | |
| | | const _locale = antdZhCN |
| | | |
| | | const MenuForm = asyncComponent(() => import('./menuform')) |
| | | const TableNodes = asyncComponent(() => import('@/menu/tablenodes')) |
| | | const TableSource = asyncComponent(() => import('./tablesource')) |
| | | const Header = asyncComponent(() => import('@/menu/header')) |
| | | const MenuShell = asyncComponent(() => import('@/menu/tableshell')) |
| | |
| | | const StyleController = asyncComponent(() => import('@/menu/stylecontroller')) |
| | | const ReplaceField = asyncComponent(() => import('@/menu/replaceField')) |
| | | const Versions = asyncComponent(() => import('@/menu/versions')) |
| | | const Unattended = asyncComponent(() => import('@/templates/zshare/unattended')) |
| | | const UrlFieldComponent = asyncComponent(() => import('@/menu/urlfieldcomponent')) |
| | | const ModalController = asyncComponent(() => import('@/menu/modalconfig/controller')) |
| | | const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent')) |
| | |
| | | config.uuid = MenuId |
| | | config.MenuID = MenuId |
| | | config.Template = 'BaseTable' |
| | | config.components.forEach(item => { |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | | tab.components[0].name = tab.label |
| | | }) |
| | | } else { |
| | | item.name = '主表' |
| | | } |
| | | }) |
| | | } |
| | | |
| | | config.open_edition = result.open_edition || '' |
| | |
| | | }) |
| | | } |
| | | |
| | | getMenuMessage = (delButtons) => { |
| | | getMenuMessage = (delButtons, tbs) => { |
| | | 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 { |
| | | item.action && item.action.forEach(btn => { |
| | | config.components.forEach(item => { |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | | if (tab.components[0].$tables) { |
| | | tbs.push(...tab.components[0].$tables) |
| | | } |
| | | tab.components[0].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`) |
| | | buttons.push(`select '${btn.uuid}' as menuid, '${tab.label + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`) |
| | | _sort++ |
| | | }) |
| | | item.cols && item.cols.forEach(col => { |
| | | tab.components[0].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`) |
| | | buttons.push(`select '${btn.uuid}' as menuid, '${tab.label + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`) |
| | | _sort++ |
| | | }) |
| | | }) |
| | | }) |
| | | } else { |
| | | if (item.$tables) { |
| | | tbs.push(...item.$tables) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | traversal(config.components) |
| | | item.action.forEach(btn => { |
| | | if (btn.hidden === 'true') { |
| | | delButtons.push(btn.uuid) |
| | | return |
| | | } |
| | | buttons.push(`select '${btn.uuid}' as menuid, '${btn.label}' as menuname, '${_sort * 10}' as Sort`) |
| | | _sort++ |
| | | }) |
| | | 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, '${btn.label}' as menuname, '${_sort * 10}' as Sort`) |
| | | _sort++ |
| | | }) |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | return buttons |
| | | } |
| | |
| | | config.enabled = false |
| | | } |
| | | |
| | | let tbs = [] |
| | | let delButtons = [] |
| | | let btns = this.getMenuMessage(delButtons, tbs) |
| | | let arr = [] |
| | | tbs = tbs.filter(tb => { |
| | | let _tb = tb.toLowerCase() |
| | | |
| | | if (arr.includes(_tb)) return false |
| | | arr.push(_tb) |
| | | |
| | | return true |
| | | }) |
| | | tbs.sort() |
| | | if (tbs.length && sessionStorage.getItem('mk_tb_names')) { |
| | | let names = sessionStorage.getItem('mk_tb_names') |
| | | tbs = tbs.filter(tb => names.indexOf(',' + tb.toLowerCase() + ',') > -1) |
| | | } |
| | | tbs = tbs.map(tb => `'${tb}'`).join(';') |
| | | |
| | | let key = md5(config.uuid + tbs.toLowerCase()) |
| | | let url = '' |
| | | |
| | | if (config.tbkey === key) { |
| | | key = '' |
| | | } else { |
| | | let urlparam = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param))) |
| | | urlparam.type = 'admin' |
| | | urlparam.MenuType = 'BaseTable' |
| | | url = window.btoa(window.encodeURIComponent(JSON.stringify(urlparam))) |
| | | config.tbkey = key |
| | | } |
| | | |
| | | let param = { |
| | | func: 'sPC_TrdMenu_AddUpt', |
| | | FstID: config.fstMenuId || '', |
| | |
| | | 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: '' |
| | | LTexttb: '', |
| | | 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) |
| | |
| | | LText: [] |
| | | } |
| | | |
| | | let delButtons = [] |
| | | |
| | | btnParam.LText = this.getMenuMessage(delButtons) |
| | | btnParam.LText = btns |
| | | btnParam.LText = btnParam.LText.join(' union all ') |
| | | |
| | | btnParam.LText = Utils.formatOptions(btnParam.LText) |
| | |
| | | const { config } = this.state |
| | | let error = '' |
| | | |
| | | let check = (components) => { |
| | | components.forEach(item => { |
| | | if (error) return |
| | | config.components.forEach(item => { |
| | | if (error) return |
| | | |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | | check(tab.components) |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | | if (!tab.components[0].errors || tab.components[0].errors.length === 0 || error) return |
| | | tab.components[0].errors.forEach(err => { |
| | | if (err.level !== 0 || error) return |
| | | error = `子表《${tab.label}》${err.detail}` |
| | | }) |
| | | return |
| | | } else if (item.type === 'group') { |
| | | check(item.components) |
| | | return |
| | | } else if (!item.errors || item.errors.length === 0) { |
| | | return |
| | | } |
| | | |
| | | }) |
| | | } else { |
| | | item.errors.forEach(err => { |
| | | if (err.level !== 0 || error) return |
| | | error = `组件《${item.name}》${err.detail}` |
| | | error = `主表 ${err.detail}` |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | check(config.components) |
| | | } |
| | | }) |
| | | |
| | | if (show && error) { |
| | | notification.warning({ |
| | |
| | | <div style={{paddingLeft: '15px'}}> {config && config.MenuName} </div> |
| | | } bordered={false} extra={ |
| | | <div> |
| | | {config ? <Unattended config={config} updateConfig={this.updateConfig}/> : null} |
| | | <Versions MenuId={MenuId} open_edition={config ? config.open_edition : ''}/> |
| | | <TableNodes config={config} /> |
| | | <ReplaceField type="custom" config={config} updateConfig={this.resetConfig}/> |
| | | <Switch className="big" checkedChildren="启" unCheckedChildren="停" checked={config && config.enabled} onChange={this.onEnabledChange} /> |
| | | <Button type="primary" id="save-config" onClick={this.submitConfig} loading={menuloading}>保存</Button> |