diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/inspection/InspectionPlanController.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/inspection/InspectionPlanController.java index d9d8dbc..149c838 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/inspection/InspectionPlanController.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/inspection/InspectionPlanController.java @@ -119,4 +119,9 @@ public class InspectionPlanController { BeanUtils.toBean(list, InspectionPlanRespVO.class)); } + @GetMapping("/hasChild") + @Operation(summary = "是否有子节点") + public CommonResult hasInspectionPlan(@RequestParam("id") Long id) { + return success(inspectionPlanService.hasChildInspectionPlan(id)); + } } diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/inspection/InspectionPlanService.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/inspection/InspectionPlanService.java index 016c7a9..531cdf2 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/inspection/InspectionPlanService.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/inspection/InspectionPlanService.java @@ -77,4 +77,9 @@ public interface InspectionPlanService { * @return java.util.List */ List getInspectionPlanHaveFeedbackList(InspectionPlanListReqVO reqVO); + + /** + * 是否有子节点 + */ + Boolean hasChildInspectionPlan(Long id); } diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/inspection/InspectionPlanServiceImpl.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/inspection/InspectionPlanServiceImpl.java index 049dc69..30a1f0d 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/inspection/InspectionPlanServiceImpl.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/inspection/InspectionPlanServiceImpl.java @@ -127,4 +127,15 @@ public class InspectionPlanServiceImpl implements InspectionPlanService { } return inspectionPlanDOS; } + + @Override + /** + * 是否有子节点 + */ + public Boolean hasChildInspectionPlan(Long id){ + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.apply("find_in_set("+id+",ancestors)") + .eq("deleted",0); + return inspectionPlanMapper.selectCount(queryWrapper) > 0; + } } diff --git a/imt-ui/src/api/system/inspection/plan.js b/imt-ui/src/api/system/inspection/plan.js index 902aa49..81c92b9 100644 --- a/imt-ui/src/api/system/inspection/plan.js +++ b/imt-ui/src/api/system/inspection/plan.js @@ -77,3 +77,11 @@ export function getInspectionPlanListHaveFeedback(params) { params, }); } + +//是否有子节点 +export function hasInspectionPlanChild(id) { + return request({ + url: "/imt/inspection-plan/hasChild?id=" + id, + method: "get", + }); +} diff --git a/imt-ui/src/views/system/inspectionPlan/index.vue b/imt-ui/src/views/system/inspectionPlan/index.vue index 24c754f..c656f14 100644 --- a/imt-ui/src/views/system/inspectionPlan/index.vue +++ b/imt-ui/src/views/system/inspectionPlan/index.vue @@ -257,9 +257,19 @@ export default { '是否确认删除点检方案编号为"' + inspectionPlanId + '"的数据项?' ); try { - await InspectionPlanApi.deleteInspectionPlan(inspectionPlanId); - await this.getList(); - this.$modal.msgSuccess("删除成功"); + const hasChildRes = await InspectionPlanApi.hasInspectionPlanChild( + inspectionPlanId + ); + if (hasChildRes.data) { + this.$message({ + message: "该节点存在子节点,请先删除子节点!", + type: "warning", + }); + } else { + await InspectionPlanApi.deleteInspectionPlan(inspectionPlanId); + await this.getList(); + this.$modal.msgSuccess("删除成功"); + } } catch {} }, /** 导出按钮操作 */