主题整合学期计划 修改月份后 子项数据无法变更 bug修复
This commit is contained in:
parent
9629c47c82
commit
f88a929c20
@ -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) {
|
||||
|
@ -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<ByThemeTermplan> 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<ByThemeTermplanitem> 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<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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交主题整合学期计划
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user