From 27821f7b598e9e87de8fb179bdcbfdc5e2cb31fa Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 25 九月 2019 00:17:55 +0800 Subject: [PATCH] 2019-09-25update --- src/components/mainTable/index.jsx | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 52 insertions(+), 6 deletions(-) diff --git a/src/components/mainTable/index.jsx b/src/components/mainTable/index.jsx index b742eda..2289e12 100644 --- a/src/components/mainTable/index.jsx +++ b/src/components/mainTable/index.jsx @@ -1,10 +1,13 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Table, Icon, message } from 'antd' +// import { is, fromJS } from 'immutable' +import { Table, Icon, message, Affix } from 'antd' import './index.scss' export default class MainTable extends Component { static propTpyes = { + MenuNo: PropTypes.string, // 鑿滃崟鍙傛暟 + fixed: PropTypes.object, // 琛ㄦ牸澶撮儴鏄惁鍥哄畾浜庨〉闈笂鏂� loading: PropTypes.bool, total: PropTypes.number, select: PropTypes.object, @@ -59,15 +62,22 @@ } changeRow = (record, index) => { - // 鐐瑰嚮鏁磋锛岃Е鍙戝垏鎹� + // 鐐瑰嚮鏁磋锛岃Е鍙戝垏鎹紝鍒ゆ柇鏄惁鍙�夛紝鍗曢�夋垨澶氶�夛紝杩涜瀵瑰簲鎿嶄綔 + if (!this.props.select || !this.props.select.selectable) return + let newkeys = JSON.parse(JSON.stringify(this.state.selectedRowKeys)) let _re = newkeys.includes(index) - if (_re) { - newkeys = newkeys.filter(item => item !== index) + + if (this.props.select.selectType === 'radio') { + this.setState({ selectedRowKeys: [index] }) } else { - newkeys.push(index) + if (_re) { + newkeys = newkeys.filter(item => item !== index) + } else { + newkeys.push(index) + } + this.setState({ selectedRowKeys: newkeys }) } - this.setState({ selectedRowKeys: newkeys }) } changeTable = (pagination, filters, sorter) => { @@ -77,6 +87,13 @@ selectedRowKeys: [] }) this.props.refreshdata(pagination, filters, sorter) + } + + resetTable = () => { + this.setState({ + pageIndex: 1, + selectedRowKeys: [] + }) } render() { @@ -89,8 +106,37 @@ onChange: this.onSelectChange } } + let offset = null + if (this.props.fixed.fixtable) { + // 琛ㄦ牸澶撮儴鍥哄畾浜庨《閮ㄦ椂锛屽垽鏂窛椤堕儴楂樺害 + if (!this.props.fixed.fixaction) { + offset = 48 + } else { + let box = document.getElementById(this.props.MenuNo + 'mainaction') + if (box) { + offset = 48 + box.offsetHeight + } else { + offset = 105 + } + } + } return ( <div className="main-table"> + {this.props.fixed.fixtable && <Affix offsetTop={offset} className="fix-header"> + <Table + bordered={true} + rowSelection={rowSelection} + size="middle" + columns={this.state.columns.map(column => { + return { + align: column.align, + dataIndex: column.dataIndex, + title: column.title, + width: column.width + } + })} + /> + </Affix>} <Table bordered={true} rowSelection={rowSelection} -- Gitblit v1.8.0