Merge remote-tracking branch 'origin/master'

master
hanbo 2021-11-25 13:58:33 +08:00
commit bef5ae36a1
7 changed files with 78 additions and 1 deletions

View File

@ -380,7 +380,9 @@ public class ProjectController extends BaseController {
//审核记录
List<ProjectTaskRecord> list = projectTaskRecordService.list(id);
model.put("taskRecords", list);
if (!list.isEmpty()) {
model.put("taskRecords", list);
}
return "admin/project_approve";
}
@ -483,6 +485,16 @@ public class ProjectController extends BaseController {
return ResponseMsg.buildSuccessMsg("成功");
}
/**
* 稿
*/
@GetMapping("/deleteProject/{id}")
@ResponseBody
public ResponseMsg deleteProject(@PathVariable int id) {
return projectService.deleteProject(id);
}
@InitBinder
public void initBinder(WebDataBinder webDataBinder) {
webDataBinder.addCustomFormatter(new DateFormatter("yyyy-MM-dd"));

View File

@ -6,4 +6,6 @@ import java.util.List;
public interface ProjectEstimateCostManageRepository extends JpaRepository<ProjectEstimateCostManage,Integer> {
List<ProjectEstimateCostManage> findAllByProjectIdEquals(int id);
int deleteByProjectId(int pId);
}

View File

@ -6,4 +6,6 @@ import java.util.List;
public interface ProjectEstimateCostRepository extends JpaRepository<ProjectEstimateCost,Integer> {
List<ProjectEstimateCost> findAllByProjectIdEquals(int id);
int deleteByProjectId(int pId);
}

View File

@ -6,4 +6,6 @@ import java.util.List;
public interface ProjectEstimateIncomeRepository extends JpaRepository<ProjectEstimateIncome,Integer> {
List<ProjectEstimateIncome> findAllByProjectIdEquals(int id);
int deleteByProjectId(int piId);
}

View File

@ -63,6 +63,15 @@ public class ProjectEstimateService {
costManage(project, estimateBean);
}
public void deleteEstimate(int projectId){
//删除收入记录
projectEstimateIncomeRepository.deleteByProjectId(projectId);
//删除成本记录
projectEstimateCostRepository.deleteByProjectId(projectId);
//删除管理记录
projectEstimateCostManageRepository.deleteByProjectId(projectId);
}
private void cost(Project project, EstimateBean estimateBean) {
ProjectEstimateCost projectEstimateCostDevice = new ProjectEstimateCost();
projectEstimateCostDevice.setProjectId(project.getId());

View File

@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import top.jfunc.common.db.QueryHelper;
import top.jfunc.common.db.bean.Page;
import top.jfunc.common.db.utils.Pagination;
@ -39,6 +40,8 @@ public class ProjectService {
private SysRoleRepository sysRoleRepository;
@Autowired
private AdminRepository adminRepository;
@Autowired
private ProjectEstimateService projectEstimateService;
private QueryHelper getQueryHelper(Map<String, String> searchInfo) {
@ -300,4 +303,23 @@ public class ProjectService {
}
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("删除成功");
}
}

View File

@ -216,6 +216,15 @@
</button>
</#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 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>