| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Spin, notification, Col, Empty, Pagination } from 'antd' |
| | | import { Spin, notification, Row, Col, Empty, Pagination } from 'antd' |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | |
| | | config: null, // 图表配置信息 |
| | | loading: false, // 数据加载状态 |
| | | search: null, // 搜索条件 |
| | | preIndex: 0, // 开始索引 |
| | | pageIndex: 1, // 页码 |
| | | total: 0, // 总数 |
| | | sync: false, // 是否统一请求数据 |
| | |
| | | item.key = index |
| | | item.$$uuid = item[_config.setting.primaryKey] || '' |
| | | item.$$BID = BID || '' |
| | | item.$Index = index + 1 + '' |
| | | return item |
| | | }) |
| | | } |
| | |
| | | } |
| | | |
| | | if (_config.setting.laypage) { |
| | | _config.wrap.contentHeight = _config.wrap.height - (showHeader ? 85 : 40) |
| | | _config.wrap.contentHeight = showHeader ? 'calc(100% - 85px)' : 'calc(100% - 40px)' |
| | | } else { |
| | | _config.wrap.contentHeight = _config.wrap.height - (showHeader ? 45 : 0) |
| | | _config.wrap.contentHeight = showHeader ? 'calc(100% - 45px)' : '100%' |
| | | } |
| | | |
| | | _config.columns.forEach(item => { |
| | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.addListener('getexceloutparam', this.getexceloutparam) |
| | | MKEmitter.addListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | } |
| | | |
| | |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | MKEmitter.removeListener('getexceloutparam', this.getexceloutparam) |
| | | MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | } |
| | | |
| | |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$$BID = BID || '' |
| | | item.$Index = index + 1 + '' |
| | | return item |
| | | }) |
| | | |
| | | this.setState({sync: false, data: _data}) |
| | | } else if (nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | if (config.setting.syncRefresh === 'true') { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | } else if (config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | if (!config.setting.supModule || config.setting.supModule !== MenuID) return |
| | | if (id !== this.state.BID) { |
| | | this.setState({ BID: id }, () => { |
| | | this.setState({ BID: id, pageIndex: 1 }, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | |
| | | /** |
| | | * @description 导出Excel时,获取页面搜索排序等参数 |
| | | */ |
| | | getexceloutparam = (menuId, btnId) => { |
| | | queryModuleParam = (menuId, btnId) => { |
| | | const { mainSearch } = this.props |
| | | const { arr_field, config, search } = this.state |
| | | |
| | | if (config.uuid !== menuId) return |
| | | |
| | | let searches = search ? fromJS(search).toJS() : [] |
| | | if (mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key.toLowerCase()) |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key.toLowerCase())) { |
| | |
| | | }) |
| | | } |
| | | |
| | | MKEmitter.emit('execExcelout', config.uuid, btnId, { |
| | | MKEmitter.emit('returnModuleParam', config.uuid, btnId, { |
| | | arr_field: arr_field, |
| | | orderBy: config.setting.order || '', |
| | | search: searches, |
| | |
| | | if (config.setting.supModule && !BID) { // BID 不存在时,不做查询 |
| | | this.setState({ |
| | | data: [], |
| | | total: 0, |
| | | preIndex: 0 |
| | | total: 0 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let searches = search ? fromJS(search).toJS() : [] |
| | | if (mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | let keys = searches.map(item => item.key) |
| | | mainSearch.forEach(item => { |
| | | if (!keys.includes(item.key)) { |
| | | searches.push(item) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | return |
| | | } |
| | | |
| | | this.setState({ |
| | |
| | | |
| | | let result = await Api.genericInterface(param) |
| | | if (result.status) { |
| | | let _preIndex = 0 |
| | | let start = 1 |
| | | if (config.setting.laypage) { |
| | | _preIndex = config.setting.pageSize * (pageIndex - 1) |
| | | start = config.setting.pageSize * (pageIndex - 1) + 1 |
| | | } |
| | | |
| | | this.setState({ |
| | |
| | | item.key = index |
| | | item.$$uuid = item[config.setting.primaryKey] || '' |
| | | item.$$BID = BID || '' |
| | | item.$Index = index + start + '' |
| | | return item |
| | | }), |
| | | total: result.total, |
| | | preIndex: _preIndex, |
| | | loading: false |
| | | }) |
| | | } else { |
| | |
| | | }) |
| | | } |
| | | |
| | | getLines = (data, seq) => { |
| | | getLines = (data) => { |
| | | const { config } = this.state |
| | | |
| | | let line = [] |
| | |
| | | line.push( |
| | | <Col key={index} span={24}> |
| | | <div className="card-item-box" style={item.style}> |
| | | <CardCellComponent seq={seq} data={data} cards={config} cardCell={item} elements={item.elements}/> |
| | | <CardCellComponent data={data} cards={config} cardCell={item} elements={item.elements}/> |
| | | </div> |
| | | </Col> |
| | | ) |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { config, loading, data, BID, pageIndex, preIndex, total } = this.state |
| | | const { config, loading, data, BID, pageIndex, total } = this.state |
| | | |
| | | return ( |
| | | <div className="custom-table-card-box" style={{...config.style, height: config.wrap.height}}> |
| | | <div className="custom-table-card-box" style={{...config.style}}> |
| | | {loading ? |
| | | <div className="loading-mask"> |
| | | {data ? <div className="ant-spin-blur"></div> : null} |
| | |
| | | </div> : null |
| | | } |
| | | <NormalHeader config={config} BID={BID} menuType={this.props.menuType} refresh={this.refreshSearch} /> |
| | | {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 ? <Row className="card-row-list" style={{height: config.wrap.contentHeight}}> |
| | | {data.map(item => this.getLines(item))} |
| | | </Row> : null} |
| | | {data && data.length === 0 ? <div className="card-row-list" style={{height: config.wrap.contentHeight}}> |
| | | <Empty description={false}/> |
| | | </div> : null} |