From aa41be24e83653077d85860cb70882551912af24 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 28 十月 2022 12:53:25 +0800
Subject: [PATCH] 2022-10-28

---
 src/tabviews/custom/components/timeline/normal-timeline/index.jsx |  133 +++++++++++++++++++++++++++++++++++++------
 1 files changed, 113 insertions(+), 20 deletions(-)

diff --git a/src/tabviews/custom/components/timeline/normal-timeline/index.jsx b/src/tabviews/custom/components/timeline/normal-timeline/index.jsx
index eaf2074..8e6e58e 100644
--- a/src/tabviews/custom/components/timeline/normal-timeline/index.jsx
+++ b/src/tabviews/custom/components/timeline/normal-timeline/index.jsx
@@ -1,13 +1,14 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Spin, notification, Timeline, Empty } from 'antd'
+import { Spin, notification, Timeline, Empty, Modal } from 'antd'
 
 import Api from '@/api'
 import MkIcon from '@/components/mk-icon'
 import asyncComponent from '@/utils/asyncComponent'
 import UtilsDM from '@/utils/utils-datamanage.js'
 import MKEmitter from '@/utils/events.js'
+import TimerTask from '@/utils/timer-task.js'
 import './index.scss'
 
 const CardCellComponent = asyncComponent(() => import('@/tabviews/custom/components/card/cardcellList'))
@@ -15,11 +16,9 @@
 
 class NormalTimeline extends Component {
   static propTpyes = {
-    BID: PropTypes.any,              // 鐖剁骇Id
     data: PropTypes.array,           // 缁熶竴鏌ヨ鏁版嵁
     config: PropTypes.object,        // 缁勪欢閰嶇疆淇℃伅
     mainSearch: PropTypes.any,       // 澶栧眰鎼滅储鏉′欢
-    menuType: PropTypes.any,         // 鑿滃崟绫诲瀷
   }
 
   state = {
@@ -29,7 +28,8 @@
     sync: false,               // 鏄惁缁熶竴璇锋眰鏁版嵁
     data: null,                // 鏁版嵁
     BData: '',
-    card: null
+    card: null,
+    description: false
   }
 
   /**
@@ -37,13 +37,25 @@
    * 1銆� initdata 涓烘墦鍗版椂浣跨敤鐨勬暟鎹泦
    */
   UNSAFE_componentWillMount () {
-    const { data, initdata, BID, BData } = this.props
+    const { data, initdata } = this.props
     let _config = fromJS(this.props.config).toJS()
     let _cols = new Map()
 
     let _data = null
     let card = null
     let _sync = _config.setting.sync === 'true'
+
+    let BID = ''
+    let BData = ''
+
+    if (_config.setting.supModule) {
+      BData = window.GLOB.CacheData.get(_config.setting.supModule)
+    } else {
+      BData = window.GLOB.CacheData.get(_config.$pageId)
+    }
+    if (BData) {
+      BID = BData.$BID || ''
+    }
 
     if (_config.setting.sync === 'true' && data) {
       _data = data[_config.dataName] || []
@@ -98,10 +110,19 @@
   }
 
   componentDidMount () {
+    const { config } = this.state
+
     MKEmitter.addListener('reloadData', this.reloadData)
     MKEmitter.addListener('resetSelectLine', this.resetParentParam)
     MKEmitter.addListener('queryModuleParam', this.queryModuleParam)
     MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult)
+
+    if (config.timer) {
+      this.timer = new TimerTask()
+      this.timer.init(config.uuid, config.timer, config.timerRepeats, () => {
+        this.loadData(true)
+      })
+    }
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -116,6 +137,8 @@
     MKEmitter.removeListener('resetSelectLine', this.resetParentParam)
     MKEmitter.removeListener('queryModuleParam', this.queryModuleParam)
     MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
+
+    this.timer && this.timer.stop()
   }
 
   /**
@@ -191,7 +214,7 @@
    /**
    * @description 瀵煎嚭Excel鏃讹紝鑾峰彇椤甸潰鎼滅储鎺掑簭绛夊弬鏁�
    */
-  queryModuleParam = (menuId, btnId) => {
+  queryModuleParam = (menuId, callback) => {
     const { mainSearch } = this.props
     const { arr_field, config } = this.state
 
@@ -207,7 +230,7 @@
       })
     }
 
