From 1da6506bf58270bacc2a4345002c6b082835580e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 21 十月 2021 23:17:08 +0800
Subject: [PATCH] 2021-10-21

---
 src/tabviews/zshare/topSearch/index.jsx |   79 +++++++++++++++++++++------------------
 1 files changed, 43 insertions(+), 36 deletions(-)

diff --git a/src/tabviews/zshare/topSearch/index.jsx b/src/tabviews/zshare/topSearch/index.jsx
index 90209bf..c1403af 100644
--- a/src/tabviews/zshare/topSearch/index.jsx
+++ b/src/tabviews/zshare/topSearch/index.jsx
@@ -1,7 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
-import { fromJS } from 'immutable'
-import { Form, Row, Col, Input, Button, notification, Modal, Icon } from 'antd'
+import { is, fromJS } from 'immutable'
+import { Form, Row, Col, Button, notification, Modal, Icon } from 'antd'
 import moment from 'moment'
 
 import Api from '@/api'
@@ -11,9 +11,8 @@
 import Utils from '@/utils/utils.js'
 import zhCN from '@/locales/zh-CN/main.js'
 import enUS from '@/locales/en-US/main.js'
+import MKInput from './mkInput'
 import './index.scss'
-
-const { Search } = Input
 
 const MutilForm = asyncSpinComponent(() => import('./advanceform'))
 const MKCheckCard = asyncComponent(() => import('@/tabviews/zshare/mutilform/checkCard'))
@@ -78,6 +77,9 @@
     }
 
     if (searchlist) {
+      if (setting && setting.show === 'false') {
+        showButton = false
+      }
       _searchlist = fromJS(searchlist).toJS()
     } else if (config) {
       _searchlist = fromJS(config.search).toJS()
@@ -203,6 +205,10 @@
     })
   }
 
+  shouldComponentUpdate (nextProps, nextState) {
+    return !is(fromJS(this.state), fromJS(nextState))
+  }
+
   // 鏌ヨ涓嬫媺鑿滃崟
   improveSearch = (mainItems, localItems) => {
     const { menuType, BID } = this.props
@@ -312,7 +318,7 @@
   improveSimpleSearch = (deForms) => {
     if (deForms.length === 0) return
 
-    let deffers = deForms.map(item => {
+    let deffers = deForms.map((item, index) => {
       let param = {
         func: 'sPC_Get_SelectedList',
         LText: item.data_sql,
@@ -329,16 +335,18 @@
 
       return (
         new Promise(resolve => {
-          Api.getSystemCacheConfig(param).then(res => {
-            if (!res.status) {
-              notification.warning({
-                top: 92,
-                message: res.message,
-                duration: 5
-              })
-            }
-            resolve(res)
-          })
+          setTimeout(() => {
+            Api.getSystemCacheConfig(param).then(res => {
+              if (!res.status) {
+                notification.warning({
+                  top: 92,
+                  message: res.message,
+                  duration: 5
+                })
+              }
+              resolve(res)
+            })
+          }, index * 30)
         })
       )
     })
@@ -360,7 +368,7 @@
   }
 
   resetSearch = (result) => {
-    let _searchlist = this.state.searchlist.map(item => {
+    let _searchlist = fromJS(this.state.searchlist).toJS().map(item => {
       if (['select', 'link', 'multiselect', 'checkcard'].includes(item.type) && result[item.field] && result[item.field].length > 0) {
         let options = []
         result[item.field].forEach(cell => {
@@ -388,23 +396,22 @@
 
         item.oriOptions = [...item.oriOptions, ...options]
       }
+
+      if (item.type === 'link') {
+        if (item.supInitVal) {
+          item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal || option.Value === '')
+        } else {
+          item.options = item.oriOptions
+        }
+      } else if (item.type === 'select' || item.type === 'multiselect' || item.type === 'checkcard') {
+        item.options = item.oriOptions
+      }
+
       return item
     })
 
     this.setState({
-      searchlist: _searchlist.map(item => {
-        if (item.type === 'link') {
-          if (item.supInitVal) {
-            item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal || option.Value === '')
-          } else {
-            item.options = item.oriOptions
-          }
-        } else if (item.type === 'select' || item.type === 'multiselect' || item.type === 'checkcard') {
-          item.options = item.oriOptions
-        }
-
-        return item
-      })
+      searchlist: _searchlist
     })
   }
 
@@ -433,6 +440,7 @@
     const { getFieldDecorator } = this.props.form
     const { dict, showButton, showAdvanced, float, visible } = this.state
     const fields = []
+    let lastRadio = 6
 
     this.state.searchlist.forEach((item, index) => {
       if (item.hidden || item.advanced) return
@@ -445,14 +453,12 @@
       ]
 
       let content = null
+      let className = ''
       let field = item.field
+      lastRadio = item.ratio || 6
 
       if (item.type === 'text') {
-        if (item.inputType === 'search') {
-          content = <Search allowClear placeholder={item.labelShow === 'false' ? item.label : ''} autoComplete="off" onSearch={this.handleSubmit} enterButton/>
-        } else {
-          content = <Input allowClear placeholder={item.labelShow === 'false' ? item.label : ''} autoComplete="off" onPressEnter={this.handleSubmit} />
-        }
+        content = (<MKInput config={item} onInputSubmit={this.handleSubmit} />)
       } else if (item.type === 'select' || item.type === 'link' || item.type === 'multiselect') {
         content = (<MKSelect config={item} onChange={(val, defer) => this.recordChange(val, defer, item)} />)
       } else if (item.type === 'date' || item.type === 'datemonth' || item.type === 'dateweek' || item.type === 'daterange') {
@@ -461,13 +467,14 @@
         field = item.datefield
         content = <DateGroup position={index} config={item} onChange={(val, type) => this.dateGroupChange(val, type, item)} />
       } else if (item.type === 'checkcard') {
+        className = 'checkcard'
         content = <MKCheckCard card={item} onChange={this.handleSubmit} />
       }
 
       if (content) {
         fields.push(
           <Col span={item.ratio || 6} key={index}>
-            <Form.Item label={item.labelShow !== 'false' ? item.label : ''}>
+            <Form.Item className={className} label={item.labelShow !== 'false' ? item.label : ''}>
               {getFieldDecorator(field, {
                 initialValue: item.initval,
                 rules: _rules
@@ -480,7 +487,7 @@
 
     if (showButton) {
       let action = (
-        <Col span={6} style={{ whiteSpace: 'nowrap' }} className="search-button" key="actions">
+        <Col span={lastRadio < 6 ? 6 : lastRadio} style={{ whiteSpace: 'nowrap' }} className="search-button" key="actions">
           <Form.Item label={' '} colon={false} style={{ minHeight: '40px' }}>
             <Button type="primary" onClick={this.handleSubmit}>
               {dict['main.search']}

--
Gitblit v1.8.0