/**
|
* 系统管理--用户管理的单例对象
|
*/
|
let RegistrationRecord = {
|
id: "managerTable",//表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
let language =$("#language").val()
|
/**
|
* 初始化表格的列
|
*/
|
RegistrationRecord.initColumn = function () {
|
let columns = [
|
{field: 'selectItem', checkbox: true},
|
{title: '序号', field: 'id', visible: true, align: 'center', valign: 'middle'},
|
{title: '购买用户', field: 'userName', align: 'center', valign: 'middle'},
|
{title: '联系方式', field: 'phone', align: 'center', valign: 'middle'},
|
{title: '购课学员', field: 'studentName', align: 'center', valign: 'middle'},
|
{title: '报名时间', field: 'insertTime', align: 'center', valign: 'middle'},
|
// {title: '总课时数', field: 'totalClassHours', align: 'center', valign: 'middle'},
|
// {title: '剩余课时数', field: 'laveClassHours', align: 'center', valign: 'middle',rowStyle: function(row, index) {
|
// // 参数说明:
|
// //row, 行,row.xxx,能获取某个字段的值
|
// //index,索引,第几行
|
//
|
// // 逻辑判断
|
// // .....
|
// return {"background-color":'rgba(208,9,9,0.7)'};
|
// }
|
// },
|
// {title: '已上课时数', field: 'already', align: 'center', valign: 'middle'},
|
{title: '请假次数', field: 'absencesNumber', align: 'center', valign: 'middle'},
|
{title: '状态', field: 'status', align: 'center', valign: 'middle',
|
formatter: function (v) {
|
switch (v) {
|
case 1:
|
return '正常';
|
case 2:
|
return '<a href="#" onclick="">已退课-查看凭证</a>';
|
}
|
}
|
}
|
];
|
return columns;
|
};
|
|
/**
|
* 检查是否选中
|
*/
|
RegistrationRecord.check = function () {
|
let selected = $('#' + this.id).bootstrapTable('getSelections');
|
if (selected.length == 0) {
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
} else {
|
RegistrationRecord.seItem = selected[0];
|
RegistrationRecord.seItem1 = selected;
|
|
return true;
|
}
|
};
|
|
/**
|
* 上课记录
|
*/
|
RegistrationRecord.classRecord = function () {
|
let index = layer.open({
|
type: 2,
|
title: '上课记录',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/coursePackage/openClassRecord1?id=' + $('#id').val()
|
});
|
this.layerIndex = index;
|
};
|
|
|
RegistrationRecord.holiClass = function () {
|
if (this.check()) {
|
var ids = RegistrationRecord.seItem1.map(function(item) {
|
return item.id;
|
}).join(",");
|
let index = layer.open({
|
type: 2,
|
title: '报名信息',
|
area: ['50%', '50%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tStudent/TTT?ids='+ids+'&id='+$('#id').val()
|
});
|
this.layerIndex = index;
|
}
|
};
|
|
RegistrationRecord.transClass = function () {
|
if (this.check()) {
|
var ids = RegistrationRecord.seItem1.map(function(item) {
|
return item.id;
|
}).join(",");
|
let index = layer.open({
|
type: 2,
|
title: '报名信息',
|
area: ['50%', '50%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tStudent/trans?ids='+ids+'&id='+$('#id').val()
|
});
|
this.layerIndex = index;
|
}
|
};
|
|
|
/**
|
* 点击修改按钮时
|
* @param userId 管理员id
|
*/
|
RegistrationRecord.dropClass = function () {
|
if (this.check()) {
|
if(ClassRecord.seItem.status == 2){
|
Feng.error("不能重复退课");
|
return
|
}
|
let htmlStr =
|
'<div class="form-horizontal">' +
|
' <div class="col-sm-11">' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-8 control-label">课程名称:' + $("#name").text() + '</label>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-8 control-label">用户姓名:' + ClassRecord.seItem.userName + '</label>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-8 control-label">学员姓名:' + ClassRecord.seItem.studentName + '</label>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-8 control-label">*上传凭证:</label>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <div class="col-sm-8">\n' +
|
' <img id="certificate" src="" style="height: 100px;">' +
|
' <input type="file" id="file" style="display: none;"/>' +
|
' <button onclick="uploadImgs()" style="width: 20px;padding: 10px; color: white;background-color: #0d8ddb;border-radius: 5px;"> 上传 </button>' +
|
' </div>\n' +
|
' </div>' +
|
' </div>' +
|
'</div>';
|
layer.open({
|
type: 1
|
, title: '退课'
|
, area: ['50%', '50%']
|
, offset: 'auto' //具体配置参考:http://www.layui.com/doc/modules/layer.html#offset
|
, id: 'layerDemo' //防止重复弹出cge
|
, content: htmlStr
|
, btn: ['保存', '关闭']
|
, btnAlign: 'c' //按钮居中
|
, shade: 0.5 //不显示遮罩
|
, yes: function () {
|
let certificate = $('#certificate').attr('img');
|
if(null == certificate || '' == certificate){
|
Feng.error("请上传凭证图片");
|
return
|
}
|
let ajax = new $ax(Feng.ctxPath + "/coursePackage/dropTheClass", function (res) {
|
if(res.code == 200){
|
Feng.success("退课成功!");
|
layer.closeAll();
|
RegistrationRecord.table.refresh();
|
}else{
|
Feng.error(res.msg);
|
}
|
}, function (data) {
|
Feng.error("退课失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("coursePackagePaymentId", ClassRecord.seItem.id);
|
ajax.set("certificate", certificate);
|
ajax.start();
|
},
|
});
|
|
$('#file').on('change', function () {
|
var formData = new FormData() //创建一个forData
|
formData.append('file', $('#file')[0].files[0]) //把file添加进去 name命名为img
|
layer.load(); //上传loading
|
$.ajax({
|
url: Feng.ctxPath + '/mgr/uploadImg',
|
data: formData,
|
type: "POST",
|
async: true,
|
cache: false,
|
contentType: false,
|
processData: false,
|
success: function(res) {
|
layer.closeAll('loading'); //关闭loading
|
$('#file').val('');
|
$('#certificate').attr('src', res);
|
}
|
})
|
})
|
}
|
};
|
|
|
|
function uploadImgs(){
|
$('#file').click();
|
}
|
|
|
/**
|
* 删除用户
|
*/
|
RegistrationRecord.makeUpMissedLessons = function () {
|
if (this.check()) {
|
let operation = function(){
|
let ajax = new $ax(Feng.ctxPath + "/coursePackage/makeUpMissedLessons", function () {
|
Feng.success("补课成功!");
|
RegistrationRecord.table.refresh();
|
}, function (data) {
|
Feng.error("补课失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id", RegistrationRecord.seItem.id);
|
ajax.start();
|
};
|
|
Feng.confirm("是否补课",operation);
|
}
|
};
|
|
|
|
|
RegistrationRecord.resetSearch = function () {
|
$("#userName").val("");
|
$("#studentName").val("");
|
RegistrationRecord.search();
|
}
|
|
RegistrationRecord.search = function () {
|
let queryData = {};
|
queryData['userName'] = $("#userName").val();
|
queryData['studentName'] = $("#studentName").val();
|
queryData['id'] = $('#id').val();
|
RegistrationRecord.table.refresh({query: queryData});
|
}
|
|
|
$(function () {
|
let defaultColunms = RegistrationRecord.initColumn();
|
let table = new BSTable(RegistrationRecord.id, "/coursePackage/queryRegistrationRecord", defaultColunms);
|
// 设置物理分页server(逻辑分页client)
|
table.setPaginationType("server");
|
table.setQueryParams({
|
id: $('#id').val()
|
})
|
RegistrationRecord.table = table.init();
|
});
|