From f13a35d40aa98a8c43820155bf5c296d264d4e8d Mon Sep 17 00:00:00 2001 From: lSun <15893999301@qq.com> Date: Wed, 16 Apr 2025 18:52:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E7=A8=8B=E9=A2=84=E4=BB=98=E6=AC=BE?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E5=8A=9F=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manager/ca/bm/entity/OperationsBean.java | 5 +- .../service/impl/PrepaymentServiceImpl.java | 3 + .../resources/mappers/ca/PrepaymentMapper.xml | 195 +++++++++--------- src/main/resources/static/js/common.js | 10 + .../static/js/prepayment/addOperations.js | 22 +- .../resources/static/js/prepayment/addPro.js | 3 +- .../resources/static/js/prepayment/proForm.js | 1 + .../pages/prepayment/addOperations.html | 10 +- .../static/pages/prepayment/proForm.html | 3 - 9 files changed, 135 insertions(+), 117 deletions(-) diff --git a/src/main/java/com/bonus/boot/manager/ca/bm/entity/OperationsBean.java b/src/main/java/com/bonus/boot/manager/ca/bm/entity/OperationsBean.java index a89d203..255edcc 100644 --- a/src/main/java/com/bonus/boot/manager/ca/bm/entity/OperationsBean.java +++ b/src/main/java/com/bonus/boot/manager/ca/bm/entity/OperationsBean.java @@ -35,7 +35,10 @@ public class OperationsBean { private String operator;//更新人 @JsonSerialize(using = ToStringSerializer.class) - private BigDecimal currentBalance;//当前余额 + private BigDecimal currentBalance;//未进行新增修改时余额;就是此余额加上调整金额就是现在的金额 + + @JsonSerialize(using = ToStringSerializer.class) + private BigDecimal currentBalanceNew;//当前余额 private String userId; //用户id private String userName; //用户名 diff --git a/src/main/java/com/bonus/boot/manager/ca/bm/service/impl/PrepaymentServiceImpl.java b/src/main/java/com/bonus/boot/manager/ca/bm/service/impl/PrepaymentServiceImpl.java index 853a44e..78e6acb 100644 --- a/src/main/java/com/bonus/boot/manager/ca/bm/service/impl/PrepaymentServiceImpl.java +++ b/src/main/java/com/bonus/boot/manager/ca/bm/service/impl/PrepaymentServiceImpl.java @@ -98,7 +98,10 @@ public class PrepaymentServiceImpl implements PrepaymentService { @Override public void delOperations(Long id) { String userId =UserUtil.getLoginUser().getId().toString(); + OperationsBean bean = dao.getOperationsById(id.toString()); + bean.setCurrentBalanceNew(bean.getCurrentBalance()); dao.delOperations(id,userId); + dao.updatePrepaymentId(bean); } /** diff --git a/src/main/resources/mappers/ca/PrepaymentMapper.xml b/src/main/resources/mappers/ca/PrepaymentMapper.xml index 4713e41..d815379 100644 --- a/src/main/resources/mappers/ca/PrepaymentMapper.xml +++ b/src/main/resources/mappers/ca/PrepaymentMapper.xml @@ -6,17 +6,17 @@ INSERT INTO `bm_project_prepayment` (`project_code`, `project_name`, `business_unit`, `contact_unit`, `type`, - `initial_amount`, `first_payment_date`, `current_balance`, `remarks`,`operator`,`is_active`) - VALUES (#{projectCode},#{projectName},#{businessUnit},#{contactUnit},#{type}, - #{initialAmount},#{firstPaymentDate},#{initialAmount},#{remarks},#{operator},'1') + `initial_amount`, `first_payment_date`, `current_balance`, `remarks`, + `operator`, `is_active`) + VALUES (#{projectCode}, #{projectName}, #{businessUnit}, #{contactUnit}, #{type}, + #{initialAmount}, #{firstPaymentDate}, #{initialAmount}, #{remarks}, #{operator}, '1') - INSERT INTO `bm_monthly_operations` ( `p_id`, `month`, `operation_type`, `amount`, `executor`, `remarks`, - `next_month`, `proposed_amount`, `handler`, `next_remarks`,`is_active`,`operator` ) - VALUES - ( - #{prepaymentId}, + INSERT INTO `bm_monthly_operations` (`p_id`, `month`, `operation_type`, `amount`, `executor`, `remarks`, + `next_month`, `proposed_amount`, `handler`, `next_remarks`, `is_active`, + `operator`,`current_balance`) + VALUES (#{prepaymentId}, #{month}, #{operationType}, #{amount}, @@ -25,10 +25,13 @@ #{nextMonth}, #{proposedAmount}, #{handler}, - #{nextRemarks},'1',#{operator}) + #{nextRemarks}, '1', #{operator},#{currentBalance}) - UPDATE `bm_project_prepayment` SET `current_balance` = #{currentBalance}, `operator` = #{operator} WHERE `id` = #{prepaymentId} + UPDATE `bm_project_prepayment` + SET `current_balance` = #{currentBalanceNew}, + `operator` = #{operator} + WHERE `id` = #{prepaymentId} UPDATE `bm_project_prepayment` SET `operator` = #{operator} @@ -59,11 +62,11 @@ ,remarks = #{remarks} - WHERE `id` = #{id} + WHERE `id` = #{id} UPDATE `bm_monthly_operations` SET `month` = #{month}, `operation_type` = #{operationType}, - `amount` = #{amount}, `executor` = #{executor},operator = #{operator}, + `amount` = #{amount}, `executor` = #{executor},operator = #{operator} ,remarks = #{remarks} @@ -83,128 +86,118 @@ - UPDATE `bm_project_prepayment` SET `is_active` = '0' , operator = #{userId} WHERE `id` = #{id} + UPDATE `bm_project_prepayment` + SET `is_active` = '0', + operator = #{userId} + WHERE `id` = #{id} - UPDATE `bm_monthly_operations` SET `is_active` = '0' , operator = #{userId} WHERE `id` = #{id} + UPDATE `bm_monthly_operations` + SET `is_active` = '0', + operator = #{userId} + WHERE `id` = #{id} \ No newline at end of file diff --git a/src/main/resources/static/js/common.js b/src/main/resources/static/js/common.js index a75ae6e..f370b3e 100644 --- a/src/main/resources/static/js/common.js +++ b/src/main/resources/static/js/common.js @@ -38,4 +38,14 @@ function getCurrentMonth() { var year = now.getFullYear(); var month = now.getMonth() + 1; // 月份从 0 开始 return year + '-' + (month < 10 ? '0' + month : month); +} + +function getToday() { + var now = new Date(); + var year = now.getFullYear(); + var month = now.getMonth() + 1; // 月份从 0 开始 + var day = now.getDate(); + return year + '-' + + (month < 10 ? '0' + month : month) + '-' + + (day < 10 ? '0' + day : day); } \ No newline at end of file diff --git a/src/main/resources/static/js/prepayment/addOperations.js b/src/main/resources/static/js/prepayment/addOperations.js index 3bdd379..42c146e 100644 --- a/src/main/resources/static/js/prepayment/addOperations.js +++ b/src/main/resources/static/js/prepayment/addOperations.js @@ -104,6 +104,7 @@ function initData(){ $("#proposedAmount").val(info.proposedAmount); $("#handler").val(info.handler); $("#nextRemarks").val(info.nextRemarks); + currentBalance = info.currentBalance; } }, error: function (XMLHttpRequest, textStatus, e) { @@ -118,21 +119,29 @@ function initData(){ function calculateNewBalance() { var amount = parseFloat($('#amount').val()) || 0; var operationType = $('#operationType').val(); + var num = currentBalance; + // 将 currentBalance 转换为数字 + num = parseFloat(num) || 0; if (operationType === '1') { // 冲销是减少余额 - currentBalance = currentBalance - amount; + num = num - amount; } else { // 新增是增加余额 - currentBalance = currentBalance + amount; + num = num + amount; } - return currentBalance.toFixed(2); + // 确保返回值是保留两位小数的字符串 + console.log("最终余额:", num.toFixed(2)); + return num.toFixed(2); } function add(formData) { - // 计算更新后的余额 - var currentBalance = calculateNewBalance(); - // 添加更新后的余额到表单数据 + //先保证未进行冲销或新增金额 formData.field.currentBalance = currentBalance; + // 计算更新后的余额 + var currentBalanceNew = calculateNewBalance(); + // 添加更新后的余额到表单数据 + formData.field.currentBalanceNew = currentBalanceNew; + formData.field.prepaymentId = prepaymentId; formData.field.executor = $("#prepaymentUserId").val(); @@ -166,6 +175,7 @@ function add(formData) { top.layer.close(addLoadingMsg); //再执行关闭 parent.layer.msg(tip + '成功', { icon: 1, time: 2000 }); parent.table.reload('menuTable'); + parent.initData() } else { top.layer.close(addLoadingMsg); //再执行关闭 if(data.resMsg ==="当前月份已经存在"){ diff --git a/src/main/resources/static/js/prepayment/addPro.js b/src/main/resources/static/js/prepayment/addPro.js index 2c679ab..7b911a6 100644 --- a/src/main/resources/static/js/prepayment/addPro.js +++ b/src/main/resources/static/js/prepayment/addPro.js @@ -6,7 +6,8 @@ layui.use(['table', 'layer', 'laydate', 'jquery', 'form'], function(){ laydate = layui.laydate; // 渲染 laydate.render({ - elem: '#firstPaymentDate' + elem: '#firstPaymentDate', + max: getToday(), }); initData(); form.render(); diff --git a/src/main/resources/static/js/prepayment/proForm.js b/src/main/resources/static/js/prepayment/proForm.js index 76d77dd..4fa026d 100644 --- a/src/main/resources/static/js/prepayment/proForm.js +++ b/src/main/resources/static/js/prepayment/proForm.js @@ -176,6 +176,7 @@ function del(id) { url: ctxPath + '/prepayment/delOperations/' + id, success: function (data) { table.reload('menuTable'); + initData() layer.msg("删除成功"); } }); diff --git a/src/main/resources/static/pages/prepayment/addOperations.html b/src/main/resources/static/pages/prepayment/addOperations.html index ec2ff71..4f3ac60 100644 --- a/src/main/resources/static/pages/prepayment/addOperations.html +++ b/src/main/resources/static/pages/prepayment/addOperations.html @@ -129,14 +129,14 @@
经办人:
- +
备注:
- +
@@ -146,7 +146,7 @@
月度冲销计划及措施:
- +
@@ -160,14 +160,14 @@
责任人:
- +
备注:
- +
diff --git a/src/main/resources/static/pages/prepayment/proForm.html b/src/main/resources/static/pages/prepayment/proForm.html index 336d990..e4d4632 100644 --- a/src/main/resources/static/pages/prepayment/proForm.html +++ b/src/main/resources/static/pages/prepayment/proForm.html @@ -150,9 +150,6 @@ -