From 31ec63f0419895876cbaba99637a884a32d33d0d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 01 九月 2021 10:31:45 +0800
Subject: [PATCH] 2021-09-01

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

diff --git a/src/tabviews/custom/components/card/data-card/index.jsx b/src/tabviews/custom/components/card/data-card/index.jsx
index 5f29f7b..5ec9396 100644
--- a/src/tabviews/custom/components/card/data-card/index.jsx
+++ b/src/tabviews/custom/components/card/data-card/index.jsx
@@ -2,7 +2,7 @@
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
 import { connect } from 'react-redux'
-import { Spin, Empty, notification, Row, Col, Pagination } from 'antd'
+import { Spin, Empty, notification, message, Row, Col, Pagination } from 'antd'
 
 import Api from '@/api'
 import Utils from '@/utils/utils.js'
@@ -146,6 +146,7 @@
 
   componentDidMount () {
     MKEmitter.addListener('reloadData', this.reloadData)
+    MKEmitter.addListener('mkCheckAll', this.mkCheckAll)
     MKEmitter.addListener('resetSelectLine', this.resetParentParam)
     MKEmitter.addListener('queryModuleParam', this.queryModuleParam)
     MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult)
@@ -173,12 +174,10 @@
       })
 
       this.setState({sync: false, data: _data})
-    } else if (nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
-      if (config.setting.syncRefresh === 'true') {
-        this.setState({pageIndex: 1}, () => {
-          this.loadData()
-        })
-      }
+    } else if (config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
+      this.setState({pageIndex: 1}, () => {
+        this.loadData()
+      })
     }
   }
 
@@ -187,6 +186,7 @@
       return
     }
     MKEmitter.removeListener('reloadData', this.reloadData)
+    MKEmitter.removeListener('mkCheckAll', this.mkCheckAll)
     MKEmitter.removeListener('resetSelectLine', this.resetParentParam)
     MKEmitter.removeListener('queryModuleParam', this.queryModuleParam)
     MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
@@ -225,17 +225,32 @@
     }
   }
 
-  reloadData = (btn) => {
-    if (!btn || btn.resetPageIndex !== 'false') {
+  mkCheckAll = (menuId, checked) => {
+    const { config, data } = this.state
+
+    if (config.uuid !== menuId) return
+
+    if (checked) {
       this.setState({
-        pageIndex: 1
-      }, () => {
-        this.loadmaindata(true, 'true')
-        this.getStatFieldsValue()
+        activeKey: '',
+        selectKeys: data.map((item, index) => index),
+        selectedData: data
       })
+  
+      MKEmitter.emit('resetSelectLine', config.uuid, '', '')
+      MKEmitter.emit('syncBalconyData', config.uuid, data, data.length > 0)
+      if (data.length === 0) {
+        message.warning('鏈幏鍙栧埌鏁版嵁锛�')
+      }
     } else {
-      this.loadmaindata(true, 'false')
-      this.getStatFieldsValue()
+      this.setState({
+        activeKey: '',
+        selectKeys: [],
+        selectedData: []
+      })
+  
+      MKEmitter.emit('resetSelectLine', config.uuid, '', '')
+      MKEmitter.emit('syncBalconyData', config.uuid, [], false)
     }
   }
 
@@ -273,7 +288,7 @@
     if (config.uuid !== menuId) return
 
     let searches = search ? fromJS(search).toJS() : []
-    if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
+    if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
       let keys = searches.map(item => item.key.toLowerCase())
       mainSearch.forEach(item => {
         if (!keys.includes(item.key.toLowerCase())) {
@@ -292,7 +307,7 @@
 
   async loadData () {
     const { mainSearch, menuType } = this.props
-    const { config, arr_field, pageIndex, search, BID } = this.state
+    const { config, arr_field, pageIndex, search, BID, BData } = this.state
 
     if (config.setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇�
       this.setState({
@@ -304,11 +319,15 @@
         total: 0,
         loading: false
       })
+      MKEmitter.emit('resetSelectLine', config.uuid, '', '')
+      if (config.setting.$hasSyncModule) {
+        MKEmitter.emit('syncBalconyData', config.uuid, [], false)
+      }
       return
     }
 
     let searches = fromJS(search).toJS()
-    if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
+    if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
       let keys = searches.map(item => item.key.toLowerCase())
       mainSearch.forEach(item => {
         if (!keys.includes(item.key.toLowerCase())) {
@@ -317,11 +336,8 @@
       })
     }
 
-    let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0))
+    let requireFields = searches.filter(item => item.required && item.value === '')
     if (requireFields.length > 0) {
-      this.setState({
-        loading: false
-      })
       return
     }
 
@@ -347,12 +363,17 @@
           item.key = index
           item.$$uuid = item[config.setting.primaryKey] || ''
           item.$$BID = BID || ''
+          item.$$BData = BData || ''
           item.$Index = index + start + ''
           return item
         }),
         total: result.total,
         loading: false
       })
