-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.js
More file actions
109 lines (106 loc) · 2.89 KB
/
Copy pathindex.js
File metadata and controls
109 lines (106 loc) · 2.89 KB
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
/**
* react-pagination 示例
* Created by hanwei on 15/2/16.
*/
var React = require('react');
var DataGird = require('./src/grid');
var Pagination = require('./src/pagination');
var App = React.createClass({
getInitialState : function(){
return {
columns:[
{name: '', field: 'applyId', checkbox: true},
{name: '申请单编号', field: 'applyId'},
{name: '品牌', field: 'applyBrand'},
{name: '状态', field: 'verify'},
{name: '申请时间', field: 'addTime'}
],
condition:{},
data:[],
checkedList:[]
}
},
callback : function(data,pageInfo){
this.setState({
data:data
});
},
search : function(){
this.setState({
condition:{
paramType:$('#paramType').val(),
paramValue:$('#paramValue').val()
}
});
},
render: function(){
return (
<div>
<div className="row">
<div className="span span24">
<div className="search-form">
<div className="trigger-content">
<a className="btn btn-primary" href="javascript:void(0);"
onClick={this.search}>搜索</a>
</div>
<form method="post" name="searchForm" id="searchForm">
<ul>
<li>
<select id="paramType" name="paramType">
<option value="applyId">申请单编号</option>
<option value="brandName">品牌名称</option>
</select>
<input type="text" className="input-text" id="paramValue" name="paramValue"/>
</li>
</ul>
</form>
</div>
</div>
</div>
<DataGird
data={this.state.data}
columns={this.state.columns}
checkedIds={this.state.checkedList}
onAllChecked={this._handleDTAllChecked}
onOneChecked={this._handleDTOneChecked}/>
<Pagination
url="./data.js"
callback={this.callback}
condition={this.state.condition}/>
</div>
);
},
/**
* datatable的全选or全不选
* @param status
* @param ids
* @private
*/
_handleDTAllChecked(status, ids) {
if(status){
this.setState({checkedList:this.state.checkedList.concat(ids)});
}else{
this.setState({checkedList:[]});
}
},
/**
* 选中or取消某个datable的checkbox
* @param status
* @param id
* @private
*/
_handleDTOneChecked(status, id) {
if(status){
this.setState({checkedList:this.state.checkedList.concat([id])});
}else{
var checkedList = this.state.checkedList;
for(var i=0,l=checkedList.length;i<l;i++){
if(checkedList[i] == id){
checkedList.splice(i,1);
}
}
this.setState({checkedList:checkedList});
}
}
});
React.render(<App/>, document.body);