From f243f22075cd7e1133c10283b4543b829fa844d4 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 17 十一月 2021 23:13:22 +0800 Subject: [PATCH] 2021-11-17 --- src/tabviews/custom/components/table/edit-table/normalTable/index.jsx | 62 +++++++++++++++++++++++++++---- 1 files changed, 54 insertions(+), 8 deletions(-) diff --git a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx index 30e8586..19a7ed6 100644 --- a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx +++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx @@ -202,11 +202,13 @@ const { value } = this.state this.setState({editing: false}) - if (col.enter === '$next') { - MKEmitter.emit('nextLine', col, record.$Index) - } else { - MKEmitter.emit('tdFocus', col.enter + record.$Index) - } + setTimeout(() => { + if (col.enter === '$next') { + MKEmitter.emit('nextLine', col, record.$Index) + } else { + MKEmitter.emit('tdFocus', col.enter + record.$Index) + } + }, 50) if (value !== record[col.field]) { MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: value}) @@ -368,6 +370,39 @@ {content ? <Paragraph copyable ellipsis={{ rows: 3, expandable: true }}>{content}</Paragraph> : null } </div> ) + } else if (col.type === 'formula') { + let content = col.formula + Object.keys(record).forEach(key => { + let reg = new RegExp('@' + key + '@', 'ig') + content = content.replace(reg, record[key]) + }) + + if (col.eval !== 'false') { + try { + // eslint-disable-next-line + content = eval(content) + } catch (e) { + content = '' + } + } + + content = content === undefined ? '' : content + + if (content !== '') { + content = `${col.prefix || ''}${content}${col.postfix || ''}` + + if (col.eval === 'false') { + content = content.replace(/\n/ig, '<br/>').replace(/\s/ig, ' ') + content = <span dangerouslySetInnerHTML={{__html: content}}></span> + } + } + + if (col.marks) { + style = style || {} + content = this.getMark(record, col.marks, style, content) + } + + children = content } else if (col.type === 'custom') { style.padding = '0px' if (col.style) { @@ -421,7 +456,8 @@ pickup: false, // 鏀惰捣鏈�夋嫨椤� orderfields: {}, // 鎺掑簭id涓巉ield杞崲 loading: false, - editable: 'false' + editable: 'false', + pageOptions: [] } UNSAFE_componentWillMount () { @@ -506,7 +542,17 @@ document.getElementsByTagName('head')[0].appendChild(ele) } + let size = (setting.pageSize || 10) + '' + let pageOptions = ['10', '25', '50', '100', '500', '1000'] + + if (!pageOptions.includes(size)) { + pageOptions.push(size) + pageOptions = pageOptions.sort((a, b) => a - b) + } + this.setState({ + pageSize: setting.pageSize || 10, + pageOptions, data, columns: _columns, edColumns, @@ -998,7 +1044,7 @@ render() { const { setting, statFValue, lineMarks, submit } = this.props - const { pickup, tableId, data, edData, columns, edColumns, loading } = this.state + const { pickup, tableId, data, edData, columns, edColumns, loading, pageOptions } = this.state const components = { body: { @@ -1022,7 +1068,7 @@ _pagination = { current: this.state.pageIndex, pageSize: this.state.pageSize, - pageSizeOptions: ['10', '25', '50', '100', '500', '1000'], + pageSizeOptions: pageOptions, showSizeChanger: true, total: this.props.total || 0, showTotal: (total, range) => `${range[0]}-${range[1]} ${this.state.dict['main.pagination.of']} ${total} ${this.state.dict['main.pagination.items']}` -- Gitblit v1.8.0