From 46f79b491173d284a4900d19e7aecf7509481438 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 21 一月 2022 17:21:25 +0800
Subject: [PATCH] 2022-01-21

---
 src/tabviews/custom/components/card/data-card/index.jsx |  155 ++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 127 insertions(+), 28 deletions(-)

diff --git a/src/tabviews/custom/components/card/data-card/index.jsx b/src/tabviews/custom/components/card/data-card/index.jsx
index 5b91693..704b8bc 100644
--- a/src/tabviews/custom/components/card/data-card/index.jsx
+++ b/src/tabviews/custom/components/card/data-card/index.jsx
@@ -41,7 +41,9 @@
     total: null,
     precards: [],
     nextcards: [],
-    selected: 'false'
+    selected: 'false',
+    supNodes: [],
+    supComs: null
   }
 
   UNSAFE_componentWillMount () {
@@ -51,6 +53,14 @@
     let _card = null
     let precards = []
     let nextcards = []
+
+    if (_config.wrap.controlField) {
+      if (_config.wrap.controlVal) {
+        _config.wrap.controlVal = _config.wrap.controlVal.split(',')
+      } else {
+        _config.wrap.controlVal = ['']
+      }
+    }
 
     _config.subcards.forEach(item => {
       if (item.setting.click === 'button' && !item.setting.linkbtn) {
@@ -114,6 +124,12 @@
         item.$$BID = BID || ''
         item.$$BData = BData || ''
         item.$Index = index + 1 + ''
+
+        if (_config.wrap.controlField) {
+          if (_config.wrap.controlVal.includes(item[_config.wrap.controlField])) {
+            item.$disabled = true
+          }
+        }
         return item
       })
 
@@ -144,7 +160,18 @@
       return item
     })
 
+    let supComs = null
+    if (_config.wrap.supType === 'multi') {
+      supComs = _config.supNodes.map(item => item.componentId)
+    }
+
+    _config.wrap.selStyle = _config.wrap.selStyle || 'active'
+    _config.wrap.scale = _config.wrap.scale === 'true' ? 'scale' : ''
+
+    _config.wrap.wrapClass =  `${_config.wrap.selStyle} ${_config.wrap.cardType || ''} ${_config.wrap.scale}`
+
     this.setState({
+      supComs,
       selected,
       precards,
       nextcards,
@@ -188,6 +215,13 @@
           item.$$BID = BID || ''
           item.$$BData = BData || ''
           item.$Index = index + 1 + ''
+
+          if (config.wrap.controlField) {
+            if (config.wrap.controlVal.includes(item[config.wrap.controlField])) {
+              item.$disabled = true
+            }
+          }
+
           return item
         })
 
@@ -227,7 +261,7 @@
    * @param {*} btn        // 鎵ц鐨勬寜閽�
    */
   refreshByButtonResult = (menuId, position, btn, id, lines) => {
-    const { config, BID } = this.state
+    const { config, BID, supComs, supNodes } = this.state
 
     if (config.uuid !== menuId) return
 
@@ -243,22 +277,45 @@
       this.loadData()
     }
 
-    if (btn.syncComponentId && btn.syncComponentId !== config.uuid && btn.syncComponentId !== config.setting.supModule) {
-      MKEmitter.emit('reloadData', btn.syncComponentId)                        // 鍚岀骇鏍囩鍒锋柊
-    }
 
