-
Notifications
You must be signed in to change notification settings - Fork 0
/
test1.html
251 lines (235 loc) · 10.8 KB
/
test1.html
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>#####</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="font-awesome/css/font-awesome.css" rel="stylesheet">
<link href="css/plugins/dataTables/datatables.min.css" rel="stylesheet">
<!--<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs/dt-1.10.16/cr-1.4.1/fc-3.2.4/rg-1.0.2/rr-1.2.3/sl-1.2.5/datatables.min.css"/>-->
<link href="css/plugins/select2/select2.min.css" rel="stylesheet">
<link href="css/plugins/jsTree/style.min.css" rel="stylesheet">
<link href="css/plugins/daterangepicker/daterangepicker.css" rel="stylesheet">
<link href="css/animate.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<style>
.details-control {
background: url('images/details_open.png') no-repeat center center;
cursor: pointer;
display: inline-block;
height: 20px;
width: 20px;
}
tr.shown .details-control {
background: url('images/details_close.png') no-repeat center center;
}
</style>
</head>
<body>
<div class="container">
<!-- 实例1 开始 -->
<div class="panel panel-default">
<div class="panel-heading">###</div>
<div class="panel-body">
<div class="demo-box">
<table id="example9_1" class="table table-striped table-bordered nowrap" cellspacing="0" width="100%">
<thead>
</thead>
<tbody class="first_table">
</tbody>
</table>
</div>
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#demo1-html" role="tab" data-toggle="tab">html</a></li>
<li role="presentation"><a href="#demo1-js" role="tab" data-toggle="tab">js</a></li>
<li role="presentation"><a href="#demo1-css" role="tab" data-toggle="tab">css</a></li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="demo1-html">
<pre>
//TODO
</pre>
</div>
<div role="tabpanel" class="tab-pane" id="demo1-js">
<pre>
//TODO
</pre>
</div>
<div role="tabpanel" class="tab-pane" id="demo1-css">
<pre>
//TODO
</pre>
</div>
</div>
</div>
</div>
<!-- 实例1 结束 -->
</div>
<script src="js/jquery-2.1.1.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/plugins/layer/layer.js"></script>
<script src="js/plugins/jsTree/jstree.min.js"></script>
<script src="js/pinyin.js"></script>
<!-- Custom and plugin javascript -->
<script src="js/plugins/datatables/datatables.min.js"></script>
<!--<script type="text/javascript" src="https://cdn.datatables.net/v/bs/dt-1.10.16/cr-1.4.1/fc-3.2.4/rg-1.0.2/rr-1.2.3/sl-1.2.5/datatables.min.js"></script>-->
<script src="js/plugins/select2/select2.full.min.js"></script>
<script src="js/plugins/jquery-number/jquery.number.min.js"></script>
<script src="js/jquery.hash.min.js"></script>
<script src="i18n/zh-CN.js"></script>
<script src="js/subindex.js"></script>
<script type="text/javascript" src="js/plugins/moment/moment.min.js" ></script>
<script src="js/plugins/daterangepicker/daterangepicker.min.js"></script>
<!-- 以下js仅用于演示 -->
<script src="js/jquery.mockjax.min.js"></script>
<script type="text/javascript" src="demo-data.js" ></script>
<script>
$(document).ready(function() {
var searchParemOBj_ = { //示例
'asd': 112
};
var DT_ = COM_TOOLS.DT_init('example9_1', [{
"data": null,
"title": '序号',
"className": "text-center",
"width": "30px",
render: function(data, type, row, meta) { /*显示行号*/
return 1 + meta.row;
}
}, {
"data": "office",
"width": "30px",
"title": "keke",
render: function(data, type, row, meta){
console.log('asdasd')
return '<span class="details-control no-Sel-obj"></span><span>' + data +'</span>';
}
}, {
"data": "first_name",
"className": "text-center",
"title": '姓名'
}, {
"data": "position",
"className": "text-center",
"title": '地址'
}],
'/dt/api',
'get',
searchParemOBj_, {
jsTrDblclick: function(trdata, jqdom) {
alert('当前操作行ID为:' + trdata['first_name']);
},
other: {
pagingType: "simple_numbers_no_totalpage",
fixedColumns:{//可选,锁定左侧、右侧各两列,需引用列冻结包
leftColumns: 2,
},
preDrawCallback:function(){
console.log('###!!')
}
}
}
);
window.table1 = DT_.table;
function makeChildRow(tr, str) {
var tb = tr.closest('.dataTables_wrapper');
if(tb.length == 0){
console.log('#',0)
return false;
}
var nodeid = tb.attr('id').replace(/_wrapper$/gi,'');
if(!nodeid){
console.log('#',1)
return false;
}
if(!$('#'+nodeid).length){
console.log('#',2)
return false;
}
var index_ = tr.data('cindex') || 0;
var getFristPrev = function(node){
if(node.hasClass('js-child-tr')){
return getFristPrev(node.prev('tr'));
}else{
return node;
}
};
var tableTr = getFristPrev(tr);
var table = $('#'+nodeid).DataTable();
var r = table.row(tableTr);
if(tr.hasClass('js-child-tr')){
tr.after(str);
}else{
r.child(str).show();
}
if(index_ == 0){
/*if(r.child.isShown()) {
tr.removeClass('shown');
r.child.hide();
} else {
table.rows().every(function() {
this.child.hide();
this.nodes().to$().removeClass('shown');
})
tr.addClass('shown');
r.child(str).show();
}*/
}else{
// '[data-cindex="'+ index_ +'"]'
}
tr.addClass('shown');
}
$('#example9_1').on('click', '.details-control', function(e) {
e.stopPropagation();
console.log(123)
var tr = $(this).closest('tr');
var index_ = parseInt(tr.data('cindex') || 0) + 1;
var prevTr = '';
for(var i =0; i < index_; i++){
prevTr+='<td></td>';
}
console.log(prevTr)
var str = $('<tr class="js-child-tr" data-cindex="'+(index_)+'"><td></td>'+ prevTr +'<td><span class="details-control no-Sel-obj"></span>333</td><td>444</td></tr><tr class="js-child-tr" data-cindex="'+(index_)+'"><td></td>'+ prevTr +'<td><span class="details-control no-Sel-obj"></span>@333</td><td>444</td></tr>');
makeChildRow(tr, str);
});
})
</script>
<div class="" style="width: 400px;">
<input id="demo" value="" />
</div>
<div class="" style="height: 400px;">
</div>
<script>
$('#demo').daterangepicker({
ranges:{
'今日': [moment(), moment()],
'昨日': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'本周': [moment().startOf('week'), moment().endOf('week')],
'上周': [moment().subtract(1, 'week').startOf('week'), moment().subtract(1, 'week').endOf('week')],
'本月': [moment().startOf('month'), moment().endOf('month')],
'上月': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')],
'过去30天': [moment().subtract(29, 'days'), moment()],
},
alwaysShowCalendars: true,
locale:{
"format": 'YYYY-MM-DD',
"separator": " 至 ",
"applyLabel": "确定",
"cancelLabel": "取消",
"fromLabel": "起始时间",
"toLabel": "结束时间'",
"customRangeLabel": "自定义",
"weekLabel": "W",
"daysOfWeek": ["日", "一", "二", "三", "四", "五", "六"],
"monthNames": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
"firstDay": 1
},
startDate: moment().subtract(29, 'days'),
endDate: moment()
}, function(start, end, label) {
console.log('New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')');
});
</script>
</body>