From fa381753ef2a2b25b1c0722549ac17e333da79be Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 06 九月 2022 22:50:54 +0800
Subject: [PATCH] 2022-09-06

---
 src/tabviews/custom/components/timeline/normal-timeline/index.jsx |  172 ++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 146 insertions(+), 26 deletions(-)

diff --git a/src/tabviews/custom/components/timeline/normal-timeline/index.jsx b/src/tabviews/custom/components/timeline/normal-timeline/index.jsx
index 2a62ef0..1dbcafe 100644
--- a/src/tabviews/custom/components/timeline/normal-timeline/index.jsx
+++ b/src/tabviews/custom/components/timeline/normal-timeline/index.jsx
@@ -15,11 +15,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 +27,8 @@
     sync: false,               // 鏄惁缁熶竴璇锋眰鏁版嵁
     data: null,                // 鏁版嵁
     BData: '',
-    card: null
+    card: null,
+    description: false
   }
 
   /**
@@ -37,13 +36,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] || []
@@ -158,20 +169,10 @@
 
     if (config.uuid !== menuId) return
 
-    let supModule = config.setting.supModule
-
-    btn.syncComponentId && MKEmitter.emit('reloadData', btn.syncComponentId)
-
-    if (!btn.syncComponentId || btn.syncComponentId !== supModule) {
-      if (position === 'mainline' || position === 'popclose') { // 鍒锋柊婧愮粍浠舵椂锛岄檮甯﹀埛鏂颁笂绾ц涓庡綋鍓嶇粍浠�
-        if (supModule && BID) {
-          MKEmitter.emit('reloadData', supModule, BID)
-        } else {
-          this.loadData()
-        }
-      } else {
-        this.loadData()
-      }
+    if ((position === 'mainline' || position === 'popclose') && config.setting.supModule && BID) { // 鍒锋柊婧愮粍浠舵椂锛岄檮甯﹀埛鏂颁笂绾ц涓庡綋鍓嶇粍浠�
+      MKEmitter.emit('reloadData', config.setting.supModule, BID)
+    } else {
+      this.loadData()
     }
 
     if (position === 'popclose') { // 鎵ц鍚姩寮圭獥鐨勬寜閽墍閫夋嫨鐨勫埛鏂伴」
@@ -201,7 +202,7 @@
    /**
    * @description 瀵煎嚭Excel鏃讹紝鑾峰彇椤甸潰鎼滅储鎺掑簭绛夊弬鏁�
    */
-  queryModuleParam = (menuId, btnId) => {
+  queryModuleParam = (menuId, callback) => {
     const { mainSearch } = this.props
     const { arr_field, config } = this.state
 
@@ -217,7 +218,7 @@
       })
     }
 
-    MKEmitter.emit('returnModuleParam', config.uuid, btnId, {
+    callback({
       arr_field: arr_field,
       orderBy: config.setting.order || '',
       search: searches,
@@ -226,13 +227,18 @@
   }
 
   async loadData () {
-    const { mainSearch, menuType } = this.props
+    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
     }
 
@@ -256,7 +262,7 @@
     })
 
     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) {
@@ -281,6 +287,61 @@
         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) => {
@@ -314,8 +375,64 @@
     </Timeline.Item>)
   }
 
+  getMknodes = (data) => {
+    const { config, card } = this.state
+
+    let color = config.wrap.color
+    let dot = ''
+    let linebg = {}
+    if (config.wrap.node && card.nodes && card.nodes.length > 0) {
+      let sign = data[config.wrap.node]
+      card.nodes.some(item => {
+        if (sign === item.sign) {
+          color = item.color
+
+          if (item.icon) {
+            dot = <MkIcon type={item.icon}/>
+          }
+
+          if (item.linecolor) {
+            linebg = {borderColor: item.linecolor}
+          }
+          return true
+        }
+        return false
+      })
+    }
+
+    if (config.wrap.mode === 'down') {
+      return (<div className="mk-time-line-item" key={data.$Index}>
+        <div className="mk-timeline-item-content">
+          <div className="card-item-box" style={card.style}>
+            <CardCellComponent data={data} cards={config} cardCell={card} elements={card.elements}/>
+          </div>
+        </div>
+        <div className="mk-timeline-item-head">
+          <div className="mk-timeline-item-tail" style={linebg}></div>
+          <div className={'mk-dot ' + (dot ? 'mk-dot-icon' : '')} style={{background: color}}>
+            {dot}
+          </div>
+        </div>
+      </div>)
+    } else {
+      return (<div className="mk-time-line-item" key={data.$Index}>
+        <div className="mk-timeline-item-head">
+          <div className="mk-timeline-item-tail" style={linebg}></div>
+          <div className={'mk-dot ' + (dot ? 'mk-dot-icon' : '')} style={{background: color}}>
+            {dot}
+          </div>
+        </div>
+        <div className="mk-timeline-item-content">
+          <div className="card-item-box" style={card.style}>
+            <CardCellComponent data={data} cards={config} cardCell={card} elements={card.elements}/>
+          </div>
+        </div>
+      </div>)
+    }
+  }
+
   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}}>
@@ -326,11 +443,14 @@
           </div> : null
         }
         <NormalHeader config={config} />
-        {data && data.length > 0 ? <Timeline mode={config.wrap.mode} reverse={config.wrap.reverse === 'true'} className={'card-row-list ' + (config.wrap.line || '')} style={{height: config.wrap.contentHeight}}>
+        {config.wrap.direction !== 'horizontal' && data && data.length > 0 ? <Timeline mode={config.wrap.mode} className={'card-row-list ' + (config.wrap.line || '')} style={{height: config.wrap.contentHeight}}>
           {data.map(item => this.getnodes(item))}
         </Timeline> : null}
+        {config.wrap.direction === 'horizontal' && data && data.length > 0 ? <div className={'mk-time-line-wrap card-row-list ' + (config.wrap.line || '')} style={{height: config.wrap.contentHeight}}>
+          {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