bt-yjj-system-examination-s.../src/main/resources/static/route/classplan/save.html

496 lines
24 KiB
HTML
Raw Normal View History

2021-05-03 18:08:21 +08:00
<!doctype html>
<html lang="en">
<head>
<base href="/signup/">
<meta 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="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
<link rel="stylesheet" type="text/css" href="assets/js/vendor/viewer/viewer.min.css">
</head>
<body>
2021-05-15 14:43:37 +08:00
<div class="layui-anim layui-anim-fadein">
2021-05-03 18:08:21 +08:00
<div class="layui-card">
<div class="layui-card-body" style="padding: 15px;">
<form class="layui-form layui-form-pane" lay-filter="dataForm">
2021-05-04 14:00:54 +08:00
<div class="layui-row">
2021-05-11 09:19:02 +08:00
<div class="layui-col-md6">
2021-05-04 14:00:54 +08:00
<div class="layui-form-item">
2021-05-17 17:14:40 +08:00
<label class="layui-form-label"><span style="color: red">*</span>班号</label>
2021-05-04 14:00:54 +08:00
<div class="layui-input-block">
2021-05-15 14:43:37 +08:00
<input type="text" id="planNumber" name="planNumber" class="layui-input" value=""
autocomplete="off" placeholder="班次不可重复" lay-verify="required" maxlength="100">
2021-05-04 14:00:54 +08:00
</div>
</div>
2021-05-03 18:08:21 +08:00
</div>
2021-05-11 09:19:02 +08:00
</div>
<div class="layui-row">
<div class="layui-col-md12">
2021-05-04 14:00:54 +08:00
<div class="layui-form-item">
2021-05-15 14:43:37 +08:00
<label class="layui-form-label"><span style="color: red">*</span>班级名称</label>
2021-05-04 14:00:54 +08:00
<div class="layui-input-block">
2021-05-15 14:43:37 +08:00
<input type="text" id="planName" name="planName" class="layui-input" value=""
autocomplete="off" placeholder="请输入班级名称" lay-verify="required" maxlength="255">
2021-05-04 14:00:54 +08:00
</div>
</div>
2021-05-03 18:08:21 +08:00
</div>
</div>
2021-05-04 14:00:54 +08:00
<div class="layui-row">
2021-05-04 18:10:04 +08:00
<div class="layui-col-md3">
2021-05-04 14:00:54 +08:00
<div class="layui-form-item">
2021-05-11 09:19:02 +08:00
<label class="layui-form-label"><span style="color: red">*</span>培训类型</label>
2021-05-04 14:00:54 +08:00
<div class="layui-input-block">
<select id="planType" name="planType">
<option value="1">初训</option>
<option value="2">复训</option>
</select>
</div>
</div>
2021-05-03 18:08:21 +08:00
</div>
2021-05-04 18:10:04 +08:00
<div class="layui-col-md3">
<div class="layui-form-item">
2021-05-11 09:19:02 +08:00
<label class="layui-form-label"><span style="color: red">*</span>培训项目</label>
2021-05-04 18:10:04 +08:00
<div class="layui-input-block">
<input type="hidden" id="projectCatalogId" name="projectCatalogId" value="">
2021-05-11 09:19:02 +08:00
<input type="text" id="projectCatalogName" name="projectCatalogName" class="layui-input" value="" style="cursor: pointer;" lay-verify="required" placeholder="请选择培训项目" readonly="readonly">
2021-05-04 18:10:04 +08:00
</div>
</div>
</div>
<div class="layui-col-md3">
2021-05-04 14:00:54 +08:00
<div class="layui-form-item">
2021-05-15 14:43:37 +08:00
<label class="layui-form-label"><span style="color: red">*</span>开班时间</label>
2021-05-04 14:00:54 +08:00
<div class="layui-input-block">
2021-05-15 14:43:37 +08:00
<input type="text" id="planStartTime" name="planStartTime" class="layui-input" value="" placeholder="请选择开班时间" readonly style="cursor: pointer;" lay-verify="required">
2021-05-04 14:00:54 +08:00
</div>
</div>
2021-05-03 18:08:21 +08:00
</div>
2021-05-04 14:00:54 +08:00
<div class="layui-col-md3">
<div class="layui-form-item">
2021-05-15 14:43:37 +08:00
<label class="layui-form-label"><span style="color: red">*</span>结课时间</label>
2021-05-04 14:00:54 +08:00
<div class="layui-input-block">
2021-05-15 14:43:37 +08:00
<input type="text" id="planEndTime" name="planEndTime" class="layui-input" value="" placeholder="请选择结课时间" readonly style="cursor: pointer;" lay-verify="required">
2021-05-04 14:00:54 +08:00
</div>
</div>
2021-05-03 18:08:21 +08:00
</div>
</div>
2021-05-04 14:00:54 +08:00
<div class="layui-row">
<div class="layui-col-md6">
<div class="layui-form-item">
2021-05-11 09:19:02 +08:00
<label class="layui-form-label"><span style="color: red">*</span>负责人</label>
2021-05-04 14:00:54 +08:00
<div class="layui-input-block">
2021-05-15 14:43:37 +08:00
<input type="text" id="chargePerson" name="chargePerson" class="layui-input" value=""
autocomplete="off" placeholder="请输入负责人" lay-verify="required" maxlength="50">
2021-05-04 14:00:54 +08:00
</div>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-form-item">
2021-05-11 09:19:02 +08:00
<label class="layui-form-label"><span style="color: red">*</span>联系方式</label>
2021-05-04 14:00:54 +08:00
<div class="layui-input-block">
2021-05-15 14:43:37 +08:00
<input type="text" id="chargePersonTel" name="chargePersonTel" class="layui-input" value=""
autocomplete="off" placeholder="请输入联系方式" lay-verify="required" maxlength="255">
2021-05-04 14:00:54 +08:00
</div>
</div>
2021-05-03 18:08:21 +08:00
</div>
</div>
2021-05-04 14:00:54 +08:00
<div class="layui-row">
<div class="layui-col-md12">
<div class="layui-form-item">
2021-05-11 09:19:02 +08:00
<label class="layui-form-label"><span style="color: red">*</span>培训地点</label>
2021-05-04 14:00:54 +08:00
<div class="layui-input-block">
2021-05-15 14:43:37 +08:00
<input type="text" id="planAddress" name="planAddress" class="layui-input" value=""
autocomplete="off" placeholder="请输入培训地点" lay-verify="required" maxlength="255">
2021-05-04 14:00:54 +08:00
</div>
</div>
2021-05-03 18:08:21 +08:00
</div>
</div>
2021-05-04 14:00:54 +08:00
<div class="layui-row">
2021-05-15 14:43:37 +08:00
<div class="layui-col-md12">
<button type="button" id="teacher-lessons-event" class="layui-btn layui-btn layui-btn-info">
<i class="fa fa-lg fa-plus"></i> 配置课程及讲师
</button>
</div>
</div>
<div class="layui-row teacher-lessons-div" style="display:;">
2021-05-04 14:00:54 +08:00
<div class="layui-col-md12">
2021-05-04 18:10:04 +08:00
<table class="layui-table" id="dataTable" lay-filter="dataTable">
<thead>
<tr>
2021-05-05 15:56:38 +08:00
<th style="width: 50px; text-align: center"><b>确认课程</b></th>
2021-05-15 14:43:37 +08:00
<th style="width: 100px; text-align: center"><b>选择讲师</b></th>
<th style="width: 200px; text-align: center"><b>授课时间</b></th>
2021-05-04 18:10:04 +08:00
<th style="width: 260px; text-align: center"><b>课程名称</b></th>
<th style="width: 100px; text-align: center"><b>课程类型</b></th>
<th style="width: 100px; text-align: center"><b>授课方式</b></th>
</tr>
</thead>
<tbody id="lessonTbodyBox"></tbody>
<script type="text/html" id="lessonTbodyTemplate">
{{# for(var i = 0, item; item = d.lesson[i++];) { }}
<tr id="lesson-{{item.lessonId}}" data-lesson-id="{{item.lessonId}}">
<td style="text-align: center">
<input data-lesson-id="{{item.lessonId}}" type="checkbox" name="lessonCheckBox" lay-skin="primary" lay-filter="lessonCheckBox">
</td>
2021-05-05 15:56:38 +08:00
<td style="text-align: center">
<select id="select-{{item.lessonId}}">
<option value="">请选择</option>
{{# for(var j = 0, teacher; teacher = d.teacher[j++];) { }}
<option value="{{teacher.teacherId}}">{{teacher.teacherName}}</option>
{{# } }}
</select>
</td>
2021-05-15 14:43:37 +08:00
<td>
<div class="test-table-reload-btn">
<div class="layui-inline">
<input type="text" id="date-start-{{item.lessonId}}" class="layui-input search-item lessons-date"
2021-05-17 17:14:40 +08:00
style="width: 150px" placeholder="开始时间" readonly>
2021-05-15 14:43:37 +08:00
</div>
<div class="layui-inline">
<input type="text" id="date-end-{{item.lessonId}}" class="layui-input search-item lessons-date"
2021-05-17 17:14:40 +08:00
style="width: 150px" placeholder="结束时间" readonly>
2021-05-15 14:43:37 +08:00
</div>
</div>
</td>
2021-05-04 18:10:04 +08:00
<td style="text-align: center">
{{item.lessonName}}
</td>
<td style="text-align: center">
{{# if(item.lessonType == '1'){ }}
必修
{{# } }}
{{# if(item.lessonType == '2'){ }}
选修
{{# } }}
</td>
<td style="text-align: center">
{{# if(item.teachWay == '1'){ }}
面授
{{# } }}
</td>
</tr>
{{# } }}
</script>
</table>
2021-05-03 18:08:21 +08:00
</div>
</div>
<div class="layui-form-item layui-layout-admin">
<div class="layui-input-block">
2021-05-05 15:56:38 +08:00
<div class="layui-footer" style="left: 0;z-index: 10">
2021-05-03 18:08:21 +08:00
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交新增</button>
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
2021-05-04 14:00:54 +08:00
}).use(['index', 'table', 'form', 'laydate', 'laytpl'], function(){
2021-05-03 18:08:21 +08:00
var $ = layui.$;
2021-05-04 14:00:54 +08:00
var $win = $(window);
var table = layui.table;
2021-05-03 18:08:21 +08:00
var form = layui.form;
2021-05-04 14:00:54 +08:00
var admin = layui.admin;
2021-05-03 18:08:21 +08:00
var laytpl = layui.laytpl;
var laydate = layui.laydate;
2021-05-04 18:10:04 +08:00
var teacherList = [];
2021-05-05 14:48:07 +08:00
var orgId = top.restAjax.params(window.location.href).orgId;
2021-05-15 19:42:31 +08:00
var workerCatalog = top.restAjax.params(window.location.href).workerCatalog;
2021-05-03 18:08:21 +08:00
2021-05-04 14:00:54 +08:00
// 初始化内容
function initData() {
2021-05-15 14:43:37 +08:00
$('.layui-card').height($(window).height());
2021-05-04 14:00:54 +08:00
initPlanStartTimeDateTime();
initPlanEndTimeDateTime();
2021-05-04 18:10:04 +08:00
initTeacherList();
2021-05-03 18:08:21 +08:00
}
2021-05-04 14:00:54 +08:00
initData();
2021-05-03 18:08:21 +08:00
2021-05-15 14:43:37 +08:00
// 初始化培训开始时间时间戳
function initPlanStartTimeDateTime() {
laydate.render({
elem: '#planStartTime',
type: 'date',
trigger: 'click',
min : 0
});
}
// 初始化培训结束时间时间戳
function initPlanEndTimeDateTime() {
laydate.render({
elem: '#planEndTime',
type: 'date',
trigger: 'click',
min : 0
});
}
2021-05-04 18:10:04 +08:00
//查询课程列表
function initLessonsList(){
2021-05-05 14:48:07 +08:00
var dataObj = {};
2021-05-04 18:10:04 +08:00
var projectCatalogId = $('#projectCatalogId').val();
if(projectCatalogId == ''){
2021-05-05 14:48:07 +08:00
dataObj['lesson'] = [];
dataObj['teacher'] = [];
laytpl(document.getElementById('lessonTbodyTemplate').innerHTML).render(dataObj, function(html) {
2021-05-04 18:10:04 +08:00
document.getElementById('lessonTbodyBox').innerHTML = html;
});
form.render();
return;
}
top.restAjax.get(top.restAjax.path('api/lessons/list',[]), {projectCatalogId : projectCatalogId}, null, function(code,data){
dataObj['lesson'] = data;
dataObj['teacher'] = teacherList;
laytpl(document.getElementById('lessonTbodyTemplate').innerHTML).render(dataObj, function(html) {
document.getElementById('lessonTbodyBox').innerHTML = html;
});
form.render();
2021-05-15 14:43:37 +08:00
$.each($('.lessons-date'),function(){
var _this = this;
laydate.render({
format : 'HH:mm',
elem: _this,
type: 'time',
trigger: 'click',
min: '08:00:00',
max: '21:00:00'
});
});
2021-05-04 18:10:04 +08:00
},function(code,data){
top.dialog.msg(data.msg);
});
}
//查询讲师列表
function initTeacherList(){
2021-05-05 14:51:40 +08:00
top.restAjax.get(top.restAjax.path('api/teacher/list',[]), {orgId : orgId}, null, function(code,data){
2021-05-04 18:10:04 +08:00
teacherList = data;
},function(code,data){
top.dialog.msg(data.msg);
});
}
2021-05-15 14:43:37 +08:00
// 配置讲师及课程按钮事件
$('#teacher-lessons-event').on('click',function(){
if($('#projectCatalogId').val() == ''){
layer.msg('必须先选择培训项目');
return;
}
if($('#planStartTime').val() == ''){
layer.msg('必须先选择开班时间');
return;
}
if($('#planEndTime').val() == ''){
layer.msg('必须先选择结课时间');
return;
}
initLessonsList();
$('.teacher-lessons-div').show();
});
2021-05-04 18:10:04 +08:00
form.on('checkbox(lessonCheckBox)',function(data){
var lessonId = $(data.elem).attr('data-lesson-id');
var teacherId = $('#select-' + lessonId).val();
2021-05-15 14:43:37 +08:00
var dateStartTime = $('#date-start-' + lessonId).val();
var dateEndTime = $('#date-end-' + lessonId).val();
if(teacherId == ''){
data.elem.checked = false;
2021-05-04 18:10:04 +08:00
form.render();
2021-05-15 14:43:37 +08:00
layer.msg('先选择讲师');
2021-05-04 18:10:04 +08:00
return;
}
2021-05-15 14:43:37 +08:00
if(dateStartTime == '' || dateEndTime == ''){
2021-05-04 18:10:04 +08:00
data.elem.checked = false;
2021-05-15 14:43:37 +08:00
$('#date-start-' + lessonId).removeAttr("disabled");
$('#date-end-' + lessonId).removeAttr("disabled");
form.render();
layer.msg('授课时间存在空值');
return;
}
dateStartTime = '1970-12-12 ' + dateStartTime + ':00';
dateEndTime = '1970-12-12 ' + dateEndTime + ':00';
if(verifyDate(dateStartTime,dateEndTime) != -1){
data.elem.checked = false;
$('#date-start-' + lessonId).removeAttr("disabled");
$('#date-end-' + lessonId).removeAttr("disabled");
form.render();
layer.msg('授课起止时间冲突');
return;
}
//校验所有时间是否合法
var checkedList = $('input[name="lessonCheckBox"]:checked');
var checkPass = true;
2021-05-17 14:20:03 +08:00
if((checkedList.length -1) != 0){
2021-05-15 14:43:37 +08:00
$.each(checkedList,function(i,e){
var tempLessonId = $(e).attr('data-lesson-id');
2021-05-17 14:20:03 +08:00
var tempTeacherId = $('#select-' + tempLessonId).val();
2021-05-15 14:43:37 +08:00
var _tempStart = '1970-12-12 ' + $('#date-start-' + tempLessonId).val() + ':00';
var _tempEnd = '1970-12-12 ' + $('#date-end-' + tempLessonId).val() + ':00';
if((verifyDate(dateEndTime, _tempStart) == -1)
|| (verifyDate(dateStartTime, _tempEnd) == 1)){
checkPass = true;
2021-05-17 14:20:03 +08:00
} else if( tempLessonId != lessonId && tempTeacherId == teacherId){
2021-05-15 14:43:37 +08:00
data.elem.checked = false;
layer.msg('课程时间存在冲突');
form.render();
return;
}
});
}
if(data.elem.checked == false){
$('#select-' + lessonId).removeAttr("disabled");
$('#date-start-' + lessonId).removeAttr("disabled");
$('#date-end-' + lessonId).removeAttr("disabled");
2021-05-04 18:10:04 +08:00
form.render();
return;
}
$('#select-' + lessonId).attr("disabled","disabled");
2021-05-15 14:43:37 +08:00
$('#date-start-' + lessonId).attr("disabled","disabled");
$('#date-end-' + lessonId).attr("disabled","disabled");
2021-05-04 18:10:04 +08:00
form.render();
});
$(document).on('click', '#projectCatalogName', function() {
var dataUrl = 'api/data/listztree';
2021-05-04 14:25:41 +08:00
layer.open({
type: 2,
2021-05-04 18:10:04 +08:00
title: '选择培训项目',
2021-05-04 14:25:41 +08:00
closeBtn: 1,
area: ['200px', '400px'],
shadeClose: false,
anim: 2,
2021-05-04 18:10:04 +08:00
content: top.restAjax.path('route/classplan/select-tree.html?parentId={parentId}&dataUrl={dataUrl}',
['9c57f832-0606-48eb-94bb-9b3f90ca0cb2',dataUrl]),
2021-05-04 14:25:41 +08:00
end: function() {
2021-05-04 18:10:04 +08:00
var obj = {};
obj['projectCatalogId'] = top.dialog.dialogTreeData.selectedNodes['id'];
obj['projectCatalogName'] = top.dialog.dialogTreeData.selectedNodes['name'];
form.val('dataForm',obj);
form.render(null, 'dataForm');
top.dialog.dialogTreeData.selectedNodes = {};
2021-05-15 14:43:37 +08:00
if($('#projectCatalogId').val() == ''){
$('.teacher-lessons-div').hide();
}
2021-05-04 14:25:41 +08:00
}
});
});
2021-05-04 18:10:04 +08:00
$(document).on('click', '#workerCatalogName', function() {
var dataUrl = 'api/worktype/listztree';
layer.open({
type: 2,
title: '选择工种',
closeBtn: 1,
area: ['200px', '400px'],
shadeClose: false,
anim: 2,
content: top.restAjax.path('route/classplan/select-tree.html?parentId={parentId}&dataUrl={dataUrl}', ['0',dataUrl]),
end: function() {
var obj = {};
obj['workerCatalog'] = top.dialog.dialogTreeData.selectedNodes['id'];
obj['workerCatalogName'] = top.dialog.dialogTreeData.selectedNodes['name'];
form.val('dataForm',obj);
form.render(null, 'dataForm');
top.dialog.dialogTreeData.selectedNodes = {};
2021-05-03 18:08:21 +08:00
}
});
2021-05-04 18:10:04 +08:00
});
2021-05-03 18:08:21 +08:00
// 提交表单
form.on('submit(submitForm)', function(formData) {
2021-05-04 18:10:04 +08:00
var checkedList = $('input[name="lessonCheckBox"]:checked');
var lessonList = [];
$.each(checkedList,function(i,e){
var obj = {};
obj['lessonId'] = $(e).attr('data-lesson-id');
obj['teacherId'] = $('#select-' + obj['lessonId']).val();
2021-05-15 14:43:37 +08:00
obj['lessonStartTime'] = $('#date-start-' + obj['lessonId']).val();
obj['lessonEndTime'] = $('#date-end-' + obj['lessonId']).val();
2021-05-04 18:10:04 +08:00
lessonList.push(obj);
});
2021-05-06 18:36:57 +08:00
if(lessonList.length == 0){
layer.msg('请至少选择一节课程');
return;
}
2021-05-12 17:20:00 +08:00
// 校验时间
if(verifyDate(formData.field['planStartTime'],formData.field['planEndTime']) == 1){
layer.msg('培训开始时间不能大于结束时间');
return;
}
2021-05-15 19:42:31 +08:00
formData.field['orgId'] = orgId;
formData.field['workerCatalog'] = workerCatalog;
2021-05-04 18:10:04 +08:00
formData.field['lessonList'] = lessonList;
2021-05-03 18:08:21 +08:00
top.dialog.confirm(top.dataMessage.commit, function(index) {
top.dialog.close(index);
var loadLayerIndex;
top.restAjax.post(top.restAjax.path('api/classplan/save', []), formData.field, null, function(code, data) {
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function(index) {
top.dialog.close(index);
2021-05-15 22:21:40 +08:00
closeBox();
2021-05-03 18:08:21 +08:00
},
btn2: function() {
closeBox();
}
});
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
});
return false;
});
2021-05-04 18:10:04 +08:00
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
2021-05-12 17:20:00 +08:00
function verifyDate(value1,value2){
var v1 = new Date(Date.parse(value1.replace(/-/g,"/"))).getTime();
var v2 = new Date(Date.parse(value2.replace(/-/g,"/"))).getTime();
if( v1 < v2){
return -1;
}
if( v1 == v2){
return 0;
}
if( v1 > v2){
return 1;
}
}
2021-05-03 18:08:21 +08:00
$('.close').on('click', function() {
closeBox();
});
// 校验
form.verify({
2021-05-11 09:19:02 +08:00
checkPlanPersonNum : function(value){
if(value <= 0){
return '计划人数必须大于0';
}
}
2021-05-03 18:08:21 +08:00
});
});
</script>
</body>
</html>