From ba9e189dd33c8d48f7f4ac36bcefeef9afb426f8 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 17 七月 2023 23:40:49 +0800
Subject: [PATCH] 2023-07-17

---
 src/tabviews/custom/components/code/sand-box/index.jsx |   53 ++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 36 insertions(+), 17 deletions(-)

diff --git a/src/tabviews/custom/components/code/sand-box/index.jsx b/src/tabviews/custom/components/code/sand-box/index.jsx
index fa09f57..6bdaf07 100644
--- a/src/tabviews/custom/components/code/sand-box/index.jsx
+++ b/src/tabviews/custom/components/code/sand-box/index.jsx
@@ -1,7 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Spin, notification } from 'antd'
+import { Spin, notification, Modal } from 'antd'
 
 import Api from '@/api'
 import UtilsDM from '@/utils/utils-datamanage.js'
@@ -22,6 +22,7 @@
     sync: false,               // 鏄惁缁熶竴璇锋眰鏁版嵁
     data: [],                  // 鏁版嵁
     html: '',
+    result: {}
   }
 
   loaded = false
@@ -199,24 +200,50 @@
         }, 10)
       }
 
+      let _result = {...result}
+      delete _result.data
+
       this.setState({
         data: _data,
+        result: _result,
         loading: false
       })
+
+      if (result.message) {
+        if (result.ErrCode === 'Y') {
+          Modal.success({
+            title: result.message
+          })
+        } else if (result.ErrCode === 'S') {
+          notification.success({
+            top: 92,
+            message: result.message,
+            duration: 2
+          })
+        }
+      }
     } else {
       this.setState({
         loading: false
       })
-      notification.error({
-        top: 92,
-        message: result.message,
-        duration: 10
-      })
+
+      if (!result.message) return
+      if (result.ErrCode === 'N') {
+        Modal.error({
+          title: result.message
+        })
+      } else if (result.ErrCode !== '-2') {
+        notification.error({
+          top: 92,
+          message: result.message,
+          duration: 10
+        })
+      }
     }
   }
 
   renderView = () => {
-    const { data } = this.state
+    const { data, result } = this.state
     const { html, js, wrap, columns } = this.state.config
 
     let _html = html
@@ -239,16 +266,8 @@
       if (js) {
         try {
           // eslint-disable-next-line
-          let evalfunc = eval('(true && function (data) {' + js + '})')
-          evalfunc(data)
-          // if (wrap.compileMode !== 'custom') {
-          //   // eslint-disable-next-line no-eval
-          //   eval(js)
-          // } else {
-          //   // eslint-disable-next-line
-          //   let evalfunc = eval('(true && function (data) {' + js + '})')
-          //   evalfunc(data)
-          // }
+          let evalfunc = eval('(true && function (data, result) {' + js + '})')
+          evalfunc(data, result)
         } catch (e) {
           console.warn(e)
         }

--
Gitblit v1.8.0