计划关联课程关联讲师

This commit is contained in:
wans 2021-05-04 18:10:04 +08:00
parent c267a60482
commit 8ee5e653bf
11 changed files with 253 additions and 97 deletions

View File

@ -1,5 +1,6 @@
package cn.com.tenlion.controller.api.classplan;
import com.alibaba.fastjson.JSONObject;
import ink.wgink.annotation.CheckRequestBodyAnnotation;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.interfaces.consts.ISystemConstant;
@ -38,8 +39,8 @@ public class ClassPlanController extends DefaultBaseController {
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("save")
@CheckRequestBodyAnnotation
public SuccessResult save(@RequestBody ClassPlanVO classPlanVO) {
classPlanService.save(classPlanVO);
public SuccessResult save(@RequestBody JSONObject obj) {
classPlanService.saveJson(obj);
return new SuccessResult();
}

View File

@ -49,6 +49,14 @@ public class TeacherController extends DefaultBaseController {
return teacherService.listPage(page);
}
@ApiOperation(value = "讲师列表", notes = "讲师列表")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list")
public List<TeacherDTO> list() throws SearchException {
Map<String, Object> params = requestParams();
return teacherService.list(params);
}
@ApiOperation(value = "讲师信息新增", notes = "讲师新增接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("save")

View File

@ -117,4 +117,9 @@ public interface IClassPlanDao {
*/
Integer count(Map<String, Object> params) throws SearchException;
/**
* 保存培训计划课程信息
* @param params
*/
void saveClassPlanLesson(Map<String, Object> params);
}

View File

@ -1,5 +1,6 @@
package cn.com.tenlion.service.classplan;
import com.alibaba.fastjson.JSONObject;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.result.SuccessResultList;
import cn.com.tenlion.pojo.dtos.classplan.ClassPlanDTO;
@ -185,4 +186,9 @@ public interface IClassPlanService {
*/
Integer count(Map<String, Object> params);
/**
* 保存培训计划
* @param obj
*/
void saveJson(JSONObject obj);
}

View File

@ -6,6 +6,8 @@ import cn.com.tenlion.pojo.dtos.classplan.ClassPlanDTO;
import cn.com.tenlion.pojo.pos.classplan.ClassPlanPO;
import cn.com.tenlion.pojo.vos.classplan.ClassPlanVO;
import cn.com.tenlion.service.classplan.IClassPlanService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import ink.wgink.common.base.DefaultBaseService;
@ -62,6 +64,44 @@ public class ClassPlanServiceImpl extends DefaultBaseService implements IClassPl
return classPlanId;
}
@Override
public void saveJson(JSONObject obj) {
String classPlanId = UUIDUtil.getUUID();
ClassPlanVO classPlanVO = new ClassPlanVO();
classPlanVO.setClassPlanId(classPlanId);
classPlanVO.setOrgId(obj.getString("orgId"));
classPlanVO.setPlanNumber(obj.getString("planNumber"));
classPlanVO.setPlanName(obj.getString("planName"));
classPlanVO.setPlanType(obj.getString("planType"));
classPlanVO.setProjectCatalogId(obj.getString("projectCatalogId"));
classPlanVO.setWorkerCatalog(obj.getString("workerCatalog"));
classPlanVO.setPlanPersonNum(Integer.parseInt(obj.getString("planPersonNum")));
classPlanVO.setPlanStartTime(obj.getString("planStartTime"));
classPlanVO.setPlanEndTime(obj.getString("planEndTime"));
classPlanVO.setSignUpStartTime(obj.getString("signUpStartTime"));
classPlanVO.setSignUpEndTime(obj.getString("signUpEndTime"));
classPlanVO.setPlanAddress(obj.getString("planAddress"));
classPlanVO.setChargePerson(obj.getString("chargePerson"));
classPlanVO.setChargePersonTel(obj.getString("chargePersonTel"));
classPlanVO.setReportType("0");
classPlanVO.setReportReason("");
Map<String, Object> params = HashMapUtil.beanToMap(classPlanVO);
params.put("classPlanId", classPlanId);
setSaveInfo(params);
classPlanDao.save(params);
//保存课程及讲师
JSONArray array = obj.getJSONArray("lessonList");
params.clear();
for(int i = 0; i < array.size(); i++){
JSONObject item = array.getJSONObject(i);
params.put("classPlanId",classPlanId);
params.put("lessonId",item.getString("lessonId"));
params.put("teacherId",item.getString("teacherId"));
params.put("isDelete",item.getString("teacherId"));
classPlanDao.saveClassPlanLesson(params);
}
}
@Override
public void remove(List<String> ids) {
remove(null, ids);

View File

@ -10,6 +10,7 @@ import ink.wgink.pojo.result.SuccessResultData;
import ink.wgink.pojo.result.SuccessResultList;
import java.util.List;
import java.util.Map;
/**
* 讲师接口
@ -68,4 +69,11 @@ public interface ITeacherService {
* @throws RemoveException
*/
SuccessResult delete(String ids) throws RemoveException ;
/**
* 讲师列表
* @param params
* @return
*/
List<TeacherDTO> list(Map<String, Object> params);
}

View File

@ -43,6 +43,12 @@ public class TeacherServiceImpl extends DefaultBaseService implements ITeacherSe
return new SuccessResultList<>(dtos, pageInfo.getPageNum(), pageInfo.getTotal());
}
@Override
public List<TeacherDTO> list(Map<String, Object> params) {
List<TeacherDTO> dtos = teacherDao.list(params);
return dtos;
}
@Override
public SuccessResultData save(String token, TeacherVO teacherVO) throws Exception {
String teacherId = UUIDUtil.getUUID();

View File

@ -385,4 +385,11 @@
1 = 1
</select>
<insert id="saveClassPlanLesson" parameterType="map">
INSERT INTO e_class_plan_lesson
(class_plan_id,lesson_id,teacher_id,is_delete)
VALUES
(#{classPlanId},#{lessonId},#{teacherId},#{isDelete})
</insert>
</mapper>

View File

@ -38,7 +38,10 @@
FROM
e_teacher t1
WHERE
t1.is_delete = 0
t1.is_delete = 0
<if test="orgId != null and orgId !=''">
AND t1.org_id = #{orgId}
</if>
<if test="keywords != null and keywords != ''">
AND (
t1.certificate_no LIKE CONCAT('%', #{keywords}, '%')

View File

@ -51,7 +51,7 @@
</div>
</div>
<div class="layui-row">
<div class="layui-col-md4">
<div class="layui-col-md3">
<div class="layui-form-item">
<label class="layui-form-label">培训类型</label>
<div class="layui-input-block">
@ -63,24 +63,25 @@
</div>
</div>
</div>
<div class="layui-col-md4">
<div class="layui-col-md3">
<div class="layui-form-item">
<label class="layui-form-label">培训项目</label>
<div class="layui-input-block">
<input type="hidden" id="projectCatalogId" name="projectCatalogId" value="">
<input type="text" id="projectCatalogName" name="projectCatalogName" class="layui-input" value="" style="cursor: pointer;" placeholder="请选择培训项目" readonly="readonly">
</div>
</div>
</div>
<div class="layui-col-md3">
<div class="layui-form-item">
<label class="layui-form-label">培训工种</label>
<div class="layui-input-block">
<input type="text" id="workerCatalog" name="workerCatalog" class="layui-input" value="" placeholder="请选择培训工种" readonly="readonly" maxlength="255">
<input type="hidden" id="workerCatalog" name="workerCatalog" value="">
<input type="text" id="workerCatalogName" name="workerCatalogName" class="layui-input" value="" style="cursor: pointer;" placeholder="请选择培训工种" readonly="readonly">
</div>
<!--<div class="layui-input-block layui-form" id="workerCatalogSelectTemplateBox" lay-filter="workerCatalogSelectTemplateBox"></div>
<script id="workerCatalogSelectTemplate" type="text/html">
<select id="workerCatalog" name="workerCatalog" lay-verify="required">
<option value="">请选择培训工种</option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.dictionaryId}}">{{item.dictionaryName}}</option>
{{# } }}
</select>
</script>-->
</div>
</div>
<div class="layui-col-md4">
<div class="layui-col-md3">
<div class="layui-form-item">
<label class="layui-form-label">计划人数</label>
<div class="layui-input-block">
@ -152,28 +153,53 @@
</div>
</div>
</div>
<div class="layui-row">
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">培训项目</label>
<div class="layui-input-block">
<select id="projectCatalogId" name="projectCatalogId">
<option value="1">培训项目一</option>
</select>
</div>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-form-item">
<select id="projectCatalogId1" name="projectCatalogId1">
<option value="2">培训项目一</option>
</select>
</div>
</div>
</div>
<div class="layui-row">
<div class="layui-col-md12">
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
<table class="layui-table" id="dataTable" lay-filter="dataTable">
<thead>
<tr>
<th style="width: 50px; text-align: center"><b>选择</b></th>
<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>
<th style="width: 200px; 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>
<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>
<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>
</tr>
{{# } }}
</script>
</table>
</div>
</div>
<div class="layui-form-item layui-layout-admin">
@ -208,6 +234,7 @@
var wangEditor = window.wangEditor;
var wangEditorObj = {};
var viewerObj = {};
var teacherList = [];
// 初始化内容
function initData() {
@ -215,11 +242,85 @@
initPlanEndTimeDateTime();
initSignUpStartTimeDateTime();
initSignUpEndTimeDateTime();
initWorkerCatalogSelect();
initTeacherList();
}
initData();
$(document).on('click', '#workerCatalog', function() {
//查询课程列表
function initLessonsList(){
var projectCatalogId = $('#projectCatalogId').val();
if(projectCatalogId == ''){
laytpl(document.getElementById('lessonTbodyTemplate').innerHTML).render([], function(html) {
document.getElementById('lessonTbodyBox').innerHTML = html;
});
form.render();
return;
}
top.restAjax.get(top.restAjax.path('api/lessons/list',[]), {projectCatalogId : projectCatalogId}, null, function(code,data){
var dataObj = {};
dataObj['lesson'] = data;
dataObj['teacher'] = teacherList;
laytpl(document.getElementById('lessonTbodyTemplate').innerHTML).render(dataObj, function(html) {
document.getElementById('lessonTbodyBox').innerHTML = html;
});
form.render();
},function(code,data){
top.dialog.msg(data.msg);
});
}
//查询讲师列表
function initTeacherList(){
top.restAjax.get(top.restAjax.path('api/teacher/list',[]), {orgId : '10086'}, null, function(code,data){
teacherList = data;
},function(code,data){
top.dialog.msg(data.msg);
});
}
form.on('checkbox(lessonCheckBox)',function(data){
var lessonId = $(data.elem).attr('data-lesson-id');
var teacherId = $('#select-' + lessonId).val();
if(data.elem.checked == false){
$('#select-' + lessonId).removeAttr("disabled");
form.render();
return;
}
if(teacherId == ''){
data.elem.checked = false;
form.render();
layer.msg('先选择讲师');
return;
}
$('#select-' + lessonId).attr("disabled","disabled");
form.render();
});
$(document).on('click', '#projectCatalogName', function() {
var dataUrl = 'api/data/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}',
['9c57f832-0606-48eb-94bb-9b3f90ca0cb2',dataUrl]),
end: function() {
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 = {};
initLessonsList();
}
});
});
$(document).on('click', '#workerCatalogName', function() {
var dataUrl = 'api/worktype/listztree';
layer.open({
type: 2,
title: '选择工种',
@ -227,68 +328,18 @@
area: ['200px', '400px'],
shadeClose: false,
anim: 2,
content: top.restAjax.path('route/classplan/select-tree.html', []),
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 = {};
}
});
});
// 初始化培训工种下拉选择
function initWorkerCatalogSelect() {
/*top.restAjax.get(top.restAjax.path('api/datadictionary/listdictionarybyparentid/cbb5f8a8-595c-4df4-b38e-7cbb715f754f', []), {}, null, function(code, data, args) {
laytpl(document.getElementById('workerCatalogSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('workerCatalogSelectTemplateBox').innerHTML = html;
});
form.render('select', 'workerCatalogSelectTemplateBox');
}, function(code, data) {
top.dialog.msg(data.msg);
});*/
}
// 初始化表格
function initTable() {
table.render({
elem: '#dataTable',
id: 'dataTable',
url: top.restAjax.path('', []),
width: admin.screen() > 1 ? '100%' : '',
height: $win.height() - 90,
limit: 20,
limits: [20, 40, 60, 80, 100, 200],
toolbar: '#headerToolBar',
request: {
pageName: 'page',
limitName: 'rows'
},
cols: [
[
{type: 'checkbox', fixed: 'left'},
{
field: 'rowNum',
width: 80,
title: '序号',
fixed: 'left',
align: 'center',
templet: '<span>{{d.LAY_INDEX}}</span>'
}
]
],
page: false,
parseData: function (data) {
return {
'code': 0,
'msg': '',
'count': data.total,
'data': data.rows
};
}
});
}
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
// 初始化培训开始时间时间戳
function initPlanStartTimeDateTime() {
laydate.render({
@ -331,6 +382,15 @@
// 提交表单
form.on('submit(submitForm)', function(formData) {
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();
lessonList.push(obj);
});
formData.field['lessonList'] = lessonList;
top.dialog.confirm(top.dataMessage.commit, function(index) {
top.dialog.close(index);
var loadLayerIndex;
@ -358,6 +418,10 @@
return false;
});
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
$('.close').on('click', function() {
closeBox();
});

View File

@ -37,7 +37,8 @@
var $ = layui.$;
var $win = $(window);
var resizeTimeout = null;
var parentId = '0';
var parentId = top.restAjax.params(window.location.href).parentId;
var dataUrl = top.restAjax.params(window.location.href).dataUrl;
function initData(){
initThree();
@ -60,7 +61,7 @@
enable: true,
autoLoad: true,
type: 'get',
url: top.restAjax.path('api/worktype/listztree', []),
url: top.restAjax.path(dataUrl, []),
autoParam: ['id'],
otherParam: {
id : function () {
@ -81,6 +82,9 @@
return;
}
parentId = treeNode.id;
top.dialog.dialogTreeData.selectedNodes['id'] = treeNode.id;
top.dialog.dialogTreeData.selectedNodes['name'] = treeNode.name;
closeBox();
return false;
}
},
@ -88,6 +92,10 @@
var zTree = $.fn.zTree.init($("#leftTree"), setting);
}
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
// 事件 - 页面变化
$win.on('resize', function() {
clearTimeout(resizeTimeout);