From 09e0de52a398dd08a0dc3f4b43e4589d211e9c27 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 30 十二月 2021 12:44:45 +0800 Subject: [PATCH] 2021-12-30 --- src/templates/formtabconfig/index.jsx | 103 +++++++++++++++++++++------------------------------ 1 files changed, 42 insertions(+), 61 deletions(-) diff --git a/src/templates/formtabconfig/index.jsx b/src/templates/formtabconfig/index.jsx index 38b589d..297b37b 100644 --- a/src/templates/formtabconfig/index.jsx +++ b/src/templates/formtabconfig/index.jsx @@ -5,7 +5,8 @@ import { DndProvider } from 'react-dnd' import HTML5Backend from 'react-dnd-html5-backend' import moment from 'moment' -import { Button, Card, Modal, Collapse, notification, Spin, Select, List, Icon, Empty, Switch, Tooltip } from 'antd' +import { Button, Card, Modal, Collapse, notification, Spin, Select, List, Empty, Switch, Tooltip } from 'antd' +import { QuestionCircleOutlined, CloseOutlined, RedoOutlined, SettingOutlined, PlusOutlined, DeleteOutlined, EditOutlined, SnippetsOutlined } from '@ant-design/icons' import Api from '@/api' import zhCN from '@/locales/zh-CN/model.js' @@ -16,23 +17,25 @@ import TabsComponent from '@/templates/sharecomponent/tabscomponent' -import ModalForm from '@/templates/zshare/modalform' import PasteForm from '@/templates/zshare/pasteform' import ActionForm from './actionform' import SettingForm from './settingform' import DragElement from './dragelement' import GroupForm from './groupform' import EditCard from '@/templates/zshare/editcard' -import VerifyCard from '@/templates/zshare/verifycard' + import MenuForm from '@/templates/zshare/menuform' import SourceElement from '@/templates/zshare/dragsource' -import CreateFunc from '@/templates/zshare/createfunc' +import asyncComponent from '@/utils/asyncComponent' import Source from './source' import './index.scss' const { Panel } = Collapse const { Option } = Select const { confirm } = Modal +const ModalForm = asyncComponent(() => import('@/templates/zshare/modalform')) +const CreateFunc = asyncComponent(() => import('@/templates/zshare/createfunc')) +const VerifyCard = asyncComponent(() => import('@/templates/zshare/verifycard')) class ComTableConfig extends Component { static propTpyes = { @@ -43,7 +46,7 @@ } state = { - dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, // 瀛楀吀 + dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, // 瀛楀吀 config: null, // 椤甸潰閰嶇疆 modaltype: '', // 妯℃�佹绫诲瀷锛屾帶鍒舵ā鎬佹鏄剧ず tableVisible: false, // 鏁版嵁琛ㄥ瓧娈垫ā鎬佹 @@ -427,10 +430,7 @@ let _inputfields = [] let _tabfields = [] let _linkableFields = [] - let _linksupFields = [{ - value: '', - text: '绌�' - }] + let _linksupFields = [] let _formfields = [] // 璁剧疆涓嬫媺鑿滃崟鍙叧鑱斿瓧娈� @@ -438,7 +438,7 @@ _formfields = [..._formfields, ...group.sublist] }) - _inputfields = _formfields.filter(item => item.type === 'text' || item.type === 'number' || item.type === 'textarea' || item.type === 'color') + _inputfields = _formfields.filter(item => ['text', 'number', 'textarea', 'color'].includes(item.type) && card.field !== item.field) _tabfields = _formfields.filter(item => card.field !== item.field && item.hidden !== 'true' && ['text', 'number', 'select', 'link'].includes(item.type)) _tabfields.unshift({field: '', text: '鍘熻〃鍗�'}) @@ -482,7 +482,7 @@ this.setState({ modaltype: 'search', card: card, - formlist: getModalForm(card, _inputfields, _tabfields, _linkableFields, _linksupFields, false).map(item => { + formlist: getModalForm(card, _inputfields, _tabfields, _linkableFields, _linksupFields).map(item => { if (item.key === 'type') { item.options = item.options.filter(option => !['switch', 'checkbox', 'radio', 'checkcard', 'hint'].includes(option.value)) } @@ -496,22 +496,17 @@ if (usefulFields) { try { usefulFields = JSON.parse(usefulFields) - } catch { + } catch (e) { usefulFields = [] } } else { usefulFields = [] } - let ableField = usefulFields.join(', ') - let functip = <div> - <p style={{marginBottom: '5px'}}>{this.state.dict['model.tooltip.func.innerface'].replace('@ableField', ableField)}</p> - </div> - this.setState({ modaltype: 'actionEdit', card: card, - formlist: getActionForm(card, functip, this.state.config, usefulFields) + formlist: getActionForm(card, this.state.config, usefulFields) }) } @@ -540,7 +535,6 @@ let _groups = null let fieldrepet = false // 瀛楁閲嶅 - let labelrepeat = false // 鎻愮ず鏂囧瓧閲嶅 if (card.iscopy) { _groups = _config.groups.map(group => { @@ -552,8 +546,6 @@ if (item.uuid !== res.uuid && item.field === res.field) { fieldrepet = true - } else if (item.uuid !== res.uuid && item.label === res.label) { - labelrepeat = true } }) @@ -571,8 +563,6 @@ group.sublist = group.sublist.map(item => { if (item.uuid !== res.uuid && item.field === res.field) { fieldrepet = true - } else if (item.uuid !== res.uuid && item.label === res.label) { - labelrepeat = true } if (item.uuid === res.uuid) { @@ -592,13 +582,6 @@ notification.warning({ top: 92, message: '瀛楁宸插瓨鍦紒', - duration: 5 - }) - return - } else if (labelrepeat) { - notification.warning({ - top: 92, - message: '鍚嶇О宸插瓨鍦紒', duration: 5 }) return @@ -905,7 +888,7 @@ if (_ismutil && group.sublist.length === 0) { _config.enabled = false } - let arr = group.sublist.filter(item => item.field.toLowerCase() === _primary) + let arr = group.sublist.filter(item => item.field && item.field.toLowerCase() === _primary) if (arr.length > 0) { _config.enabled = false @@ -1341,7 +1324,6 @@ initval: '', type: item.type, resourceType: '0', - setAll: 'false', options: [], orderType: 'asc' } @@ -1619,7 +1601,7 @@ let primaryrepeat = false config.groups.forEach(group => { - let arr = group.sublist.filter(item => item.field.toLowerCase() === _primary) + let arr = group.sublist.filter(item => item.field && item.field.toLowerCase() === _primary) if (arr.length > 0) { primaryrepeat = true @@ -1806,7 +1788,7 @@ <div className="ant-col ant-form-item-label"> <label> <Tooltip placement="topLeft" title="姝ゅ鍙互娣诲姞閰嶇疆鐩稿叧鐨勫父鐢ㄨ〃锛屽湪娣诲姞鎼滅储鏉′欢鍜屾樉绀哄垪鏃讹紝鍙�氳繃宸ュ叿鏍忎腑鐨勬坊鍔犳寜閽紝鎵归噺娣诲姞琛ㄦ牸鐩稿叧瀛楁銆�"> - <Icon type="question-circle" /> + <QuestionCircleOutlined className="mk-form-tip" /> {this.state.dict['header.menu.table.add']} </Tooltip> </label> @@ -1816,7 +1798,7 @@ className="tables" style={{ width: '100%' }} optionFilterProp="children" - value={this.state.dict['header.menu.table.placeholder']} + value="璇烽�夋嫨琛ㄥ悕" onChange={this.onTableChange} showArrow={false} getPopupContainer={() => document.getElementById('common-basedata')} @@ -1835,7 +1817,7 @@ dataSource={this.state.selectedTables} renderItem={(item, index) => <List.Item key={index} title={item.Remark + ' (' + item.TbName + ')'}> {item.Remark + ' (' + item.TbName + ')'} - <Icon type="close" onClick={() => this.deleteTable(item)}/> + <CloseOutlined onClick={() => this.deleteTable(item)}/> <div className="bottom-mask"></div> </List.Item>} />} @@ -1847,7 +1829,7 @@ return (<SourceElement key={index} content={item}/>) })} </div> - <Button type="primary" block onClick={() => this.queryField('search')}>{this.state.dict['header.menu.form.add']}</Button> + <Button type="primary" block onClick={() => this.queryField('search')}>鎵归噺娣诲姞</Button> </Panel> {/* 鎸夐挳娣诲姞 */} <Panel header={this.state.dict['header.menu.action']} key="2"> @@ -1867,9 +1849,9 @@ {configTabs.length > 0 ? <p className="config-btn-title"> <Tooltip placement="topLeft" title="鐐瑰嚮鎸夐挳锛屽彲瀹屾垚鎴栨煡鐪嬫爣绛鹃厤缃俊鎭��"> - <Icon type="question-circle" /> + <QuestionCircleOutlined className="mk-form-tip" /> </Tooltip> - {this.state.dict['header.menu.tab.configurable']} + 鏍囩閰嶇疆 </p> : null } {configTabs.map((item, index) => { @@ -1890,8 +1872,8 @@ <div className="setting"> <Card title={ <div> - {this.state.dict['header.menu.page.configurable']} - <Icon type="redo" style={{marginLeft: '10px'}} title="鍒锋柊鏍囩鍒楄〃" onClick={this.reloadTab} /> + 椤甸潰閰嶇疆 + <RedoOutlined style={{marginLeft: '10px'}} title="鍒锋柊鏍囩鍒楄〃" onClick={this.reloadTab} /> </div> } bordered={false} extra={ <div> @@ -1900,9 +1882,9 @@ <Button onClick={this.cancelConfig}>{this.state.dict['model.back']}</Button> </div> } style={{ width: '100%' }}> - <Icon type="setting" onClick={this.changeSetting} /> + <SettingOutlined onClick={this.changeSetting} /> <Tooltip placement="bottomLeft" overlayClassName="middle" title="鍦ㄥ乏渚у伐鍏锋爮銆婃悳绱€�嬩腑锛岄�夋嫨瀵瑰簲鎼滅储妗嗘嫋鑷虫澶勬坊鍔狅紱鎴栫偣鍑绘寜閽�婃坊鍔犳悳绱㈡潯浠躲�嬫壒閲忔坊鍔狅紝閫夋嫨鎵归噺娣诲姞鏃讹紝闇�鎻愬墠閫夋嫨浣跨敤琛ㄣ��"> - <Icon type="question-circle" /> + <QuestionCircleOutlined style={{position: 'relative', color: '#c49f47', left: '5px', top: '20px'}} /> </Tooltip> <Collapse activeKey={config.groups.map(group => group.uuid)} @@ -1911,21 +1893,16 @@ {config.groups.map((group, index) => ( <Panel showArrow={false} header={group.label} key={group.uuid} extra={( <span> - {index === _length - 1 ? <Icon - type="plus" + {index === _length - 1 ? <PlusOutlined onClick={() => { this.handleGroup()}} /> : null} - {_length > 1 && index !== _length - 1 ? <Icon - type="delete" + {_length > 1 && index !== _length - 1 ? <DeleteOutlined onClick={() => { this.closeGroup(group) }} /> : null} - <Icon - type="edit" - onClick={() => { this.handleGroup(group) }} - /> + <EditOutlined onClick={() => { this.handleGroup(group) }}/> </span> )}> - {group.isDefault ? <Icon type="snippets" title={this.state.dict['header.form.paste']} onClick={() => {this.setState({pasteVisible: true})}} /> : null} + {group.isDefault ? <SnippetsOutlined title={this.state.dict['header.form.paste']} onClick={() => {this.setState({pasteVisible: true})}} /> : null} <DragElement type="search" groupId={group.uuid} @@ -1934,14 +1911,13 @@ setting={config.setting} handleMenu={this.handleSearch} deleteMenu={this.deleteElement} - placeholder={this.state.dict['header.form.modal.placeholder']} /> </Panel> ))} </Collapse> <div className="action-list"> <Tooltip placement="bottomLeft" overlayClassName="middle" title="鍦ㄥ乏渚у伐鍏锋爮銆婃寜閽�嬩腑锛岄�夋嫨瀵瑰簲绫诲瀷鐨勬寜閽嫋鑷虫澶勬坊鍔狅紝濡傞�夋嫨鎸夐挳绫诲瀷涓鸿〃鍗曘�佹柊鏍囩椤电瓑鍚湁閰嶇疆椤甸潰鐨勬寜閽紝鍙湪宸︿晶宸ュ叿鏍�-鎸夐挳-鍙厤缃寜閽锛岀偣鍑绘寜閽畬鎴愮浉鍏抽厤缃�傛敞锛氬綋璁剧疆鎸夐挳鏄剧ず浣嶇疆涓鸿〃鏍兼椂锛屾樉绀哄垪浼氬鍔犳搷浣滃垪銆�"> - <Icon type="question-circle" /> + <QuestionCircleOutlined style={{position: 'absolute', color: '#c49f47', left: '5px', top: '5px'}} /> </Tooltip> <DragElement type="action" @@ -1950,7 +1926,6 @@ handleMenu={this.handleAction} deleteMenu={this.deleteElement} profileMenu={this.profileAction} - placeholder={this.state.dict['header.form.action.placeholder']} /> </div> {/* 鏍囩缁� */} @@ -1965,7 +1940,7 @@ </DndProvider> {/* 缂栬緫琛ㄥ崟 */} <Modal - title={this.state.card && this.state.card.iscopy ? this.state.dict['header.modal.form.copy'] : this.state.dict['header.modal.form.edit']} + title={this.state.card && this.state.card.iscopy ? '琛ㄥ崟-澶嶅埗' : '琛ㄥ崟-缂栬緫'} visible={modaltype === 'search'} width={700} maskClosable={false} @@ -1986,7 +1961,7 @@ <Modal title={this.state.dict['model.action'] + '-' + this.state.dict['model.edit']} visible={modaltype === 'actionEdit'} - width={700} + width={900} maskClosable={false} onCancel={this.editModalCancel} footer={[ @@ -2013,7 +1988,6 @@ visible={this.state.tableVisible} width={'65vw'} maskClosable={false} - style={{minWidth: '900px', maxWidth: '1200px'}} cancelText={this.state.dict['model.close']} onOk={this.addFieldSubmit} onCancel={() => { // 鍙栨秷娣诲姞 @@ -2037,10 +2011,17 @@ visible={this.state.profileVisible} width={'75vw'} maskClosable={false} - style={{minWidth: '900px', maxWidth: '1200px'}} okText={this.state.dict['model.submit']} onOk={this.verifySubmit} - onCancel={() => { this.setState({ profileVisible: false }) }} + onCancel={() => { + if (this.verifyRef.handleCancel) { + this.verifyRef.handleCancel().then(() => { + this.setState({ profileVisible: false }) + }) + } else { + this.setState({ profileVisible: false }) + } + }} destroyOnClose > <VerifyCard @@ -2094,7 +2075,7 @@ {this.state.dict['header.menu.config.placeholder']} </Modal> <Modal - title={this.state.dict['header.menu.group.manage']} + title="鍒嗙粍绠$悊" visible={this.state.groupVisible} width={700} maskClosable={false} -- Gitblit v1.8.0