diff --git a/web/src/main/resources/static/js/jlw/resourcesApplicationCourse/index.js b/web/src/main/resources/static/js/jlw/resourcesApplicationCourse/index.js index 4cfb1905..37f81f88 100644 --- a/web/src/main/resources/static/js/jlw/resourcesApplicationCourse/index.js +++ b/web/src/main/resources/static/js/jlw/resourcesApplicationCourse/index.js @@ -1,7 +1,8 @@ -layui.define(['form', 'laydate', 'table'], function (exports) { +layui.define(['form', 'laydate', 'table', 'dropdown', 'util'], function (exports) { var form = layui.form; var laydate = layui.laydate; var table = layui.table; + var dropdown = layui.dropdown, util = layui.util; var resourcesApplicationCourseTable = null; // 查询去重的标签列表 window.disLabelTypeSelectList = Common.postAjax('/jlw/courseLabel/disLabelType.json').data; @@ -17,6 +18,8 @@ layui.define(['form', 'laydate', 'table'], function (exports) { } }, initTable: function () { + //更多下拉菜单 + resourcesApplicationCourseTable = table.render({ elem: '#resourcesApplicationCourseTable', height: Lib.getTableHeight(1), @@ -51,6 +54,7 @@ layui.define(['form', 'laydate', 'table'], function (exports) { }, { field: 'courseLabelId', + id: 'sdfs', title: '绑定模块', align: "center", templet: '#select_courseLabelIdSelect' @@ -66,18 +70,18 @@ layui.define(['form', 'laydate', 'table'], function (exports) { if (d.courseLabelType == '应用课程类') { copyHtml = $($('#select_resourcesApplicationIds').html()); - if(!$.isEmpty(d.resourcesApplicationIds)){ - copyHtml.find("option[value="+d.resourcesApplicationIds.split(',')[0]+"]").attr("selected", true); + if (!$.isEmpty(d.resourcesApplicationIds)) { + copyHtml.find("option[value=" + d.resourcesApplicationIds.split(',')[0] + "]").attr("selected", true); } copyHtml = copyHtml.html(); - }else if (d.courseLabelType == '考证课程类') { + } else if (d.courseLabelType == '考证课程类') { copyHtml = '\n'; return copyHtml - }else if (d.courseLabelType == '理论课程类') { - copyHtml =' \n' + ' \n' + ' \n' + ' '; @@ -92,16 +96,20 @@ layui.define(['form', 'laydate', 'table'], function (exports) { align: "center", templet: function (d) { var htm = ''; - // htm += '绑定'; - htm += ''; + // htm += '绑定'; + if (d.courseLabelType == "应用课程类" && $.isEmpty(d.resourcesApplicationIds)) { + htm += ''; + } else { + htm += ''; + } htm += '编辑'; return htm; } } ]] - /* ,done: function (res, curr, count) { + /* ,done: function (res, curr, count) { - }*/ + }*/ }); table.on('checkbox(resourcesApplicationCourseTable)', function (obj) { @@ -149,11 +157,12 @@ layui.define(['form', 'laydate', 'table'], function (exports) { toolbar[type] ? toolbar[type].call(this) : ''; }); }, initTableTool: table.on('tool(resourcesApplicationCourseTable)', function (obj) { + var that = this; var data = obj.data; if (obj.event === 'edit') { // 实际是修改课程的数据,为了懒省事 var url = "/jlw/resourcesApplicationCourse/add.do?courseInfoId=" + data.courseInfoId; - Common.openDlg(url, ""); + Common.openDlg(url, "编辑"); } else if (obj.event === "del") { layer.confirm('是否确定删除该课程?', function (index) { //courseInfoStatus:状态(1启用 2禁用 3删除) var ret = Common.postAjax("/jlw/resourcesApplicationCourse/delete.json", {ids: data.resourcesApplicationCourseId}); @@ -172,9 +181,9 @@ layui.define(['form', 'laydate', 'table'], function (exports) { var data = obj.data; var param = { courseInfoId: data.courseInfoId, - courseLabelType:data.courseLabelType, - courseLabelId:data.courseLabelId, - resourcesApplicationIds:data.resourcesApplicationIds, + courseLabelType: data.courseLabelType, + courseLabelId: data.courseLabelId, + resourcesApplicationIds: data.resourcesApplicationIds, }; console.log(param) return; @@ -189,10 +198,46 @@ layui.define(['form', 'laydate', 'table'], function (exports) { } }); }); + } else if (obj.event === "labelSelect") { + var childData = []; + var ret = Common.getAjax("/jlw/courseLabel/getValues.json", { + courseLabelType: '理论课程类', + courseLabelStatus: 1 + }); + if (ret.code == 0) { + var htm = ''; + for (var i = 0; i < ret.data.length; i++) { + childData.push({ + title: ret.data[i].courseLabelName, + id: ret.data[i].courseLabelId + }); + } + } + dropdown.render({ + elem: that + , show: true //外部事件触发即显示 + , data: [{ + title: '课程中心' + , id: 'aaa' + , child: childData + }] + , click: function (data, othis) { + var tr = obj.tr; + this.elem.val('课程中心 / ' + data.title); + var index = tr.data("index"); + table.cache['resourcesApplicationCourseTable'][index].courseLabelId = data.id; + table.cache['resourcesApplicationCourseTable'][index].courseLabelName = data.title; + } + , align: 'right' //右对齐弹出(v2.6.8 新增) + , style: 'box-shadow: 1px 1px 10px rgb(0 0 0 / 12%);' //设置额外样式 + }); + updateBindingBtnStatus(this); + form.render(); } }) }; + /** * 修改绑定checkbox状态 */ @@ -221,32 +266,33 @@ layui.define(['form', 'laydate', 'table'], function (exports) { } });*/ form.on('select(select_courseLabelType)', function (obj) { - if(!$.isEmpty(obj.value)){ - var htm = ''; - var htm_application =''; + if (!$.isEmpty(obj.value)) { + var htm = ''; + htm_application = $($('#select_resourcesApplicationIds').html()).children('select').html(); table.cache['resourcesApplicationCourseTable'][index].courseLabelType = '应用课程类'; - }else if(obj.value == "考证课程类"){ - htm+=''; - htm_application+=''; + } else if (obj.value == "考证课程类") { + htm += ''; + htm_application += ''; table.cache['resourcesApplicationCourseTable'][index].courseLabelType = '考证课程类'; - }else if(obj.value == "理论课程类"){ - htm+=''; - htm_application+=''; + + } else if (obj.value == "理论课程类") { + htm = ''; + htm_application += ''; table.cache['resourcesApplicationCourseTable'][index].courseLabelType = '理论课程类'; } - $(this).parents("td").siblings('td').eq(1).find('select').empty(); - $(this).parents("td").siblings('td').eq(1).find('select').append(htm); + $(this).parents("td").siblings('td').eq(1).find('div').empty(); + $(this).parents("td").siblings('td').eq(1).find('div').append(htm); $(this).parents("td").siblings('td').eq(2).find('select').empty(); $(this).parents("td").siblings('td').eq(2).find('select').append(htm_application); updateBindingBtnStatus(this); form.render(); - }else { + } else { $(this).parents("td").siblings('td').eq(1).find('select').empty(); form.render(); @@ -267,33 +313,48 @@ layui.define(['form', 'laydate', 'table'], function (exports) { form.on('checkbox(binding)', function (obj) { var index = $(this).parents("tr").data("index"); + var ht = $(this).parents("td"); + layer.confirm('是否确定绑定?', function (i) { - var data = table.cache['resourcesApplicationCourseTable'][index]; - var param = {}; - if(data.courseLabelType == '应用课程类'){ - param = { - courseInfoId: data.courseInfoId, - courseLabelType:'应用课程类', - courseLabelId:data.courseLabelId, - resourcesApplicationIds:data.resourcesApplicationIds, - }; - }else if(data.courseLabelType == '理论课程类'){ - param = {courseInfoId: data.courseInfoId,courseLabelType:'理论课程类'}; - }else if(data.courseLabelType == '考证课程类') { - param = {courseInfoId: data.courseInfoId, courseLabelType: '考证课程类'}; - } - var ret = Common.postAjax("/jlw/courseInfo/courseBind.json", 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.tableRefresh(); + var data = table.cache['resourcesApplicationCourseTable'][index]; + var param = {}; + if (data.courseLabelType == '应用课程类') { + param = { + courseInfoId: data.courseInfoId, + courseLabelType: '应用课程类', + /*courseLabelId: data.courseLabelId,*/ + resourcesApplicationIds: data.resourcesApplicationIds, + }; + } else if (data.courseLabelType == '理论课程类') { + param = {courseInfoId: data.courseInfoId, courseLabelType: '理论课程类', courseLabelId: data.courseLabelId}; + } else if (data.courseLabelType == '考证课程类') { + param = {courseInfoId: data.courseInfoId, courseLabelType: '考证课程类'}; } + var ret = Common.postAjax("/jlw/courseInfo/courseBind.json", 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.tableRefresh(); + } else { + ht.find('input:checkbox[title=绑定]').prop('checked', false) + form.render('checkbox'); + } + }); + }, + function (index) { + + if (obj.elem.checked) { + ht.find('input:checkbox[title=绑定]').prop('checked', false); + } else { + ht.find('input:checkbox[title=绑定]').prop('checked', true); + console.log(obj.elem.checked) + } + form.render('checkbox'); }); - }); - }) + }); exports('index', view); diff --git a/web/src/main/resources/templates/jlw/resourcesApplicationCourse/index.html b/web/src/main/resources/templates/jlw/resourcesApplicationCourse/index.html index 1a47aedf..a070c49c 100644 --- a/web/src/main/resources/templates/jlw/resourcesApplicationCourse/index.html +++ b/web/src/main/resources/templates/jlw/resourcesApplicationCourse/index.html @@ -1,17 +1,24 @@ @@ -19,7 +26,8 @@
-
@@ -29,9 +37,10 @@ @@ -45,20 +54,23 @@ --> -