From f88a929c208b29a771ffa6670cc6d61e6a536d39 Mon Sep 17 00:00:00 2001 From: zhanglipeng Date: Fri, 3 Sep 2021 23:53:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E9=A2=98=E6=95=B4=E5=90=88=E5=AD=A6?= =?UTF-8?q?=E6=9C=9F=E8=AE=A1=E5=88=92=20=E4=BF=AE=E6=94=B9=E6=9C=88?= =?UTF-8?q?=E4=BB=BD=E5=90=8E=20=E5=AD=90=E9=A1=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=8F=98=E6=9B=B4=20bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/benyi/themetermplan/index.vue | 43 +++++++-- .../controller/ByThemeTermplanController.java | 90 ++++++++++++------- 2 files changed, 95 insertions(+), 38 deletions(-) diff --git a/ruoyi-ui/src/views/benyi/themetermplan/index.vue b/ruoyi-ui/src/views/benyi/themetermplan/index.vue index 985d057ec..9c14ac26f 100644 --- a/ruoyi-ui/src/views/benyi/themetermplan/index.vue +++ b/ruoyi-ui/src/views/benyi/themetermplan/index.vue @@ -279,6 +279,8 @@ export default { name: "Termplan", data() { return { + smonth: null, + emonth: null, // 遮罩层 loading: true, // 选中数组 @@ -444,6 +446,8 @@ export default { time.push(response.data.startmonth); time.push(response.data.endmonth); this.form.startmonth = time; + this.smonth = time[0]; + this.emonth = time[1]; }); }, /** 提交按钮 */ @@ -451,16 +455,41 @@ export default { this.$refs["form"].validate((valid) => { if (valid) { const time = this.form.startmonth; + let timeArr = this.form.startmonth; this.form.startmonth = time[0]; this.form.endmonth = time[1]; if (this.form.id != undefined) { - updateTermplan(this.form).then((response) => { - if (response.code === 200) { - this.msgSuccess("修改成功"); - this.open = false; - this.getList(); - } - }); + if ( + this.smonth != this.form.startmonth || + this.emonth != this.form.endmonth + ) { + this.$confirm("如果修改月份,设置的月份主题会被清空?", "警告", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning", + }) + .then(() => { + //console.log(this.form.startmonth); + updateTermplan(this.form).then((response) => { + if (response.code === 200) { + this.msgSuccess("修改成功"); + this.open = false; + this.getList(); + } + }); + }) + .catch((_) => { + this.form.startmonth = timeArr; + }); + } else { + updateTermplan(this.form).then((response) => { + if (response.code === 200) { + this.msgSuccess("修改成功"); + this.open = false; + this.getList(); + } + }); + } } else { addTermplan(this.form).then((response) => { if (response.code === 200) { diff --git a/ruoyi/src/main/java/com/ruoyi/project/benyi/controller/ByThemeTermplanController.java b/ruoyi/src/main/java/com/ruoyi/project/benyi/controller/ByThemeTermplanController.java index e43e3f7b4..69cbba755 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/benyi/controller/ByThemeTermplanController.java +++ b/ruoyi/src/main/java/com/ruoyi/project/benyi/controller/ByThemeTermplanController.java @@ -100,8 +100,7 @@ public class ByThemeTermplanController extends BaseController { */ @PreAuthorize("@ss.hasPermi('benyi:themetermplan:query')") @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") String id) - { + public AjaxResult getInfo(@PathVariable("id") String id) { AjaxResult ajax = AjaxResult.success(); ByThemeTermplan byThemeTermplan = byThemeTermplanService.selectByThemeTermplanById(id); ajax.put(AjaxResult.DATA_TAG, byThemeTermplan); @@ -124,7 +123,7 @@ public class ByThemeTermplanController extends BaseController { String bjtypeNew = byClassService.selectByClassById(classId).getBjtype(); if (bjtypeNew.equals("1")) { return AjaxResult.error("当前班级为托班,无法创建计划"); - }else { + } else { ByThemeTermplan mybyThemeTermplan = new ByThemeTermplan(); String xnxqNew = null; List list = null; @@ -138,9 +137,7 @@ public class ByThemeTermplanController extends BaseController { // 判断是否存在当前学期计划 if (list != null && list.size() > 0) { return AjaxResult.error("当前学年学期计划已经存在,无法创建学期计划"); - }else { - int iCount = schoolCommon.getDifMonth(byThemeTermplan.getStartmonth(), byThemeTermplan.getEndmonth()); - System.out.println("月份差=" + iCount); + } else { String uuid = schoolCommon.getUuid(); byThemeTermplan.setId(uuid); byThemeTermplan.setSchoolid(SecurityUtils.getLoginUser().getUser().getDept().getDeptId()); @@ -148,25 +145,7 @@ public class ByThemeTermplanController extends BaseController { byThemeTermplan.setClassid(classId); byThemeTermplan.setName(byClassService.selectByClassById(classId).getBjmc() + "-主题整合学期计划"); - - ByThemeTermplanitem byThemeTermplanitem = null; - for (int i = 0; i <= iCount; i++) { - byThemeTermplanitem = new ByThemeTermplanitem(); - byThemeTermplanitem.setTpid(uuid); - byThemeTermplanitem.setCreateuserid(SecurityUtils.getLoginUser().getUser().getUserId()); -// //月份加1 -// Calendar calendar = Calendar.getInstance(); -// calendar.setTime(byThemeTermplan.getStartmonth()); -// calendar.add(Calendar.MONTH, i); - - byThemeTermplanitem.setMonth(schoolCommon.DateAddMonths(i, byThemeTermplan.getStartmonth())); - - //创建时间 - byThemeTermplanitem.setCreateTime(new Date()); - - //新增每月计划 - byThemeTermplanitemService.insertByThemeTermplanitem(byThemeTermplanitem); - } + addItem(byThemeTermplan); return toAjax(byThemeTermplanService.insertByThemeTermplan(byThemeTermplan)); } @@ -177,6 +156,30 @@ public class ByThemeTermplanController extends BaseController { } + public void addItem(ByThemeTermplan byThemeTermplan){ + int iCount = schoolCommon.getDifMonth(byThemeTermplan.getStartmonth(), byThemeTermplan.getEndmonth()); + System.out.println("月份差=" + iCount); + + ByThemeTermplanitem byThemeTermplanitem = null; + for (int i = 0; i <= iCount; i++) { + byThemeTermplanitem = new ByThemeTermplanitem(); + byThemeTermplanitem.setTpid(byThemeTermplan.getId()); + byThemeTermplanitem.setCreateuserid(SecurityUtils.getLoginUser().getUser().getUserId()); +// //月份加1 +// Calendar calendar = Calendar.getInstance(); +// calendar.setTime(byThemeTermplan.getStartmonth()); +// calendar.add(Calendar.MONTH, i); + + byThemeTermplanitem.setMonth(schoolCommon.DateAddMonths(i, byThemeTermplan.getStartmonth())); + + //创建时间 + byThemeTermplanitem.setCreateTime(new Date()); + + //新增每月计划 + byThemeTermplanitemService.insertByThemeTermplanitem(byThemeTermplanitem); + } + } + /** * 修改主题整合学期计划 */ @@ -184,6 +187,23 @@ public class ByThemeTermplanController extends BaseController { @Log(title = "主题整合学期计划", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody ByThemeTermplan byThemeTermplan) { + //如果修改月份的话,应该新增或删除子项目 + //判断起止时间是否有变化 + ByThemeTermplan byThemeTermplanNew = byThemeTermplanService.selectByThemeTermplanById(byThemeTermplan.getId()); + System.out.println(byThemeTermplan.getId()); + System.out.println(byThemeTermplanNew.getId()); + System.out.println(byThemeTermplan.getStartmonth()); + System.out.println(byThemeTermplan.getEndmonth()); + System.out.println(byThemeTermplanNew.getStartmonth()); + System.out.println(byThemeTermplanNew.getEndmonth()); + if(byThemeTermplanNew.getStartmonth().equals(byThemeTermplan.getStartmonth())&&byThemeTermplanNew.getEndmonth().equals(byThemeTermplan.getEndmonth())){ + System.out.println("equals"); + }else{ + //清空 + delItem(byThemeTermplanNew.getId()); + //新增 + addItem(byThemeTermplan); + } return toAjax(byThemeTermplanService.updateByThemeTermplan(byThemeTermplan)); } @@ -196,16 +216,24 @@ public class ByThemeTermplanController extends BaseController { public AjaxResult remove(@PathVariable String[] ids) { //首先判断当前id下是否存在子目录 for (int i = 0; i < ids.length; i++) { - ByThemeTermplanitem byThemeTermplanitem = new ByThemeTermplanitem(); - byThemeTermplanitem.setTpid(ids[i]); - List list = byThemeTermplanitemService.selectByThemeTermplanitemList(byThemeTermplanitem); - if (list != null && list.size() > 0) { - return AjaxResult.error("选中的计划下存在子计划,无法删除"); - } + delItem(ids[i]); } return toAjax(byThemeTermplanService.deleteByThemeTermplanByIds(ids)); } + //清除子项 + public void delItem(String id){ + ByThemeTermplanitem byThemeTermplanitem = new ByThemeTermplanitem(); + byThemeTermplanitem.setTpid(id); + List list = byThemeTermplanitemService.selectByThemeTermplanitemList(byThemeTermplanitem); + if (list != null && list.size() > 0) { + //return AjaxResult.error("选中的计划下存在子计划,无法删除"); + for (int j = 0; j < list.size(); j++) { + byThemeTermplanitemService.deleteByThemeTermplanitemById(list.get(j).getId()); + } + } + } + /** * 提交主题整合学期计划 */