From 60bc7643d20c80740711dd1de1cff37c01222d3d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 18 七月 2023 15:22:31 +0800
Subject: [PATCH] 2023-07-18

---
 src/tabviews/custom/components/share/normalTable/index.jsx |   41 ++++++++++++++++++++++++++++-------------
 1 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/src/tabviews/custom/components/share/normalTable/index.jsx b/src/tabviews/custom/components/share/normalTable/index.jsx
index 4922254..b16b14a 100644
--- a/src/tabviews/custom/components/share/normalTable/index.jsx
+++ b/src/tabviews/custom/components/share/normalTable/index.jsx
@@ -6,13 +6,13 @@
 
 import asyncComponent from '@/utils/asyncComponent'
 import { getMark } from '@/utils/utils.js'
-import MkIcon from '@/components/mk-icon'
 import MKEmitter from '@/utils/events.js'
 import Encrypts from '@/components/encrypts'
 import './index.scss'
 
 const { Paragraph } = Typography
 const Video = asyncComponent(() => import('@/components/video'))
+const MkIcon = asyncComponent(() => import('@/components/mk-icon'))
 const MkPicture = asyncComponent(() => import('@/components/mkPicture'))
 const CardCellComponent = asyncComponent(() => import('@/tabviews/custom/components/card/cardcellList'))
 const PicRadio = {
@@ -330,32 +330,47 @@
       )
     } 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') {
+      if (col.eval === 'func') {
         try {
           // eslint-disable-next-line
-          content = eval(content)
+          let func = new Function('data', col.formula)
+          content = func([record])
         } catch (e) {
           if (window.debugger) {
-            console.info(content)
             console.warn(e)
           }
           content = ''
         }
-
-        if (col.round && typeof(content) === 'number') {
-          content = Math.round(content * col.round) / col.round
-          content = content.toFixed(col.decimal)
+      } else {
+        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) {
+            if (window.debugger) {
+              console.info(content)
+              console.warn(e)
+            }
+            content = ''
+          }
+  
+          if (col.round && typeof(content) === 'number') {
+            content = Math.round(content * col.round) / col.round
+            content = content.toFixed(col.decimal)
+          }
         }
       }
 
       content = content === undefined ? '' : content
 
-      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, '&nbsp;')
         content = <span dangerouslySetInnerHTML={{__html: content}}></span>

--
Gitblit v1.8.0