From 0bbaa727cdfc65622e33e91c4bf694c83f184535 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 04 二月 2024 23:12:14 +0800
Subject: [PATCH] 2024-02-04

---
 src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx |  104 ++++++++++++++++++++++++---------------------------
 1 files changed, 49 insertions(+), 55 deletions(-)

diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx
index 76aa845..7acae2d 100644
--- a/src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx
+++ b/src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx
@@ -1,13 +1,15 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Form, Row, Col, Button, notification, Tooltip, Select, Switch } from 'antd'
+import { Form, Row, Col, Button, notification, Tooltip, Select, Switch, Radio } from 'antd'
+import { QuestionCircleOutlined } from '@ant-design/icons'
 import moment from 'moment'
 
 import Api from '@/api'
 import Utils from '@/utils/utils.js'
+import { checkSQL } from '@/utils/utils-custom.js'
 import CodeMirror from '@/templates/zshare/codemirror'
-import './index.scss'
+// import './index.scss'
 
 class CustomForm extends Component {
   static propTpyes = {
@@ -48,17 +50,18 @@
     
     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.getCloudConfig(_sParam).then(res => {
@@ -94,9 +97,26 @@
         _usefulFields.push(item.field)
         _usefulFields.push(item.datefield)
         _usefulFields.push(item.datefield + '1')
-      } else if (['dateweek', 'datemonth', 'daterange'].includes(item.type)) {
+      } else if (item.type === 'dateweek') {
         _usefulFields.push(item.field)
         _usefulFields.push(item.field + '1')
+      } else if (item.type === 'datemonth') {
+        if (item.match === '=') {
+          _usefulFields.push(item.field)
+        } else {
+          _usefulFields.push(item.field)
+          _usefulFields.push(item.field + '1')
+        }
+      } else if (item.type === 'daterange') {
+        let _skey = item.field
+        let _ekey = item.field + '1'
+
+        if (/,/.test(item.field)) {
+          _skey = item.field.split(',')[0]
+          _ekey = item.field.split(',')[1]
+        }
+        _usefulFields.push(_skey)
+        _usefulFields.push(_ekey)
       } else if (item.type === 'date' && _usefulFields.includes(item.field)) {
         _usefulFields.push(item.field + '1')
       } else {
@@ -115,7 +135,8 @@
     })
 
     this.props.form.setFieldsValue({
-      sql: record.sql
+      sql: record.sql,
+      position: record.position || 'front'
     })
   }
 
@@ -135,54 +156,9 @@
         
         values.uuid = this.state.editItem ? this.state.editItem.uuid : ''
 
-        let _quot = values.sql.match(/'{1}/g)
-        let _lparen = values.sql.match(/\({1}/g)
-        let _rparen = values.sql.match(/\){1}/g)
+        let pass = checkSQL(values.sql, 'customscript')
 
-        _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
-        } 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
-        }
+        if (!pass) return
 
         this.setState({
           loading: true
@@ -214,7 +190,8 @@
     })
     
     this.props.form.setFieldsValue({
-      sql: ' '
+      sql: ' ',
+      position: 'front'
     })
   }
 
@@ -277,6 +254,23 @@
               {linefields ? <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'琛ㄥ崟鍙婅鍙橀噺锛岀郴缁熶細瀹氫箟鍙橀噺骞惰祴鍊笺��'}>,&nbsp;{linefields}</Tooltip> : null}
             </Form.Item>
           </Col>
+          <Col span={8} style={{whiteSpace: 'nowrap'}}>
+            <Form.Item style={{marginBottom: 0}} label={
+              <Tooltip placement="bottomLeft" title={'鑷畾涔夎剼鏈笌鏁版嵁婧愪綅缃叧绯汇��'}>
+                <QuestionCircleOutlined className="mk-form-tip" />
+                鎵ц浣嶇疆
+              </Tooltip>
+            }>
+              {getFieldDecorator('position', {
+                initialValue: 'front'
+              })(
+                <Radio.Group>
+                  <Radio value="front">鍓嶇疆</Radio>
+                  <Radio value="back">鍚庣疆</Radio>
+                </Radio.Group>
+              )}
+            </Form.Item>
+          </Col>
           <Col span={8}>
             <Form.Item style={{marginBottom: 0}} label="蹇嵎娣诲姞">
               <Select

--
Gitblit v1.8.0