From 31871ca836e6fcbea9b1c54e2ec15f49667bf093 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 23 十二月 2022 14:14:04 +0800 Subject: [PATCH] 2022-12-23 --- src/tabviews/custom/components/table/base-table/index.jsx | 74 +++++++++++++++++++++++++----------- 1 files changed, 51 insertions(+), 23 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..c4753cc 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' @@ -206,15 +206,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 +417,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 +545,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 +578,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 +600,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