From 92901b788e77399bb52b75c27d3f57947971aaff Mon Sep 17 00:00:00 2001 From: wans <747101512@qq.com> Date: Thu, 6 May 2021 18:36:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=B9=E8=AE=AD=E8=AE=A1=E5=88=92=E5=9B=9E?= =?UTF-8?q?=E6=98=BE=E7=BC=96=E8=BE=91=E6=96=B9=E6=B3=95=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/classplan/ClassPlanController.java | 25 +- .../tenlion/dao/classplan/IClassPlanDao.java | 13 + .../pojo/dtos/classplan/ClassPlanDTO.java | 28 + .../service/classplan/IClassPlanService.java | 9 + .../classplan/impl/ClassPlanServiceImpl.java | 57 +- .../mapper/classplan/class-plan-mapper.xml | 19 + .../static/route/classplan/list.html | 8 + .../static/route/classplan/save.html | 4 + .../static/route/classplan/update.html | 515 ++++++++++++------ 9 files changed, 498 insertions(+), 180 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 a6f57c7..a1389a2 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 @@ -44,6 +44,19 @@ public class ClassPlanController extends DefaultBaseController { return new SuccessResult(); } + @ApiOperation(value = "修改", notes = "修改接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "classPlanId", value = "ID", paramType = "path") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @PutMapping("update/{classPlanId}") + @CheckRequestBodyAnnotation + public SuccessResult update(@PathVariable("classPlanId") String classPlanId, @RequestBody JSONObject obj) { + obj.put("classPlanId",classPlanId); + classPlanService.updateJson(obj); + return new SuccessResult(); + } + @ApiOperation(value = "删除", notes = "删除接口") @ApiImplicitParams({ @ApiImplicitParam(name = "ids", value = "ID列表,用下划线分隔", paramType = "path", example = "1_2_3") @@ -55,18 +68,6 @@ public class ClassPlanController extends DefaultBaseController { return new SuccessResult(); } - @ApiOperation(value = "修改", notes = "修改接口") - @ApiImplicitParams({ - @ApiImplicitParam(name = "classPlanId", value = "ID", paramType = "path") - }) - @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @PutMapping("update/{classPlanId}") - @CheckRequestBodyAnnotation - public SuccessResult update(@PathVariable("classPlanId") String classPlanId, @RequestBody ClassPlanVO classPlanVO) { - classPlanService.update(classPlanId, classPlanVO); - return new SuccessResult(); - } - @ApiOperation(value = "详情", notes = "详情接口") @ApiImplicitParams({ @ApiImplicitParam(name = "classPlanId", value = "ID", paramType = "path") 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 5605b6a..29b0500 100644 --- a/src/main/java/cn/com/tenlion/dao/classplan/IClassPlanDao.java +++ b/src/main/java/cn/com/tenlion/dao/classplan/IClassPlanDao.java @@ -122,4 +122,17 @@ public interface IClassPlanDao { * @param params */ void saveClassPlanLesson(Map params); + + /** + * 查询计划下课程选择信息 + * @param classPlanId + * @return + */ + List> listClassPlanLessons(String classPlanId); + + /** + * 逻辑删除计划下所有课程 + * @param params + */ + void deleteClassPlanLessons(Map params); } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/pojo/dtos/classplan/ClassPlanDTO.java b/src/main/java/cn/com/tenlion/pojo/dtos/classplan/ClassPlanDTO.java index bbcd835..2ea7bfb 100644 --- a/src/main/java/cn/com/tenlion/pojo/dtos/classplan/ClassPlanDTO.java +++ b/src/main/java/cn/com/tenlion/pojo/dtos/classplan/ClassPlanDTO.java @@ -5,6 +5,10 @@ import ink.wgink.annotation.CheckNumberAnnotation; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + /** * * @ClassName: ClassPlanDTO @@ -59,6 +63,11 @@ public class ClassPlanDTO { private String reportType; @ApiModelProperty(name = "reportReason", value = "报备审核原因") private String reportReason; + @ApiModelProperty(name = "orgName", value = "机构名称") + private String orgName; + @ApiModelProperty(name = "classPlanLessons", value = "计划下课程列表") + private List> classPlanLessons; + public String getPlanNumber() { return planNumber == null ? "" : planNumber.trim(); @@ -211,4 +220,23 @@ public class ClassPlanDTO { public void setWorkerCatalogName(String workerCatalogName) { this.workerCatalogName = workerCatalogName; } + + public String getOrgName() { + return orgName == null ? "" : orgName; + } + + public void setOrgName(String orgName) { + this.orgName = orgName; + } + + public List> getClassPlanLessons() { + if (classPlanLessons == null) { + return new ArrayList<>(); + } + return classPlanLessons; + } + + public void setClassPlanLessons(List> classPlanLessons) { + this.classPlanLessons = classPlanLessons; + } } 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 1dc2fd4..8b4a4ac 100644 --- a/src/main/java/cn/com/tenlion/service/classplan/IClassPlanService.java +++ b/src/main/java/cn/com/tenlion/service/classplan/IClassPlanService.java @@ -88,6 +88,14 @@ public interface IClassPlanService { */ void update(String classPlanId, ClassPlanVO classPlanVO); + /** + * 修改 + * + * @param obj + * @return + */ + void updateJson(JSONObject obj); + /** * 修改 * @@ -198,4 +206,5 @@ public interface IClassPlanService { * @param classPlanVO */ void updateReportType(String classPlanId, ClassPlanVO classPlanVO); + } \ 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 d5bbaa8..c5fbae0 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 @@ -1,6 +1,8 @@ package cn.com.tenlion.service.classplan.impl; import cn.com.tenlion.dao.classplan.IClassPlanDao; +import cn.com.tenlion.institutionmanagement.pojo.dtos.institution.InstitutionDTO; +import cn.com.tenlion.institutionmanagement.service.institution.IInstitutionService; import cn.com.tenlion.pojo.bos.classplan.ClassPlanBO; import cn.com.tenlion.pojo.dtos.classplan.ClassPlanDTO; import cn.com.tenlion.pojo.dtos.worktype.WorkTypeDTO; @@ -47,6 +49,8 @@ public class ClassPlanServiceImpl extends DefaultBaseService implements IClassPl private IDataService dataService; @Autowired private IWorkTypeService workTypeService; + @Autowired + private IInstitutionService iInstitutionService; @Override public void save(ClassPlanVO classPlanVO) { @@ -115,6 +119,44 @@ public class ClassPlanServiceImpl extends DefaultBaseService implements IClassPl } } + @Override + public void updateJson(JSONObject obj) { + String classPlanId = obj.getString("classPlanId"); + 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); + setUpdateInfo(params); + classPlanDao.update(params); + classPlanDao.deleteClassPlanLessons(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); @@ -179,7 +221,20 @@ public class ClassPlanServiceImpl extends DefaultBaseService implements IClassPl public ClassPlanDTO get(String classPlanId) { Map params = super.getHashMap(2); params.put("classPlanId", classPlanId); - return get(params); + ClassPlanDTO dto = get(params); + // 查询机构名称 + InstitutionDTO institutionDTO = iInstitutionService.get(dto.getOrgId()); + dto.setOrgName(institutionDTO.getInstitutionName()); + // 查询培训项目 + DataDTO dataDTO = dataService.get(dto.getProjectCatalogId()); + dto.setProjectCatalogName(dataDTO.getDataName()); + // 查询工种类型 + WorkTypeDTO workTypeDTO = workTypeService.get(dto.getWorkerCatalog()); + dto.setWorkerCatalogName(workTypeDTO.getWorkTypeName()); + // 查询当前计划下所有课程和讲师绑定信息 + List> classPlanLessons = classPlanDao.listClassPlanLessons(classPlanId); + dto.setClassPlanLessons(classPlanLessons); + return dto; } @Override 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 c1155a2..21bff99 100644 --- a/src/main/resources/mybatis/mapper/classplan/class-plan-mapper.xml +++ b/src/main/resources/mybatis/mapper/classplan/class-plan-mapper.xml @@ -405,4 +405,23 @@ (#{classPlanId},#{lessonId},#{teacherId},0) + + + + UPDATE e_class_plan_lesson SET + is_delete = '1' + WHERE + class_plan_id = #{classPlanId} + + \ No newline at end of file diff --git a/src/main/resources/static/route/classplan/list.html b/src/main/resources/static/route/classplan/list.html index 208bc05..3448005 100644 --- a/src/main/resources/static/route/classplan/list.html +++ b/src/main/resources/static/route/classplan/list.html @@ -330,6 +330,14 @@ } else if(checkDatas.length > 1) { top.dialog.msg(top.dataMessage.table.selectOneEdit); } else { + if(checkDatas[0].reportType == '1'){ + layer.msg('报备待审状态下无法修改'); + return; + } + if(checkDatas[0].reportType == '2'){ + layer.msg('报备通过后无法修改'); + return; + } layer.open({ type: 2, title: false, diff --git a/src/main/resources/static/route/classplan/save.html b/src/main/resources/static/route/classplan/save.html index 2507929..d5524a9 100644 --- a/src/main/resources/static/route/classplan/save.html +++ b/src/main/resources/static/route/classplan/save.html @@ -396,6 +396,10 @@ obj['teacherId'] = $('#select-' + obj['lessonId']).val(); lessonList.push(obj); }); + if(lessonList.length == 0){ + layer.msg('请至少选择一节课程'); + return; + } formData.field['lessonList'] = lessonList; top.dialog.confirm(top.dataMessage.commit, function(index) { top.dialog.close(index); diff --git a/src/main/resources/static/route/classplan/update.html b/src/main/resources/static/route/classplan/update.html index b057865..7560a69 100644 --- a/src/main/resources/static/route/classplan/update.html +++ b/src/main/resources/static/route/classplan/update.html @@ -17,93 +17,196 @@
-
- -
- +
+
+
+ +
+ + +
+
-
- -
- +
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
-
- -
- +
+
+
+ +
+ +
+
+
+
+
+ +
+ + +
+
+
+
+
+ +
+ + +
+
+
+
+
+ +
+ +
+
-
- -
- +
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
-
- -
- +
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
-
- -
- +
+
+
+ +
+ +
+
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- +
+
+ + + + + + + + + + + + +
确认课程选择讲师课程名称课程类型授课方式
- @@ -121,111 +224,20 @@ base: 'assets/layuiadmin/' //静态资源所在路径 }).extend({ index: 'lib/index' //主入口模块 - }).use(['index', 'form', 'laydate', 'laytpl'], function(){ + }).use(['index', 'table', 'form', 'laydate', 'laytpl'], function(){ var $ = layui.$; + var $win = $(window); + var table = layui.table; var form = layui.form; + var admin = layui.admin; var laytpl = layui.laytpl; var laydate = layui.laydate; - var classPlanId = top.restAjax.params(window.location.href).classPlanId; - var wangEditor = window.wangEditor; var wangEditorObj = {}; var viewerObj = {}; - - function closeBox() { - parent.layer.close(parent.layer.getFrameIndex(window.name)); - } - - function refreshDownloadTemplet(fileName, file) { - var dataRander = {}; - dataRander[fileName] = file; - - laytpl(document.getElementById(fileName +'FileDownload').innerHTML).render(dataRander, function(html) { - document.getElementById(fileName +'FileBox').innerHTML = html; - }); - } - - // 初始化文件列表 - function initFileList(fileName, ids, callback) { - var dataForm = {}; - dataForm[fileName] = ids; - form.val('dataForm', dataForm); - - if(!ids) { - refreshDownloadTemplet(fileName, []); - if(callback) { - callback(fileName, []); - } - return; - } - - top.restAjax.get(top.restAjax.path('api/file/list', []), { - ids: ids - }, null, function(code, data) { - refreshDownloadTemplet(fileName, data); - if(callback) { - callback(fileName, data); - } - }, function(code, data) { - top.dialog.msg(data.msg); - }); - } - - // 初始化视频 - function initVideo(fileName, data) { - for(var i = 0, item; item = data[i++];) { - var player = new ckplayer({ - container: '#'+ fileName + i, - variable: 'player', - flashplayer: false, - video: { - file: 'route/file/download/true/'+ item.fileId, - type: 'video/mp4' - } - }); - } - } - - // 初始化培训开始时间时间戳 - function initPlanStartTimeDateTime() { - laydate.render({ - elem: '#planStartTime', - type: 'datetime', - value: new Date(), - trigger: 'click' - }); - } - - // 初始化培训结束时间时间戳 - function initPlanEndTimeDateTime() { - laydate.render({ - elem: '#planEndTime', - type: 'datetime', - value: new Date(), - trigger: 'click' - }); - } - - // 初始化报名时间开始时间戳 - function initSignUpStartTimeDateTime() { - laydate.render({ - elem: '#signUpStartTime', - type: 'datetime', - value: new Date(), - trigger: 'click' - }); - } - - // 初始化报名时间截止时间戳 - function initSignUpEndTimeDateTime() { - laydate.render({ - elem: '#signUpEndTime', - type: 'datetime', - value: new Date(), - trigger: 'click' - }); - } - + var teacherList = []; + var classPlanLessons = []; + var classPlanId = top.restAjax.params(window.location.href).classPlanId; // 初始化内容 function initData() { @@ -235,12 +247,19 @@ for(var i in data) { dataFormData[i] = data[i] +''; } + dataFormData['planStartTime'] = dataFormData['planStartTime'].substring(0,10); + dataFormData['planEndTime'] = dataFormData['planEndTime'].substring(0,10); + dataFormData['signUpStartTime'] = dataFormData['signUpStartTime'].substring(0,10); + dataFormData['signUpEndTime'] = dataFormData['signUpEndTime'].substring(0,10); form.val('dataForm', dataFormData); form.render(null, 'dataForm'); initPlanStartTimeDateTime(); initPlanEndTimeDateTime(); initSignUpStartTimeDateTime(); initSignUpEndTimeDateTime(); + //初始化课程列表 + initTeacherList(data.orgId); + classPlanLessons = data.classPlanLessons; }, function(code, data) { top.dialog.msg(data.msg); }, function() { @@ -250,14 +269,172 @@ }); } initData(); - + + //查询讲师列表 + function initTeacherList(orgId){ + top.restAjax.get(top.restAjax.path('api/teacher/list',[]), {orgId : orgId}, null, function(code,data){ + teacherList = data; + initLessonsList(); + },function(code,data){ + top.dialog.msg(data.msg); + }); + } + + //查询课程列表 + function initLessonsList(){ + var dataObj = {}; + var projectCatalogId = $('#projectCatalogId').val(); + if(projectCatalogId == ''){ + dataObj['lesson'] = []; + dataObj['teacher'] = []; + laytpl(document.getElementById('lessonTbodyTemplate').innerHTML).render(dataObj, 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){ + dataObj['lesson'] = data; + dataObj['teacher'] = teacherList; + laytpl(document.getElementById('lessonTbodyTemplate').innerHTML).render(dataObj, function(html) { + document.getElementById('lessonTbodyBox').innerHTML = html; + }); + form.render(); + reloadLessonsList(); + },function(code,data){ + top.dialog.msg(data.msg); + }); + } + + function reloadLessonsList(){ + if(typeof (classPlanLessons) != 'undefined' && classPlanLessons.length > 0) + $.each(classPlanLessons,function(i,e){ + var checkBox = $('#lesson-' + e.lessonId).find('input[name="lessonCheckBox"]').get(0); + $(checkBox).attr('checked', 'checked'); + $('#select-' + e.lessonId).val(e.teacherId); + $('#select-' + e.lessonId).attr("disabled","disabled"); + }); + form.render(); + } + + 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: '选择工种', + 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 = {}; + } + }); + }); + + // 初始化培训开始时间时间戳 + function initPlanStartTimeDateTime() { + laydate.render({ + elem: '#planStartTime', + type: 'date', + trigger: 'click' + }); + } + + // 初始化培训结束时间时间戳 + function initPlanEndTimeDateTime() { + laydate.render({ + elem: '#planEndTime', + type: 'date', + trigger: 'click' + }); + } + + // 初始化报名时间开始时间戳 + function initSignUpStartTimeDateTime() { + laydate.render({ + elem: '#signUpStartTime', + type: 'date', + trigger: 'click' + }); + } + + // 初始化报名时间截止时间戳 + function initSignUpEndTimeDateTime() { + laydate.render({ + elem: '#signUpEndTime', + type: 'date', + trigger: 'click' + }); + } + // 提交表单 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); + }); + if(lessonList.length == 0){ + layer.msg('请至少选择一节课程'); + return; + } + formData.field['lessonList'] = lessonList; top.dialog.confirm(top.dataMessage.commit, function(index) { top.dialog.close(index); var loadLayerIndex; top.restAjax.put(top.restAjax.path('api/classplan/update/{classPlanId}', [classPlanId]), formData.field, null, function(code, data) { - var layerIndex = top.dialog.msg(top.dataMessage.updateSuccess, { + var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, { time: 0, btn: [top.dataMessage.button.yes, top.dataMessage.button.no], shade: 0.3, @@ -280,6 +457,10 @@ return false; }); + function closeBox() { + parent.layer.close(parent.layer.getFrameIndex(window.name)); + } + $('.close').on('click', function() { closeBox(); });