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

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'
@ -93,7 +97,11 @@ layui.define(['form', 'laydate', 'table'], function (exports) {
templet: function (d) {
var htm = '';
// 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;
}
@ -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});
@ -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状态
*/
@ -222,26 +267,27 @@ 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 = '<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());
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 += '<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 = '<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);
@ -267,6 +313,8 @@ 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 = {};
@ -274,11 +322,11 @@ layui.define(['form', 'laydate', 'table'], function (exports) {
param = {
courseInfoId: data.courseInfoId,
courseLabelType: '应用课程类',
courseLabelId:data.courseLabelId,
/*courseLabelId: data.courseLabelId,*/
resourcesApplicationIds: data.resourcesApplicationIds,
};
} else if (data.courseLabelType == '理论课程类') {
param = {courseInfoId: data.courseInfoId,courseLabelType:'理论课程类'};
param = {courseInfoId: data.courseInfoId, courseLabelType: '理论课程类', courseLabelId: data.courseLabelId};
} else if (data.courseLabelType == '考证课程类') {
param = {courseInfoId: data.courseInfoId, courseLabelType: '考证课程类'};
}
@ -290,10 +338,23 @@ layui.define(['form', 'laydate', 'table'], function (exports) {
}, 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);

@ -3,14 +3,21 @@
.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;
}
}*/
/*td .layui-input {
padding: 0px;
}*/
.layui-form-select dl {
text-align: left;
}
@ -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>
@ -30,7 +38,8 @@
<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>
<option value="{{item}}" {{ item== d.courseLabelType ?
'selected' : '' }}>{{item}}</option>
{{# }); }}
</select>
</script>
@ -45,16 +54,19 @@
</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 == '应用课程类'){ }}
<option value="应用中心" selected>应用中心</option>
{{# }else if(d.courseLabelType == '考证课程类'){ }}
<option value="考证辅导" selected>考证辅导</option>
{{# }else if(d.courseLabelType == '理论课程类'){ }}
<option value="课程中心" selected>课程中心</option>
{{# } }}
</select>
{{# } }}
</script>
<!--绑定应用-->

Loading…
Cancel
Save