From 31871ca836e6fcbea9b1c54e2ec15f49667bf093 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 23 十二月 2022 14:14:04 +0800 Subject: [PATCH] 2022-12-23 --- src/menu/components/table/base-table/columns/index.jsx | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 53 insertions(+), 3 deletions(-) diff --git a/src/menu/components/table/base-table/columns/index.jsx b/src/menu/components/table/base-table/columns/index.jsx index a5f8102..07ec61f 100644 --- a/src/menu/components/table/base-table/columns/index.jsx +++ b/src/menu/components/table/base-table/columns/index.jsx @@ -3,7 +3,7 @@ import { is, fromJS } from 'immutable' import { DndProvider, DragSource, DropTarget } from 'react-dnd' import { Table, Popover, Modal, message, notification } from 'antd' -import { PlusOutlined, EditOutlined, CopyOutlined, DeleteOutlined, FontColorsOutlined, CloseCircleOutlined, AntDesignOutlined } from '@ant-design/icons' +import { PlusOutlined, EditOutlined, CopyOutlined, DeleteOutlined, FontColorsOutlined, CloseCircleOutlined, AntDesignOutlined, InfoOutlined } from '@ant-design/icons' import asyncComponent from '@/utils/asyncComponent' import asyncIconComponent from '@/utils/asyncIconComponent' @@ -138,6 +138,34 @@ DragSource('col', rowSource, connect => ({ connectDragSource: connect.dragSource(), }))(HeaderCol), +) + +class HeaderEmptyCol extends Component { + render() { + const { connectDragSource, connectDropTarget } = this.props + + return connectDragSource( + connectDropTarget(<div style={{border: '1px solid #e8e8e8', textAlign: 'center', height: '100px', lineHeight: '100px', color: '#bcbcbc'}}>璇锋坊鍔犳樉绀哄垪</div>) + ) + } +} + +const ColEmptyTarget = { + drop(props, monitor) { + const item = monitor.getItem() + + if (item.$init) { + props.dropCol(item, 0) + } + } +} + +const DragableEmptyCol = DropTarget('col', ColEmptyTarget, connect => ({ + connectDropTarget: connect.dropTarget() +}))( + DragSource('col', rowSource, connect => ({ + connectDragSource: connect.dragSource(), + }))(HeaderEmptyCol) ) class EditableColumnCell extends Component { @@ -560,6 +588,27 @@ }) } + copyFields = () => { + const { config } = this.props + let m = [] + let n = [] + + config.columns.forEach(col => { + m.push(`${col.field}(${col.label})`) + n.push(col.field) + }) + + let oInput = document.createElement('input') + oInput.value = `/*${m.join(',')}*/ + ${n.join(',')}` + document.body.appendChild(oInput) + oInput.select() + document.execCommand('Copy') + document.body.removeChild(oInput) + + message.success('澶嶅埗鎴愬姛銆�') + } + componentDidMount () { MKEmitter.addListener('plusColumns', this.plusColumns) } @@ -604,6 +653,7 @@ <FieldsComponent config={config} type="columns" /> <CopyOutlined title="澶嶅埗鏄剧ず鍒�" onClick={this.copycolumn} /> <MarkColumn columns={fields} type="line" marks={lineMarks} onSubmit={this.updateLineMarks} /> + <InfoOutlined title="澶嶅埗瀛楁" style={{color: 'orange'}} onClick={this.copyFields}/> </div> <DndProvider> {groups ? groups.map((group, i) => { @@ -626,7 +676,7 @@ } : false} /> }) : - <Table + (columns.length === 0 ? <DragableEmptyCol dropCol={this.dropCol}/> : <Table rowKey="uuid" size={config.wrap.size || 'middle'} bordered={config.wrap.bordered !== 'false'} @@ -642,7 +692,7 @@ total: 58, showTotal: (total, range) => `${range[0]}-${range[1]} 鍏� ${total} 鏉 }} - />} + />)} </DndProvider> <EditColumn column={card} fields={fields} submitCol={this.submitCol} cancelCol={this.cancelCol}/> </div> -- Gitblit v1.8.0