king
2024-06-14 2c573446cd5059b09c06c8673eaf1f51f43967ce
src/menu/components/table/edit-table/columns/index.jsx
@@ -16,6 +16,7 @@
const EditColumn = asyncComponent(() => import('./editColumn'))
const TableVerify = asyncComponent(() => import('./tableIn'))
const MarkColumn = asyncIconComponent(() => import('@/menu/components/share/markcomponent'))
const ColsControl = asyncIconComponent(() => import('@/menu/components/share/colsControl'))
const CardCellComponent = asyncComponent(() => import('@/menu/components/card/cardcellcomponent'))
const PasteComponent = asyncIconComponent(() => import('@/components/paste'))
@@ -37,6 +38,32 @@
    this.props.updateCol({...column, marks: vals})
  }
  copycolumn = () => {
    const { column } = this.props
    let oInput = document.createElement('input')
    let val = {
      copyType: 'editcols',
      cols: [column]
    }
    let srcid = localStorage.getItem(window.location.href.split('#')[0] + '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) {
    if (this.props.rowSpan !== nextProps.rowSpan || this.props.colSpan !== nextProps.colSpan) {
@@ -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}>
@@ -189,8 +219,9 @@
class NormalTableColumns extends Component {
  static propTpyes = {
    config: PropTypes.object,       // 配置信息
    updatecolumn: PropTypes.func    // 数据变化
    config: PropTypes.object,
    updatecolumn: PropTypes.func,
    addColumns: PropTypes.func
  }
  state = {
@@ -249,13 +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.submit), fromJS(nextProps.config.submit)) ||
      !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) => {
@@ -412,6 +437,8 @@
  submitCol = (col) => {
    const { card } = this.state
    
    if (!card) return
    col.uuid = card.uuid
    col.isSub = card.isSub === true
    col.marks = card.marks || []
@@ -522,7 +549,7 @@
    let oInput = document.createElement('input')
    let val = {
      copyType: 'cols',
      copyType: 'editcols',
      cols: columns.filter(col => !col.origin)
    }
@@ -610,10 +637,6 @@
    })
  }
  componentDidMount () {
    MKEmitter.addListener('submitStyle', this.getStyle)
  }
  /**
   * @description 组件销毁,清除state更新,清除快捷键设置
   */
@@ -621,7 +644,6 @@
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('submitStyle', this.getStyle)
  }
  handlecolumns = (columns, fields, config, pId) => {
@@ -694,8 +716,10 @@
          } trigger="hover">
            <Button className="submit-btn" style={config.submit.style} onDoubleClick={() => this.setState({visible: true})} type="primary">提交</Button>
          </Popover>
          <PlusOutlined title="添加列" onClick={this.props.addColumns}/>
          <CopyOutlined title="复制显示列" onClick={this.copycolumn} />
          <MarkColumn columns={fields} type="line" marks={lineMarks} onSubmit={this.updateLineMarks} />
          <ColsControl config={config} onSubmit={this.props.updatecolumn}/>
          <FileSyncOutlined title="同步字段集" onClick={this.syncfield} />
          <DeleteOutlined title="清空显示列" onClick={this.clear}/>
        </div>
@@ -718,7 +742,7 @@
            }}
          />
        </DndProvider>
        <EditColumn column={card} columns={this.state.columns} fields={fields} submitCol={this.submitCol} cancelCol={this.cancelCol}/>
        <EditColumn column={card} wrap={config.wrap} columns={this.state.columns} fields={fields} submitCol={this.submitCol} cancelCol={this.cancelCol}/>
        <Modal
          wrapClassName="mk-pop-modal"
          visible={visible}