From 6f817bf3ae4e6f51f982c07b0713adb3caf9fac2 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 02 二月 2023 17:14:16 +0800
Subject: [PATCH] 2023-02-02

---
 src/tabviews/custom/components/table/base-table/index.jsx |   97 +++++++++++++++++++++++++++++++++++-------------
 1 files changed, 71 insertions(+), 26 deletions(-)

diff --git a/src/tabviews/custom/components/table/base-table/index.jsx b/src/tabviews/custom/components/table/base-table/index.jsx
index 58a66c5..f8f7454 100644
--- a/src/tabviews/custom/components/table/base-table/index.jsx
+++ b/src/tabviews/custom/components/table/base-table/index.jsx
@@ -1,7 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { notification } from 'antd'
+import { notification, Modal } from 'antd'
 
 import Api from '@/api'
 import Utils from '@/utils/utils.js'
@@ -70,7 +70,7 @@
 
     let setting = {..._config.setting, ..._config.wrap}
 
-    if (setting.selected !== 'always' && setting.selected !== 'init') {
+    if (setting.selected !== 'always' && setting.selected !== 'init' && setting.selected !== 'sign') {
       setting.selected = 'false'
     } else {
       setting.orisel = true
@@ -126,7 +126,7 @@
       })
       
       MKEmitter.emit('resetSelectLine', config.uuid, '', '') // 骞挎挱鏁版嵁鍒囨崲
-      reset && MKEmitter.emit('resetTable', config.uuid, repage) // 鍒楄〃閲嶇疆
+      reset && MKEmitter.emit('resetTable', config.uuid, 'true') // 鍒楄〃閲嶇疆
       if (setting.$hasSyncModule) {
         MKEmitter.emit('syncBalconyData', config.uuid, [], false)
       }
@@ -157,9 +157,26 @@
 
     let result = await Api.genericInterface(param)
     if (result.status) {
+      if (repage === 'false' && result.data && result.data.length === 0 && result.total > 0 && pageIndex > 1) {
+        let _pageIndex = Math.ceil(result.total / pageSize)
+
+        if (_pageIndex < pageIndex) {
+          MKEmitter.emit('resetTable', config.uuid, 'repage', _pageIndex)
+          this.setState({
+            pageIndex: _pageIndex,
+            data: [],
+            selectedData: [],
+            total: result.total
+          }, () => {
+            this.loadmaindata()
+          })
+          return
+        }
+      }
+
       if ((setting.selected !== 'false' || (setting.orisel && id)) && result.data && result.data.length > 0) {
         setTimeout(() => {
-          MKEmitter.emit('mkCheckTopLine', config.uuid, id)
+          MKEmitter.emit('mkCheckTopLine', config.uuid, id, setting.selected)
         }, 200)
         if (setting.selected === 'init') {
           this.setState({setting: {...setting, selected: 'false'}})
@@ -206,15 +223,34 @@
         total: result.total,
         loading: false
       })
+
+      if (config.autoMatic) {
+        if (result.data && result.data.length > 0) {
+          MKEmitter.emit('autoGetData', config.MenuID)
+        } else {
+          MKEmitter.emit('autoMaticOver', config.MenuID)
+        }
+      }
     } else {
       this.setState({
         loading: false
       })
-      notification.error({
-        top: 92,
-        message: result.message,
-        duration: 10
-      })
+
+      if (config.autoMatic) {
+        MKEmitter.emit('autoMaticError', config.MenuID)
+      }
+      
+      if (result.ErrCode === 'N') {
+        Modal.error({
+          title: result.message,
+        })
+      } else {
+        notification.error({
+          top: 92,
+          message: result.message,
+          duration: 10
+        })
+      }
     }
   }
 
@@ -398,21 +434,29 @@
    * @description 琛ㄦ牸鏉′欢鏀瑰彉鏃堕噸缃暟鎹紙鍒嗛〉鎴栨帓搴忥級
    */
   refreshbytable = (pagination, filters, sorter) => {
-    if (sorter.order) {
-      let _chg = {
-        ascend: 'asc',
-        descend: 'desc'
+    if (!sorter) { // 鏃犱汉鍊煎畧
+      this.setState({
+        pageIndex: pagination.pageIndex
+      }, () => {
+        this.loadmaindata()
+      })
+    } else {
+      if (sorter.order) {
+        let _chg = {
+          ascend: 'asc',
+          descend: 'desc'
+        }
+        sorter.order = _chg[sorter.order]
       }
-      sorter.order = _chg[sorter.order]
+  
+      this.setState({
+        pageIndex: pagination.current,
+        pageSize: pagination.pageSize,
+        orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : ''
+      }, () => {
+        this.loadmaindata()
+      })
     }
-
-    this.setState({
-      pageIndex: pagination.current,
-      pageSize: pagination.pageSize,
-      orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : ''
-    }, () => {
-      this.loadmaindata()
-    })
   }
 
   /**
@@ -518,7 +562,7 @@
   UNSAFE_componentWillReceiveProps(nextProps) {
     const { config } = this.state
 
-    if (config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
+    if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
       this.setState({pageIndex: 1}, () => {
         this.reloadtable()
       })
@@ -551,20 +595,20 @@
 
   render() {
     const { BID, setting, actions, config, columns, selectedData, BData, data } = this.state
-
+    
     return (
       <div className="custom-base-table" style={config.style}>
         {config.search.length ?
           <MainSearch BID={BID} config={config} refreshdata={this.refreshbysearch}/> : null
         }
-        {actions.length ? <MainAction
+        {actions.length > 0 ? <MainAction
           BID={BID}
           setting={setting}
           actions={actions}
           BData={BData}
           columns={config.columns}
           selectedData={selectedData}
-        /> : <div style={{height: '15px'}}></div>}
+        /> : <div style={{height: '25px'}}></div>}
         <div className="main-table-box">
           <MainTable
             data={data}
@@ -573,6 +617,7 @@
             MenuID={config.uuid}
             fields={config.columns}
             total={this.state.total}
+            autoMatic={config.autoMatic}
             lineMarks={config.lineMarks}
             loading={this.state.loading}
             refreshdata={this.refreshbytable}

--
Gitblit v1.8.0