From 3d71e181be80c0a1cbb03aff2afecb4351496d46 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 25 十一月 2022 11:19:21 +0800 Subject: [PATCH] Merge branch 'master' into positec --- src/menu/components/table/base-table/columns/index.jsx | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 52 insertions(+), 8 deletions(-) diff --git a/src/menu/components/table/base-table/columns/index.jsx b/src/menu/components/table/base-table/columns/index.jsx index cc47ae6..a5f8102 100644 --- a/src/menu/components/table/base-table/columns/index.jsx +++ b/src/menu/components/table/base-table/columns/index.jsx @@ -12,7 +12,7 @@ import './index.scss' const { confirm } = Modal -const EditColumn = asyncIconComponent(() => import('./editColumn')) +const EditColumn = asyncComponent(() => import('./editColumn')) const MarkColumn = asyncIconComponent(() => import('@/menu/components/share/markcomponent')) const CardCellComponent = asyncComponent(() => import('@/menu/components/card/cardcellcomponent')) const PasteComponent = asyncIconComponent(() => import('@/components/paste')) @@ -53,8 +53,14 @@ const { connectDragSource, connectDropTarget, moveCol, addElement, dropCol, updateCol, editColumn, pasteCell, changeStyle, deleteCol, index, column, align, fields, children, ...restProps } = this.props if (index !== undefined) { + let style = {cursor: 'move', textAlign: align} + if (column.Width) { + style.width = column.Width + style.minWidth = column.Width + } + return connectDragSource( - connectDropTarget(<th {...restProps} index={index} style={{ cursor: 'move', textAlign: align }} onDoubleClick={() => column && this.props.editColumn(column)}> + connectDropTarget(<th {...restProps} index={index} style={style} onDoubleClick={() => column && this.props.editColumn(column)}> <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ <div className="mk-popover-control" onDoubleClick={(e) => e.stopPropagation()}> {column && ['custom', 'colspan', 'action'].includes(column.type) ? @@ -72,8 +78,13 @@ </th>), ) } else if (column) { + let style = {textAlign: align} + if (column.Width) { + style.width = column.Width + style.minWidth = column.Width + } return ( - <th {...restProps} key={column.uuid} onDoubleClick={() => this.props.editColumn(column)}> + <th {...restProps} style={style} key={column.uuid} onDoubleClick={() => this.props.editColumn(column)}> <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ <div className="mk-popover-control" onDoubleClick={(e) => e.stopPropagation()}> {column && ['custom', 'colspan'].includes(column.type) ? @@ -150,13 +161,13 @@ if (column && column.type === 'custom') { return ( - <td style={{padding: 0, minWidth: (column.Width || 100) / 2, ...(column.style || {})}} className={className}> + <td style={{padding: 0, ...(column.style || {})}} className={className}> <CardCellComponent cards={config} cardCell={column} elements={column.elements} updateElement={this.updateCard}/> </td> ) } else if (column && column.type === 'action') { return ( - <td style={{padding: '0 5px', textAlign: column.Align, minWidth: (column.Width || 100) / 2}} className={'action-column ' + className}> + <td style={{padding: '0 5px', textAlign: column.Align}} className={'action-column ' + className}> <CardCellComponent cards={config} cardCell={column} elements={column.elements} updateElement={this.updateCard}/> </td> ) @@ -172,7 +183,7 @@ } } return ( - <td style={{...style, minWidth: (column.Width || 100) / 2}} className={className}> + <td style={{...style}} className={className}> {val} {column.Hide === 'true' ? <CloseCircleOutlined style={{marginLeft: '5px', color: 'orange', fontSize: '12px'}}/> : null} {column.marks && column.marks.length ? <AntDesignOutlined className="profile"/> : null} @@ -313,6 +324,10 @@ let config = {...this.props.config, cols: _columns} if (btn) { config.action = config.action.filter(item => item.uuid !== btn.uuid) + + setTimeout(() => { + MKEmitter.emit('revert', config.uuid) + }, 200) } this.props.updatecolumn(config) @@ -572,6 +587,16 @@ } const columns = this.handlecolumns(this.state.columns, fields, config) + let groups = null + if (columns.length > 12) { + let g = Math.ceil(columns.length / 8) + let n = Math.ceil(columns.length / g) + groups = [] + + for (let i = 0, len = columns.length; i < len; i += n) { + groups.push(columns.slice(i, i + n)) + } + } return ( <div className={`normal-table-columns ${config.setting.laypage} ${config.wrap.tableType} ${config.wrap.mode || ''}`} id={tableId}> @@ -581,10 +606,29 @@ <MarkColumn columns={fields} type="line" marks={lineMarks} onSubmit={this.updateLineMarks} /> </div> <DndProvider> + {groups ? groups.map((group, i) => { + return <Table + key={i} + rowKey="uuid" + size={config.wrap.size || 'middle'} + bordered={config.wrap.bordered !== 'false'} + components={components} + dataSource={this.state.data} + rowSelection={config.wrap.tableType && i === 0 ? { type: 'radio' } : null} + columns={group} + pagination={i === groups.length - 1 ? { + current: 1, + pageSize: 10, + pageSizeOptions: ['10', '25', '50', '100', '500', '1000'], + showSizeChanger: true, + total: 58, + showTotal: (total, range) => `${range[0]}-${range[1]} 鍏� ${total} 鏉 + } : false} + /> + }) : <Table rowKey="uuid" size={config.wrap.size || 'middle'} - rowClassName="editable-row" bordered={config.wrap.bordered !== 'false'} components={components} dataSource={this.state.data} @@ -598,7 +642,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