From 19e156d67e400bff8883425f3511812bb4f9d193 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 10 七月 2023 12:46:00 +0800
Subject: [PATCH] 2023-07-10

---
 src/tabviews/custom/components/form/simple-form/index.jsx |   88 +++++++++++++++++++++++++++++---------------
 1 files changed, 58 insertions(+), 30 deletions(-)

diff --git a/src/tabviews/custom/components/form/simple-form/index.jsx b/src/tabviews/custom/components/form/simple-form/index.jsx
index 5ea76fc..d3214a5 100644
--- a/src/tabviews/custom/components/form/simple-form/index.jsx
+++ b/src/tabviews/custom/components/form/simple-form/index.jsx
@@ -1,8 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { connect } from 'react-redux'
-import { Spin, notification } from 'antd'
+import { Spin, notification, Modal, Button } from 'antd'
 
 import Api from '@/api'
 import UtilsDM from '@/utils/utils-datamanage.js'
@@ -58,12 +57,13 @@
     if (config.wrap.datatype !== 'static') {
       _sync = config.setting.sync === 'true'
 
-      if (_sync && data && data[config.dataName]) {
-        _data = data[config.dataName]
+      if (_sync && data) {
+        _data = data[config.dataName] || {$$empty: true}
         if (Array.isArray(_data)) {
           _data = _data[0] || {$$empty: true}
         }
         _sync = false
+        _data.$$uuid = _data[config.setting.primaryKey] || ''
       }
     } else {
       _data = {$$empty: true}
@@ -71,7 +71,7 @@
 
     let _group = config.subcards[0]
 
-    if (_group.subButton.enable === 'false') {
+    if (_group.subButton.enable === 'false' && (!_group.closeButton || _group.closeButton.enable !== 'true')) {
       _group.subButton.style.display = 'none'
       _group.$button = 'no-button'
     }
@@ -129,8 +129,10 @@
         }
       }
 
+      _data.$$uuid = _data[config.setting.primaryKey] || ''
+
       this.setState({sync: false, data: _data})
-    } else if (config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
+    } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
       this.setState({}, () => {
         this.loadData()
       })
@@ -156,7 +158,7 @@
 
     if (group.uuid !== menuId) return
 
-    if (position === 'mainline' && config.setting.supModule && BID) {
+    if ((position === 'mainline' || position === 'popclose') && config.setting.supModule && BID) {
       MKEmitter.emit('reloadData', config.setting.supModule, BID)
     } else {
       this.loadData()
@@ -196,7 +198,7 @@
   execSuccess = (btn, id) => {
     if (btn.linkmenu && btn.linkmenu.length > 0) {
       let menu_id = btn.linkmenu[btn.linkmenu.length - 1]
-      let menu = this.props.permMenus.filter(m => m.MenuID === menu_id)[0] || ''
+      let menu = window.GLOB.mkThdMenus.filter(m => m.MenuID === menu_id)[0] || ''
 
       if (!menu) return
 
@@ -205,11 +207,7 @@
         param: {$BID: id || ''}
       }
 
-      if (['linkage_navigation', 'linkage', 'menu_board'].includes(window.GLOB.navBar)) {
-        MKEmitter.emit('modifyTabs', newtab, 'replace')
-      } else {
-        MKEmitter.emit('modifyTabs', newtab, 'plus', true)
-      }
+      MKEmitter.emit('modifyTabs', newtab, true)
     }
   }
 
@@ -217,7 +215,12 @@
     const { mainSearch } = this.props
     const { config, arr_field, BID } = this.state
 
-    if (config.wrap.datatype === 'static' || (config.setting.supModule && !BID)) {
+    if (config.wrap.datatype === 'static') {
+      this.setState({
+        data: {$$empty: true}
+      })
+      return
+    } else if (config.setting.supModule && !BID) {
       this.setState({
         data: null
       }, () => {
@@ -244,21 +247,45 @@
     if (result.status) {
       let _data = result.data && result.data[0] ? result.data[0] : {$$empty: true}
 
+      _data.$$uuid = _data[config.setting.primaryKey] || ''
+
       this.setState({
         data: null,
         loading: false
       }, () => {
         this.setState({data: _data})
       })
+
+      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.setState({
         loading: false,
       })
-      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
+        })
+      }
     }
   }
 
@@ -272,9 +299,18 @@
     })
   }
 
+  closeTab = () => {
+    const { group } = this.state
+
+    MKEmitter.emit('closeTabView', group.subButton.$MenuID)
+  }
+
   render() {
     const { config, loading, BID, BData, data, group, dict } = this.state
 
+    if (config.wrap.empty === 'hidden' && (!data || data.$$empty)) return null
+    if (config.idCtrl && (!data || data.$$empty)) return null
+    
     return (
       <div className="custom-simple-form-box" id={'anchor' + config.uuid} style={{...config.style}}>
         {loading ?
@@ -290,6 +326,7 @@
           dict={dict}
           data={data}
           action={group}
+          unload={config.setting.supModule && !BID}
           inputSubmit={() => this.mkFormSubmit(group.uuid)}
           wrappedComponentRef={(inst) => this.formRef = inst}
         /> : null}
@@ -301,20 +338,11 @@
             columns={config.columns}
             selectedData={data.$$empty ? [] : [data]}
           />
+          {group.closeButton && group.closeButton.enable === 'true' ? <Button type="link" onClick={this.closeTab} style={group.closeButton.style}>{group.closeButton.label}</Button> : null}
         </div> : null}
       </div>
     )
   }
 }
 
-const mapStateToProps = (state) => {
-  return {
-    permMenus: state.permMenus,
-  }
-}
-
-const mapDispatchToProps = () => {
-  return {}
-}
-
-export default connect(mapStateToProps, mapDispatchToProps)(SimpleForm)
\ No newline at end of file
+export default SimpleForm
\ No newline at end of file

--
Gitblit v1.8.0