From 54d01e6ef9ac31f10de4a0e92824eba50b77eda6 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 27 九月 2021 18:40:51 +0800 Subject: [PATCH] 2021-09-27 --- src/templates/zshare/editcomponent/index.jsx | 87 +++++++------------------------------------ 1 files changed, 14 insertions(+), 73 deletions(-) diff --git a/src/templates/zshare/editcomponent/index.jsx b/src/templates/zshare/editcomponent/index.jsx index 6fd72b8..dd89e6d 100644 --- a/src/templates/zshare/editcomponent/index.jsx +++ b/src/templates/zshare/editcomponent/index.jsx @@ -9,6 +9,7 @@ import TransferForm from '@/templates/zshare/basetransferform' import zhCN from '@/locales/zh-CN/model.js' import enUS from '@/locales/en-US/model.js' +import MKEmitter from '@/utils/events.js' import './index.scss' class editComponent extends Component { @@ -116,30 +117,16 @@ } pasteSubmit = () => { - const { options } = this.props + const { options, config } = this.props let _config = fromJS(this.props.config).toJS() this.pasteFormRef.handleConfirm().then(res => { if (res.copyType === 'action' && options.includes('action')) { res.uuid = Utils.getuuid() - - _config.action = _config.action.filter(item => !item.origin) - _config.action.push(res) - - this.setState({ - pasteVisible: false - }, () => { - this.props.refresh({ - type: 'paste', - config: _config - }) - }) + MKEmitter.emit('pasteButton', config.uuid, res) } else if (options.includes('search') && res.copyType === 'search') { res.uuid = Utils.getuuid() - _config.search = _config.search.filter(item => !item.origin) - let keys = _config.search.map(item => item.field.toLowerCase()) - - _config.search.push(res) + let keys = _config.search.map(item => item.field ? item.field.toLowerCase() : '') if (res.field && keys.includes(res.field.toLowerCase())) { notification.warning({ @@ -149,83 +136,37 @@ }) return } - - this.setState({ - pasteVisible: false - }, () => { - this.props.refresh({ - type: 'paste', - config: _config - }) - }) + MKEmitter.emit('plusSearch', config.uuid, res, 'simple') } else if (options.includes('columns') && res.copyType === 'columns') { - _config.columns = _config.columns.filter(col => !col.origin) let keys = _config.columns.map(item => item.field ? item.field.toLowerCase() : '') - - if (_config.columns.length === 0) { - _config.columns = res.columns - } else { - res.columns.forEach(col => { - if (!col.field) return - let _key = col.field.toLowerCase() - if (!keys.includes(_key)) { - keys.push(_key) - _config.columns.push(col) - } - }) - } + let items = res.columns.filter(col => col.field && !keys.includes(col.field.toLowerCase())) - this.setState({ - pasteVisible: false - }, () => { - this.props.refresh({ - type: 'paste', - config: _config - }) - }) + MKEmitter.emit('plusColumns', config.uuid, items) } else if (options.includes('form') && res.copyType === 'form') { - let fields = [] - let labels = [] + let keys = _config.fields.map(item => item.field ? item.field.toLowerCase() : '') res.uuid = Utils.getuuid() - _config.fields.forEach(item => { - item.field && fields.push(item.field.toLowerCase()) - labels.push(item.label) - }) - _config.fields.push(res) - - if (res.field && fields.includes(res.field.toLowerCase())) { + if (res.field && keys.includes(res.field.toLowerCase())) { notification.warning({ top: 92, message: '瀛楁宸插瓨鍦紒', duration: 10 }) return - } else if (labels.includes(res.label)) { - notification.warning({ - top: 92, - message: '鍚嶇О宸插瓨鍦紒', - duration: 10 - }) - return } - this.setState({ - pasteVisible: false - }, () => { - this.props.refresh({ - type: 'paste', - config: _config, - newform: res - }) - }) + this.props.plusFields([res]) } else { notification.warning({ top: 92, message: '閰嶇疆淇℃伅鏍煎紡閿欒锛�', duration: 5 }) + return } + this.setState({ + pasteVisible: false + }) }) } -- Gitblit v1.8.0