概算草稿状态下增加删除按钮
parent
8fe0d90af6
commit
ca25b7e8e1
|
@ -470,6 +470,16 @@ public class ProjectController extends BaseController {
|
||||||
return ResponseMsg.buildSuccessMsg("成功");
|
return ResponseMsg.buildSuccessMsg("成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除草稿状态下的概算项目
|
||||||
|
*/
|
||||||
|
@GetMapping("/deleteProject/{id}")
|
||||||
|
@ResponseBody
|
||||||
|
public ResponseMsg deleteProject(@PathVariable int id) {
|
||||||
|
return projectService.deleteProject(id);
|
||||||
|
}
|
||||||
|
|
||||||
@InitBinder
|
@InitBinder
|
||||||
public void initBinder(WebDataBinder webDataBinder) {
|
public void initBinder(WebDataBinder webDataBinder) {
|
||||||
webDataBinder.addCustomFormatter(new DateFormatter("yyyy-MM-dd"));
|
webDataBinder.addCustomFormatter(new DateFormatter("yyyy-MM-dd"));
|
||||||
|
|
|
@ -6,4 +6,6 @@ import java.util.List;
|
||||||
|
|
||||||
public interface ProjectEstimateCostManageRepository extends JpaRepository<ProjectEstimateCostManage,Integer> {
|
public interface ProjectEstimateCostManageRepository extends JpaRepository<ProjectEstimateCostManage,Integer> {
|
||||||
List<ProjectEstimateCostManage> findAllByProjectIdEquals(int id);
|
List<ProjectEstimateCostManage> findAllByProjectIdEquals(int id);
|
||||||
|
|
||||||
|
int deleteByProjectId(int pId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,4 +6,6 @@ import java.util.List;
|
||||||
|
|
||||||
public interface ProjectEstimateCostRepository extends JpaRepository<ProjectEstimateCost,Integer> {
|
public interface ProjectEstimateCostRepository extends JpaRepository<ProjectEstimateCost,Integer> {
|
||||||
List<ProjectEstimateCost> findAllByProjectIdEquals(int id);
|
List<ProjectEstimateCost> findAllByProjectIdEquals(int id);
|
||||||
|
|
||||||
|
int deleteByProjectId(int pId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,4 +6,6 @@ import java.util.List;
|
||||||
|
|
||||||
public interface ProjectEstimateIncomeRepository extends JpaRepository<ProjectEstimateIncome,Integer> {
|
public interface ProjectEstimateIncomeRepository extends JpaRepository<ProjectEstimateIncome,Integer> {
|
||||||
List<ProjectEstimateIncome> findAllByProjectIdEquals(int id);
|
List<ProjectEstimateIncome> findAllByProjectIdEquals(int id);
|
||||||
|
|
||||||
|
int deleteByProjectId(int piId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,15 @@ public class ProjectEstimateService {
|
||||||
costManage(project, estimateBean);
|
costManage(project, estimateBean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteEstimate(int projectId){
|
||||||
|
//删除收入记录
|
||||||
|
projectEstimateIncomeRepository.deleteByProjectId(projectId);
|
||||||
|
//删除成本记录
|
||||||
|
projectEstimateCostRepository.deleteByProjectId(projectId);
|
||||||
|
//删除管理记录
|
||||||
|
projectEstimateCostManageRepository.deleteByProjectId(projectId);
|
||||||
|
}
|
||||||
|
|
||||||
private void cost(Project project, EstimateBean estimateBean) {
|
private void cost(Project project, EstimateBean estimateBean) {
|
||||||
ProjectEstimateCost projectEstimateCostDevice = new ProjectEstimateCost();
|
ProjectEstimateCost projectEstimateCostDevice = new ProjectEstimateCost();
|
||||||
projectEstimateCostDevice.setProjectId(project.getId());
|
projectEstimateCostDevice.setProjectId(project.getId());
|
||||||
|
|
|
@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import top.jfunc.common.db.QueryHelper;
|
import top.jfunc.common.db.QueryHelper;
|
||||||
import top.jfunc.common.db.bean.Page;
|
import top.jfunc.common.db.bean.Page;
|
||||||
import top.jfunc.common.db.utils.Pagination;
|
import top.jfunc.common.db.utils.Pagination;
|
||||||
|
@ -39,6 +40,8 @@ public class ProjectService {
|
||||||
private SysRoleRepository sysRoleRepository;
|
private SysRoleRepository sysRoleRepository;
|
||||||
@Autowired
|
@Autowired
|
||||||
private AdminRepository adminRepository;
|
private AdminRepository adminRepository;
|
||||||
|
@Autowired
|
||||||
|
private ProjectEstimateService projectEstimateService;
|
||||||
|
|
||||||
|
|
||||||
private QueryHelper getQueryHelper(Map<String, String> searchInfo) {
|
private QueryHelper getQueryHelper(Map<String, String> searchInfo) {
|
||||||
|
@ -300,4 +303,23 @@ public class ProjectService {
|
||||||
}
|
}
|
||||||
projectVisibleRepository.save(pvs);
|
projectVisibleRepository.save(pvs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public ResponseMsg deleteProject(int id) {
|
||||||
|
Project one = projectRepository.findOne(id);
|
||||||
|
if (one == null) {
|
||||||
|
return ResponseMsg.buildFailedMsg("项目不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (one.getStatus() != StatusEnum.ESTIMATE_ACCOUNTS.getStatus()
|
||||||
|
|| one.getApproveStatusEstimate() != ApproveStatusEnum.APPROVAL_UNCOMMIT.getApproveStatus()) {
|
||||||
|
return ResponseMsg.buildFailedMsg("项目当前状态下不能删除");
|
||||||
|
}
|
||||||
|
|
||||||
|
projectRepository.delete(id);
|
||||||
|
|
||||||
|
projectEstimateService.deleteEstimate(id);
|
||||||
|
|
||||||
|
return ResponseMsg.buildSuccessMsg("删除成功");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,6 +216,15 @@
|
||||||
</button>
|
</button>
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
|
<#-- 项目等于概算状态、概算审核为草稿状态-->
|
||||||
|
<#if list.creatorId==adminId && list.status==1 && list.approveStatusEstimate==0>
|
||||||
|
<button type="button"
|
||||||
|
class="am-btn am-btn-default am-btn-xs am-text-secondary"
|
||||||
|
onclick="deleteProject('${list.id}')"><span
|
||||||
|
class="am-icon-pencil-square-o"></span>删除
|
||||||
|
</button>
|
||||||
|
</#if>
|
||||||
|
|
||||||
<#-- </@shiro.hasPermission>
|
<#-- </@shiro.hasPermission>
|
||||||
<@shiro.hasPermission name="PROJECT_EDIT">-->
|
<@shiro.hasPermission name="PROJECT_EDIT">-->
|
||||||
<#-- 概算审核等于通过状态、预算审核不等于待审核状态、 决算审核不等于通过状态-->
|
<#-- 概算审核等于通过状态、预算审核不等于待审核状态、 决算审核不等于通过状态-->
|
||||||
|
@ -401,4 +410,23 @@
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var deleteProject = function (id) {
|
||||||
|
if (window.confirm('确定要删除此项目吗?')) {
|
||||||
|
$.ajax({
|
||||||
|
url: '${base}/project/deleteProject/' + id,
|
||||||
|
dataType: "json",
|
||||||
|
async: false,
|
||||||
|
success: function (data) {
|
||||||
|
if (data.status == 0) {
|
||||||
|
alert(data.msg);
|
||||||
|
window.location.href = window.location.href;
|
||||||
|
} else if (data.status == 1) {
|
||||||
|
alert(data.msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue