detail.js
41.1 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
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
define(['jquery', 'bootstrap', 'backend', 'form', 'table', '../project_common/project-api','layer'], function ($, undefined, Backend, Form, Table, projectApi,Layer) {
var container_id = $("input[name='container_id']").val();
console.log(container_id);
var type = $("input[name='type']").val();
var project_double_id = $("input[name='project_double_id']").val();
var param = '';
var detail_param = '';
if(parseInt(type)==0){
param = "?container_id="+container_id;
}else{
param ="?container_id="+container_id+"&project_type="+type;
}
if(project_double_id){
detail_param = "?project_double_id="+project_double_id;
}
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init();
//绑定事件
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { // 为tab按钮绑定事件
var panel = $($(this).attr("href"));
if (panel.size() > 0) {
Controller.table[panel.attr('id')].call(this, panel.index() + 1, panel.attr('id'));
$(this).on('click', function (e) {
$($(this).attr("href")).find(".btn-refresh").trigger("click");
});
}
//移除绑定的事件
$(this).unbind('shown.bs.tab');
});
//必须默认触发shown.bs.tab事件
$('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");
},
detail:function(){
// 初始化表格参数配置
Table.api.init();
Controller.table['detail'].call(this, '','detail');
},
table: {
first: function (index,id) {
var table1 = $("#table1");
table1.bootstrapTable({
url: '/teacher/double_detail/detail/projectPush' + param,
extend: {
url: '/teacher/double_detail/detail/projectPush' + param,
add_url:'/teacher/double_detail/detail/add_double/' + param,
edit_url:'/teacher/double_detail/detail/edit_double/' + param,
del_url:'/teacher/double_detail/detail/del_double/' + param,
table: '',
},
toolbar: '#toolbar1',
search: false,
columns: [
[
{checkbox: true},
{ field: 'id', title: '序号', operate: false },
{
field: 'project_name', title: '项目名称', operate: false, align: 'left',
},
{ field: 'createtime_text', title: '发布时间', operate: false },
{ field: 'count', title: '申请学生数', operate: false },
{ field: 'is_complete', title: '完成情况', align: 'left', operate: false },
{
field: 'operate', title: __('Operate'), operate: false, table: table1,
class: 'nowrap',
events: Table.api.events.operate,
formatter: Table.api.formatter.operate,
buttons: [
{
name: 'btn2',
text: '完成双选',
title: '完成双选',
classname: 'btn btn-xs btn-info btn-click',
click: function (val, row) {
var project_id = row.id;
var row_index = val.rowIndex;
Layer.confirm('您想?', {
btn: ['完成双选','取消'] //按钮
}, function(index){
var confirm_index = index;
$.ajax({
type:'post',
url:'double_detail/detail/compeletedouble',
data:{id:project_id},
dataType:'json',
success:function(res){
$('#table'+index).bootstrapTable('updateRow', {
index: row_index,
row: {
is_complete: '完成双选',
}
});
Layer.msg(res.msg, {icon: 1});
setTimeout(function(){
Layer.close(confirm_index);
},3000);
},
error:function(error){
console.log(error);
}
});
});
}
},
{
name: 'btn3',
text: '申请人员列表',
title: '申请人员列表',
classname: 'btn btn-xs btn-warning btn-click',
click: function (val, row) {
var double_id = row.id;
Fast.api.open('/teacher/double_detail/detail/apply_list?double_id=' + double_id,'申请人员列表',{area:["80%","80%"]});
var row_index = val.rowIndex;
}
},
]
}
]
]
});
// 为表格1绑定事件
Table.api.bindevent(table1);
},
second: function(index,id) {
var table2 = $("#table2");
table2.bootstrapTable({
url: '/teacher/double_detail/detail/projectChoose' + param,
toolbar: '#toolbar2',
search: false,
columns: [
[
{checkbox: true},
{ field: 'id', title: '序号', operate: false },
{
field: 'project_name', title: '项目名称', operate: false, align: 'left',
},
{ field: 'student_no', title: '负责人学号', operate: false },
{ field: 'username', title: '负责人姓名', operate: false },
{ field: 'mobile', title: '负责人手机号', operate: false },
{ field: 'teacher_name', title: '指导教师姓名', align: 'left', operate: false },
{ field: 'teacher_no', title: '指导教师工号', align: 'left', operate: false },
{ field: 'teacher_mobile', title: '指导教师手机号', align: 'left', operate: false },
{
field: 'operate', title: __('Operate'), operate: false, table: table2,
class: 'nowrap',
events: Table.api.events.operate,
formatter: Table.api.formatter.operate,
buttons: [
{
name: 'btn2',
text: '选择项目',
title: '选择项目',
classname: 'btn btn-xs btn-info btn-click',
click: function (val, row) {
var project_id = row.id;
$("#c-id").val(project_id);
var row_index = val.rowIndex;
Layer.open({
title:'选择项目',
area:["60%","60%"],
type:1,
content:$('#modal2'),
success: function(layer,index){
var lay_index = index;
$(document).on("click","#add-form .btn-update",function(){
var data = $("#add-form").serialize();
console.log("#add-form");
console.log(data);
$.ajax({
type:'post',
url:'/teacher/double_detail/detail/add_apply',
data:data,
dataType:'json',
success:function(res){
Layer.msg(res.msg, {icon: 1});
},
error:function(error){
Layer.msg(res.msg, {icon: 2});
}
});
});
}
});
}
},
{
name: 'btn3',
text: '项目信息',
title: '项目信息',
classname: 'btn btn-xs btn-info btn-click',
click: function (val, row) {
var project_id = row.id;
$("#c-id").val(project_id);
var row_index = val.rowIndex;
Layer.open({
title:'项目信息',
area:["60%","60%"],
type:2,
content:'/teacher/double_detail/detail/project_detail?id=' +project_id,
success: function(layer,index){
}
});
}
}
]
}
]
]
});
},
// 项目管理
// projectPush: function (index, id) {
// // 表格1
// var option = {
// index: index,
// url: '/teacher/double_detail/detail/projectPush' + id + param,
// add_url:'/teacher/double_detail/detail/add_double/' + id + param,
// edit_url:'/teacher/double_detail/detail/edit_double/' + id + param,
// del_url:'/teacher/double_detail/detail/del_double/' + id + param,
// }
// var table = Controller.api.initTable(option);
// },
// 成员变更审核
projectChoose: function (index, id) {
// 表格2 '/teacher/Container/Container_detail/' + id + param
var option = {
index: index,
url: '/teacher/double_detail/detail/' + id + param,
operateButtons: [
// {
// name: 'btn1',
// text: '通过',
// title: '通过',
// classname: 'btn btn-xs btn-success btn-click',
// click: function (val, row) {
// confirm('确定通过这个项目吗?', function () {
// Controller.api.passProject(row.id, table, 3);
// })
// }
// },
// {
// name: 'btn2',
// text: '淘汰',
// title: '淘汰',
// classname: 'btn btn-xs btn-danger btn-click',
// click: function (val, row) {
// confirm('确定淘汰这个项目吗?', function () {
// Controller.api.outProject(row.id, table);
// });
// }
// }
]
}
var table = Controller.api.initTable(option);
},
detail: function(index,id){
var option = {
index: index,
url: '/teacher/double_detail/detail/getDetail' + detail_param,
operateButtons: [
{
name: '_btn1',
text: '审核',
title: '审核',
classname: 'btn btn-xs btn-success btn-click',
click: function (row_index,row) {
console.log(row_index);
console.log(row);
$.ajax({
type:'post',
url:'/teacher/double_detail/detail/pass',
data:{id:row.id},
dataType:'json',
success:function(res){
if(parseInt(res.code) != 0){
$('#table'+index).bootstrapTable('updateRow', {
index: row_index.rowIndex,
row: {
proposer_state:1,
}
});
}
Layer.msg(res.msg, {icon: 1});
},
error:function(error){
console.log(error);
}
});
}
},{
name: '_btn2',
text: '拒绝',
title: '拒绝',
classname: 'btn btn-xs btn-success btn-click',
click: function (row_index,row) {
$.ajax({
type:'post',
url:'/teacher/double_detail/detail/refuse',
data:{id:row.id},
dataType:'json',
success:function(res){
if(parseInt(res.code) != 0){
$('#table').bootstrapTable('updateRow', {
index: row_index.rowIndex,
row: {
proposer_state: 2,
}
});
}
Layer.msg(res.msg, {icon: 1});
},
error:function(error){
console.log(error);
}
});
}
}
]
}
var table = Controller.api.initTable(option);
},
},
add_double:function(){
Form.api.bindevent($("form[role=form]"));
},
edit_double:function(){
Form.api.bindevent($("form[role=form]"));
},
apply_list:function(){
Table.api.init({});
var table = $("#table");
table.bootstrapTable({
url: '/teacher/double_detail/detail/apply_list?double_id='+Config.double_id,
toolbar: '#toolbar' , // toolbar属性用于绑定table自己的工具栏,避免一个页面出现多个工具栏
// 是否显示快速搜索(搜索框)
search: false,
// 是否显示切换视图按钮
showToggle: false,
queryParams: function (params) {
// 初次进入页面,设置默认过滤值
// if ('{}' === params.filter) {
// var filter = params.filter ? JSON.parse(params.filter) : {};
// var op = params.op ? JSON.parse(params.op) : {};
// op.project_type = '=' + type;
// params.filter = JSON.stringify(filter);
// params.op = JSON.stringify(op);
// }
// return params;
},
columns: [
[
{ field: 'id', title: '序号', operate: false },
{
field: 'username', title: '姓名', operate: false, align: 'left',
},
{ field: 'student_no', title: '学号', operate: false },
{ field: 'collage_name', title: '学院', operate: false },
{ field: 'specialty_name', title: '专业', align: 'left', operate: false },
{ field: 'mobile', title: '手机号', align: 'left', operate: false },
{ field: 'proposer_details', title: '申请原因', align: 'left', operate: false },
{ field: 'createtime', title: '申请时间', align: 'left', operate: false },
{ field: 'sort', title: '参与顺序', align: 'left', operate: false },
{ field: 'proposer_state', title: '状态', align: 'left', operate: false,formatter: function(index,row){
return row.proposer_state ==0 ? '待审核' : '已审核';
}
},
{
field: 'operate', title: __('Operate'), operate: false, table: table,
class: 'nowrap',
events: Table.api.events.operate,
formatter: Table.api.formatter.operate,
buttons: [
{
name: 'btn2',
text: '审核',
title: '审核',
classname: 'btn btn-xs btn-info btn-click',
click: function (val, row) {
var id = row.id;
var row_index = val.rowIndex;
Layer.confirm('确定通过?', {
btn: ['通过审核','取消'] //按钮
}, function(layer_index){
$.ajax({
type:'post',
url:'double_detail/detail/passapply',
data:{id:id},
dataType:'json',
success:function(res){
$('#table').bootstrapTable('updateRow', {
index: row_index,
row: {
proposer_state: '已审核',
}
});
Layer.msg(res.msg);
Layer.close(layer_index);
},
error:function(error){
console.log(error);
}
});
});
}
},
]
}
]
]
});
// 为表格1绑定事件
Table.api.bindevent(table);
return table;
},
api: $.extend(projectApi, {
/**
* 初始化table
* @param {Number} option.index 显示表格对应的下标(table和toolbar的id命名都以下标结尾)
* @param {Array} option.operateButtons 操作栏按钮
*/
initTable: function (option) {
var table = $('#table' + option.index);
switch (option.index) {
case 1:
Table.api.init({
extend: {
index_url: option.url,
add_url:option.add_url,
edit_url: option.edit_url,
del_url:option.del_url
}
});
option.column = option.column || []
table.bootstrapTable({
url: option.url,
toolbar: '#toolbar' + option.index, // toolbar属性用于绑定table自己的工具栏,避免一个页面出现多个工具栏
// 是否显示快速搜索(搜索框)
search: false,
// 是否显示切换视图按钮
showToggle: false,
queryParams: function (params) {
// 初次进入页面,设置默认过滤值
// if ('{}' === params.filter) {
// var filter = params.filter ? JSON.parse(params.filter) : {};
// var op = params.op ? JSON.parse(params.op) : {};
// op.project_type = '=' + type;
// params.filter = JSON.stringify(filter);
// params.op = JSON.stringify(op);
// }
// return params;
},
columns: [
[
{checkbox: true},
{ field: 'id', title: '序号', operate: false },
{
field: 'project_name', title: '项目名称', operate: false, align: 'left',
},
{ field: 'createtime_text', title: '发布时间', operate: false },
{ field: 'count', title: '申请学生数', operate: false },
{ field: 'is_complete', title: '完成情况', align: 'left', operate: false },
].concat(option.column).concat([
{
field: 'operate', title: __('Operate'), operate: false, table: table,
class: 'nowrap',
events: Table.api.events.operate,
formatter: Table.api.formatter.operate,
buttons: [
{
name: 'btn2',
text: '完成双选',
title: '完成双选',
classname: 'btn btn-xs btn-info btn-click',
click: function (val, row) {
var project_id = row.id;
var row_index = val.rowIndex;
Layer.confirm('您想?', {
btn: ['完成双选','取消'] //按钮
}, function(index){
var confirm_index = index;
$.ajax({
type:'post',
url:'double_detail/detail/compeletedouble',
data:{id:project_id},
dataType:'json',
success:function(res){
$('#table'+index).bootstrapTable('updateRow', {
index: row_index,
row: {
is_complete: '完成双选',
}
});
Layer.msg(res.msg, {icon: 1});
setTimeout(function(){
Layer.close(confirm_index);
},3000);
},
error:function(error){
console.log(error);
}
});
});
}
},
{
name: 'btn3',
text: '申请人员列表',
title: '申请人员列表',
classname: 'btn btn-xs btn-warning btn-click',
click: function (val, row) {
var double_id = row.id;
Fast.api.open('/teacher/double_detail/detail/apply_list?double_id=' + double_id,'申请人员列表',{area:["80%","80%"]});
var row_index = val.rowIndex;
}
},
]
}
])
]
});
break;
case 2:
Table.api.init({
extend: {
index_url: option.url,
}
});
option.column = option.column || []
table.bootstrapTable({
url: option.url,
toolbar: '#toolbar' + option.index, // toolbar属性用于绑定table自己的工具栏,避免一个页面出现多个工具栏
// 是否显示快速搜索(搜索框)
search: false,
// 是否显示切换视图按钮
showToggle: false,
queryParams: function (params) {
console.log(params);
// 初次进入页面,设置默认过滤值
if ('{}' === params.filter) {
var filter = params.filter ? JSON.parse(params.filter) : {};
var op = params.op ? JSON.parse(params.op) : {};
filter.project_type_id = $('.nav-tabs .active a').data('value');
op.project_type_id = '=';
params.filter = JSON.stringify(filter);
params.op = JSON.stringify(op);
}
return params;
},
columns: [
[
{checkbox: true},
{ field: 'id', title: '序号', operate: false },
{
field: 'project_name', title: '项目名称', operate: false, align: 'left',
},
{ field: 'student_no', title: '负责人学号', operate: false },
{ field: 'username', title: '负责人姓名', operate: false },
{ field: 'mobile', title: '负责人手机号', operate: false },
{ field: 'teacher_name', title: '指导教师姓名', align: 'left', operate: false },
{ field: 'teacher_no', title: '指导教师工号', align: 'left', operate: false },
{ field: 'teacher_mobile', title: '指导教师手机号', align: 'left', operate: false },
{
field: 'operate', title: __('Operate'), operate: false, table: table,
class: 'nowrap',
events: Table.api.events.operate,
formatter: Table.api.formatter.operate,
buttons: [
{
name: 'btn2',
text: '选择项目',
title: '选择项目',
classname: 'btn btn-xs btn-info btn-click',
click: function (val, row) {
var project_id = row.id;
$("#c-id").val(project_id);
var row_index = val.rowIndex;
Layer.open({
title:'选择项目',
area:["60%","60%"],
type:1,
content:$('#modal2'),
success: function(layer,index){
var lay_index = index;
$(document).on("click","#add-form .btn-update",function(){
var data = $("#add-form").serialize();
console.log("#add-form");
console.log(data);
$.ajax({
type:'post',
url:'/teacher/double_detail/detail/add_apply',
data:data,
dataType:'json',
success:function(res){
Layer.msg(res.msg, {icon: 1});
},
error:function(error){
Layer.msg(res.msg, {icon: 2});
}
});
});
}
});
}
},
{
name: 'btn3',
text: '项目信息',
title: '项目信息',
classname: 'btn btn-xs btn-info btn-click',
click: function (val, row) {
var project_id = row.id;
$("#c-id").val(project_id);
var row_index = val.rowIndex;
Layer.open({
title:'项目信息',
area:["60%","60%"],
type:2,
content:'/teacher/double_detail/detail/project_detail?id=' +project_id,
success: function(layer,index){
}
});
}
}
]
}
]
]
});
break;
default:
option.column = option.column || []
table.bootstrapTable({
url: option.url,
toolbar: '#toolbar' + option.index, // toolbar属性用于绑定table自己的工具栏,避免一个页面出现多个工具栏
// 是否显示快速搜索(搜索框)
search: false,
// 是否显示切换视图按钮
showToggle: false,
columns: [
[
{checkbox: true},
{ field: 'id', title: '序号', operate: false },
{ field: 'project_name', title: '项目名称', operate: false },
{ field: 'username', title: '申请人', operate: false },
{ field: 'proposer_details', title: '申请理由', operate: false },
{ field: 'mobile', title: '申请人手机号', operate: false },
{ field: 'proposer_state', title: '申请状态', operate: false, formatter:function(val,row){
switch(parseInt(row.proposer_state)){
case 1 :
return '通过';
break;
case 2 :
return '拒绝';
break;
default:
return '申请中';
}
}
},
// {
// field: 'teacher_info', title: '提交情况', formatter: function (val, row) {
// return (!row.mid_attachment) ?
// '<span class="text-danger">未提交</span>' :
// '<span class="text-success">已提交</span>'
// }, operate: false
// },
// { field: 'teacher_info', title: '中期检查结果', operate: false },
].concat(option.column).concat([
{
field: 'operate', title: __('Operate'), operate: false, table: table,
class: 'nowrap',
formatter: Table.api.formatter.buttons,
buttons: [
].concat(option.operateButtons || [])
}
])
]
});
}
// 为表格1绑定事件
Table.api.bindevent(table);
return table;
},
updateTableData:function(){
},
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
})
}
/**
* 询问弹窗
* @param {string} msg 询问文字
* @param {function} callback 确认回调
*/
function confirm(msg, callback) {
layer.confirm(msg, {
btn: ['确定', '取消'] //按钮
}, function (index) {
callback && callback()
layer.close(index)
});
}
return Controller
})