From 93f67eceb286067a6ec5bbd747147f4824c1c6d2 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 13 五月 2023 22:50:54 +0800
Subject: [PATCH] 2023-05-13

---
 src/tabviews/zshare/topSearch/index.jsx |  109 +++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 78 insertions(+), 31 deletions(-)

diff --git a/src/tabviews/zshare/topSearch/index.jsx b/src/tabviews/zshare/topSearch/index.jsx
index 43ad250..2ee1aaa 100644
--- a/src/tabviews/zshare/topSearch/index.jsx
+++ b/src/tabviews/zshare/topSearch/index.jsx
@@ -4,6 +4,7 @@
 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 options from '@/store/options.js'
@@ -15,6 +16,8 @@
 
 const MutilForm = asyncSpinComponent(() => import('./advanceform'))
 const MKCheckCard = asyncComponent(() => import('@/tabviews/zshare/mutilform/mkCheckCard'))
+const MKCheck = asyncComponent(() => import('@/tabviews/zshare/mutilform/mkCheck'))
+const MKSwitch = asyncComponent(() => import('@/tabviews/zshare/mutilform/mkSwitch'))
 const MKSelect = asyncComponent(() => import('./mkSelect'))
 const DateGroup = asyncComponent(() => import('./dategroup'))
 const MKDatePicker = asyncComponent(() => import('./mkDatePicker'))
@@ -22,7 +25,6 @@
 class MainSearch extends Component {
   static propTpyes = {
     BID: PropTypes.any,          // 鐖剁骇Id锛岀敤浜庢煡璇笅鎷夐�夋嫨椤�
-    menuType: PropTypes.any,     // 鑿滃崟鏉冮檺锛屾槸鍚︿负HS
     searchlist: PropTypes.array, // 鎼滅储鏉′欢鍒楄〃
     config: PropTypes.object,    // 缁勪欢閰嶇疆淇℃伅(鑷畾涔夐〉闈�)
     setting: PropTypes.object,   // 缁勪欢閰嶇疆淇℃伅(鑷畾涔夐〉闈�)
@@ -38,9 +40,10 @@
   }
 
   record = {}
+  sign = ''
 
   UNSAFE_componentWillMount () {
-    const { config, menuType, searchlist, setting } = this.props
+    const { config, searchlist, setting } = this.props
 
     let _searchlist = []
     let fieldMap = new Map()
@@ -76,13 +79,14 @@
         _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.style = null
       
       if (config.type === 'search') {
         _setting.float = config.wrap.float || 'left'
         _setting.style = config.style
-      } else if (config.type === 'table' && (config.subtype === 'normaltable' || config.subtype === 'editable')) {
+      } else if (config.type === 'table') {
         _setting.float = 'left'
       } else {
         _setting.float = 'right'
@@ -174,8 +178,12 @@
         if (item.resourceType === '1' && item.dataSource) {
           let _option = Utils.getSelectQueryOptions(item)
 
+          if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) {
+            console.info(_option.sql)
+          }
+
           // 娴嬭瘯绯荤粺鍗曚釜璇锋眰
-          if (menuType !== 'HS' && options.sysType === 'local' && !window.GLOB.systemType) {
+          if (!window.GLOB.mkHS && options.sysType === 'local' && !window.GLOB.systemType) {
             deForms.push({
               ...item,
               arr_field: _option.field,
@@ -183,9 +191,9 @@
             })
           } else { // 鍚堝苟璇锋眰锛屽尯鍒嗘湰鍦板強绯荤粺
             if (item.database === 'sso') {
-              mainItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_option.sql))}' as LText`)
+              mainItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_option.sql.replace(/%/ig, ' mpercent ')))}' as LText`)
             } else {
-              localItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_option.sql))}' as LText`)
+              localItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_option.sql.replace(/%/ig, ' mpercent ')))}' as LText`)
             }
           }
         }
