From 6b680ace26dc95031a1b7a3e33f8785c112f787d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 20 四月 2020 18:32:01 +0800 Subject: [PATCH] 2020-04-20 --- src/templates/subtableconfig/index.jsx | 191 ++++++++++++----------------------------------- 1 files changed, 51 insertions(+), 140 deletions(-) diff --git a/src/templates/subtableconfig/index.jsx b/src/templates/subtableconfig/index.jsx index 2930bf1..dab3aa9 100644 --- a/src/templates/subtableconfig/index.jsx +++ b/src/templates/subtableconfig/index.jsx @@ -4,7 +4,7 @@ import { is, fromJS } from 'immutable' import { DndProvider } from 'react-dnd' import HTML5Backend from 'react-dnd-html5-backend' -import { Button, Card, Modal, Collapse, notification, Spin, Select, List, Icon, Empty, Switch, Tooltip } from 'antd' +import { Button, Card, Modal, Collapse, notification, Spin, Select, List, Icon, Empty, Switch, Tooltip, message } from 'antd' import moment from 'moment' import Api from '@/api' @@ -20,7 +20,6 @@ import SearchForm from '@/templates/zshare/searchform' import ColumnForm from '@/templates/zshare/columnform' import DragElement from '@/templates/zshare/dragelement' -import PasteForm from '@/templates/zshare/pasteform' import ColspanForm from '@/templates/zshare/colspanform' import GridBtnForm from '@/templates/zshare/gridbtnform' import EditCard from '@/templates/zshare/editcard' @@ -29,7 +28,7 @@ import VerifyCardExcelIn from '@/templates/zshare/verifycardexcelin' import VerifyCardExcelOut from '@/templates/zshare/verifycardexcelout' import MenuForm from '@/templates/zshare/menuform' -import TransferForm from '@/components/transferform' +import EditComponent from '@/templates/zshare/editcomponent' import SourceElement from '@/templates/zshare/dragelement/source' import CreateFunc from '@/templates/zshare/createfunc' import CreateInterface from '@/templates/zshare/createinterface' @@ -83,8 +82,6 @@ tabviews: [], // 鎵�鏈夋爣绛鹃〉 profileVisible: false, // 楠岃瘉淇℃伅妯℃�佹 optionLibs: null, // 鑷畾涔変笅鎷夐�夐」搴� - thawBtnVisible: false, // 瑙e喕鎸夐挳寮圭獥 - thawbtnlist: null, // 瑙e喕鎸夐挳鍒楄〃 thawButtons: [], // 宸查�夋嫨瑕佽В鍐荤殑鎸夐挳 activeKey: '0', // 榛樿灞曞紑鍩烘湰淇℃伅 sqlVerifing: false // sql楠岃瘉 @@ -2106,86 +2103,6 @@ } /** - * @description 瑙e喕鎸夐挳 - */ - handleThaw = () => { - const { config } = this.state - - this.setState({ - thawBtnVisible: true - }) - - Api.getSystemConfig({ - func: 'sPC_Get_FrozenMenu', - ParentID: config.uuid, - TYPE: 40 - }).then(res => { - if (res.status) { - let _list = [] - - res.data.forEach(menu => { - let _conf = '' - - if (menu.ParentParam) { - try { - _conf = JSON.parse(window.decodeURIComponent(window.atob(menu.ParentParam))) - } catch (e) { - console.warn('Parse Failure') - _conf = '' - } - } - - if (_conf) { - _list.push({ - key: menu.MenuID, - title: menu.MenuName, - btnParam: _conf - }) - } - }) - - this.setState({ - thawbtnlist: _list - }) - } else { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } - }) - } - - /** - * @description 瑙e喕鎸夐挳鎻愪氦 - */ - thawBtnSubmit = () => { - const { thawButtons, config, thawbtnlist } = this.state - // 涓夌骇鑿滃崟瑙i櫎鍐荤粨 - if (this.refs.trawmenu.state.targetKeys.length === 0) { - notification.warning({ - top: 92, - message: this.state.dict['form.required.select'] + this.state.dict['header.form.thawbutton'], - duration: 5 - }) - } else { - - thawbtnlist.forEach(item => { - if (this.refs.trawmenu.state.targetKeys.includes(item.key)) { - config.action.push(item.btnParam) - } - }) - - this.setState({ - thawButtons: [...thawButtons, ...this.refs.trawmenu.state.targetKeys], - config: config, - thawBtnVisible: false - }) - } - } - - /** * @description 鍒涘缓鎸夐挳鎺ュ彛锛堝啓鍏ワ級 */ btnCreatInterface = () => { @@ -2244,30 +2161,42 @@ }) } - pasteSubmit = () => { - this.pasteFormRef.handleConfirm().then(res => { - if (res.copyType !== 'action') { - notification.warning({ - top: 92, - message: '閰嶇疆淇℃伅鏍煎紡閿欒锛�', - duration: 5 - }) - return - } else if (!['pop', 'prompt', 'exec', 'excelIn', 'excelOut', 'popview'].includes(res.OpenType)) { - notification.warning({ - top: 92, - message: '涓嶆敮鎸佹鎵撳紑鏂瑰紡锛�', - duration: 5 - }) - return - } + copycolumn = () => { + const { config } = this.state + let oInput = document.createElement('input') + let val = { + copyType: 'columns', + columns: config.columns + } + + oInput.value = window.btoa(window.encodeURIComponent(JSON.stringify(val))) + document.body.appendChild(oInput) + oInput.select() + document.execCommand('Copy') + oInput.className = 'oInput' + oInput.style.display = 'none' + + message.success('澶嶅埗鎴愬姛銆�') + + document.body.removeChild(oInput) + } + + updateConfig = (res) => { + if (res.type === 'thaw') { this.setState({ - modaltype: '' - }, () => { - this.handleAction(res, 'copy') + thawButtons: res.thawButtons, + config: res.config }) - }) + } else if (res.type === 'paste') { + if (res.copyType === 'action') { + this.handleAction(res.content, 'copy') + } else if (res.copyType === 'columns') { + this.setState({ + config: res.config + }) + } + } } render () { @@ -2359,9 +2288,6 @@ {this.state.dict['header.menu.action.configurable']} </p> : null } - <div className="thawbutton" title={this.state.dict['header.form.thawbutton']} onClick={this.handleThaw}> - <Icon type="unlock" /> - </div> </div> {configAction.map((item, index) => { return ( @@ -2395,6 +2321,7 @@ </div> } bordered={false} extra={ <div> + <EditComponent dict={this.state.dict} type="subtable" config={this.state.config} thawButtons={this.state.thawButtons} refresh={this.updateConfig}/> <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" checked={this.state.config.enabled} onChange={this.onEnabledChange} /> <Button type="primary" onClick={this.submitConfig} loading={this.state.menuloading}>{this.state.dict['header.save']}</Button> <Button onClick={this.cancelConfig}>{this.state.dict['header.return']}</Button> @@ -2414,13 +2341,24 @@ placeholder={this.state.dict['header.form.search.placeholder']} /> </div> + {/* <div className="action-list"> + <DragElement + type="action" + list={this.state.config.action} + setting={this.state.config.setting} + handleList={this.handleList} + handleMenu={this.handleAction} + copyElement={(val) => this.handleAction(val, 'copy')} + deleteMenu={this.deleteElement} + profileMenu={this.profileAction} + doubleClickCard={this.btnDoubleClick} + placeholder={this.state.dict['header.form.action.placeholder']} + /> + </div> */} <div className="action-list"> <Tooltip placement="bottomLeft" overlayClassName="middle" title="鍦ㄥ乏渚у伐鍏锋爮銆婃寜閽�嬩腑锛岄�夋嫨瀵瑰簲绫诲瀷鐨勬寜閽嫋鑷虫澶勬坊鍔狅紝濡傞�夋嫨鎸夐挳绫诲瀷涓鸿〃鍗曘�佹柊鏍囩椤电瓑鍚湁閰嶇疆椤甸潰鐨勬寜閽紝鍙湪宸︿晶宸ュ叿鏍�-鎸夐挳-鍙厤缃寜閽锛岀偣鍑绘寜閽畬鎴愮浉鍏抽厤缃�傛敞锛氬綋璁剧疆鎸夐挳鏄剧ず浣嶇疆涓鸿〃鏍兼椂锛屾樉绀哄垪浼氬鍔犳搷浣滃垪銆�"> <Icon type="question-circle" /> </Tooltip> - <div className="copybutton" title={this.state.dict['header.form.paste']} onClick={() => {this.setState({modaltype: 'paste'})}}> - <Icon type="snippets" /> - </div> <DragElement type="action" list={this.state.config.action} @@ -2438,6 +2376,7 @@ <Tooltip placement="bottomLeft" overlayClassName="middle" title="鍦ㄥ乏渚у伐鍏锋爮銆婃樉绀哄垪銆嬩腑锛岄�夋嫨瀵瑰簲绫诲瀷鐨勬樉绀哄垪鎷栬嚦姝ゅ娣诲姞锛涙垨鐐瑰嚮銆婃坊鍔犳樉绀哄垪銆嬫寜閽壒閲忔坊鍔狅紝閫夋嫨鎵归噺娣诲姞鏃讹紝闇�鎻愬墠閫夋嫨浣跨敤琛ㄣ�傛敞锛氭坊鍔犲悎骞跺垪鏃讹紝闇�璁剧疆鍙�夊垪銆�"> <Icon type="question-circle" /> </Tooltip> + {config.columns && config.columns.length > 0 ? <Icon className="column-copy" title="copy" type="copy" onClick={this.copycolumn} /> : null} <Switch checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={this.state.showColumnName} onChange={this.onColumnNameChange} /> <DragElement type="columns" @@ -2668,34 +2607,6 @@ destroyOnClose > {this.state.dict['header.menu.config.placeholder']} - </Modal> - {/* 瑙e喕鎸夐挳妯℃�佹 */} - <Modal - title={this.state.dict['header.form.thawbutton']} - okText={this.state.dict['header.confirm']} - cancelText={this.state.dict['header.cancel']} - visible={this.state.thawBtnVisible} - onOk={this.thawBtnSubmit} - onCancel={() => {this.setState({thawBtnVisible: false, thawbtnlist: null})}} - destroyOnClose - > - {!this.state.thawbtnlist && <Spin style={{marginLeft: 'calc(50% - 22px)', marginTop: '70px', marginBottom: '70px'}} size="large" />} - {this.state.thawbtnlist && <TransferForm ref="trawmenu" menulist={this.state.thawbtnlist}/>} - </Modal> - {/* 鎸夐挳閰嶇疆淇℃伅绮樿创澶嶅埗 */} - <Modal - title={this.state.dict['header.form.paste']} - visible={modaltype === 'paste'} - width={600} - maskClosable={false} - onOk={this.pasteSubmit} - onCancel={() => {this.setState({modaltype: ''})}} - destroyOnClose - > - <PasteForm - dict={this.state.dict} - wrappedComponentRef={(inst) => this.pasteFormRef = inst} - /> </Modal> {this.state.loading && <Spin size="large" />} </div> -- Gitblit v1.8.0