| | |
| | | ) |
| | | } else if (col.type === 'formula') { |
| | | let content = col.formula |
| | | |
| | | if (col.eval === 'func') { |
| | | try { |
| | | // eslint-disable-next-line |
| | | let func = new Function('data', col.formula) |
| | | content = func([record]) |
| | | } catch (e) { |
| | | if (window.debugger) { |
| | | console.warn(e) |
| | | } |
| | | content = '' |
| | | } |
| | | } else { |
| | | Object.keys(record).forEach(key => { |
| | | let reg = new RegExp('@' + key + '@', 'ig') |
| | | content = content.replace(reg, record[key]) |
| | |
| | | content = '' |
| | | } |
| | | } |
| | | } |
| | | |
| | | content = content === undefined ? '' : content |
| | | |
| | |
| | | content = content.toFixed(col.decimal) |
| | | } |
| | | |
| | | if (content !== '') { |
| | | if (col.eval === 'func') { |
| | | content = <span dangerouslySetInnerHTML={{__html: content}}></span> |
| | | } else if (content !== '') { |
| | | content = `${col.prefix || ''}${content}${col.postfix || ''}` |
| | | content = content.replace(/\n/ig, '<br/>').replace(/\s/ig, ' ') |
| | | content = <span dangerouslySetInnerHTML={{__html: content}}></span> |