From d59f518f466274b2caeb2e01c10c92deafe7c93b Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 09 二月 2022 11:48:29 +0800 Subject: [PATCH] 2022-02-09 --- src/menu/components/table/edit-table/columns/index.jsx | 115 +++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 91 insertions(+), 24 deletions(-) diff --git a/src/menu/components/table/edit-table/columns/index.jsx b/src/menu/components/table/edit-table/columns/index.jsx index 639a389..4ed5e10 100644 --- a/src/menu/components/table/edit-table/columns/index.jsx +++ b/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 } 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' @@ -14,6 +15,7 @@ const { confirm } = Modal const EditColumn = asyncComponent(() => import('./editColumn')) +const TableVerify = asyncComponent(() => import('./tableIn')) const MarkColumn = asyncIconComponent(() => import('@/menu/components/share/markcomponent')) const CardCellComponent = asyncComponent(() => import('@/menu/components/card/cardcellcomponent')) @@ -54,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} @@ -134,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, ' ') + 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 { @@ -219,6 +231,7 @@ 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.search), fromJS(nextProps.config.search)) || !is(fromJS(config.action), fromJS(nextProps.config.action)) || config.setting.laypage !== nextProps.config.setting.laypage @@ -268,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) @@ -283,8 +296,7 @@ intertype: 'system', execSuccess: 'grid', execError: 'never', - show: 'link', - $type: 'tableButton' + show: 'link' } // 娉ㄥ唽浜嬩欢-娣诲姞鍏冪礌 @@ -294,10 +306,6 @@ submitCol = (col) => { const { card } = this.state - - col.uuid = card.uuid - col.isSub = card.isSub === true - col.marks = card.marks || [] if (col.type === 'custom') { col.elements = card.type === 'custom' ? (card.elements || []) : [] @@ -317,10 +325,24 @@ MKEmitter.emit('changeStyle', [col.uuid], ['font', 'padding'], col.style || {}) } + changeSubmitStyle = () => { + const { config } = this.props + + MKEmitter.emit('changeStyle', [config.uuid, 'submit'], ['font', 'background', 'border', 'margin', 'padding'], config.submit.style || {}) + } + getStyle = (comIds, style) => { + const { config } = this.props const { editStyleCard } = this.state - if (!editStyleCard || comIds[0] !== editStyleCard.uuid || comIds.length !== 1) return + if (comIds.length === 2 && comIds[0] === config.uuid && comIds[1] === 'submit') { + let submit = {...config.submit, style} + + this.props.updatecolumn({...config, submit: submit}) + + return + } + if (comIds.length !== 1 || !editStyleCard || comIds[0] !== editStyleCard.uuid) return let _card = {...editStyleCard, style} @@ -408,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' @@ -417,6 +439,7 @@ cell.format = 'none' cell.sum = 'false' cell.decimal = item.decimal || 0 + cell.Width = 80 } columns.push(cell) @@ -449,6 +472,19 @@ }) } + verifySubmit = () => { + const { config } = this.props + + this.verifyRef.handleConfirm().then(res => { + res.style = config.submit.style || {} + this.setState({ + visible: false + }, () => { + this.props.updatecolumn({...config, submit: res}) + }) + }) + } + componentDidMount () { MKEmitter.addListener('submitStyle', this.getStyle) } @@ -465,7 +501,7 @@ render() { const { config } = this.props - const { fields, card, lineMarks, dict, tableId } = this.state + const { fields, card, lineMarks, dict, tableId, visible } = this.state const components = { header: { cell: DragableHeaderCol @@ -476,8 +512,12 @@ } const columns = this.state.columns.map((col, index) => { + let title = col.label + if (col.editable === 'true') { + title = <span>{col.label}<EditOutlined style={{position: 'absolute', bottom: 0, right: 0, color: '#1890ff'}}/></span> + } return { - title: col.label, + title: title, dataIndex: col.uuid, align: col.Align, sorter: col.IsSort === 'true', @@ -513,10 +553,18 @@ return ( <div className={`edit-table-columns ${config.setting.laypage} ${config.wrap.mode || ''}`} id={tableId}> <div className="col-control"> - <Icon title="澶嶅埗鏄剧ず鍒�" type="copy" onClick={this.copycolumn} /> + <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ + <div className="mk-popover-control"> + <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> + <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 @@ -539,6 +587,25 @@ /> </DndProvider> <EditColumn column={card} dict={dict} columns={this.state.columns} fields={fields} submitCol={this.submitCol} cancelCol={this.cancelCol}/> + <Modal + wrapClassName="model-table-action-verify-modal" + title={'缂栬緫'} + visible={visible} + width={'75vw'} + maskClosable={false} + onOk={this.verifySubmit} + onCancel={() => { this.setState({ visible: false }) }} + destroyOnClose + > + <TableVerify + card={config.submit} + setting={config.setting} + dict={dict} + cols={config.cols} + columns={config.columns} + wrappedComponentRef={(inst) => this.verifyRef = inst} + /> + </Modal> </div> ) } -- Gitblit v1.8.0