From 79943222ed0edc6bd35ab2858c5eda2bc3246f66 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 28 二月 2022 15:03:45 +0800
Subject: [PATCH] 2022-02-28

---
 src/tabviews/custom/components/carousel/data-card/index.jsx |  123 +++++++----------------------------------
 1 files changed, 21 insertions(+), 102 deletions(-)

diff --git a/src/tabviews/custom/components/carousel/data-card/index.jsx b/src/tabviews/custom/components/carousel/data-card/index.jsx
index e4c768a..7154c9e 100644
--- a/src/tabviews/custom/components/carousel/data-card/index.jsx
+++ b/src/tabviews/custom/components/carousel/data-card/index.jsx
@@ -1,14 +1,12 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { connect } from 'react-redux'
 import { Spin, Empty, notification, Carousel } from 'antd'
 
 import Api from '@/api'
 import UtilsDM from '@/utils/utils-datamanage.js'
 import MKEmitter from '@/utils/events.js'
 import asyncComponent from '@/utils/asyncComponent'
-import { modifyTabview } from '@/store/action'
 import './index.scss'
 
 const CardItem = asyncComponent(() => import('../cardItem'))
@@ -29,10 +27,11 @@
     sync: false,               // 鏄惁缁熶竴璇锋眰鏁版嵁
     card: null,                // 鍗$墖璁剧疆
     data: null,                // 鏁版嵁
+    BData: null
   }
 
   UNSAFE_componentWillMount () {
-    const { data, initdata, BID } = this.props
+    const { data, initdata, BID, BData } = this.props
     let _config = fromJS(this.props.config).toJS()
     let _card = _config.subcards[0]
     let _cols = new Map()
@@ -53,11 +52,14 @@
         item.key = index
         item.$$uuid = item[_config.setting.primaryKey] || ''
         item.$$BID = BID || ''
+        item.$$BData = BData || ''
+        item.$Index = index + 1
         return item
       })
     }
 
     _config.columns.forEach(item => {
+      if (item.type !== 'number') return
       _cols.set(item.field, item)
     })
 
@@ -68,8 +70,8 @@
     }
 
     _card.elements = _card.elements.map(item => {
-      if (item.field && _cols.has(item.field)) {
-        item.col = _cols.get(item.field)
+      if (item.eleType === 'number' && item.field && _cols.has(item.field) && typeof(item.decimal) !== 'number') {
+        item.decimal = _cols.get(item.field).decimal || 0
       }
       return item
     })
@@ -80,12 +82,15 @@
       sync: _sync,
       data: _data,
       BID: BID || '',
+      BData: BData || '',
       config: _config,
       card: _card,
       arr_field: _config.columns.map(col => col.field).join(','),
     }, () => {
       if (_config.setting.sync !== 'true' && _config.setting.onload === 'true') {
-        this.loadData()
+        setTimeout(() => {
+          this.loadData()
+        }, _config.setting.delay || 0)
       }
     })
   }
@@ -101,7 +106,7 @@
   }
 
   UNSAFE_componentWillReceiveProps (nextProps) {
-    const { sync, config, BID } = this.state
+    const { sync, config, BID, BData } = this.state
 
     if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) {
       let _data = []
@@ -113,6 +118,8 @@
         item.key = index
         item.$$uuid = item[config.setting.primaryKey] || ''
         item.$$BID = BID || ''
+        item.$$BData = BData || ''
+        item.$Index = index + 1
         return item
       })
 
@@ -162,8 +169,8 @@
     const { config } = this.state
 
     if (!config.setting.supModule || config.setting.supModule !== MenuID) return
