课程绑定-将下拉改成二级下拉

beetlsql3-dev
姚丹ab 2 years ago
parent da4660b7cd
commit a1f1ffe5ae

@ -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 = '<select lay-filter="select_resourcesApplicationIds" name="resourcesApplicationIds">\n' +
' <option value="">请选择</option>\n' +
' <option value="考证辅导" selected>考证辅导</option>\n' +
' </select>\n';
return copyHtml
}else if (d.courseLabelType == '理论课程类') {
copyHtml =' <select lay-filter="select_resourcesApplicationIds" name="resourcesApplicationIds">\n' +
} else if (d.courseLabelType == '理论课程类') {
copyHtml = ' <select lay-filter="select_resourcesApplicationIds" name="resourcesApplicationIds">\n' +
' <option value="">请选择</option>\n' +
' <option value="课程中心" selected>课程中心</option>\n' +
' </select>';
@ -92,16 +96,20 @@ layui.define(['form', 'laydate', 'table'], function (exports) {
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" lay-event="binding">绑定</a>';
if (d.courseLabelType == "应用课程类" && $.isEmpty(d.resourcesApplicationIds)) {
htm += '<input type="checkbox" name="" lay-filter="binding" title="绑定">';
} else {
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) {
/* ,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 = '<option value="">请选择</option>';
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 = '<option value="">请选择</option>';
var htm_application ='<option value="">请选择</option>';
if (!$.isEmpty(obj.value)) {
var htm = '<select lay-filter="select_courseLabelId" name="courseLabelId"><option value="">请选择</option>';
var htm_application = '<option value="">请选择</option>';
var index = $(this).parents("tr").data("index");
if(obj.value == '应用课程类'){
htm+='<option value="应用中心" selected>应用中心</option>';
htm_application = $($('#select_resourcesApplicationIds').html());
if (obj.value == '应用课程类') {
htm += '<option value="应用中心" selected>应用中心</option></select>';
htm_application = $($('#select_resourcesApplicationIds').html()).children('select').html();
table.cache['resourcesApplicationCourseTable'][index].courseLabelType = '应用课程类';
}else if(obj.value == "考证课程类"){
htm+='<option value="考证辅导" selected>考证辅导</option>';
htm_application+='<option value="考证辅导" selected>考证辅导</option>';
} else if (obj.value == "考证课程类") {
htm += '<option value="考证辅导" selected>考证辅导</option></select>';
htm_application += '<option value="考证辅导" selected>考证辅导</option>';
table.cache['resourcesApplicationCourseTable'][index].courseLabelType = '考证课程类';
}else if(obj.value == "理论课程类"){
htm+='<option value="课程中心" selected>课程中心</option>';
htm_application+='<option value="课程中心" selected>课程中心</option>';
} else if (obj.value == "理论课程类") {
htm = '<input lay-event="labelSelect" name="courseLabelId" placeholder="请选择" class="layui-input"/>';
htm_application += '<option value="课程中心" selected>课程中心</option>';
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);

@ -1,17 +1,24 @@
<!--#layout("/common/layout.html",{"jsBase":"/js/jlw/resourcesApplicationCourse/"}){ -->
<style>
.layui-table-body, .layui-table-box .layui-table-cell{
overflow:visible;
.layui-table-body, .layui-table-box .layui-table-cell {
overflow: visible;
}
.layui-table a {
margin-right: 10px;
}
td .layui-form-select {
/*td .layui-form-select {
margin-top: -10px;
margin-left: -15px;
margin-right: -15px;
}
.layui-form-select dl {
}*/
/*td .layui-input {
padding: 0px;
}*/
.layui-form-select dl {
text-align: left;
}
</style>
@ -19,7 +26,8 @@
<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"
<input type="text" name="courseInfoName" id="courseInfoName" autocomplete="off" placeholder="请输入检索条件"
class="layui-input"
style="width: 200px;float: left;margin-right: 10px;">
</div>
</div>
@ -29,9 +37,10 @@
<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>
{{# }); }}
{{# layui.each(window.disLabelTypeSelectList, function(index, item){ }}
<option value="{{item}}" {{ item== d.courseLabelType ?
'selected' : '' }}>{{item}}</option>
{{# }); }}
</select>
</script>
@ -45,20 +54,23 @@
</select>
</script>-->
<script type="text/html" id="select_courseLabelIdSelect">
{{# if(d.courseLabelType == '理论课程类'){ }}
<input lay-event="labelSelect" name="courseLabelId" placeholder="请选择" class="layui-input"
value="课程中心 / {{d.courseLabelName}}"/>
{{# }else{ }}
<select lay-filter="select_courseLabelId" name="courseLabelId">
<option value="">请选择</option>
{{# if(d.courseLabelType == '应用课程类'){ }}
{{# if(d.courseLabelType == '应用课程类'){ }}
<option value="应用中心" selected>应用中心</option>
{{# }else if(d.courseLabelType == '考证课程类'){ }}
{{# }else if(d.courseLabelType == '考证课程类'){ }}
<option value="考证辅导" selected>考证辅导</option>
{{# }else if(d.courseLabelType == '理论课程类'){ }}
<option value="课程中心" selected>课程中心</option>
{{# } }}
{{# } }}
</select>
{{# } }}
</script>
<!--绑定应用-->
<script type="text/html" id="select_resourcesApplicationIds" >
<script type="text/html" id="select_resourcesApplicationIds">
<layui:simpleDictSelect style='layui-input-inline'
layFilter="select_resourcesApplicationIds"
type="resources_application.application_name.1=1"
@ -69,10 +81,10 @@
<!--#} -->
<script>
layui.use(['index'], function(){
var index = layui.index;
layui.use(['index'], function () {
var index = layui.index;
index.init();
});
index.init();
});
</script>

Loading…
Cancel
Save