-
Notifications
You must be signed in to change notification settings - Fork 5
/
Demo10.js
127 lines (112 loc) · 3.29 KB
/
Demo10.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/**
*
* @title 嵌套表格的模态框
* @description 嵌套表格
*
*/
import React, { Component } from 'react';
import Button from 'bee-button';
import Checkbox from 'bee-checkbox'
import Table from 'bee-table'
import multiSelect from "bee-table/build/lib/multiSelect";
import Modal from '../../src';
let MultiSelectTable = multiSelect(Table, Checkbox);
class Demo10 extends Component {
constructor(props) {
super(props);
this.state = {
showModal: false,
data: [
{ a: "杨过", b: "男", c: 30, d: '内行', key: "2", _checked: true },
{ a: "令狐冲", b: "男", c: 41, d: '大侠', key: "1", _checked: true },
{ a: "郭靖", b: "男", c: 25, d: '大侠', key: "3", _checked: true }
]
};
}
columns = [
{
title: "名字",
dataIndex: "a",
key: "a",
width: "25%"
},
{
title: "性别",
dataIndex: "b",
key: "b",
width: "25%"
},
{
title: "年龄",
dataIndex: "c",
key: "c",
width: "20%",
sorter: (a, b) => a.c - b.c
},
{
title: "武功级别",
dataIndex: "d",
key: "25%"
}
];
close = () => {
this.setState({
showModal: false
});
}
open = () => {
this.setState({
showModal: true
});
}
getSelectedDataFunc = data => {
console.log(data);
};
clear = () => {
let { data } = this.state;
data.forEach(item => item._checked = false)
this.setState({
data:JSON.parse(JSON.stringify(data))
})
}
render () {
let multiObj = {
type: "checkbox"
};
return (
<div>
<Button
bordered
className="demo-margin"
onClick={this.open}>
打开模态框
</Button>
<Modal
show={this.state.showModal}
onHide={this.close}
size="lg"
ref={ref => this.modal = ref}
className="demo10-modal"
>
<Modal.Header closeButton>
<Modal.Title>标题</Modal.Title>
</Modal.Header>
<Modal.Body>
<MultiSelectTable
columns={this.columns}
data={this.state.data}
multiSelect={multiObj}
getSelectedDataFunc={this.getSelectedDataFunc}
/>
</Modal.Body>
<Modal.Footer>
<Button onClick={this.clear} colors="secondary" className="clear-btn">清空所选</Button>
<Button onClick={this.close} colors="secondary" style={{ marginRight: 8 }}>取消</Button>
<Button onClick={this.close} bordered>确认</Button>
</Modal.Footer>
</Modal>
</div>
)
}
}
export default Demo10;