From af6486b3629d23e426ce85b87dbc20dfa15b1afe Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 07 十一月 2022 18:50:27 +0800 Subject: [PATCH] 2022-11-07 --- src/templates/comtableconfig/index.jsx | 477 ++++++++++++++++++++++++++++++----------------------------- 1 files changed, 242 insertions(+), 235 deletions(-) diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index 7ae69ce..09683e2 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -1,6 +1,5 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { connect } from 'react-redux' import { is, fromJS } from 'immutable' import { DndProvider } from 'react-dnd' import HTML5Backend from 'react-dnd-html5-backend' @@ -10,9 +9,8 @@ import Api from '@/api' import Utils from '@/utils/utils.js' +import MKEmitter from '@/utils/events.js' import { updateCommonTable } from '@/utils/utils-update.js' -import zhCN from '@/locales/zh-CN/model.js' -import enUS from '@/locales/en-US/model.js' import asyncComponent from '@/utils/asyncComponent' import SearchComponent from '@/templates/sharecomponent/searchcomponent' @@ -30,6 +28,7 @@ const Versions = asyncComponent(() => import('@/menu/versions')) const UrlFieldComponent = asyncComponent(() => import('@/menu/urlfieldcomponent')) const ReplaceField = asyncComponent(() => import('@/menu/replaceField')) +const UpdateTable = asyncComponent(() => import('./updatetable')) const Unattended = asyncComponent(() => import('@/templates/zshare/unattended')) const EditComponent = asyncComponent(() => import('@/templates/zshare/editcomponent')) const SettingComponent = asyncComponent(() => import('@/templates/sharecomponent/settingcomponent')) @@ -48,7 +47,6 @@ } state = { - dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, config: null, // 椤甸潰閰嶇疆 formlist: null, // 鎼滅储鏉′欢銆佹寜閽�佹樉绀哄垪琛ㄥ崟瀛楁 menuloading: false, // 鑿滃崟淇濆瓨涓� @@ -63,7 +61,7 @@ thawButtons: [], // 宸查�夋嫨瑕佽В鍐荤殑鎸夐挳 activeKey: '0', // 榛樿灞曞紑鍩烘湰淇℃伅 chartview: null, // 褰撳墠瑙嗗浘 - openEdition: '' // 缂栬緫鐗堟湰鏍囪锛岄槻姝㈠浜烘搷浣� + openEdition: '', // 缂栬緫鐗堟湰鏍囪锛岄槻姝㈠浜烘搷浣� } /** @@ -78,9 +76,6 @@ if (!_LongParam) { _config = fromJS(Source.baseConfig).toJS() - if (!menu.isSubtable) { // 涓嶆槸閫夋嫨涓诲瓙琛ㄦ椂锛岄殣钘忔爣绛鹃〉 - _config.tabgroups = [{ uuid: 'tabs', sublist: [] }] - } _config.isAdd = true } else { _config = _LongParam @@ -113,12 +108,6 @@ curuuid: uuid, Template: 'Modal' }) - } else if (item.OpenType === 'tab' && item.tabTemplate === 'FormTab') { // 鍚湁瀛愰厤缃」鐨勬寜閽�(鏍囩椤垫墦寮�) - _oriActions.push({ - prebtn: fromJS(item).toJS(), - curuuid: uuid, - Template: 'FormTab' - }) } item.uuid = uuid @@ -140,7 +129,7 @@ } this.setState({ - chartview: _config.charts[0].uuid, + chartview: _config.charts ? _config.charts[0].uuid : '', config: _config, openEdition: menu.open_edition || '', activeKey: menu.activeKey || '0', @@ -154,6 +143,55 @@ */ componentDidMount () { this.reloadTab(false) + + document.onkeydown = (event) => { + let e = event || window.event + let keyCode = e.keyCode || e.which || e.charCode + let preKey = '' + + if (e.ctrlKey) { + preKey = 'ctrl' + } + if (e.shiftKey) { + preKey = 'shift' + } else if (e.altKey) { + preKey = 'alt' + } + + if (!preKey || !keyCode) return + + let _shortcut = `${preKey}+${keyCode}` + + if (_shortcut === 'ctrl+83') { + let modals = document.querySelectorAll('.mk-pop-modal') + let msg = null + for (let i = 0; i < modals.length; i++) { + if (msg) { + break + } + + let node = modals[i].querySelector('.mk-com-name') + + if (node) { + msg = node.innerText + } + } + if (msg) { + notification.warning({ + top: 92, + message: '璇蜂繚瀛�' + msg, + duration: 5 + }) + return false + } + + let node = document.getElementById('save-config') + if (node && node.click) { + node.click() + } + return false + } + } } /** @@ -163,6 +201,7 @@ this.setState = () => { return } + document.onkeydown = () => {} } /** @@ -263,7 +302,7 @@ if (!_config.fstMenuId || !_config.ParentId || !_config.MenuName || !_config.MenuNo) { notification.warning({ top: 92, - message: this.state.dict['model.menu.basemsg'], + message: '璇峰畬鍠勮彍鍗曞熀鏈俊鎭紒', duration: 5 }) this.setState({activeKey: '0'}) @@ -297,6 +336,11 @@ }) } + // 鎸夐挳涓嶅瓨鍦ㄦ椂锛屽幓鎺夌粦瀹氱殑鍙屽嚮鎸夐挳 + if (_config.setting.doubleClick && _config.action.findIndex((item) => item.uuid === _config.setting.doubleClick) === -1) { + _config.setting.doubleClick = '' + } + // 鏈缃暟鎹簮鎴栨爣绛句笉鍚堟硶鏃讹紝鍚敤鐘舵�佷负false let vresult = this.verifyconfig(_config) if (vresult !== true) { @@ -313,11 +357,12 @@ }) } + let _LongParam = '' + let reload = _config.isAdd + // 淇濆瓨鏃跺垹闄ら厤缃被鍨嬶紝system 銆乽ser delete _config.type delete _config.isAdd - - let _LongParam = '' try { _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config))) @@ -349,6 +394,7 @@ } _config.action.forEach(item => { + if (item.hidden === 'true') return _sort++ if (item.OpenType === 'popview') { btntabs.push({ @@ -428,139 +474,143 @@ param.open_edition = openEdition } - // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣� - // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆 - new Promise(resolve => { - if (delActions.length > 0) { - let deffers = delActions.map(item => { - let _param = { - func: 'sPC_MainMenu_Del', - MenuID: item.card ? item.card.uuid : item.uuid - } - - if (item.type === 'action') { - let _ParentParam = null - - try { - _ParentParam = window.btoa(window.encodeURIComponent(JSON.stringify(item.card))) - } catch (e) { - console.warn('Stringify Failure') - _ParentParam = null + setTimeout(() => { + // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣� + // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆 + new Promise(resolve => { + if (delActions.length > 0) { + let deffers = delActions.map(item => { + let _param = { + func: 'sPC_MainMenu_Del', + MenuID: item.card ? item.card.uuid : item.uuid } - if (_ParentParam) { // 鍒犻櫎鎸夐挳鏃讹紝淇濆瓨鎸夐挳閰嶇疆淇℃伅锛岀敤浜庢仮澶嶆寜閽� - _param.ParentParam = _ParentParam - } - } + if (item.type === 'action') { + let _ParentParam = null - return new Promise(resolve => { - Api.getSystemConfig(_param).then(response => { - resolve(response) + try { + _ParentParam = window.btoa(window.encodeURIComponent(JSON.stringify(item.card))) + } catch (e) { + console.warn('Stringify Failure') + _ParentParam = null + } + + if (_ParentParam) { // 鍒犻櫎鎸夐挳鏃讹紝淇濆瓨鎸夐挳閰嶇疆淇℃伅锛岀敤浜庢仮澶嶆寜閽� + _param.ParentParam = _ParentParam + } + } + + return new Promise(resolve => { + Api.getSystemConfig(_param).then(response => { + resolve(response) + }) }) }) - }) - Promise.all(deffers).then(result => { - let error = null - result.forEach(response => { - if (!response.status) { - error = response + Promise.all(deffers).then(result => { + let error = null + result.forEach(response => { + if (!response.status) { + error = response + } + }) + + if (error) { + this.setState({ + menuloading: false, + menucloseloading: false + }) + notification.warning({ + top: 92, + message: error.message, + duration: 5 + }) + resolve(false) + } else { + this.setState({ + delActions: [] + }) + resolve(true) } }) + } else if (delActions.length === 0) { + resolve(true) + } + }).then(resp => { + if (resp === false) return - if (error) { + if (thawButtons.length > 0) { + let defers = thawButtons.map(item => { + return new Promise((resolve) => { + Api.getSystemConfig({ + func: 'sPC_MainMenu_ReDel', + MenuID: item + }).then(res => { + if (res.status) { + resolve('') + } else { + resolve(res.message) + } + }) + }) + }) + + return Promise.all(defers) + } else { + return true + } + }).then(res => { + if (res === true || res === false) return res + + let msg = res.filter(Boolean)[0] + if (msg) { + notification.warning({ + top: 92, + message: msg, + duration: 5 + }) + return false + } else { + this.setState({ + thawButtons: [] + }) + return true + } + }).then(resp => { + if (resp === false) return + let localParam = fromJS(param).toJS() + Api.getSystemConfig(param).then(response => { + if (response.status) { + this.setState({ + config: _config, + openEdition: response.open_edition || '', + originMenu: fromJS(_config).toJS() + }, () => { + reload && MKEmitter.emit('revert') + }) + + localParam.func = 'sPC_TrdMenu_AddUpt_For_Local' + delete localParam.LongParam + delete localParam.PageParam + delete localParam.Template + delete localParam.Sort + delete localParam.EasyCode + delete localParam.open_edition + + this.submitAction(btnParam, tabParam, localParam) + } else { this.setState({ menuloading: false, menucloseloading: false }) notification.warning({ top: 92, - message: error.message, + message: response.message, duration: 5 }) - resolve(false) - } else { - this.setState({ - delActions: [] - }) - resolve(true) } }) - } else if (delActions.length === 0) { - resolve(true) - } - }).then(resp => { - if (resp === false) return - - if (thawButtons.length > 0) { - let defers = thawButtons.map(item => { - return new Promise((resolve) => { - Api.getSystemConfig({ - func: 'sPC_MainMenu_ReDel', - MenuID: item - }).then(res => { - if (res.status) { - resolve('') - } else { - resolve(res.message) - } - }) - }) - }) - - return Promise.all(defers) - } else { - return true - } - }).then(res => { - if (res === true || res === false) return res - - let msg = res.filter(Boolean)[0] - if (msg) { - notification.warning({ - top: 92, - message: msg, - duration: 5 - }) - return false - } else { - this.setState({ - thawButtons: [] - }) - return true - } - }).then(resp => { - if (resp === false) return - let localParam = fromJS(param).toJS() - Api.getSystemConfig(param).then(response => { - if (response.status) { - this.setState({ - config: _config, - openEdition: response.open_edition || '', - originMenu: fromJS(_config).toJS() - }) - - localParam.func = 'sPC_TrdMenu_AddUpt_For_Local' - delete localParam.LongParam - delete localParam.PageParam - delete localParam.Template - delete localParam.Sort - delete localParam.EasyCode - delete localParam.open_edition - - this.submitAction(btnParam, tabParam, localParam) - } else { - this.setState({ - menuloading: false, - menucloseloading: false - }) - notification.warning({ - top: 92, - message: response.message, - duration: 5 - }) - } }) - }) + }, +sessionStorage.getItem('mkDelay')) } /** @@ -622,7 +672,6 @@ let curBtn = config.action.filter(cell => item.curuuid === cell.uuid)[0] // 鏌ョ湅鍒濆鍖栨寜閽槸鍚﹀瓨鍦� if (!curBtn) return if (curBtn.OpenType !== item.prebtn.OpenType) return - if (curBtn.OpenType === 'tab' && curBtn.tabTemplate !== 'FormTab') return if (curBtn.OpenType === 'funcbutton' && curBtn.execMode !== 'pop') return oriActions.push({ @@ -641,76 +690,30 @@ MenuID: action.prebtn.uuid }).then(result => { if (result.status && result.LongParam) { - let _LongParam = '' let _temp = '' - if (result.LongParam) { - let _subconfig = '' - try { - _subconfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) - _temp = _subconfig.type - } catch (e) { - console.warn('Parse Failure') - _subconfig = '' - } - - if (_temp === 'FormTab') { - try { - _subconfig.action = _subconfig.action.map(_btn => { - _btn.uuid = Utils.getuuid() - - return _btn - }) - - // 鍏煎宸叉湁缁撴瀯 - if (!_subconfig.tabgroups) { - _subconfig.tabgroups = [{ uuid: 'tabs', sublist: [] }] - } else if (typeof(_subconfig.tabgroups[0]) === 'string') { - let _tabgroups = [] - _subconfig.tabgroups.forEach(groupId => { - let _group = { - uuid: groupId, - sublist: fromJS(_subconfig[groupId]).toJS() - } - delete _subconfig[groupId] - _tabgroups.push(_group) - }) - _subconfig.tabgroups = _tabgroups - } - - _subconfig.tabgroups.forEach(group => { - group.sublist = group.sublist.map(_tab => { - _tab.uuid = Utils.getuuid() - _tab.linkTab = Utils.getuuid() - - return _tab - }) - }) - _subconfig = window.btoa(window.encodeURIComponent(JSON.stringify(_subconfig))) - } catch (e) { - console.warn('Stringify Failure') - _subconfig = '' - } - - _LongParam = _subconfig - } else if (_subconfig) { - _LongParam = result.LongParam - } + let _subconfig = '' + try { + _subconfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) + _temp = _subconfig.type + } catch (e) { + console.warn('Parse Failure') + _subconfig = '' } - if (_LongParam) { - let param = { - func: 'sPC_ButtonParam_AddUpt', - ParentID: this.props.menu.MenuID, - MenuID: action.curBtn.uuid, - MenuNo: config.MenuNo, - Template: _temp, - MenuName: action.curBtn.label, - PageParam: JSON.stringify({Template: _temp}), - LongParam: _LongParam - } - Api.getSystemConfig(param).then(() => {}) + if (!_subconfig) return + + let param = { + func: 'sPC_ButtonParam_AddUpt', + ParentID: this.props.menu.MenuID, + MenuID: action.curBtn.uuid, + MenuNo: config.MenuNo, + Template: _temp, + MenuName: action.curBtn.label, + PageParam: JSON.stringify({Template: _temp}), + LongParam: result.LongParam } + Api.getSystemConfig(param).then(() => {}) } }) }) @@ -732,7 +735,7 @@ }) } this.props.reloadmenu() - Api.getLocalConfig(localParam) + Api.genericInterface(localParam) } else { this.setState({ menuloading: false, @@ -779,14 +782,14 @@ if (config.isAdd) { // 鏂板缓鑿滃崟锛屾彁绀鸿彍鍗曞皻鏈繚瀛� notification.warning({ top: 92, - message: this.state.dict['header.menu.config.notsave'], + message: '鑿滃崟灏氭湭淇濆瓨锛岃鍏堜繚瀛樿彍鍗曢厤缃紒', duration: 5 }) } else { if (!is(fromJS(originMenu), fromJS(config))) { // 鑿滃崟淇℃伅鍙樺寲鏃讹紝鎻愮ず淇濆瓨 notification.warning({ top: 92, - message: this.state.dict['header.menu.config.update'], + message: '鑿滃崟閰嶇疆宸蹭慨鏀癸紝璇蜂繚瀛橈紒', duration: 5 }) return @@ -1127,7 +1130,7 @@ config: null }, () => { this.setState({ - chartview: _config.charts[0].uuid, + chartview: _config.charts ? _config.charts[0].uuid : '', config: _config, openEdition: res.open_edition || '', activeKey: menu.activeKey || '0', @@ -1165,12 +1168,11 @@ <div className="tools"> <Collapse accordion activeKey={activeKey} bordered={false} onChange={(key) => this.setState({activeKey: key})}> {/* 鍩烘湰淇℃伅 */} - <Panel forceRender={true} header={this.state.dict['header.menu.basedata']} key="0" id="main-basedata"> + <Panel forceRender={true} header="鍩烘湰淇℃伅" key="0" id="main-basedata"> {/* 鑿滃崟淇℃伅 */} <MenuForm menu={menu} config={config} - dict={this.state.dict} updatemenu={this.updateconfig} /> {config ? <UrlFieldComponent @@ -1185,14 +1187,14 @@ /> </Panel> {/* 鎼滅储鏉′欢娣诲姞 */} - <Panel header={this.state.dict['header.menu.search']} key="1"> + <Panel header="鎼滅储" key="1"> <div className="search-element"> {Source.searchItems.map((item, index) => (<SourceElement key={index} content={item}/>))} </div> <FieldsComponent config={config} type="search" /> </Panel> {/* 鎸夐挳娣诲姞 */} - <Panel header={this.state.dict['header.menu.action']} key="2"> + <Panel header="鎸夐挳" key="2"> <div className="search-element"> {Source.actionItems.map((item, index) => (<SourceElement key={index} content={item}/>))} </div> @@ -1202,7 +1204,7 @@ <Tooltip placement="topLeft" title="鐐瑰嚮鎸夐挳锛屽彲瀹屾垚鎴栨煡鐪嬫寜閽厤缃俊鎭��"> <QuestionCircleOutlined className="mk-form-tip"/> </Tooltip> - {this.state.dict['header.menu.action.configurable']} + 鎸夐挳閰嶇疆 </p> : null } </div> @@ -1220,14 +1222,14 @@ })} </Panel> {/* 娣诲姞鏄剧ず鍒� */} - <Panel header={this.state.dict['header.menu.column']} key="3"> + <Panel header="鏄剧ず鍒�" key="3"> <div className="search-element"> {Source.columnItems.map((item, index) => (<SourceElement key={index} content={item}/>))} </div> <FieldsComponent config={config} type="columns"/> </Panel> {/* 娣诲姞鏍囩 */} - <Panel header={this.state.dict['header.menu.tab']} key="4"> + <Panel header="鏍囩椤�" key="4"> <div className="search-element"> {Source.tabItems.map((item, index) => (<SourceElement key={index} content={item}/>))} </div> @@ -1236,7 +1238,7 @@ <Tooltip placement="topLeft" title="鐐瑰嚮鎸夐挳锛屽彲瀹屾垚鎴栨煡鐪嬫爣绛鹃厤缃俊鎭��"> <QuestionCircleOutlined className="mk-form-tip"/> </Tooltip> - {this.state.dict['header.menu.tab.configurable']} + 鏍囩閰嶇疆 </p> : null } {configTabs.map((item, index) => { @@ -1257,7 +1259,7 @@ <div className="setting"> <Card title={ <div> - {this.state.dict['header.menu.page.configurable']} + 椤甸潰閰嶇疆 <RedoOutlined style={{marginLeft: '10px'}} title="鍒锋柊鏍囩鍒楄〃" onClick={() => this.reloadTab(true)} /> </div> } bordered={false} extra={ @@ -1265,10 +1267,11 @@ <Unattended config={config} updateConfig={this.updateconfig}/> <Versions MenuId={menu.MenuID} open_edition={openEdition} updateConfig={this.refreshConfig}/> <ReplaceField type="table" config={config} updateConfig={this.updateconfig}/> - <EditComponent dict={this.state.dict} type="table" options={['search', 'form', 'action', 'columns']} config={this.state.config} MenuID={this.props.menu.MenuID} thawButtons={this.state.thawButtons} refresh={this.editConfig}/> - <Switch className="big" checkedChildren={this.state.dict['model.enable']} unCheckedChildren={this.state.dict['model.disable']} checked={this.state.config.enabled} onChange={this.onEnabledChange} /> - <Button type="primary" onClick={this.submitConfig} loading={this.state.menuloading}>{this.state.dict['model.save']}</Button> - <Button onClick={this.cancelConfig}>{this.state.dict['model.back']}</Button> + <EditComponent type="table" options={['search', 'form', 'action', 'columns']} config={this.state.config} MenuID={this.props.menu.MenuID} thawButtons={this.state.thawButtons} refresh={this.editConfig}/> + <UpdateTable config={config}/> + <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" checked={this.state.config.enabled} onChange={this.onEnabledChange} /> + <Button type="primary" id="save-config" onClick={this.submitConfig} loading={this.state.menuloading}>淇濆瓨</Button> + <Button onClick={this.cancelConfig}>鍏抽棴</Button> </div> } style={{ width: '100%' }}> <SettingComponent @@ -1280,12 +1283,12 @@ config={config} updatesearch={this.updatesearch} /> - <div className="chart-view" style={{position: 'relative'}}> - {/* 瑙嗗浘缁� 鏉冮檺 浼氬憳绛夌骇20+ */} - {this.props.memberLevel >= 20 ? <ChartGroupComponent + {config.charts ? <div className="chart-view" style={{position: 'relative'}}> + {/* 瑙嗗浘缁� 宸插純鐢� */} + <ChartGroupComponent config={config} updatechartgroup={this.updatechartgroup} - /> : null} + /> {config.charts.map(item => { if (!config.expand && chartview !== item.uuid) return '' @@ -1330,7 +1333,21 @@ ) } })} - </div> + </div> : <> + <ActionComponent + type="main" + menu={{ MenuID: this.props.menu.MenuID, MenuName: config.MenuName, MenuNo: config.MenuNo, fstMenuList: this.props.menu.fstMenuList }} + config={config} + tabs={this.state.tabviews} + setSubConfig={(_btn) => this.setSubConfig(_btn, 'button')} + updateaction={this.updateaction} + /> + <ColumnComponent + config={config} + menu={this.props.menu} + updatecolumn={this.updateconfig} + /> + </>} {/* 鏍囩缁� */} <TabsComponent config={config} @@ -1349,13 +1366,13 @@ visible={this.state.closeVisible} onCancel={() => { this.setState({closeVisible: false}) }} footer={[ - <Button key="save" className="mk-btn mk-green" loading={this.state.menucloseloading} onClick={this.submitConfig}>{this.state.dict['model.save']}</Button>, - <Button key="notsave" className="mk-btn mk-yellow" onClick={this.notsave}>{this.state.dict['model.notsave']}</Button>, - <Button key="cancel" onClick={() => { this.setState({closeVisible: false}) }}>{this.state.dict['model.cancel']}</Button> + <Button key="save" className="mk-btn mk-green" loading={this.state.menucloseloading} onClick={this.submitConfig}>淇濆瓨</Button>, + <Button key="notsave" className="mk-btn mk-yellow" onClick={this.notsave}>涓嶄繚瀛�</Button>, + <Button key="cancel" onClick={() => { this.setState({closeVisible: false}) }}>鍙栨秷</Button> ]} destroyOnClose > - {this.state.dict['header.menu.config.placeholder']} + 閰嶇疆宸蹭慨鏀癸紝鏄惁淇濆瓨閰嶇疆淇℃伅锛� </Modal> {this.state.loading && <Spin size="large" />} </div> @@ -1363,14 +1380,4 @@ } } -const mapStateToProps = (state) => { - return { - memberLevel: state.memberLevel - } -} - -const mapDispatchToProps = () => { - return {} -} - -export default connect(mapStateToProps, mapDispatchToProps)(ComTableConfig) +export default ComTableConfig -- Gitblit v1.8.0