CreateGradeApe.js
8.8 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
//*
// 班级管理模块
// */
import Loger from "../Loger";
import Ape from "./Ape";
import $ from "jquery";
import ClassDataProxy from "proxy/ClassDataProxy";
import ErrorApe from "./ErrorApe";
let loger = Loger.getLoger('PC-CreateGradeApe');
const adminListTit = `<table width="100%" align="center" cellpadding="0" cellspacing="0" border="0" class="t_box">
<tbody>
<tr align="center" height="44" class="tr_center" bgcolor="#fff" bordercolor="#e6e6e6">
<th width="8%" class="tr_center">
登录名
</th>
<th width="8%" class="tr_center">
姓名
</th>
<th width="8%" class="tr_center">
科目
</th>
<th width="8%" class="tr_center">
上课总数
</th>
<th width="8%" class="tr_center">
最新约课
</th>
<th width="10%" class="tr_center">
操作
</th>
</tr>
`;
//管理首页
const adminList = `<tr align="center" bgcolor="#FFFFFF" height="44" bordercolor="#e6e6e6">
<td width="8%" class="tr_main tr_mainLeft">{_loginName}</td>
<td width="8%" class="tr_main">{_userName}</td>
<td width="8%" class="tr_main">{_course}</td>
<td width="8%" class="tr_main">{_totalNmu}</td>
<td width="8%" class="tr_main">{_latest}</td>
<td width="10%" class="tr_main tr_mainRight" align="center">
<a id="{_removeInd}" class="classHandlePort deleteClass" data="{_aboutMsg}" href="###">删除</a>
<a id="{_joinInd}" class="classHandlePort" href="###" data="{_aboutMsg}">查看约课信息</a>
</td>
</tr>
`;
const adminListEnd = `</tbody></table>`;
class CreateGradeApe extends Ape {
constructor() {
super();
this.pageNo = 0;
this.presentInd = 1;
this.addEvent();
this.init();
}
init() {
//班级管理
$('#addClassBtn').on('click',this._addClassBtnHandler.bind(this));//创建班级按钮
$('#manageClassBtn').on('click',this._manageClassBtnHandler.bind(this));//创建班级按钮
$('#createGradeA').on('click',this._closeCreateGradeHandler.bind(this));//关闭新建班级课堂
$('#manageClassA').on('click',this._closemanageClassHandler.bind(this));//关闭班级管理课堂
$('#classHandlerHomePage2').on('click',this._homePageHandler.bind(this));//首页
$('#classHandlerUpPage2').on('click',this._upPageHandler.bind(this));//上页
$('#classHandlerDownPage2').on('click',this._downPageHandler.bind(this));//下页
$('#classHandlerEndPage2').on('click',this._endPageHandler.bind(this));//尾页
$('#classHandlerSpecificPage2').on('click',this._assignPageHandler.bind(this));//指定页
// $('#courseContent2').on('click','.deleteClass',this._deleteClass.bind(this));//删除课堂
}
addEvent() {
}
//首页
_homePageHandler(){
this.presentInd = 1;
this.userAdminHandler(this.presentInd);
}
//上页
_upPageHandler(){
if(this.presentInd >1){
this.presentInd--;
this.userAdminHandler(this.presentInd);
}
}
//下页
_downPageHandler(){
if(this.presentInd < this.pageNo){
this.presentInd++;
this.userAdminHandler(this.presentInd);
}
}
//尾页
_endPageHandler(){
this.presentInd = this.pageNo;
this.userAdminHandler(this.presentInd);
}
//指定页
_assignPageHandler(){
let inputVal = $('#classHandlerPageInfoInput2').val();
if(parseInt(inputVal) <= this.pageNo || parseInt(inputVal) >= 1 ){
this.userAdminHandler(parseInt(inputVal));
}
}
//用户管理 创建用户界面
userAdminHandler(ind){
let _url = ClassDataProxy.locationProtocol + ClassDataProxy.locationProt + '/users/getUser';
let that = this;
let dataInfo = {
siteId : ClassDataProxy.siteId,
}
$.ajax({
type: "POST",
url: _url,
timeout:5000,
data:dataInfo,
headers: {siteId:ClassDataProxy.siteId,
pageno:7,
'page':ind,
'token':'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlhXQnJlRU00T0swYTVqUUIyUTFicGtObHlxOUFWbXZkIiwibmFtZSI6ImFkbWluIiwiY29kZSI6MSwiaWF0IjoxNTAzNDUxODU0LCJleHAiOjIyODEwNTE4NTR9.3kTVzKd_jbP7l69nxOpNaFeSjVnnjZkagYMzRB8fjNo'},
success:function(_data){
//获取课堂数据
if(_data && _data.code == 200){
//loger.log(_data,'班级界面用户列表数据')
that._gainUserClassData(_data.returnData.data);
}
},
error:function(error){
//alert('直播数据获取失败')
that._gainUserClassDataErr();
loger.log(error,'班级数据获取失败')
}
})
}
_gainUserClassData(_data){
let _dataList = _data.users;
let courseContent = $('#courseContent2');
courseContent.empty();
let count = _data.count;
let page = _data.page;
let pageno = _data.pageno;
let pagenum = Math.ceil(count / pageno);
this.pageNo = pagenum;
$('#classHandlerPageMsg2').html('第'+page+'页/共'+pagenum+'页,有'+count+'个记录');
courseContent.append(adminListTit);
if(_dataList){
if(count <= 7){
$('#classHandlerPageBox2').hide();
}
for(let i = 0;i<_dataList.length;i++){
let _adminList = this._format(adminList,{
_loginName : _dataList[i].loginName,
_userName : _dataList[i].userName,
_course : '暂无',
_totalNmu : '2',
_latest : '1',
_removeInd : 'classDoc'+i,
_joinInd : 'classMedia'+i,
_aboutMsg : _dataList[i].id
})
courseContent.append(_adminList);
}
courseContent.append(adminListEnd);
}
}
_gainUserClassDataErr(){
let courseContent = $('#courseContent2');
courseContent.empty();
courseContent.append(adminListTit);
let _adminList = '<tr align="center" bgcolor="#FFFFFF" height="44" bordercolor="#e6e6e6">' +
'<td class="tr_main tr_mainNone">' +
'该课堂暂无班级数据~'+
'</td>>'+
'</tr>'
courseContent.append(_adminList);
courseContent.append(adminListEnd);
}
_deleteClass(evt){
let id = $(evt.target).attr('data');
loger.log('删除',id)
let _url = ClassDataProxy.locationProtocol + ClassDataProxy.locationProt + '/users/delUserByUserId/' + id;
let that = this;
$.ajax({
type: "PUT",
url: _url,
headers: {siteId:ClassDataProxy.siteId,
'token':'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlhXQnJlRU00T0swYTVqUUIyUTFicGtObHlxOUFWbXZkIiwibmFtZSI6ImFkbWluIiwiY29kZSI6MSwiaWF0IjoxNTAzNDUxODU0LCJleHAiOjIyODEwNTE4NTR9.3kTVzKd_jbP7l69nxOpNaFeSjVnnjZkagYMzRB8fjNo'},
success:function(_data){
loger.log('删除成功',_data)
if(_data && _data.code == 200){
// that.detailPage();
// that._gainClassData(_data.returnData.data);
}
},
error:function(error){
loger.log(error,'失败')
}
})
}
//创建班级
_addClassBtnHandler(){
$('#createGradeBox').show();
}
//管理班级
_manageClassBtnHandler(){
$('#manageClassBox').show();
}
//关闭创建班级
_closeCreateGradeHandler(){
$('#createGradeBox').hide();
}
//关闭班级管理
_closemanageClassHandler(){
$('#manageClassBox').hide();
}
//工具类
_format(str, obj) {
return str.replace(/\{(\w+)\}/g, function (match, group, index) {
return obj[group];
});
};
}
export default CreateGradeApe;