From 2a347c8d91d6962f4302f0553c55a3b9f743baa5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 09 九月 2020 21:15:58 +0800 Subject: [PATCH] 2020-09-09 --- src/templates/zshare/editcomponent/index.jsx | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 113 insertions(+), 7 deletions(-) diff --git a/src/templates/zshare/editcomponent/index.jsx b/src/templates/zshare/editcomponent/index.jsx index 7c52871..adb6bd8 100644 --- a/src/templates/zshare/editcomponent/index.jsx +++ b/src/templates/zshare/editcomponent/index.jsx @@ -1,9 +1,11 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' +import { fromJS } from 'immutable' import { Menu, Dropdown, Icon, Modal, Spin, notification } from 'antd' import Api from '@/api' import PasteForm from '@/templates/zshare/pasteform' +import ReplaceForm from '@/templates/zshare/replaceform' import TransferForm from '@/templates/zshare/basetransferform' import zhCN from '@/locales/zh-CN/model.js' import enUS from '@/locales/en-US/model.js' @@ -22,7 +24,8 @@ dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, thawVisible: false, thawbtnlist: null, - pasteVisible: false + pasteVisible: false, + replaceVisible: false } handleMenuClick = e => { @@ -30,6 +33,8 @@ this.handleThaw() } else if (e.key === 'paste') { this.setState({pasteVisible: true}) + } else if (e.key === 'replace') { + this.setState({replaceVisible: true}) } } @@ -127,10 +132,10 @@ } pasteSubmit = () => { - const { config } = this.props + const { config, type } = this.props this.pasteFormRef.handleConfirm().then(res => { - if (res.copyType === 'action') { + if (['maintable', 'subtable'].includes(type) && res.copyType === 'action') { if (this.props.type === 'subtable' && !['pop', 'prompt', 'exec', 'excelIn', 'excelOut', 'popview'].includes(res.OpenType)) { notification.warning({ top: 92, @@ -147,7 +152,7 @@ content: res }) }) - } else if (res.copyType === 'search') { + } else if (['maintable', 'subtable'].includes(type) && res.copyType === 'search') { this.setState({ pasteVisible: false }, () => { @@ -156,7 +161,7 @@ content: res }) }) - } else if (res.copyType === 'columns') { + } else if (['maintable', 'subtable'].includes(type) && res.copyType === 'columns') { let _columns = config.columns.filter(col => !col.origin) if (_columns.length > 0) { notification.warning({ @@ -175,6 +180,78 @@ content: res }) }) + } else if (['form'].includes(type) && res.copyType === 'form') { + if (res.type === 'linkMain') { + notification.warning({ + top: 92, + message: '涓嶆敮鎸佹琛ㄥ崟绫诲瀷锛�', + duration: 10 + }) + return + } + + let _config = fromJS(config).toJS() + let fieldrepet = false + let labelrepet = false + + if (_config.groups.length > 0) { + _config.groups.forEach(group => { + group.sublist.forEach(item => { + if (item.uuid === res.uuid) { + fieldrepet = true + } else if (item.field === res.field) { + fieldrepet = true + } else if (item.label === res.label) { + labelrepet = true + } + }) + }) + } else { + _config.fields.forEach(item => { + if (item.uuid === res.uuid) { + fieldrepet = true + } else if (item.field === res.field) { + fieldrepet = true + } else if (item.label === res.label) { + labelrepet = true + } + }) + } + + if (fieldrepet) { + notification.warning({ + top: 92, + message: '瀛楁宸插瓨鍦紒', + duration: 10 + }) + return + } else if (labelrepet) { + notification.warning({ + top: 92, + message: '鍚嶇О宸插瓨鍦紒', + duration: 10 + }) + return + } + + if (_config.groups.length > 0) { + _config.groups.forEach(group => { + if (group.default) { + group.sublist.push(res) + } + }) + } else { + _config.fields.push(res) + } + + this.setState({ + pasteVisible: false + }, () => { + this.props.refresh({ + type: 'paste', + content: _config + }) + }) } else { notification.warning({ top: 92, @@ -185,12 +262,25 @@ }) } + replaceSubmit = () => { + this.replaceFormRef.handleConfirm().then(res => { + this.props.refresh({ + type: 'replace', + ...res + }) + this.setState({ + replaceVisible: false + }) + }) + } + render() { + const { type } = this.props const { dict } = this.state const menu = ( <Menu onClick={this.handleMenuClick}> - {this.props.type !== 'TreePage' ? <Menu.Item key="thaw"><Icon type="unlock" />{dict['header.form.thawbutton']}</Menu.Item> : null} - <Menu.Item key="paste"><Icon type="snippets" />{dict['header.form.paste']}</Menu.Item> + {['maintable', 'subtable'].includes(type) ? <Menu.Item key="thaw"><Icon type="unlock" />{dict['header.form.thawbutton']}</Menu.Item> : null} + {['maintable', 'subtable', 'form'].includes(type) ? <Menu.Item key="paste"><Icon type="snippets" />{dict['header.form.paste']}</Menu.Item> : null} {/* <Menu.Item key="replace"><Icon type="retweet" />鏇挎崲</Menu.Item> */} </Menu> ) @@ -228,6 +318,22 @@ wrappedComponentRef={(inst) => this.pasteFormRef = inst} /> </Modal> + {/* 鏇挎崲 */} + <Modal + title={'鏇挎崲'} + visible={this.state.replaceVisible} + width={600} + maskClosable={false} + onOk={this.replaceSubmit} + onCancel={() => {this.setState({replaceVisible: false})}} + destroyOnClose + > + <ReplaceForm + dict={dict} + inputSubmit={this.replaceSubmit} + wrappedComponentRef={(inst) => this.replaceFormRef = inst} + /> + </Modal> </div> ) } -- Gitblit v1.8.0