|
|
|
@ -4,8 +4,8 @@ layui.define(['form', 'laydate', 'table'], function (exports) {
|
|
|
|
|
var table = layui.table;
|
|
|
|
|
var resourcesApplicationCourseTable = null;
|
|
|
|
|
// 查询去重的标签列表
|
|
|
|
|
var selectList = Common.postAjax('/jlw/courseLabel/disLabelType.json').data;
|
|
|
|
|
var courseLabelList = Common.getAjax('/jlw/courseLabel/getValues.json?courseLabelStatus=1').data;
|
|
|
|
|
window.disLabelTypeSelectList = Common.postAjax('/jlw/courseLabel/disLabelType.json').data;
|
|
|
|
|
window.courseLabelList = Common.getAjax('/jlw/courseLabel/getValues.json?courseLabelStatus=1').data;
|
|
|
|
|
|
|
|
|
|
var view = {
|
|
|
|
|
init: function () {
|
|
|
|
@ -47,47 +47,13 @@ layui.define(['form', 'laydate', 'table'], function (exports) {
|
|
|
|
|
field: 'courseLabelType',
|
|
|
|
|
title: '绑定模块',
|
|
|
|
|
align: "center",
|
|
|
|
|
templet: function (d) {
|
|
|
|
|
var prefix = '<!-- \'应用课程类\',\'考证课程类\',\'理论课程类\';-->\n' +
|
|
|
|
|
'<select lay-filter="select_courseLabelType" name="courseLabelType">\n' +
|
|
|
|
|
' <option value="">请选择</option>';
|
|
|
|
|
var content = '';
|
|
|
|
|
var suffix = '</select>';
|
|
|
|
|
|
|
|
|
|
$.each(selectList, function (key, value) {
|
|
|
|
|
var selected = value == d.courseLabelType ? "selected" : "";
|
|
|
|
|
content += '<option value="' + value + '" '+selected+'>' + value + '</option>';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return prefix + content + suffix;
|
|
|
|
|
}
|
|
|
|
|
templet: '#select_courseLabelTypeSelect',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: 'courseLabelId',
|
|
|
|
|
title: '课程类别',
|
|
|
|
|
align: "center",
|
|
|
|
|
templet: function (d) {
|
|
|
|
|
|
|
|
|
|
var prefix = '<!-- \'应用课程类\',\'考证课程类\',\'理论课程类\';-->\n' +
|
|
|
|
|
'<select lay-filter="select_courseLabelId" name="courseLabelId">\n' +
|
|
|
|
|
' <option value="">请选择</option>';
|
|
|
|
|
var content = '';
|
|
|
|
|
var suffix = '</select>';
|
|
|
|
|
|
|
|
|
|
var labelList = [];
|
|
|
|
|
// 一级类型
|
|
|
|
|
for (var courseLabel of courseLabelList) {
|
|
|
|
|
if(courseLabel.courseLabelType == d.courseLabelType) {
|
|
|
|
|
labelList.push(courseLabel)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$.each(labelList, function (key, value) {
|
|
|
|
|
var selected = value.courseLabelId == d.courseLabelId ? "selected" : "";
|
|
|
|
|
content += '<option value="' + value.courseLabelId + '" '+selected+'>' + value.courseLabelName + '</option>';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return prefix + content + suffix;
|
|
|
|
|
}
|
|
|
|
|
templet: '#select_courseLabelIdSelect'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: 'resourcesApplicationIds',
|
|
|
|
@ -95,7 +61,7 @@ layui.define(['form', 'laydate', 'table'], function (exports) {
|
|
|
|
|
align: "center",
|
|
|
|
|
templet: function (d) {
|
|
|
|
|
// html字符串转对象,深拷贝操作,相当于每行copy一个下拉框进行回显选中操作
|
|
|
|
|
var copyHtml = $($('#selectGxmc').html())
|
|
|
|
|
var copyHtml = $($('#select_resourcesApplicationIds').html())
|
|
|
|
|
copyHtml.find("option[value="+d.resourcesApplicationIds+"]").attr("selected", true);
|
|
|
|
|
return copyHtml.html();
|
|
|
|
|
}
|
|
|
|
@ -105,8 +71,10 @@ layui.define(['form', 'laydate', 'table'], function (exports) {
|
|
|
|
|
title: '操作',
|
|
|
|
|
align: "center",
|
|
|
|
|
templet: function (d) {
|
|
|
|
|
var htm = '<a class="layui-table-link" lay-event="binding">绑定</a>';
|
|
|
|
|
htm += '<a class="layui-table-link" lay-event="edit">编辑</a>';
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -196,6 +164,14 @@ layui.define(['form', 'laydate', 'table'], function (exports) {
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改绑定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)){
|
|
|
|
@ -207,6 +183,7 @@ layui.define(['form', 'laydate', 'table'], function (exports) {
|
|
|
|
|
}
|
|
|
|
|
$(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 {
|
|
|
|
@ -215,23 +192,38 @@ layui.define(['form', 'laydate', 'table'], function (exports) {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
form.on('select(select_)', function (obj) {
|
|
|
|
|
var id = obj.value;
|
|
|
|
|
return;
|
|
|
|
|
var resourcesApplicationCourseId = table.cache['resourcesApplicationCourseTable'][$(this).parents("tr").attr("data-index")].resourcesApplicationCourseId;
|
|
|
|
|
if (!$.isEmpty(resourcesApplicationCourseId)) {
|
|
|
|
|
var param = {
|
|
|
|
|
resourcesApplicationCourseId: resourcesApplicationCourseId,
|
|
|
|
|
id: id,
|
|
|
|
|
};
|
|
|
|
|
var ret = Common.postAjax("/jlw/resourcesApplicationCourse/edit.json", param);
|
|
|
|
|
// 下拉框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_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 param = table.cache['resourcesApplicationCourseTable'][index];
|
|
|
|
|
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: 1000 //2秒关闭(如果不配置,默认是3秒)
|
|
|
|
|
time: 1500 //2秒关闭(如果不配置,默认是3秒)
|
|
|
|
|
}, function () {
|
|
|
|
|
if (ret.code == 0) {
|
|
|
|
|
Lib.tableRefresh();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
exports('index', view);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|