From 4453a9e63e8e176c70c432b03fd4ba3ebf00a04c Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 09 二月 2023 14:55:20 +0800
Subject: [PATCH] 2023-02-09

---
 src/tabviews/custom/components/card/data-card/index.jsx |   89 ++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 80 insertions(+), 9 deletions(-)

diff --git a/src/tabviews/custom/components/card/data-card/index.jsx b/src/tabviews/custom/components/card/data-card/index.jsx
index ec98383..edc216a 100644
--- a/src/tabviews/custom/components/card/data-card/index.jsx
+++ b/src/tabviews/custom/components/card/data-card/index.jsx
@@ -452,15 +452,29 @@
     if (config.uuid !== menuId) return
 
     if (checked) {
+      let index = ''
+      let keys = []
+      let items = []
+      let last = ''
+
+      data.forEach((item, i) => {
+        if (item.$disabled) return
+
+        items.push(item)
+        keys.push(i)
+        index = i
+        last = item
+      })
+
       this.setState({
-        activeKey: '',
-        selectKeys: data.map((item, index) => index),
-        selectedData: data
+        activeKey: index,
+        selectKeys: keys,
+        selectedData: items
       })
   
-      MKEmitter.emit('resetSelectLine', config.uuid, '', '')
-      MKEmitter.emit('syncBalconyData', config.uuid, data, data.length > 0)
-      if (data.length === 0) {
+      MKEmitter.emit('resetSelectLine', config.uuid, last ? last.$$uuid : '', last)
+      MKEmitter.emit('syncBalconyData', config.uuid, items, data.length > 0 && data.length === keys.length)
+      if (items.length === 0) {
         message.warning('鏈幏鍙栧埌鏁版嵁锛�')
       }
     } else {
@@ -472,6 +486,50 @@
   
       MKEmitter.emit('resetSelectLine', config.uuid, '', '')
       MKEmitter.emit('syncBalconyData', config.uuid, [], false)
+    }
+  }
+
+  checkAll = () => {
+    const { config, data, selectedData } = this.state
+
+    if (!data || data.length === 0) return
+    
+    if (selectedData.length === 0 || selectedData.length < data.length) {
+      let index = ''
+      let keys = []
+      let items = []
+      let last = ''
+
+      data.forEach((item, i) => {
+        if (item.$disabled) return
+
+        items.push(item)
+        keys.push(i)
+        index = i
+        last = item
+      })
+
+      this.setState({
+        activeKey: index,
+        selectKeys: keys,
+        selectedData: items
+      })
+  
+      MKEmitter.emit('resetSelectLine', config.uuid, last ? last.$$uuid : '', last)
+      if (config.setting.$hasSyncModule) {
+        MKEmitter.emit('syncBalconyData', config.uuid, items, data.length === keys.length)
+      }
+    } else {
+      this.setState({
+        activeKey: '',
+        selectKeys: [],
+        selectedData: []
+      })
+  
+      MKEmitter.emit('resetSelectLine', config.uuid, '', '')
+      if (config.setting.$hasSyncModule) {
+        MKEmitter.emit('syncBalconyData', config.uuid, [], false)
+      }
     }
   }
 
@@ -878,6 +936,13 @@
       extendData = {...extendData, ...data[0]}
     }
 
+    let checkAll = ''
+    if (config.wrap.selStyle.indexOf('check') > -1) {
+      if (selectedData.length > 0) {
+        checkAll = selectedData.length < data.length ? ' half' : ' whole'
+      }
+    }
+
     return (
       <div className="custom-data-card-box" id={'anchor' + config.uuid} style={config.style}>
         {loading ?
@@ -902,7 +967,9 @@
           <Row className={'card-row-list ' + config.wrap.layout}>
             {precards.map((item, index) => (
               <Col key={'pre' + index} className="extend-card" span={item.setting.width || 6}>
-                <CardItem card={item} cards={config} data={extendData}/>
+                <CardItem card={item} cards={config} data={extendData}>
+                  {item.setting.checkAll === 'show' ? <span onClick={this.checkAll} className={'circle-select' + checkAll}></span> : null}
+                </CardItem>
               </Col>
             ))}
             {data && data.map((item, index) => {
@@ -922,13 +989,17 @@
 
               return (
                 <Col className={className} key={index} span={card.setting.width} onClick={() => {this.changeCard(index, item)}}>
-                  <CardItem card={card} cards={config} data={item}/>
+                  <CardItem card={card} cards={config} data={item}>
+                    <span className="circle-select"></span>
+                  </CardItem>
                 </Col>
               )
             })}
             {nextcards.map((item, index) => (
               <Col key={'next' + index} className="extend-card" span={item.setting.width || 6}>
-                <CardItem card={item} cards={config} data={extendData}/>
+                <CardItem card={item} cards={config} data={extendData}>
+                  {item.setting.checkAll === 'show' ? <span onClick={this.checkAll} className={'circle-select' + checkAll}></span> : null}
+                </CardItem>
               </Col>
             ))}
           </Row>

--
Gitblit v1.8.0