You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

181 lines
7.1 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

layui.define([ 'form', 'laydate', 'table' ], function(exports) {
var form = layui.form;
var laydate = layui.laydate;
var table = layui.table;
var studentTable = null;
var isSignRole = $("input[name='isSignRole']").val();
var view ={
init:function(){
this.initTable();
this.initSearchForm();
this.initToolBar();
window.dataReload = function(){
Lib.doSearchForm($("#searchForm"),studentTable)
}
},
initTable:function(){
studentTable = table.render({
elem : '#studentTable',
height : Lib.getTableHeight(),
cellMinWidth: 100,
method : 'post',
even:true,
// skin:'nob',
size:"lg",
where:{studentStatus:1},
url : Common.ctxPath + '/jlw/student/list.json' // 数据接口
,page : Lib.tablePage // 开启分页
,limit : 10,
cols : [ [ // 表头//isSignRole.get()!'' :1admin+管理员 2:uniAdmin学院管理员 3:teacher 4student
{
field : 'universitiesCollegesName',
title : '所属院校',align: "center",
hide: isSignRole != 2 ? false : true,
},
{
field : 'universitiesCollegesName',
title : '所属院系',align: "center",
hide: isSignRole != 1 ? false : true
},
{
field : 'classIdText',
title : '所属专业',align: "center",
hide: isSignRole != 1 ? false : true
},
{
field : 'classIdText',
title : '所属班级',align: "center"
},
{
field : 'studentName',
title : '学生姓名',align: "center"
},
{
field : 'studentSn',
title : '学号',align: "center"
},
{
field : 'studentMobile',
title : '电话',align: "center"
},
{
field : 'studentEmail',
title : '邮箱',align: "center"
},
{
field : 'studentWeixinInfo',
title : '微信号',align: "center"
},
{
field : 'undefinedYD',
title : '账号来源',align: "center"
},
{
field : 'addTime',
title : '创建时间',align: "center"
},
{
field : 'userId',title : '操作',align:"center",fixed: "right", width: 200, templet: function (d) {
var htm = '<a class="layui-table-link" lay-event="edit">编辑</a>';
htm += '<a class="layui-table-link" lay-event="del">删除</a>';
htm += '<a class="layui-table-link" lay-event="password">初始化密码</a>';
return htm;
}
}
] ]
});
table.on('checkbox(studentTable)', function(obj){
var student = obj.data;
if(obj.checked){
//按钮逻辑Lib.buttonEnable()
}else{
}
})
},
initSearchForm:function(){
Lib.initSearchForm( $("#searchForm"),studentTable,form);
},
initToolBar:function(){
toolbar = {
add : function() { // 获取选中数据
var url = "/jlw/student/add.do";
Common.openDlg(url,"学生管理/添加学生");
},
refresh: function () {//刷新
searchForm.reset();
Lib.doSearchForm($("#searchForm"), studentTable, 1);
},
search:function () {
Lib.doSearchForm($("#searchForm"), studentTable, 1);
},import:function (){
var url = "/jlw/student/importPage.do";
Common.openDlg(url,"");
},export:function () {//导出
layer.confirm('是否确定导出学生信息?', function (index) {
layer.close(index);
var classId = $("#searchForm select[name='classId']").val(),
studentName = $("#searchForm input[name='studentName']").val(),
studentSn = $("#searchForm input[name='studentSn']").val();
window.open(Common.ctxPath + "/jlw/student/export.json?classId="+classId+"&studentName="+studentName+"&studentSn="+studentSn);
});
}
};
$('.ext-toolbar').on('click', function() {
var type = $(this).data('type');
toolbar[type] ? toolbar[type].call(this) : '';
});
}, initTableTool: table.on('tool(studentTable)', function (obj) {
var data = obj.data;
if (obj.event === 'edit') {
var url = "/jlw/student/add.do?studentId="+data.studentId;
Common.openDlg(url,"学生管理/编辑学生");
}else if(obj.event === "del"){
layer.confirm('是否确定删除该信息?', function (index) {
var ret = Common.postAjax("/jlw/student/delete.json", {ids: data.studentId});
layer.msg(ret.code == 0 ? "删除成功!" : ret.msg, {
offset: ['50%'],
icon: ret.code == 0 ? 1 : 2,
time: 1500 //2秒关闭如果不配置默认是3秒
}, function () {
if (ret.code == 0) {
Lib.tableRefresh();
}
});
});
}else if(obj.event === "password"){
layer.confirm('是否确定初始化该学生密码?', function (index) {
var ret = Common.postAjax("/jlw/student/initPassword.json", {
studentId: data.studentId
});
layer.msg(ret.code == 0 ? "密码初始化成功!" : ret.msg, {
offset: ['50%'],
icon: ret.code == 0 ? 1 : 2,
time: 1500 //2秒关闭如果不配置默认是3秒
}, function () {
if (ret.code == 0) {
Lib.tableRefresh();
}
});
});
}
})
}
//根据所选学校查询班级
form.on('select(select_universitiesColleges)', function (obj) {
Lib.getSchoolClass($("select[name='classId']"),obj.value);
});
exports('index',view);
});