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.

319 lines
13 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>
<!-- 让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">dddd</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>
</div>
</div>
<script src="../../lib/layui/layui.js"></script>
<script src="../../lib/template.js"></script>
<script src="../../lib/base64.js"></script>
<script>
window.GetQueryString = function (name, istop) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (typeof (istop) != "undefined") r = top.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]);
return null;
};
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;
//用来保存返回前一页时定位的数据
var rule_id = GetQueryString("rule_id");
var entry_year = GetQueryString("entry_year");
var zhuanye_code = GetQueryString("zhuanye_code");
//显示本页的提示信息
var rule_name = decode64(GetQueryString("rule_name"));
$("#info").text("正在为规则:“" + rule_name + "” 设置课程信息");
//返回并定位
window.prePage = function () {
window.location.href = "ruleList.html?entry_year=" + entry_year + "&zhuanye_code=" + zhuanye_code;
};
//增加课程
window.addCourse = function () {
var rule_id = GetQueryString("rule_id");
WeAdminShow('步骤1', './rule_add_course_1.html?rule_id=' + rule_id, 400, 250);
};
// 绑定课程
window.bindCourseList = function () {
var rule_id = GetQueryString("rule_id");
table.render({
elem: '#idTest',
url: '/baseService/teachbase/getCourseListByRuleId?rule_id=' + rule_id,
cols: [[
{type: 'checkbox', fixed: 'left', align: 'center', rowspan: 2}
, {field: 'id', title: '序号', align: 'center', type: 'numbers', width: 40, rowspan: 2}
, {field: 'level_1_name', title: '类型', align: 'center', rowspan: 2}
, {field: 'level_2_name', title: '子类', align: 'center', rowspan: 2}
, {field: 'course_code', title: '课程代码', align: 'center', rowspan: 2}
, {field: 'course_name', title: '名称', align: 'center', rowspan: 2}
, {field: 'credit_hours', title: '学时', align: 'center', rowspan: 2, edit: 'text'}
, {field: 'credit_points', title: '学分', align: 'center', rowspan: 2, edit: 'text'}
, {field: 'theory', title: '理论', align: 'center', rowspan: 2, edit: 'text'}
, {field: 'practice', title: '实践', align: 'center', rowspan: 2, edit: 'text'}
, {
field: 'exam_mode_id', title: '方式', align: 'center', rowspan: 2
, templet: function (d) {
var t="";
if(d.exam_mode_id=="1")
{
t="考试";
}
else
{
t="考查";
}
var str = '<div><a href="#" class="layui-table-link" onclick="changeFangShi('+rule_id+"," + d.course_id +","+d.exam_mode_id+ ')">' + t + '</a></div>';
return str;
}
}
, {field: 'memo', title: '开课学期和周学时数', align: 'center', colspan: 10}
, {field: 'memo', title: '备注', align: 'center', rowspan: 2, edit: 'text'}
], [
{field: 'term_1', title: '1', align: 'center', width: 50, edit: 'text'}
, {field: 'term_2', title: '2', align: 'center', width: 50, edit: 'text'}
, {field: 'term_3', title: '3', align: 'center', width: 50, edit: 'text'}
, {field: 'term_4', title: '4', align: 'center', width: 50, edit: 'text'}
, {field: 'term_5', title: '5', align: 'center', width: 50, edit: 'text'}
, {field: 'term_6', title: '6', align: 'center', width: 50, edit: 'text'}
, {field: 'term_7', title: '7', align: 'center', width: 50, edit: 'text'}
, {field: 'term_8', title: '8', align: 'center', width: 50, edit: 'text'}
, {field: 'term_9', title: '9', align: 'center', width: 50, edit: 'text'}
, {field: 'term_10', title: '10', align: 'center', width: 50, edit: 'text'}
]]
, page: true
, height: 'full'
, done: function () {
}
});
};
//绑定课程
bindCourseList();
//变更方式
window.changeFangShi=function(rule_id,course_id,exam_mode_id)
{
layer.open({
title:"选择考核方式",
type:2,
shadeClose: true,
shade: 0.8,
area: ['220px','130px'],
content: './changeFangShi.html?rule_id='+rule_id+'&course_id=' + course_id+"&exam_mode_id="+exam_mode_id
})
};
//删除课程
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', {page: {curr: 1}});
});
}
});
});
};
//监听单元格编辑
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;
} 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(checkType==3)
{
is_legal=true;
}
//2、是不是检查通过
if (is_legal) {
//规则ID
var rule_id = GetQueryString("rule_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 (data) {
}
});
} else {
//如果合法就保存,如果不合法,就回到原来的值
var tips='需要输入空字符串,或者大于0的数字,或者类似2*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
});
});
}
});
})
</script>
</body>
</html>