-    MKEmitter.emit('returnModuleParam', config.uuid, btnId, {
+    callback({
       arr_field: arr_field,
       orderBy: config.setting.order || '',
       search: searches,
@@ -215,14 +238,19 @@
     })
   }
 
-  async loadData () {
-    const { mainSearch, menuType } = this.props
+  async loadData (hastimer) {
+    const { mainSearch } = this.props
     const { config, arr_field, BID, BData } = this.state
-
+    
     if (config.setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇�
       this.setState({
         data: [],
       })
+      return
+    }
+
+    if (config.setting.interType === 'inner' && config.setting.innerFunc === 'z_mk_express') {
+      this.getExpress()
       return
     }
 
@@ -241,12 +269,14 @@
       return
     }
 
-    this.setState({
-      loading: true
-    })
+    if (!hastimer) {
+      this.setState({
+        loading: true
+      })
+    }
 
     let _orderBy = config.setting.order || ''
-    let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, 1, config.setting.pageSize, BID, menuType)
+    let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, 1, config.setting.pageSize, BID)
 
     let result = await Api.genericInterface(param)
     if (result.status) {
@@ -265,12 +295,75 @@
       this.setState({
         loading: false
       })
-      notification.error({
-        top: 92,
-        message: result.message,
-        duration: 10
+      this.timer && this.timer.stop()
+      
+      if (result.ErrCode === 'N') {
+        Modal.error({
+          title: result.message,
+        })
+      } else {
+        notification.error({
+          top: 92,
+          message: result.message,
+          duration: 10
+        })
+      }
+    }
+  }
+
+  getExpress = () => {
+    const { BData } = this.state
+
+    let code = ''
+    let order = ''
+    if (BData) {
+      Object.keys(BData).forEach(key => {
+        if (key.toLowerCase() === 'expresscode') {
+          code = BData[key]
+        } else if (key.toLowerCase() === 'expressno') {
+          order = BData[key]
+        }
       })
     }
+
+    if (!code || !order) {
+      notification.warning({
+        top: 92,
+        message: '鏈幏鍙栧埌蹇��' + (!code ? '鍏徃缂栫爜銆�' : '鍗曞彿銆�'),
+        duration: 5
+      })
+      return
+    }
+
+    this.setState({
+      loading: true
+    })
+    Api.wxNginxRequest(`express/${code}/${order}`, 'get').then(res => {
+      if (!res || typeof(res) !== 'string') {
+        notification.error({
+          top: 92,
+          message: '鏈幏鍙栧埌蹇�掍俊鎭�',
+          duration: 10
+        })
+      } else if (/鏌ヨ鏃犵粨鏋�/.test(res)) {
+        this.setState({description: res, data: [], loading: false})
+      } else {
+        let data = res.split(/\n/).filter(Boolean)
+
+        data = data.map((item, i) => {
+          return {
+            $Index: i,
+            date: item.substr(0, 19),
+            content: item.substr(20)
+          }
+        })
+
+        this.setState({
+          data: data,
+          loading: false
+        })
+      }
+    })
   }
 
   getnodes = (data) => {
@@ -361,7 +454,7 @@
   }
 
   render() {
-    const { config, loading, data } = this.state
+    const { config, loading, data, description } = this.state
 
     return (
       <div className="normal-timeline-box" id={'anchor' + config.uuid} style={{...config.style}}>
@@ -379,7 +472,7 @@
           {data.map(item => this.getMknodes(item))}
         </div> : null}
         {data && data.length === 0 ? <div className="card-row-list" style={{height: config.wrap.contentHeight}}>
-          <Empty description={false}/>
+          <Empty description={description}/>
         </div> : null}
       </div>
     )

--
Gitblit v1.8.0