| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Spin, notification, Col, Empty } from 'antd' |
| | | import { Spin, notification, Col, Empty, Pagination } from 'antd' |
| | | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import Api from '@/api' |
| | |
| | | state = { |
| | | config: null, // 图表配置信息 |
| | | loading: false, // 数据加载状态 |
| | | preIndex: 0, // 开始索引 |
| | | pageIndex: 1, // 页码 |
| | | total: 0, // 总数 |
| | | sync: false, // 是否统一请求数据 |
| | | data: null, // 数据 |
| | | title: '', // 标题 |
| | |
| | | let showHeader = false |
| | | if (_config.wrap.title || _config.search.length > 0) { |
| | | showHeader = true |
| | | } |
| | | |
| | | if (_config.setting.laypage) { |
| | | _config.wrap.contentHeight = _config.wrap.height - (showHeader ? 85 : 40) |
| | | } else { |
| | | _config.wrap.contentHeight = _config.wrap.height - (showHeader ? 45 : 0) |
| | | } |
| | | |
| | | _config.columns.forEach(item => { |
| | |
| | | |
| | | if (syncId && syncId !== config.uuid) return |
| | | |
| | | this.setState({ |
| | | pageIndex: 1 |
| | | }, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | async loadData () { |
| | | const { mainSearch, BID, menuType, dataManager } = this.props |
| | | const { config, arr_field } = this.state |
| | | const { config, arr_field, pageIndex } = this.state |
| | | |
| | | let searches = [] |
| | | if (mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | |
| | | }) |
| | | |
| | | let _orderBy = config.setting.order || '' |
| | | let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, 1, 1, BID, menuType, dataManager) |
| | | let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, pageIndex, config.setting.pageSize, BID, menuType, dataManager) |
| | | |
| | | let result = await Api.genericInterface(param) |
| | | if (result.status) { |
| | | let _preIndex = 0 |
| | | if (config.setting.laypage) { |
| | | _preIndex = config.setting.pageSize * (pageIndex - 1) |
| | | } |
| | | |
| | | this.setState({ |
| | | data: result.data, |
| | | total: result.total, |
| | | preIndex: _preIndex, |
| | | loading: false |
| | | }) |
| | | } else { |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | changePageIndex = (page) => { |
| | | this.setState({ |
| | | pageIndex: page |
| | | }, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | getLines = (data, seq) => { |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { config, loading, data, title, showHeader } = this.state |
| | | const { config, loading, data, title, showHeader, pageIndex, preIndex, total } = this.state |
| | | |
| | | return ( |
| | | <div className="custom-table-card-box" style={{...config.style, height: config.wrap.height}}> |
| | |
| | | <span className="table-title">{title}</span> |
| | | {/* <searchLine /> */} |
| | | </div> : null} |
| | | {data && data.length > 0 ? <div className="card-row-list" style={{height: config.wrap.height - (showHeader ? 45 : 0)}}> |
| | | {data.map((item, index) => this.getLines(item, index + 1))} |
| | | {data && data.length > 0 ? <div className="card-row-list" style={{height: config.wrap.contentHeight}}> |
| | | {data.map((item, index) => this.getLines(item, preIndex + index + 1))} |
| | | </div> : null} |
| | | {data && data.length === 0 ? <Empty description={false}/> : null} |
| | | {data && data.length === 0 ? <div className="card-row-list" style={{height: config.wrap.contentHeight}}> |
| | | <Empty description={false}/> |
| | | </div> : null} |
| | | {config.setting.laypage ? <Pagination size="small" current={pageIndex} total={total} onChange={this.changePageIndex} /> : null} |
| | | </div> |
| | | ) |
| | | } |