From 46f59e30133c25f1f01074b1c92445f9e85b8c98 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 31 十二月 2019 15:58:37 +0800
Subject: [PATCH] 2019-12-31

---
 src/templates/tableshare/searchform/index.jsx |   60 ++++++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 46 insertions(+), 14 deletions(-)

diff --git a/src/templates/tableshare/searchform/index.jsx b/src/templates/tableshare/searchform/index.jsx
index 73d67e2..df348b6 100644
--- a/src/templates/tableshare/searchform/index.jsx
+++ b/src/templates/tableshare/searchform/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 } from 'antd'
+import { Form, Row, Col, Input, Select, Icon, Radio, notification, Tooltip } from 'antd'
 import { dateOptions, matchReg } from '@/utils/option.js'
 import EditTable from '../editable'
 import './index.scss'
@@ -32,10 +32,14 @@
     let resourceType = formlist.filter(cell => cell.key === 'resourceType')[0].initVal
     let _options = ['label', 'field', 'initval', 'type', 'match']                // 榛樿鏄剧ず椤�
 
-    if ((type === 'select' || type === 'link') && resourceType === '0') {        // 涓嬫媺閫夋嫨绫诲瀷銆侀�夐」涓鸿嚜瀹氫箟璧勬簮
-      _options = [..._options, 'resourceType', 'setAll', 'options', 'display']
-    } else if ((type === 'select' || type === 'link') && resourceType === '1') { // 涓嬫媺閫夋嫨绫诲瀷銆侀�夐」涓哄悗鍙版暟鎹簮涓幏鍙�
-      _options = [..._options, 'resourceType', 'setAll', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'display']
+    if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '0') {        // 涓嬫媺閫夋嫨绫诲瀷銆侀�夐」涓鸿嚜瀹氫箟璧勬簮
+      _options = [..._options, 'resourceType', 'options', 'display']
+    } else if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '1') { // 涓嬫媺閫夋嫨绫诲瀷銆侀�夐」涓哄悗鍙版暟鎹簮涓幏鍙�
+      _options = [..._options, 'resourceType', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'display']
+    }
+
+    if (type === 'select' || type === 'link') {
+      _options.push('setAll')
     }
 
     if (type === 'link') { // 鍏宠仈绫诲瀷銆佸鍔犲叧鑱斾笂绾х殑瀛楁鍚�
@@ -55,7 +59,7 @@
         if (form.key === 'match') {
           if (type === 'text') {
             form.options = matchReg.text
-          } else if (type === 'select' || type === 'link') {
+          } else if (type === 'multiselect' || type === 'select' || type === 'link') {
             form.options = matchReg.select
           } else if (type === 'date') {
             form.options = matchReg.date
@@ -71,6 +75,19 @@
     })
   }
 
+  componentDidMount () {
+    const { card } = this.props
+
+    if (card.focus) {
+      try {
+        let _form = document.getElementById('label')
+        _form.select()
+      } catch {
+        console.warn('琛ㄥ崟focus澶辫触锛�')
+      }
+    }
+  }
+
   /**
    * @description 鎼滅储鏉′欢绫诲瀷鍒囨崲
    */
@@ -80,10 +97,14 @@
     if (key === 'type') {
       let _options = ['label', 'field', 'initval', 'type', 'match']
 
-      if ((value === 'select' || value === 'link') && resourceType === '0') {        // 涓嬫媺閫夋嫨绫诲瀷銆侀�夐」涓鸿嚜瀹氫箟璧勬簮
-        _options = [..._options, 'resourceType', 'setAll', 'options', 'display']
-      } else if ((value === 'select' || value === 'link') && resourceType === '1') { // 涓嬫媺閫夋嫨绫诲瀷銆侀�夐」涓哄悗鍙版暟鎹簮涓幏鍙�
-        _options = [..._options, 'resourceType', 'setAll', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'display']
+      if ((value === 'multiselect' || value === 'select' || value === 'link') && resourceType === '0') {        // 涓嬫媺閫夋嫨绫诲瀷銆侀�夐」涓鸿嚜瀹氫箟璧勬簮
+        _options = [..._options, 'resourceType', 'options', 'display']
+      } else if ((value === 'multiselect' || value === 'select' || value === 'link') && resourceType === '1') { // 涓嬫媺閫夋嫨绫诲瀷銆侀�夐」涓哄悗鍙版暟鎹簮涓幏鍙�
+        _options = [..._options, 'resourceType', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'display']
+      }
+
+      if (value === 'select' || value === 'link') {
+        _options.push('setAll')
       }
       
       if (value === 'link') {
@@ -107,7 +128,7 @@
           } else if (form.key === 'match') {                     // 鎼滅储鏉′欢绫诲瀷鍒囨崲鏃讹紝鍖归厤瑙勫垯绫诲瀷瀵瑰簲鍒囨崲
             if (value === 'text') {
               form.options = matchReg.text
-            } else if (value === 'select' || value === 'link') {
+            } else if (value === 'multiselect' || value === 'select' || value === 'link') {
               form.options = matchReg.select
             } else if (value === 'date') {
               form.options = matchReg.date
@@ -147,12 +168,16 @@
     let value = e.target.value
 
     if (key === 'resourceType') {
-      let _options = ['label', 'field', 'initval', 'type', 'match', 'resourceType', 'setAll', 'display']
+      let _options = ['label', 'field', 'initval', 'type', 'match', 'resourceType', 'display']
 
       if (value === '0') {
         _options = [..._options, 'options']
       } else if (value === '1') {
         _options = [..._options, 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType']
+      }
+
+      if (openType === 'select' || openType === 'link') {
+        _options.push('setAll')
       }
       
       if (openType === 'link') {
@@ -176,16 +201,23 @@
       if (item.hidden) return
 
       if (item.type === 'text') { // 鏂囨湰鎼滅储
+        let rules = item.rules || []
         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: [
                   {
                     required: !!item.required,
                     message: this.props.dict['form.required.input'] + item.label + '!'
-                  }
+                  },
+                  ...rules
                 ]
               })(<Input placeholder="" autoComplete="off" disabled={item.readonly} />)}
             </Form.Item>

--
Gitblit v1.8.0