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.

139 lines
5.8 KiB
JavaScript

2 years ago
layui.define(['form', 'laydate', 'table'], function (exports) {
3 years ago
var form = layui.form;
var laydate = layui.laydate;
var table = layui.table;
var teacherTable = null;
2 years ago
var view = {
init: function () {
3 years ago
this.initTable();
this.initSearchForm();
this.initToolBar();
2 years ago
window.dataReload = function () {
Lib.doSearchForm($("#searchForm"), teacherTable)
3 years ago
}
},
2 years ago
initTable: function () {
3 years ago
teacherTable = table.render({
2 years ago
elem: '#teacherTable',
height: Lib.getTableHeight(),
3 years ago
cellMinWidth: 100,
2 years ago
even: true,
3 years ago
// skin:'nob',
2 years ago
method: 'post',
size: "lg",
where: {teacherStatus: 1},
url: Common.ctxPath + '/jlw/teacher/list.json' // 数据接口
, page: Lib.tablePage // 开启分页
, limit: 10,
cols: [[ // 表头
{
2 years ago
field: 'universitiesCollegesIdText', title: '院校名称', align: "center"
2 years ago
},
{
field: 'teacherName', title: '教师姓名', align: "center"
},
// {
// field : 'teacherSn', title : '教师编号',align: "center"
// },
{
field: 'teacherJobNumber', title: '工号', align: "center"
},
{
field: 'teacherMobile', title: '电话', align: "center"
},
{
field: 'teacherEmail', title: '邮箱', align: "center"
},
2 years ago
{
field: 'addTime', title: '创建日期', align: "center"
},
2 years ago
{
2 years ago
field: 'userId', title: '操作',width:190, align: "center", templet: function (d) {
2 years ago
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;
}
3 years ago
}
2 years ago
]]
3 years ago
2 years ago
});
3 years ago
2 years ago
table.on('checkbox(teacherTable)', function (obj) {
3 years ago
var teacher = obj.data;
2 years ago
if (obj.checked) {
3 years ago
//按钮逻辑Lib.buttonEnable()
2 years ago
} else {
3 years ago
}
})
},
2 years ago
initSearchForm: function () {
Lib.initSearchForm($("#searchForm"), teacherTable, form);
3 years ago
},
2 years ago
initToolBar: function () {
3 years ago
toolbar = {
2 years ago
add: function () { // 获取选中数据
3 years ago
var url = "/jlw/teacher/add.do";
2 years ago
Common.openDlg(url, "教师管理/添加教师",{area: ["350px", "400px"]});
3 years ago
},
refresh: function () {//刷新
searchForm.reset();
Lib.doSearchForm($("#searchForm"), teacherTable, 1);
},
2 years ago
search: function () {
3 years ago
Lib.doSearchForm($("#searchForm"), teacherTable, 1);
2 years ago
}, import: function () {
3 years ago
var url = "/jlw/teacher/importPage.do";
2 years ago
Common.openDlg(url, "");
}, export: function () {//导出
3 years ago
layer.confirm('是否确定导出教师信息?', function (index) {
layer.close(index);
window.open(Common.ctxPath + "/jlw/teacher/export.json");
});
}
2 years ago
};
$('.ext-toolbar').on('click', function () {
3 years ago
var type = $(this).data('type');
toolbar[type] ? toolbar[type].call(this) : '';
});
}, initTableTool: table.on('tool(teacherTable)', function (obj) {
var data = obj.data;
if (obj.event === 'edit') {
2 years ago
var url = "/jlw/teacher/add.do?teacherId=" + data.teacherId;
Common.openDlg(url, "教师管理/编辑教师");
} else if (obj.event === "del") {
3 years ago
layer.confirm('是否确定删除该信息?', function (index) {
var ret = Common.postAjax("/jlw/teacher/delete.json", {ids: data.teacherId});
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();
}
});
});
2 years ago
} else if (obj.event === "password") {
3 years ago
layer.confirm('是否确定初始化该老师密码?', function (index) {
var ret = Common.postAjax("/jlw/teacher/initPassword.json", {
teacherId: data.teacherId
});
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();
}
});
});
}
})
}
2 years ago
exports('index', view);
3 years ago
});