| | |
| | | import { Icon, Modal, notification } from 'antd' |
| | | |
| | | import Utils from '@/utils/utils.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import './index.scss' |
| | | |
| | |
| | | this.setState({visible: true}) |
| | | } |
| | | |
| | | resetconfig = (item) => { |
| | | item.uuid = Utils.getuuid() |
| | | resetconfig = (item, copyBtns) => { |
| | | let _uuid = Utils.getuuid() |
| | | |
| | | if (item.OpenType === 'popview') { |
| | | let _cell = fromJS(item).toJS() |
| | | _cell.$originUuid = _cell.uuid |
| | | _cell.uuid = _uuid |
| | | copyBtns.set(_uuid, _cell) |
| | | } |
| | | |
| | | if (item.uuid) { |
| | | item.uuid = _uuid |
| | | } |
| | | |
| | | if (item.copyType === 'cardcell') { |
| | | item.setting = item.setting || {} |
| | |
| | | return cell |
| | | }) |
| | | } |
| | | } else if (item.copyType === 'table') { |
| | | } else if (item.copyType === 'cols') { |
| | | let loopCol = (col) => { |
| | | col.subcols = col.subcols.map(c => { |
| | | c.uuid = Utils.getuuid() |
| | |
| | | cell.uuid = Utils.getuuid() |
| | | return cell |
| | | }) |
| | | } else if (c.type === 'action' && c.elements) { |
| | | c.elements = c.elements.map(cell => { |
| | | cell.uuid = Utils.getuuid() |
| | | return cell |
| | | }) |
| | | } |
| | | return c |
| | | }) |
| | |
| | | return col |
| | | } |
| | | |
| | | if (item.type === 'colspan' && item.subcols) { |
| | | item = loopCol(item) |
| | | } else if (item.type === 'custom' && item.elements) { |
| | | item.elements = item.elements.map(cell => { |
| | | cell.uuid = Utils.getuuid() |
| | | return cell |
| | | }) |
| | | } else if (item.type === 'action' && item.elements) { |
| | | item.elements = item.elements.map(cell => { |
| | | cell.uuid = Utils.getuuid() |
| | | return cell |
| | | }) |
| | | } |
| | | item.cols = item.cols.map(_item => { |
| | | _item.uuid = Utils.getuuid() |
| | | if (_item.type === 'colspan' && _item.subcols) { |
| | | _item = loopCol(_item) |
| | | } else if (_item.type === 'custom' && _item.elements) { |
| | | _item.elements = _item.elements.map(cell => { |
| | | cell.uuid = Utils.getuuid() |
| | | return cell |
| | | }) |
| | | } else if (_item.type === 'action' && _item.elements) { |
| | | _item.elements = _item.elements.map(cell => { |
| | | let _uuid = Utils.getuuid() |
| | | if (cell.OpenType === 'popview') { |
| | | let _cell = fromJS(cell).toJS() |
| | | _cell.$originUuid = _cell.uuid |
| | | _cell.uuid = _uuid |
| | | copyBtns.set(_uuid, _cell) |
| | | } |
| | | cell.uuid = _uuid |
| | | return cell |
| | | }) |
| | | } |
| | | return _item |
| | | }) |
| | | } |
| | | |
| | | return item |
| | |
| | | |
| | | let type = res.copyType |
| | | let config = fromJS(this.props.config).toJS() |
| | | let copyBtns = new Map() |
| | | |
| | | res = this.resetconfig(res) |
| | | res = this.resetconfig(res, copyBtns) |
| | | delete res.copyType |
| | | |
| | | copyBtns = [...copyBtns.values()] |
| | | |
| | | if (copyBtns.length > 0) { |
| | | MKEmitter.emit('copyButtons', copyBtns) |
| | | } |
| | | |
| | | if (type === 'action') { |
| | | config.action = config.action || [] |
| | | config.action = config.action.filter(item => !item.origin) |
| | | |
| | | config.action.push(res) |
| | | MKEmitter.emit('addButton', config.uuid, res) |
| | | } else if (type === 'search' || type === 'form') { |
| | | config.search = config.search || [] |
| | | config.search = config.search.filter(item => !item.origin) |
| | |
| | | config.search.push(res) |
| | | } else if (type === 'cardcell') { |
| | | config.subcards.push(res) |
| | | } else if (type === 'cols') { |
| | | config.cols = config.cols.filter(col => !col.origin) |
| | | |
| | | let keys = config.cols.map(col => (col.field || '$empty')) |
| | | |
| | | res.cols.forEach(col => { |
| | | if (!keys.includes(col.field)) { |
| | | config.cols.push(col) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | this.props.updateConfig(config) |