From 706cda8fee92196639acc4bd6073398686925fc5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 23 十二月 2020 18:58:12 +0800 Subject: [PATCH] 2020-12-23 --- src/menu/components/table/normal-table/columns/index.jsx | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 42 insertions(+), 0 deletions(-) diff --git a/src/menu/components/table/normal-table/columns/index.jsx b/src/menu/components/table/normal-table/columns/index.jsx index 8383fbf..b2e611a 100644 --- a/src/menu/components/table/normal-table/columns/index.jsx +++ b/src/menu/components/table/normal-table/columns/index.jsx @@ -206,6 +206,7 @@ this.setState({fields: fromJS(nextProps.config.columns).toJS()}) } } + shouldComponentUpdate (nextProps, nextState) { const { config } = this.props @@ -417,6 +418,46 @@ }) } + syncfield = () => { + const { fields } = this.state + let columns = fromJS(this.state.columns).toJS() + + columns = columns.filter(c => !c.origin) + + let keys = columns.map(col => col.field) + + fields.forEach(item => { + if (keys.includes(item.field)) return + + let cell = { uuid: Utils.getuuid(), label: item.label, field: item.field, Align: 'left', Hide: 'false', IsSort: 'true', Width: 120, blacklist: [], postfix: '', prefix: '', linkmenu: [], marks: [], perspective: 'linkmenu' } + + if (/Nvarchar/ig.test(item.datatype)) { + cell.type = 'text' + cell.rowspan = 'false' + cell.textFormat = 'none' + } else { + cell.type = 'number' + cell.format = 'none' + cell.sum = 'false' + cell.decimal = item.decimal || 0 + } + + columns.push(cell) + }) + + const _this = this + + confirm({ + content: '纭畾鍚屾瀛楁闆嗗悧锛�', + onOk() { + _this.setState({columns}, () => { + _this.props.updatecolumn({..._this.props.config, cols: columns}) + }) + }, + onCancel() {} + }) + } + render() { const { config } = this.props const { fields, card, lineMarks, dict } = this.state @@ -436,6 +477,7 @@ <div className="col-control"> <Icon title="澶嶅埗" type="copy" onClick={this.copycolumn} /> <MarkColumn columns={fields} type="line" marks={lineMarks} onSubmit={this.updateLineMarks} /> + <Icon title="鍚屾" type="file-sync" onClick={this.syncfield} /> </div> <DndProvider> <Table -- Gitblit v1.8.0