You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

517 lines
22 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!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>
<!--引入tip组件 -->
<link rel="stylesheet" type="text/css" href="../../lib/poshytip/tip-darkgray/tip-darkgray.css"/>
<script type="text/javascript" src="../../lib/poshytip/jquery.poshytip.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: 180px;
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">
<span id="info"></span>
<div class="layui-form-item inline" style="float:right">
<span id="importAcc">
<div class="layui-btn layui-btn-primary" type="button" id="prePage" onclick="prePage();">
<span class="layui-icon layui-icon-shrink-right"></span>返回
</div>
<div class="layui-btn" type="button" id="addCourse" onclick="addCourse();">
<span class="layui-icon layui-icon-shrink-right"></span>增加
</div>
<div class="layui-btn layui-btn-danger" type="button" id="deleteCourse"
onclick="deleteCourse();">
<span class="layui-icon layui-icon-shrink-right"></span>删除
</div>
</span>
</div>
<div class="layui-form-item">
<table class="layui-table" lay-filter="idTest" id="idTest"></table>
<script type="text/html" id="barDemo">
<a class="layui-btn layui-btn-xs" lay-event="up">向上</a>
<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="down">向下</a>
</script>
<script type="text/html" id="switchTplCategory">
<input type="checkbox" name="category_select" value="{{d.category_id}}" lay-skin="switch" lay-text="必修|选修"
lay-filter="category_select"
id="category_{{d.course_id}}"
{{ d.category_id===1 ?'checked' : '' }}>
</script>
<script type="text/html" id="switchTplExamMode">
<input type="checkbox" name="ExamMode_select" value="{{d.exam_mode_id}}" lay-skin="switch" lay-text="考试|考查"
lay-filter="exam_mode_select"
id="exam_mode_{{d.course_id}}"
{{ d.exam_mode_id===1 ?'checked' : '' }}>
</script>
</div>
</div>
<script src="../../lib/layui/layui.js"></script>
<script src="../../lib/template.js"></script>
<script src="../../lib/base64.js"></script>
<!--加载日常开发中常用的函数库-->
<script src="../../lib/layuiExtend.js"></script>
<script src="../../lib/JqueryExtend.js"></script>
<script>
layui.extend({
admin: '{/}../../static/js/admin'
});
layui.use(['form', 'jquery', 'laytpl', 'admin', 'layer', 'table', 'rate'], function () {
var form = layui.form,
$ = layui.jquery,
admin = layui.admin,
layer = layui.layer,
table = layui.table,
laytpl = layui.laytpl,
rate = layui.rate;
var flag=GetQueryString("flag");
//用来保存返回前一页时定位的数据
var rule_id = GetQueryString("rule_id");
var entry_year = GetQueryString("entry_year");
var zhuanye_code = GetQueryString("zhuanye_code");
var length = GetQueryString("length");
//显示本页的提示信息
var rule_name = decode64(GetQueryString("rule_name"));
// 一级课程类别名称
var first_level_module_id = GetQueryString("first_level_module_id");
var first_level_module_name = decode64(GetQueryString("first_level_module_name"));
// 二级课程类别名称
var second_level_module_id = GetQueryString("second_level_module_id");
var second_level_module_name = decode64(GetQueryString("second_level_module_name"));
//是不是已经审核通过
var is_checked = 0;
$.ajax({
type: "GET",
dataType: "json",
async: false,
url: "/baseService/teachbase/getRuleInfoById?rule_id=" + rule_id,
success: function (data) {
is_checked = data.is_checked;
}
});
if (is_checked === 1) {
$("#addCourse").css("display", "none");
$("#deleteCourse").css("display", "none");
}
$("#info").text("正在为规则:“" + rule_name + "->”" + first_level_module_name + "->" + second_level_module_name + " 设置课程信息");
//返回并定位
window.prePage = function () {
var url = './courseModuleList.html?rule_id=' + rule_id + '&length=' + length + '&entry_year=' + entry_year
+ "&zhuanye_code=" + zhuanye_code + "&rule_name=" + encode64(rule_name)+"&flag="+flag;
window.location.href = url;
};
//增加课程
window.addCourse = function () {
WeAdminShowCallBack("增加课程", './rule_add_course.html?level_1_id=' + first_level_module_id + "&level_2_id=" + second_level_module_id +
"&rule_id=" + rule_id, $(window).width() - 100, 500, rule_id);
};
//弹出页面关闭进行回调
window.callbackFunction = function () {
layui.table.reload('idTest', {
where: {}
, page: {}
});
return false;
};
// 绑定课程
var cols = [
[
{type: 'checkbox', fixed: 'left', align: 'center', rowspan: 2}
, {field: 'id', title: '序号', align: 'center', type: 'numbers', width: 40, rowspan: 2}
, {field: 'course_code', title: '代码', align: 'center', rowspan: 2,width: 80}
, {field: 'course_name', title: '名称', align: 'center', rowspan: 2}
, {
field: 'category_id',
title: '性质',
align: 'center',
width: 85,
templet: '#switchTplCategory',
unresize: true,
rowspan: 2
}
, {field: 'credit_points', title: '学分', align: 'center', width: 60,rowspan: 2}
, {field: 'credit_hours', title: '学时', align: 'center', width: 60, rowspan: 2}
, {field: 'theory', title: '理论', align: 'center', width: 60,rowspan: 2}
, {field: 'practice', title: '实践', align: 'center', width: 60, rowspan: 2}
, {
field: 'exam_mode_id',
title: '考查方式',
width: 90,
templet: '#switchTplExamMode',
unresize: true,
rowspan: 2
}
, {
field: 'sub_course_count', title: '学期', align: 'center', width: 60, rowspan: 2, templet: function (d) {
var green_color = '#5FB878';
var red_color = '#FF5722';
var yellow_color = '#FFB800';
var color = '';
if (d.sub_course_config_count > d.sub_course_count) {
color = red_color;
}
if (d.sub_course_config_count == d.sub_course_count) {
color = green_color;
}
if (d.sub_course_config_count < d.sub_course_count) {
color = yellow_color;
}
var str = '<a href=# onclick="showstatus(\'' + d.sub_course_count + '\',' + d.sub_course_config_count + ')">' + d.sub_course_count + '<i class="layui-icon layui-icon-rate-solid" style="font-size: 18px; color: ' + color + ';"></i></a>';
return str;
}
}
, {field: 'memo', title: '开课学期和周学时数', align: 'center', colspan: 10}
, {field: 'unit_name', title: '教学单位', align: 'center', rowspan: 2, width: 150}
, {
field: 'is_netcourse', title: '网络课程', align: 'center', rowspan: 2, width: 90
, templet: function (d) {
return d.is_netcourse === 1 ? "是" : "";
}
}
, {field: 'memo', title: '备注', align: 'center', rowspan: 2, edit: 'text', width: 70}
, {fixed: 'right', title: '操作', toolbar: '#barDemo', rowspan: 2, align: 'center', width: 150}
], [
{field: 'term_1', title: '1', align: 'center', edit: 'text', width: 50}
, {field: 'term_2', title: '2', align: 'center', edit: 'text', width: 50}
, {field: 'term_3', title: '3', align: 'center', edit: 'text', width: 50}
, {field: 'term_4', title: '4', align: 'center', edit: 'text', width: 50}
, {field: 'term_5', title: '5', align: 'center', edit: 'text', width: 50}
, {field: 'term_6', title: '6', align: 'center', edit: 'text', width: 50}
]];
//五年制
if (length == 5) {
cols[1].push({field: 'term_7', title: '7', align: 'center', edit: 'text', width: 50});
cols[1].push({field: 'term_8', title: '8', align: 'center', edit: 'text', width: 50});
cols[1].push({field: 'term_9', title: '9', align: 'center', edit: 'text', width: 50});
cols[1].push({field: 'term_10', title: '10', align: 'center', edit: 'text', width: 50});
}
window.bindCourseList = function () {
table.render({
elem: '#idTest',
url: '/baseService/teachbase/getCourseListByRuleId?rule_id=' + rule_id + "&first_level_module_id=" + first_level_module_id + "&second_level_module_id=" + second_level_module_id,
cols: cols
, page: false
, height: 'full'
, done: function (res, curr, count) {
//禁止table edit
var tableView = this.elem.next(); // 当前表格渲染之后的视图
layui.each(res.data, function (i, item) {
if (is_checked == 1) {
//tableView.find('tr[data-index=' + i + ']').css("background-color", "#CCCCCC").find('td').data('edit',false)
tableView.find('tr[data-index=' + i + ']').find('td').data('edit', false)
}
});
}
});
};
//绑定课程
bindCourseList();
//删除课程
window.deleteCourse = function () {
//选中数据
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 + ",";
}
}
}
//规则ID
var rule_id = GetQueryString("rule_id");
//提交数据
data = {
"courseIds": courseIds,
"rule_id": rule_id
};
var tip = '您确定要删除选定的课程吗?';
layer.confirm(tip, {
btn: ['确定', '取消']
}, function (index, layero) {
$.ajax({
type: "POST",
dataType: "json",
async: false,
data: data,
url: "/baseService/teachbase/deleteCourseFromRule",
success: function (data) {
layer.msg("删除成功", {icon: 1, time: 1000, shade: [0.5, '#000', true]}, function () {
layui.table.reload('idTest', {});
});
}
});
});
};
//监听课程类型变更
form.on('switch(category_select)', function (obj) {
if (is_checked == 1) {
var swt = $(obj.elem);
layer.msg('此规则已通过审核,不能进行变更类型,如确定需要变更类型,请先修改审核状态为未通过!', {icon: 2, time: 2000, shade: 0.1});
swt.prop('checked', !obj.elem.checked); //修改switch开关
layui.form.render();//刷新表格
return;
}
var value = 2;
if (obj.elem.checked) {
value = 1;
}
var course_id = $(this).attr("id").split("_")[1];
//保存
var data = {"rule_id": rule_id, "course_id": course_id, "field": "category_id", "value": value};
$.ajax({
type: "POST",
dataType: "json",
async: false,
data: data,
url: "/baseService/teachbase/saveCourseFieldValue",
success: function (data) {
console.log("保存成功!");
}
});
});
//监听考查方式变更
form.on('switch(exam_mode_select)', function (obj) {
if (is_checked == 1) {
var swt = $(obj.elem);
layer.msg('此规则已通过审核,不能进行变更考查方式,如确定需要变更考查方式,请先修改审核状态为未通过!', {icon: 2, time: 2000, shade: 0.1});
swt.prop('checked', !obj.elem.checked); //修改switch开关
layui.form.render();//刷新表格
return;
}
var value = 2;
if (obj.elem.checked) {
value = 1;
}
var course_id = $(this).attr("id").split("_")[2];
//保存
var data = {"rule_id": rule_id, "course_id": course_id, "field": "exam_mode_id", "value": value};
$.ajax({
type: "POST",
dataType: "json",
async: false,
data: data,
url: "/baseService/teachbase/saveCourseFieldValue",
success: function (data) {
console.log("保存成功!");
}
});
});
//监听单元格编辑
table.on('edit(idTest)', function (obj) {
var value = obj.value //得到修改后的值
, data = obj.data //得到所在行所有键值
, field = obj.field; //得到字段
//前4个一种检查标准后10种另一种检查标准
var arr1 = ["credit_hours", "credit_points", "theory", "practice"];
var arr2 = ["term_1", "term_2", "term_3", "term_4", "term_5", "term_6", "term_7", "term_8", "term_9", "term_10"];
var arr3 = ["memo"];
//方式1
var checkType = 0;
if (arr1.indexOf(field) >= 0) {
checkType = 1;
}
if (arr2.indexOf(field) >= 0) {
checkType = 2;
}
if (arr3.indexOf(field) >= 0) {
checkType = 3;
}
if (checkType == 0) {
layer.msg('我KAO你是不是写错了怎么会有这种情况产生');
return
}
//是不是合法
var is_legal = false;
//1、是不是大于零的数字,方式1和方式2都可以
if ((!(isNaN(obj.value)) && (obj.value) > 0) || (obj.value == '')) {
is_legal = true;
if (checkType == 4 && obj.value == '') {
is_legal = false;
}
} else {
if (checkType == 2) {
//2、是不是2*2形式的
if (obj.value.indexOf("*") > 0) {
var arr = obj.value.split("*");
if (arr.length == 2) {
var a = arr[0];
var b = arr[1];
if ((!(isNaN(a)) && (parseInt(a) > 0)) && (!(isNaN(b)) && (parseInt(b) > 0))) {
is_legal = true;
}
}
}
if (obj.value.indexOf("*") > 0) {
var s = obj.value;
s = s.replace("*", "");
if ((!(isNaN(s)) && (parseInt(s) > 0))) {
is_legal = true;
}
}
if (obj.value.indexOf("周") > 0) {
var s = obj.value;
s = s.replace("周", "");
if ((!(isNaN(s)) && (parseInt(s) > 0))) {
is_legal = true;
}
}
}
}
//备注
if (checkType == 3) {
is_legal = true;
}
//2、是不是检查通过
if (is_legal) {
//规则ID
//保存
var d = {"rule_id": rule_id, "course_id": data.course_id, "field": field, "value": value};
$.ajax({
type: "POST",
dataType: "json",
async: false,
data: d,
url: "/baseService/teachbase/saveCourseFieldValue",
success: function (d) {
if (d.success) {
obj.update({
sub_course_config_count: d.term_count,
sub_course_count: data.sub_course_count
});
}
}
});
} else {
//如果合法就保存,如果不合法,就回到原来的值
var tips = '需要输入空字符串,或者大于0的数字,或者类似2*2或者类似于*周 形式的输入格式!';
if (checkType == 1) {
tips = '需要输入空字符串,或者大于0的数字';
}
layer.msg(tips, {icon: 2, time: 3000}, function () {
//恢复旧数据
var tableBak = table.cache['idTest'];
table.reload('idTest', {
data: tableBak
});
});
}
});
table.on('tool(idTest)', function (obj) {
var data = obj.data;
//上
if (obj.event === "up") {
changeSortId(data.course_id,-1);
}
//下
if (obj.event === 'down') {
changeSortId(data.course_id,1);
}
});
//更改排序号
window.changeSortId=function(course_id,action){
var data={rule_id:rule_id,course_id:course_id,action:action};
console.log(data);
$.ajax({
type: "POST",
dataType: "json",
async: false,
data: data,
url: "/baseService/teachbase/changeSortId",
success: function (d) {
if (d.success) {
//绑定课程
bindCourseList();
}
}
});
}
//显示状态
window.showstatus = function (sub_course_count, sub_course_config_count) {
if (sub_course_count - sub_course_config_count == 0) {
var tips = '绿色五星代表要求学习学期数与已配置学期数相等';
layer.msg(tips, {
icon: 6,
time: 2000
}, function () {
});
}
if (sub_course_count - sub_course_config_count > 0) {
var tips = '黄色五星代表要求学习学期数比已配置学期数多,还需要继续配置。';
layer.msg(tips, {
icon: 6,
time: 2000
}, function () {
});
}
if (sub_course_count - sub_course_config_count < 0) {
var tips = '红色五星代表要求学习学期数比已配置学期数少,需要减少学期配置。';
layer.msg(tips, {
icon: 6,
time: 2000
}, function () {
});
}
};
})
</script>
</body>
</html>