diff --git a/web/src/main/resources/static/js/jlw/resourcesApplicationCourse/index_back.js b/web/src/main/resources/static/js/jlw/resourcesApplicationCourse/index_back.js new file mode 100644 index 00000000..0cb64fe4 --- /dev/null +++ b/web/src/main/resources/static/js/jlw/resourcesApplicationCourse/index_back.js @@ -0,0 +1,237 @@ +layui.define(['form', 'laydate', 'table'], function (exports) { + var form = layui.form; + var laydate = layui.laydate; + var table = layui.table; + var resourcesApplicationCourseTable = null; + // 查询去重的标签列表 + window.disLabelTypeSelectList = Common.postAjax('/jlw/courseLabel/disLabelType.json').data; + window.courseLabelList = Common.getAjax('/jlw/courseLabel/getValues.json?courseLabelStatus=1').data; + + var view = { + init: function () { + this.initTable(); + this.initSearchForm(); + this.initToolBar(); + window.dataReload = function () { + Lib.doSearchForm($("#searchForm"), resourcesApplicationCourseTable) + } + }, + initTable: function () { + resourcesApplicationCourseTable = table.render({ + elem: '#resourcesApplicationCourseTable', + height: Lib.getTableHeight(1), + cellMinWidth: 100, + method: 'post', + url: Common.ctxPath + '/jlw/courseInfo/courseInfoList.json' // 数据接口 + , page: Lib.tablePage // 开启分页 + , limit: 10, + size: 'lg', + cols: [[ // 表头 + /*{ + type : 'checkbox', + fixed:'left', + },*/ + /* { + + field: 'resourcesApplicationCourseId', + title: 'ID', + fixed: 'left', + width: 60 + },*/ + { + field: 'courseInfoName', + align: "center", + title: '课程名称', + }, + { + field: 'courseLabelType', + title: '绑定模块', + align: "center", + templet: '#select_courseLabelTypeSelect', + }, + { + field: 'courseLabelId', + title: '课程类别', + align: "center", + templet: '#select_courseLabelIdSelect' + }, + { + field: 'resourcesApplicationIds', + title: '绑定应用', + align: "center", + templet: function (d) { + // html字符串转对象,深拷贝操作,相当于每行copy一个下拉框进行回显选中操作 + var copyHtml = $($('#select_resourcesApplicationIds').html()) + copyHtml.find("option[value="+d.resourcesApplicationIds+"]").attr("selected", true); + return copyHtml.html(); + } + }, + { + field: 'operation_', + title: '操作', + align: "center", + templet: function (d) { + var htm = ''; + // htm += '绑定'; + htm += ''; + htm += '编辑'; + return htm; + } + } + ]] + /* ,done: function (res, curr, count) { + + }*/ + }); + + table.on('checkbox(resourcesApplicationCourseTable)', function (obj) { + var resourcesApplicationCourse = obj.data; + if (obj.checked) { + //按钮逻辑Lib.buttonEnable() + } else { + + } + }); + table.on('edit(resourcesApplicationCourseTable)', function (obj) { //注:edit是固定事件名,test是table原始容器的属性 lay-filter="对应的值" + console.log(obj.value); //得到修改后的值 + console.log(obj.field); //当前编辑的字段名 + console.log(obj.data); //所在行的所有相关数据 + }); + }, + + initSearchForm: function () { + Lib.initSearchForm($("#searchForm"), resourcesApplicationCourseTable, form); + + }, + initToolBar: function () { + toolbar = { + add: function () { // 获取选中数据 + var url = "/jlw/resourcesApplicationCourse/add.do"; + Common.openDlg(url, "ResourcesApplicationCourse管理>新增"); + }, + edit: function () { // 获取选中数目 + var data = Common.getOneFromTable(table, "resourcesApplicationCourseTable"); + if (data == null) { + return; + } + var url = "/jlw/resourcesApplicationCourse/edit.do?resourcesApplicationCourseId=" + data.resourcesApplicationCourseId; + Common.openDlg(url, "ResourcesApplicationCourse管理>" + data.resourcesApplicationCourseId + ">编辑"); + }, + del: function () { + layui.use(['del'], function () { + var delView = layui.del + delView.delBatch(); + }); + } + }; + $('.ext-toolbar').on('click', function () { + var type = $(this).data('type'); + toolbar[type] ? toolbar[type].call(this) : ''; + }); + }, initTableTool: table.on('tool(resourcesApplicationCourseTable)', function (obj) { + var data = obj.data; + if (obj.event === 'edit') { + var url = "/jlw/resourcesApplicationCourse/add.do?courseInfoId=" + data.courseInfoId; + 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}); + 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 if (obj.event === "binding") { + layer.confirm('是否确定绑定?', function (index) { + var data = obj.data; + var param = { + courseInfoId: data.courseInfoId, + courseLabelType:data.courseLabelType, + courseLabelId:data.courseLabelId, + resourcesApplicationIds:data.resourcesApplicationIds, + }; + var ret = Common.postAjax("/jlw/courseInfo/edit.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(); + } + }); + }); + } + }) + }; + + /** + * 修改绑定checkbox状态 + */ + function updateBindingBtnStatus(that) { + $(that).parents("td").parents("tr").find('input:checkbox[title=绑定]').attr('checked', false); + form.render('checkbox'); + } + + //绑定课程名称选择 + 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 = ''; + for (var i = 0;i< ret.data.length;i++){ + htm += ''; + } + $(this).parents("td").siblings('td').eq(1).find('select').empty(); + $(this).parents("td").siblings('td').eq(1).find('select').append(htm); + updateBindingBtnStatus(this); + form.render(); + } + }else { + $(this).parents("td").siblings('td').eq(1).find('select').empty(); + form.render(); + } + }); + + // 下拉框change事件 + form.on('select(select_courseLabelId)', function (obj) { + table.cache['resourcesApplicationCourseTable'][$(this).parents("tr").data("index")].courseLabelId = obj.value; + updateBindingBtnStatus(this); + }); + + form.on('select(select_resourcesApplicationIds)', function (obj) { + table.cache['resourcesApplicationCourseTable'][$(this).parents("tr").data("index")].resourcesApplicationIds = obj.value; + updateBindingBtnStatus(this); + }); + + form.on('checkbox(binding)', function (obj) { + var index = $(this).parents("tr").data("index") + layer.confirm('是否确定绑定?', function (i) { + var data = table.cache['resourcesApplicationCourseTable'][index]; + var param = { + courseInfoId: data.courseInfoId, + courseLabelType:data.courseLabelType, + courseLabelId:data.courseLabelId, + resourcesApplicationIds:data.resourcesApplicationIds, + }; + var ret = Common.postAjax("/jlw/courseInfo/edit.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(); + } + }); + }); + }) + exports('index', view); + + +}); \ No newline at end of file diff --git a/web/src/main/resources/templates/jlw/resourcesApplicationCourse/add_back.html b/web/src/main/resources/templates/jlw/resourcesApplicationCourse/add_back.html new file mode 100644 index 00000000..4cf19a50 --- /dev/null +++ b/web/src/main/resources/templates/jlw/resourcesApplicationCourse/add_back.html @@ -0,0 +1,86 @@ + + +
+
+ +
+
+
+
+ 课程管理/新增课程 +
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ + +
+
+
+
+
+
+
+ +
+ + + + + +
+
+
+
+
+
+ + +
+
+
+
+
+ + + +
+ + diff --git a/web/src/main/resources/templates/jlw/resourcesApplicationCourse/index_back.html b/web/src/main/resources/templates/jlw/resourcesApplicationCourse/index_back.html new file mode 100644 index 00000000..4aa56459 --- /dev/null +++ b/web/src/main/resources/templates/jlw/resourcesApplicationCourse/index_back.html @@ -0,0 +1,62 @@ + + + +
+ +
+ +
+
+
+ + + + + + +
+ +