|
|
<!DOCTYPE html>
|
|
|
<html>
|
|
|
<head>
|
|
|
<meta charset="UTF-8">
|
|
|
<title>选择课程类型</title>
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
|
|
<meta name="renderer" content="webkit">
|
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
|
|
<meta name="viewport"
|
|
|
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
|
|
<link rel="stylesheet" href="../../static/css/font.css">
|
|
|
<link rel="stylesheet" href="../../static/css/weadmin.css">
|
|
|
<link rel="stylesheet" href="../../lib/layui/css/layui.css">
|
|
|
<script src="../../lib/jquery-1.12.4.min.js"></script>
|
|
|
<script src="../../lib/ztree/jquery.ztree.core-3.5.min.js"></script>
|
|
|
<!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
|
|
|
<!--[if lt IE 9]>
|
|
|
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
|
|
|
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
|
|
|
<![endif]-->
|
|
|
<style>
|
|
|
select {
|
|
|
width: 220px;
|
|
|
height: 38px;
|
|
|
line-height: 38px;
|
|
|
border: 1px solid #ccc;
|
|
|
border-radius: 3px;
|
|
|
font-size: 15px;
|
|
|
padding-left: 6px;
|
|
|
color: #666;
|
|
|
}
|
|
|
|
|
|
.inline {
|
|
|
display: inline-block;
|
|
|
vertical-align: top;
|
|
|
}
|
|
|
|
|
|
ul.log li {
|
|
|
color: #666666;
|
|
|
list-style: none;
|
|
|
padding-left: 10px;
|
|
|
}
|
|
|
</style>
|
|
|
</head>
|
|
|
<body>
|
|
|
<div class="weadmin-body">
|
|
|
<div class="layui-form-item inline " id="div3">
|
|
|
<label for="" class="layui-form-label" style="padding:9px 0;text-align: left;">
|
|
|
授课单位
|
|
|
</label>
|
|
|
<div class="layui-input-inline" id="select_3" style="width: 188px"></div>
|
|
|
<script type="text/html" id="test3">
|
|
|
<select name="service_type" id="sel3" onchange="changeUnit()">
|
|
|
<% for (var i = 0; i < data.length; i ++) { %>
|
|
|
<option value="<%=data[i].unit_id%>"><%=data[i].unit_name%></option>
|
|
|
<% } %>
|
|
|
</select>
|
|
|
</script>
|
|
|
</div>
|
|
|
<div class="layui-form-item">
|
|
|
<table class="layui-table" lay-filter="idTest" id="idTest"></table>
|
|
|
</div>
|
|
|
|
|
|
<div class="layui-form-item" align="center">
|
|
|
<buttin class="layui-btn" id="save">保存</buttin>
|
|
|
</div>
|
|
|
</div>
|
|
|
<script src="../../lib/layui/layui.js"></script>
|
|
|
<script src="../../lib/template.js"></script>
|
|
|
<script src="../../lib/base64.js"></script>
|
|
|
<script>
|
|
|
layui.extend({
|
|
|
admin: '{/}../../static/js/admin'
|
|
|
});
|
|
|
layui.use(['form', 'jquery', 'laytpl', 'admin', 'layer', 'table'], function () {
|
|
|
var form = layui.form,
|
|
|
$ = layui.jquery,
|
|
|
admin = layui.admin,
|
|
|
layer = layui.layer,
|
|
|
table = layui.table,
|
|
|
laytpl = layui.laytpl;
|
|
|
|
|
|
// 绑定单位
|
|
|
window.bindUnit = function () {
|
|
|
$.ajax({
|
|
|
type: "GET",
|
|
|
async: false,
|
|
|
dataType: "json",
|
|
|
url: "/baseService/teachbase/getUnitList?page=1&limit=9999",
|
|
|
success: function (data) {
|
|
|
var html = template.render('test3', data);
|
|
|
document.getElementById('select_3').innerHTML = html;
|
|
|
}
|
|
|
})
|
|
|
};
|
|
|
bindUnit();
|
|
|
|
|
|
//绑定单位下的课程
|
|
|
window.bindCourse = function () {
|
|
|
var unit_id = $("#sel3").val();
|
|
|
var rule_id = GetQueryString("rule_id");
|
|
|
table.render({
|
|
|
elem: '#idTest',
|
|
|
url: '/baseService/teachbase/getCourseListByUnitId?unit_id=' + unit_id + "&rule_id=" + rule_id,
|
|
|
cols: [[
|
|
|
{type: 'checkbox', fixed: 'left', align: 'center'},
|
|
|
{field: 'id', title: '序号', align: 'center', type: 'numbers', width: 40}
|
|
|
, {field: 'course_code', title: '课程代码', align: 'center'}
|
|
|
, {field: 'course_name', title: '课程名称', align: 'center'}
|
|
|
, {field: 'course_type_name', title: '课程类型', align: 'center'}
|
|
|
, {field: 'is_netcourse', title: '网络课程', align: 'center'}
|
|
|
, {field: 'credit_hours', title: '学时', align: 'center'}
|
|
|
, {field: 'credit_points', title: '学分', align: 'center'}
|
|
|
, {field: 'theory', title: '理论课时', align: 'center'}
|
|
|
, {field: 'practice', title: '实践课时', align: 'center'}
|
|
|
, {field: 'exam_mode_id', title: '考试方式', align: 'center'}
|
|
|
]]
|
|
|
, page: true
|
|
|
, height: 'full'
|
|
|
, done: function (res, curr, count) {
|
|
|
$("[data-field='exam_mode_id']").children().each(function () {
|
|
|
if ($(this).text() == '1') {
|
|
|
$(this).text("考试")
|
|
|
} else if ($(this).text() == '2') {
|
|
|
$(this).text("考查")
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$("[data-field='is_netcourse']").children().each(function () {
|
|
|
if ($(this).text() == '1') {
|
|
|
$(this).text("是")
|
|
|
} else if ($(this).text() == '0') {
|
|
|
$(this).text("否")
|
|
|
}
|
|
|
});
|
|
|
//禁止一些选择框
|
|
|
var found = false;
|
|
|
for (var i in res.data) {
|
|
|
var item = res.data[i];
|
|
|
if (item.is_exists == 1) {
|
|
|
// checkbox 根据条件设置不可选中
|
|
|
$('tr[data-index=' + i + '] input[type="checkbox"]').prop('disabled', true);
|
|
|
//设置行背景为灰色,表示不可以用,或者设置checkbox不可以用的样式
|
|
|
$("tr[data-index='" + i + "']").css("background-color", "#dddddd");
|
|
|
found = true;
|
|
|
}
|
|
|
}
|
|
|
form.render();// 重新渲染一下
|
|
|
if (found) {
|
|
|
// 根据条件移除全选 checkbox
|
|
|
$('th[data-field=0] div').replaceWith('<div class="layui-table-cell laytable-cell-5-0-0"><span> </span></div>');
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
bindCourse();
|
|
|
|
|
|
//变更单位时
|
|
|
window.changeUnit = function () {
|
|
|
bindCourse();
|
|
|
};
|
|
|
//保存
|
|
|
$(document).on('click', '#save', function (data) {
|
|
|
var rule_id = GetQueryString("rule_id");
|
|
|
var level_1_id = GetQueryString("level_1_id");
|
|
|
var level_2_id = GetQueryString("level_2_id");
|
|
|
//选中数据
|
|
|
var checkStatus = table.checkStatus('idTest')
|
|
|
, data = checkStatus.data;
|
|
|
if (data.length == 0) {
|
|
|
layer.msg("请先选择要添加的课程!", {icon: 2, time: 2000})
|
|
|
return;
|
|
|
} else {
|
|
|
var courseIds = "";
|
|
|
for (var i = 0; i < data.length; i++) {
|
|
|
if (i == data.length - 1) {
|
|
|
courseIds += data[i].course_id;
|
|
|
} else {
|
|
|
courseIds += data[i].course_id + ",";
|
|
|
}
|
|
|
}
|
|
|
//保存课程
|
|
|
data = {
|
|
|
"courseIds": courseIds,
|
|
|
"rule_id": rule_id,
|
|
|
"level_1_id": level_1_id,
|
|
|
"level_2_id": level_2_id
|
|
|
};
|
|
|
$.ajax({
|
|
|
type: "POST",
|
|
|
dataType: "json",
|
|
|
async: false,
|
|
|
data: data,
|
|
|
url: "/baseService/teachbase/saveRuleCourse",
|
|
|
success: function (data) {
|
|
|
layer.msg("保存成功", {icon: 1, time: 1000, shade: [0.5, '#000', true]}, function () {
|
|
|
var index = parent.layer.getFrameIndex(window.name);
|
|
|
parent.layer.close(index);
|
|
|
parent.layui.table.reload('idTest', {page: {curr: 1}});
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//单击行勾选checkbox事件
|
|
|
$(document).on("click", ".layui-table-body table.layui-table tbody tr", function () {
|
|
|
var index = $(this).attr('data-index');
|
|
|
var tableBox = $(this).parents('.layui-table-box');
|
|
|
//存在固定列
|
|
|
if (tableBox.find(".layui-table-fixed.layui-table-fixed-l").length > 0) {
|
|
|
tableDiv = tableBox.find(".layui-table-fixed.layui-table-fixed-l");
|
|
|
} else {
|
|
|
tableDiv = tableBox.find(".layui-table-body.layui-table-main");
|
|
|
}
|
|
|
var checkCell = tableDiv.find("tr[data-index=" + index + "]").find("td div.laytable-cell-checkbox div.layui-form-checkbox I");
|
|
|
if (checkCell.length > 0) {
|
|
|
checkCell.click();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$(document).on("click", "td div.laytable-cell-checkbox div.layui-form-checkbox", function (e) {
|
|
|
e.stopPropagation();
|
|
|
});
|
|
|
})
|
|
|
</script>
|
|
|
</body>
|
|
|
</html> |