From 93f67eceb286067a6ec5bbd747147f4824c1c6d2 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 13 五月 2023 22:50:54 +0800
Subject: [PATCH] 2023-05-13

---
 src/menu/components/table/edit-table/columns/editColumn/index.jsx |   63 +++++++++++++++++++++++++++++--
 1 files changed, 58 insertions(+), 5 deletions(-)

diff --git a/src/menu/components/table/edit-table/columns/editColumn/index.jsx b/src/menu/components/table/edit-table/columns/editColumn/index.jsx
index 6e92415..0f479c0 100644
--- a/src/menu/components/table/edit-table/columns/editColumn/index.jsx
+++ b/src/menu/components/table/edit-table/columns/editColumn/index.jsx
@@ -3,7 +3,10 @@
 import { is, fromJS } from 'immutable'
 import { Form, Row, Col, Input, Select, InputNumber, Radio, Tooltip, Modal, notification, Popover } from 'antd'
 import { QuestionCircleOutlined } from '@ant-design/icons'
+import moment from 'moment'
 
+import Api from '@/api'
+import Utils from '@/utils/utils.js'
 import { getColumnForm } from './formconfig'
 import { formRule } from '@/utils/option.js'
 import CodeMirror from '@/templates/zshare/codemirror'
@@ -35,6 +38,7 @@
 
   state = {
     visible: false,
+    loading: false,
     formlist: null,
     transfield: {}
   }
@@ -405,22 +409,70 @@
             return
           }
         }
-        this.setState({visible: false, formlist: null})
-        this.props.submitCol(values)
 
-        this.column = null
+        if (values.dataSource && /\s/.test(values.dataSource)) {
+          let error = Utils.verifySql(values.dataSource)
+
+          if (error) {
+            notification.warning({
+              top: 92,
+              message: '鏁版嵁婧愪腑涓嶅彲浣跨敤' + error,
+              duration: 5
+            })
+            return
+          }
+
+          this.setState({
+            loading: true
+          })
+    
+          let param = {
+            func: 's_debug_sql',
+            exec_type: 'y',
+            LText: `declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20)
+              ${values.dataSource}`
+          }
+    
+          param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+          param.LText = param.LText.replace(/@\$|\$@/ig, '').replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'${param.timestamp}'`)
+          param.LText = param.LText.replace(/\n/g, ' ')
+          
+          param.LText = Utils.formatOptions(param.LText)
+          param.secretkey = Utils.encrypt('', param.timestamp)
+    
+          if (window.GLOB.mainSystemApi && values.database === 'sso') {
+            param.rduri = window.GLOB.mainSystemApi
+          }
+          
+          Api.genericInterface(param).then(result => {
+            if (result.status) {
+              this.setState({visible: false, loading: false, formlist: null})
+              this.props.submitCol(values)
+              this.column = null
+            } else {
+              this.setState({loading: false})
+              Modal.error({
+                title: result.message
+              })
+            }
+          })
+        } else {
+          this.setState({visible: false, formlist: null})
+          this.props.submitCol(values)
+          this.column = null
+        }
       }
     })
   }
 
   editModalCancel = () => {
-    this.setState({visible: false, formlist: null})
+    this.setState({visible: false, loading: false, formlist: null})
 
     this.props.cancelCol()
   }
 
   render() {
-    const { visible } = this.state
+    const { visible, loading } = this.state
     const formItemLayout = {
       labelCol: {
         xs: { span: 24 },
@@ -441,6 +493,7 @@
           maskClosable={false}
           onOk={this.handleSubmit}
           onCancel={this.editModalCancel}
+          confirmLoading={loading}
           destroyOnClose
         >
           <Form {...formItemLayout} className="commontable-column-form" id="edit-table-column-winter">

--
Gitblit v1.8.0