From 1a11f7115e61c548f9ffc77d0a9e504307ca71b2 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 24 八月 2021 18:37:20 +0800 Subject: [PATCH] 2021-08-24 --- src/menu/components/table/normal-table/columns/index.jsx | 65 +++++++++++++++++++++++++++----- 1 files changed, 54 insertions(+), 11 deletions(-) diff --git a/src/menu/components/table/normal-table/columns/index.jsx b/src/menu/components/table/normal-table/columns/index.jsx index 0ddcf33..c88a996 100644 --- a/src/menu/components/table/normal-table/columns/index.jsx +++ b/src/menu/components/table/normal-table/columns/index.jsx @@ -49,7 +49,7 @@ } render() { - const { connectDragSource, connectDropTarget, moveCol, addElement, updateCol, editColumn, deleteCol, index, column, align, fields, children, ...restProps } = this.props + const { connectDragSource, connectDropTarget, moveCol, addElement, updateCol, editColumn, changeStyle, deleteCol, index, column, align, fields, children, ...restProps } = this.props if (index !== undefined) { return connectDragSource( @@ -60,6 +60,7 @@ <Icon className="plus" title="娣诲姞" type="plus" 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 } </div> @@ -143,7 +144,7 @@ if (column && column.type === 'custom') { return ( - <td style={{padding: 0, minWidth: column.Width || 100}} className={className}> + <td style={{padding: 0, minWidth: column.Width || 100, ...(column.style || {})}} className={className}> <CardCellComponent cards={config} cardCell={column} elements={column.elements} updateElement={this.updateCard}/> </td> ) @@ -156,7 +157,7 @@ } else if (column) { return ( <td style={{...style, minWidth: column.Width || 100}} className={className}> - {column.field} + {column.field || (column.type === 'index' ? '$Index' : '')} {column.marks && column.marks.length ? <Icon className="profile" type="ant-design"/> : null} </td> ) @@ -178,11 +179,13 @@ state = { dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, + appType: sessionStorage.getItem('appType'), tableId: '', data: [{uuid: Utils.getuuid()}], refresh: false, // 寮哄埗鍒锋柊 columns: [], fields: [], + editStyleCard: null, lineMarks: [] } @@ -343,6 +346,24 @@ this.updateCol(col) } + changeStyle = (col) => { + this.setState({ + editStyleCard: fromJS(col).toJS() + }) + + MKEmitter.emit('changeStyle', [col.uuid], ['font', 'padding'], col.style || {}) + } + + getStyle = (comIds, style) => { + const { editStyleCard } = this.state + + if (!editStyleCard || comIds[0] !== editStyleCard.uuid || comIds.length !== 1) return + + let _card = {...editStyleCard, style} + + this.updateCol(_card) + } + cancelCol = () => { const { card } = this.state @@ -363,22 +384,29 @@ } deleteCol = (col) => { + const { appType } = this.state let _columns = fromJS(this.state.columns).toJS() - _columns = this.loopDelCol(_columns, col) - if (col.type === 'action') { - let uuids = [] - col.elements && col.elements.forEach(c => { - uuids.push(c.uuid) - }) - MKEmitter.emit('delButtons', uuids) - } + _columns = this.loopDelCol(_columns, col) this.setState({ columns: _columns }, () => { this.props.updatecolumn({...this.props.config, cols: _columns}) }) + + if (col.type !== 'action' || appType === 'mob') return + + let uuids = [] + col.elements && col.elements.forEach(c => { + if (appType === 'pc' && c.OpenType !== 'popview') return + + uuids.push(c.uuid) + }) + + if (uuids.length === 0) return + + MKEmitter.emit('delButtons', uuids) } updateLineMarks = (vals) => { @@ -435,6 +463,7 @@ updateCol: this.updateCol, addElement: this.addElement, editColumn: this.editColumn, + changeStyle: this.changeStyle, deleteCol: this.deleteCol, }), children: col.subcols && col.subcols.length ? this.handlecolumns(col.subcols, fields, config, true) : null, @@ -482,6 +511,20 @@ }) } + componentDidMount () { + MKEmitter.addListener('submitStyle', this.getStyle) + } + + /** + * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 + */ + componentWillUnmount () { + this.setState = () => { + return + } + MKEmitter.removeListener('submitStyle', this.getStyle) + } + render() { const { config } = this.props const { fields, card, lineMarks, dict, tableId } = this.state -- Gitblit v1.8.0