@@ -229,9 +237,9 @@
       advanceValues,
       searchlist: _list
     }, () => {
-      if (menuType !== 'HS' && options.sysType === 'local' && !window.GLOB.systemType) {
+      if (!window.GLOB.mkHS && options.sysType === 'local' && window.GLOB.systemType !== 'production') {
         this.improveSimpleSearch(deForms)
-      } else {
+      } else if (mainItems.length > 0 || localItems.length > 0) {
         this.improveSearch(mainItems, localItems)
       }
     })
@@ -239,13 +247,8 @@
 
   // 鏌ヨ涓嬫媺鑿滃崟
   improveSearch = (mainItems, localItems) => {
-    const { menuType, BID } = this.props
+    const { BID } = this.props
     let deffers = []
-
-    if (menuType !== 'HS' && window.GLOB.systemType !== 'production') {
-      localItems = [...localItems, ...mainItems]
-      mainItems = []
-    }
 
     // 鏈湴璇锋眰
     let param = {
@@ -265,7 +268,7 @@
       param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
       param.secretkey = Utils.encrypt(param.LText, param.timestamp)
 
-      if (menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉
+      if (window.GLOB.mkHS) { // 浜戠鏁版嵁楠岃瘉
         param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
       }
 
@@ -303,7 +306,7 @@
       mainparam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
       mainparam.secretkey = Utils.encrypt(mainparam.LText, mainparam.timestamp)
 
-      if (menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉
+      if (window.GLOB.mkHS) { // 浜戠鏁版嵁楠岃瘉
         mainparam.open_key = Utils.encryptOpenKey(mainparam.secretkey, mainparam.timestamp)
         if (options.cloudServiceApi) {
           mainparam.rduri = options.cloudServiceApi
@@ -361,6 +364,10 @@
       param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
       param.secretkey = Utils.encrypt(param.LText, param.timestamp)
 
+      if (item.database === 'sso' && window.GLOB.mainSystemApi) {
+        param.rduri = window.GLOB.mainSystemApi
+      }
+
       return (
         new Promise(resolve => {
           setTimeout(() => {
@@ -399,24 +406,46 @@
     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 = []
+        let map = new Map()
+        let all = false
         result[item.field].forEach(cell => {
           let _item = {
-            key: Utils.getuuid()
-          }
-
-          if (item.type !== 'checkcard') {
-            _item.Value = cell[item.valueField]
-            _item.Text = cell[item.valueText]
-            if (!_item.Text && _item.Text !== 0) {
-              return
-            }
-          } else {
-            _item.$value = cell[item.cardValField]
-            _item = {..._item, ...cell}
+            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)
@@ -505,6 +534,10 @@
         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 === '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)} />
       }
 
       if (content) {
@@ -526,6 +559,11 @@
     })
 
     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
@@ -534,10 +572,10 @@
             labelCol={setting.labelCol}
             wrapperCol={setting.wrapperCol}
           >
-            {setting.show ? <Button type="primary" onClick={this.handleSubmit}>
+            {setting.show ? <Button style={style} type="primary" onClick={this.handleSubmit}>
               鎼滅储
             </Button> : null}
-            {setting.show ? <Button style={{ marginLeft: 8 }} onClick={this.handleReset}>
+            {setting.show ? <Button style={{ marginLeft: 8, ...style }} onClick={this.handleReset}>
               閲嶇疆
             </Button> : null}
             {setting.showAdv ? <Button className={visible ? 'visible' : ''} type="link" onClick={this.handleAdvance}>
@@ -621,6 +659,15 @@
           }
         }
 
+        let sign = md5(JSON.stringify(searches))
+
+        if (sign === this.sign) return
+
+        this.sign = sign
+        setTimeout(() => {
+          this.sign = ''
+        }, 2000)
+        
         this.props.refreshdata(searches)
       })
     })
@@ -795,7 +842,7 @@
 
     return (
       <>
-        <Form {...formItemLayout} className={`top-search mk-float-${setting.float}`} style={setting.style}>
+        <Form {...formItemLayout} className={`mk-search-wrap mk-float-${setting.float}`} 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">

--
Gitblit v1.8.0