Explorar el Código

变更调整变更后数量及金额计算及显示方式为实时

ellisran hace 9 horas
padre
commit
3929c2f988
Se han modificado 2 ficheros con 19 adiciones y 15 borrados
  1. 14 10
      app/controller/change_controller.js
  2. 5 5
      app/public/js/change_information.js

+ 14 - 10
app/controller/change_controller.js

@@ -444,12 +444,14 @@ module.exports = app => {
                         // 清单表页赋值
                         for (const au in change.userGroups) {
                             if (change.userGroups[au][0].audit_order !== 0) {
+                                // cl['audit_amount_' + change.userGroups[au][0].audit_order] =
+                                // (change.userGroups[au][0].audit_type === auditType.key.and &&
+                                //     ctx.helper._.findIndex(change.userGroups[au], { status: audit.change.status.checking }) !== -1 &&
+                                //     ctx.helper._.findIndex(change.userGroups[au], { uid: ctx.session.sessionUser.accountId, status: audit.change.status.checked }) !== -1) ||
+                                //     (change.shenpiPower && ctx.helper._.findIndex(change.userGroups[au], { uid: ctx.session.sessionUser.accountId }) !== -1) ?
+                                //     cl.spamount : (audit_amount[au - 1] !== undefined ? parseFloat(audit_amount[au - 1]) : null);
                                 cl['audit_amount_' + change.userGroups[au][0].audit_order] =
-                                (change.userGroups[au][0].audit_type === auditType.key.and &&
-                                    ctx.helper._.findIndex(change.userGroups[au], { status: audit.change.status.checking }) !== -1 &&
-                                    ctx.helper._.findIndex(change.userGroups[au], { uid: ctx.session.sessionUser.accountId, status: audit.change.status.checked }) !== -1) ||
-                                    (change.shenpiPower && ctx.helper._.findIndex(change.userGroups[au], { uid: ctx.session.sessionUser.accountId }) !== -1) ?
-                                    cl.spamount : (audit_amount[au - 1] !== undefined ? parseFloat(audit_amount[au - 1]) : null);
+                                    ctx.helper._.findIndex(change.userGroups[au], { status: audit.change.status.checking }) !== -1 ? cl.spamount : (audit_amount[au - 1] !== undefined ? parseFloat(audit_amount[au - 1]) : null);
                             }
                         }
                         if (change.readOnly && !change.shenpiPower) {
@@ -808,12 +810,14 @@ module.exports = app => {
                                 // 清单表页赋值
                                 for (const au in ctx.change.userGroups) {
                                     if (ctx.change.userGroups[au][0].audit_order !== 0) {
+                                        // cl['audit_amount_' + ctx.change.userGroups[au][0].audit_order] =
+                                        //     (ctx.change.userGroups[au][0].audit_type === auditType.key.and &&
+                                        //         ctx.helper._.findIndex(ctx.change.userGroups[au], { status: audit.change.status.checking }) !== -1 &&
+                                        //         ctx.helper._.findIndex(ctx.change.userGroups[au], { uid: ctx.session.sessionUser.accountId, status: audit.change.status.checked }) !== -1) ||
+                                        //     (ctx.change.shenpiPower && ctx.helper._.findIndex(ctx.change.userGroups[au], { uid: ctx.session.sessionUser.accountId }) !== -1) ?
+                                        //         cl.spamount : (audit_amount[au - 1] !== undefined ? parseFloat(audit_amount[au - 1]) : null);
                                         cl['audit_amount_' + ctx.change.userGroups[au][0].audit_order] =
-                                            (ctx.change.userGroups[au][0].audit_type === auditType.key.and &&
-                                                ctx.helper._.findIndex(ctx.change.userGroups[au], { status: audit.change.status.checking }) !== -1 &&
-                                                ctx.helper._.findIndex(ctx.change.userGroups[au], { uid: ctx.session.sessionUser.accountId, status: audit.change.status.checked }) !== -1) ||
-                                            (ctx.change.shenpiPower && ctx.helper._.findIndex(ctx.change.userGroups[au], { uid: ctx.session.sessionUser.accountId }) !== -1) ?
-                                                cl.spamount : (audit_amount[au - 1] !== undefined ? parseFloat(audit_amount[au - 1]) : null);
+                                            ctx.helper._.findIndex(ctx.change.userGroups[au], { status: audit.change.status.checking }) !== -1 ? cl.spamount : (audit_amount[au - 1] !== undefined ? parseFloat(audit_amount[au - 1]) : null);
                                     }
                                 }
                             }

+ 5 - 5
app/public/js/change_information.js

@@ -678,11 +678,11 @@ $(document).ready(() => {
                 return ZhCalc.round(data.camount, findDecimal(data.unit));
             },
             changed_amount: function (data) {
-                return ZhCalc.round(ZhCalc.add(data.oamount2, data.camount), findDecimal(data.unit));
+                return ZhCalc.round(ZhCalc.add(data.oamount2, data.spamount), findDecimal(data.unit));
             },
             changed_tp: function (data) {
-                return ZhCalc.add(ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.oamount2, findDecimal(data.unit))), totalPriceUnit),
-                    ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.camount, findDecimal(data.unit))), totalPriceUnit));
+                const otp = ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.oamount2, findDecimal(data.unit))), totalPriceUnit);
+                return ZhCalc.add(otp, ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.spamount, findDecimal(data.unit))), totalPriceUnit));
             },
             // del_list: function (data) {
             //     return !_.find(changeUsedData, { cbid: data.id }) && !checkIsSettle(data) ? '移除' : '';
@@ -811,7 +811,7 @@ $(document).ready(() => {
                     }
                     c.order = node.order;
                 }
-                if (!_.isEqual(node.oamount2, oamount2) || !_.isEqual(node.camount, camount) || !_.isEqual(node.samount, samount)) {
+                if (!_.isEqual(node.oamount2, oamount2) || !_.isEqual(node.camount, camount) || !_.isEqual(node.samount, samount) || !_.isEqual(node.spamount, spamount)) {
                     node.oamount2 = oamount2;
                     node.camount = camount;
                     node.samount = samount;
@@ -2995,7 +2995,7 @@ $(document).ready(() => {
                     spamount = ZhCalc.add(spamount, ZhCalc.round(np.spamount, findDecimal(node.unit)));
                     if (np.is_valuation === 0) is_valuation = 0;
                 }
-                if (!_.isEqual(node.oamount2, oamount2) || !_.isEqual(node.camount, camount) || !_.isEqual(node.samount, samount)) {
+                if (!_.isEqual(node.oamount2, oamount2) || !_.isEqual(node.camount, camount) || !_.isEqual(node.samount, samount) || !_.isEqual(node.spamount, spamount)) {
                     node.oamount2 = oamount2;
                     node.camount = camount;
                     node.samount = samount;