From 4c6bdfe1f3557e49a315c1564bcb6164c0bc7faa Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 03 四月 2020 18:27:22 +0800
Subject: [PATCH] 2020-04-03

---
 src/templates/zshare/modalform/index.jsx |   81 ++++++++++++----------------------------
 1 files changed, 24 insertions(+), 57 deletions(-)

diff --git a/src/templates/zshare/modalform/index.jsx b/src/templates/zshare/modalform/index.jsx
index 44a7776..da2cc4e 100644
--- a/src/templates/zshare/modalform/index.jsx
+++ b/src/templates/zshare/modalform/index.jsx
@@ -8,6 +8,21 @@
 
 const { TextArea } = Input
 
+const modalTypeOptions = {
+  text: ['label', 'field', 'initval', 'type', 'readonly', 'required', 'hidden', 'readin', 'blacklist', 'fieldlength', 'regular'],
+  number: ['label', 'field', 'initval', 'type', 'readonly', 'hidden', 'decimal', 'min', 'max', 'readin', 'blacklist'],
+  select: ['label', 'field', 'initval', 'type', 'readonly', 'required', 'hidden', 'readin', 'blacklist', 'resourceType', 'setAll', 'linkSubField'],
+  multiselect: ['label', 'field', 'initval', 'type', 'readonly', 'required', 'hidden', 'readin', 'blacklist', 'resourceType', 'fieldlength'],
+  link: ['label', 'field', 'initval', 'type', 'readonly', 'required', 'hidden', 'readin', 'blacklist', 'resourceType', 'setAll', 'linkField'],
+  fileupload: ['label', 'field', 'type', 'readonly', 'required', 'readin', 'fieldlength', 'blacklist', 'maxfile', 'fileType'],
+  date: ['label', 'field', 'initval', 'type', 'readonly', 'required', 'hidden', 'readin', 'blacklist'],
+  datemonth: ['label', 'field', 'initval', 'type', 'readonly', 'required', 'hidden', 'readin', 'blacklist'],
+  datetime: ['label', 'field', 'initval', 'type', 'readonly', 'required', 'hidden', 'readin', 'blacklist'],
+  textarea: ['label', 'field', 'initval', 'type', 'readonly', 'required', 'hidden', 'readin', 'blacklist', 'fieldlength', 'maxRows'],
+  funcvar: ['label', 'field', 'type', 'blacklist'],
+  linkMain: ['label', 'field', 'type', 'readonly', 'required', 'hidden', 'fieldlength', 'blacklist']
+}
+
 class MainSearch extends Component {
   static propTpyes = {
     dict: PropTypes.object,    // 瀛楀吀椤�
@@ -54,32 +69,12 @@
       }
     })
     
-    let _options = ['label', 'field', 'initval', 'type', 'readonly', 'required', 'hidden', 'readin', 'blacklist'] // 榛樿鏄剧ず椤�
+    let _options = modalTypeOptions[type]
 
     if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '0') { // 閫夋嫨绫诲瀷銆佽嚜瀹氫箟璧勬簮
-      _options = [..._options, 'resourceType', 'options', 'quick']
+      _options = [..._options, 'options', 'quick']
     } 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', 'readin', 'blacklist']
-    } else if (type === 'fileupload') {
-      _options = ['label', 'field', 'type', 'readonly', 'required', 'readin', 'fieldlength', 'blacklist']
-    } else if (type === 'textarea') {
-      _options = [..._options, 'fieldlength', 'maxRows']
-    } else if (type === 'text') {
-      _options = [..._options, 'fieldlength', 'regular']
-    }
-
-    if (type === 'select') {
-      _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', 'blacklist']
-    } else if (type === 'linkMain') {
-      _options = ['label', 'field', 'type', 'readonly', 'required', 'hidden', 'fieldlength', 'blacklist']
+      _options = [..._options, 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'database']
     }
 
     if (type !== 'funcvar' && type !== 'linkMain') {
@@ -132,34 +127,13 @@
   }
 
   openTypeChange = (key, value) => {
-
     if (key === 'type') {
-      let _options = ['label', 'field', 'initval', 'type', 'readonly', 'required', 'hidden', 'readin', 'blacklist']
+      let _options = modalTypeOptions[value]
 
       if ((value === 'multiselect' || value === 'select' || value === 'link') && this.state.resourceType === '0') { // 閫夋嫨绫诲瀷銆佽嚜瀹氫箟璧勬簮
-        _options = [..._options, 'resourceType', 'options', 'quick']
+        _options = [..._options, 'options', 'quick']
       } 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', 'readin', 'blacklist']
-      } else if (value === 'fileupload') {
-        _options = ['label', 'field', 'type', 'readonly', 'required', 'readin', 'fieldlength', 'blacklist']
-      } else if (value === 'textarea') {
-        _options = [..._options, 'fieldlength', 'maxRows']
-      } else if (value === 'text') {
-        _options = [..._options, 'fieldlength', 'regular']
-      }
-
-      if (value === 'select') {
-        _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', 'blacklist']
-      } else if (value === 'linkMain') {
-        _options = ['label', 'field', 'type', 'readonly', 'required', 'hidden', 'fieldlength', 'blacklist']
+        _options = [..._options, 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'database']
       }
 
       if (value !== 'funcvar' && value !== 'linkMain') {
@@ -267,21 +241,14 @@
     const { openType } = this.state
     let value = e.target.value
     if (key === 'resourceType') {
-      let _options = ['label', 'field', 'initval', 'type', 'resourceType', 'readonly', 'required', 'hidden', 'readin', 'blacklist', 'supField']
+      let _options = modalTypeOptions[openType]
+
       if (value === '0') {
         _options = [..._options, 'options', 'quick']
       } else if (value === '1') {
         _options = [..._options, 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'database']
       }
 
-      if (openType === 'select') {
-        _options = [..._options, 'setAll', 'linkSubField']
-      } else if (openType === 'link') {
-        _options = [..._options, 'setAll', 'linkField']
-      } else if (openType === 'multiselect') {
-        _options = [..._options, 'fieldlength']
-      }
-      
       this.setState({
         resourceType: value,
         formlist: this.state.formlist.map(form => {
@@ -363,7 +330,7 @@
               </Form.Item>
             </Col>
           )
-        } else if (item.key === 'fieldlength') {
+        } else if (item.key === 'fieldlength' || item.key === 'maxfile') {
           fields.push(
             <Col span={12} key={index}>
               <Form.Item label={item.label}>

--
Gitblit v1.8.0