From 00a2b870bd3c25b6d51f9c7c2674da59d4b1f81e Mon Sep 17 00:00:00 2001 From: xxssyyyyssxx <xxssyyyyssxx@126.com> Date: Thu, 4 Nov 2021 10:32:16 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=AE=A1=E7=90=86=E6=98=8E?= =?UTF-8?q?=E7=BB=86=E9=BB=98=E8=AE=A4=E5=BF=85=E6=9C=89=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectBudgetCostProjectManageDetail.java | 13 ++++++++ .../work/service/ProjectBudgetService.java | 30 ++++++++++++++++++- src/main/resources/application.properties | 5 +++- .../static/assets/js/project_budget_cost.js | 2 +- .../js/project_budget_cost_project_manage.js | 5 ++-- .../static/assets/js/project_budget_income.js | 2 +- .../templates/admin/project_budget_edit.ftl | 18 ++++++----- .../templates/admin/project_estimate_add.ftl | 2 +- 8 files changed, 62 insertions(+), 15 deletions(-) diff --git a/src/main/java/cn/palmte/work/model/ProjectBudgetCostProjectManageDetail.java b/src/main/java/cn/palmte/work/model/ProjectBudgetCostProjectManageDetail.java index 6a265ab..6a76667 100644 --- a/src/main/java/cn/palmte/work/model/ProjectBudgetCostProjectManageDetail.java +++ b/src/main/java/cn/palmte/work/model/ProjectBudgetCostProjectManageDetail.java @@ -41,6 +41,11 @@ public class ProjectBudgetCostProjectManageDetail { private String predictWhy; private String remark; + /** + * 是否可以被删除,有些项是默认的不可删除,用于页面判断是否显示删除按钮 + */ + private int deletable; + public Integer getId() { return id; } @@ -135,4 +140,12 @@ public class ProjectBudgetCostProjectManageDetail { } return price.multiply(new BigDecimal(amount)); } + + public int getDeletable() { + return deletable; + } + + public void setDeletable(int deletable) { + this.deletable = deletable; + } } \ No newline at end of file diff --git a/src/main/java/cn/palmte/work/service/ProjectBudgetService.java b/src/main/java/cn/palmte/work/service/ProjectBudgetService.java index c0edc64..56dcf7c 100644 --- a/src/main/java/cn/palmte/work/service/ProjectBudgetService.java +++ b/src/main/java/cn/palmte/work/service/ProjectBudgetService.java @@ -3,9 +3,12 @@ package cn.palmte.work.service; import cn.palmte.work.bean.BudgetBean; import cn.palmte.work.model.*; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import top.jfunc.common.utils.CollectionUtil; +import java.math.BigDecimal; +import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -28,6 +31,8 @@ public class ProjectBudgetService { @Autowired private ProjectBudgetCostProjectManageDetailRepository projectBudgetCostProjectManageDetailRepository; + @Value("#{'${fourcal.fixedprojectmanagedetails}'.split('\\|')}") + private String[] fixedProjectManageDetails; public void clearBudget(Project project){ List<ProjectBudgetIncome> incomes = projectBudgetIncomeRepository.findAllByProjectIdEquals(project.getId()); @@ -283,6 +288,29 @@ public class ProjectBudgetService { } } public List<ProjectBudgetCostProjectManageDetail> getBudgetCostProjectManageDetail(Project project){ - return projectBudgetCostProjectManageDetailRepository.findAllByProjectIdEquals(project.getId()); + List<ProjectBudgetCostProjectManageDetail> projectManageDetails = projectBudgetCostProjectManageDetailRepository.findAllByProjectIdEquals(project.getId()); + + if(CollectionUtil.isNotEmpty(projectManageDetails)){ + return projectManageDetails; + }else { + //默认必填的明细 + return getFixedNotDeletable(); + } + } + + private List<ProjectBudgetCostProjectManageDetail> getFixedNotDeletable() { + List<ProjectBudgetCostProjectManageDetail> projectManageDetails = new ArrayList<>(6); + for (String fixedProjectManageDetail : fixedProjectManageDetails) { + String[] split = fixedProjectManageDetail.split(","); + ProjectBudgetCostProjectManageDetail detail = new ProjectBudgetCostProjectManageDetail(); + detail.setType(Integer.parseInt(split[0])); + detail.setName(split[1]); + detail.setPrice(new BigDecimal(0)); + detail.setAmount(0); + detail.setDeletable(0); + projectManageDetails.add(detail); + } + + return projectManageDetails; } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 604d429..c36438a 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -46,4 +46,7 @@ fourcal.excluded.pc.urls= fourcal.log.excluded.urls= -fourcal.slideInterval=1800000 \ No newline at end of file +fourcal.slideInterval=1800000 + + +fourcal.fixedprojectmanagedetails=1,\u4EBA\u5DE5\u8D39|1,\u603B\u90E8\u652F\u6491\u4EBA\u529B\u8D39\u7528|2,\u4EBA\u5458\u5DEE\u65C5\u8D39|2,\u4E1A\u52A1\u8D39\u7528|2,\u5546\u52A1\u53CA\u4E13\u9879\u9A8C\u6536\u8D39\u7528|2,\u529E\u516C\u8D39\u7528 \ No newline at end of file diff --git a/src/main/resources/static/assets/js/project_budget_cost.js b/src/main/resources/static/assets/js/project_budget_cost.js index 09f2f2e..25ca5b2 100644 --- a/src/main/resources/static/assets/js/project_budget_cost.js +++ b/src/main/resources/static/assets/js/project_budget_cost.js @@ -50,7 +50,7 @@ function appendTrCost() { '<td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost input-changeable-tax-rate"></td>'+ '<td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost input-changeable-total-tax-include" readonly></td>'+ '<td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost input-changeable-total-tax-exclude" readonly></td>'+ - '<td><button type="button" class="am-btn am-btn-warning am-btn-xs am-modal-line-delete"><span class="am-icon-minus"></span></button></td>'+ + '<td><button type="button" class="am-btn am-btn-warning am-btn-xs am-round am-modal-line-delete"><span class="am-icon-minus"></span></button></td>'+ '</tr>'; $("#costTable").append(template); //重新绑定删除事件和input修改事件 diff --git a/src/main/resources/static/assets/js/project_budget_cost_project_manage.js b/src/main/resources/static/assets/js/project_budget_cost_project_manage.js index 5516912..dee45ce 100644 --- a/src/main/resources/static/assets/js/project_budget_cost_project_manage.js +++ b/src/main/resources/static/assets/js/project_budget_cost_project_manage.js @@ -1,7 +1,7 @@ /** * 一个采购成本详情的字段 */ -COST_PROJECT_MANAGE_DETAIL_ARR=["type","name","detail","unit","amount","price","total","predictMethod","predictWhy","remark"]; +COST_PROJECT_MANAGE_DETAIL_ARR=["type","name","detail","unit","amount","price","total","predictMethod","predictWhy","remark","deletable"]; $(function () { $("#cost-project-manage-detail").click(function () { $('#my-prompt-cost-project-manage-detail').modal({ @@ -41,7 +41,8 @@ function appendTrCostProjectManage() { ' <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost-project-manage"></td>\n' + ' <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost-project-manage"></td>\n' + ' <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost-project-manage"></td>\n' + - ' <td><button type="button" class="am-btn am-btn-warning am-btn-xs am-modal-line-delete"><span class="am-icon-minus"></span></button></td>\n' + + ' <td><button type="button" class="am-btn am-btn-warning am-btn-xs am-round am-modal-line-delete"><span class="am-icon-minus"></span></button>' + + ' <input type="hidden" class="am-modal-prompt-input am-modal-prompt-input-cost-project-manage" value="1"></td>\n' + ' </tr>'; $("#costProjectManageTable").append(template); //重新绑定删除事件和input修改事件 diff --git a/src/main/resources/static/assets/js/project_budget_income.js b/src/main/resources/static/assets/js/project_budget_income.js index 64c850f..7185245 100644 --- a/src/main/resources/static/assets/js/project_budget_income.js +++ b/src/main/resources/static/assets/js/project_budget_income.js @@ -81,7 +81,7 @@ function appendTrIncome() { ' <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-income input-changeable-tax-rate"></td>\n' + ' <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-income input-changeable-total-tax-include" readonly></td>\n' + ' <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-income input-changeable-total-tax-exclude" readonly></td>\n' + - ' <td><button type="button" class="am-btn am-btn-warning am-btn-xs am-modal-line-delete"><span class="am-icon-minus"></span></button></td>\n' + + ' <td><button type="button" class="am-btn am-btn-warning am-btn-xs am-round am-modal-line-delete"><span class="am-icon-minus"></span></button></td>\n' + ' </tr>'; $("#incomeTable").append(template); //重新绑定删除事件和input修改事件 diff --git a/src/main/resources/templates/admin/project_budget_edit.ftl b/src/main/resources/templates/admin/project_budget_edit.ftl index d5b23fc..86c7105 100644 --- a/src/main/resources/templates/admin/project_budget_edit.ftl +++ b/src/main/resources/templates/admin/project_budget_edit.ftl @@ -442,14 +442,14 @@ <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-income input-changeable-tax-rate" value="${incomeDetail.taxRate!}"></td> <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-income input-changeable-total-tax-include" value="${incomeDetail.totalTaxInclude!}" readonly></td> <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-income input-changeable-total-tax-exclude" value="${incomeDetail.totalTaxExclude!}" readonly></td> - <td><button type="button" class="am-btn am-btn-warning am-btn-xs am-modal-line-delete"><span class="am-icon-minus"></span></button></td> + <td><button type="button" class="am-btn am-btn-warning am-btn-xs am-round am-modal-line-delete"><span class="am-icon-minus"></span></button></td> </tr> </#list> </#if> </tbody> </table> - <button type="button" id="incomeAddBtn" class="am-btn am-btn-primary am-btn-xs"><span class="am-icon-plus"></span></button> + <button type="button" id="incomeAddBtn" class="am-btn am-btn-primary am-btn-xs am-round"><span class="am-icon-plus"></span></button> </div> <div class="am-modal-footer"> <span class="am-modal-btn" data-am-modal-cancel>取消</span> @@ -507,14 +507,14 @@ <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost input-changeable-tax-rate" value="${costDetail.taxRate!}"></td> <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost input-changeable-total-tax-include" value="${costDetail.totalTaxInclude!}" readonly></td> <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost input-changeable-total-tax-exclude" value="${costDetail.totalTaxExclude!}" readonly></td> - <td><button type="button" class="am-btn am-btn-warning am-btn-xs am-modal-line-delete"><span class="am-icon-minus"></span></button></td> + <td><button type="button" class="am-btn am-btn-warning am-btn-xs am-round am-modal-line-delete"><span class="am-icon-minus"></span></button></td> </tr> </#list> </#if> </tbody> </table> - <button type="button" id="costAddBtn" class="am-btn am-btn-primary am-btn-xs"><span class="am-icon-plus"></span></button> + <button type="button" id="costAddBtn" class="am-btn am-btn-primary am-btn-xs am-round"><span class="am-icon-plus"></span></button> </div> <div class="am-modal-footer"> <span class="am-modal-btn" data-am-modal-cancel>取消</span> @@ -547,13 +547,13 @@ <#list costProjectManageDetails as costProjectManageDetail> <tr> <td> - <select style="width: auto" class="am-modal-prompt-input am-modal-prompt-input-cost-project-manage"> + <select style="width: auto" class="am-modal-prompt-input am-modal-prompt-input-cost-project-manage" <#if costProjectManageDetail.deletable==0>readonly</#if>> <option value="1" <#if costProjectManageDetail.type == 1>selected</#if>>人工成本</option> <option value="2" <#if costProjectManageDetail.type == 2>selected</#if>>业务费用</option> <option value="3" <#if costProjectManageDetail.type == 3>selected</#if>>其他费用</option> </select> </td> - <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost-project-manage" value="${costProjectManageDetail.name!}"></td> + <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost-project-manage" value="${costProjectManageDetail.name!}" <#if costProjectManageDetail.deletable==0>readonly</#if>></td> <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost-project-manage" value="${costProjectManageDetail.detail!}"></td> <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost-project-manage" value="${costProjectManageDetail.unit!}"></td> <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost-project-manage input-changeable-amount-project-manage" value="${costProjectManageDetail.amount!}"></td> @@ -562,14 +562,16 @@ <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost-project-manage" value="${costProjectManageDetail.predictMethod!}"></td> <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost-project-manage" value="${costProjectManageDetail.predictWhy!}"></td> <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost-project-manage" value="${costProjectManageDetail.remark!}"></td> - <td><button type="button" class="am-btn am-btn-warning am-btn-xs am-modal-line-delete"><span class="am-icon-minus"></span></button></td> + <td><#if costProjectManageDetail.deletable==1><button type="button" class="am-btn am-btn-warning am-btn-xs am-round am-modal-line-delete"><span class="am-icon-minus"></span></button></#if> + <input type="hidden" class="am-modal-prompt-input am-modal-prompt-input-cost-project-manage" value="${costProjectManageDetail.deletable!}"> + </td> </tr> </#list> </#if> </tbody> </table> - <button type="button" id="costProjectManageAddBtn" class="am-btn am-btn-primary am-btn-xs"><span class="am-icon-plus"></span></button> + <button type="button" id="costProjectManageAddBtn" class="am-btn am-btn-primary am-btn-xs am-round"><span class="am-icon-plus"></span></button> </div> <div class="am-modal-footer"> <span class="am-modal-btn" data-am-modal-cancel>取消</span> diff --git a/src/main/resources/templates/admin/project_estimate_add.ftl b/src/main/resources/templates/admin/project_estimate_add.ftl index 4754eca..8096fd5 100644 --- a/src/main/resources/templates/admin/project_estimate_add.ftl +++ b/src/main/resources/templates/admin/project_estimate_add.ftl @@ -255,7 +255,7 @@ <td>成本</td> <td>项目管理成本</td> <td>项目管理成本</td> - <td><input name="costProjectManageTaxInclude" required></td> + <td><#--<input name="costProjectManageTaxInclude" required>-->/</td> <td><input name="costProjectManageTaxExclude" required></td> </tr> <tr>