king
2021-10-05 f9180a3ab8813c3937c7ba30750763cd693d1d37
src/menu/components/table/edit-table/columns/index.jsx
@@ -56,7 +56,7 @@
        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)} />
@@ -74,7 +74,7 @@
        <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)} />
@@ -257,21 +257,14 @@
    })
  }
  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,
@@ -295,16 +288,7 @@
    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'}}
  
      // 注册事件-添加元素
@@ -336,9 +320,7 @@
    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 || []) : []
@@ -376,20 +358,11 @@
    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