From f3d4db769ba9b51b799d981511a710fd443d0e08 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 21 四月 2025 12:18:03 +0800 Subject: [PATCH] Merge branch 'master' into positec --- src/menu/components/table/edit-table/columns/index.jsx | 86 +++++++++++++++++++++++++------------------ 1 files changed, 50 insertions(+), 36 deletions(-) diff --git a/src/menu/components/table/edit-table/columns/index.jsx b/src/menu/components/table/edit-table/columns/index.jsx index 4897eff..16de3eb 100644 --- a/src/menu/components/table/edit-table/columns/index.jsx +++ b/src/menu/components/table/edit-table/columns/index.jsx @@ -16,17 +16,18 @@ 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')) class HeaderCol extends Component { deleteCol = () => { - const _this = this + const that = this confirm({ content: '纭畾鍒犻櫎鏄剧ず鍒楀悧锛�', onOk() { - _this.props.deleteCol(_this.props.column) + that.props.deleteCol(that.props.column) }, onCancel() {} }) @@ -35,6 +36,27 @@ updateMarks = (vals) => { const { column } = this.props this.props.updateCol({...column, marks: vals}) + } + + copycolumn = () => { + const { column } = this.props + + let oInput = document.createElement('input') + let val = { + copyType: 'editcols', + cols: [column] + } + + 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) { @@ -48,7 +70,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 +100,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 +190,10 @@ 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 style={{fontWeight: 'inherit'}} dangerouslySetInnerHTML={{__html: val}}></span> - } + // if (column.eval === 'false') { + // val = val.replace(/\n/ig, '<br/>').replace(/\s/ig, ' ') + // val = <span style={{fontWeight: 'inherit'}} dangerouslySetInnerHTML={{__html: val}}></span> + // } } return ( <td style={style} className={className}> @@ -189,8 +214,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 +275,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) => { @@ -361,7 +381,7 @@ if (!cell.eleType) { if (cell.copyType === 'action') { cell.eleType = 'button' - cell.width = cell.width || 12 + cell.width = cell.width || cell.width === 0 ? cell.width : 12 } else { cell.eleType = 'text' } @@ -411,6 +431,8 @@ submitCol = (col) => { const { card } = this.state + + if (!card) return col.uuid = card.uuid col.isSub = card.isSub === true @@ -522,13 +544,8 @@ let oInput = document.createElement('input') let val = { - copyType: 'cols', + copyType: 'editcols', cols: columns.filter(col => !col.origin) - } - - let srcid = localStorage.getItem(window.location.href.split('#')[0] + 'srcId') - if (srcid) { - val.$srcId = srcid } oInput.value = window.btoa(window.encodeURIComponent(JSON.stringify(val))) @@ -570,13 +587,13 @@ columns.push(cell) }) - const _this = this + const that = this confirm({ content: '纭畾鍚屾瀛楁闆嗗悧锛�', onOk() { - _this.setState({columns}, () => { - _this.props.updatecolumn({..._this.props.config, cols: columns}) + that.setState({columns}, () => { + that.props.updatecolumn({...that.props.config, cols: columns}) }) }, onCancel() {} @@ -584,13 +601,13 @@ } clear = () => { - const _this = this + const that = this confirm({ content: '纭畾娓呯┖鏄剧ず鍒楀悧锛�', onOk() { - _this.setState({columns: []}, () => { - _this.props.updatecolumn({..._this.props.config, cols: []}) + that.setState({columns: []}, () => { + that.props.updatecolumn({...that.props.config, cols: []}) }) }, onCancel() {} @@ -610,10 +627,6 @@ }) } - componentDidMount () { - MKEmitter.addListener('submitStyle', this.getStyle) - } - /** * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 */ @@ -621,7 +634,6 @@ this.setState = () => { return } - MKEmitter.removeListener('submitStyle', this.getStyle) } handlecolumns = (columns, fields, config, pId) => { @@ -694,8 +706,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 +732,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} -- Gitblit v1.8.0