guoxu hace 2 años
padre
commit
d22e3c5e8d

+ 36 - 12
src/main/java/com/jeeplus/modules/ruralprojectrecords/web/RuralProjectRecordsController.java

@@ -507,16 +507,22 @@ public class RuralProjectRecordsController extends BaseController {
 	 * 删除项目
 	 */
 	@RequestMapping(value = "adminDelete")
-	public String adminDelete(RuralProjectRecords projectRecords, RedirectAttributes redirectAttributes) {
+	@ResponseBody
+	public Map adminDelete(RuralProjectRecords projectRecords, RedirectAttributes redirectAttributes) {
 		int status = projectRecords.getProjectStatus();
+		Map map = new HashMap();
 		if(status== ProjectStatusEnum.SIGNED.getValue()){
 			projectRecordsService.adminDelete(projectRecords);
 			addMessage(redirectAttributes, "管理员删除项目成功");
-			return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecords/?repage";
+//			return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecords/?repage";
+			map.put("success","删除成功");
+			return map;
 		}else {
 			addMessage(redirectAttributes, "管理员删除项目失败");
+			map.put("failure","删除失败");
 		}
-		return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecords/?repage";
+//		return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecords/?repage";
+		return map;
 	}
 
 	/**
@@ -1238,15 +1244,33 @@ public class RuralProjectRecordsController extends BaseController {
 		}
 	}
 
-//	/**
-//	 * 查询项目名称是否重复
-//	 */
-//	@RequestMapping(value = "reProjectName")
-//	@ResponseBody
-//	public Integer reProjectName(String projectName){
-//		Integer count = projectRecordsService.reProjectName(projectName);
-//		return count;
-//	}
+	/**
+	 * 查询项目的数量
+	 */
+	@RequestMapping(value = "queryProjectIsUse")
+	@ResponseBody
+	public Map queryProjectIsUse(RuralProjectRecords projectRecords, RedirectAttributes redirectAttributes) {
+		int status = projectRecords.getProjectStatus();
+		//判断该项目是否在发票或者报销中被引用,如果被引用则不允许作废
+		//查询报告中调用的次数(若被调用的发票也被作废 则可进行作废)
+		Map map = new HashMap();
+		Integer cancellationRelationCount = workInvoiceService.getProjectRelationListByProjectId(projectRecords.getId());
+		//查询报销中调用的次数(若被调用的报销被作废,则可进行作废)
+		Integer cancellationReimbursementCount = workReimbursementService.getWorkAccountByProjectId(projectRecords.getId());
+		if (cancellationRelationCount > 0 || cancellationReimbursementCount > 0) {
+			addMessage(redirectAttributes, "项目在开票或报销中已被使用,无法删除");
+			map.put("success", false);
+			map.put("message", "项目在开票或报销中已被使用,无法删除");
+			if ("1".equals(projectRecords.getProjectType())) {
+//				return "redirect:" + Global.getAdminPath() + "/ruralProject/ruralProjectRecords/?repage";
+			}
+//			return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralCostProjectRecords/?repage";
+			return map;
+		}
+		map.put("success", true);
+		map.put("message", "项目在开票或报销中未被使用,可以删除");
+		return map;
+	}
 
 
 }

+ 74 - 1
src/main/webapp/webpage/modules/ruralprojectrecords/cost/ruralCostProjectRecordsList.jsp

@@ -188,6 +188,77 @@
                 }
             });
         }
