From 1e4a7720c748bc0206b02b30f4a2e0b3dafb54f3 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 19 二月 2024 13:31:13 +0800
Subject: [PATCH] 2024-02-19

---
 src/templates/zshare/customscript/index.jsx |   77 ++++++--------------------------------
 1 files changed, 12 insertions(+), 65 deletions(-)

diff --git a/src/templates/zshare/customscript/index.jsx b/src/templates/zshare/customscript/index.jsx
index bd962d5..50e6ad5 100644
--- a/src/templates/zshare/customscript/index.jsx
+++ b/src/templates/zshare/customscript/index.jsx
@@ -7,6 +7,7 @@
 
 import Utils from '@/utils/utils.js'
 import Api from '@/api'
+import { checkSQL, getSearchFields } from '@/utils/utils-custom.js'
 import CodeMirror from '@/templates/zshare/codemirror'
 import asyncComponent from '@/utils/asyncComponent'
 import MKEmitter from '@/utils/events.js'
@@ -92,26 +93,9 @@
   UNSAFE_componentWillMount() {
     const { searches, scripts, urlFields } = this.props
 
-    let _usefulFields = []
-    searches.forEach(item => {
-      if (!item.field) return
-      if (item.type === 'group') {
-        _usefulFields.push(item.field)
-        _usefulFields.push(item.datefield)
-        _usefulFields.push(item.datefield + '1')
-      } else if (['dateweek', 'datemonth', 'daterange'].includes(item.type)) {
-        _usefulFields.push(item.field)
-        _usefulFields.push(item.field + '1')
-      } else if (_usefulFields.includes(item.field)) {
-        _usefulFields.push(item.field + '1')
-      } else {
-        _usefulFields.push(item.field.replace(/,/ig, ', '))
-      }
-    })
-
     this.setState({
       urlFields: urlFields ? urlFields.join(', ') : '',
-      usefulFields: _usefulFields.join(', '),
+      usefulFields: getSearchFields(searches),
       scripts: fromJS(scripts).toJS()
     })
   }
@@ -129,20 +113,21 @@
     }
     let _scriptSql = `Select distinct func+Remark as funcname,longparam, s.Sort from聽 s_custom_script s inner join (select OpenID from sapp where ID=@Appkey@) p on s.openid = case when s.appkey='' then s.openid else p.OpenID end order by s.Sort`
 
-    _scriptSql = Utils.formatOptions(_scriptSql)
+    _scriptSql = Utils.formatOptions(_scriptSql, 'x')
 
     let _sParam = {
       func: 'sPC_Get_SelectedList',
       LText: _scriptSql,
       obj_name: 'data',
-      arr_field: 'funcname,longparam'
+      arr_field: 'funcname,longparam',
+      exec_type: 'x'
     }
     
     _sParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-    _sParam.secretkey = Utils.encrypt(_sParam.LText, _sParam.timestamp)
+    _sParam.secretkey = Utils.encrypt('', _sParam.timestamp)
     _sParam.open_key = Utils.encryptOpenKey(_sParam.secretkey, _sParam.timestamp) // 浜戠鏁版嵁楠岃瘉
     
-    Api.getSystemConfig(_sParam).then(res => {
+    Api.getCloudConfig(_sParam).then(res => {
       if (res.status) {
         let _scripts = res.data.map(item => {
           let _item = {
@@ -197,51 +182,13 @@
       return
     }
 
+    let pass = checkSQL(_sql, 'customscript')
+
+    if (!pass) return
+
     let values = {
       uuid: editItem && editItem.uuid ? editItem.uuid : Utils.getuuid(),
       sql: _sql
-    }
-
-    let _quot = values.sql.match(/'{1}/g)
-    let _lparen = values.sql.match(/\({1}/g)
-    let _rparen = values.sql.match(/\){1}/g)
-
-    _quot = _quot ? _quot.length : 0
-    _lparen = _lparen ? _lparen.length : 0
-    _rparen = _rparen ? _rparen.length : 0
-
-    if (_quot % 2 !== 0) {
-      notification.warning({
-        top: 92,
-        message: 'sql涓璡'蹇呴』鎴愬鍑虹幇',
-        duration: 5
-      })
-      return
-    } else if (_lparen !== _rparen) {
-      notification.warning({
-        top: 92,
-        message: 'sql涓�()蹇呴』鎴愬鍑虹幇',
-        duration: 5
-      })
-      return
-    } else if (/--/ig.test(values.sql)) {
-      notification.warning({
-        top: 92,
-        message: '鑷畾涔塻ql璇彞涓紝涓嶅彲鍑虹幇瀛楃 -- 锛屾敞閲婅鐢� /*鍐呭*/',
-        duration: 5
-      })
-      return
-    }
-
-    let error = Utils.verifySql(values.sql, 'customscript')
-
-    if (error) {
-      notification.warning({
-        top: 92,
-        message: 'sql涓笉鍙娇鐢�' + error,
-        duration: 5
-      })
-      return
     }
 
     let _scripts = fromJS(scripts).toJS()
@@ -422,7 +369,7 @@
               <Form.Item label={'sql'}>
                 {getFieldDecorator('sql', {
                   initialValue: ''
-                })(<CodeMirror />)}
+                })(<CodeMirror/>)}
               </Form.Item>
             </Col>
           </Row>

--
Gitblit v1.8.0