112 lines
4.4 KiB
JavaScript

layui.define([ 'form', 'laydate', 'table','laytpl','upload','layedit','teacherOpenCourseHandsOnApi'], function(exports) {
var form = layui.form;
var teacherOpenCourseHandsOnApi = layui.teacherOpenCourseHandsOnApi;
var index = layui.index;
var upload = layui.upload;
var layedit = layui.layedit;
var laytpl = layui.laytpl
layedit.set({ //富文本上传图片
uploadImage: {
url: Common.ctxPath + "/jlw/file/update.do",
imgUrl:Common.ctxPath
}
});
var courseInfoParentId = $("select[name='courseInfoId']").val();//课程ID
var sourceType = $("select[name='courseInfoId']").find('option:selected').attr("status");
var childValue = $("#courseChildNode").val();
//反显章节下拉框key,courseInfoParentId,courseInfoType,sourceType,resourcesQuestionIdsIsNotNull
Lib.getCourseInfo($("select[name='courseChildNode']"),courseInfoParentId,2,sourceType,'',childValue);
form.render();
window.loadList = function (){//重新加载实训任务列表
getListInfo();
}
var handsOnId = $("input[name='handsOnId']").val();
var teacherOpenCourseId = $("input[name='teacherOpenCourseId']").val();
var one = layedit.build('test-editor'); //建立编辑器
if(!$.isEmpty(handsOnId)){
var ret = Common.getAjax("/jlw/handsOn/view.json",{handsOnId:handsOnId});
if(ret.code == 0){
layedit.setContent(one,Lib.repLaceltgt(ret.data.applicationIntroduction),false);
}else {
layer.msg(ret.msg, {
offset: ['50%'],
icon: 2,
time: 1500 //2秒关闭如果不配置默认是3秒
});
}
}
var view = {
init:function(){
Lib.initGenrealForm($("#updateForm"),form);
this.initSubmit();
},
initSubmit:function(){
$("#updateButton").click(function(){
form.on('submit(form)', function(){
teacherOpenCourseHandsOnApi.updateTeacherOpenCourseHandsOn($('#updateForm'),function(){
parent.window.dataReload();
Common.info("更新成功");
Lib.closeFrame();
});
});
});
$("#updateButton-cancel").click(function(){
Lib.closeFrame();
});
}
}
//选择归属课程 并且根据选择的课程查询章节 resourcesQuestionIdsIsNotNull:查询题目不为空的章节
form.on('select(select_courseInfoIds)', function (obj) {
let sourceType = $("select[name='courseInfoId']").find('option:selected').attr("status");
let courseInfoType = 2;//courseInfoType2 章节3 节)
Lib.getCourseInfo($("select[name='courseChildNode']"), obj.value,courseInfoType,sourceType);
});
$(".button_add").click(() => {
handsOnId = $("#updateForm input[name='handsOnId']").val();
if (!$.isEmpty(handsOnId)){
var url = "/jlw/handsOnSimulationTasks/add.do?handsOnId="+handsOnId+'&courseInfoId='+teacherOpenCourseId;
Common.openDlg(url);
}
});
//实训任务编辑
$(".bj").click(edit_simu)
function edit_simu(){
var taskId = $(this).attr("taskid");
var url = "/jlw/handsOnSimulationTasks/add.do?taskId="+taskId + "&handsOnId="+handsOnId;
Common.openDlg(url,"");
}
//实训任务删除
$(".sc").click(del_simu)
function del_simu(){
var taskId = $(this).attr("taskid");
var ret = Common.postAjax("/jlw/handsOnSimulationTasks/delete.json",{ids:taskId})
if (ret.code == 0) {
$(this).parent().parent().remove()
}
}
$(".uploader-file-cancel").click(function () {
$(this).parent().parent().remove()
});
function getListInfo(){ //获取
var ret = Common.postAjax("/api/handsOnSimulationTasks/getPageList.do",{handsOnId:$("#updateForm input[name='handsOnId']").val()})
if (ret.code == 0) {
var getTpl = sc_demo.innerHTML
,view = document.getElementById('sc_view');
laytpl(getTpl).render({list:ret.data}, function(html){
view.innerHTML = html;
$(".bj").unbind();
$(".sc").unbind();
$(".bj").click(edit_simu);
$(".sc").click(del_simu);
});
}
}
exports('edit',view);
});