主题整合学期计划 修改月份后 子项数据无法变更 bug修复

This commit is contained in:
zhanglipeng 2021-09-03 23:53:40 +08:00
parent 9629c47c82
commit f88a929c20
2 changed files with 95 additions and 38 deletions

View File

@ -279,6 +279,8 @@ export default {
name: "Termplan", name: "Termplan",
data() { data() {
return { return {
smonth: null,
emonth: null,
// //
loading: true, loading: true,
// //
@ -444,6 +446,8 @@ export default {
time.push(response.data.startmonth); time.push(response.data.startmonth);
time.push(response.data.endmonth); time.push(response.data.endmonth);
this.form.startmonth = time; this.form.startmonth = time;
this.smonth = time[0];
this.emonth = time[1];
}); });
}, },
/** 提交按钮 */ /** 提交按钮 */
@ -451,9 +455,21 @@ export default {
this.$refs["form"].validate((valid) => { this.$refs["form"].validate((valid) => {
if (valid) { if (valid) {
const time = this.form.startmonth; const time = this.form.startmonth;
let timeArr = this.form.startmonth;
this.form.startmonth = time[0]; this.form.startmonth = time[0];
this.form.endmonth = time[1]; this.form.endmonth = time[1];
if (this.form.id != undefined) { if (this.form.id != undefined) {
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) => { updateTermplan(this.form).then((response) => {
if (response.code === 200) { if (response.code === 200) {
this.msgSuccess("修改成功"); this.msgSuccess("修改成功");
@ -461,6 +477,19 @@ export default {
this.getList(); 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 { } else {
addTermplan(this.form).then((response) => { addTermplan(this.form).then((response) => {
if (response.code === 200) { if (response.code === 200) {

View File

@ -100,8 +100,7 @@ public class ByThemeTermplanController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('benyi:themetermplan:query')") @PreAuthorize("@ss.hasPermi('benyi:themetermplan:query')")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id) public AjaxResult getInfo(@PathVariable("id") String id) {
{
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
ByThemeTermplan byThemeTermplan = byThemeTermplanService.selectByThemeTermplanById(id); ByThemeTermplan byThemeTermplan = byThemeTermplanService.selectByThemeTermplanById(id);
ajax.put(AjaxResult.DATA_TAG, byThemeTermplan); ajax.put(AjaxResult.DATA_TAG, byThemeTermplan);
@ -139,8 +138,6 @@ public class ByThemeTermplanController extends BaseController {
if (list != null && list.size() > 0) { if (list != null && list.size() > 0) {
return AjaxResult.error("当前学年学期计划已经存在,无法创建学期计划"); return AjaxResult.error("当前学年学期计划已经存在,无法创建学期计划");
} else { } else {
int iCount = schoolCommon.getDifMonth(byThemeTermplan.getStartmonth(), byThemeTermplan.getEndmonth());
System.out.println("月份差=" + iCount);
String uuid = schoolCommon.getUuid(); String uuid = schoolCommon.getUuid();
byThemeTermplan.setId(uuid); byThemeTermplan.setId(uuid);
byThemeTermplan.setSchoolid(SecurityUtils.getLoginUser().getUser().getDept().getDeptId()); byThemeTermplan.setSchoolid(SecurityUtils.getLoginUser().getUser().getDept().getDeptId());
@ -148,11 +145,25 @@ public class ByThemeTermplanController extends BaseController {
byThemeTermplan.setClassid(classId); byThemeTermplan.setClassid(classId);
byThemeTermplan.setName(byClassService.selectByClassById(classId).getBjmc() + "-主题整合学期计划"); byThemeTermplan.setName(byClassService.selectByClassById(classId).getBjmc() + "-主题整合学期计划");
addItem(byThemeTermplan);
return toAjax(byThemeTermplanService.insertByThemeTermplan(byThemeTermplan));
}
}
} else {
return AjaxResult.error("当前用户非幼儿园教师,无法创建计划");
}
}
public void addItem(ByThemeTermplan byThemeTermplan){
int iCount = schoolCommon.getDifMonth(byThemeTermplan.getStartmonth(), byThemeTermplan.getEndmonth());
System.out.println("月份差=" + iCount);
ByThemeTermplanitem byThemeTermplanitem = null; ByThemeTermplanitem byThemeTermplanitem = null;
for (int i = 0; i <= iCount; i++) { for (int i = 0; i <= iCount; i++) {
byThemeTermplanitem = new ByThemeTermplanitem(); byThemeTermplanitem = new ByThemeTermplanitem();
byThemeTermplanitem.setTpid(uuid); byThemeTermplanitem.setTpid(byThemeTermplan.getId());
byThemeTermplanitem.setCreateuserid(SecurityUtils.getLoginUser().getUser().getUserId()); byThemeTermplanitem.setCreateuserid(SecurityUtils.getLoginUser().getUser().getUserId());
// //月份加1 // //月份加1
// Calendar calendar = Calendar.getInstance(); // Calendar calendar = Calendar.getInstance();
@ -167,14 +178,6 @@ public class ByThemeTermplanController extends BaseController {
//新增每月计划 //新增每月计划
byThemeTermplanitemService.insertByThemeTermplanitem(byThemeTermplanitem); byThemeTermplanitemService.insertByThemeTermplanitem(byThemeTermplanitem);
} }
return toAjax(byThemeTermplanService.insertByThemeTermplan(byThemeTermplan));
}
}
} else {
return AjaxResult.error("当前用户非幼儿园教师,无法创建计划");
}
} }
/** /**
@ -184,6 +187,23 @@ public class ByThemeTermplanController extends BaseController {
@Log(title = "主题整合学期计划", businessType = BusinessType.UPDATE) @Log(title = "主题整合学期计划", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody ByThemeTermplan byThemeTermplan) { 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)); return toAjax(byThemeTermplanService.updateByThemeTermplan(byThemeTermplan));
} }
@ -196,16 +216,24 @@ public class ByThemeTermplanController extends BaseController {
public AjaxResult remove(@PathVariable String[] ids) { public AjaxResult remove(@PathVariable String[] ids) {
//首先判断当前id下是否存在子目录 //首先判断当前id下是否存在子目录
for (int i = 0; i < ids.length; i++) { for (int i = 0; i < ids.length; i++) {
ByThemeTermplanitem byThemeTermplanitem = new ByThemeTermplanitem(); delItem(ids[i]);
byThemeTermplanitem.setTpid(ids[i]);
List<ByThemeTermplanitem> list = byThemeTermplanitemService.selectByThemeTermplanitemList(byThemeTermplanitem);
if (list != null && list.size() > 0) {
return AjaxResult.error("选中的计划下存在子计划,无法删除");
}
} }
return toAjax(byThemeTermplanService.deleteByThemeTermplanByIds(ids)); return toAjax(byThemeTermplanService.deleteByThemeTermplanByIds(ids));
} }
//清除子项
public void delItem(String id){
ByThemeTermplanitem byThemeTermplanitem = new ByThemeTermplanitem();
byThemeTermplanitem.setTpid(id);
List<ByThemeTermplanitem> 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());
}
}
}
/** /**
* 提交主题整合学期计划 * 提交主题整合学期计划
*/ */