From 5a995a24857abb0a1dac5e4c67c600e54db01539 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 13 十月 2021 17:35:56 +0800 Subject: [PATCH] 2021-10-13 --- src/tabviews/custom/components/table/edit-table/normalTable/index.jsx | 45 ++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 40 insertions(+), 5 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..a391160 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) { -- Gitblit v1.8.0