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.

924 lines
43 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','laytpl', 'laydate', 'table','element','handsOnSimulationTasksApi', 'upload', 'layedit','layer','table'], function(exports) {
var handsOnSimulationTasksApi = layui.handsOnSimulationTasksApi;
var form = layui.form,
laytpl = layui.laytpl,
index = layui.index,
element = layui.element,
upload = layui.upload,
layedit = layui.layedit,
layer = layui.layer,
table = layui.table;
element.render();
layedit.set({ //富文本上传图片
uploadImage: {
url: Common.ctxPath + "/jlw/file/update.do",
imgUrl:"http://localhost:9090/server"
}
});
var one = layedit.build('test-editor1'); //建立编辑器
var editor = null;
var resourcesQuestionTable =null;
var resourcesQuestionTable1 = null;
var selectResourcesQuestion = [];
var tableData4 = [];
var resourcesQuestionIds = ""; //选中题目id
var resourcesInfoTable = [];//资源库的table
var resourcesInfoShowTable = []//选中视频资源后展示的table
var resourcesInfoShowPPTTable = [];//选中PPT资源后展示的table
var checkStatusData = [];//资源选中data
var courseInfoIds = $("input[name=courseInfoId_1]").val();
var typeInfo = $("#taskTypeInfo input[name='taskType']:checked").val(); //当前操作的类型
if (typeInfo == 1){
$(".progressCss_mp4 .closeInfo").unbind();
$(".progressCss_mp4 .closeInfo").click(function (){
$(this).parents(".progressCss_mp4").remove();
});
}else if(typeInfo == 2){
$(".progressCss_ppt .closeInfo").unbind();
$(".progressCss_ppt .closeInfo").click(function (){
$(this).parents(".progressCss_ppt").remove();
});;
}else if(typeInfo == 3){
getQuestionTotal();
resourcesQuestionIds = $("input[name='taskList']").val(); //选中的题目ID
}else if(typeInfo == 4){
if (editor === null) {
editor = Lib.editorMd("test-editor");
editor.setToolbarAutoFixed(false);
}
$("#tableData4_view .infoTr").each(function (){
tableData4.push({
handsOnId:$("#addForm input[name='handsOnId']").val(),//实操ID
handsOnSimulationTasksAssessmentQuestion:$(this).find(".handsOnSimulationTasksAssessmentQuestion").text(), //考核题目
handsOnSimulationTasksAssessmentAnswer:$(this).find("textarea[name='handsOnSimulationTasksAssessmentAnswer']").val(), //考核答案
handsOnSimulationTasksAssessmentScore:$(this).find("input[name='handsOnSimulationTasksAssessmentScore']").val(), //考核分值
});
});
getScoreInfo();
}else if (typeInfo == 5){
$(".progressCss_file .closeInfo").unbind();
$(".progressCss_file .closeInfo").click(function (){
$(this).parents(".progressCss_file").remove();
});
}
var assessmentContent = $("#assessmentContent").val();
window.loadYl = function (){//富文本代码编辑器 产生变化时触发
yl();
}
// setTimeout(function (){
// editor.init();
// // $("#test-editor .editormd-preview").width("50%");
// // $("#test-editor .CodeMirror-wrap").width("50%");
// },500);
//普通图片上传
var uploadInst = upload.render({
elem: '#test-upload-normal'
,url: Common.ctxPath +'/jlw/file/update.do'
,accept:'video'
, progress: function(value) {
var v =
element.progress('progressBar',v);
}
,choose: function(obj){
$("#mp4Info").append('<div class="progressCss_mp4">\n' +
'<span type="text" class="nameV" style="width: 300px"></span>\n' +
'<span class="mv_m" style="float: right;"></span>\n' +
'<span class="fileUrl" style="display: none;"></span>\n' +
'<div class="layui-progress " lay-showPercent="yes" lay-filter="progressBar" style="margin-top: 15px; width:300px">\n' +
'<div class="layui-progress-bar layui-bg-blue" lay-percent="100%"></div>\n' +
'</div>\n' +
'<span class="closeInfo">X</span>\n' +
'</div>');
element.init();//进度条更新
},
before: function(obj) {
obj.preview(function(index, file, result) {
//$('input[name="src"]').html(file.name);
$('.progressCss_mp4:last .nameV').html(file.name);
var size = (file.size/1014).toFixed(1)+'kb';
$('.progressCss_mp4:last .mv_m').html(size);
});
}
,done: function(res){
//如果上传失败
if(res.code > 0){
return layer.msg('上传失败');
}else {
$('.progressCss_mp4:last .fileUrl').html(res.data.url);
$(".progressCss_mp4 .closeInfo").unbind();
$(".progressCss_mp4 .closeInfo").click(function (){
$(this).parents(".progressCss_mp4").remove();
})
}
//上传成功
}
,error: function(){
//演示失败状态,并实现重传
var demoText = $('#test-upload-demoText');
demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
demoText.find('.demo-reload').on('click', function(){
uploadInst.upload();
});
}
});
var uploadInstPPT = upload.render({
elem: '#upload-normalPPT'
,url: Common.ctxPath +'/jlw/file/update.do'
,accept:'file'
,exts:'ppt|pps|pptx|ppsx|pot|ppa|pdf'
, progress: function(value) {
element.progress('progressBarPPT',value + '%');
}
,choose: function(obj){
$("#pptInfo").append('<div class="progressCss_ppt">\n' +
'<span type="text" class="nameV" style="width: 300px"></span>\n' +
'<span class="mv_m" style="float: right;"></span>\n' +
'<span class="fileUrl" style="display: none;"></span>\n' +
'<div class="layui-progress " lay-showPercent="yes" lay-filter="progressBarPPT" style="margin-top: 15px; width:300px">\n' +
'<div class="layui-progress-bar layui-bg-blue" lay-percent="100%"></div>\n' +
'</div>\n' +
'<span class="closeInfo">X</span>\n' +
'</div>');
element.init();//进度条更新
},
before: function(obj) {
obj.preview(function(index, file, result) {
//$('input[name="src"]').html(file.name);
$('.progressCss_ppt:last .nameV').html(file.name);
var size = (file.size/1014).toFixed(1)+'kb';
$('.progressCss_ppt:last .mv_m').html(size);
});
}
,done: function(res){
//如果上传失败
if(res.code > 0){
return layer.msg('上传失败');
}else {
if(!$.isEmpty(res.data.cvPDFUrl)){
$('.progressCss_ppt:last .fileUrl').html(res.data.cvPDFUrl);
}else {
$('.progressCss_ppt:last .fileUrl').html(res.data.url);
}
$(".progressCss_ppt .closeInfo").unbind();
$(".progressCss_ppt .closeInfo").click(function (){
$(this).parents(".progressCss_ppt").remove();
})
}
//上传成功
}
,error: function(){
//演示失败状态,并实现重传
var demoText = $('#upload-demoTextPPT');
demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reloadP">重试</a>');
demoText.find('.demo-reloadP').on('click', function(){
uploadInstPPT.upload();
});
}
});
var uploadInstFile = upload.render({
elem: '#upload-normalFile'
,url: Common.ctxPath +'/jlw/file/update.do'
,accept:'file'
, progress: function(value) {
element.progress('progressBarFile',value + '%');
},
choose: function(obj){
$("#fileInfo").append('<div class="progressCss_file">\n' +
'<span type="text" class="nameV" style="width: 300px"></span>\n' +
'<span class="mv_m" style="float: right;"></span>\n' +
'<span class="fileUrl" style="display: none;"></span>\n' +
'<div class="layui-progress " lay-showPercent="yes" lay-filter="progressBarFile" style="margin-top: 13%; width:300px">\n' +
'<div class="layui-progress-bar layui-bg-blue" lay-percent="100%"></div>\n' +
'</div>\n' +
'<span class="closeInfo">X</span>\n' +
'</div>');
element.init();//进度条更新
},
before: function(obj) {
obj.preview(function(index, file, result) {
//$('input[name="src"]').html(file.name);
$('.progressCss_file:last .nameV').html(file.name);
var size = (file.size/1014).toFixed(1)+'kb';
$('.progressCss_file:last .mv_m').html(size);
});
}
,done: function(res){
//如果上传失败
if(res.code > 0){
return layer.msg('上传失败');
}else {
$('.progressCss_file:last .fileUrl').html(res.data.url);
$(".progressCss_file .closeInfo").unbind();
$(".progressCss_file .closeInfo").click(function (){
$(this).parents(".progressCss_file").remove();
});
}
//上传成功
}
,error: function(){
//演示失败状态,并实现重传
var demoText = $('#upload-demoTextFile');
demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reloadF">重试</a>');
demoText.find('.demo-reloadF').on('click', function(){
uploadInstFile.upload();
});
}
});
$('#manualProblemSetting').click(function () {//手动出题
layer.open({
type: 1
, title: '选择题库'
,fixed:false//固定页面后,弹出框随着滚动
, shadeClose: true
,offset:'30px'
, scrollbar: true//滚动条
, content: $("#resourcesQuestionTable_demo")
, btn: ['保存','关闭']
,success:function () {
resourcesQuestionTable();
Lib.getCourseInfo($("select[name='courseInfoId_1']"), courseInfoIds,2,2);
}
, yes: function (index, layero) {
var ret = Common.getAjax('/jlw/handsOnSimulationTasks/getObjectiveProblem.do?problemIds='+resourcesQuestionIds);
if (ret.length > 0){
var getTpl = kgtTable_demo.innerHTML
,view = document.getElementById('kgtTable_view');
laytpl(getTpl).render({list:ret}, function(html){
view.innerHTML = html;
getQuestionTotal();
});
}
layer.close(index);
$('#resourcesQuestionTable_demo').hide();
}
, btn2: function (index, layero) {
layer.close(index);
$('#resourcesQuestionTable_demo').hide();
}
});
});
///jlw/teacherOpenCourseHandsOnSimulationTasks/getObjectiveProblem.do?problemIds=
var btn = $("#searchFormQuestion");
btn.on('click', function () {
resourcesQuestionTable1.reload({
where: {
'courseInfoId_0':courseInfoIds,
'courseInfoId_1':$("#resourcesQuestionTable_demo select[name='courseInfoId_1']").find("option:selected").val(),
"questionStem":$("#resourcesQuestionTable_demo input[name='generalQuestionSettingName']").val(),
'questionType':$("#resourcesQuestionTable_demo select[name='questionType']").find("option:selected").val(),
'addTypeText': "超级管理员"
},
});
});
table.on('checkbox(resourcesQuestionTable)', function(obj){ //test 是 table 标签对应的 lay-filter 属性
if (obj.checked) { //选中
if (obj.type == "all") {//全选
var checkStatus = table.checkStatus('resourcesQuestionTable').data;
for (var i = 0; i < checkStatus.length; i++) {
if (("," + resourcesQuestionIds + ",").indexOf(checkStatus[i].resourcesQuestionId) < 0) {
if (!$.isEmpty(resourcesQuestionIds)) {
resourcesQuestionIds += "," + checkStatus[i].resourcesQuestionId;
} else {
resourcesQuestionIds = checkStatus[i].resourcesQuestionId;
}
}
}
} else {
if (!$.isEmpty(resourcesQuestionIds)) {
resourcesQuestionIds += "," + obj.data.resourcesQuestionId;
} else {
resourcesQuestionIds = obj.data.resourcesQuestionId;
}
}
} else {//取消全选
if (obj.type == "all") {//全选
var checkStatus = table.cache["resourcesQuestionTable"];
for (var i = 0; i < checkStatus.length; i++) {
resourcesQuestionIds = Lib.stringRemove(resourcesQuestionIds, checkStatus[i].resourcesQuestionId);
}
} else {
resourcesQuestionIds = Lib.stringRemove(resourcesQuestionIds, obj.data.resourcesQuestionId);
}
}
$("#countQ").html(resourcesQuestionIds.split(',').length)
});
$("#del").click(function () {//清除已选
resourcesQuestionIds = [];
$("#countQ").html(0);
var param = {
'courseInfoId_0':courseInfoIds,
'courseInfoId_1':$("#resourcesQuestionTable_demo select[name='courseInfoId_1']").find("option:selected").val(),
"questionStem":$("#resourcesQuestionTable_demo input[name='generalQuestionSettingName']").val(),
'questionType':$("#resourcesQuestionTable_demo select[name='questionType']").find("option:selected").val(),
'addTypeText' : "超级管理员"
};
resourcesQuestionTable1.reload({
where: param,
page: {
curr: 1
}
});
});
resourcesQuestionTable= function(){
var isAdmin = '${user.get().isAdmin}';
var addType;
if(isAdmin){
addType = 'ADMIN_ADD';
}else {
addType = 'FACULTY_ADD';
}
resourcesQuestionTable1=table.render({
elem: '#resourcesQuestionTable',
cellMinWidth: 100,
method: 'post',
even: true,
size: "sms",
url: Common.ctxPath + '/jlw/resourcesQuestion/testItemManageList.json' // 数据接口
, page: Lib.tablePage // 开启分页
, limit: 8
, where: {"courseInfoId_0": courseInfoIds,'addTypeText':"超级管理员"}
,cols: [[ // 表头
{
type: 'checkbox', align: "center"
},
{
field: 'questionStem', width: 320,
title: '题干', align: "center"
},
{
field: 'questionType', align: "center", width: 80,
title: '题型', templet: function (d) {//(1单选 2多选 3判断 4填空 5分析)
return d.questionType == 1 ? '单选' : d.questionType == 2 ? '多选' : d.questionType == 3 ? '判断' : '-';
}
},
{
field: 'courseInfoParentName',
title: '归属课程', align: "center"
},
{
field: 'courseInfoName',
title: '归属章节', align: "center"
}
]],done: function(res, curr, count){
//循环所有数据找出对应关系设置checkbox选中状态
for (var i = 0; i < res.data.length; i++) {
for (var j = 0; j < resourcesQuestionIds.split(',').length; j++) {
if (res.data[i].resourcesQuestionId == resourcesQuestionIds.split(',')[j]) {
//这里才是真正的有效勾选
res.data[i]["LAY_CHECKED"] = 'true';
//找到对应数据改变勾选样式,呈现出选中效果
var index = res.data[i]['LAY_TABLE_INDEX'];
$('.layui-table tr[data-index=' + index + '] input[type="checkbox"]').prop('checked', true);
$('.layui-table tr[data-index=' + index + '] input[type="checkbox"]').next().addClass('layui-form-checked');
}
}
}
}
});
};
var view = {
init:function(){
Lib.initGenrealForm($("#addForm"),form);
this.initSubmit();
},
initSubmit:function(){
$("#addButton").click(function(){
form.on('submit(form)', function(){
var taskId = $("#addForm input[name='taskId']").val(),param = {},
handsOnId = $("#addForm input[name='handsOnId']").val();
var taskType = $("#taskTypeInfo input[name='taskType']:checked").val(); //得到当前操作的任务类型 1观看视频 2PPT 3理论测评 4实操 5报告撰写
var key = $("#taskTypeContent .layui-show");
param.taskTitle = key.find("input[name='taskTitle']").val(); //标题
param.taskOrder = key.find("input[name='taskOrder']").val(); //顺序
if ($.isEmpty(param.taskTitle)){
Common.info("请输入标题!");
return;
}
// if ($.isEmpty(param.taskOrder)){
// Common.info("请输入顺序!");
// return;
// }
if (taskType == 1){ //视频
param.taskScore = key.find("input[name='taskScore']").val(); //分值
if ($.isEmpty(param.taskScore)){
Common.info("请输入分值!");
return;
}
param.assessmentRequirements = key.find("input[name='assessmentRequirements']").val(); //至少观看时长
param.assessmentTime = key.find("input[name='assessmentTime']").val(); //至少观看时长
if ($.isEmpty(param.assessmentRequirements)){
Common.info("请输入至少观看时长!");
return;
}
if ($.isEmpty(param.assessmentTime)){
Common.info("请输入间隔多少分钟出现一次弹窗!");
return;
}
var tasksFile = [];
$("#mp4Info .progressCss_mp4").each(function (){
tasksFile.push({
fileName:$(this).find(".nameV").html(),
fileUrl:$(this).find(".fileUrl").html()
});
});
var resourcesInfoTableData = table.cache["resourcesInfoShowTable"]||[]; //获取showtable数据 视频
for (var i = 0;i<resourcesInfoTableData.length;i++){
if(resourcesInfoTableData[i].resourcesInfoType == "1"){
tasksFile.push({
fileName:resourcesInfoTableData[i].resourcesInfoName,
fileUrl:resourcesInfoTableData[i].resourcesInfoContent
});
}
}
if (tasksFile.length <= 0){
Common.info("请上传视频!");
return;
}
param.tasksFile = JSON.stringify(tasksFile);
}else if (taskType == 2){ //PPT
param.taskScore = key.find("input[name='taskScore']").val(); //分值
param.assessmentRequirements = key.find("input[name='assessmentRequirements']").val(); //至少观看时长
param.assessmentTime = key.find("input[name='assessmentTime']").val(); //至少观看时长
if ($.isEmpty(param.taskScore)){
Common.info("请输入分值!");
return;
}
if ($.isEmpty(param.assessmentRequirements)){
Common.info("请输入至少观看时长!");
return;
}
if ($.isEmpty(param.assessmentTime)){
Common.info("请输入间隔多少分钟出现一次弹窗!");
return;
}
var tasksFile = [];
$("#pptInfo .progressCss_ppt").each(function (){
tasksFile.push({
fileName:$(this).find(".nameV").html(),
fileUrl:$(this).find(".fileUrl").html()
});
});
var resourcesInfoTableData = table.cache["resourcesInfoShowPPTTable"]||[]; //获取showtable数据 ppt
for (var i = 0;i<resourcesInfoTableData.length;i++){
if(resourcesInfoTableData[i].resourcesInfoType == "2" || resourcesInfoTableData[i].resourcesInfoType == "3"){
tasksFile.push({
fileName:resourcesInfoTableData[i].resourcesInfoName,
fileUrl:resourcesInfoTableData[i].resourcesInfoContent
});
}
}
if (tasksFile.length <= 0){
Common.info("请上传PPT");
return;
}
param.tasksFile = JSON.stringify(tasksFile);
}else if (taskType == 3){ //理论测评
var tableQuestionData = [];
$("#kgtTable_view .infoTr").each(function (){
tableQuestionData.push({
questionType:$(this).find(".questionType").text(),
questionTypeName:$(this).find(".questionTypeName").text(),
questionNum:$(this).find(".questionNum").text(),
questionScore:$(this).find("input[name='questionScore']").val(),
questionTotal:$(this).find(".questionTotal").text(),
});
});
if (tableQuestionData.length <= 0){
Common.info("请选择客观题");
return;
}
param.taskList = resourcesQuestionIds;
param.taskScore = $(".questionTotalInfo").text(); //分值
param.handsOnTaskProblemVo = JSON.stringify(tableQuestionData);
}else if (taskType == 4){ //实操
param.assessmentContent = editor.getMarkdown(); //考核内容
param.taskScore = $(".scoreInfo").text(); //分值
if ($.isEmpty(param.assessmentContent)){
Common.info("请输入考核内容!");
return;
}
param.handsOnSimulationTasksAssessment = JSON.stringify(tableData4); //考核答案
}else if (taskType == 5){ //报告撰写
param.taskScore = key.find("input[name='taskScore']").val(); //分值
param.assessmentContent = layedit.getContent(one); //获取报告要求
if ($.isEmpty(param.taskScore)){
Common.info("请输入分值!");
return;
}
if ($.isEmpty(param.assessmentContent)){
Common.info("请输入报告要求!");
return;
}
var tasksFile = [];
$("#fileInfo .progressCss_file").each(function (){
tasksFile.push({
fileName:$(this).find(".nameV").html(),
fileUrl:$(this).find(".fileUrl").html()
});
});
if (tasksFile.length <= 0){
Common.info("请上传报告参考模板!");
return;
}
param.tasksFile = JSON.stringify(tasksFile);
}
param.taskType = taskType;
param.taskId = taskId;
param.handsOnId = handsOnId; //案例ID
var url = "/jlw/handsOnSimulationTasks/edit.json";
if($.isEmpty(taskId)){
url = "/jlw/handsOnSimulationTasks/add.json";
}
var ret = Common.postAjax(url,param);
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.closeFrame();
parent.loadList();
}
});
});
});
$("#addButton-cancel").click(function(){
Lib.closeFrame();
});
}
}
// noinspection BadExpressionStatementJS
form.on('radio(taskType)', obj => {
element.tabChange('demo', obj.value);
if (obj.value === "4") {
if (editor === null) {
editor = Lib.editorMd("test-editor");
editor.setToolbarAutoFixed(false);
}
}
if(obj.value == "2"||obj.value == "1"){
if(!$.isEmpty(resourcesInfoShowTable)){
resourcesInfoShowTable.reload({data:[]});
}
if(!$.isEmpty(resourcesInfoShowPPTTable)){
resourcesInfoShowPPTTable.reload({data:[]});
}
}
// $("input[name='taskTitle']").val("");
// $("input[name='taskScore']").val("");
// $("input[name='taskOrder']").val("");
// $("input[name='assessmentRequirements']").val("");
// $("input[name='assessmentTime']").val("");
});
//理论测评分值修改
function getQuestionTotal(){
$("#kgtTable_view input[name='questionScore']").unbind();
$("#kgtTable_view input[name='questionScore']").change(function (){
var questionScore = $(this).val();//当前输入的分值
var indexInfo = $(this).attr("indexInfo"); //当前操作的位置
var questionNum = $("#kgtTable_view .questionNum:eq("+indexInfo+")").text(); //题目数量
$("#kgtTable_view .questionTotal:eq("+indexInfo+")").text((Number(questionScore) * Number(questionNum)).toFixed(2)); //合计
$(".questionTotalInfo").text(0);
$("#kgtTable_view .questionTotal").each(function (){
$(".questionTotalInfo").text(Number($(this).text()) + Number($(".questionTotalInfo").text()));
})
});
}
//实操分值修改
function getScoreInfo(){
$("#tableData4_view input[name='handsOnSimulationTasksAssessmentScore']").unbind();
$("#tableData4_view input[name='handsOnSimulationTasksAssessmentScore']").change(function (){
var indexInfo = $(this).attr("indexInfo"); //当前操作的位置
tableData4[indexInfo].handsOnSimulationTasksAssessmentScore = $(this).val();
var score = 0;
$("#tableData4_view input[name='handsOnSimulationTasksAssessmentScore']").each(function (){
score = Number(score) + Number($(this).val());
})
$("#tableData4_view .scoreInfo").text(score);
});
$("#tableData4_view textarea[name='handsOnSimulationTasksAssessmentAnswer']").unbind();
$("#tableData4_view textarea[name='handsOnSimulationTasksAssessmentAnswer']").change(function (){
var indexInfo = $(this).attr("indexInfo"); //当前操作的位置
tableData4[indexInfo].handsOnSimulationTasksAssessmentAnswer = $(this).val();
});
}
function yl(){
var val = editor.getMarkdown();
if(!$.isEmpty(val) && val.indexOf("[---]") >= 0 ){
if(tableData4.length > val.split("[---]").length - 1){
tableData4 = tableData4.slice(0,val.split("[---]").length - 1);
}else if(tableData4.length < val.split("[---]").length - 1){
if((val.split("[---]").length - 1)-tableData4.length > 1){
var length = (val.split("[---]").length - 1) - tableData4.length;
for(var i=0;i < length;i++){
tableData4.push({
handsOnId:$("#addForm input[name='handsOnId']").val(),//实操ID
handsOnSimulationTasksAssessmentQuestion:Lib.chineseNum(tableData4.length,1), //考核题目
handsOnSimulationTasksAssessmentAnswer:"", //考核答案
handsOnSimulationTasksAssessmentScore:"", //考核分值
})
}
}else{
tableData4.push({
handsOnId:$("#addForm input[name='handsOnId']").val(),//实操ID
handsOnSimulationTasksAssessmentQuestion:Lib.chineseNum(tableData4.length,1), //考核题目
handsOnSimulationTasksAssessmentAnswer:"", //考核答案
handsOnSimulationTasksAssessmentScore:"", //考核分值
})
}
}
}else{
tableData4 = [];
}
var getTpl = tableData4_demo.innerHTML
,view = document.getElementById('tableData4_view');
laytpl(getTpl).render({list:tableData4}, function(html){
view.innerHTML = html;
getScoreInfo();
});
}
//视频资源库button
$("#videoClick").click(function (obj) {
updataResourcesOpenRe(1);
var htm = "已选中0";
$("#checkNumber").html(htm)
});
//PPT资源库button
$("#pptClick").click(function (obj) {
updataResourcesOpenRe('2,3');
var htm = "已选中0";
$("#checkNumber").html(htm)
});
/*资源库上传弹出框*/
function updataResourcesOpenRe(resourcesInfoTypePlural) {
checkStatusData = [];
layer.open({
type: 1,
title: "资源库上传",
shadeClose: true,
btn: ['保存', '关闭'],
btnAlign: 'c',
area: ['820px', '600px'],
content: $("#edit_dialog"),
success: function (layero, index) {
loadResourcesInfo(resourcesInfoTypePlural);
$(".search").unbind();
$(".search").click(function () {searchList(resourcesInfoTypePlural);}); //搜索
//table.reload('resourcesInfoTable');//刷新table
}, yes: function (index) {
var checkStatus = table.checkStatus("resourcesInfoTable"); //获取选中行状态
var dataNew = checkStatus.data, ids = Common.concatBatchId(dataNew, "resourcesInfoId"); //获取选中行数据
if(resourcesInfoTypePlural == 1){
resourcesInfoShowInfo(checkStatusData)
}else if(resourcesInfoTypePlural == '2,3'){
resourcesInfoShowPPTInfo(checkStatusData)
}
form.render();
layer.close(index);
}, btn2: function (index, layero) {
layer.close(index);
}
});
}
//资源库表格
function loadResourcesInfo(resourcesInfoTypePlural) {
$("#edit_dialog input[name='resourcesInfoName']").val("");
resourcesInfoTable = table.render({
elem: '#resourcesInfoTable',
height: Lib.getTableHeight(),
cellMinWidth: 100,
method: 'post',
even: true,
//url: Common.ctxPath + '/jlw/resourcesInfo/list.json' // 数据接口
url: Common.ctxPath + '/jlw/resourcesInfo/getResourceSystemOAndUniversitiesList.json' // 数据接口
, where: getParamRe(resourcesInfoTypePlural)
, page: Lib.tablePage // 开启分页
, limit: 10,
cols: [[ // 表头
{
type: 'checkbox'
},
{
field: 'resourcesInfoName', title: '资源名称', align: "center", style: "text-align: left;"
},
{
field: 'courseInfoParentParentName', title: '归属课程', align: "center", width: 150
},
{
field: 'resourcesInfoType', width: 150, title: '资源类型', align: "center", templet: function (d) {//(1视频 2PPT 3PDF)
var text = d.resourcesInfoType == 1 ? "视频" : d.resourcesInfoType == 2 ? "PPT" : d.resourcesInfoType == 3 ? "PDF" : d.resourcesInfoType == 4 ? "链接" : d.resourcesInfoType == 5 ? "图文" : '-';
return '<span class="textType">' + text + '</span>';
}
},
{
field: 'userId',
title: '操作',
width: 80,
align: "center",
templet: function (d) {
var htm = '<button type="button" class="layui-btn layui-btn-xs bg_button" lay-event="previewPage">查看</button></a>';
return htm;
}
}
]],done: function(res, curr, count){
//循环所有数据找出对应关系设置checkbox选中状态
for (var i = 0; i < res.data.length; i++) {
for (var j = 0; j < checkStatusData.length; j++) {
if (res.data[i].resourcesInfoId == checkStatusData[j].resourcesInfoId) {
//这里才是真正的有效勾选
res.data[i]["LAY_CHECKED"] = 'true';
//找到对应数据改变勾选样式,呈现出选中效果
var index = res.data[i]['LAY_TABLE_INDEX'];
$('.layui-table tr[data-index=' + index + '] input[type="checkbox"]').prop('checked', true);
$('.layui-table tr[data-index=' + index + '] input[type="checkbox"]').next().addClass('layui-form-checked');
}
}
}
}
});
table.on('tool(resourcesInfoTable)', function (obj) {
var data = obj.data;
if (obj.event === 'previewPage') { //预览
Lib.downloadFile(data);
}
});
table.on('checkbox(resourcesInfoTable)', function(obj){
if (obj.checked) { //选中
if (obj.type == "all") {//全选
var checkStatus = table.checkStatus('resourcesInfoTable').data;
var data = checkStatus;
for (var i = 0; i < checkStatusData.length; i++) {
for (var j = 0; j < checkStatus.length; j++) {
if(checkStatusData[i].resourcesInfoId == checkStatus[j].resourcesInfoId){
data.splice(checkStatus[j], 1); // 删除
}
}
}
for (var i = 0; i < data.length; i++) {
checkStatusData.push(data[i])
}
} else {
checkStatusData.push(obj.data);
}
} else {//取消全选
if (obj.type == "all") {//全选
var checkStatus = table.cache["resourcesInfoTable"];
for (var i = 0; i < checkStatus.length; i++) {
checkStatusData.splice(checkStatus[i], 1)
}
} else {
checkStatusData.splice(obj.data, 1); // 删除
//resourcesQuestionIds = Lib.stringRemove(resourcesQuestionIds, obj.data.resourcesQuestionId);
}
}
var htm = "已选择:"+checkStatusData.length;
$("#checkNumber").html(htm)
})
}
function resourcesInfoShowInfo(data) {
resourcesInfoShowTable = table.render({
elem: '#resourcesInfoShowTable',
height: Lib.getTableHeight(),
cellMinWidth: 100,
method: 'post',
even: true,
data:data,
limit: 1000,
cols: [[ // 表头
{
field: 'resourcesInfoName', title: '资源名称', align: "center", style: "text-align: left;"
},
{
field: 'courseInfoParentParentName', title: '归属课程', align: "center", width: 150
},
{
field: 'resourcesInfoType', width: 150, title: '资源类型', align: "center", templet: function (d) {//(1视频 2PPT 3PDF)
var text = d.resourcesInfoType == 1 ? "视频" : d.resourcesInfoType == 2 ? "PPT" : d.resourcesInfoType == 3 ? "PDF" : d.resourcesInfoType == 4 ? "链接" : d.resourcesInfoType == 5 ? "图文" : '-';
return '<span class="textType">' + text + '</span>';
}
},
{
field: 'userId',
title: '操作',
width: 160,
align: "center",
templet: function (d) {
var htm = '<button type="button" class="layui-btn layui-btn-xs bg_button" lay-event="previewPage">查看</button></a>';
htm += '<button type="button" class="layui-btn layui-btn-xs bg_button" lay-event="del">删除</button></a>';
return htm;
}
}
]]
});
table.on('tool(resourcesInfoShowTable)', function (obj) {
var data = obj.data;
if (obj.event === 'previewPage') { //预览
Lib.downloadFile(data);
}else if(obj.event === 'del'){
checkStatusData.splice(data, 1); // 删除
resourcesInfoShowTable.reload({data:checkStatusData});
}
});
};function resourcesInfoShowPPTInfo(data) {
resourcesInfoShowPPTTable = table.render({
elem: '#resourcesInfoShowPPTTable',
height: Lib.getTableHeight(),
cellMinWidth: 100,
method: 'post',
even: true,
data:data,
limit: 1000,
cols: [[ // 表头
{
field: 'resourcesInfoName', title: '资源名称', align: "center", style: "text-align: left;"
},
{
field: 'courseInfoParentParentName', title: '归属课程', align: "center", width: 150
},
{
field: 'resourcesInfoType', width: 150, title: '资源类型', align: "center", templet: function (d) {//(1视频 2PPT 3PDF)
var text = d.resourcesInfoType == 1 ? "视频" : d.resourcesInfoType == 2 ? "PPT" : d.resourcesInfoType == 3 ? "PDF" : d.resourcesInfoType == 4 ? "链接" : d.resourcesInfoType == 5 ? "图文" : '-';
return '<span class="textType">' + text + '</span>';
}
},
{
field: 'userId',
title: '操作',
width: 160,
align: "center",
templet: function (d) {
var htm = '<button type="button" class="layui-btn layui-btn-xs bg_button" lay-event="previewPage">查看</button></a>';
htm += '<button type="button" class="layui-btn layui-btn-xs bg_button" lay-event="del">删除</button></a>';
return htm;
}
}
]]
});
table.on('tool(resourcesInfoShowPPTTable)', function (obj) {
var data = obj.data;
if (obj.event === 'previewPage') { //预览
Lib.downloadFile(data);
}else if(obj.event === 'del'){
checkStatusData.splice(data, 1); // 删除
resourcesInfoShowPPTTable.reload({data:checkStatusData});
}
});
}
/*资源表格搜索*/
/*资源表格搜索*/
function searchList(resourcesInfoTypePlural) {
resourcesInfoTable.reload({
where: getParamRe(resourcesInfoTypePlural),
page: {
curr: 1
}
});
}
/*资源库搜索条件*/
function getParamRe(resourcesInfoTypePlural){
var param = {
"courseInfoId_0": $("#edit_dialog select[name='courseInfoId_0']").val(),
"resourcesInfoName": $("#edit_dialog input[name = 'resourcesInfoName']").val(),
"resourcesInfoTypePlural":resourcesInfoTypePlural
};
return param;
}
exports('add',view);
});