-    if (position === 'mainline' && config.setting.supModule) {                 // 涓昏〃琛屽埛鏂�
-      MKEmitter.emit('reloadData', config.setting.supModule, (BID || 'empty'))
-    } else if (position === 'popclose') {                                      // 鏍囩鍏抽棴鍒锋柊
-      config.setting.supModule && MKEmitter.emit('reloadData', config.setting.supModule, (BID || 'empty'))
-      btn.$tabId && MKEmitter.emit('refreshPopButton', btn.$tabId)
+    if (supComs) {
+      if (btn.syncComponentId && btn.syncComponentId !== config.uuid && !supComs.includes(btn.syncComponentId)) {
+        MKEmitter.emit('reloadData', btn.syncComponentId)                        // 鍚岀骇鏍囩鍒锋柊
+      }
+  
+      if (position === 'mainline' || position === 'popclose') {                 // 涓昏〃琛屽埛鏂�
+        let supNode = supNodes[supNodes.length - 1]
+        supComs.forEach((item, i) => {
+          setTimeout(() => {
+            if (supNode && supNode.key === item) {
+              MKEmitter.emit('reloadData', item, supNode.value)
+            } else {
+              MKEmitter.emit('reloadData', item)
+            }
+          }, i * 10)
+        })
+        if (position === 'popclose') {                                      // 鏍囩鍏抽棴鍒锋柊
+          btn.$tabId && MKEmitter.emit('refreshPopButton', btn.$tabId)
+        }
+      }
+    } else {
+      if (btn.syncComponentId && btn.syncComponentId !== config.uuid && btn.syncComponentId !== config.setting.supModule) {
+        MKEmitter.emit('reloadData', btn.syncComponentId)                        // 鍚岀骇鏍囩鍒锋柊
+      }
+  
+      if (position === 'mainline' && config.setting.supModule) {                 // 涓昏〃琛屽埛鏂�
+        MKEmitter.emit('reloadData', config.setting.supModule, (BID || 'empty'))
+      } else if (position === 'popclose') {                                      // 鏍囩鍏抽棴鍒锋柊
+        config.setting.supModule && MKEmitter.emit('reloadData', config.setting.supModule, (BID || 'empty'))
+        btn.$tabId && MKEmitter.emit('refreshPopButton', btn.$tabId)
+      }
     }
   }
 
   checkTopLine = () => {
     const { config, data } = this.state
 
-    if (!data || data.length === 0) {
+    if (!data || data.length === 0 || data[0].$disabled) {
       this.setState({
         activeKey: '',
         selectKeys: [],
@@ -327,13 +384,34 @@
   }
 
   resetParentParam = (MenuID, id, data) => {
-    const { config } = this.state
+    const { config, supComs } = this.state
 
-    if (!config.setting.supModule || config.setting.supModule !== MenuID) return
-    if (id !== this.state.BID || id !== '') {
-      this.setState({ BID: id, BData: data, pageIndex: 1 }, () => {
-        this.loadData()
-      })
+    if (supComs) {
+      if (!supComs.includes(MenuID)) return
+      let supNodes = this.state.supNodes.filter(item => item.key !== MenuID)
+      let bid = ''
+      let _data = null
+
+      if (id) {
+        supNodes.push({key: MenuID, value: id, data})
+      }
+      if (supNodes.length > 0) {
+        bid = supNodes[supNodes.length - 1].value
+        _data = supNodes[supNodes.length - 1].data
+      }
+
+      if (bid !== this.state.BID || bid !== '') {
+        this.setState({ BID: bid, BData: _data, pageIndex: 1 }, () => {
+          this.loadData()
+        })
+      }
+    } else {
+      if (!config.setting.supModule || config.setting.supModule !== MenuID) return
+      if (id !== this.state.BID || id !== '') {
+        this.setState({ BID: id, BData: data, pageIndex: 1 }, () => {
+          this.loadData()
+        })
+      }
     }
   }
 
@@ -368,7 +446,7 @@
     const { mainSearch, menuType } = this.props
     const { config, arr_field, pageIndex, search, BID, BData, selected } = this.state
 
-    if (config.setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇�
+    if (config.setting.supModule && !BID && config.wrap.supKey !== 'false') { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇�
       this.setState({
         activeKey: '',
         selectKeys: [],
@@ -448,6 +526,13 @@
           item.$$BID = BID || ''
           item.$$BData = BData || ''
           item.$Index = index + start + ''
+
+          if (config.wrap.controlField) {
+            if (config.wrap.controlVal.includes(item[config.wrap.controlField])) {
+              item.$disabled = true
+            }
+          }
+          
           return item
         }),
         total: result.total,
@@ -575,6 +660,7 @@
     const { config, selectKeys, selectedData, activeKey, data } = this.state
 
     if (!config.wrap.cardType) return
+    if (item.$disabled) return
     
     let _selectKeys = []
     let _selectedData = []
@@ -585,12 +671,12 @@
         _selectKeys = selectKeys.filter(key => key !== index)
         _selectedData = selectedData.filter(cell => cell.key !== index)
         _activeKey = _selectKeys.slice(-1)[0]
-        _item = selectedData.slice(-1)[0] || ''
+        _item = _selectedData.slice(-1)[0] || ''
       } else if (selectKeys.indexOf(index) > -1) {
         _selectKeys = selectKeys.filter(key => key !== index)
         _selectedData = selectedData.filter(cell => cell.key !== index)
         _activeKey = activeKey
-        _item = selectedData.filter(cell => cell.key === activeKey)[0] || ''
+        _item = _selectedData.filter(cell => cell.key === activeKey)[0] || ''
       } else {
         _selectKeys = [...selectKeys, index]
         _selectedData = [...selectedData, item]
@@ -617,6 +703,8 @@
 
   render() {
     const { config, precards, nextcards, loading, data, pageIndex, total, card, activeKey, BID, BData, selectedData, selectKeys } = this.state
+
+    if (config.wrap.empty === 'hidden' && (!data || data.length === 0)) return null
 
     let _total = 0
     let switchable = false
@@ -655,23 +743,34 @@
             selectedData={selectedData}
           /> : null
         }
-        <div className={`data-zoom ${config.wrap.cardType || ''} ${config.wrap.scale || ''}`}>
+        <div className={`data-zoom ${config.wrap.wrapClass}`}>
           {switchable ? <div className={'prev-page ' + (pageIndex === 1 ? 'disabled' : '')} onClick={this.prevPage}><div><div><img src={preImg} alt=""/></div></div></div> : null}
           <Row className="card-row-list">
             {offset ? <Col span={offset} style={{height: '10px'}}> </Col> : null}
             {precards.map((item, index) => (
               <Col key={'pre' + index} className="extend-card" span={item.setting.width || 6}>
-                <CardItem card={item} cards={config} data={{$$BID: BID, $$BData: BData, $$type: 'extendCard'}}/>
+                <CardItem card={item} cards={config} data={{$$BID: BID, $$BData: BData, $$selectedData: selectedData, $$type: 'extendCard'}}/>
               </Col>
             ))}
-            {data && data.map((item, index) => (
-              <Col className={(activeKey === index ? ' active' : (selectKeys.indexOf(index) > -1 ? ' selected' : '')) + (card.setting.click ? ' pointer' : '')} key={index} span={card.setting.width} onClick={() => {this.changeCard(index, item)}}>
-                <CardItem card={card} cards={config} data={item}/>
-              </Col>
-            ))}
+            {data && data.map((item, index) => {
+              let className = card.setting.click ? 'mk-card pointer ' : 'mk-card '
+              if (item.$disabled) {
+                className = 'mk-disabled'
+              } else if (activeKey === index) {
+                className += 'active'
+              } else if (selectKeys.indexOf(index) > -1) {
+                className += 'selected'
+              }
+
+              return (
+                <Col className={className} key={index} span={card.setting.width} onClick={() => {this.changeCard(index, item)}}>
+                  <CardItem card={card} cards={config} data={item}/>
+                </Col>
+              )
+            })}
             {nextcards.map((item, index) => (
               <Col key={'next' + index} className="extend-card" span={item.setting.width || 6}>
-                <CardItem card={item} cards={config} data={{$$BID: BID, $$BData: BData, $$type: 'extendCard'}}/>
+                <CardItem card={item} cards={config} data={{$$BID: BID, $$BData: BData, $$selectedData: selectedData, $$type: 'extendCard'}}/>
               </Col>
             ))}
           </Row>

--
Gitblit v1.8.0