195 lines
6.1 KiB
JavaScript
195 lines
6.1 KiB
JavaScript
|
|
let form, layer, table, tableIns, laydate;
|
|||
|
|
let pageNum = 1, limitSize = 10; // 默认第一页,分页数量为20
|
|||
|
|
let user = getUser();
|
|||
|
|
layui.use(['form', 'layer', 'table', 'laydate'], function () {
|
|||
|
|
form = layui.form;
|
|||
|
|
layer = layui.layer;
|
|||
|
|
table = layui.table;
|
|||
|
|
pages(1, 10, 1);
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
|
|||
|
|
function pages(pageNum, pageSize, typeNum) {
|
|||
|
|
let params = getReqParams(pageNum, pageSize, typeNum);
|
|||
|
|
$.ajax({
|
|||
|
|
url: dataUrl + "proteam/pot/studyTask/getStudyTaskListByUser?token=" + token,
|
|||
|
|
data: params,
|
|||
|
|
type: 'POST',
|
|||
|
|
async: false,
|
|||
|
|
success: function (result) {
|
|||
|
|
if (result.code === 200) {
|
|||
|
|
if (result.data) {
|
|||
|
|
initTable(result.data, result.limit, result.curr)
|
|||
|
|
laypages(result.count, result.curr, result.limit)
|
|||
|
|
}
|
|||
|
|
} else if (result.code === 500) {
|
|||
|
|
layer.alert(result.msg, { icon: 2 })
|
|||
|
|
} else if (result.code === 401) {
|
|||
|
|
logout(1);
|
|||
|
|
}
|
|||
|
|
}, error: function () {
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function laypages(total, page, limit) {
|
|||
|
|
layui.use(['laypage'], function () {
|
|||
|
|
let laypage = layui.laypage;
|
|||
|
|
laypage.render({
|
|||
|
|
elem: 'voi-page',
|
|||
|
|
count: total,
|
|||
|
|
curr: page,
|
|||
|
|
limit: limit,
|
|||
|
|
limits: [10, 20, 50, 100],
|
|||
|
|
layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'],
|
|||
|
|
groups: 5,
|
|||
|
|
jump: function (obj, first) {
|
|||
|
|
if (!first) {
|
|||
|
|
pageNum = obj.curr, limitSize = obj.limit;
|
|||
|
|
pages(obj.curr, obj.limit, null);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*初始化表格*/
|
|||
|
|
function initTable(dataList, limit, page) {
|
|||
|
|
let loadingMsg = layer.msg("数据加载中,请稍候...", { icon: 16, scrollbar: false, time: 0, });
|
|||
|
|
tableIns = table.render({
|
|||
|
|
id: 'todayTaskTable',
|
|||
|
|
elem: "#todayTaskTable",
|
|||
|
|
height: "full-150",
|
|||
|
|
data: dataList,
|
|||
|
|
cols: [
|
|||
|
|
[
|
|||
|
|
{
|
|||
|
|
title: "序号",
|
|||
|
|
width: '5%',
|
|||
|
|
unresize: true,
|
|||
|
|
align: "center",
|
|||
|
|
templet: function (d) {
|
|||
|
|
return (page - 1) * limit + d.LAY_NUM;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: "studyTaskName",
|
|||
|
|
title: "学习任务名称",
|
|||
|
|
width: '25%',
|
|||
|
|
unresize: false,
|
|||
|
|
align: "center",
|
|||
|
|
templet: function (d) {
|
|||
|
|
if (d.studyTaskName) {
|
|||
|
|
if (d.studyTaskName.length > 60) {
|
|||
|
|
return '<span title="' + d.studyTaskName + '">' + d.studyTaskName.substring(0, 60) + '...</span>'
|
|||
|
|
} else {
|
|||
|
|
return '<span title="' + d.studyTaskName + '">' + d.studyTaskName + '</span>'
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
return '';
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: "fileNum",
|
|||
|
|
title: "学习课件",
|
|||
|
|
width: '15%',
|
|||
|
|
unresize: false,
|
|||
|
|
align: "center",
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: "publishUser",
|
|||
|
|
title: "发布人",
|
|||
|
|
width: '15%',
|
|||
|
|
unresize: false,
|
|||
|
|
align: "center",
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: "publishTime",
|
|||
|
|
title: "发布时间",
|
|||
|
|
width: '15%',
|
|||
|
|
unresize: false,
|
|||
|
|
align: "center",
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: "studyStatus",
|
|||
|
|
title: "学习进度",
|
|||
|
|
width: '15%',
|
|||
|
|
unresize: false,
|
|||
|
|
align: "center",
|
|||
|
|
templet: function (d) {
|
|||
|
|
if (d.studyStatus === '0') {
|
|||
|
|
return '<span style="color:#f40">未进行</span>'
|
|||
|
|
} else if (d.studyStatus === '1') {
|
|||
|
|
return '<span style="color:#b9b912">进行中</span>'
|
|||
|
|
} else if (d.studyStatus === '2') {
|
|||
|
|
return '<span style="color:green">已完成</span>'
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
title: "操作",
|
|||
|
|
width: '10%',
|
|||
|
|
unresize: false,
|
|||
|
|
align: "center",
|
|||
|
|
templet: function (d) {
|
|||
|
|
let html = '';
|
|||
|
|
html += "<a onclick='viewStudyCourseware(" + JSON.stringify(d) + ")'>查看</a>";
|
|||
|
|
return html;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
],
|
|||
|
|
],
|
|||
|
|
limit: limit,
|
|||
|
|
done: function (res, curr, count) {
|
|||
|
|
layer.close(loadingMsg);
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
// 获取参数
|
|||
|
|
function getReqParams(page, limit, type) {
|
|||
|
|
let obj = {};
|
|||
|
|
if (!type) {
|
|||
|
|
obj = {
|
|||
|
|
page: page + "",
|
|||
|
|
limit: limit + "",
|
|||
|
|
studyStatus: $('#studyStatus').val(),
|
|||
|
|
studyTaskName: $('#studyTaskName').val(),
|
|||
|
|
roleType: user.isSup,
|
|||
|
|
userId: user.userId
|
|||
|
|
};
|
|||
|
|
} else {
|
|||
|
|
obj = {
|
|||
|
|
page: 1,
|
|||
|
|
limit: limit,
|
|||
|
|
studyStatus: $('#studyStatus').val(),
|
|||
|
|
studyTaskName: $('#studyTaskName').val(),
|
|||
|
|
roleType: user.isSup,
|
|||
|
|
userId: user.userId
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
return obj;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 查询
|
|||
|
|
function query(type) {
|
|||
|
|
if (type === 2) {
|
|||
|
|
$('#studyTaskName').val('');
|
|||
|
|
$('#studyStatus').val('');
|
|||
|
|
layui.form.render();
|
|||
|
|
}
|
|||
|
|
pages(1, limitSize);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function reloadData(){
|
|||
|
|
pages(pageNum, limitSize);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 学习详情
|
|||
|
|
function viewStudyCourseware(params) {
|
|||
|
|
openIframeByParamObjNoTitle("viewStudyCourseware", '学习详情', "studyCoursewareDetail.html", "100%", "100%", params);
|
|||
|
|
}
|