fixed: 修改和完善代码和文档
This commit is contained in:
parent
9be18be1c9
commit
c61f9fead6
|
@ -1,15 +1,15 @@
|
|||
/**
|
||||
*
|
||||
* @title 全选功能
|
||||
* @description 全选功能
|
||||
* @title 列排序、全选功能
|
||||
* @description 列排序、全选功能
|
||||
*
|
||||
*/
|
||||
|
||||
import React, { Component } from "react";
|
||||
import Table from "../../src";
|
||||
import Checkbox from "bee-checkbox";
|
||||
import multiTable from "../../src/lib/multiSelectFunc.js";
|
||||
import sortTable from "../../src/lib/sortFunc.js";
|
||||
import multiSelectFunc from "../../src/lib/multiSelectFunc.js";
|
||||
import sortFunc from "../../src/lib/sortFunc.js";
|
||||
|
||||
const columns13 = [
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ const data13 = [
|
|||
{ a: "郭靖", b: "男", c: 25, key: "3" }
|
||||
];
|
||||
class Demo13 extends Component {
|
||||
setCheckedOjb = (data) =>{
|
||||
getSelectedDataFunc = (data) =>{
|
||||
console.log(data)
|
||||
}
|
||||
render() {
|
||||
|
@ -55,15 +55,14 @@ class Demo13 extends Component {
|
|||
type: "checkbox",
|
||||
param: "key"
|
||||
};
|
||||
let ComplexTable = multiTable(sortTable(Table));
|
||||
let ComplexTable = multiSelectFunc(sortFunc(Table));
|
||||
return (
|
||||
<div>
|
||||
<ComplexTable
|
||||
columns={columns13}
|
||||
data={data13}
|
||||
multiSelect={multiObj}
|
||||
prefixCls="bee-table"
|
||||
getSelectedDataFunc={this.setCheckedOjb}
|
||||
getSelectedDataFunc={this.getSelectedDataFunc}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
# editType
|
|
@ -0,0 +1,5 @@
|
|||
## Table
|
||||
## Code display
|
||||
## API
|
||||
|Property|Description|Type|Default|
|
||||
|:---|:-----|:----|:------|
|
|
@ -0,0 +1,35 @@
|
|||
## util
|
||||
|
||||
Table拓展功能方法
|
||||
|
||||
### 如何使用
|
||||
xxx
|
||||
|
||||
|
||||
### multiSelectFunc
|
||||
|
||||
全选功能
|
||||
|
||||
#### Table新增参数
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
| ------------------- | -------------------------- | -------- | -------- |
|
||||
| multiSelect | 全选功能的配置对象,属性参见下面 | obj | {} |
|
||||
| multiSelect.type | 全选功能的类型,多选或单选(暂时只支持多选) | string | checkbox |
|
||||
| multiSelect.param | 通过设置该参数来设计获取的数据数组,默认返还所有数据 | string | '' |
|
||||
| getSelectedDataFunc | 返回当前选中的数据数组 | Function | 无 |
|
||||
|
||||
|
||||
|
||||
### sortFunc
|
||||
|
||||
排序功能
|
||||
|
||||
#### Column新增参数
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
| ------ | ---------- | -------- | ---- |
|
||||
| sorter | 排序函数,可以自定义 | Function | 无 |
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
## Table
|
||||
## Code display
|
||||
## API
|
||||
|Property|Description|Type|Default|
|
||||
|:---|:-----|:----|:------|
|
|
@ -8,7 +8,7 @@ import Checkbox from "bee-checkbox";
|
|||
* getSelectedDataFunc--function,能获取到选中的数据
|
||||
* 使用全选时得注意,data中的key值一定要是唯一值
|
||||
*/
|
||||
module.exports = function multiTable(Table) {
|
||||
module.exports = function multiSelectFunc(Table) {
|
||||
Array.prototype.indexOf = function(val) {
|
||||
for (var i = 0; i < this.length; i++) {
|
||||
if (this[i] == val) return i;
|
||||
|
@ -63,11 +63,14 @@ module.exports = function multiTable(Table) {
|
|||
let self = this;
|
||||
let allFlag = false;
|
||||
let selIds = self.state.selIds;
|
||||
let id = self.props.multiSelect.param
|
||||
let id = self.props.multiSelect
|
||||
? self.props.multiSelect.param
|
||||
? record[self.props.multiSelect.param]
|
||||
: record
|
||||
: record;
|
||||
let checkedObj = Object.assign({}, self.state.checkedObj);
|
||||
let checkedArray = Object.keys(checkedObj);
|
||||
let { getSelectedDataFunc } = self.props;
|
||||
if (checkedObj[record["key"]]) {
|
||||
selIds.remove(id);
|
||||
} else {
|
||||
|
@ -87,7 +90,9 @@ module.exports = function multiTable(Table) {
|
|||
checkedObj: checkedObj,
|
||||
selIds: selIds
|
||||
});
|
||||
self.props.getSelectedDataFunc(selIds);
|
||||
if(typeof getSelectedDataFunc === 'function'){
|
||||
getSelectedDataFunc(selIds);
|
||||
}
|
||||
};
|
||||
renderColumnsMultiSelect(columns) {
|
||||
const { data } = this.state;
|
||||
|
|
|
@ -6,7 +6,7 @@ import Icon from 'bee-icon';
|
|||
* 参数:prefixCls,默认bee-table,用于设置图标的样式
|
||||
* @param {*} Table
|
||||
*/
|
||||
export default function sortTable(Table) {
|
||||
export default function sortFunc(Table) {
|
||||
return class Demo11 extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
|
Loading…
Reference in New Issue