|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
import ReactDOM from 'react-dom';
|
|
|
import Table from '../src/Table/index.js';
|
|
|
import Animate from 'rc-animate';
|
|
|
-import renders from '../utils/RenderUtils.js';
|
|
|
import '../assets/Table/index.less';
|
|
|
import '../assets/Table/animation.less';
|
|
|
|
|
|
@@ -30,9 +29,7 @@ class TableModel extends React.Component {
|
|
|
// 根据render方法名获得对应方法实体
|
|
|
for (let i = 0; i < cols.length; i++) {
|
|
|
let col = cols[i];
|
|
|
- let renderFunction = typeof (col.render) == 'string' ? renders[col.render] :
|
|
|
- (typeof (col.render) == 'function' ? col.render :
|
|
|
- renders[this.newProps.render] || function (_v, _r, _i) { return { children: _v, props: {} } });
|
|
|
+ let renderFunction = col.render ? col.render : this.newProps.render ? this.newProps.render : function (_v, _r, _i) { return { children: _v, props: {} } };
|
|
|
col.render = renderFunction;
|
|
|
}
|
|
|
return cols;
|
|
|
@@ -56,12 +53,15 @@ class TableModel extends React.Component {
|
|
|
let node = this._reactInternalInstance.getHostNode();
|
|
|
let title = node.getElementsByClassName('rc-table-title')[0] || {offsetHeight: 0};
|
|
|
let thead = node.getElementsByClassName('rc-table-thead')[0];
|
|
|
- this.cHeight = node.offsetHeight - title.offsetHeight - thead.offsetHeight - 4;
|
|
|
+ this.cHeight = node.offsetHeight - title.offsetHeight;
|
|
|
+ thead.style.fontSize = `${this.rowHeight * .6}px`;
|
|
|
+ thead.style.height = `${this.cHeight/(this.rowCount + 1)}px`;
|
|
|
let count = this.state.data.length;
|
|
|
if (count == 0) { return; }
|
|
|
let trs = node.getElementsByClassName('fade-enter');
|
|
|
for (let i = 0; i < trs.length; i++) {
|
|
|
- trs[i].style.height = `${this.cHeight/this.rowCount}px`;
|
|
|
+ trs[i].style.height = `${this.cHeight/(this.rowCount + 1)}px`;
|
|
|
+ trs[i].style.fontSize = `${this.rowHeight * .6}px`;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -105,13 +105,13 @@ class TableModel extends React.Component {
|
|
|
* 根据容器高度分割data展示
|
|
|
*/
|
|
|
splitData() {
|
|
|
- const { fontSize } = this.newProps;
|
|
|
+ const { fontSize, pageSize } = this.newProps;
|
|
|
let node = this._reactInternalInstance.getHostNode();
|
|
|
let title = node.getElementsByClassName('rc-table-title')[0] || {offsetHeight: 0};
|
|
|
let thead = node.getElementsByClassName('rc-table-thead')[0];
|
|
|
- this.cHeight = node.offsetHeight - title.offsetHeight - thead.offsetHeight;
|
|
|
- this.cWidth = node.offsetWidth
|
|
|
- this.rowCount = Math.round(this.cHeight/(this.newProps.rowHeight || 40));
|
|
|
+ this.cHeight = node.offsetHeight - title.offsetHeight;
|
|
|
+ this.cWidth = node.offsetWidth;
|
|
|
+ this.rowCount = (pageSize + 1) || Math.round(this.cHeight/(fontSize / .6));
|
|
|
this.rowHeight = this.cHeight/this.rowCount;
|
|
|
let a = this.newProps.data;
|
|
|
let result = [];
|
|
|
@@ -187,13 +187,8 @@ class TableModel extends React.Component {
|
|
|
|
|
|
getTitle() {
|
|
|
const { title } = this.newProps;
|
|
|
- if (renders[title]) {
|
|
|
- return renders[title];
|
|
|
- } else {
|
|
|
- let me = this;
|
|
|
- return function(state) {
|
|
|
- return title;
|
|
|
- }
|
|
|
+ return function(state) {
|
|
|
+ return title;
|
|
|
}
|
|
|
}
|
|
|
|