From 7b8cfa542fb5f8fa699b114b2a71a2f6a005483a Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 13 五月 2025 20:49:31 +0800
Subject: [PATCH] 2025-05-13

---
 src/tabviews/zshare/topSearch/index.jsx | 1539 ++++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 1,207 insertions(+), 332 deletions(-)

diff --git a/src/tabviews/zshare/topSearch/index.jsx b/src/tabviews/zshare/topSearch/index.jsx
index 8c1adb4..06cddd2 100644
--- a/src/tabviews/zshare/topSearch/index.jsx
+++ b/src/tabviews/zshare/topSearch/index.jsx
@@ -1,66 +1,346 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
-import { Form, Row, Col, Input, Button, Select, DatePicker, notification } from 'antd'
+import { fromJS } from 'immutable'
+import { Form, Row, Col, Button, notification, Modal, Drawer } from 'antd'
+import { CloseOutlined, DownOutlined } from '@ant-design/icons'
 import moment from 'moment'
+import md5 from 'md5'
+
+import Api from '@/api'
+import asyncComponent from '@/utils/asyncComponent'
+import asyncSpinComponent from '@/utils/asyncSpinComponent'
 import Utils from '@/utils/utils.js'
+import MKEmitter from '@/utils/events.js'
+import MKInput from './mkInput'
 import './index.scss'
 
