/** * 系统管理--用户管理的单例对象 */ 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', formatter: function (value, row) { if (row.status ==7){ return '
' + value + '
'; } else { return value; } }}, {title: '购买用户', field: 'userName', align: 'center', valign: 'middle', formatter: function (value, row) { if (row.status ==7){ return '
' + value + '
'; } else { return value; } }}, {title: '联系方式', field: 'phone', align: 'center', valign: 'middle', formatter: function (value, row) { if (row.status ==7){ return '
' + value + '
'; } else { return value; } }}, {title: '购课学员', field: 'studentName', align: 'center', valign: 'middle', formatter: function (value, row) { if (row.status ==7){ return '
' + value + '
'; } else { return value; } }}, {title: '报名时间', field: 'insertTime', align: 'center', valign: 'middle', formatter: function (value, row) { if (row.status ==7){ return '
' + value + '
'; } else { return value; } }}, {title: '总课时数', field: 'totalClassHours', align: 'center', valign: 'middle', formatter: function (value, row) { if (row.status ==7){ return '
' + value + '
'; } else { return value; } }}, { title: '剩余课时数', field: 'laveClassHours', align: 'center', valign: 'middle', formatter: function (value, row) { if (value < 3) { return '
' + value + '
'; }else if (row.status ==7){ return '
' + value + '
'; } else { return value; } } }, { title: '已上课时数', field: 'already', align: 'center', valign: 'middle', formatter: function (value, row) { if (row.status ==7){ return '
' + value + '
'; } else { return value; } } // , // formatter: function (value, row) { // var totalClassHours = row.totalClassHours; // var laveClassHours = row.laveClassHours; // var alreadyClassHours = totalClassHours - laveClassHours; // return alreadyClassHours; // } }, {title: '请假次数', field: 'absencesNumber', align: 'center', valign: 'middle', formatter: function (value, row) { if (row.status ==7){ return '
' + value + '
'; } else { return value; } }}, { title: '状态', field: 'status', align: 'center', valign: 'middle', formatter: function (v) { switch (v) { case 1: return '正常'; case 2: return '已退课'; case 3: return '换课中'; case 4: return '申请退费中'; case 5: return '已转移'; case 6: return '已赠课' case 7: return '体验购课'; default: return ''; } } } ]; return columns; }; /** * 检查是否选中 */ RegistrationRecord.check = function () { let selected = $('#' + this.id).bootstrapTable('getSelections'); if (selected.length > 1) { Feng.info("只能选中表格中的一条记录!"); return false; } else { RegistrationRecord.seItem = selected[0]; RegistrationRecord.seItem1 = selected; return true; } }; RegistrationRecord.check1 = 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/openClassRecord?id=' + $('#id').val() }); this.layerIndex = index; }; RegistrationRecord.holiClass = function () { if (this.check1()) { var ids = RegistrationRecord.seItem1.map(function(item) { return item.studentId; }).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.studentId; }).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 = '
' + '
' + '
\n' + ' \n' + '
' + '
\n' + ' \n' + '
' + '
\n' + ' \n' + '
' + '
\n' + ' \n' + '
' + '
\n' + '
\n' + ' ' + ' ' + ' ' + '
\n' + '
' + '
' + '
'; 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 (data) { Feng.success(data.msg); 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(); });