From b8cdbe3fbd57bbd513509a7d76c529096b1a7153 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 15 七月 2020 14:39:10 +0800
Subject: [PATCH] 2020-07-15

---
 src/mob/datasource/verifycard/settingform/index.jsx |   95 +++++++++++++++++++++--------------------------
 1 files changed, 43 insertions(+), 52 deletions(-)

diff --git a/src/mob/datasource/verifycard/settingform/index.jsx b/src/mob/datasource/verifycard/settingform/index.jsx
index 361cc5e..75352f2 100644
--- a/src/mob/datasource/verifycard/settingform/index.jsx
+++ b/src/mob/datasource/verifycard/settingform/index.jsx
@@ -13,16 +13,16 @@
 
 class SettingForm extends Component {
   static propTpyes = {
-    type: PropTypes.string,      // 鑿滃崟绫诲瀷
     dict: PropTypes.object,      // 瀛楀吀椤�
     menuId: PropTypes.string,    // 鑿滃崟Id
     setting: PropTypes.object,   // 鏁版嵁婧愰厤缃�
-    formlist: PropTypes.array,   // 琛ㄥ崟淇℃伅
+    columns: PropTypes.array,    // 鍒楄缃�
+    scripts: PropTypes.array,    // 鑷畾涔夎剼鏈�
   }
 
   state = {
-    interType: 'inner',
-    structure: 'array'
+    interType: this.props.setting.interType || 'inner',
+    structure: this.props.setting.structure || 'array'
   }
 
   handleConfirm = (otype) => {
@@ -31,10 +31,8 @@
     return new Promise((resolve, reject) => {
       this.props.form.validateFieldsAndScroll((err, values) => {
         if (!err) {
-          values = {...setting, ...values}
-
           // 鏁版嵁婧愬墠绔獙璇�
-          if (values.interType === 'inner' && !values.innerFunc && values.default !== 'false' && !values.dataresource) {
+          if (values.interType === 'inner' && !values.innerFunc && values.execute !== 'false' && !values.dataresource) {
             notification.warning({
               top: 92,
               message: '璇峰~鍐欏唴閮ㄥ嚱鏁版垨鏁版嵁婧愶紒',
@@ -42,7 +40,7 @@
             })
             reject()
             return
-          } else if (values.interType === 'inner' && !values.innerFunc && values.default !== 'false' && values.dataresource) {
+          } else if (values.interType === 'inner' && !values.innerFunc && values.execute !== 'false' && values.dataresource) {
             let _quot = values.dataresource.match(/'{1}/g)
             let _lparen = values.dataresource.match(/\({1}/g)
             let _rparen = values.dataresource.match(/\){1}/g)
@@ -57,6 +55,7 @@
                 message: '鏁版嵁婧愪腑\'蹇呴』鎴愬鍑虹幇',
                 duration: 5
               })
+              reject()
               return
             } else if (_lparen !== _rparen) {
               notification.warning({
@@ -64,6 +63,7 @@
                 message: '鏁版嵁婧愪腑()蹇呴』鎴愬鍑虹幇',
                 duration: 5
               })
+              reject()
               return
             } else if (/--/ig.test(values.dataresource)) {
               notification.warning({
@@ -71,6 +71,7 @@
                 message: '鏁版嵁婧愪腑锛屼笉鍙嚭鐜板瓧绗� -- 锛屾敞閲婅鐢� /*鍐呭*/',
                 duration: 5
               })
+              reject()
               return
             }
 
@@ -89,10 +90,8 @@
 
           // 鏁版嵁婧愪繚瀛�
           if (
-            values.interType === 'inner' && !values.innerFunc &&
-            values.default !== 'false' &&
-            /[^\s]+\s+[^\s]+/ig.test(values.dataresource) &&
-            setting.dataresource !== values.dataresource
+            values.interType === 'inner' && !values.innerFunc && values.execute !== 'false' &&
+            /[^\s]+\s+[^\s]+/ig.test(values.dataresource) && setting.dataresource !== values.dataresource
           ) {
             let param = {
               func: 's_DataSrc_Save',
@@ -107,17 +106,7 @@
             Api.getLocalConfig(param)
           }
 
-          if (otype === 'change') {
-            this.setState({
-              setting: values,
-            }, () => {
-              resolve()
-            })
-          } else {
-            values.customScript = this.getCustomScript(values)
-
-            this.sqlverify(values, resolve, reject)
-          }
+          resolve(values)
         } else {
           reject(err)
         }
@@ -140,7 +129,7 @@
   }
 
   render() {
-    const { columns } = this.props
+    const { columns, setting } = this.props
     const { getFieldDecorator } = this.props.form
     const { interType, structure } = this.state
 
@@ -162,7 +151,7 @@
             <Col span={8}>
               <Form.Item label="鍚嶇О">
                 {getFieldDecorator('name', {
-                  initialValue: '',
+                  initialValue: setting.name,
                   rules: [
                     {
                       required: true,
@@ -175,7 +164,7 @@
             <Col span={8}>
               <Form.Item label="琛ㄥ悕">
                 {getFieldDecorator('tableName', {
-                  initialValue: '',
+                  initialValue: setting.tableName,
                   rules: [
                     {
                       required: true,
@@ -222,7 +211,7 @@
             {interType === 'inner' ? <Col span={8}>
               <Form.Item label="鍐呴儴鍑芥暟">
                 {getFieldDecorator('innerFunc', {
-                  initialValue: '',
+                  initialValue: setting.innerFunc || '',
                   rules: [
                     
                   ]
@@ -232,7 +221,7 @@
             {interType === 'outer' ? <Col span={8}>
               <Form.Item label="鎺ュ彛鍦板潃">
                 {getFieldDecorator('interface', {
-                  initialValue: '',
+                  initialValue: setting.interface || '',
                   rules: [
                     {
                       required: true,
@@ -245,14 +234,14 @@
             {interType === 'outer' ? <Col span={8}>
               <Form.Item label="澶栭儴鍑芥暟">
                 {getFieldDecorator('outerFunc', {
-                  initialValue: '',
+                  initialValue: setting.outerFunc || '',
                   rules: [
 
                   ]
                 })(<Input placeholder={''} autoComplete="off" />)}
               </Form.Item>
             </Col> : null}
-            <Col span={24} className="data-source" style={{paddingLeft: '7px'}}>
+            {interType === 'inner' ? <Col span={24} className="data-source" style={{paddingLeft: '7px'}}>
               <Form.Item labelCol={{xs: { span: 24 }, sm: { span: 2 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 22 }} } label={
                 <Tooltip placement="topLeft" title={'浣跨敤绯荤粺鍑芥暟鏃讹紝闇�濉啓鏁版嵁婧愩�傛敞锛氭暟鎹潈闄愭浛鎹㈢ $@ -> /* 鎴� \'\'銆� @$ -> */ 鎴� \'\''}>
                   <Icon type="question-circle" />
@@ -260,17 +249,30 @@
                 </Tooltip>
               }>
                 {getFieldDecorator('dataresource', {
-                  initialValue: ''
+                  initialValue: setting.dataresource || ''
                 })(<TextArea rows={4} />)}
               </Form.Item>
-            </Col>
+            </Col> : null}
+            {interType === 'inner' ? <Col span={8}>
+              <Form.Item label={
+                <Tooltip placement="topLeft" title={'鏌ヨ鏃讹紝鎼滅储鏉′欢浠here鏉′欢鎷兼帴杩涘叆sql锛岀粺璁℃椂锛屽皢鏁版嵁婧愪腑浠モ�淍+鎼滅储瀛楁+@鈥濈殑鍐呭锛屼互鎼滅储鏉′欢涓殑鍊艰繘琛屾浛鎹㈠悗锛屾彁浜ゆ煡璇紝娉細鏌ヨ绫诲瀷浠呭湪浣跨敤绯荤粺鍑芥暟鏃舵湁鏁堛��'}>
+                  <Icon type="question-circle" />
+                  鏌ヨ绫诲瀷
+                </Tooltip>
+              }>
+                {getFieldDecorator('queryType', {
+                  initialValue: setting.queryType || 'query'
+                })(
+                <Radio.Group>
+                  <Radio value="query">鏌ヨ</Radio>
+                  <Radio value="statistics">缁熻</Radio>
+                </Radio.Group>)}
+              </Form.Item>
+            </Col> : null}
             {structure === 'array' ? <Col span={8}>
               <Form.Item label="涓婚敭">
                 {getFieldDecorator('primaryKey', {
-                  initialValue: '',
-                  rules: [
-
-                  ]
+                  initialValue: setting.primaryKey || ''
                 })(
                   <Select onChange={(value) => {this.selectChange('primaryKey', value)}}>
                     {columns.map((option, i) =>
@@ -285,20 +287,14 @@
             {structure === 'array' ? <Col span={8}>
               <Form.Item label="榛樿鎺掑簭">
                 {getFieldDecorator('order', {
-                  initialValue: '',
-                  rules: [
-
-                  ]
+                  initialValue: setting.order || ''
                 })(<Input placeholder={'ID asc, UID desc'} autoComplete="off" />)}
               </Form.Item>
             </Col> : null}
             {structure === 'array' ? <Col span={8}>
               <Form.Item label="鍒嗛〉">
                 {getFieldDecorator('laypage', {
-                  initialValue: '',
-                  rules: [
-
-                  ]
+                  initialValue: setting.laypage || 'true'
                 })(
                 <Radio.Group>
                   <Radio value="true">鏄�</Radio>
@@ -306,13 +302,11 @@
                 </Radio.Group>)}
               </Form.Item>
             </Col> : null}
+            
             {interType === 'inner' ? <Col span={8}>
               <Form.Item label="榛樿sql">
                 {getFieldDecorator('execute', {
-                  initialValue: 'true',
-                  rules: [
-
-                  ]
+                  initialValue: setting.execute || 'true'
                 })(
                 <Radio.Group>
                   <Radio value="true">鎵ц</Radio>
@@ -323,10 +317,7 @@
             <Col span={8}>
               <Form.Item label="鎼滅储鏉′欢">
                 {getFieldDecorator('search', {
-                  initialValue: 'true',
-                  rules: [
-
-                  ]
+                  initialValue: setting.search || 'true'
                 })(
                 <Radio.Group>
                   <Radio value="true">鎺ユ敹</Radio>

--
Gitblit v1.8.0