| | |
| | | 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 { |
| | |
| | | } |
| | | |
| | | 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({ |
| | |
| | | }) |
| | | 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 |
| | | }) |
| | | }) |
| | | } |
| | | |