From 8ee5e653bf96878aae3d01ef9bf22868634f28f3 Mon Sep 17 00:00:00 2001 From: wans <747101512@qq.com> Date: Tue, 4 May 2021 18:10:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A1=E5=88=92=E5=85=B3=E8=81=94=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=85=B3=E8=81=94=E8=AE=B2=E5=B8=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/classplan/ClassPlanController.java | 5 +- .../api/teacher/TeacherController.java | 8 + .../tenlion/dao/classplan/IClassPlanDao.java | 5 + .../service/classplan/IClassPlanService.java | 6 + .../classplan/impl/ClassPlanServiceImpl.java | 40 +++ .../service/service/ITeacherService.java | 8 + .../service/impl/TeacherServiceImpl.java | 6 + .../mapper/classplan/class-plan-mapper.xml | 7 + .../mybatis/mapper/teacher/teacher-mapper.xml | 5 +- .../static/route/classplan/save.html | 248 +++++++++++------- .../static/route/classplan/select-tree.html | 12 +- 11 files changed, 253 insertions(+), 97 deletions(-) diff --git a/src/main/java/cn/com/tenlion/controller/api/classplan/ClassPlanController.java b/src/main/java/cn/com/tenlion/controller/api/classplan/ClassPlanController.java index 8816844..53a9dc2 100644 --- a/src/main/java/cn/com/tenlion/controller/api/classplan/ClassPlanController.java +++ b/src/main/java/cn/com/tenlion/controller/api/classplan/ClassPlanController.java @@ -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(); } diff --git a/src/main/java/cn/com/tenlion/controller/api/teacher/TeacherController.java b/src/main/java/cn/com/tenlion/controller/api/teacher/TeacherController.java index 57720fc..69a0f9d 100644 --- a/src/main/java/cn/com/tenlion/controller/api/teacher/TeacherController.java +++ b/src/main/java/cn/com/tenlion/controller/api/teacher/TeacherController.java @@ -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 list() throws SearchException { + Map params = requestParams(); + return teacherService.list(params); + } + @ApiOperation(value = "讲师信息新增", notes = "讲师新增接口") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @PostMapping("save") diff --git a/src/main/java/cn/com/tenlion/dao/classplan/IClassPlanDao.java b/src/main/java/cn/com/tenlion/dao/classplan/IClassPlanDao.java index 17c1b81..5605b6a 100644 --- a/src/main/java/cn/com/tenlion/dao/classplan/IClassPlanDao.java +++ b/src/main/java/cn/com/tenlion/dao/classplan/IClassPlanDao.java @@ -117,4 +117,9 @@ public interface IClassPlanDao { */ Integer count(Map params) throws SearchException; + /** + * 保存培训计划课程信息 + * @param params + */ + void saveClassPlanLesson(Map params); } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/service/classplan/IClassPlanService.java b/src/main/java/cn/com/tenlion/service/classplan/IClassPlanService.java index 89f292d..2388292 100644 --- a/src/main/java/cn/com/tenlion/service/classplan/IClassPlanService.java +++ b/src/main/java/cn/com/tenlion/service/classplan/IClassPlanService.java @@ -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 params); + /** + * 保存培训计划 + * @param obj + */ + void saveJson(JSONObject obj); } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/service/classplan/impl/ClassPlanServiceImpl.java b/src/main/java/cn/com/tenlion/service/classplan/impl/ClassPlanServiceImpl.java index 25457ac..61c0787 100644 --- a/src/main/java/cn/com/tenlion/service/classplan/impl/ClassPlanServiceImpl.java +++ b/src/main/java/cn/com/tenlion/service/classplan/impl/ClassPlanServiceImpl.java @@ -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 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 ids) { remove(null, ids); diff --git a/src/main/java/cn/com/tenlion/service/service/ITeacherService.java b/src/main/java/cn/com/tenlion/service/service/ITeacherService.java index 5b40dff..6dd3b1b 100644 --- a/src/main/java/cn/com/tenlion/service/service/ITeacherService.java +++ b/src/main/java/cn/com/tenlion/service/service/ITeacherService.java @@ -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 list(Map params); } diff --git a/src/main/java/cn/com/tenlion/service/service/impl/TeacherServiceImpl.java b/src/main/java/cn/com/tenlion/service/service/impl/TeacherServiceImpl.java index b8eb0c0..302c885 100644 --- a/src/main/java/cn/com/tenlion/service/service/impl/TeacherServiceImpl.java +++ b/src/main/java/cn/com/tenlion/service/service/impl/TeacherServiceImpl.java @@ -43,6 +43,12 @@ public class TeacherServiceImpl extends DefaultBaseService implements ITeacherSe return new SuccessResultList<>(dtos, pageInfo.getPageNum(), pageInfo.getTotal()); } + @Override + public List list(Map params) { + List dtos = teacherDao.list(params); + return dtos; + } + @Override public SuccessResultData save(String token, TeacherVO teacherVO) throws Exception { String teacherId = UUIDUtil.getUUID(); diff --git a/src/main/resources/mybatis/mapper/classplan/class-plan-mapper.xml b/src/main/resources/mybatis/mapper/classplan/class-plan-mapper.xml index 40b8454..f95a193 100644 --- a/src/main/resources/mybatis/mapper/classplan/class-plan-mapper.xml +++ b/src/main/resources/mybatis/mapper/classplan/class-plan-mapper.xml @@ -385,4 +385,11 @@ 1 = 1 + + INSERT INTO e_class_plan_lesson + (class_plan_id,lesson_id,teacher_id,is_delete) + VALUES + (#{classPlanId},#{lessonId},#{teacherId},#{isDelete}) + + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/teacher/teacher-mapper.xml b/src/main/resources/mybatis/mapper/teacher/teacher-mapper.xml index 0805904..c01a361 100644 --- a/src/main/resources/mybatis/mapper/teacher/teacher-mapper.xml +++ b/src/main/resources/mybatis/mapper/teacher/teacher-mapper.xml @@ -38,7 +38,10 @@ FROM e_teacher t1 WHERE - t1.is_delete = 0 + t1.is_delete = 0 + + AND t1.org_id = #{orgId} + AND ( t1.certificate_no LIKE CONCAT('%', #{keywords}, '%') diff --git a/src/main/resources/static/route/classplan/save.html b/src/main/resources/static/route/classplan/save.html index b854adc..9c03703 100644 --- a/src/main/resources/static/route/classplan/save.html +++ b/src/main/resources/static/route/classplan/save.html @@ -51,7 +51,7 @@
-
+
@@ -63,24 +63,25 @@
-
+
+
+ +
+ + +
+
+
+
- + +
-
-
+
@@ -152,28 +153,53 @@
-
-
-
- -
- -
-
-
-
-
- -
-
-
-
+ + + + + + + + + + + + +
选择课程名称课程类型授课方式选择讲师
@@ -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: '{{d.LAY_INDEX}}' - } - ] - ], - 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(); }); diff --git a/src/main/resources/static/route/classplan/select-tree.html b/src/main/resources/static/route/classplan/select-tree.html index 6923fc1..4d09d75 100644 --- a/src/main/resources/static/route/classplan/select-tree.html +++ b/src/main/resources/static/route/classplan/select-tree.html @@ -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);