king
2022-09-16 66cc7818cf5e13c44f4372e7d47fb72df7d2f752
src/menu/components/table/normal-table/columns/index.jsx
@@ -53,7 +53,7 @@
  }
  render() {
    const { connectDragSource, connectDropTarget, moveCol, addElement, updateCol, editColumn, pasteCell, changeStyle, deleteCol, index, column, align, fields, children, ...restProps } = this.props
    const { connectDragSource, connectDropTarget, moveCol, dropCol, addElement, updateCol, editColumn, pasteCell, changeStyle, deleteCol, index, column, align, fields, children, ...restProps } = this.props
    if (index !== undefined) {
      return connectDragSource(
@@ -109,10 +109,14 @@
const ColTarget = {
  drop(props, monitor) {
    const dragIndex = monitor.getItem().index
    const item = monitor.getItem()
    const dragIndex = item.index
    const hoverIndex = props.index
    if (dragIndex === undefined || hoverIndex === undefined || dragIndex === hoverIndex) {
    if (item.$init) {
      props.dropCol(item, hoverIndex)
      return
    } else if (dragIndex === undefined || hoverIndex === undefined || dragIndex === hoverIndex) {
      return
    }
@@ -274,6 +278,20 @@
    })
  }
  dropCol = (item, hoverIndex) => {
    let _columns = fromJS(this.state.columns).toJS()
    let col = { focus: true, uuid: Utils.getuuid(), label: 'label', field: '', type: item.subType, elements: [] }
    _columns.splice(hoverIndex, 0, col)
    this.setState({
      columns: _columns
    }, () => {
      this.editColumn(col)
    })
  }
  loopCol = (columns, col) => {
    return columns.map(column => {
      if (column.type === 'colspan') {
@@ -315,11 +333,10 @@
    cell.uuid = Utils.getuuid()
    cell.focus = true
    
    MKEmitter.emit('cardAddElement', [this.props.config.uuid, col.uuid], cell)
    MKEmitter.emit('cardAddElement', col.uuid, cell)
  }
  addElement = (col) => {
    const { config } = this.props
    let column = fromJS(col).toJS()
    if (column.type === 'colspan') {
@@ -335,7 +352,7 @@
      let newcard = {uuid: Utils.getuuid(), focus: true, width: 24, eleType: 'text', datatype: 'dynamic', style: {paddingLeft: '4px'}}
  
      // 注册事件-添加元素
      MKEmitter.emit('cardAddElement', [config.uuid, column.uuid], newcard)
      MKEmitter.emit('cardAddElement', column.uuid, newcard)
    } else if (column.type === 'action') {
      let newcard = {
        uuid: Utils.getuuid(),
@@ -351,7 +368,7 @@
      }
      // 注册事件-添加元素
      MKEmitter.emit('cardAddElement', [config.uuid, column.uuid], newcard)
      MKEmitter.emit('cardAddElement', column.uuid, newcard)
    }
  }
@@ -492,6 +509,7 @@
          fields: fields,
          align: col.Align,
          moveCol: this.moveCol,
          dropCol: this.dropCol,
          updateCol: this.updateCol,
          addElement: this.addElement,
          editColumn: this.editColumn,