-    if (id !== this.state.BID) {
-      this.setState({ BID: id }, () => {
+    if (id !== this.state.BID || id !== '') {
+      this.setState({ BID: id, BData: data }, () => {
         this.loadData()
       })
     }
@@ -190,7 +197,7 @@
 
   async loadData () {
     const { mainSearch, menuType } = this.props
-    const { config, arr_field, BID } = this.state
+    const { config, arr_field, BID, BData } = this.state
 
     if (config.setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇�
       this.setState({
@@ -220,6 +227,8 @@
           item.key = index
           item.$$uuid = item[config.setting.primaryKey] || ''
           item.$$BID = BID || ''
+          item.$$BData = BData || ''
+          item.$Index = index + 1
           return item
         }),
         loading: false
@@ -233,83 +242,6 @@
         message: result.message,
         duration: 10
       })
-    }
-  }
-
-  openView = (item) => {
-    const { card } = this.state
-
-    if (card.setting.click === 'menu') {
-      let menu = null
-
-      if (card.setting.menu && card.setting.menu.length > 0) {
-        let menu_id = card.setting.menu.slice(-1)[0]
-        menu = this.props.permMenus.filter(m => m.MenuID === menu_id)[0] || ''
-      }
-
-      if (!menu) {
-        notification.warning({
-          top: 92,
-          message: '鑿滃崟宸插垹闄ゆ垨娌℃湁璁块棶鏉冮檺锛�',
-          duration: 5
-        })
-        return
-      }
-
-      let newtab = {
-        ...menu,
-        selected: true,
-        param: {}
-      }
-
-      if (card.setting.joint === 'true') {
-        newtab.param.$BID = item.$$uuid
-      }
-
-      if (['linkage_navigation', 'linkage'].includes(window.GLOB.navBar)) {
-        this.props.modifyTabview([newtab])
-      } else {
-        let tabs = this.props.tabviews.filter((tab, i) => {
-          tab.selected = false
-          return tab.MenuID !== newtab.MenuID
-        })
-
-        if (this.props.tabviews.length > tabs.length) {
-          this.props.modifyTabview(fromJS(tabs).toJS())
-        }
-
-        this.setState({}, () => {
-          tabs.push(newtab)
-          this.props.modifyTabview(tabs)
-        })
-      }
-    } else if (card.setting.click === 'link') {
-      let src = card.setting.linkurl
-
-      if (src.indexOf('paramsmain/') > -1) {
-        try {
-          let _url = src.split('paramsmain/')[0] + 'paramsmain/'
-          let _param = JSON.parse(window.decodeURIComponent(window.atob(src.split('paramsmain/')[1])))
-
-          _param.UserID = sessionStorage.getItem('UserID')
-          _param.LoginUID = sessionStorage.getItem('LoginUID')
-          _param.User_Name = sessionStorage.getItem('User_Name')
-          _param.param = { BID: item.$$uuid }
-          src = _url + window.btoa(window.encodeURIComponent(JSON.stringify(_param)))
-        } catch {
-          console.warn('鑿滃崟鍙傛暟瑙f瀽閿欒锛�')
-        }
-      } else if (card.setting.joint === 'true') {
-        let con = '?'
-
-        if (/\?/ig.test(src)) {
-          con = '&'
-        }
-
-        src = src + `${con}id=${item.$$uuid}&appkey=${window.GLOB.appkey}&userid=${sessionStorage.getItem('UserID')}&LoginUID=${sessionStorage.getItem('LoginUID') || ''}`
-      }
-
-      window.open(src)
     }
   }
 
@@ -332,7 +264,7 @@
           autoplaySpeed={config.wrap.speed}
         >
           {data.map((item, index) => (
-            <div key={index} onClick={() => {this.openView(item)}}>
+            <div key={index}>
               <CardItem card={card} cards={config} data={item}/>
             </div>
           ))}
@@ -343,17 +275,4 @@
   }
 }
 
-const mapStateToProps = (state) => {
-  return {
-    permMenus: state.permMenus,
-    tabviews: state.tabviews,
-  }
-}
-
-const mapDispatchToProps = (dispatch) => {
-  return {
-    modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews))
-  }
-}
-
-export default connect(mapStateToProps, mapDispatchToProps)(DataCard)
\ No newline at end of file
+export default DataCard
\ No newline at end of file

--
Gitblit v1.8.0