king
2024-08-25 326aa6b3effaccc71cfe0775d47b0f29eb3695a6
src/menu/components/table/normal-table/columns/index.jsx
@@ -12,21 +12,22 @@
import './index.scss'
const { confirm } = Modal
const { Paragraph } = Typography
const { Paragraph } = Typography
const EditColumn = asyncComponent(() => import('./editColumn'))
const MarkColumn = asyncIconComponent(() => import('@/menu/components/share/markcomponent'))
const CardCellComponent = asyncComponent(() => import('@/menu/components/card/cardcellcomponent'))
const MobPagination = asyncIconComponent(() => import('@/menu/components/share/mobPagination'))
const ColsControl = asyncIconComponent(() => import('@/menu/components/share/colsControl'))
const PasteComponent = asyncIconComponent(() => import('@/components/paste'))
class HeaderCol extends Component {
  deleteCol = () => {
    const _this = this
    const that = this
    confirm({
      content: '确定删除显示列吗?',
      onOk() {
        _this.props.deleteCol(_this.props.column)
        that.props.deleteCol(that.props.column)
      },
      onCancel() {}
    })
@@ -35,6 +36,32 @@
  updateMarks = (vals) => {
    const { column } = this.props
    this.props.updateCol({...column, marks: vals})
  }
  copycolumn = () => {
    const { column } = this.props
    let oInput = document.createElement('input')
    let val = {
      copyType: 'cols',
      cols: [column]
    }
    let srcid = localStorage.getItem(window.GLOB.sysSign + 'srcId')
    if (srcid) {
      val.$srcId = srcid
    }
    oInput.value = window.btoa(window.encodeURIComponent(JSON.stringify(val)))
    document.body.appendChild(oInput)
    oInput.select()
    document.execCommand('Copy')
    oInput.className = 'oInput'
    oInput.style.display = 'none'
    message.success('复制成功。')
    document.body.removeChild(oInput)
  }
  shouldComponentUpdate (nextProps, nextState) {
@@ -48,7 +75,9 @@
    return !is(fromJS(this.props.column), fromJS(nextProps.column)) ||
      !is(fromJS(this.props.fields), fromJS(nextProps.fields)) ||
      this.props.index !== nextProps.index ||
      window.GLOB.columnId === nextProps.column.uuid || window.GLOB.precolumnId === nextProps.column.uuid
      (nextProps.className && this.props.className !== nextProps.className) ||
      window.GLOB.columnId === nextProps.column.uuid ||
      window.GLOB.precolumnId === nextProps.column.uuid
  }
  render() {
@@ -76,10 +105,11 @@
            {column.type === 'custom' ? <PlusOutlined className="plus" title="添加元素" onClick={() => this.props.addElement(column)} /> : null}
            {column.type === 'custom' ? <PlusSquareOutlined className="plus" title="添加按钮" onClick={() => this.props.addElement(column, 'button')} /> : null}
            <EditOutlined className="edit" title="编辑" onClick={() => this.props.editColumn(column)} />
            <CopyOutlined title="复制显示列" style={{color: '#26C281'}} onClick={this.copycolumn} />
            {column.type === 'custom' ? <PasteComponent options={['customCardElement', 'action']} updateConfig={(res, resolve) => this.props.pasteCell(column, res, resolve)} /> : null}
            {column.type === 'custom' ? <FontColorsOutlined className="style" title="调整样式" onClick={() => this.props.changeStyle(column)}/> : null}
            <DeleteOutlined className="close" title="删除" onClick={this.deleteCol} />
            {['text', 'number', 'formula'].includes(column.type) ? <MarkColumn field={column.field || ''} columns={fields} marks={column.marks} onSubmit={this.updateMarks} /> : null }
            {['text', 'number', 'formula', 'extend'].includes(column.type) ? <MarkColumn field={column.field || ''} columns={fields} marks={column.marks} onSubmit={this.updateMarks} /> : null }
          </div>
        } trigger="hover">
          {children}
@@ -165,10 +195,10 @@
        val = '$Index'
      } else if (column.type === 'formula') {
        val = column.formula
        if (column.eval === 'false') {
          val = val.replace(/\n/ig, '<br/>').replace(/\s/ig, '&nbsp;')
          val = <span style={{fontWeight: 'inherit'}} dangerouslySetInnerHTML={{__html: val}}></span>
        }
        // if (column.eval === 'false') {
        //   val = val.replace(/\n/ig, '<br/>').replace(/\s/ig, '&nbsp;')
        //   val = <span style={{fontWeight: 'inherit'}} dangerouslySetInnerHTML={{__html: val}}></span>
        // }
      }
      return (
        <td style={{...style}} className={className}>
@@ -250,12 +280,7 @@
  }
  shouldComponentUpdate (nextProps, nextState) {
    const { config } = this.props
    return !is(fromJS(this.state), fromJS(nextState)) ||
      !is(fromJS(config.wrap), fromJS(nextProps.config.wrap)) ||
      !is(fromJS(config.action), fromJS(nextProps.config.action)) ||
      config.setting.laypage !== nextProps.config.setting.laypage
    return !is(fromJS(this.state), fromJS(nextState)) || !is(fromJS(this.props.config), fromJS(nextProps.config))
  }
  moveCol = (dragIndex, hoverIndex) => {
@@ -493,7 +518,7 @@
      cols: columns.filter(col => !col.origin)
    }
    let srcid = localStorage.getItem(window.location.href.split('#')[0] + 'srcId')
    let srcid = localStorage.getItem(window.GLOB.sysSign + 'srcId')
    if (srcid) {
      val.$srcId = srcid
    }
@@ -563,7 +588,6 @@
      } else {
        cell.type = 'number'
        cell.format = 'none'
        cell.sum = 'false'
        cell.decimal = item.decimal || 0
        cell.Width = 80
      }
@@ -571,13 +595,13 @@
      columns.push(cell)
    })
    const _this = this
    const that = this
    confirm({
      content: '确定同步字段集吗?',
      onOk() {
        _this.setState({columns}, () => {
          _this.props.updatecolumn({..._this.props.config, cols: columns})
        that.setState({columns}, () => {
          that.props.updatecolumn({...that.props.config, cols: columns})
        })
      },
      onCancel() {}
@@ -585,17 +609,23 @@
  }
  clear = () => {
    const _this = this
    const that = this
    confirm({
      content: '确定清空显示列吗?',
      onOk() {
        _this.setState({columns: []}, () => {
          _this.props.updatecolumn({..._this.props.config, cols: []})
        that.setState({columns: []}, () => {
          that.props.updatecolumn({...that.props.config, cols: []})
        })
      },
      onCancel() {}
    })
  }
  addColumns = () => {
    const { config } = this.props
    MKEmitter.emit('addColumns', config.uuid)
  }
  /**
@@ -624,8 +654,10 @@
    return (
      <div className={`normal-table-columns ${config.setting.laypage} ${config.wrap.tableType} ${config.wrap.mode || ''} table-vertical-${config.wrap.vertical || ''} table-col-${columns.length}`} id={tableId}>
        <div className="col-control">
          <PlusOutlined style={{color: '#26C281'}} title="添加列" onClick={this.addColumns}/>
          <CopyOutlined title="复制显示列" onClick={this.copycolumn} />
          <MarkColumn columns={fields} type="line" marks={lineMarks} onSubmit={this.updateLineMarks} />
          {appType !== 'mob' ? <ColsControl config={config} onSubmit={this.props.updatecolumn}/> : null}
          <FileSyncOutlined title="同步字段集" onClick={this.syncfield} />
          <DeleteOutlined title="清空显示列" onClick={this.clear}/>
        </div>