-const {MonthPicker, WeekPicker, RangePicker} = DatePicker
+const MutilForm = asyncSpinComponent(() => import('./advanceform'))
+const MKCheckCard = asyncComponent(() => import('./mkCheckCard'))
+const MKCheck = asyncComponent(() => import('@/tabviews/zshare/mutilform/mkCheck'))
+const MKSwitch = asyncComponent(() => import('@/tabviews/zshare/mutilform/mkSwitch'))
+const MKRadio = asyncComponent(() => import('./mkRadio'))
+const MKSelect = asyncComponent(() => import('./mkSelect'))
+const DateGroup = asyncComponent(() => import('./dategroup'))
+const MKDatePicker = asyncComponent(() => import('./mkDatePicker'))
+const MKNumber = asyncComponent(() => import('./mkNumber'))
 
 class MainSearch extends Component {
   static propTpyes = {
-    searchlist: PropTypes.array, // 鎼滅储鏉′欢鍒楄〃
-    dict: PropTypes.object // 瀛楀吀椤�
+    BID: PropTypes.any,
+    config: PropTypes.object
   }
 
   state = {
-    match: null,            // 鎼滅储鏉′欢鍖归厤瑙勫垯
-    style: null,            // 鎼滅储鏉′欢绫诲瀷
-    label: null,            // 鎻愮ず鏂囧瓧
-    required: null,         // 鏄惁蹇呭~
-    searchlist: null,       // 鎼滅储椤�
-    formId: Utils.getuuid() // 鎼滅储琛ㄥ崟Id
+    searchlist: null,        // 鎼滅储椤�
+    setting: {},
+    advanceValues: [],       // 楂樼骇鎼滅储鏉′欢淇濆瓨鍊�
+    visible: false,
+    hasReqFields: false
   }
 
-  UNSAFE_componentWillMount () {
-    let searchlist = JSON.parse(JSON.stringify(this.props.searchlist))
-    let match = {}
-    let label = {}
-    let style = {}
-    let required = {}
-    let _list = []
-    let fieldMap = new Map()
+  record = {}
+  sign = ''
 
-    searchlist.forEach(item => {
+  UNSAFE_componentWillMount () {
+    const { config } = this.props
+
+    let _searchlist = []
+    let fieldMap = new Map()
+    let mainItems = []  // 浜戠鎴栧崟鐐规暟鎹�
+    let localItems = [] // 鏈湴鏁版嵁
+    let backMItems = [] // 浜戠鎴栧崟鐐规暟鎹�
+    let backLItems = [] // 鏈湴鏁版嵁
+    let deForms = []    // 娴嬭瘯绯荤粺锛屽崟涓姹�
+    let advanceValues = []
+    let linkFields = {}
+    let record = {}
+    let forbid = false // header涓笉璁剧疆楂樼骇鎼滅储
+    let _setting = {showAdv: false, show: false, style: null, $pageId: config.$pageId || ''}
+    let BID = this.props.BID
+    let sysvals = {}
+
+    if (window.backend) {
+      sysvals = {
+        mk_departmentcode: sessionStorage.getItem('departmentcode') || '',
+        mk_organization: sessionStorage.getItem('organization') || '',
+        mk_user_type: sessionStorage.getItem('mk_user_type') || '',
+        bid: BID || '',
+        datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
+        datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
+        datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
+      }
+      if (window.GLOB.externalDatabase !== null) {
+        sysvals.db = window.GLOB.externalDatabase
+      }
+    }
+    
+    if (config.wrap) {
+      _setting.show = config.wrap.show !== 'false'
+      _setting.advanceType = config.wrap.advanceType || 'modal'
+      _setting.advWidth = config.wrap.advanceWidth || 1000
+      _setting.placement = config.wrap.drawerPlacement || 'right'
+      _setting.ratio = config.wrap.searchRatio || 6
+      _setting.labelwidth = config.wrap.searchLwidth !== undefined ? config.wrap.searchLwidth : 33.3
+      _setting.labelCol = {style: {width: _setting.labelwidth + '%'}}
+      _setting.wrapperCol = {style: {width: (100 - _setting.labelwidth) + '%'}}
+      _setting.borderRadius = config.wrap.borderRadius
+      _setting.resetContrl = config.wrap.resetContrl || 'init'
+      _setting.order = config.wrap.searchSize || ''
+
+      if (config.wrap.searchBtn === 'show') {
+        _setting.showBtn = true
+      }
+
+      if (config.wrap.supModule) {
+        let BData = window.GLOB.CacheData.get(config.wrap.supModule)
+        BID = BData ? (BData.$BID || '') : ''
+      }
+    }
+    
+    if (config.type === 'search') {
+      _setting.float = config.wrap.float || 'left'
+      _setting.style = config.style
+    } else if (config.type === 'table') {
+      _setting.float = 'left'
+    } else {
+      _setting.float = 'right'
+      _setting.show = false
+      forbid = true
+    }
+
+    if (_setting.advanceType === 'drawer' && _setting.advWidth) {
+      if (_setting.placement === 'top' || _setting.placement === 'bottom') {
+        _setting.advHeight = _setting.advWidth > 100 ? _setting.advWidth + 'px' : _setting.advWidth + 'vh'
+        _setting.advWidth = '100vw'
+      } else {
+        _setting.advWidth = _setting.advWidth > 100 ? _setting.advWidth + 'px' : _setting.advWidth + 'vw'
+      }
+    } else if (_setting.advanceType === 'modal' && _setting.advWidth) {
+      if (_setting.advWidth < 100) {
+        _setting.advWidth = _setting.advWidth + 'vw'
+      } else {
+        _setting.advWidth = _setting.advWidth + 'px'
+      }
+    }
+
+    _searchlist = fromJS(config.search).toJS()
+
+    _searchlist.forEach(item => {
+      if (item.linkField) {
+        linkFields[item.linkField] = linkFields[item.linkField] || []
+        linkFields[item.linkField].push({field: item.field, uuid: item.uuid})
+      }
+
+      let labelwidth = item.labelwidth || 33.3
+      if (item.labelShow === 'false') {
+        labelwidth = 0
+      }
+      item.labelCol = {style: {width: labelwidth + '%'}}
+      item.wrapperCol = {style: {width: (100 - labelwidth) + '%'}}
+
       if (fieldMap.has(item.field)) {
         item.field = item.field + '@tail@'
       }
-      fieldMap.set(item.field, true)
 
-      match[item.field] = item.match
-      label[item.field] = item.label
-      style[item.field] = item.type
-      required[item.field] = item.required === 'true'
-
-      if (item.type === 'select' || item.type === 'link') {
-        item.oriOptions = JSON.parse(JSON.stringify(item.options))
+      if (item.advanced && !forbid) {
+        _setting.showAdv = true
+        if (!['group', 'check', 'switch'].includes(item.type)) {
+          item.signValue = true
+        }
+      } else {
+        item.advanced = false
       }
 
-      _list.push(item)
+      if (item.checkShift && !item.initval) {
+        let d = ''
+        if (window.GLOB.CacheData.has(item.$supId)) {
+          d = window.GLOB.CacheData.get(item.$supId)
+          d = d[item.dateShift] || ''
+          if (d) {
+            d = moment(d).format('YYYY-MM-DD')
+            d = d === 'Invalid date' ? '' : d
+          }
+        }
+
+        if (d) {
+          if (item.type === 'daterange') {
+            if (item.$initval === 'week') {
+              item.initval = [moment(d).startOf('week').format(item.format), moment(d).endOf('week').format(item.format)].join(',')
+            } else if (item.$initval === 'month') {
+              item.initval = [moment(d).startOf('month').format(item.format), moment(d).endOf('month').format(item.format)].join(',')
+            } else if (item.$initval === 'lastMonth') {
+              item.initval = [moment(d).subtract(1, 'months').startOf('month').format(item.format), moment(d).subtract(1, 'months').endOf('month').format(item.format)].join(',')
+            } else if (item.$initval === 'year') {
+              item.initval = [moment(d).startOf('year').format(item.format), moment(d).endOf('year').format(item.format)].join(',')
+            } else if (item.$initval === 'lastYear') {
+              item.initval = [moment(d).subtract(1, 'years').startOf('year').format(item.format), moment(d).subtract(1, 'years').endOf('year').format(item.format)].join(',')
+            } else {
+              try {
+                let _initval = JSON.parse(item.$initval)
+                let _vals = [moment(d).subtract(_initval[0], 'days').format(item.format), moment(d).subtract(_initval[1], 'days').format(item.format)]
+                item.initval = _vals.join(',')
+              } catch (e) {
+                item.initval = ''
+              }
+            }
+          } else {
+            item.initval = moment(d).subtract(item.$initval, 'month').format('YYYY-MM')
+          }
+          item.oriInitval = item.initval
+        }
+      }
+
+      if (item.type === 'group') {
+        record[item.field] = item.initType
+        record[item.datefield] = item.initval
+      } else {
+        record[item.field] = item.initval
+      }
+      
+      if (['select', 'link', 'multiselect', 'checkcard', 'radio'].includes(item.type)) {
+        item.options = item.options || []
+        item.options = item.options.filter(op => !op.Hide)
+        if (item.setAll === 'true' && ['select', 'link'].includes(item.type)) {
+          item.options.unshift({
+            key: Utils.getuuid(),
+            Value: '',
+            Text: '鍏ㄩ儴',
+            ParentID: ''
+          })
+        }
+
+        // 鏁版嵁婧愭煡璇㈣鍙�
+        if (item.resourceType === '1' && item.dataSource) {
+          if (window.backend && window.GLOB.CacheData.has('sql_' + item.uuid)) {
+            let ex = window.GLOB.CacheData.get('sql_' + item.uuid)
+            let exps = []
+
+            ex.reps.forEach(n => {
+              let key = n.toLowerCase()
+              if (sysvals.hasOwnProperty(key)) {
+                exps.push({
+                  key: n,
+                  value: sysvals[key]
+                })
+              }
+            })
+
+            let cell = {
+              id: ex.id,
+              exps: exps,
+              menuname: item.label + '锛堟悳绱級',
+              md5_id: ''
+            }
+            if (item.checkBid) {
+              item.sqlId = ex.id
+              item.exps = exps
+            }
+
+            if (item.checkBid && !BID) {
+
+            } else if (item.database === 'sso' && window.GLOB.mainSystemApi) {
+              backMItems.push(cell)
+            } else {
+              backLItems.push(cell)
+            }
+          } else {
+            let _option = Utils.getSelectQueryOptions(item)
+            let _declare = `Declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20)  select @mk_departmentcode='${sessionStorage.getItem('departmentcode') || ''}',@mk_organization='${sessionStorage.getItem('organization') || ''}',@mk_user_type='${sessionStorage.getItem('mk_user_type') || ''}'\n`
+  
+            let exec = true
+            if (item.checkBid) {
+              item.sql = _declare + _option.sql
+              item.arr_field = _option.field
+  
+              exec = !!BID
+            }
+  
+            if (exec) {
+              let _sql = _option.sql.replace(/@BID@/ig, `'${BID || ''}'`)
+    
+              if (window.GLOB.debugger === true) {
+                window.mkInfo(_declare + _sql)
+              }
+    
+              // 娴嬭瘯绯荤粺鍗曚釜璇锋眰
+              if (!window.GLOB.mkHS && window.GLOB.sysType === 'local' && !window.GLOB.systemType) {
+                deForms.push({
+                  ...item,
+                  arr_field: _option.field,
+                  data_sql: Utils.formatOptions(_declare + _sql, window.GLOB.execType)
+                })
+              } else { // 鍚堝苟璇锋眰锛屽尯鍒嗘湰鍦板強绯荤粺
+                _sql = _sql.replace(/%/ig, ' mpercent ')
+                if (item.database === 'sso') {
+                  if (mainItems.length === 0) {
+                    _sql = _declare + _sql
+                  }
+                  mainItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_sql))}' as LText`)
+                } else {
+                  if (localItems.length === 0) {
+                    _sql = _declare + _sql
+                  }
+                  localItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_sql))}' as LText`)
+                }
+              }
+            }
+          }
+        }
+        item.oriOptions = fromJS(item.options).toJS()
+
+        if (item.type === 'checkcard' && item.multiple === 'dropdown' && item.resourceType === '0') {
+          this.resetCheckcard(item)
+        }
+      }
+
+      if (item.signValue && item.initval) {
+        let val = item.initval
+        if (item.precision === 'hour') {
+          if (/,/ig.test(val)) {
+            val = val.split(',').map(m => m + ':00').join(',')
+          } else {
+            val = val + ':00'
+          }
+        }
+
+        let text = val
+
+        if (item.type === 'select' || item.type === 'link' || item.type === 'radio') {
+          item.oriOptions.forEach(cell => {
+            if (cell.Value === val) {
+              text = cell.Text
+            }
+          })
+        }
+
+        advanceValues.push({field: item.field, type: item.type, label: item.label, value: val, text})
+      }
+
+      fieldMap.set(item.field, item)
     })
 
