From 03a22ec6f9ad7303d10b4c65bb5bc6fa5cbd448a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 22 十月 2022 23:21:42 +0800 Subject: [PATCH] 2022-10-22 --- src/views/tabledesign/index.jsx | 141 +++++++++++++++++++++++++++++++++------------- 1 files changed, 101 insertions(+), 40 deletions(-) diff --git a/src/views/tabledesign/index.jsx b/src/views/tabledesign/index.jsx index 3ebbafb..f57afa6 100644 --- a/src/views/tabledesign/index.jsx +++ b/src/views/tabledesign/index.jsx @@ -6,6 +6,7 @@ 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' @@ -24,6 +25,7 @@ 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')) @@ -31,6 +33,7 @@ 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')) @@ -392,6 +395,15 @@ 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 || '' @@ -412,42 +424,62 @@ }) } - 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 } @@ -473,6 +505,38 @@ 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 || '', @@ -484,10 +548,13 @@ 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) @@ -505,9 +572,7 @@ LText: [] } - let delButtons = [] - - btnParam.LText = this.getMenuMessage(delButtons) + btnParam.LText = btns btnParam.LText = btnParam.LText.join(' union all ') btnParam.LText = Utils.formatOptions(btnParam.LText) @@ -648,30 +713,24 @@ 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({ @@ -778,7 +837,9 @@ <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> -- Gitblit v1.8.0