From 1d1ef9c117f162f5ee48237b67d69fbd015b10d1 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 23 七月 2023 10:32:40 +0800
Subject: [PATCH] Merge branch 'master' into positec

---
 src/tabviews/custom/components/interfaces/interItem/index.jsx |  109 ++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 96 insertions(+), 13 deletions(-)

diff --git a/src/tabviews/custom/components/interfaces/interItem/index.jsx b/src/tabviews/custom/components/interfaces/interItem/index.jsx
index 9253bd9..7e8c885 100644
--- a/src/tabviews/custom/components/interfaces/interItem/index.jsx
+++ b/src/tabviews/custom/components/interfaces/interItem/index.jsx
@@ -1,6 +1,6 @@
 import {Component} from 'react'
 import PropTypes from 'prop-types'
-import { notification } from 'antd'
+import { notification, Modal } from 'antd'
 
 import Api from '@/api'
 import UtilsDM from '@/utils/utils-datamanage.js'
@@ -17,20 +17,38 @@
 
   loading = false
   
-  state = {}
+  state = {
+    BID: ''
+  }
 
   componentDidMount () {
-    const { config } = this.props
+    const { config, BID } = this.props
 
     if (config.setting.timer) {
       this.timer = new TimerTask()
       this.timer.init(config.uuid, config.setting.timer, config.setting.timerRepeats, () => {this.loadData()})
     }
-    setTimeout(() => {
-      this.loadData()
-    }, config.setting.delay)
+
+    if (!config.setting.supModule) {
+      this.setState({ BID: BID || '' })
+    } else {
+      let BData = window.GLOB.CacheData.get(config.setting.supModule)
+
+      if (BData) {
+        this.setState({ BID: BData.$BID || '' })
+      }
+    }
+
+    if (config.setting.onload !== 'false') {
+      setTimeout(() => {
+        this.loadData()
+      }, config.setting.delay)
+    } else {
+      MKEmitter.addListener('initFinish', this.initFinish)
+    }
 
     MKEmitter.addListener('reloadData', this.reloadData)
+    MKEmitter.addListener('resetSelectLine', this.resetParentParam)
   }
 
   shouldComponentUpdate (nextProps, nextState) { return false }
@@ -43,7 +61,32 @@
       return
     }
     this.timer && this.timer.stop()
+    MKEmitter.removeListener('initFinish', this.initFinish)
     MKEmitter.removeListener('reloadData', this.reloadData)
+    MKEmitter.removeListener('resetSelectLine', this.resetParentParam)
+  }
+
+  initFinish = (MenuID) => {
+    const { config } = this.props
+
+    if (config.MenuID !== MenuID) return
+
+    if (config.setting.onload === 'false') {
+      setTimeout(() => {
+        this.loadData()
+      }, config.setting.delay)
+    }
+  }
+
+  resetParentParam = (MenuID, id) => {
+    const { config } = this.props
+
+    if (!config.setting.supModule || config.setting.supModule !== MenuID) return
+    if (id !== this.state.BID || id !== '') {
+      this.setState({ BID: id }, () => {
+        this.loadData()
+      })
+    }
   }
 
   reloadData = (publicId) => {
@@ -53,7 +96,15 @@
   }
 
   async loadData () {
-    const { config, BID } = this.props
+    const { config } = this.props
+    const { BID } = this.state
+
+    if (config.setting.supModule && !BID) {
+      MKEmitter.emit('mkPublicData', config.uuid, { $$empty: true, $$uuid: '' })
+      MKEmitter.emit('resetSelectLine', config.uuid, '', { $$empty: true, $$uuid: '' })
+      this.loading = false
+      return
+    }
 
     if (this.loading) return
 
@@ -64,10 +115,11 @@
     let result = await Api.genericInterface(param)
     if (result.status) {
       this.loading = false
-      let _data = { $$empty: true }
+      let _data = { $$empty: true, $$uuid: '' }
 
       if (result.data && result.data[0]) {
         _data = result.data[0]
+        _data.$$uuid = _data[config.setting.primaryKey] || ''
       }
       
       _data.$$loaded = true
@@ -75,14 +127,45 @@
       window.GLOB.CacheData.set(config.uuid, _data)
 
       MKEmitter.emit('mkPublicData', config.uuid, _data)
+      MKEmitter.emit('resetSelectLine', config.uuid, _data.$$uuid, _data)
+
+      if (config.setting.loadlevel === 'init') {
+        MKEmitter.emit('interFinish', config.MenuID, config.uuid)
+      }
+
+      if (result.message) {
+        if (result.ErrCode === 'Y') {
+          Modal.success({
+            title: result.message
+          })
+        } else if (result.ErrCode === 'S') {
+          notification.success({
+            top: 92,
+            message: result.message,
+            duration: 2
+          })
+        }
+      }
     } else {
       this.loading = false
       this.timer && this.timer.stop()
-      notification.error({
-        top: 92,
-        message: result.message,
-        duration: 10
-      })
+      
+      if (!result.message) return
+      if (result.ErrCode === 'N') {
+        Modal.error({
+          title: result.message,
+        })
+      } else if (result.ErrCode !== '-2') {
+        notification.error({
+          top: 92,
+          message: result.message,
+          duration: 10
+        })
+      }
+
+      if (config.setting.loadlevel === 'init') {
+        MKEmitter.emit('interFinish', config.MenuID, config.uuid)
+      }
     }
   }
 

--
Gitblit v1.8.0