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.

205 lines
8.6 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 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;
}
</style>
</head>
<body>
<form>
<div class="weadmin-body">
<div class="layui-form-item inline" style="float:right">
<span id="importAcc">
<div class="layui-btn" type="button" id="addSubCourse" onclick="addSubCourse();">
<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 layui-btn-danger" lay-event="delete">删除</a>
</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>
layui.extend({
admin: '{/}../../static/js/admin'
});
layui.use(['form', 'jquery', 'admin', 'layer', 'table'], function () {
var form = layui.form,
$ = layui.jquery,
admin = layui.admin,
layer = layui.layer,
table = layui.table;
//课程id
var course_id = GetQueryString("course_id");
//增加子课程
window.addSubCourse = function () {
$.ajax({
type: "POST",
dataType: "json",
async: false,
data: {
"course_id": course_id
},
url: "/baseService/teachbase/addSubCourse",
success: function (data) {
if (data.success) {
layer.msg("增加成功", {icon: 1, time: 1000, shade: [0.5, '#000', true]}, function () {
var index = layer.getFrameIndex(window.name);
layer.close(index);
layui.table.reload('idTest', {});
});
}
}
});
};
// 绑定子课程
window.bindSubCourse = function () {
table.render({
elem: '#idTest',
url: '/baseService/teachbase/getSubCourseList?course_id=' + course_id,
cols: [[
{field: 'id', title: '序号', align: 'center', type: 'numbers'}
, {field: 'sub_course_code', title: '课程代码', align: 'center'}
, {field: 'sub_course_name', title: '课程名称', align: 'center'}
, {field: 'sub_course_alias', title: '课程简称', align: 'center', edit: 'text'}
, {field: 'sub_help_code', title: '助记码', align: 'center', edit: 'text'}
, {field: 'sub_credit_points', title: '学分', align: 'center', edit: 'text'}
, {field: 'sub_credit_hours', title: '总学时', align: 'center', edit: 'text'}
, {field: 'sub_theory', title: '理论学时', align: 'center', edit: 'text'}
, {field: 'sub_practice', title: '实践学时', align: 'center', edit: 'text'}
, {fixed: 'right', title: '操作', toolbar: '#barDemo', align: 'center'}
]]
, page: false
, height: 'full'
, done: function () {
}
});
};
//绑定子课程
bindSubCourse();
//编辑与删除
table.on('tool(idTest)', function (obj) {
var data = obj.data;
//删除检查
if (obj.event === "delete") {
//删除功能
var sub_course_id = data.sub_course_id;
var tip = '您确定要删除此子课程吗?';
layer.confirm(tip, {
btn: ['确定', '取消']
}, function (index, layero) {
$.ajax({
type: "POST",
dataType: "json",
async: false,
data: {
"sub_course_id": sub_course_id
},
url: "/baseService/teachbase/delSubCourse",
success: function (data) {
if (data.success) {
layer.msg("保存成功", {icon: 1, time: 1000, shade: [0.5, '#000', true]}, function () {
var index = layer.getFrameIndex(window.name);
layer.close(index);
layui.table.reload('idTest', {});
});
}
}
});
}
);
}
});
//监听单元格编辑
table.on('edit(idTest)', function (obj) {
var value = obj.value //得到修改后的值
, data = obj.data //得到所在行所有键值
, field = obj.field; //得到字段
//1、是不是大于等于零的数字,方式1和方式2都可以
var b = true;
//sub_credit_hours :总学时
//sub_theory :理论
//sub_practice :实践
//sub_credit_points :学分
if (field =="sub_credit_points" || field=="sub_theory" || field=="sub_credit_points") {
if (((isNaN(obj.value)) || (parseFloat(obj.value)) <0)) {
b = false;
}
}
//实践可以等于0
if (field =="sub_practice") {
if (((isNaN(obj.value)) || (parseFloat(obj.value)) < 0)) {
b = false;
}
}
if (b) {
//保存
var d = {"sub_course_id": data.sub_course_id, "field": field, "value": value};
$.ajax({
type: "POST",
dataType: "json",
async: false,
data: d,
url: "/baseService/teachbase/updateSubCourse",
success: function (data) {
layui.table.reload('idTest', {});
}
});
} else {
var tips = '输入的数字无效,请检查后重新输入!';
layer.msg(tips, {
icon: 2,
time: 3000
}, function () {
layui.table.reload('idTest', {});
});
}
});
})
</script>
</form>
</body>
</html>