From 113ff1aa0d62549730f1413fe5ffcadcf3a14f11 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 23 八月 2022 11:37:24 +0800
Subject: [PATCH] 2022-08-23

---
 src/templates/zshare/verifycard/callbackcustomscript/index.jsx |   73 +++++++++++++++++++++++++++---------
 1 files changed, 54 insertions(+), 19 deletions(-)

diff --git a/src/templates/zshare/verifycard/callbackcustomscript/index.jsx b/src/templates/zshare/verifycard/callbackcustomscript/index.jsx
index b53a5fd..ce8b2f5 100644
--- a/src/templates/zshare/verifycard/callbackcustomscript/index.jsx
+++ b/src/templates/zshare/verifycard/callbackcustomscript/index.jsx
@@ -1,6 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
-import { Form, Row, Col, Button, notification, Modal, Tooltip, Icon, Radio, Select } from 'antd'
+import { Form, Row, Col, Button, notification, Modal, Tooltip, Radio, Select } from 'antd'
+import { QuestionCircleOutlined } from '@ant-design/icons'
 import moment from 'moment'
 
 import Utils from '@/utils/utils.js'
@@ -12,6 +13,8 @@
   static propTpyes = {
     dict: PropTypes.object,         // 瀛楀吀椤�
     btn: PropTypes.object,          // 鎸夐挳淇℃伅
+    initsql: PropTypes.string,      // 鍒濆鍖栬剼鏈�
+    usefulfields: PropTypes.string, // 鍙敤瀛楁
     systemScripts: PropTypes.array, // 绯荤粺鑴氭湰
     customScripts: PropTypes.array, // 鑷畾涔夎剼鏈�
     scriptsChange: PropTypes.func   // 琛ㄥ崟
@@ -105,14 +108,36 @@
           }
         })
 
+        if (!values.uuid) {
+          if (values.position === 'front') {
+            _prevCustomScript += `
+            /* 榛樿sql鍓嶈剼鏈� */
+            ${values.sql}
+            `
+          } else {
+            _backCustomScript += `
+            /* 榛樿sql鍚庤剼鏈� */
+            ${values.sql}
+            `
+          }
+        }
+
         let param = {
           func: 's_debug_sql',
           exec_type: 'y',
-          LText: _prevCustomScript + _backCustomScript + tail
+          LText: this.props.initsql +  _prevCustomScript + _backCustomScript + tail
+        }
+
+        if (window.GLOB.funcs && window.GLOB.funcs.length > 0) {
+          window.GLOB.funcs.forEach(item => {
+            let reg = new RegExp('\\$ex@' + item.func_code + '@ex\\$', 'ig')
+            param.LText = param.LText.replace(reg, `/*$ex@${item.func_code}-begin*/\n${item.key_sql}\n/*@ex$-end*/`)
+          })
         }
 
         // 鏁版嵁鏉冮檺
         param.LText = param.LText.replace(/@\$|\$@/ig, '')
+
         // check
         param.LText = param.LText.replace(/\$check@|@check\$/ig, '')
 
@@ -121,14 +146,16 @@
           param.LText = param.LText.replace(/@db@/ig, window.GLOB.externalDatabase)
         }
 
+        param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+        param.LText = param.LText.replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'${param.timestamp}'`)
+
         console.info(`/* sql 楠岃瘉 */\n${param.LText.replace(/\n\s{6,20}/ig, '\n')}`)
 
         param.LText = Utils.formatOptions(param.LText)
-        param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
         param.secretkey = Utils.encrypt('', param.timestamp)
         
         this.setState({loading: true})
-        Api.getLocalConfig(param).then(res => {
+        Api.genericInterface(param).then(res => {
           if (res.status) {
             this.setState({
               loading: false,
@@ -162,6 +189,7 @@
   }
 
   selectScript = (value, option) => {
+    if (!value || !option) return
     let _sql = this.props.form.getFieldValue('sql')
     if (_sql) {
       _sql = _sql + ` 
