From cd5079f2dbe12eb03fcef2e1898e4f013848d895 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 28 九月 2023 12:34:30 +0800
Subject: [PATCH] 2023-09-28

---
 src/templates/zshare/customscript/index.jsx |   72 +++++++++++++++++++++++++++--------
 1 files changed, 55 insertions(+), 17 deletions(-)

diff --git a/src/templates/zshare/customscript/index.jsx b/src/templates/zshare/customscript/index.jsx
index ecaa177..80db92a 100644
--- a/src/templates/zshare/customscript/index.jsx
+++ b/src/templates/zshare/customscript/index.jsx
@@ -17,7 +17,6 @@
 
 class CustomForm extends Component {
   static propTpyes = {
-    dict: PropTypes.object,         // 瀛楀吀椤�
     setting: PropTypes.object,      // 璁剧疆
     scripts: PropTypes.array,       // 鑷畾涔夎剼鏈垪琛�
     searches: PropTypes.array,      // 鎼滅储鏉′欢
@@ -76,11 +75,11 @@
         dataIndex: 'operation',
         render: (text, record) =>
           (<div style={{textAlign: 'center'}}>
-            <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record)} style={{color: '#1890ff'}}><EditOutlined /></span>
-            <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record)} style={{color: '#8E44AD'}}><SwapOutlined /></span>
+            <span className="operation-btn" title="缂栬緫" onClick={() => this.handleEdit(record)} style={{color: '#1890ff'}}><EditOutlined /></span>
+            <span className="operation-btn" title="鐘舵�佸垏鎹�" onClick={() => this.handleStatus(record)} style={{color: '#8E44AD'}}><SwapOutlined /></span>
             <Popconfirm
               overlayClassName="popover-confirm"
-              title={this.props.dict['model.query.delete']}
+              title="纭畾鍒犻櫎鍚�?"
               onConfirm={() => this.handleDelete(record)
             }>
               <span className="operation-btn" style={{color: '#ff4d4f'}}><DeleteOutlined /></span>
@@ -95,18 +94,23 @@
 
     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')
+      if (['dateweek', 'datemonth'].includes(item.type)) {
+        _usefulFields.push(item.key)
+        _usefulFields.push(item.key + '1')
+      } else if (item.type === 'daterange') {
+        let _skey = item.key
+        let _ekey = item.key + '1'
+
+        if (/,/.test(item.key)) {
+          _skey = item.key.split(',')[0]
+          _ekey = item.key.split(',')[1]
+        }
+        _usefulFields.push(_skey)
+        _usefulFields.push(_ekey)
+      } else if (item.type === 'date' && _usefulFields.includes(item.key)) {
+        _usefulFields.push(item.key + '1')
       } else {
-        _usefulFields.push(item.field.replace(/,/ig, ', '))
+        _usefulFields.push(item.key.replace(/,/ig, ', '))
       }
     })
 
@@ -122,6 +126,12 @@
   }
 
   getsysScript = () => {
+    if (sessionStorage.getItem('mk_sys_scripts')) {
+      this.setState({
+        systemScripts: JSON.parse(sessionStorage.getItem('mk_sys_scripts'))
+      })
+      return
+    }
     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)
@@ -137,7 +147,7 @@
     _sParam.secretkey = Utils.encrypt(_sParam.LText, _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 = {
@@ -146,6 +156,8 @@
           }
           return _item
         })
+
+        sessionStorage.setItem('mk_sys_scripts', JSON.stringify(_scripts))
 
         this.setState({
           systemScripts: _scripts
@@ -224,6 +236,32 @@
         duration: 5
       })
       return
+    } else if (/,,/ig.test(values.sql)) {
+      notification.warning({
+        top: 92,
+        message: '鑷畾涔塻ql璇彞涓紝涓嶅彲鍑虹幇杩炵画鐨勮嫳鏂囬�楀彿锛�,,锛�',
+        duration: 5
+      })
+      return
+    } else if (/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig.test(values.sql)) {
+      let list = values.sql.match(/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig)
+      let errors = []
+      list.forEach(str => {
+        str = str.replace(/^\s/, '')
+        let strs = str.match(/(\s|=)[a-z0-9_]+\./ig)
+        if (strs.length === 2 && (strs[0].replace(/\s|\./g, '') === strs[1].replace(/\s|\./g, ''))) {
+          errors.push(str)
+        }
+      })
+
+      if (errors.length > 0) {
+        notification.warning({
+          top: 92,
+          message: '涓嶅彲浣跨敤鍚屼竴涓〃瀛楁杩涜鍏宠仈锛�' + errors.join('銆�'),
+          duration: 5
+        })
+        return
+      }
     }
 
     let error = Utils.verifySql(values.sql, 'customscript')
@@ -415,7 +453,7 @@
               <Form.Item label={'sql'}>
                 {getFieldDecorator('sql', {
                   initialValue: ''
-                })(<CodeMirror />)}
+                })(<CodeMirror/>)}
               </Form.Item>
             </Col>
           </Row>

--
Gitblit v1.8.0