gs-jjsp-web/bns/js/studyExam/studyCoursewareDetail.js

179 lines
5.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

let form, layer, table, tableIns, laydate;
let pageNum = 1, limitSize = 10; // 默认第一页分页数量为20
let user = getUser();
let dataObj = {};
function setParams(params){
dataObj = JSON.parse(params);
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/getStudyDetailListByUser?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-110",
data: dataList,
cols: [
[
{
title: "序号",
width: '5%',
unresize: true,
align: "center",
templet: function (d) {
return (page - 1) * limit + d.LAY_NUM;
}
},
{
field: "studyTaskName",
title: "学习任务名称",
width: '30%',
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: "fileName",
title: "学习课件名称",
width: '45%',
unresize: false,
align: "center",
},
{
title: "学习进度",
width: '10%',
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:green">已完成</span>'
}
}
},
{
title: "操作",
width: '10%',
unresize: false,
align: "center",
templet: function (d) {
let html = '';
html += "<a onclick='viewCourseware(" + 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 + "",
roleType: user.isSup,
userId: user.userId,
studyId:dataObj.studyId,
studyPeopleId:dataObj.studyPeopleId,
};
} else {
obj = {
page: 1,
limit: limit,
roleType: user.isSup,
userId: user.userId,
studyId:dataObj.studyId,
studyPeopleId:dataObj.studyPeopleId
};
}
return obj;
}
// 查询
function query() {
pages(1, limitSize);
}
// 考试详情
function viewCourseware(params) {
openIframeByParamObj7("viewCourseware", '学习', "studyCoursewareView.html", "92%", "95%", params);
}
// 关闭页面
function closePage() {
let index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
parent.layer.close(index); //再执行关闭
parent.reloadData();
}