| | |
| | | connectDropTarget(<th {...restProps} index={index} style={{ cursor: 'move', textAlign: align }} onDoubleClick={() => column && this.props.editColumn(column)}> |
| | | <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control"> |
| | | {column && ['custom', 'colspan', 'action'].includes(column.type) ? |
| | | {column && ['custom', 'action'].includes(column.type) ? |
| | | <Icon className="plus" title="添加" type="plus" onClick={() => this.props.addElement(column)} /> : null |
| | | } |
| | | <Icon className="edit" title="编辑" type="edit" onClick={() => this.props.editColumn(column)} /> |
| | |
| | | <th {...restProps} key={column.uuid} onDoubleClick={() => this.props.editColumn(column)}> |
| | | <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control"> |
| | | {column && ['custom', 'colspan'].includes(column.type) ? |
| | | {column && ['custom'].includes(column.type) ? |
| | | <Icon className="plus" title="添加" type="plus" onClick={() => this.props.addElement(column)} /> : null |
| | | } |
| | | <Icon className="edit" title="编辑" type="edit" onClick={() => this.props.editColumn(column)} /> |
| | |
| | | }) |
| | | } |
| | | |
| | | loopCol = (columns, col) => { |
| | | return columns.map(column => { |
| | | if (column.type === 'colspan') { |
| | | column.subcols = this.loopCol(column.subcols, col) |
| | | } |
| | | updateCol = (col, btn) => { |
| | | let _columns = fromJS(this.state.columns).toJS() |
| | | _columns = _columns.map(column => { |
| | | if (column.uuid === col.uuid) { |
| | | return col |
| | | } |
| | | return column |
| | | }) |
| | | } |
| | | |
| | | updateCol = (col, btn) => { |
| | | let _columns = fromJS(this.state.columns).toJS() |
| | | _columns = this.loopCol(_columns, col) |
| | | |
| | | this.setState({ |
| | | columns: _columns, |
| | |
| | | const { config } = this.props |
| | | let column = fromJS(col).toJS() |
| | | |
| | | if (column.type === 'colspan') { |
| | | column.subcols = column.subcols || [] |
| | | let subcol = { isSub: true, focus: true, uuid: Utils.getuuid(), label: 'label', field: '', type: 'text' } |
| | | column.subcols.push(subcol) |
| | | |
| | | this.setState({ |
| | | card: subcol |
| | | }) |
| | | this.updateCol(column) |
| | | } else if (column.type === 'custom') { |
| | | if (column.type === 'custom') { |
| | | let newcard = {uuid: Utils.getuuid(), focus: true, eleType: 'text', datatype: 'dynamic', style: {paddingLeft: '4px'}} |
| | | |
| | | // 注册事件-添加元素 |
| | |
| | | col.isSub = card.isSub === true |
| | | col.marks = card.marks || [] |
| | | |
| | | if (col.type === 'colspan') { |
| | | col.subcols = card.subcols || [] |
| | | } else if (col.type === 'custom') { |
| | | if (col.type === 'custom') { |
| | | col.elements = card.type === 'custom' ? (card.elements || []) : [] |
| | | } else if (col.type === 'action') { |
| | | col.elements = card.type === 'action' ? (card.elements || []) : [] |
| | |
| | | this.setState({card: null}) |
| | | } |
| | | |
| | | loopDelCol = (columns, col) => { |
| | | return columns.filter(column => { |
| | | if (column.type === 'colspan') { |
| | | column.subcols = this.loopDelCol(column.subcols, col) |
| | | } |
| | | return column.uuid !== col.uuid |
| | | }) |
| | | } |
| | | |
| | | deleteCol = (col) => { |
| | | const { appType } = this.state |
| | | let _columns = fromJS(this.state.columns).toJS() |
| | | |
| | | _columns = this.loopDelCol(_columns, col) |
| | | _columns = _columns.filter(column => column.uuid !== col.uuid) |
| | | |
| | | this.setState({ |
| | | columns: _columns |