king
2021-05-25 2f95e9ca3984bba9bfe602596c2401e98e84f323
src/menu/components/table/normal-table/columns/index.jsx
@@ -49,7 +49,7 @@
  }
  render() {
    const { connectDragSource, connectDropTarget, moveCol, addElement, updateCol, editColumn, deleteCol, index, column, align, fields, children, ...restProps } = this.props
    const { connectDragSource, connectDropTarget, moveCol, addElement, updateCol, editColumn, changeStyle, deleteCol, index, column, align, fields, children, ...restProps } = this.props
    if (index !== undefined) {
      return connectDragSource(
@@ -60,6 +60,7 @@
                <Icon className="plus" title="添加" type="plus" onClick={() => this.props.addElement(column)} /> : null
              }
              <Icon className="edit" title="编辑" type="edit" onClick={() => this.props.editColumn(column)} />
              {column && column.type === 'custom' ? <Icon className="style" title="调整样式" onClick={() => this.props.changeStyle(column)} type="font-colors" /> : null}
              <Icon className="close" title="删除" type="delete" onClick={this.deleteCol} />
              {column && ['text', 'number'].includes(column.type) ? <MarkColumn columns={fields} marks={column.marks} onSubmit={this.updateMarks} /> : null }
            </div>
@@ -143,7 +144,7 @@
    if (column && column.type === 'custom') {
      return (
        <td style={{padding: 0, minWidth: column.Width || 100}} className={className}>
        <td style={{padding: 0, minWidth: column.Width || 100, ...(column.style || {})}} className={className}>
          <CardCellComponent cards={config} cardCell={column} elements={column.elements} updateElement={this.updateCard}/>
        </td>
      )
@@ -183,6 +184,7 @@
    refresh: false,    // 强制刷新
    columns: [],
    fields: [],
    editStyleCard: null,
    lineMarks: []
  }
@@ -343,6 +345,24 @@
    this.updateCol(col)
  }
  changeStyle = (col) => {
    this.setState({
      editStyleCard: fromJS(col).toJS()
    })
    MKEmitter.emit('changeStyle', [col.uuid], ['font', 'padding'], col.style || {})
  }
  getStyle = (comIds, style) => {
    const { editStyleCard } = this.state
    if (!editStyleCard || comIds[0] !== editStyleCard.uuid || comIds.length !== 1) return
    let _card = {...editStyleCard, style}
    this.updateCol(_card)
  }
  cancelCol = () => {
    const { card } = this.state
@@ -435,6 +455,7 @@
          updateCol: this.updateCol,
          addElement: this.addElement,
          editColumn: this.editColumn,
          changeStyle: this.changeStyle,
          deleteCol: this.deleteCol,
        }),
        children: col.subcols && col.subcols.length ? this.handlecolumns(col.subcols, fields, config, true) : null,
@@ -482,6 +503,20 @@
    })
  }
  componentDidMount () {
    MKEmitter.addListener('submitStyle', this.getStyle)
  }
  /**
   * @description 组件销毁,清除state更新,清除快捷键设置
   */
  componentWillUnmount () {
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('submitStyle', this.getStyle)
  }
  render() {
    const { config } = this.props
    const { fields, card, lineMarks, dict, tableId } = this.state