课程绑定_备份

beetlsql3-dev
Mlxa0324 2 years ago
commit d04ea1d563

@ -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 += '<a class="layui-table-link" lay-event="binding">绑定</a>';
htm += '<input type="checkbox" name="" lay-filter="binding" checked title="绑定">';
htm += '<a class="layui-table-link" style="padding-left: 15px" lay-event="edit">编辑</a>';
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 = '<option value="">请选择</option>';
for (var i = 0;i< ret.data.length;i++){
htm += '<option value="'+ret.data[i].courseLabelId+'">'+ret.data[i].courseLabelName+'</option>';
}
$(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);
});

@ -0,0 +1,86 @@
<!--# layout("/common/layout.html",{"jsBase":"/js/jlw/courseInfo/"}){ -->
<link rel="stylesheet" type="text/css" href="${ctxPath}/css/plugin.css?v=${jsVer}" media="all"/>
<form class="layui-form" id="addForm">
<div style="margin-left: 80px;">
<layui:submitButtons id="addButton" buttonType="" />
</div>
<div class="layui-row" style="margin-left: 80px;">
<div class="layui-form-item">
<div class="layui-inline">
课程管理/新增课程
</div>
</div>
</div>
<div class="layui-row">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label"><span class="req">*</span>课程名称:</label>
<div class="layui-input-inline">
<input type="text" name="courseInfoName" disabled value="${courseInfo.courseInfoName}" placeholder="请输入课程名称" class="layui-input" >
</div>
</div>
</div>
</div>
<div class="layui-row">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label"><span class="req">*</span>课程模块:</label>
<div class="layui-input-inline">
<!-- '应用课程类','考证课程类','理论课程类';-->
<select lay-filter="select_courseLabelType">
<option value="">请选择</option>
<option value="应用课程类" ${courseInfo.courseLabelType =='应用课程类'?'selected':''}>应用课程类</option>
<option value="考证课程类" ${courseInfo.courseLabelType =='考证课程类'?'selected':''}>考证课程类</option>
<option value="理论课程类" ${courseInfo.courseLabelType =='理论课程类'?'selected':''}>理论课程类</option>
</select>
</div>
</div>
</div>
</div>
<div class="layui-row">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label"><span class="req">*</span>课程类别:</label>
<div class="layui-input-inline">
<!--#if(courseInfo.courseLabelId != null){-->
<layui:simpleDictSelect style='layui-input-inline' value="${courseInfo.courseLabelId}"
type="course_label.course_label_name.course_label_type=${courseInfo.courseLabelType},course_label_status=1"
id="courseLabelId" name="courseLabelId"/>
<!--#}else{-->
<select name="courseLabelId"></select>
<!--#}-->
</div>
</div>
</div>
</div>
<div class="layui-row">
<div class="layui-form-item">
<input name="resourcesApplicationIds" type="hidden" value="${courseInfo.resourcesApplicationIds}" />
<label class="layui-form-label"><span class="req">*</span>关联应用:</label>
<div class="layui-input-block" style="margin-left: 180px;">
<div id="transfer" class="demo-transfer"></div>
</div>
</div>
</div>
<input type="hidden" name="courseInfoId" value='${courseInfo.courseInfoId}' />
<!--类型(1课程 2章 3节)-->
<input type="hidden" name="courseInfoType" value='1' />
</form>
<!--#} -->
<script>
layui.use(['add','upload'], function(){
var courseInfoAdd = layui.add;
var upload = layui.upload;
courseInfoAdd.init();
//上传LOGO
upload.render({
elem: '#test10'
, url: Common.ctxPath + "/jlw/file/update.do"
, done: function (res) {//每成功一次调用
$("#logo").hide();
layui.$('#uploadDemoView').removeClass('layui-hide').find('img').attr('src',Common.ctxPath + res.data.src);
$("input[name='courseInfoThumbnail']").val(res.data.src);
}
});
});
</script>

@ -0,0 +1,62 @@
<!--#layout("/common/layout.html",{"jsBase":"/js/jlw/resourcesApplicationCourse/"}){ -->
<style>
.layui-table-body, .layui-table-box, .layui-table-cell{
overflow:visible;
}
.layui-table a {
margin-right: 10px;
}
td .layui-form-select {
margin-top: -10px;
margin-left: -15px;
margin-right: -15px;
}
.layui-form-select dl {
text-align: left;
}
</style>
<layui:searchForm formId="searchForm" searchList="" condition="${search}">
<div class="layui-inline">
<label class="layui-form-label">课程名称</label>
<div class="layui-input-inline">
<input type="text" name="courseInfoName" id="courseInfoName" autocomplete="off" placeholder="请输入检索条件" class="layui-input"
style="width: 200px;float: left;margin-right: 10px;">
</div>
</div>
</layui:searchForm>
<script type="text/html" id="select_resourcesApplicationIds" >
<layui:simpleDictSelect style='layui-input-inline'
layFilter="select_resourcesApplicationIds"
type="resources_application.application_name.1=1"
id="resourcesApplicationIds" name="resourcesApplicationIds"/>
</script>
<script type="text/html" id="select_courseLabelTypeSelect">
<select lay-filter="select_courseLabelType" name="courseLabelType">
<option value="">请选择</option>
{{# layui.each(window.disLabelTypeSelectList, function(index, item){ }}
<option value="{{item}}" {{ item == d.courseLabelType ? 'selected' : '' }}>{{item}}</option>
{{# }); }}
</select>
</script>
<script type="text/html" id="select_courseLabelIdSelect">
<select lay-filter="select_courseLabelId" name="courseLabelId">
<option value="">请选择</option>
{{# layui.each(window.courseLabelList, function(index, item){ }}
<option value="{{item.courseLabelId}}" {{ item.courseLabelId == d.courseLabelId ? 'selected' : '' }}>{{item.courseLabelName}}</option>
{{# }); }}
</select>
</script>
<table id="resourcesApplicationCourseTable" lay-filter="resourcesApplicationCourseTable"></table>
<!--#} -->
<script>
layui.use(['index'], function(){
var index = layui.index;
index.init();
});
</script>
Loading…
Cancel
Save