-    _list = _list.map(item => {
-      if (item.type === 'link') {
-        let supItem = _list.filter(form => form.field === item.linkField)[0]
+    this.record = record
+
+    let _list = _searchlist.map(item => {
+      if (item.hidden) return item
+
+      if (linkFields[item.field] && (item.type === 'select' || item.type === 'link' || (item.type === 'checkcard' && item.multiple !== 'true'))) {
+        item.linkFields = linkFields[item.field]
+      }
+
+      if (item.linkField) {
+        let supItem = fieldMap.get(item.linkField)
         
         if (!supItem) {
           notification.warning({
             top: 92,
             message: '鏈煡璇㈠埌鎼滅储鏉′欢銆�' + item.label + '銆嬪叧鑱斿瓧娈碉紒',
-            duration: 10
+            duration: 5
           })
+          item.type = 'select'
         } else {
-          item.options = item.oriOptions.filter(option => option.parentId === supItem.initval)
+          item.supInitVal = supItem.initval
+          item.options = item.oriOptions.filter(option => option.ParentID === supItem.initval || option.Value === '')
         }
       }
 
@@ -68,364 +348,911 @@
     })
 
     this.setState({
-      match: match,
-      label: label,
-      style: style,
-      required: required,
+      setting: _setting,
+      hasReqFields: config.$s_req,
+      advanceValues,
       searchlist: _list
+    }, () => {
+      if (window.backend && (backMItems.length > 0 || backLItems.length > 0)) {
+        this.improveBackSearch(backMItems, backLItems, false)
+      } else if (!window.GLOB.mkHS && window.GLOB.sysType === 'local' && window.GLOB.systemType !== 'production') {
+        this.improveSimpleSearch(deForms, false, null, BID)
+      } else if (mainItems.length > 0 || localItems.length > 0) {
+        this.improveSearch(mainItems, localItems, BID)
+      }
     })
+  }
+
+  componentDidMount () {
+    const { config } = this.props
+
+    if (config.type === 'search' && config.wrap.supModule) {
+      MKEmitter.addListener('resetSelectLine', this.resetParentParam)
+    }
+  }
+
+  componentWillUnmount () {
+    this.setState = () => {
+      return
+    }
+    MKEmitter.removeListener('resetSelectLine', this.resetParentParam)
   }
 
   UNSAFE_componentWillReceiveProps(nextProps) {
-    let searchlist = JSON.parse(JSON.stringify(nextProps.searchlist))
-    let _list = []
-    let fieldMap = new Map()
+    const { config, BID } = this.props
 
-    searchlist.forEach(item => {
-      if (fieldMap.has(item.field)) {
-        item.field = item.field + '@tail@'
-      }
-      fieldMap.set(item.field, true)
-
-      if (item.type === 'select' || item.type === 'link') {
-        item.oriOptions = JSON.parse(JSON.stringify(item.options))
-      }
-
-      _list.push(item)
-    })
-
-    _list = _list.map(item => {
-      if (item.type === 'link') {
-        let supItem = _list.filter(form => form.field === item.linkField)[0]
-        
-        if (supItem) {
-          item.options = item.oriOptions.filter(option => option.parentId === supItem.initval)
-        }
-      }
-
-      return item
-    })
-
-    this.setState({
-      searchlist: _list
-    })
+    if (config.$checkBid && nextProps.BID !== BID) {
+      this.resetOptions(nextProps.BID)
+    }
   }
 
-  resetform = (formlist, supfields, index) => {
-    index++
-    let subfields = []
+  resetParentParam = (MenuID, id) => {
+    const { config } = this.props
 
-    supfields.forEach(supfield => {
-      formlist = formlist.map(item => {
-        if (item.type === 'link' && item.linkField === supfield.field) {
-          item.options = item.oriOptions.filter(option => option.parentId === supfield.initval)
-          item.initval = item.options[0] ? item.options[0].Value : ''
-          item.hiden = true
+    if (config.wrap.supModule !== MenuID) return
+
+    this.resetOptions(id)
+  }
+
+  resetOptions = (BID) => {
+    let deForms = []
+    let backMItems = [] // 浜戠鎴栧崟鐐规暟鎹�
+    let backLItems = [] // 鏈湴鏁版嵁
+    let searchlist = fromJS(this.state.searchlist).toJS().map(item => {
+      if (item.checkBid) {
+        if (window.backend && item.sqlId) {
+          let cell = {
+            id: item.sqlId,
+            menuname: item.label + '锛堟悳绱級',
+            md5_id: '',
+            exps: item.exps.map(n => {
+              if (n.key === 'BID') {
+                n.value = BID
+              }
+              return n
+            })
+          }
+
+          if (item.database === 'sso' && window.GLOB.mainSystemApi) {
+            backMItems.push(cell)
+          } else {
+            backLItems.push(cell)
+          }
+        } else {
+          let sql = item.sql.replace(/@BID@/ig, `'${BID || ''}'`)
+    
+          if (window.GLOB.debugger === true) {
+            window.mkInfo(sql)
+          }
   
-          subfields.push(item)
+          deForms.push({
+            ...item,
+            arr_field: item.arr_field,
+            data_sql: Utils.formatOptions(sql, window.GLOB.execType)
+          })
         }
-        return item
-      })
-    })
+      } else if (item.checkShift) {
+        let d = ''
+        if (window.GLOB.CacheData.has(item.$supId)) {
+          d = window.GLOB.CacheData.get(item.$supId)
+          d = d[item.dateShift] || ''
+          if (d) {
+            d = moment(d).format('YYYY-MM-DD')
+            d = d === 'Invalid date' ? '' : d
+          }
+        }
 
-    if (subfields.length === 0 || index > 6) {
-      return formlist
-    } else {
-      return this.resetform(formlist, subfields, index)
-    }
-  }
-
-  selectChange = (_field, value) => {
-    let formlist = JSON.parse(JSON.stringify(this.state.searchlist))
-
-    let subfields = []
-    formlist = formlist.map(item => {
-      if (item.type === 'link' && item.linkField === _field.field) {
-        item.options = item.oriOptions.filter(option => option.parentId === value)
-        item.initval = item.options[0] ? item.options[0].Value : ''
-        item.hiden = true
-
-        subfields.push(item)
+        if (d) {
+          if (item.type === 'daterange') {
+            if (item.$initval === 'week') {
+              item.initval = [moment(d).startOf('week').format(item.format), moment(d).endOf('week').format(item.format)].join(',')
+            } else if (item.$initval === 'month') {
+              item.initval = [moment(d).startOf('month').format(item.format), moment(d).endOf('month').format(item.format)].join(',')
+            } else if (item.$initval === 'lastMonth') {
+              item.initval = [moment(d).subtract(1, 'months').startOf('month').format(item.format), moment(d).subtract(1, 'months').endOf('month').format(item.format)].join(',')
+            } else if (item.$initval === 'year') {
+              item.initval = [moment(d).startOf('year').format(item.format), moment(d).endOf('year').format(item.format)].join(',')
+            } else if (item.$initval === 'lastYear') {
+              item.initval = [moment(d).subtract(1, 'years').startOf('year').format(item.format), moment(d).subtract(1, 'years').endOf('year').format(item.format)].join(',')
+            } else {
+              try {
+                let _initval = JSON.parse(item.$initval)
+                let _vals = [moment(d).subtract(_initval[0], 'days').format(item.format), moment(d).subtract(_initval[1], 'days').format(item.format)]
+                item.initval = _vals.join(',')
+              } catch (e) {
+                item.initval = ''
+              }
+            }
+          } else {
+            item.initval = moment(d).subtract(item.$initval, 'month').format('YYYY-MM')
+          }
+          item.oriInitval = item.initval
+        }
       }
+
       return item
     })
 
-    if (subfields.length === 0) {
-      this.searchChange()
-      return
+    if (window.backend && (backMItems.length > 0 || backLItems.length > 0)) {
+      this.improveBackSearch(backMItems, backLItems, true, searchlist)
+    } else if (deForms.length > 0) {
+      this.improveSimpleSearch(deForms, true, searchlist, BID)
+    } else {
+      this.setState({
+        searchlist: searchlist
+      })
+      
+      setTimeout(() => {
+        this.handleSubmit()
+      }, 20)
+    }
+  }
+
+  resetCheckcard = (item) => {
+    let pid = item.resourceType === '0' ? 'pid' : item.parentField
+    let _options = []
+    let _others = []
+    item.oriOptions.forEach(op => {
+      if (op[pid] === item.mark) {
+        _options.push(op)
+      } else {
+        _others.push(op)
+      }
+    })
+
+    _options = _options.map(op => {
+      op.children = []
+
+      _others = _others.filter(cell => {
+        if (cell[pid] === op.$value) {
+          op.children.push(cell)
+          return false
+        }
+        return true
+      })
+
+      op.subIds = op.children.map(cell => cell.$value)
+
+      return op
+    })
+
+    item.oriOptions = _options
+    item.options = _options
+  }
+
+  // 鏌ヨ涓嬫媺鑿滃崟
+  improveSearch = (mainItems, localItems, BID) => {
+    let deffers = []
+
+    // 鏈湴璇锋眰
+    let param = {
+      func: 'sPC_Get_SelectedList',
+      LText: localItems.join(' union all '),
+      obj_name: '',
+      arr_field: '',
+      table_type: 'Y'
     }
 
-    formlist = this.resetform(formlist, subfields, 0)
+    if (BID) {
+      param.BID = BID
+    }
+    
+    if (param.LText) {
+      if (window.GLOB.execType === 'x') {
+        param.exec_type = 'x'
+      }
 
-    this.setState({
-      searchlist: formlist
-    }, () => {
-      this.setState({
-        searchlist: formlist.map(item => {
-          item.hiden = false
-          return item
+      param.LText = Utils.formatOptions(param.LText, param.exec_type)
+      param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+      param.secretkey = Utils.encrypt(window.GLOB.execType === 'x' ? '' : param.LText, param.timestamp)
+
+      if (window.GLOB.mkHS) { // 浜戠鏁版嵁楠岃瘉
+        param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
+      }
+
+      deffers.push(
+        new Promise(resolve => {
+          Api.getSystemCacheConfig(param).then(res => {
+            if (!res.status && res.ErrCode !== '-2') {
+              notification.warning({
+                top: 92,
+                message: res.message,
+                duration: 5
+              })
+            }
+            resolve(res)
+          })
         })
-      }, () => {
-        this.searchChange()
+      )
+    }
+
+    // 绯荤粺璇锋眰
+    let mainparam = {
+      func: 'sPC_Get_SelectedList',
+      LText: mainItems.join(' union all '),
+      obj_name: '',
+      arr_field: '',
+      table_type: 'Y'
+    }
+
+    if (BID) {
+      mainparam.BID = BID
+    }
+
+    if (mainparam.LText) {
+      if (window.GLOB.execType === 'x') {
+        mainparam.exec_type = 'x'
+      }
+
+      mainparam.LText = Utils.formatOptions(mainparam.LText, mainparam.exec_type)
+      mainparam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+      mainparam.secretkey = Utils.encrypt(window.GLOB.execType === 'x' ? '' : mainparam.LText, mainparam.timestamp)
+
+      if (window.GLOB.mainSystemApi) {
+        mainparam.rduri = window.GLOB.mainSystemApi
+      }
+      if (window.GLOB.mkHS) { // 浜戠鏁版嵁楠岃瘉
+        mainparam.open_key = Utils.encryptOpenKey(mainparam.secretkey, mainparam.timestamp)
+      }
+
+      deffers.push(
+        new Promise(resolve => {
+          Api.getSystemCacheConfig(mainparam).then(res => {
+            if (!res.status && res.ErrCode !== '-2') {
+              notification.warning({
+                top: 92,
+                message: res.message,
+                duration: 5
+              })
+            }
+            resolve(res)
+          })
+        })
+      )
+    }
+
+    Promise.all(deffers).then(response => {
+      let result = {...response[0], ...(response[1] || {})}
+
+      delete result.ErrCode
+      delete result.ErrMesg
+      delete result.message
+      delete result.status
+
+      this.resetSearch(result, false)
+    })
+  }
+
+  // 鏌ヨ涓嬫媺鑿滃崟
+  improveBackSearch = (mainItems, localItems, trigger, searchlist) => {
+    let deffers = []
+    
+    if (localItems.length) {
+      deffers.push({
+        $backend: true,
+        $type: 's_Get_SelectedList',
+        data: localItems
+      })
+    }
+
+    if (mainItems.length) {
+      deffers.push({
+        $backend: true,
+        $type: 's_Get_SelectedList',
+        data: mainItems,
+        rduri: window.GLOB.mainSystemApi
+      })
+    }
+
+    deffers = deffers.map(item => {
+      return new Promise(resolve => {
+        Api.getSystemCacheConfig(item).then(res => {
+          if (!res.status && res.ErrCode !== '-2') {
+            notification.warning({
+              top: 92,
+              message: res.message,
+              duration: 5
+            })
+          }
+          resolve(res)
+        })
       })
     })
+
+    Promise.all(deffers).then(response => {
+      let result = {...response[0], ...(response[1] || {})}
+
+      delete result.ErrCode
+      delete result.ErrMesg
+      delete result.message
+      delete result.status
+
+      this.resetSearch(result, trigger, searchlist)
+    })
+  }
+
+  // 娴嬭瘯绯荤粺鍗曚釜璇锋眰涓嬫媺閫夐」
+  improveSimpleSearch = (deForms, trigger, searchlist, BID) => {
+    if (deForms.length === 0) return
+
+    let deffers = deForms.map((item, index) => {
+      let param = {
+        func: 'sPC_Get_SelectedList',
+        LText: item.data_sql,
+        obj_name: item.field,
+        arr_field: item.arr_field
+      }
+
+      if (BID) {
+        param.BID = BID
+      }
+
+      if (window.GLOB.execType === 'x') {
+        param.exec_type = 'x'
+      }
+
+      param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+      param.secretkey = Utils.encrypt(window.GLOB.execType === 'x' ? '' : param.LText, param.timestamp)
+
+      if (item.database === 'sso' && window.GLOB.mainSystemApi) {
+        param.rduri = window.GLOB.mainSystemApi
+      }
+
+      return (
+        new Promise(resolve => {
+          setTimeout(() => {
+            Api.getSystemCacheConfig(param).then(res => {
+              if (!res.status && res.ErrCode !== '-2') {
+                notification.warning({
+                  top: 92,
+                  message: res.message,
+                  duration: 5
+                })
+              }
+              resolve(res)
+            })
+          }, index * 30)
+        })
+      )
+    })
+
+    Promise.all(deffers).then(response => {
+      let result = {}
+
+      response.forEach(res => {
+        result = {...result, ...res}
+      })
+
+      delete result.ErrCode
+      delete result.ErrMesg
+      delete result.message
+      delete result.status
+
+      this.resetSearch(result, trigger, searchlist)
+    })
+  }
+
+  resetSearch = (result, submit, searchlist) => {
+    let trigger = submit
+    let _searchlist = fromJS(searchlist || this.state.searchlist).toJS().map(item => {
+      if (['select', 'link', 'multiselect', 'checkcard', 'radio'].includes(item.type) && result[item.field] && result[item.field].length > 0) {
+        let options = []
+        let map = new Map()
+        let all = false
+        result[item.field].forEach(cell => {
+          let _item = {
+            key: Utils.getuuid(),
+            ParentID: ''
+          }
+
+          if (item.linkField) {
+            _item.ParentID = cell[item.linkField] + ''
+          }
+
+          if (item.type !== 'checkcard') {
+            _item.Value = cell[item.valueField] + ''
+            _item.Text = cell[item.valueText] + ''
+            
+            if (map.has(_item.ParentID + _item.Value)) return
+            if (!_item.Text) {
+              if (!all) {
+                _item.Text = '鍏ㄩ儴'
+                all = true
+              } else {
+                return
+              }
+            }
+            
+            map.set(_item.ParentID + _item.Value, 0)
+          } else {
+            _item.$value = cell[item.cardValField] + ''
+            _item = {..._item, ...cell}
+
+            if (item.urlField) {
+              _item.$url = cell[item.urlField] || ''
+            } else if (item.colorField) {
+              _item.$color = cell[item.colorField] || ''
+            }
+
+            if (map.has(_item.ParentID + _item.$value)) return
+            
+            map.set(_item.ParentID + _item.$value, 0)
+          }
+
+          options.push(_item)
+        })
+
+        item.oriOptions = [...item.oriOptions, ...options]
+
+        if (item.type === 'checkcard' && item.multiple === 'dropdown') {
+          this.resetCheckcard(item)
+        }
+      }
+
+      if (item.linkField) {
+        if (item.supInitVal) {
+          item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal || option.Value === '')
+        } else {
+          item.options = item.oriOptions
+        }
+      } else if (item.oriOptions) {
+        item.options = item.oriOptions
+      }
+
+      if (item.$first) {
+        if (item.options.length > 0) {
+          item.initval = item.options[0].Value
+          trigger = true
+        } else {
+          item.initval = ''
+        }
+      }
+
+      return item
+    })
+
+    this.setState({
+      searchlist: _searchlist
+    })
+    
+    if (trigger) {
+      setTimeout(() => {
+        this.handleSubmit()
+      }, 20)
+    }
+  }
+
+  recordChange = (val, defer, item) => {
+    this.record[item.field] = val
+
+    if (defer) return
+
+    if (item.linkFields) {
+      setTimeout(() => {
+        this.handleSubmit()
+      }, 1000)
+    } else {
+      setTimeout(() => {
+        this.handleSubmit()
+      }, 10)
+    }
+  }
+
+  dateGroupChange = (val, type, item) => {
+    this.record[item.datefield] = val
+    this.record[item.field] = type
+
+    this.handleSubmit()
+  }
+
+  cardChange = (val, item) => {
+    this.record[item.field] = val
+
+    if (!item.linkFields) {
+      setTimeout(() => {
+        this.handleSubmit()
+      }, 10)
+    }
   }
 
   getFields() {
     const { getFieldDecorator } = this.props.form
+    const { visible, setting } = this.state
     const fields = []
 
     this.state.searchlist.forEach((item, index) => {
-      if (item.hidden) return
+      if (item.hidden || (item.advanced && (setting.advanceType !== 'pulldown' || !visible))) return
 
-      if (item.type === 'text') { // 鏂囨湰鎼滅储
-        fields.push(
-          <Col span={item.ratio || 6} key={index}>
-            <Form.Item label={item.label}>
-              {getFieldDecorator(item.field, {
-                initialValue: item.initval,
-                rules: [
-                  {
-                    required: item.required === 'true',
-                    message: this.props.dict['form.required.input'] + item.label + '!'
-                  }
-                ]
-              })(<Input placeholder="" autoComplete="off" />)}
-            </Form.Item>
-          </Col>
-        )
-      } else if (item.type === 'select') { // 涓嬫媺鎼滅储
-        fields.push(
-          <Col span={item.ratio || 6} key={index}>
-            <Form.Item label={item.label}>
-              {getFieldDecorator(item.field, {
-                initialValue: item.initval,
-                rules: [
-                  {
-                    required: item.required === 'true',
-                    message: this.props.dict['form.required.select'] + item.label + '!'
-                  }
-                ]
-              })(
-                <Select
-                  showSearch
-                  onChange={(value) => {this.selectChange(item, value)}}
-                  filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
-                  getPopupContainer={() => document.getElementById(this.state.formId)}
-                >
-                  {item.options.map((option, i) =>
-                    <Select.Option id={`${i}`} title={option.Text} key={`${i}`} value={option.Value}>{option.Text}</Select.Option>
-                  )}
-                </Select>
-              )}
-            </Form.Item>
-          </Col>
-        )
-      } else if (item.type === 'multiselect') { // 涓嬫媺澶氶��
-        let _initval = item.initval ? item.initval.split(',').filter(Boolean) : []
-        fields.push(
-          <Col span={item.ratio || 6} key={index}>
-            <Form.Item label={item.label}>
-              {getFieldDecorator(item.field, {
-                initialValue: _initval,
-                rules: [
-                  {
-                    required: item.required === 'true',
-                    message: this.props.dict['form.required.select'] + item.label + '!'
-                  }
-                ]
-              })(
-                <Select
-                  showSearch
-                  mode="multiple"
-                  filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
-                  getPopupContainer={() => document.getElementById(this.state.formId)}
-                >
-                  {item.options.map((option, i) =>
-                    <Select.Option id={`${i}`} title={option.Text} key={`${i}`} value={option.Value}>{option.Text}</Select.Option>
-                  )}
-                </Select>
-              )}
-            </Form.Item>
-          </Col>
-        )
-      } else if (item.type === 'date') { // 鏃堕棿鎼滅储
-        fields.push(
-          <Col span={item.ratio || 6} key={index}>
-            <Form.Item label={item.label}>
-              {getFieldDecorator(item.field, {
-                initialValue: item.initval ? moment().subtract(item.initval, 'days') : null,
-                rules: [
-                  {
-                    required: item.required === 'true',
-                    message: this.props.dict['form.required.select'] + item.label + '!'
-                  }
-                ]
-              })(
-                <DatePicker onChange={this.searchChange} getCalendarContainer={() => document.getElementById(this.state.formId)} />
-              )}
-            </Form.Item>
-          </Col>
-        )
-      } else if (item.type === 'datemonth') {
-        fields.push(
-          <Col span={item.ratio || 6} key={index}>
-            <Form.Item label={item.label}>
-              {getFieldDecorator(item.field, {
-                initialValue: item.initval ? moment().subtract(item.initval, 'month') : null,
-                rules: [
-                  {
-                    required: item.required === 'true',
-                    message: this.props.dict['form.required.select'] + item.label + '!'
-                  }
-                ]
-              })(
-                <MonthPicker onChange={this.searchChange} getCalendarContainer={() => document.getElementById(this.state.formId)} />
-              )}
-            </Form.Item>
-          </Col>
-        )
-      } else if (item.type === 'dateweek') {
-        fields.push(
-          <Col span={item.ratio || 6} key={index}>
-            <Form.Item label={item.label}>
-              {getFieldDecorator(item.field, {
-                initialValue: item.initval ? moment().subtract(item.initval * 7, 'days') : null,
-                rules: [
-                  {
-                    required: item.required === 'true',
-                    message: this.props.dict['form.required.select'] + item.label + '!'
-                  }
-                ]
-              })(
-                <WeekPicker onChange={this.searchChange} getCalendarContainer={() => document.getElementById(this.state.formId)} />
-              )}
-            </Form.Item>
-          </Col>
-        )
-      } else if (item.type === 'daterange') {
-        let _defaultValue = [null, null]
-
-        if (item.initval) {
-          try {
-            let _initval = JSON.parse(item.initval)
-            _defaultValue = [moment().subtract(_initval[0], 'days'), moment().subtract(_initval[1], 'days')]
-          } catch {
-            _defaultValue = [null, null]
-          }
+      const _rules = [
+        {
+          required: item.required,
+          message: item.label + (window.GLOB.dict['not_empty'] || '涓嶅彲涓虹┖锛�')
         }
+      ]
 
+      let content = null
+      let field = item.field
+
+      if (item.type === 'text') {
+        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') {
+        content = (<MKDatePicker config={item} onChange={(val, defer) => this.recordChange(val, defer, item)} />)
+      } else if (item.type === 'group') {
+        field = item.datefield
+        content = <DateGroup position={index} config={item} onChange={(val, type) => this.dateGroupChange(val, type, item)} />
+      } else if (item.type === 'checkcard') {
+        content = <MKCheckCard config={item} onChange={(val) => this.cardChange(val, item)} />
+      } else if (item.type === 'radio') {
+        content = <MKRadio config={item} onChange={(val) => this.recordChange(val, false, item)} />
+      } else if (item.type === 'check') {
+        content = <MKCheck config={item} onChange={(val) => this.recordChange(val, false, item)} />
+      } else if (item.type === 'switch') {
+        content = <MKSwitch config={item} onChange={(val) => this.recordChange(val, false, item)} />
+      } else if (item.type === 'range') {
+        content = <MKNumber config={item} onInputSubmit={this.handleSubmit} />
+      }
+
+      if (content) {
         fields.push(
-          <Col className="daterange" span={item.ratio || 6} key={index}>
-            <Form.Item label={item.label}>
-              {getFieldDecorator(item.field,
-                {
-                  initialValue: _defaultValue,
-                  rules: [
-                    {
-                      required: item.required === 'true',
-                      message: this.props.dict['form.required.select'] + item.label + '!'
-                    }
-                  ]
-                })(
-                <RangePicker
-                  placeholder={['寮�濮嬫棩鏈�', '缁撴潫鏃ユ湡']}
-                  renderExtraFooter={() => 'extra footer'}
-                  onChange={this.searchChange}
-                  getCalendarContainer={() => document.getElementById(this.state.formId)}
-                />
-              )}
+          <Col className="mk-search-col" span={item.ratio || 6} key={index}>
+            <Form.Item
+              label={item.labelShow !== 'false' ? item.label : ''}
+              labelCol={item.labelCol}
+              wrapperCol={item.wrapperCol}
+            >
+              {getFieldDecorator(field, {
+                initialValue: item.initval,
+                rules: _rules
+              })(content)}
             </Form.Item>
           </Col>
         )
       }
     })
 
-    fields.push(
-      <Col span={6} style={{ whiteSpace: 'nowrap' }} key="actions">
-        <Form.Item label={' '} colon={false} style={{ minHeight: '40px' }}>
-          <Button type="primary" htmlType="submit">
-            {this.props.dict['main.search']}
-          </Button>
-          <Button style={{ marginLeft: 8 }} onClick={this.handleReset}>
-            {this.props.dict['main.reset']}
-          </Button>
-        </Form.Item>
-      </Col>
-    )
+    if (setting.show || setting.showAdv) {
+      let style = {}
+      if (setting.borderRadius) {
+        style.borderRadius = setting.borderRadius
+      }
+
+      fields.push(
+        <Col span={setting.ratio} style={{ whiteSpace: 'nowrap' }} className="mk-search-col search-button" key="actions">
+          <Form.Item
+            label={' '}
+            colon={false}
+            labelCol={setting.labelCol}
+            wrapperCol={setting.wrapperCol}
+          >
+            {setting.show ? <Button style={style} type="primary" onClick={this.handleSubmit}>
+              {window.GLOB.dict['search'] || '鎼滅储'}
+            </Button> : null}
+            {setting.show ? <Button style={{ marginLeft: 8, ...style }} onClick={this.handleReset}>
+              {window.GLOB.dict['reset'] || '閲嶇疆'}
+            </Button> : null}
+            {setting.showAdv ? <Button className={visible ? 'visible' : ''} type="link" onClick={this.handleAdvance}>
+              {window.GLOB.dict['senior'] || '楂樼骇'}{setting.advanceType === 'pulldown' ? <DownOutlined /> : null}
+            </Button> : null}
+          </Form.Item>
+        </Col>
+      )
+    } else if (setting.showBtn) {
+      fields.push(
+        <Col className="mk-search-col search-button" key="actions">
+          <Form.Item>
+            <Button type="primary" onClick={this.handleSubmit}>
+              {window.GLOB.dict['search'] || '鎼滅储'}
+            </Button>
+          </Form.Item>
+        </Col>
+      )
+    }
     
     return fields
   }
 
-  handleSearch = (e) => {
-    // 鍥炶溅鎴栫偣鍑绘悳绱�
-    e.preventDefault()
-    this.props.form.validateFields((err, values) => {
-      let searches = this.getFieldsValues(values)
-      this.props.refreshdata(searches)
-    })
+  handleAdvance = () => {
+    const { setting, visible } = this.state
+
+    if (setting.advanceType !== 'pulldown' && visible) {
+      return
+    }
+
+    this.setState({visible: !visible})
+
+    if (setting.advanceType === 'pulldown') {
+      if (visible) {
+        let advanceValues = []
+        this.state.searchlist.forEach(item => {
+          if (!item.signValue) return
+    
+          let val = this.record[item.field]
+          if (val || val === 0) {
+            if (item.precision === 'hour') {
+              if (/,/ig.test(val)) {
+                val = val.split(',').map(m => m + ':00').join(',')
+              } else {
+                val = val + ':00'
+              }
+            }
+
+            let text = val
+
+            if (item.type === 'select' || item.type === 'link' || item.type === 'radio') {
+              item.oriOptions.forEach(cell => {
+                if (cell.Value === val) {
+                  text = cell.Text
+                }
+              })
+            }
+
+            advanceValues.push({field: item.field, type: item.type, label: item.label, value: val, text})
+          }
+        })
+        this.setState({advanceValues})
+      } else {
+        let list = this.state.searchlist.map(item => {
+          if (!item.advanced) return item
+    
+          item.initval = this.record[item.field]
+          
+          return item
+        })
+        this.setState({searchlist: list})
+      }
+    }
   }
 
-  searchChange = () => {
+  handleSubmit = () => {
+    const { config } = this.props
+
     this.setState({}, () => {
       this.props.form.validateFields((err, values) => {
-        let searches = this.getFieldsValues(values)
-        this.props.refreshdata(searches)
+        if (err) return
+
+        let { searches, error } = this.getFieldsValues(values)
+  
+        if (error) {
+          notification.warning({
+            top: 92,
+            message: error,
+            duration: 3
+          })
+          return
+        } else if (this.state.hasReqFields) {
+          let requireFields = searches.filter(item => item.required && item.value === '')
+          if (requireFields.length > 0) {
+            let labels = requireFields.map(item => item.label)
+            labels = Array.from(new Set(labels))
+      
+            notification.warning({
+              top: 92,
+              message: (window.GLOB.dict['input_tip'] || '璇疯緭鍏�') + labels.join('銆�') + ' !',
+              duration: 3
+            })
+            return
+          }
+        }
+
+        let sign = md5(JSON.stringify(searches))
+
+        if (sign === this.sign) return
+
+        this.sign = sign
+        setTimeout(() => {
+          this.sign = ''
+        }, 2000)
+        
+        if (config.wrap && config.wrap.cacheSearch === 'true') {
+          let _values = {}
+          searches.forEach(item => {
+            _values[item.key] = item.value
+          })
+  
+          window.GLOB.SearchBox.set(config.$searchId + 'cache', _values)
+        }
+
+        if (this.props.refreshdata) {
+          this.props.refreshdata(searches)
+        } else {
+          window.GLOB.SearchBox.set(config.$searchId, searches)
+          MKEmitter.emit('searchRefresh', config.$searchId)
+        }
       })
     })
   }
 
+  /**
+   * @description 鎼滅储鏉′欢閲嶇疆
+   */
   handleReset = () => {
-    // 閲嶇疆
-    this.props.form.resetFields()
-    this.props.form.validateFields((err, values) => {
-      let searches = this.getFieldsValues(values)
-      this.props.refreshdata(searches)
-    })
-  }
+    const { setting } = this.state
 
-  getFieldsValues = (values) => {
-    // 鑾峰彇鎼滅储鏉′欢鍊�
-    let search = []
-    Object.keys(values).forEach(key => {
-      let _value = ''
-      if (this.state.style[key] === 'daterange') {
-        if (values[key].length > 0) {
-          _value = [moment(values[key][0]).format('YYYY-MM-DD'), moment(values[key][1]).format('YYYY-MM-DD')]
-        }
-      } else if (this.state.style[key] === 'dateweek') {
-        if (values[key]) {
-          _value = [moment(values[key]).startOf('week').format('YYYY-MM-DD'), moment(values[key]).endOf('week').format('YYYY-MM-DD')]
-        }
-      } else if (this.state.style[key] === 'date') {
-        if (values[key]) {
-          _value = moment(values[key]).format('YYYY-MM-DD')
-        }
-      } else if (this.state.style[key] === 'datemonth') {
-        if (values[key]) {
-          _value = moment(values[key]).format('YYYY-MM')
-        }
-      } else if (this.state.style[key] === 'multiselect') {
-        _value = values[key]
+    if (setting.resetContrl === 'refresh') {
+      MKEmitter.emit('reloadMenuView', setting.$pageId, true)
+      return
+    }
 
-      } else {
-        _value = values[key].replace(/(^\s*|\s*$)/ig, '')
+    let record = {}
+    let advanceValues = []
+    let searchlist = this.state.searchlist.map(item => {
+      item.initval = item.oriInitval
 
+      if (setting.resetContrl === 'clear' && ['text', 'date', 'datemonth', 'dateweek', 'daterange', 'range'].includes(item.type)) {
+        item.initval = ''
       }
 
-      search.push({
-        type: this.state.style[key],
-        key: key.replace(/@tail@$/, ''),
-        value: _value,
-        label: this.state.label[key],
-        match: this.state.match[key],
-        required: this.state.required[key]
+      if (item.type === 'group') {
+        record[item.datefield] = item.initval
+        record[item.field] = item.initType
+      } else {
+        record[item.field] = item.initval
+      }
+      if (item.signValue && item.initval) {
+        let val = item.initval
+        if (item.precision === 'hour') {
+          if (/,/ig.test(val)) {
+            val = val.split(',').map(m => m + ':00').join(',')
+          } else {
+            val = val + ':00'
+          }
+        }
+
+        let text = val
+
+        if (item.type === 'select' || item.type === 'link' || item.type === 'radio') {
+          item.oriOptions.forEach(cell => {
+            if (cell.Value === val) {
+              text = cell.Text
+            }
+          })
+        }
+
+        advanceValues.push({field: item.field, type: item.type, label: item.label, value: val, text})
+      }
+
+      return item
+    })
+
+    this.record = record
+
+    this.setState({searchlist: [], advanceValues}, () => {
+      this.setState({searchlist}, () => {
+        this.handleSubmit()
       })
     })
-    return search
+  }
+
+  getFieldsValues = (vals) => {
+    const { searchlist } = this.state
+    let values = {...this.record, ...vals}
+    this.record = values
+
+    // 鑾峰彇鎼滅储鏉′欢鍊�
+    let search = []
+    let error = null
+    searchlist.forEach(item => {
+      if (item.type === 'group') {
+        search.push({
+          type: 'daterange',
+          key: item.datefield,
+          value: values[item.datefield] || '',
+          label: item.label,
+          match: 'between',
+          required: item.required,
+          precision: 'day',
+          forbid: item.$forbid
+        }, {
+          type: 'group',
+          key: item.field,
+          value: values[item.field] || '',
+          label: item.label,
+          match: '=',
+          forbid: true,
+          required: item.required
+        })
+      } else {
+        let type = item.type
+        let val = values[item.field] !== undefined ? values[item.field] : ''
+
+        if (type === 'multiselect' || (type === 'checkcard' && item.multiple === 'true')) {
+          type = 'multi'
+        } else if (type === 'text' && !error) {
+          if (/'/ig.test(val)) {
+            error = `鎼滅储鏉′欢${item.label}涓紝涓嶅彲浣跨敤鑻辨枃鐘舵�佺殑鍗曞紩鍙枫�俙
+          } else if (/--/ig.test(val)) {
+            error = `鎼滅储鏉′欢${item.label}涓紝涓嶅彲浣跨敤 -- 銆俙
+          } else if (/(^|\s)select\s/ig.test(val)) {
+            error = `鎼滅储鏉′欢${item.label}涓紝涓嶅彲浣跨敤鍏抽敭瀛梥elect銆俙
+          } else if (/\sfrom(\s|\()/ig.test(val)) {
+            error = `鎼滅储鏉′欢${item.label}涓紝涓嶅彲浣跨敤鍏抽敭瀛梖rom銆俙
+          } else if (/(^|\s)insert\s/ig.test(val)) {
+            error = `鎼滅储鏉′欢${item.label}涓紝涓嶅彲浣跨敤鍏抽敭瀛梚nsert銆俙
+          } else if (/(^|\s)delete\s/ig.test(val)) {
+            error = `鎼滅储鏉′欢${item.label}涓紝涓嶅彲浣跨敤鍏抽敭瀛梔elete銆俙
+          } else if (/(^|\s)update\s/ig.test(val)) {
+            error = `鎼滅储鏉′欢${item.label}涓紝涓嶅彲浣跨敤鍏抽敭瀛梪pdate銆俙
+          } else if (/(^|\s)where\s/ig.test(val)) {
+            error = `鎼滅储鏉′欢${item.label}涓紝涓嶅彲浣跨敤鍏抽敭瀛梬here銆俙
+          } else if (/(^|\s)drop\s/ig.test(val)) {
+            error = `鎼滅储鏉′欢${item.label}涓紝涓嶅彲浣跨敤鍏抽敭瀛梔rop銆俙
+          } else if (/(^|\s)exec\s/ig.test(val)) {
+            error = `鎼滅储鏉′欢${item.label}涓紝涓嶅彲浣跨敤鍏抽敭瀛梕xec銆俙
+          } else if (/(^|\s)truncate\s/ig.test(val)) {
+            error = `鎼滅储鏉′欢${item.label}涓紝涓嶅彲浣跨敤鍏抽敭瀛梩runcate銆俙
+          } else if (/(^|\s)while\s/ig.test(val)) {
+            error = `鎼滅储鏉′欢${item.label}涓紝涓嶅彲浣跨敤鍏抽敭瀛梬hile銆俙
+          } else if (/(^|\s)for\s/ig.test(val)) {
+            error = `鎼滅储鏉′欢${item.label}涓紝涓嶅彲浣跨敤鍏抽敭瀛梖or銆俙
+          }
+        }
+
+        if (typeof(val) === 'string') {
+          val = val.replace(/(^\s+|\s+$)/ig, '').replace(/\t+|\v+/g, '')
+        }
+
+        search.push({
+          type: type,
+          key: item.field.replace(/@tail@$/, ''),
+          value: val,
+          label: item.label,
+          match: item.match,
+          required: item.required,
+          precision: item.precision || 'day',
+          forbid: item.$forbid
+        })
+      }
+    })
+
+    return {searches: search, error}
+  }
+
+  handleOk = (values) => {
+    this.record = {...this.record, ...values}
+
+    let advanceValues = []
+    this.state.searchlist.forEach(item => {
+      if (!item.signValue) return
+
+      let val = this.record[item.field]
+      if (val || val === 0) {
+        if (item.precision === 'hour') {
+          if (/,/ig.test(val)) {
+            val = val.split(',').map(m => m + ':00').join(',')
+          } else {
+            val = val + ':00'
+          }
+        }
+
+        let text = val
+
+        if (item.type === 'select' || item.type === 'link' || item.type === 'radio') {
+          item.oriOptions.forEach(cell => {
+            if (cell.Value === val) {
+              text = cell.Text
+            }
+          })
+        }
+
+        advanceValues.push({field: item.field, type: item.type, label: item.label, value: val, text})
+      }
+    })
+
+    this.setState({advanceValues, visible: false})
+    this.handleSubmit()
+  }
+
+  closeAdvanceForm = (cell) => {
+    this.record[cell.field] = ''
+
+    this.setState({advanceValues: this.state.advanceValues.filter(item => item.field !== cell.field)})
+    this.handleSubmit()
   }
 
   render() {
+    const { visible, searchlist, advanceValues, setting } = this.state
     const formItemLayout = {
       labelCol: {
         xs: { span: 24 },
@@ -438,9 +1265,57 @@
     }
 
     return (
-      <Form {...formItemLayout} className="ant-advanced-search-form top-search" id={this.state.formId} onSubmit={this.handleSearch}>
-        <Row gutter={24}>{this.getFields()}</Row>
-      </Form>
+      <>
+        <Form {...formItemLayout} className={`mk-search-wrap mk-float-${setting.float} mk-order-${setting.order || 'none'}`} style={setting.style}>
+          <Row gutter={24}>{this.getFields()}</Row>
+          {advanceValues.length && (setting.advanceType !== 'pulldown' || (setting.advanceType === 'pulldown' && !visible)) ? <Row gutter={24}>
+            <div className="advanced-list">
+              {advanceValues.map((item, index) => {
+                return (
+                  <div key={index}>
+                    <span>{item.label}: </span>
+                    <span className="advance-value">{item.text}</span>
+                    <CloseOutlined onClick={() => this.closeAdvanceForm(item)} />
+                  </div>)
+              })}
+            </div>
+          </Row> : null}
+        </Form>
+        {setting.advanceType === 'modal' ? <Modal
+          title={window.GLOB.dict['adv_search'] || '楂樼骇鎼滅储'}
+          maskClosable={false}
+          visible={visible}
+          width={setting.advWidth}
+          closable={false}
+          footer={null}
+          destroyOnClose
+        >
+          <MutilForm
+            searchlist={searchlist}
+            record={this.record}
+            advanceSubmit={this.handleOk}
+            handleClose={() => this.setState({visible: false})}
+          />
+        </Modal> : null}
+        {setting.advanceType === 'drawer' ? <Drawer
+          title={window.GLOB.dict['adv_search'] || '楂樼骇鎼滅储'}
+          className="mk-search-drawer"
+          width={setting.advWidth}
+          height={setting.advHeight}
+          maskClosable={false}
+          onClose={() => this.setState({visible: false})}
+          visible={visible}
+          placement={setting.placement}
+          destroyOnClose
+        >
+          <MutilForm
+            searchlist={searchlist}
+            record={this.record}
+            advanceSubmit={this.handleOk}
+            handleClose={() => this.setState({visible: false})}
+          />
+        </Drawer> : null}
+      </>
     )
   }
 }

--
Gitblit v1.8.0