+      MKEmitter.emit('resetSelectLine', config.uuid, '', '')
+      if (config.setting.$hasSyncModule) {
+        MKEmitter.emit('syncBalconyData', config.uuid, [], false)
+      }
     } else {
       this.setState({
         loading: false
@@ -370,10 +391,10 @@
    */ 
   async loadLinedata (id) {
     const { mainSearch, menuType } = this.props
-    const { config, arr_field, pageIndex, search, BID } = this.state
+    const { config, arr_field, pageIndex, search, BID, BData } = this.state
 
     let searches = fromJS(search).toJS()
-    if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
+    if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
       let keys = searches.map(item => item.key.toLowerCase())
       mainSearch.forEach(item => {
         if (!keys.includes(item.key.toLowerCase())) {
@@ -389,10 +410,6 @@
     let _orderBy = config.setting.order || ''
     let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, pageIndex, config.setting.pageSize, BID, menuType, id)
 
-    if (param.func === 'sPC_Get_TableData') {
-      param.menuname = config.name || ''
-    }
-
     let result = await Api.genericInterface(param)
     if (result.status) {
       let data = fromJS(this.state.data).toJS()
@@ -405,13 +422,14 @@
               _data.key = item.key
               _data.$$uuid = _data[config.setting.primaryKey] || ''
               _data.$$BID = BID || ''
+              item.$$BData = BData || ''
               _data.$Index = item.$Index
               return _data
             } else {
               return item
             }
           })
-        } catch {
+        } catch (e) {
           console.warn('鏁版嵁鏌ヨ閿欒')
         }
       }
@@ -475,7 +493,7 @@
   }
   
   changeCard = (index, item) => {
-    const { config, selectKeys, selectedData, activeKey } = this.state
+    const { config, selectKeys, selectedData, activeKey, data } = this.state
 
     this.openView(item)
 
@@ -515,6 +533,9 @@
     })
 
     MKEmitter.emit('resetSelectLine', config.uuid, (_item ? _item.$$uuid : ''), _item)
+    if (config.setting.$hasSyncModule) {
+      MKEmitter.emit('syncBalconyData', config.uuid, _selectedData, data.length === _selectedData.length)
+    }
   }
 
   openView = (item) => {
@@ -547,7 +568,7 @@
         newtab.param.$BID = item.$$uuid
       }
 
-      if (['linkage_navigation', 'linkage'].includes(window.GLOB.navBar)) {
+      if (['linkage_navigation', 'linkage', 'menu_board'].includes(window.GLOB.navBar)) {
         this.props.modifyTabview([newtab])
       } else {
         let tabs = this.props.tabviews.filter((tab, i) => {
@@ -577,7 +598,7 @@
           _param.User_Name = sessionStorage.getItem('User_Name')
           _param.param = { BID: item.$$uuid }
           src = _url + window.btoa(window.encodeURIComponent(JSON.stringify(_param)))
-        } catch {
+        } catch (e) {
           console.warn('鑿滃崟鍙傛暟瑙f瀽閿欒锛�')
         }
       } else if (card.setting.joint === 'true') {
@@ -639,7 +660,7 @@
           <Row className="card-row-list">
             {offset ? <Col span={offset} style={{height: '10px'}}> </Col> : null}
             {precards.map((item, index) => (
-              <Col key={'pre' + index} className={item.setting.$click} span={item.setting.width || 6}>
+              <Col key={'pre' + index} className={'extend-card ' + item.setting.$click} span={item.setting.width || 6}>
                 <CardItem card={item} cards={config} data={{$$BID: BID, $$type: 'extendCard'}}/>
               </Col>
             ))}
@@ -649,7 +670,7 @@
               </Col>
             ))}
             {nextcards.map((item, index) => (
-              <Col key={'next' + index} className={item.setting.$click} span={item.setting.width || 6}>
+              <Col key={'next' + index} className={'extend-card ' + item.setting.$click} span={item.setting.width || 6}>
                 <CardItem card={item} cards={config} data={{$$BID: BID, $$type: 'extendCard'}}/>
               </Col>
             ))}

--
Gitblit v1.8.0