From 68f84129b685aa9539ac38ca1cf1f164c4d58074 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 26 一月 2021 13:54:26 +0800
Subject: [PATCH] 2021-01-26

---
 src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 52 insertions(+), 8 deletions(-)

diff --git a/src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx b/src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx
index 391053d..07bdde8 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'
@@ -34,7 +34,7 @@
       {
         title: 'SQL',
         dataIndex: 'sql',
-        width: '73%',
+        width: '60%',
         render: (text) => {
           let title = text.match(/^\s*\/\*.+\*\//)
           title = title && title[0] ? title[0] : ''
@@ -46,6 +46,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鍚�'
+          }
         }
       },
       {
@@ -91,6 +103,7 @@
     const { searches, scripts } = this.props
 
     let _usefulFields = []
+    let scriptsColumns = fromJS(this.state.scriptsColumns).toJS()
 
     if (searches) {
       searches.forEach(item => {
@@ -111,13 +124,20 @@
         }
       })
       _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 +216,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 +331,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()
   }
@@ -398,6 +430,18 @@
                 id, bid, loginuid, sessionuid, userid, username, fullname, appkey, time_id{usefulFields ? ', ' + usefulFields : ''}
               </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">
               <Form.Item label={'蹇嵎娣诲姞'} style={{marginBottom: 0}}>
                 <Select
@@ -406,7 +450,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))\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