project-api.js
4.4 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
define([], function() {
'use strict';
/**
* 项目管理相关api
*/
var projectApi = {
/**
* 刷新table
*/
refreshTable: function (table) {
table.trigger("uncheckbox");
table.bootstrapTable("refresh");
},
/**
* 修改项目状态
* @param {object} data
* @param {function} success
*/
editProject: function (data, table, success) {
var _me = this
$.ajax({
url: '/school/project_common/management/editProject',
method: 'POST',
data: data,
success: function (res) {
if (1 === res.code) {
success && success()
_me.refreshTable(table)
} else {
Toastr.error(res.msg)
}
}
})
},
/**
* 驳回项目
* @param {array|string} ids 驳回项目的id
* @param {object} table 当前的表格对象
*/
backProject: function (ids, table) {
ids = this.checkIds(ids)
this.editProject({
list: JSON.stringify(
ids.map(function (id) {
return { id: id, project_status: 2, check_stage: 0, review_stage: 0 }
})
)
}, table)
},
/**
* 通过项目
* @param {array|string} ids 通过项目的id
* @param {object} table 当前的表格对象
* @param {number|string} status 审核进度(0:教师审核;1:学院审核;2:学校审核;3:全部审核完)
*/
passProject: function (ids, table, status) {
if (('undefined' === typeof status) || ('' === status)) { throw new Error('审核进度参数不能为空') }
ids = this.checkIds(ids)
this.editProject({
list: JSON.stringify(
ids.map(function (id) {
var editItem = {id: id, status: status};
// 学校审核完,进入下一个评审阶段(项目结题除外)
if (3 === Number(status) && (2 != Config.review_stage)) {
editItem.review_stage = Number(Config.review_stage) + 1;
// editItem.project_approval_status = 3;
}
return editItem;
})
)
}, table)
},
/**
* 淘汰项目
*/
outProject: function (ids, table) {
ids = this.checkIds(ids)
this.editProject({
list: JSON.stringify(
ids.map(function (id) {
return { id: id, project_status: 1 }
})
)
}, table)
},
/**
* 延期项目
*/
delayProject: function (ids, table) {
ids = this.checkIds(ids)
this.editProject({
list: JSON.stringify(
ids.map(function (id) {
return { id: id, project_status: 3,verify_stage:2}
})
)
}, table)
},
/**
* 把传入的ids转为符合规则格式
* @return {array|string}
*/
checkIds: function (ids) {
if ('array' !== typeof ids) {
ids = (''+ids).split(',')
}
if (!ids.length) {
throw new Error('id不能为空')
}
return ids
},
/**
* 构建表格评审列数据
* @return {Array}
*/
getReviewColumns: function () {
var reviewStageIds = Config.review_stage_ids || []
return reviewStageIds.map(function (v, i) {
return {
field: ('review' + v), title: ('评审' + (i + 1)), operate: false, formatter: function (val, row) {
var reviewScores = row.review_scores || []
// 评审结果为空或者为'-'时,显示'-'
return (('-' !== reviewScores[v]) && ('undefined' !== typeof reviewScores[v])) ? Number(reviewScores[v]) : '-'
}
}
})
}
}
return projectApi
});