diff --git a/src/main/java/cn/palmte/work/controller/backend/ProcessController.java b/src/main/java/cn/palmte/work/controller/backend/ProcessController.java index 556dce4..b218cf9 100644 --- a/src/main/java/cn/palmte/work/controller/backend/ProcessController.java +++ b/src/main/java/cn/palmte/work/controller/backend/ProcessController.java @@ -1,14 +1,19 @@ package cn.palmte.work.controller.backend; +import org.springframework.jdbc.core.BatchPreparedStatementSetter; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; +import java.sql.PreparedStatement; +import java.sql.SQLException; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.Arrays; @@ -39,10 +44,13 @@ public class ProcessController { private final ProjectRepository projectRepository; private final ProjectBudgetService projectBudgetService; - public ProcessController(ProjectRepository projectRepository, DeptRepository deptRepository, ProjectBudgetService projectBudgetService) { + private final JdbcTemplate jdbcTemplate; + + public ProcessController(ProjectRepository projectRepository, DeptRepository deptRepository, ProjectBudgetService projectBudgetService, JdbcTemplate jdbcTemplate) { this.projectRepository = projectRepository; this.deptRepository = deptRepository; this.projectBudgetService = projectBudgetService; + this.jdbcTemplate = jdbcTemplate; } static class FormMetadata { @@ -191,7 +199,7 @@ public class ProcessController { @ResponseBody @PostMapping - public void post(SaleContractForm form) { + public void post(@RequestBody SaleContractForm form) { System.out.println(form); } @@ -216,9 +224,21 @@ public class ProcessController { @ResponseBody @PostMapping("/sale-contract-details") - public void saleContractDetails(SaleContractDetailForm form) { - + public void saleContractDetails(@RequestBody List form) { + jdbcTemplate.batchUpdate("update project_budget_income_detail set expiration_date =? where id =? ", + new BatchPreparedStatementSetter() { + @Override + public void setValues(PreparedStatement ps, int i) throws SQLException { + SaleContractDetailForm detailForm = form.get(i); + ps.setString(1, detailForm.expirationDate); + ps.setInt(2, detailForm.id); + } + @Override + public int getBatchSize() { + return form.size(); + } + }); } } diff --git a/src/main/java/cn/palmte/work/model/ProjectBudgetIncomeDetailBase.java b/src/main/java/cn/palmte/work/model/ProjectBudgetIncomeDetailBase.java index 5760faf..4b24d21 100644 --- a/src/main/java/cn/palmte/work/model/ProjectBudgetIncomeDetailBase.java +++ b/src/main/java/cn/palmte/work/model/ProjectBudgetIncomeDetailBase.java @@ -37,6 +37,10 @@ public class ProjectBudgetIncomeDetailBase { @Column(name = "tax_rate") private BigDecimal taxRate; + // 质保期 5 个字符 + @Column(name = "expiration_date") + public String expirationDate; + public Integer getId() { return id; } @@ -117,6 +121,14 @@ public class ProjectBudgetIncomeDetailBase { this.taxRate = taxRate; } + public String getExpirationDate() { + return expirationDate; + } + + public void setExpirationDate(String expirationDate) { + this.expirationDate = expirationDate; + } + public BigDecimal getTotalTaxInclude(){ if(null == price){ return null; diff --git a/src/main/resources/templates/admin/business/process-new.ftl b/src/main/resources/templates/admin/business/process-new.ftl index 122a687..fc360aa 100644 --- a/src/main/resources/templates/admin/business/process-new.ftl +++ b/src/main/resources/templates/admin/business/process-new.ftl @@ -28,6 +28,10 @@ .admin-content-body { margin-bottom: 100px; } + + .el-table__empty-block { + height: 60px !important; + }
@@ -227,21 +231,27 @@ <#-- 销售合同清单明细 -->
- - + + + - - + - - - + + + - + + + + @@ -592,8 +602,6 @@ ], fileList: [], saleContractDetails: [], - businessPurchaseDetails: [], - showBusinessPurchaseDetails: false, } } @@ -614,23 +622,36 @@ this.changeMode(saleContractProcess) }, goToSaleContractDetail() { - this.changeMode(saleContractDetail) - const loading = this.$loading({ - lock: true, - text: '正在加载项目', - spinner: 'el-icon-loading', - background: 'rgba(0, 0, 0, 0.7)' - }) + const { id } = this.processForm + if (id) { + this.changeMode(saleContractDetail) + const loading = this.$loading({ + lock: true, + text: '正在加载项目', + spinner: 'el-icon-loading', + background: 'rgba(0, 0, 0, 0.7)' + }) + fetch("${base}/process/sale-contract-details/" + id) + .then(res => res.json()) + .then(data => { + this.saleContractDetails = data + }) + .catch(err => { + this.$message.error("销售合同清单明细加载失败"); + }) + .finally(() => loading.close()) + } + else { + this.$message.warning("项目还未选择") + } + }, - fetch("${base}/process/sale-contract-details/" + this.processForm.id) - .then(res => res.json()) - .then(data => { - this.businessPurchaseDetails = data - }) - .catch(err => { - this.$message.error("销售合同清单明细加载失败"); - }) - .finally(() => loading.close()) + dbclick(row, event, column) { + row.input = !row.input + }, + + render(obj) { + console.log(obj) }, queryProject(q, callback) { @@ -654,7 +675,7 @@ }) }, handleSelectProject(selected) { - const {id, name} = selected + const { id, name } = selected if (!id) { this.processForm = {} return @@ -707,7 +728,11 @@ }, body: JSON.stringify(processForm), }).then(response => { - + this.$message({ + showClose: true, + message: '提交成功', + type: 'success' + }) }).catch(err => { this.$message.error("项目提交失败"); }).finally(() => loading.close()) @@ -726,21 +751,25 @@ background: 'rgba(0, 0, 0, 0.7)' }) - const processForm = this.processForm + const form = this.saleContractDetails.map(detail => ({ + id: detail.id, expirationDate: detail.expirationDate + })) fetch("${base}/process/sale-contract-details", { method: 'POST', // or 'PUT' headers: { 'Content-Type': 'application/json', }, - body: JSON.stringify(processForm), + body: JSON.stringify(form), }).then(response => { + this.$message({ + showClose: true, + message: '提交成功', + type: 'success' + }) this.goToSaleContractProcess() - }).catch(err => { this.$message.error("项目提交失败"); }).finally(() => loading.close()) - - }, handleRemove(file, fileList) { @@ -766,7 +795,7 @@ data, computed: { projectTitle() { - const {projectNo, name, applyPerson, applyDate} = this.processForm + const { projectNo, name, applyPerson, applyDate } = this.processForm if (projectNo && name) { return projectNo.trim() + "-" + name.trim() + "-" + applyPerson + "-" + applyDate } @@ -799,6 +828,23 @@ }, methods, + + mounted() { + fetch("${base}/process/projects/135") + .then(res => res.json()) + .then(data => { + this.processForm = { + sealType: [], + projectId: 135, + applyDate: new Date().toLocaleDateString(), + ...data + } + this.projectSelected = true + }) + .catch(err => { + this.$message.error("测试项目'加载失败"); + }) + }, })