From 6d0137932fcc8f9848123743c1aad5cff8172d8a Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 09 二月 2020 13:09:39 +0800
Subject: [PATCH] 2020-02-09

---
 src/templates/ushare/modalform/index.jsx |   92 ++++++++++++++++++++++++++++++++++------------
 1 files changed, 68 insertions(+), 24 deletions(-)

diff --git a/src/templates/ushare/modalform/index.jsx b/src/templates/ushare/modalform/index.jsx
index 7bde0cf..eeafd26 100644
--- a/src/templates/ushare/modalform/index.jsx
+++ b/src/templates/ushare/modalform/index.jsx
@@ -1,6 +1,6 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
-import { Form, Row, Col, Input, Select, Icon, Radio, notification, InputNumber } from 'antd'
+import { Form, Row, Col, Input, Select, Icon, Radio, notification, InputNumber, Tooltip } from 'antd'
 import { formRule } from '@/utils/option.js'
 import { dateOptions } from '@/utils/option.js'
 import EditTable from '../editable'
@@ -26,29 +26,30 @@
 
     let type = formlist.filter(cell => cell.key === 'type')[0].initVal
     let resourceType = formlist.filter(cell => cell.key === 'resourceType')[0].initVal
-    let _options = ['label', 'field', 'initval', 'type', 'readonly', 'required', 'hidden'] // 榛樿鏄剧ず椤�
+    let _options = ['label', 'field', 'initval', 'type', 'readonly', 'required', 'hidden', 'readin'] // 榛樿鏄剧ず椤�
 
     if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '0') { // 閫夋嫨绫诲瀷銆佽嚜瀹氫箟璧勬簮
       _options = [..._options, 'resourceType', 'options']
     } else if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '1') { // 閫夋嫨绫诲瀷銆佹暟鎹簮
       _options = [..._options, 'resourceType', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'database']
     } else if (type === 'number') {
-      _options = ['label', 'field', 'initval', 'type', 'readonly', 'hidden', 'decimal', 'min', 'max']
+      _options = ['label', 'field', 'initval', 'type', 'readonly', 'hidden', 'decimal', 'min', 'max', 'readin']
     } else if (type === 'fileupload') {
-      _options = ['label', 'field', 'type', 'readonly', 'required']
+      _options = ['label', 'field', 'type', 'readonly', 'required', 'readin', 'fieldlength']
+    } else if (type === 'text' || type === 'textarea') {
+      _options = [..._options, 'fieldlength']
     }
 
     if (type === 'select') {
-      _options = [..._options, 'setAll']
-      if (resourceType === '1') {
-        _options.push('linkSubField')
-      }
+      _options = [..._options, 'setAll', 'linkSubField']
+    } else if (type === 'multiselect') {
+      _options = [..._options, 'fieldlength']
     } else if (type === 'link') {          // 鍏宠仈绫诲瀷銆佸鍔犲叧鑱斿瓧娈�
       _options = [..._options, 'setAll', 'linkField']
     } else if (type === 'funcvar') {       // 璁剧疆涓哄嚱鏁板彉閲忔椂锛屼笉闇�瑕佸叾浠栦俊鎭�
       _options = ['label', 'field', 'type']
     } else if (type === 'linkMain') {
-      _options = ['label', 'field', 'type', 'readonly', 'required', 'hidden']
+      _options = ['label', 'field', 'type', 'readonly', 'required', 'hidden', 'fieldlength']
     }
     
     this.setState({
@@ -60,6 +61,7 @@
           form.type = 'select'
         } else if (type === 'number' && form.key === 'initval') {
           form.type = 'number'
+          form.initVal = form.initVal || 0
           form.required = true
         }
         form.show = _options.includes(form.key)
@@ -83,29 +85,30 @@
 
   openTypeChange = (key, value) => {
     if (key === 'type') {
-      let _options = ['label', 'field', 'initval', 'type', 'readonly', 'required', 'hidden']
+      let _options = ['label', 'field', 'initval', 'type', 'readonly', 'required', 'hidden', 'readin']
 
       if ((value === 'multiselect' || value === 'select' || value === 'link') && this.state.resourceType === '0') { // 閫夋嫨绫诲瀷銆佽嚜瀹氫箟璧勬簮
         _options = [..._options, 'resourceType', 'options']
       } else if ((value === 'multiselect' || value === 'select' || value === 'link') && this.state.resourceType === '1') { // 閫夋嫨绫诲瀷銆佹暟鎹簮
         _options = [..._options, 'resourceType', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'database']
       } else if (value === 'number') {
-        _options = ['label', 'field', 'initval', 'type', 'readonly', 'hidden', 'decimal', 'min', 'max']
+        _options = ['label', 'field', 'initval', 'type', 'readonly', 'hidden', 'decimal', 'min', 'max', 'readin']
       } else if (value === 'fileupload') {
-        _options = ['label', 'field', 'type', 'readonly', 'required']
+        _options = ['label', 'field', 'type', 'readonly', 'required', 'readin', 'fieldlength']
+      } else if (value === 'text' || value === 'textarea') {
+        _options = [..._options, 'fieldlength']
       }
 
       if (value === 'select') {
-        _options = [..._options, 'setAll']
-        if (this.state.resourceType === '1') {
-          _options.push('linkSubField')
-        }
+        _options = [..._options, 'setAll', 'linkSubField']
+      } else if (value === 'multiselect') {
+        _options = [..._options, 'fieldlength']
       } else if (value === 'link') {
         _options = [..._options, 'setAll', 'linkField']
       } else if (value === 'funcvar') {
         _options = ['label', 'field', 'type']
       } else if (value === 'linkMain') {
-        _options = ['label', 'field', 'type', 'readonly', 'required', 'hidden']
+        _options = ['label', 'field', 'type', 'readonly', 'required', 'hidden', 'fieldlength']
       }
       
       this.setState({
@@ -114,17 +117,26 @@
           form.show = _options.includes(form.key)
           if (form.key === 'initval') {
             form.required = false
+            form.initVal = ''
             if (dateOptions.hasOwnProperty(value)) {
               form.options = dateOptions[value]
               form.type = 'select'
             } else if (value === 'number') {
               form.type = 'number'
               form.required = true
+              form.initVal = 0
             } else {
               form.type = 'text'
             }
-            form.initVal = ''
             form.show = false
+          } else if (form.key === 'fieldlength') {
+            form.initVal = 50
+            if (value === 'textarea' || value === 'fileupload') {
+              form.initVal = 512
+            }
+            form.show = false
+          } else if (form.key === 'resourceType') {
+            form.initVal = this.state.resourceType
           }
           return form
         })
@@ -132,6 +144,8 @@
         this.setState({
           formlist: this.state.formlist.map(form => {
             if (form.key === 'initval' && value !== 'fileupload' && value !== 'funcvar' && value !== 'linkMain') {
+              form.show = true
+            } else if (form.key === 'fieldlength' && (value === 'fileupload' || value === 'multiselect' || value === 'text' || value === 'textarea' || value === 'linkMain')) {
               form.show = true
             }
             return form
@@ -141,11 +155,20 @@
     }
   }
 
+  multiselectChange = (key, value, options) => {
+    if (key === 'linkSubField') {
+
+    }
+    console.log(key)
+    console.log(value)
+    console.log(options)
+  }
+
   onChange = (e, key) => {
     const { openType } = this.state
     let value = e.target.value
     if (key === 'resourceType') {
-      let _options = ['label', 'field', 'initval', 'type', 'resourceType', 'readonly', 'required', 'hidden']
+      let _options = ['label', 'field', 'initval', 'type', 'resourceType', 'readonly', 'required', 'hidden', 'readin']
       if (value === '0') {
         _options = [..._options, 'options']
       } else if (value === '1') {
@@ -153,12 +176,11 @@
       }
 
       if (openType === 'select') {
-        _options = [..._options, 'setAll']
-        if (value === '1') {
-          _options.push('linkSubField')
-        }
+        _options = [..._options, 'setAll', 'linkSubField']
       } else if (openType === 'link') {
         _options = [..._options, 'setAll', 'linkField']
+      } else if (openType === 'multiselect') {
+        _options = [..._options, 'fieldlength']
       }
       
       this.setState({
@@ -229,6 +251,22 @@
               </Form.Item>
             </Col>
           )
+        } else if (item.key === 'fieldlength') {
+          fields.push(
+            <Col span={12} key={index}>
+              <Form.Item label={item.label}>
+                {getFieldDecorator(item.key, {
+                  initialValue: item.initVal,
+                  rules: [
+                    {
+                      required: !!item.required,
+                      message: this.props.dict['form.required.input'] + item.label + '!'
+                    }
+                  ]
+                })(<InputNumber min={1} precision={0} />)}
+              </Form.Item>
+            </Col>
+          )
         } else {
           fields.push(
             <Col span={12} key={index}>
@@ -286,6 +324,7 @@
                   showSearch
                   mode="multiple"
                   filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
+                  onChange={(value) => this.multiselectChange(item.key, value, item.options)}
                 >
                   {item.options.map(option =>
                     <Select.Option id={option.uuid} key={option.uuid} value={option.field}>{option.label}</Select.Option>
@@ -298,7 +337,12 @@
       } else if (item.type === 'radio') {
         fields.push(
           <Col span={12} key={index}>
-            <Form.Item label={item.label}>
+            <Form.Item label={item.tooltip ?
+              <Tooltip placement="topLeft" overlayClassName={item.tooltipClass} title={item.tooltip}>
+                <Icon type="question-circle" />
+                {item.label}
+              </Tooltip> : item.label
+            }>
               {getFieldDecorator(item.key, {
                 initialValue: item.initVal,
                 rules: [

--
Gitblit v1.8.0