king
2022-02-09 d59f518f466274b2caeb2e01c10c92deafe7c93b
src/menu/components/table/edit-table/columns/index.jsx
@@ -2,7 +2,8 @@
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { DndProvider, DragSource, DropTarget } from 'react-dnd'
import { Table, Popover, Icon, Modal, message, Button } from 'antd'
import { Table, Popover, Modal, message, Button } from 'antd'
import { PlusOutlined, FileSyncOutlined, EditOutlined, CopyOutlined, DeleteOutlined, FontColorsOutlined, CloseCircleOutlined, AntDesignOutlined } from '@ant-design/icons'
import asyncComponent from '@/utils/asyncComponent'
import asyncIconComponent from '@/utils/asyncIconComponent'
@@ -55,14 +56,14 @@
    return connectDragSource(
      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">
          <div className="mk-popover-control" onDoubleClick={(e) => e.stopPropagation()}>
            {column && ['custom', 'action'].includes(column.type) ?
              <Icon className="plus" title="添加" type="plus" onClick={() => this.props.addElement(column)} /> : null
              <PlusOutlined className="plus" title="添加" 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 }
            <EditOutlined className="edit" title="编辑" onClick={() => this.props.editColumn(column)} />
            {column && column.type === 'custom' ? <FontColorsOutlined className="style" title="调整样式" onClick={() => this.props.changeStyle(column)}/> : null}
            <DeleteOutlined className="close" title="删除" onClick={this.deleteCol} />
            {column && ['text', 'number', 'formula'].includes(column.type) ? <MarkColumn columns={fields} marks={column.marks} onSubmit={this.updateMarks} /> : null }
          </div>
        } trigger="hover">
          {children}
@@ -135,11 +136,21 @@
        </td>
      )
    } else if (column) {
      let val = column.field || ''
      if (column.type === 'index') {
        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 dangerouslySetInnerHTML={{__html: val}}></span>
        }
      }
      return (
        <td style={{...style, minWidth: column.Width || 100}} className={className}>
          {column.field || (column.type === 'index' ? '$Index' : '')}
          {column.Hide === 'true' ? <Icon style={{marginLeft: '5px', color: 'orange', fontSize: '12px'}} type="close-circle" /> : null}
          {column.marks && column.marks.length ? <Icon className="profile" type="ant-design"/> : null}
          {val}
          {column.Hide === 'true' ? <CloseCircleOutlined style={{marginLeft: '5px', color: 'orange', fontSize: '12px'}}/> : null}
          {column.marks && column.marks.length ? <AntDesignOutlined className="profile"/> : null}
        </td>
      )
    } else {
@@ -270,7 +281,7 @@
    let column = fromJS(col).toJS()
    if (column.type === 'custom') {
      let newcard = {uuid: Utils.getuuid(), focus: true, eleType: 'text', datatype: 'dynamic', style: {paddingLeft: '4px'}}
      let newcard = {uuid: Utils.getuuid(), focus: true, width: 24, eleType: 'text', datatype: 'dynamic', style: {paddingLeft: '4px'}}
  
      // 注册事件-添加元素
      MKEmitter.emit('cardAddElement', [config.uuid, column.uuid], newcard)
@@ -285,8 +296,7 @@
        intertype: 'system',
        execSuccess: 'grid',
        execError: 'never',
        show: 'link',
        $type: 'tableButton'
        show: 'link'
      }
      // 注册事件-添加元素
@@ -420,7 +430,7 @@
      let cell = { uuid: Utils.getuuid(), label: item.label, field: item.field, Align: 'left', Hide: 'false', IsSort: 'false', Width: 120, blacklist: [], postfix: '', prefix: '', linkmenu: [], marks: [], perspective: 'linkmenu' }
      
      if (/Nvarchar/ig.test(item.datatype)) {
      if (/Nvarchar|date/ig.test(item.datatype)) {
        cell.type = 'text'
        cell.rowspan = 'false'
        cell.textFormat = 'none'
@@ -429,6 +439,7 @@
        cell.format = 'none'
        cell.sum = 'false'
        cell.decimal = item.decimal || 0
        cell.Width = 80
      }
      columns.push(cell)
@@ -503,7 +514,7 @@
    const columns = this.state.columns.map((col, index) => {
      let title = col.label
      if (col.editable === 'true') {
        title = <span>{col.label}<Icon style={{position: 'absolute', bottom: 0, right: 0, color: '#1890ff'}} type="edit" /></span>
        title = <span>{col.label}<EditOutlined style={{position: 'absolute', bottom: 0, right: 0, color: '#1890ff'}}/></span>
      }
      return {
        title: title,
@@ -544,16 +555,16 @@
        <div className="col-control">
          <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
            <div className="mk-popover-control">
              <Icon className="edit" title="编辑" type="edit" onClick={() => this.setState({visible: true})} />
              <Icon className="style" title="调整样式" onClick={this.changeSubmitStyle} type="font-colors" />
              <EditOutlined className="edit" title="编辑" onClick={() => this.setState({visible: true})} />
              <FontColorsOutlined className="style" title="调整样式" onClick={this.changeSubmitStyle}/>
            </div>
          } trigger="hover">
            <Button className="submit-btn" style={config.submit.style} onDoubleClick={() => this.setState({visible: true})} type="primary">提交</Button>
          </Popover>
          <Icon title="复制显示列" type="copy" onClick={this.copycolumn} />
          <CopyOutlined title="复制显示列" onClick={this.copycolumn} />
          <MarkColumn columns={fields} type="line" marks={lineMarks} onSubmit={this.updateLineMarks} />
          <Icon title="同步字段集" type="file-sync" onClick={this.syncfield} />
          <Icon title="清空显示列" type="delete" onClick={this.clear}/>
          <FileSyncOutlined title="同步字段集" onClick={this.syncfield} />
          <DeleteOutlined title="清空显示列" onClick={this.clear}/>
        </div>
        <DndProvider>
          <Table