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 =' '; + 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 @@