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.
146 lines
5.9 KiB
JavaScript
146 lines
5.9 KiB
JavaScript
layui.define([ 'form', 'laydate', 'table','courseInfoApi',"layedit"], function(exports) {
|
|
var form = layui.form;
|
|
var courseInfoApi = layui.courseInfoApi;
|
|
var index = layui.index;
|
|
var transfer = layui.transfer;
|
|
var layedit = layui.layedit;
|
|
|
|
// var resourcesApplicationIds = $("input[name='resourcesApplicationIds']").val();
|
|
// if(!$.isEmpty(resourcesApplicationIds)){
|
|
// resourcesApplicationIds = resourcesApplicationIds.split(",");
|
|
// }
|
|
// var ret = Common.getAjax("/jlw/resourcesApplication/getValues.json");
|
|
// if(ret.code == 0){
|
|
// //显示搜索框
|
|
// transfer.render({
|
|
// elem: '#transfer'
|
|
// ,data: ret.data
|
|
// ,width:"400"
|
|
// ,title: ['未选应用', '已选应用']
|
|
// ,showSearch: true
|
|
// ,id: 'key123' //定义唯一索引
|
|
// ,parseData: function(res){
|
|
// return {
|
|
// "value": res.resourcesApplicationId //数据值
|
|
// ,"title": res.applicationName //数据标题
|
|
// }
|
|
// }
|
|
// ,value:resourcesApplicationIds
|
|
// ,onchange: function(data, index){
|
|
// var ids = "";
|
|
// $.each(transfer.getData("key123"),function (key,v){
|
|
// console.log(v.value);
|
|
// ids += v.value;
|
|
// if(key < transfer.getData("key123").length - 1){
|
|
// ids += ",";
|
|
// }
|
|
// });
|
|
// $("input[name='resourcesApplicationIds']").val(ids);
|
|
// }
|
|
//
|
|
// });
|
|
// }else {
|
|
// layer.msg(ret.msg);
|
|
// }
|
|
layedit.set({ //富文本上传图片
|
|
uploadImage: {
|
|
url: Common.ctxPath + "/jlw/file/update.do",
|
|
imgUrl:Common.ctxPath,
|
|
type: 'post' //默认post
|
|
}
|
|
});
|
|
|
|
var courseInfoContent_ = layedit.build('courseInfoContent',{height:100}); //题干
|
|
var view = {
|
|
init:function(){
|
|
Lib.initGenrealForm($("#addForm"),form);
|
|
this.initSubmit();
|
|
},
|
|
initSubmit:function(){
|
|
$("#addButton").click(function(){
|
|
form.on('submit(form)', function(){
|
|
var courseInfoId = $("#addForm input[name='courseInfoId']").val();
|
|
var courseInfoContent = layedit.getContent(courseInfoContent_);//课程简介
|
|
var courseInfoThumbnail = $("#addForm input[name='courseInfoThumbnail']").val();
|
|
|
|
var courseLabelId = $("#addForm select[name='courseLabelId']").val();
|
|
var courseInfoName = $("#addForm input[name='courseInfoName']").val();
|
|
if($.isEmpty(courseInfoName)){
|
|
Common.info("请输入课程名称!!");
|
|
return;
|
|
}
|
|
|
|
|
|
if($.isEmpty(courseLabelId)){
|
|
Common.info("请选中对应课程标签!!");
|
|
return;
|
|
}
|
|
if($.isEmpty(courseInfoThumbnail)){
|
|
Common.info("请上传图片!!");
|
|
return;
|
|
}
|
|
if($.isEmpty(courseInfoContent)){
|
|
Common.info("请输入课程简介!!");
|
|
return;
|
|
}
|
|
var param={'courseInfoContent':courseInfoContent,'courseInfoType':1};
|
|
|
|
if($.isEmpty(courseInfoId)){
|
|
courseInfoApi.addCourseInfo($('#addForm'),function(){
|
|
parent.window.dataReload();
|
|
Common.info("添加成功");
|
|
Lib.closeFrame();
|
|
},param);
|
|
}else {
|
|
courseInfoApi.updateCourseInfo($('#addForm'),function(){
|
|
parent.Lib.tableRefresh();
|
|
Common.info("编辑成功!");
|
|
Lib.closeFrame();
|
|
},param);
|
|
}
|
|
});
|
|
});
|
|
|
|
$("#addButton-cancel").click(function(){
|
|
Lib.closeFrame();
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
//绑定课程名称选择
|
|
form.on('select(select_courseLabelType)', function (obj) {
|
|
if(!$.isEmpty(obj.value)){
|
|
var ret = Common.getAjax("/jlw/courseLabel/getValues.json",{courseLabelType:obj.value,courseLabelStatus:1});
|
|
if(ret.code == 0){
|
|
var htm = '<option value="">请选择</option>';
|
|
for (var i = 0;i< ret.data.length;i++){
|
|
htm += '<option value="'+ret.data[i].courseLabelId+'">'+ret.data[i].courseLabelName+'</option>';
|
|
}
|
|
$("select[name='courseLabelId']").empty();
|
|
$("select[name='courseLabelId']").append(htm);
|
|
form.render();
|
|
}
|
|
}else {
|
|
$("select[name='courseLabelId']").empty();
|
|
form.render();
|
|
}
|
|
if(obj.value == '应用课程类'){
|
|
$("#appIsShow").css('display','block');
|
|
$("#testIsShow").css('display','none');
|
|
$("#courseIsShow").css('display','none');
|
|
|
|
}else if(obj.value == '考证课程类'){
|
|
$("#appIsShow").css('display','none');
|
|
$("#testIsShow").css('display','block');
|
|
$("#courseIsShow").css('display','none');
|
|
$("#addForm select[name='resourcesApplicationIds']").val("");
|
|
}else if(obj.value == '理论课程类'){
|
|
$("#appIsShow").css('display','none');
|
|
$("#testIsShow").css('display','none');
|
|
$("#courseIsShow").css('display','block');
|
|
$("#addForm select[name='resourcesApplicationIds']").val("");
|
|
}
|
|
});
|
|
exports('add',view);
|
|
}); |