diff --git a/web/src/main/resources/templates/jlw/courseInfo/courseConfigureNew.html b/web/src/main/resources/templates/jlw/courseInfo/courseConfigureNew.html index b9563b82..535d7b1c 100644 --- a/web/src/main/resources/templates/jlw/courseInfo/courseConfigureNew.html +++ b/web/src/main/resources/templates/jlw/courseInfo/courseConfigureNew.html @@ -79,7 +79,7 @@ item.resourcesInfo.forEach(function (e, i) { e.courseInfoParentId = e.courseInfoId; e.courseInfoId = 0; - e.courseInfoName = "资源名称:" + e.resourcesInfoName; + e.courseInfoName = e.resourcesInfoName; data.push(e); }) }); @@ -176,10 +176,10 @@ var param = { courseInfoParentId: courseInfoParentId, courseInfoType: 2, - courseInfoStatus: 1, - courseInfoName: "未命名" + courseInfoStatus: 1 }; - postCourseInfo("",param); + var title = "章节名称"; + addOpen('',title,'',param) }); /*返回*/ $("#addButton-cancel").click(function () { @@ -199,13 +199,12 @@ var data = obj.data; var courseInfoId = data.courseInfoId; if (obj.event === 'add') {//添加子章节 - var param = { + var param = { courseInfoParentId: courseInfoId, courseInfoType: 3, - courseInfoStatus: 1, - courseInfoName: "未命名" + courseInfoStatus: 1 }; - postCourseInfo("",param); + addOpen("",'子章节名称',"",param); }else if (obj.event === 'updateResources') {//上传资源 }else if (obj.event === 'addLine') {//添加链接 @@ -217,31 +216,18 @@ }else if (obj.event === 'update') {//上传 }else if(obj.event === 'edit'){ - layer.open({ - title: "编辑目录名称" - , content: '
\n' + - '\n' + - '
\n' + - '\n' + - '
\n' + - '
' - , btn: ['确定', '关闭'] - , shadeClose:true - , success:function () { - $("#editRoom input[name='courseInfoName']").val(data.courseInfoName) - } - , yes: function (index, layero) { - let param = { - "courseInfoId":courseInfoId, - "courseInfoName": $("#editName input[name='courseInfoName']").val(), - }; - layer.close(index); - postCourseInfo(courseInfoId, param); - }, - btn2: function (index, layero) { - layer.close(index); - } - }); + var title="章节目录"; + var param = {}; + var id = ''; + if (!$.isEmpty(data.resourcesInfoId)) { + title = "资源名称"; + param.resourcesInfoId= data.resourcesInfoId; + id = data.resourcesInfoId; + }else { + id = courseInfoId; + param.courseInfoId = courseInfoId; + } + addOpen(id,title,data,param); }else if (obj.event === 'del') { layer.confirm('是否确定删除该信息?', function (index) { layer.load(); @@ -277,6 +263,41 @@ } }); + function addOpen(id,title,data,param) { + layer.open({ + title: "编辑" + , content: '
\n' + + '\n' + + '
\n' + + '\n' + + '
\n' + + '
' + , btn: ['确定', '关闭'] + , shadeClose:true + , success:function () { + $("#editName input[name='courseInfoName']").val(data.courseInfoName) + } + , yes: function (index, layero) { + if($.isEmpty(id)){ + param.courseInfoName = $("#editName input[name='courseInfoName']").val(); + postCourseInfo('', param); + }else { + if(!$.isEmpty(param.resourcesInfoId)){ + param.resourcesInfoName = $("#editName input[name='courseInfoName']").val(); + postResourcesInfo(param.resourcesInfoId,param) + }else{ + param.courseInfoName = $("#editName input[name='courseInfoName']").val(); + postCourseInfo(id, param); + } + } + layer.close(index); + }, + btn2: function (index, layero) { + layer.close(index); + } + }); + } + function postCourseInfo(id, param) { layer.load(); setTimeout(function () { @@ -288,7 +309,29 @@ if (ret.code == 0) { courseInfoTable(); } - + layer.msg(ret.code == 0 ? "操作成功!" : ret.msg, { + offset: ['50%'], + icon: ret.code == 0 ? 1 : 2, + time: 1500 //2秒关闭(如果不配置,默认是3秒) + }, function () { + layer.closeAll(); + if (ret.code == 0) { + Lib.tableRefresh(); + } + }); + }, 50); + } + function postResourcesInfo(id, param) { + layer.load(); + setTimeout(function () { + var url = "/jlw/resourcesInfo/add.json"; + if (!$.isEmpty(id)) { + url = "/jlw/resourcesInfo/edit.json"; + } + var ret = Common.postAjax(url, param); + if (ret.code == 0) { + courseInfoTable(); + } layer.msg(ret.code == 0 ? "操作成功!" : ret.msg, { offset: ['50%'], icon: ret.code == 0 ? 1 : 2,