From 37e28da53f6d4d7d8abe7626ba28ba7dbe16e7bb Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 08 四月 2024 15:36:01 +0800
Subject: [PATCH] 2024-04-08

---
 src/templates/sharecomponent/actioncomponent/verifyexcelout/datasource/index.jsx |  105 +++++++++++++++++++++++-----------------------------
 1 files changed, 47 insertions(+), 58 deletions(-)

diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelout/datasource/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelout/datasource/index.jsx
index 10dcfb6..f8240c3 100644
--- a/src/templates/sharecomponent/actioncomponent/verifyexcelout/datasource/index.jsx
+++ b/src/templates/sharecomponent/actioncomponent/verifyexcelout/datasource/index.jsx
@@ -3,7 +3,7 @@
 import { Form, Row, Col, Input, Radio, Tooltip, notification, InputNumber } from 'antd'
 import { QuestionCircleOutlined } from '@ant-design/icons'
 
-import Utils from '@/utils/utils.js'
+import { checkSQL } from '@/utils/utils-custom.js'
 import asyncComponent from '@/utils/asyncComponent'
 import './index.scss'
 
@@ -17,7 +17,8 @@
 
   state = {
     dataType: '',
-    defaultSql: 'true'
+    defaultSql: 'true',
+    excelHandle: 'false'
   }
 
   UNSAFE_componentWillMount () {
@@ -25,7 +26,8 @@
 
     this.setState({
       dataType: btnType === 'print' ? 'custom' : setting.dataType,
-      defaultSql: setting.defaultSql || 'true'
+      defaultSql: setting.defaultSql || 'true',
+      excelHandle: setting.excelHandle || 'false'
     })
   }
 
