/** * 用户详情对话框(可用于添加和修改对话框) */ var CourseInfo = { userInfoData: {}, }; /** * 关闭此对话框 */ CourseInfo.close = function () { parent.layer.close(window.parent.Course.layerIndex); }; /** * 提交添加用户 */ CourseInfo.addSubmit = function () { let type = $('#type').val(); let name = $('#name').val(); let introduce = $('#introduce').val(); let coverDrawing = $('#coverDrawing').val(); let introductionDrawing = $('#introductionDrawing').val(); let courseVideo = $('#courseVideo').val(); if(null == name || '' == name){ Feng.error("课程名称不能为空"); return } if(null == coverDrawing || '' == coverDrawing){ Feng.error("课程封面不能为空"); return } if(null == introductionDrawing || '' == introductionDrawing){ Feng.error("课程介绍不能为空"); return } if(null == courseVideo || '' == courseVideo){ Feng.error("课程内容不能为空"); return } let obj = { type: type, name: name, introduce: introduce, coverDrawing: coverDrawing, introductionDrawing: introductionDrawing, courseVideo: courseVideo } //提交信息 var ajax = new $ax(Feng.ctxPath + "/course/addCourse", function (data) { Feng.success("添加成功!"); window.parent.Course.table.refresh(); CourseInfo.close(); }, function (data) { Feng.error("添加失败!" + data.responseJSON.message + "!"); }); ajax.set(obj); ajax.start(); }; /** * 提交修改 */ CourseInfo.editSubmit = function () { let id = $('#id').val(); let type = $('#type').val(); let name = $('#name').val(); let introduce = $('#introduce').val(); let coverDrawing = $('#coverDrawing').val(); let introductionDrawing = $('#introductionDrawing').val(); let courseVideo = $('#courseVideo').val(); if(null == name || '' == name){ Feng.error("课程名称不能为空"); return } if(null == coverDrawing || '' == coverDrawing){ Feng.error("课程封面不能为空"); return } if(null == introductionDrawing || '' == introductionDrawing){ Feng.error("课程介绍不能为空"); return } if(null == courseVideo || '' == courseVideo){ Feng.error("课程内容不能为空"); return } let obj = { id: id, type: type, name: name, introduce: introduce, coverDrawing: coverDrawing, introductionDrawing: introductionDrawing, courseVideo: courseVideo } //提交信息 var ajax = new $ax(Feng.ctxPath + "/course/editCourse", function (data) { if(data.code == 200){ window.parent.Course.table.refresh(); CourseInfo.close(); Feng.success("修改成功!"); }else{ Feng.error(data.msg); } }, function (data) { Feng.error("修改失败!" + data.responseJSON.message + "!"); }); ajax.set(obj); ajax.start(); }; function onBodyDown(event) { if (!(event.target.id == "menuBtn" || event.target.id == "menuContent" || $( event.target).parents("#menuContent").length > 0)) { CourseInfo.hideDeptSelectTree(); } } function UploadFileFn(){ $('#upFile').click(); } $(function () { $('#upFile').on('change', function () { var formData = new FormData() //创建一个forData formData.append('file', $('#upFile')[0].files[0]) //把file添加进去 name命名为img layer.load(); //上传loading $.ajax({ url: Feng.ctxPath + '/mgr/uploadFile', data: formData, type: "POST", async: true, cache: false, contentType: false, processData: false, success: function(res) { layer.closeAll('loading'); //关闭loading $('#upFile').val(''); $('#courseVideo').val(res); } }) }) });