From 6d71b3fac75a35e8ebf08e71ba40c5be8a586024 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 08 九月 2021 18:10:17 +0800
Subject: [PATCH] 2021-09-08

---
 src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx |   89 +++++++++++++++++++++++++++++++++++---------
 1 files changed, 71 insertions(+), 18 deletions(-)

diff --git a/src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx b/src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx
index 391053d..2e3bcf9 100644
--- a/src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx
+++ b/src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx
@@ -1,7 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { fromJS } from 'immutable'
-import { Form, Row, Col, Icon, Button, notification, Select, Popconfirm, Typography, Modal } from 'antd'
+import { Form, Row, Col, Icon, Button, notification, Select, Popconfirm, Typography, Modal, Radio } from 'antd'
 import moment from 'moment'
 
 import Utils from '@/utils/utils.js'
@@ -20,6 +20,7 @@
     setting: PropTypes.object,      // 璁剧疆
     scripts: PropTypes.array,       // 鑷畾涔夎剼鏈垪琛�
     searches: PropTypes.array,      // 鎼滅储鏉′欢
+    urlFields: PropTypes.any,       // url鍙橀噺
     regoptions: PropTypes.any,      // 姝e垯鏇挎崲
     scriptsChange: PropTypes.func,  // 鑷畾涔夎剼鏈垏鎹㈡椂楠岃瘉
     scriptsUpdate: PropTypes.func   // 琛ㄥ崟
@@ -34,7 +35,7 @@
       {
         title: 'SQL',
         dataIndex: 'sql',
-        width: '73%',
+        width: '60%',
         render: (text) => {
           let title = text.match(/^\s*\/\*.+\*\//)
           title = title && title[0] ? title[0] : ''
@@ -46,6 +47,18 @@
               <Paragraph copyable ellipsis={{ rows: 4, expandable: true }}>{text}</Paragraph>
             </div>
           )
+        }
+      },
+      {
+        title: '鎵ц浣嶇疆',
+        dataIndex: 'position',
+        width: '13%',
+        render: (text, record) => {
+          if (record.position === 'front') {
+            return 'sql鍓�'
+          } else {
+            return 'sql鍚�'
+          }
         }
       },
       {
@@ -88,17 +101,16 @@
   }
 
   UNSAFE_componentWillMount() {
-    const { searches, scripts } = this.props
+    const { searches, scripts, urlFields } = this.props
 
     let _usefulFields = []
+    let scriptsColumns = fromJS(this.state.scriptsColumns).toJS()
 
     if (searches) {
       searches.forEach(item => {
         if (!item.field) return
         if (item.type === 'group') {
-          if (item.transfer === 'true') {
-            _usefulFields.push(item.field)
-          }
+          _usefulFields.push(item.field)
           _usefulFields.push(item.datefield)
           _usefulFields.push(item.datefield + '1')
         } else if (['dateweek', 'datemonth', 'daterange'].includes(item.type)) {
@@ -110,14 +122,26 @@
           _usefulFields.push(item.field)
         }
       })
+
+      if (urlFields) {
+        _usefulFields.push(...urlFields)
+      }
+      
       _usefulFields = _usefulFields.join(', ')
+      scriptsColumns = scriptsColumns.filter(item => {
+        if (item.dataIndex === 'sql') {
+          item.width = '70%'
+        }
+        return item.dataIndex !== 'position'
+      })
     } else {
       _usefulFields = null
     }
 
     this.setState({
       usefulFields: _usefulFields,
-      scripts: fromJS(scripts).toJS()
+      scripts: fromJS(scripts).toJS(),
+      scriptsColumns
     })
   }
 
