|
|
@@ -17,14 +17,16 @@ class ChooseChartBox extends React.Component {
|
|
|
filterItem: { name: 'name', label: '图表名称', type: 'string' },
|
|
|
selectedRecord: -1,
|
|
|
selectedRecords: [],
|
|
|
- screenWidth: document.documentElement.clientWidth || document.body.clientWidth,
|
|
|
- screenHeight: document.documentElement.clientHeight || document.body.clientHeight
|
|
|
+ tableBodyWidth: 0,
|
|
|
+ tableBodyHeight: 0
|
|
|
};
|
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
|
const { dispatch } = this.props;
|
|
|
- dispatch({ type: 'chart/fetchList' });
|
|
|
+ dispatch({ type: 'chart/fetchList' }).then(() => {
|
|
|
+ this.onWindowResize();
|
|
|
+ });
|
|
|
window.addEventListener('resize', this.onWindowResize);
|
|
|
}
|
|
|
|
|
|
@@ -33,9 +35,15 @@ class ChooseChartBox extends React.Component {
|
|
|
}
|
|
|
|
|
|
onWindowResize = () => {
|
|
|
+ const boxEl = document.getElementsByClassName('choosechart-box')[0];
|
|
|
+ if(!boxEl) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const bodyEl = boxEl.getElementsByClassName('ant-modal-body')[0];
|
|
|
+ const bodyBox = bodyEl.getBoundingClientRect();
|
|
|
this.setState({
|
|
|
- screenWidth: document.documentElement.clientWidth || document.body.clientWidth,
|
|
|
- screenHeight: document.documentElement.clientHeight || document.body.clientHeight
|
|
|
+ tableBodyWidth: bodyBox.width - 36 * 2,
|
|
|
+ tableBodyHeight: bodyBox.height - 56 - 42 - 54
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -110,10 +118,8 @@ class ChooseChartBox extends React.Component {
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
- const { visibleBox, hideBox, dashboardDesigner, chart } = this.props;
|
|
|
- const { selectedRecords, screenWidth, screenHeight, filterItem, filterLabel: stateFilterLabel } = this.state;
|
|
|
- const tableBodyWidth = screenWidth * 0.8 - 10 - 10 - 18;
|
|
|
- const tableBodyHeight = screenHeight * 0.8 - 65 - 53 - 38 - 130;
|
|
|
+ const { visibleBox, hideBox, dashboardDesigner, chart, loading } = this.props;
|
|
|
+ const { selectedRecords, tableBodyWidth, tableBodyHeight, filterItem, filterLabel: stateFilterLabel } = this.state;
|
|
|
const tableRowHeight = 38;
|
|
|
const reg = new RegExp('([+ \\- & | ! ( ) { } \\[ \\] ^ \" ~ * ? : ( ) \/])', 'g'); // 需要转义的字符
|
|
|
let filterLabel = stateFilterLabel ? (stateFilterLabel + '').replace(new RegExp('(\\\\)', 'g'), '\\$1').replace(reg, '\\$1') : ''; // 添加转义符号
|
|
|
@@ -257,12 +263,13 @@ class ChooseChartBox extends React.Component {
|
|
|
</Col>
|
|
|
</Row>
|
|
|
<Table
|
|
|
+ loading={loading}
|
|
|
className='choosechart-table'
|
|
|
columns={columns}
|
|
|
dataSource={this.onSort(this.onSearch(chart.list)).map((d, i) => ({ ...d, key: i }))}
|
|
|
size='small'
|
|
|
scroll={{ x: columns ? columns.length * 100 : tableBodyWidth, y: tableBodyHeight }}
|
|
|
- pagination={{ defaultPageSize: Math.floor(tableBodyHeight/tableRowHeight) || 10 }}
|
|
|
+ pagination={{ pageSize: Math.ceil(tableBodyHeight/tableRowHeight) }}
|
|
|
onRow={(record) => {
|
|
|
return {
|
|
|
onClick: () => {
|
|
|
@@ -277,15 +284,9 @@ class ChooseChartBox extends React.Component {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-function mapStateToProps({ present: { dashboardDesigner, chart } }) {
|
|
|
- return { dashboardDesigner, chart };
|
|
|
+function mapStateToProps({ present: { dashboardDesigner, chart, loading: stateLoading } }) {
|
|
|
+ let loading = stateLoading.effects['chart/fetchList'];
|
|
|
+ return { dashboardDesigner, chart, loading };
|
|
|
}
|
|
|
|
|
|
export default connect(mapStateToProps)(ChooseChartBox)
|