@@ -181,7 +209,7 @@
   }
 
   render() {
-    const { systemScripts, btn } = this.props
+    const { usefulfields, systemScripts, btn } = this.props
     const { getFieldDecorator } = this.props.form
     const formItemLayout = {
       labelCol: {
@@ -194,23 +222,33 @@
       }
     }
 
+    // let _usefulfields = usefulfields ? usefulfields.replace(/(BID|ID|LoginUID|SessionUid|UserID|Appkey|UserName|FullName|RoleID|mk_departmentcode|mk_organization|mk_nation|mk_province|mk_city|mk_district|mk_address|mk_user_type|BillCode|BVoucher|FIBVoucherDate|FiYear|ModularDetailCode),\s/ig, '') : null
+
     return (
-      <Form {...formItemLayout} className="verify-form" id="verify-custom-scripts">
+      <Form {...formItemLayout} className="verify-form verify-custom-callback-scripts" id="verify-custom-callback-scripts">
         <Row gutter={24}>
-          {btn.cbTable ? <Col span={8}>
+          <Col span={8}>
             <Form.Item label={'琛ㄥ悕'} style={{whiteSpace: 'nowrap', margin: 0}}>
               {btn.cbTable}
             </Form.Item>
-          </Col> : null}
-          <Col span={16}>
-            <Form.Item label={'鎶ラ敊瀛楁'} style={{margin: 0}}>
-              ErrorCode, retmsg
+          </Col>
+          <Col span={10}>
+            <Form.Item label={'鎶ラ敊瀛楁'} style={{margin: 0, whiteSpace: 'nowrap'}}>
+              ErrorCode锛堝鍔犲悗缂�NT琛ㄧず鏁版嵁涓嶅洖婊氾紝濡侲NT銆丯NT銆丗NT銆丯MNT锛�, retmsg
+            </Form.Item>
+          </Col>
+          <Col span={24} className="sqlfield">
+            <Form.Item label={'鍙敤瀛楁'}>
+              <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'鍏叡鍊硷紝璇锋寜鐓xxx@鏍煎紡浣跨敤銆�'}><span style={{color: '#1890ff'}}>BID, ID, LoginUID, SessionUid, UserID, Appkey, time_id</span></Tooltip>,&nbsp;
+              <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'绯荤粺鍙橀噺锛岀郴缁熶細瀹氫箟鍙橀噺骞惰祴鍊笺��'}><span style={{color: '#fa8c16'}}>UserName, FullName, RoleID, mk_departmentcode, mk_organization, mk_user_type, mk_nation, mk_province, mk_city, mk_district, mk_address</span></Tooltip>,&nbsp;
+              <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'绯荤粺鍙橀噺锛岀郴缁熶細瀹氫箟鍙橀噺骞跺湪鍗曞彿鐢熸垚鎴栧垱寤哄嚟璇佹椂浣跨敤銆�'}><span style={{color: '#13c2c2'}}>BillCode, BVoucher, FIBVoucherDate, FiYear, ModularDetailCode</span></Tooltip>
+              {usefulfields ? <span>, {usefulfields}</span> : ''}
             </Form.Item>
           </Col>
           <Col span={8} style={{whiteSpace: 'nowrap'}}>
             <Form.Item style={{marginBottom: 0}} label={
               <Tooltip placement="bottomLeft" title={'鑷畾涔夎剼鏈笌榛樿sql浣嶇疆鍏崇郴銆�'}>
-                <Icon type="question-circle" style={{color: '#c49f47', marginRight: '5px'}} />
+                <QuestionCircleOutlined className="mk-form-tip" />
                 鎵ц浣嶇疆
               </Tooltip>
             }>
@@ -227,11 +265,13 @@
           <Col span={10}>
             <Form.Item label={'蹇嵎娣诲姞'} style={{marginBottom: 0}}>
               <Select
+                allowClear
                 showSearch
                 filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                 onChange={this.selectScript}
-                getPopupContainer={() => document.getElementById('verify-custom-scripts')}
+                getPopupContainer={() => document.getElementById('verify-custom-callback-scripts')}
               >
+                <Select.Option key="default" value={`declare @${btn.cbTable} table (mk_api_key nvarchar(100),mk_level nvarchar(10),mk_id nvarchar(50),mk_bid nvarchar(50))\n/*@${btn.cbTable}_data table (mk_level nvarchar(10),mk_id nvarchar(50),mk_bid nvarchar(50))*/`}>榛樿sql</Select.Option>
                 {systemScripts.map((option, i) =>
                   <Select.Option key={i} value={option.value}>{option.name}</Select.Option>
                 )}
@@ -247,12 +287,7 @@
             </Button>
           </Col>
           <Col span={24} className="sql">
-            <Form.Item label={
-              <Tooltip placement="topLeft" title={'鏁版嵁妫�鏌ユ浛鎹㈢ $check@ -> /* 鎴� \'\'銆� @check$ -> */ 鎴� \'\''}>
-                <Icon type="question-circle" />
-                sql
-              </Tooltip>
-            }>
+            <Form.Item label="sql">
               {getFieldDecorator('sql', {
                 initialValue: '',
                 rules: [

--
Gitblit v1.8.0