From 2b84af9bed8f4b7da94a4bb85e7223d3b18e4fcb Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 14 十二月 2019 23:03:26 +0800
Subject: [PATCH] 2019-12-14

---
 src/templates/comtableconfig/settingform/index.jsx |   59 +++++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 47 insertions(+), 12 deletions(-)

diff --git a/src/templates/comtableconfig/settingform/index.jsx b/src/templates/comtableconfig/settingform/index.jsx
index 98a1943..ff83ed6 100644
--- a/src/templates/comtableconfig/settingform/index.jsx
+++ b/src/templates/comtableconfig/settingform/index.jsx
@@ -1,6 +1,6 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
-import { Form, Row, Col, Input, Radio, Select, Tooltip, Icon } from 'antd'
+import { Form, Row, Col, Input, Radio, Select, Tooltip, Icon, notification } from 'antd'
 import './index.scss'
 
 const { TextArea } = Input
@@ -21,7 +21,16 @@
     return new Promise((resolve, reject) => {
       this.props.form.validateFieldsAndScroll((err, values) => {
         if (!err) {
-          resolve(values)
+
+          if (values.interType === 'inner' && !values.innerFunc && !values.dataresource) {
+            notification.warning({
+              top: 92,
+              message: '璇疯嚜瀹氫箟鍑芥暟鎴栧~鍐欐暟鎹簮锛�',
+              duration: 10
+            })
+          } else {
+            resolve(values)
+          }
         } else {
           reject(err)
         }
@@ -30,12 +39,15 @@
   }
 
   onChange = (e) => {
-    console.log(e.target.value)
+    this.setState({
+      interType: e.target.value
+    })
   }
 
   render() {
     const { data, dict } = this.props
     const { getFieldDecorator } = this.props.form
+    const { interType } = this.state
 
     const formItemLayout = {
       labelCol: {
@@ -66,7 +78,7 @@
                 rules: [
                   {
                     required: true,
-                    message: this.props.dict['form.required.input'] + '琛ㄥ悕!'
+                    message: dict['form.required.input'] + '琛ㄥ悕!'
                   }
                 ]
               })(<Input placeholder="" autoComplete="off" />)}
@@ -88,27 +100,47 @@
             </Form.Item>
           </Col>
           <Col span={12}>
-            <Form.Item label="鎺ュ彛绫诲瀷">
+            <Form.Item label={dict['header.form.intertype']}>
               {getFieldDecorator('interType', {
                 initialValue: data.interType || 'inner'
               })(
                 <Radio.Group onChange={this.onChange}>
-                  <Radio value="inner">鍐呴儴</Radio>
-                  <Radio value="outer">澶栭儴</Radio>
+                  <Radio value="inner">{dict['header.form.interface.inner']}</Radio>
+                  <Radio value="outer">{dict['header.form.interface.outer']}</Radio>
                 </Radio.Group>
               )}
             </Form.Item>
           </Col>
-          <Col span={12}>
-            <Form.Item label="鍐呴儴鍑芥暟">
+          {interType === 'outer' ? <Col span={12}>
+            <Form.Item label={dict['header.form.interface']}>
+              {getFieldDecorator('interface', {
+                initialValue: data.interface || '',
+                rules: [
+                  {
+                    required: true,
+                    message: dict['form.required.input'] + dict['header.form.interface'] + '!'
+                  }
+                ]
+              })(<Input placeholder="" autoComplete="off" />)}
+            </Form.Item>
+          </Col> : null}
+          {interType === 'outer' ? <Col span={12}>
+            <Form.Item label={dict['header.form.outerFunc']}>
+              {getFieldDecorator('outerFunc', {
+                initialValue: data.outerFunc || ''
+              })(<Input placeholder="" autoComplete="off" />)}
+            </Form.Item>
+          </Col> : null}
+          {interType !== 'outer' ? <Col span={12}>
+            <Form.Item label={dict['header.form.innerFunc']}>
               {getFieldDecorator('innerFunc', {
                 initialValue: data.innerFunc || ''
               })(<Input placeholder="" autoComplete="off" />)}
             </Form.Item>
-          </Col>
+          </Col> : null}
           <Col span={24}>
             <Form.Item label={
-              <Tooltip placement="topLeft" title="">
+              <Tooltip placement="topLeft" title="浣跨敤绯荤粺鍑芥暟鏃讹紝闇�濉啓鏁版嵁婧愶紝鑷畾涔夊嚱鏁版椂锛屽彲蹇界暐銆�">
                 <Icon type="question-circle" />
                 {'鏁版嵁婧�'}
               </Tooltip>
@@ -145,12 +177,15 @@
           <Col span={12}>
             <Form.Item label="涓婚敭">
               {getFieldDecorator('primaryKey', {
-                initialValue: primaryKey
+                initialValue: primaryKey ? primaryKey : (this.props.columns.length === 0 ? 'ID' : '')
               })(
                 <Select
                   getPopupContainer={() => document.getElementById('commontable-setting-form')}
                 >
                   <Select.Option value="">涓嶈缃�</Select.Option>
+                  {this.props.columns.length === 0 ?
+                    <Select.Option value="ID">ID</Select.Option> : null
+                  }
                   {this.props.columns.map(option =>
                     <Select.Option id={option.uuid} title={option.label} key={option.uuid} value={option.field}>{option.label}</Select.Option>
                   )}

--
Gitblit v1.8.0