+		function adminDelete(title,url,width,height,target,id) {
+			if (navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)) {//如果是移动端,就使用自适应大小弹窗
+				width = 'auto';
+				height = 'auto';
+			} else {//如果是PC端,根据用户设置的width和height显示。
+
+			}
+
+			top.layer.open({
+				type: 0,
+				title: title,
+				content: '确定删除这个项目',
+				btn:["确定","取消"],
+				btn1: function (index){
+					layer.close(index);
+					$.ajax({
+						async: false,
+						url: url,
+						dataType: "json",
+						success: function (data) {
+							if(data.success){
+								$.ajax({
+									async: false,
+									url: "${ctx}/ruralProject/ruralProjectRecords/adminDelete?id="+id,
+									dataType: "json",
+									success: function (data) {
+										if(data.success){
+											// top.layer.msg("该项目信息已成功删除!", {icon: 0});
+											top.layer.msg("该项目报告信息删除成功!", {icon: 0});
+											window.location.reload();
+										}else{
+											top.layer.msg("该项目报告信息删除失败!", {icon: 0});
+										}
+									}
+								});
+								// top.layer.msg("该项目信息已成功删除!", {icon: 0});
+							}else{
+								top.layer.open({
+									type:0,
+									title: "删除",
+									content: '该项目已被开票或报销使用,确定删除这个项目',
+									btn:["确定","取消"],
+									btn1: function(index){
+										$.ajax({
+											async: false,
+											url: "${ctx}/ruralProject/ruralProjectRecords/adminDelete?id="+id,
+											dataType: "json",
+											success: function (result){
+												if(result.success){
+													top.layer.msg("该项目报告信息删除成功!", {icon: 0});
+													window.location.reload();
+												}else{
+													top.layer.msg("该项目报告信息删除失败!", {icon: 0});
+												}
+											}
+										})
+									},
+									btn2:function (indexTwo) {
+										layer.close(index);
+									}
+								})
+							}
+						}
+					});
+				},
+				btn2:function (index) {
+					layer.close(index);
+
+				}
+			});
+		}
 	</script>
 	<style>
 		body{
@@ -627,7 +698,9 @@
 						if(d.deleteAdmin != undefined && d.deleteAdmin =="1")
 						{
 							xml+="<a href=\"#\" onclick=\"openDialogre('修改项目', '${ctx}/ruralProject/ruralCostProjectRecords/adminModify?id=" + d.id + "','95%', '95%','','提交,关闭')\" class=\"layui-btn layui-btn-xs layui-bg-green\" > 修改</a>";
-							xml+="<a href=\"${ctx}/ruralProject/ruralCostProjectRecords/adminDelete?id=" + d.id + "\" onclick=\"return confirmx('确认要删除该项目信息吗?', this.href)\" class=\"layui-btn layui-btn-xs layui-bg-red\"> 删除</a>";
+							<%--xml+="<a href=\"${ctx}/ruralProject/ruralCostProjectRecords/adminDelete?id=" + d.id + "\" onclick=\"return confirmx('确认要删除该项目信息吗?', this.href)\" class=\"layui-btn layui-btn-xs layui-bg-red\"> 删除</a>";--%>
+							xml+="<a href=\"#\" onclick=\"adminDelete('管理员删除', '${ctx}/ruralProject/ruralProjectRecords/queryProjectIsUse?id=" + d.id +"','95%', '95%','','"+ d.id + "')\" class=\"layui-btn layui-btn-xs layui-bg-green\" > 删除</a>";
+
 						}
 						if(d.modifyRecords != undefined && d.modifyRecords =="1")
 						{

+ 2 - 1
src/main/webapp/webpage/modules/ruralprojectrecords/ruralProjectRecordsList.jsp

@@ -207,6 +207,7 @@
                 }
             });
         }
+
 	</script>
 	<style>
 		body{
@@ -564,7 +565,7 @@
                         {
 							xml+="<a href=\"#\" onclick=\"openDialogre('修改项目', '${ctx}/ruralProject/ruralProjectRecords/adminModify?id=" + d.id + "','95%', '95%','','提交,关闭')\" class=\"layui-btn layui-btn-xs  layui-bg-green\" > 修改</a>";
 							xml+="<a href=\"${ctx}/ruralProject/ruralProjectRecords/adminDelete?id=" + d.id + "\" onclick=\"return confirmx('确认要删除该项目信息吗?', this.href)\" class=\"layui-btn layui-btn-xs layui-bg-red\"> 删除</a>";
-                        }
+							 }
 						if(d.modifyRecords != undefined && d.modifyRecords =="1")
 						{
 							xml+="<a href=\"#\" onclick=\"openDialogre('修改项目', '${ctx}/ruralProject/ruralProjectRecords/form?id=" + d.id +"','95%', '95%','','提交,关闭')\" class=\"layui-btn layui-btn-xs layui-bg-green\" > 修改</a>";