@@ -44,56 +46,9 @@
             reject()
             return
           } else if (values.defaultSql === 'true' && values.dataresource) {
-            let _quot = values.dataresource.match(/'{1}/g)
-            let _lparen = values.dataresource.match(/\({1}/g)
-            let _rparen = values.dataresource.match(/\){1}/g)
+            let pass = checkSQL(values.dataresource)
 
-            _quot = _quot ? _quot.length : 0
-            _lparen = _lparen ? _lparen.length : 0
-            _rparen = _rparen ? _rparen.length : 0
-
-            if (_quot % 2 !== 0) {
-              notification.warning({
-                top: 92,
-                message: '鏁版嵁婧愪腑\'蹇呴』鎴愬鍑虹幇',
-                duration: 5
-              })
-              reject()
-              return
-            } else if (_lparen !== _rparen) {
-              notification.warning({
-                top: 92,
-                message: '鏁版嵁婧愪腑()蹇呴』鎴愬鍑虹幇',
-                duration: 5
-              })
-              reject()
-              return
-            } else if (/--/ig.test(values.dataresource)) {
-              notification.warning({
-                top: 92,
-                message: '鏁版嵁婧愪腑锛屼笉鍙嚭鐜板瓧绗� -- 锛屾敞閲婅鐢� /*鍐呭*/',
-                duration: 5
-              })
-              reject()
-              return
-            } else if (/,,/ig.test(values.dataresource)) {
-              notification.warning({
-                top: 92,
-                message: '鏁版嵁婧愪腑锛屼笉鍙嚭鐜拌繛缁殑鑻辨枃閫楀彿锛�,,锛�',
-                duration: 5
-              })
-              reject()
-              return
-            }
-
-            let error = Utils.verifySql(values.dataresource)
-
-            if (error) {
-              notification.warning({
-                top: 92,
-                message: '鏁版嵁婧愪腑涓嶅彲浣跨敤' + error,
-                duration: 5
-              })
+            if (!pass) {
               reject()
               return
             }
@@ -125,7 +80,7 @@
   render() {
     const { setting, btnType } = this.props
     const { getFieldDecorator } = this.props.form
-    const { dataType, defaultSql } = this.state
+    const { dataType, defaultSql, excelHandle } = this.state
 
     const formItemLayout = {
       labelCol: {
@@ -229,7 +184,12 @@
               </Form.Item>
             </Col> : null}
             {dataType === 'custom' && defaultSql === 'true' ? <Col className="short-label" span={8}>
-              <Form.Item label="鎺掑簭鏂瑰紡">
+              <Form.Item label={
+                <Tooltip placement="topLeft" title="濡傛灉鍦ㄨ嚜瀹氫箟鑴氭湰涓娇鐢ㄤ簡@pageSize@鎴朄orderBy@锛岃鍦ㄦ暟鎹簮涓崟鐙啓鎺掑簭璇彞銆�">
+                  <QuestionCircleOutlined className="mk-form-tip" />
+                  鎺掑簭鏂瑰紡
+                </Tooltip>
+              }>
                 {getFieldDecorator('order', {
                   initialValue: setting.order || '',
                   rules: [
@@ -259,6 +219,35 @@
             </Col> : null}
             {btnType !== 'print' ? <Col span={8}>
               <Form.Item label={
+                <Tooltip placement="topRight" title="鑷畾涔夌敓鎴怑xcel锛屽彲鐢ㄥ弬鏁颁负 XLSX銆乨ata銆乧olumns銆乻earches銆乧allback銆�">
+                  <QuestionCircleOutlined className="mk-form-tip" />
+                  瀵煎嚭鏍煎紡
+                </Tooltip>
+              }>
+                {getFieldDecorator('excelHandle', {
+                  initialValue: excelHandle
+                })(
+                <Radio.Group onChange={(e) => this.setState({excelHandle: e.target.value})}>
+                  <Radio value="false">榛樿</Radio>
+                  <Radio value="true">鑷畾涔�</Radio>
+                </Radio.Group>)}
+              </Form.Item>
+            </Col> : null}
+            {btnType !== 'print' && excelHandle === 'true' ? <Col span={24} style={{paddingLeft: '30px'}}>
+              <Form.Item wrapperCol={ {xs: { span: 24 }, sm: { span: 24 }} } label="">
+                {getFieldDecorator('excel_func', {
+                  initialValue: setting.excel_func || '',
+                  rules: [
+                    {
+                      required: true,
+                      message: '璇峰~鍐欒嚜瀹氫箟閫昏緫!'
+                    }
+                  ]
+                })(<CodeMirror mode="text/javascript" theme="cobalt" />)}
+              </Form.Item>
+            </Col> : null}
+            {btnType !== 'print' && excelHandle !== 'true' ? <Col span={8}>
+              <Form.Item label={
                 <Tooltip placement="topLeft" title="瀵煎嚭excel涓伐浣滆〃鍚嶇О锛岄粯璁や负Sheet1銆�">
                   <QuestionCircleOutlined className="mk-form-tip" />
                   宸ヤ綔琛�
@@ -269,7 +258,7 @@
                 })(<Input placeholder="" autoComplete="off" />)}
               </Form.Item>
             </Col> : null}
-            {btnType !== 'print' ? <Col span={8}>
+            {btnType !== 'print' && excelHandle !== 'true' ? <Col span={8}>
               <Form.Item label={
                 <Tooltip placement="topLeft" title="瀵煎嚭excel涓殑琛岄珮銆�">
                   <QuestionCircleOutlined className="mk-form-tip" />
@@ -281,7 +270,7 @@
                 })(<InputNumber min={10} max={200} precision={0} />)}
               </Form.Item>
             </Col> : null}
-            {btnType !== 'print' ? <Col span={8}>
+            {btnType !== 'print' && excelHandle !== 'true' ? <Col span={8}>
               <Form.Item label={
                 <Tooltip placement="topLeft" title="璇峰皢闇�瑕佸悎骞剁殑琛ㄥご浣跨敤涓í绾垮垎闅旓紙濡傦細鍟嗗搧-鏁伴噺銆佸晢鍝�-鍗曚环锛夛紝鍓嶉儴鍒嗗皢浣滀负涓昏〃澶达紝鍚庨儴鍒嗗皢浣滀负瀛愯〃澶淬��">
                   <QuestionCircleOutlined className="mk-form-tip" />
@@ -297,7 +286,7 @@
                 </Radio.Group>)}
               </Form.Item>
             </Col> : null}
-            {btnType !== 'print' ? <Col span={8}>
+            {/* {btnType !== 'print' && excelHandle !== 'true' ? <Col span={8}>
               <Form.Item label={
                 <Tooltip placement="topLeft" title="Excel鍐呭鍖烘槸鍚﹁嚜鍔ㄦ崲琛屻��">
                   <QuestionCircleOutlined className="mk-form-tip" />
@@ -312,7 +301,7 @@
                   <Radio value="true">鏄�</Radio>
                 </Radio.Group>)}
               </Form.Item>
-            </Col> : null}
+            </Col> : null} */}
           </Row>
         </Form>
       </div>

--
Gitblit v1.8.0