From 0227c25e4ed573d3095ada3f9c9a4ba5f18b0de5 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 20 一月 2021 10:53:01 +0800
Subject: [PATCH] 2021-01-20

---
 src/mob/datasource/verifycard/customscript/index.jsx |   84 ++++++++---------------------------------
 1 files changed, 17 insertions(+), 67 deletions(-)

diff --git a/src/mob/datasource/verifycard/customscript/index.jsx b/src/mob/datasource/verifycard/customscript/index.jsx
index 6c9d489..5267ea7 100644
--- a/src/mob/datasource/verifycard/customscript/index.jsx
+++ b/src/mob/datasource/verifycard/customscript/index.jsx
@@ -1,14 +1,10 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
-import { Form, Row, Col, Input, Button, notification, Modal, Select } from 'antd'
-import moment from 'moment'
+import { Form, Row, Col, Button, notification, Select } from 'antd'
 
 import Utils from '@/utils/utils.js'
-import SettingUtils from '../utils.jsx'
-import Api from '@/api'
+import CodeMirror from '@/templates/zshare/codemirror'
 import './index.scss'
-
-const { TextArea } = Input
 
 class CustomForm extends Component {
   static propTpyes = {
@@ -20,7 +16,8 @@
     arr_field: PropTypes.string,    // 鍒楀瓧娈�
     regoptions: PropTypes.array,    // 姝e垯鏇挎崲
     systemScripts: PropTypes.array, // 绯荤粺鑴氭湰
-    scriptsChange: PropTypes.func   // 琛ㄥ崟
+    scriptSubmit: PropTypes.func,   // 鑴氭湰楠岃瘉鍚庢彁浜�
+    scriptsChange: PropTypes.func   // 鑴氭湰楠岃瘉
   }
 
   state = {
@@ -75,8 +72,6 @@
   }
 
   handleConfirm = () => {
-    const { setting, arr_field, regoptions, swhere } = this.props
-    
     // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭�
     this.props.form.validateFieldsAndScroll((err, values) => {
       if (!err) {
@@ -124,61 +119,16 @@
           return
         }
 
-        let _customScript = ''
-        setting.scripts && setting.scripts.forEach(script => {
-          if (this.state.editItem && this.state.editItem.uuid === script.uuid) {
-            _customScript += `
-            ${values.sql}
-            `
-          } else if (script.status !== 'false') {
-            _customScript += `
-            ${script.sql}
-            `
-          }
-        })
-
-        if (!this.state.editItem) {
-          _customScript += `
-            ${values.sql}
-            `
-        }
-
-        if (_customScript) {
-          _customScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000) select @ErrorCode='',@retmsg =''
-            ${_customScript}
-          `
-        }
-
-        let _setting = {...setting, customScript: _customScript}
-
-        let param = {
-          func: 's_debug_sql',
-          LText: SettingUtils.getDebugSql(_setting, arr_field, regoptions, swhere)
-        }
-
-        param.LText = Utils.formatOptions(param.LText)
-        param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
-        param.secretkey = Utils.encrypt(param.LText, param.timestamp)
-        
         this.setState({loading: true})
-        Api.getLocalConfig(param).then(res => {
-          if (res.status) {
-            this.setState({
-              loading: false,
-              editItem: null
-            }, () => {
-              this.props.scriptsChange(values)
-            })
-            this.props.form.setFieldsValue({
-              sql: ''
-            })
-          } else {
-            this.setState({loading: false})
-
-            Modal.error({
-              title: res.message
-            })
-          }
+        this.props.scriptsChange(values).then(() => {
+          this.setState({
+            editItem: null,
+            loading: false
+          })
+          this.props.form.setFieldsValue({
+            sql: ''
+          })
+          this.props.scriptSubmit(values)
         })
       }
     })
@@ -204,7 +154,7 @@
   }
 
   render() {
-    const { systemScripts, setting, type } = this.props
+    const { systemScripts, setting } = this.props
     const { getFieldDecorator } = this.props.form
     const { usefulFields } = this.state
     const formItemLayout = {
@@ -233,7 +183,7 @@
           </Col>
           <Col span={24} className="sqlfield">
             <Form.Item label={'鍙敤瀛楁'}>
-              id, bid, loginuid, sessionuid, userid, appkey, {type === 'main' ? 'out_id, ' : '' }time_id, orderBy{setting.laypage !== 'false' ? ', pageSize, pageIndex': ''}{usefulFields ? ', ' + usefulFields : ''}
+              id, bid, loginuid, sessionuid, userid, appkey, time_id, orderBy{setting.laypage !== 'false' ? ', pageSize, pageIndex': ''}{usefulFields ? ', ' + usefulFields : ''}
             </Form.Item>
           </Col>
           <Col span={10}>
@@ -264,10 +214,10 @@
                 rules: [
                   {
                     required: true,
-                    message: this.props.dict['form.required.input'] + 'sql!'
+                    message: this.props.dict['mob.required.input'] + 'sql!'
                   }
                 ]
-              })(<TextArea rows={15} />)}
+              })(<CodeMirror />)}
             </Form.Item>
           </Col>
         </Row>

--
Gitblit v1.8.0