@@ -196,7 +220,11 @@
 
     let values = {
       uuid: editItem && editItem.uuid ? editItem.uuid : Utils.getuuid(),
-      sql: _sql
+      sql: _sql,
+    }
+
+    if (this.props.form.getFieldValue('position')) {
+      values.position = this.props.form.getFieldValue('position')
     }
 
     let _quot = values.sql.match(/'{1}/g)
@@ -307,13 +335,21 @@
   }
 
   handleEdit = (record) => {
+    const { usefulFields } = this.state
     this.setState({
       editItem: record
     })
 
-    this.props.form.setFieldsValue({
-      sql: record.sql
-    })
+    if (usefulFields) {
+      this.props.form.setFieldsValue({
+        sql: record.sql
+      })
+    } else {
+      this.props.form.setFieldsValue({
+        sql: record.sql,
+        position: record.position || 'back'
+      })
+    }
 
     this.scrolltop()
   }
@@ -383,19 +419,36 @@
       <div className="modal-menu-setting-script">
         <Form {...formItemLayout}>
           <Row gutter={24}>
-            <Col span={8}>
-              <Form.Item label={'鍥炶皟琛ㄥ悕'} style={{whiteSpace: 'nowrap', margin: 0}}>
+            <Col span={4}>
+              <Form.Item labelCol={{span: 17}} wrapperCol={{span: 7}} label={'鍥炶皟琛ㄥ悕'} style={{whiteSpace: 'nowrap', margin: 0}}>
                 {setting.cbTable}
               </Form.Item>
             </Col>
-            <Col span={16}>
-              <Form.Item label={'鎶ラ敊瀛楁'} style={{margin: 0}}>
-                ErrorCode, retmsg
+            <Col span={20}>
+              <Form.Item labelCol={{span: 4}} wrapperCol={{span: 20}} label={'鎶ラ敊瀛楁'} style={{margin: 0}}>
+                ErrorCode锛堝鍔犲悗缂�NT琛ㄧず鏁版嵁涓嶅洖婊氾紝濡侲NT銆丯NT銆丗NT銆丯MNT锛�, retmsg
               </Form.Item>
             </Col>
             {usefulFields ? <Col span={24} className="sqlfield">
               <Form.Item label={'鍙敤瀛楁'}>
-                id, bid, loginuid, sessionuid, userid, username, fullname, appkey, time_id{usefulFields ? ', ' + usefulFields : ''}
+                id, bid, loginuid, sessionuid, userid, username, fullname, RoleID, departmentcode, organization, login_city, appkey, time_id{usefulFields ? ', ' + usefulFields : ''}
+              </Form.Item>
+            </Col> : null}
+            {!usefulFields ? <Col span={24} className="sqlfield">
+              <Form.Item label={'鍙敤瀛楁'}>
+                id, bid, loginuid, sessionuid, userid, username, fullname, RoleID, departmentcode, organization, login_city, appkey, time_id
+              </Form.Item>
+            </Col> : null}
+            {!usefulFields ? <Col span={8} style={{whiteSpace: 'nowrap'}}>
+              <Form.Item style={{marginBottom: 0}} label="鎵ц浣嶇疆">
+                {getFieldDecorator('position', {
+                  initialValue: 'front'
+                })(
+                  <Radio.Group>
+                    <Radio value="front">sql鍓�</Radio>
+                    <Radio value="back">sql鍚�</Radio>
+                  </Radio.Group>
+                )}
               </Form.Item>
             </Col> : null}
             <Col span={10} className="quick-add">
@@ -406,7 +459,7 @@
                   filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                   onChange={this.selectScript}
                 >
-                  {!usefulFields ? <Select.Option key="default" value={`declare @${setting.cbTable} table (mk_api_key nvarchar(100))`}>榛樿sql</Select.Option> : null}
+                  {!usefulFields ? <Select.Option key="default" value={`declare @${setting.cbTable} table (mk_api_key nvarchar(100),mk_level nvarchar(10),mk_id nvarchar(50),mk_bid nvarchar(50))\n/*@${setting.cbTable}_data table (mk_level nvarchar(10),mk_id nvarchar(50),mk_bid nvarchar(50))*/`}>榛樿sql</Select.Option> : null}
                   {systemScripts.map((option, i) =>
                     <Select.Option style={{whiteSpace: 'normal'}} key={i} value={option.value}>{option.name}</Select.Option>
                   )}

--
Gitblit v1.8.0