management.js
18.2 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
define(['jquery', 'bootstrap', 'backend', 'form', 'table', '../project_common/project-api'], function ($, undefined, Backend, Form, Table, projectApi) {
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');
});
// 批量通过
$(document).on('click', '.btn-multiPass', function () {
$("#mome_text").val('');
// 下一个评审阶段编号
var status = this.dataset.check_stage;
if (('undefined' === typeof status) || ('' === status)) { throw new Error('审核进度参数不能为空') }
layer.open({
type: 1,
title:['审核意见', 'background-color:#2C3E50;color:#fff;'],
skin: 'demo-class', //样式类名
closeBtn: 0, //不显示关闭按钮
anim: 2,
shadeClose: true, //开启遮罩关闭
area:["70%","70%"],
content: $("#memo"),
btn: ['确定通过', '取消'],
yes:function(val,row){
var memo = $("#mome_text").val();
var table = $( ('#table' + ($('.nav-tabs .active').index() + 1)) )
var ids = Table.api.selectedids(table);
if ('array' !== typeof ids) {
ids = (''+ids).split(',');
}
if (!ids.length) {
throw new Error('id不能为空');
}
var data = {list:JSON.stringify(ids.map(function (id) {
var editItem = {id: id, status: status,memo:memo,verify_stage:1};
// 学校审核完,进入下一个评审阶段(项目结题除外)
if (3 === Number(status) && (2 != Config.review_stage)) {
editItem.review_stage = Number(Config.review_stage) + 1;
// editItem.project_approval_status = 3;
}
return editItem;
}))};
$.ajax({
url: '/school/project_common/management/editProject',
method: 'POST',
data: data,
success: function (res) {
if (1 === res.code) {
Toastr.success('操作成功')
layer.close(val);
table.bootstrapTable("refresh");
} else {
Toastr.error(res.msg);
}
}
});
},
});
// confirm('确定通过选中的项目吗?', function () {
// var table = $( ('#table' + ($('.nav-tabs .active').index() + 1)) )
// var ids = Table.api.selectedids(table)
// Controller.api.passProject(ids, table, status)
// })
})
// 批量淘汰
$(document).on('click', '.btn-multiOut', function () {
$("#mome_text").val('');
layer.open({
type: 1,
title:['审核意见', 'background-color:#2C3E50;color:#fff;'],
skin: 'demo-class', //样式类名
closeBtn: 0, //不显示关闭按钮
anim: 2,
shadeClose: true, //开启遮罩关闭
area:["70%","70%"],
content: $("#memo"),
btn: ['确定淘汰', '取消'],
yes:function(val,row){
var memo = $("#mome_text").val();
var table = $( ('#table' + ($('.nav-tabs .active').index() + 1)) )
var ids = Table.api.selectedids(table);
if ('array' !== typeof ids) {
ids = (''+ids).split(',');
}
if (!ids.length) {
throw new Error('id不能为空');
}
var data = {list:JSON.stringify(ids.map(function (id) {return { id: id, project_status: 1,memo:memo,verify_stage:1}}))};
$.ajax({
url: '/school/project_common/management/editProject',
method: 'POST',
data: data,
success: function (res) {
if (1 === res.code) {
Toastr.success('操作成功')
layer.close(val);
table.bootstrapTable("refresh");
} else {
Toastr.error(res.msg);
}
}
});
// var res = Controller.api.outProject(ids, table,memo,val);
},
});
// confirm('确定淘汰选中的项目吗?', function () {
// var table = $( ('#table' + ($('.nav-tabs .active').index() + 1)) )
// var ids = Table.api.selectedids(table)
// Controller.api.outProject(ids, table)
// })
})
//必须默认触发shown.bs.tab事件
$('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");
},
table: {
// 项目管理
all: function (index, id) {
// 表格1
var option = {
index: index,
url: '/school/project_mid_check/management/' + id,
column: Controller.api.getReviewColumns(),
operateButtons: [
]
}
var table = Controller.api.initTable(option)
},
// 学校未审核
schoolNoAudit: function (index, id) {
console.log(Config.login_type);
// 表格2
if(Config.login_type ===0 ){
var option = {
index: index,
url: '/school/project_mid_check/management/' + id,
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)
// })
// }
// }
]
}
}else{
var option = {
index: index,
url: '/school/project_mid_check/management/' + id,
operateButtons: []
}
}
var table = Controller.api.initTable(option)
},
// 学院未审核
collegeNoAudit: function (index, id) {
var option = {
index: index,
url: '/school/project_mid_check/management/' + id,
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, 2)
// })
// }
// },
// {
// 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)
},
// 学生填报不完整
incomplete: function (index, id) {
var option = {
index: index,
url: '/school/project_mid_check/management/' + id,
}
var table = Controller.api.initTable(option)
},
// 淘汰项目
out: function (index, id) {
var option = {
index: index,
url: '/school/project_mid_check/management/' + id,
operateButtons: [
{
name: 'btn1',
text: '撤销',
title: '撤销',
classname: 'btn btn-xs btn-success btn-click',
click: function (val, row) {
confirm('确定恢复这个项目吗?', function () {
Controller.api.editProject({
list: JSON.stringify([
{ id: row.id, project_status: 0,verify_stage:1,revoke:1}
])
}, table)
})
}
}
]
}
var table = Controller.api.initTable(option)
}
},
api: $.extend(projectApi, {
/**
* 初始化table
* @param {Number} option.index 显示表格对应的下标(table和toolbar的id命名都以下标结尾)
* @param {Array} option.operateButtons 操作栏按钮
*/
initTable: function (option) {
var table = $('#table' + option.index);
option.column = option.column || []
table.bootstrapTable({
url: option.url,
toolbar: '#toolbar' + option.index, // toolbar属性用于绑定table自己的工具栏,避免一个页面出现多个工具栏
// 是否显示快速搜索(搜索框)
search: false,
// 是否显示切换视图按钮
showToggle: false,
searchFormVisible: true,
searchFormTemplate: 'search_tpl',
columns: [
[
{checkbox: true},
{ field: 'id', title: '序号', operate: false },
// { field: 'id', title: '完整度', operate: false },
{
field: 'project_info', title: '项目名称及编号', operate: false, align: 'left', formatter: function (val, row) {
return row.project_name + '<br/>' + (row.project_no ? row.project_no : '暂无');
}
},
{ field: 'memberCount', title: '团队人数', operate: false },
{ field: 'project_type_name', title: '项目分类', operate: false },
{ field: 'college_name', title: '项目所属学院', operate: false },
{
field: 'user_info', title: '负责人姓名/学号', align: 'left', operate: false, formatter: function (val, row) {
return row.nickname + '<br/>' + (row.student_no || '-')
}
},
{
field: 'user_from', title: '负责人学院/专业', align: 'left', operate: false, formatter: function (val, row) {
return row.college_name + '<br>' + (row.major_name || '-')
}
},
// { field: 'teacher_info', title: '指导教师', operate: false },
{ field: 'project_teachers', title: '指导教师', formatter: function (val) {
var teachersName = '';
for (var p in val) {
teachersName += (val[p].username + '<br>')
}
return teachersName;
}
},
{
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: 'project_metaphase_status', title: '审核状态', operate: false, formatter: function(index,row){
var project_metaphase_status = parseInt(row.project_metaphase_status);
switch (project_metaphase_status) {
case 3:
return '已审核';
default :
return '审核中';
}
}
},
].concat(option.column).concat([
{
field: 'operate', title: __('Operate'), operate: false, table: table,
class: 'nowrap',
formatter: Table.api.formatter.buttons,
buttons: [
{
name: '_btn1',
text: '查看中期项目',
title: '查看中期项目',
classname: 'btn btn-xs btn-info btn-addtabs',
url: function (val) {
return '/school/project_common/project_view/index?review_stage=1&ids=' + val.id
}
},
{
name: '_btn2',
text: '查看审核信息',
title: '查看审核信息',
classname: 'btn btn-xs btn-info btn-addtabs',
url: function (val) {
return '/school/project_common/judge/verify_list?review_stage=1®ister_id=' + val.id
}
}
].concat(option.operateButtons || [])
}
])
]
});
// 为表格1绑定事件
Table.api.bindevent(table);
return table
},
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
})