فهرست منبع

其他台账,允许单独控制金额小数位数

MaiXinRong 5 سال پیش
والد
کامیت
aa45c021f3
5فایلهای تغییر یافته به همراه38 افزوده شده و 45 حذف شده
  1. 0 1
      app/const/tender_info.js
  2. 10 2
      app/service/stage_bonus.js
  3. 14 6
      app/service/stage_jgcl.js
  4. 12 4
      app/service/stage_other.js
  5. 2 32
      app/view/tender/detail_modal.ejs

+ 0 - 1
app/const/tender_info.js

@@ -64,7 +64,6 @@ const defaultInfo = {
         pay: false,
         payTp: 0,
         extra: false,
-        extraQty: 3,
         extraTp: 0,
     },
     precision: {

+ 10 - 2
app/service/stage_bonus.js

@@ -72,6 +72,10 @@ module.exports = app => {
         }
 
         async _addDatas(data) {
+            const tpDecimal = this.ctx.tender.info.decimal.extra
+                ? this.ctx.tender.info.decimal.extraTp
+                : this.ctx.tender.info.decimal.tp;
+
             const datas = data instanceof Array ? data : [data];
             const insertData = [];
             for (const d of datas) {
@@ -87,7 +91,7 @@ module.exports = app => {
                     order: d.order,
                 };
                 nd.b_type = d.b_type ? d.b_type : null;
-                nd.tp = d.tp ? this.ctx.helper.round(d.to, this.ctx.tender.info.decimal.tp) : 0;
+                nd.tp = d.tp ? this.ctx.helper.round(d.tp, tpDecimal) : 0;
                 nd.code = d.code ? d.code: null;
                 nd.proof = d.proof ? d.proof : null;
                 nd.real_time = d.real_time ? d.real_time : null;
@@ -112,6 +116,10 @@ module.exports = app => {
         }
 
         async _updateDatas (data) {
+            const tpDecimal = this.ctx.tender.info.decimal.extra
+                ? this.ctx.tender.info.decimal.extraTp
+                : this.ctx.tender.info.decimal.tp;
+
             const datas = data instanceof Array ? data : [data];
             const orgDatas = await this.getAllDataByCondition({sid: this.ctx.stage.id, id: this.ctx.helper._.map(datas, 'id')});
 
@@ -123,7 +131,7 @@ module.exports = app => {
                 const nd = {id: od.id};
                 if (d.name !== undefined) nd.name = d.name;
                 if (d.b_type !== undefined) nd.b_type = d.b_type;
-                if (d.tp !== undefined) nd.tp = this.ctx.helper.round(d.tp, this.ctx.tender.info.decimal.tp);
+                if (d.tp !== undefined) nd.tp = this.ctx.helper.round(d.tp, tpDecimal);
                 if (d.code !== undefined) nd.code = d.code;
                 if (d.proof !== undefined) nd.proof = d.proof;
                 if (d.proof_file !== undefined) nd.proof_file = JSON.stringify(d.proof_file);

+ 14 - 6
app/service/stage_jgcl.js

@@ -71,6 +71,10 @@ module.exports = app => {
         }
 
         async _addDatas(data) {
+            const tpDecimal = this.ctx.tender.info.decimal.extra
+                ? this.ctx.tender.info.decimal.extraTp
+                : this.ctx.tender.info.decimal.tp;
+
             const datas = data instanceof Array ? data : [data];
             const insertData = [];
             for (const d of datas) {
@@ -88,11 +92,11 @@ module.exports = app => {
                 const precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, d.unit_price);
                 if (d.arrive_qty) {
                     nd.arrive_qty = this.ctx.helper.round(d.arrive_qty, precision.value);
-                    nd.arrive_tp = this.ctx.helper.mul(nd.unit_price, nd.arrive_qty, this.ctx.tender.info.decimal.tp);
+                    nd.arrive_tp = this.ctx.helper.mul(nd.unit_price, nd.arrive_qty, tpDecimal);
                 }
                 if (d.deduct_qty) {
                     nd.deduct_qty = this.ctx.helper.round(d.deduct_qty, precision.value);
-                    nd.deduct_tp = this.ctx.helper.mul(nd.unit_price, nd.deduct_qty, this.ctx.tender.info.decimal.tp);
+                    nd.deduct_tp = this.ctx.helper.mul(nd.unit_price, nd.deduct_qty, tpDecimal);
                 }
                 if (d.source) nd.source = d.source;
                 if (d.bills_code) nd.bills_code = d.bills_code;
@@ -117,6 +121,10 @@ module.exports = app => {
         }
 
         async _updateDatas (data) {
+            const tpDecimal = this.ctx.tender.info.decimal.extra
+                ? this.ctx.tender.info.decimal.extraTp
+                : this.ctx.tender.info.decimal.tp;
+
             const datas = data instanceof Array ? data : [data];
             const orgDatas = await this.getAllDataByCondition({sid: this.ctx.stage.id, id: this.ctx.helper._.map(datas, 'id')});
             const info = this.ctx.tender.info;
@@ -137,15 +145,15 @@ module.exports = app => {
                 const precision = this.ctx.helper.findPrecision(info.precision, d.unit_price);
                 if (d.arrive_qty !== undefined) {
                     nd.arrive_qty = this.ctx.helper.round(d.arrive_qty, precision.value);
-                    nd.arrive_tp = this.ctx.helper.mul(nd.unit_price, nd.arrive_qty, info.decimal.tp);
+                    nd.arrive_tp = this.ctx.helper.mul(nd.unit_price, nd.arrive_qty, tpDecimal);
                 } else if (d.unit_price !== undefined) {
-                    nd.arrive_tp = this.ctx.helper.mul(nd.unit_price, od.arrive_qty, info.decimal.tp);
+                    nd.arrive_tp = this.ctx.helper.mul(nd.unit_price, od.arrive_qty, tpDecimal);
                 }
                 if (d.deduct_qty !== undefined) {
                     nd.deduct_qty = this.ctx.helper.round(d.deduct_qty, precision.value);
-                    nd.deduct_tp = this.ctx.helper.mul(nd.unit_price, nd.deduct_qty, info.decimal.tp);
+                    nd.deduct_tp = this.ctx.helper.mul(nd.unit_price, nd.deduct_qty, tpDecimal);
                 } else if (d.unit_price !== undefined) {
-                    nd.deduct_tp = this.ctx.helper.mul(nd.unit_price, od.deduct_qty, info.decimal.tp);
+                    nd.deduct_tp = this.ctx.helper.mul(nd.unit_price, od.deduct_qty, tpDecimal);
                 }
                 if (d.source !== undefined) nd.source = d.source;
                 if (d.bills_code !== undefined) nd.bills_code = d.bills_code;

+ 12 - 4
app/service/stage_other.js

@@ -59,6 +59,10 @@ module.exports = app => {
         }
 
         async _addDatas(data) {
+            const tpDecimal = this.ctx.tender.info.decimal.extra
+                ? this.ctx.tender.info.decimal.extraTp
+                : this.ctx.tender.info.decimal.tp;
+
             const datas = data instanceof Array ? data : [data];
             const insertData = [];
             for (const d of datas) {
@@ -76,8 +80,8 @@ module.exports = app => {
                 nd.order = d.order;
 
                 if (d.o_type) nd.o_type = d.o_type;
-                if (d.total_price) nd.total_price = this.ctx.helper.round(d.total_price, this.ctx.tender.info.decimal.tp);
-                if (d.tp) nd.tp = this.ctx.helper.round(d.tp, this.ctx.tender.info.decimal.tp);
+                if (d.total_price) nd.total_price = this.ctx.helper.round(d.total_price, tpDecimal);
+                if (d.tp) nd.tp = this.ctx.helper.round(d.tp, tpDecimal);
                 if (d.real_time) nd.real_time = d.real_time;
                 if (d.memo) nd.memo = d.memo;
                 insertData.push(nd);
@@ -99,6 +103,10 @@ module.exports = app => {
         }
 
         async _updateDatas (data) {
+            const tpDecimal = this.ctx.tender.info.decimal.extra
+                ? this.ctx.tender.info.decimal.extraTp
+                : this.ctx.tender.info.decimal.tp;
+
             const datas = data instanceof Array ? data : [data];
             const orgDatas = await this.getAllDataByCondition({sid: this.ctx.stage.id, id: this.ctx.helper._.map(datas, 'id')});
 
@@ -116,9 +124,9 @@ module.exports = app => {
                 if (d.o_type !== undefined) nd.o_type = d.o_type;
                 if (d.total_price !== undefined) {
                     if (od.pre_used) throw '往期已使用,不可修改金额';
-                    nd.total_price = this.ctx.helper.round(d.total_price, this.ctx.tender.info.decimal.tp);
+                    nd.total_price = this.ctx.helper.round(d.total_price, tpDecimal);
                 }
-                if (d.tp !== undefined) nd.tp = this.ctx.helper.round(d.tp, this.ctx.tender.info.decimal.tp);
+                if (d.tp !== undefined) nd.tp = this.ctx.helper.round(d.tp, tpDecimal);
                 if (d.real_time !== undefined) nd.real_time = new Date(d.real_time);
                 if (d.memo !== undefined) nd.memo = d.memo;
                 uDatas.push(nd);

+ 2 - 32
app/view/tender/detail_modal.ejs

@@ -350,15 +350,6 @@
                         <div class="col-4">
                             <div class="input-group input-group-sm">
                                 <div class="input-group-prepend">
-                                    <span class="input-group-text">数量</span>
-                                </div>
-                                <input type="number" class="form-control" value="2" id="decimal-extra-qty"
-                                       oninput="limitDecimal(this)" min="0" max="6">
-                            </div>
-                        </div>
-                        <div class="col-4">
-                            <div class="input-group input-group-sm">
-                                <div class="input-group-prepend">
                                     <span class="input-group-text">金额</span>
                                 </div>
                                 <input type="number" class="form-control" value="2" id="decimal-extra-tp"
@@ -430,7 +421,7 @@
                         <div class="col-auto pr-0">
                             <div class="form-group form-check pl-0">
                                 <div class="custom-control custom-switch">
-                                    <input type="checkbox" class="custom-control-input" id="decimal-pay" readonly="">
+                                    <input type="checkbox" class="custom-control-input" id="decimal-pay" disabled>
                                     <label class="custom-control-label" for="decimal-pay">合同支付</label>
                                 </div>
                             </div>
@@ -448,7 +439,7 @@
                         <div class="col-auto pr-0">
                             <div class="form-group form-check pl-0">
                                 <div class="custom-control custom-switch">
-                                    <input type="checkbox" class="custom-control-input" id="decimal-extra" readonly="">
+                                    <input type="checkbox" class="custom-control-input" id="decimal-extra" disabled>
                                     <label class="custom-control-label" for="decimal-extra">其他台账</label>
                                 </div>
                             </div>
@@ -456,14 +447,6 @@
                         <div class="col-4">
                             <div class="input-group input-group-sm">
                                 <div class="input-group-prepend">
-                                    <span class="input-group-text">数量</span>
-                                </div>
-                                <input type="number" class="form-control" value="2" id="decimal-extra-qty" readonly="">
-                            </div>
-                        </div>
-                        <div class="col-4">
-                            <div class="input-group input-group-sm">
-                                <div class="input-group-prepend">
                                     <span class="input-group-text">金额</span>
                                 </div>
                                 <input type="number" class="form-control" value="2" id="decimal-extra-tp" readonly="">
@@ -778,20 +761,12 @@
         $('#decimal-extra')[0].checked = property.decimal.extra;
         $('#decimal-extra-tp').val(property.decimal.extraTp);
         $('#decimal-extra-tp')[0].disabled = !property.decimal.extra;
-        $('#decimal-extra-qty').val(property.decimal.extraQty);
-        $('#decimal-extra-qty')[0].disabled = !property.decimal.extra;
     }
     $('#decimal-pay').change(() => {
-        console.log(!$('#decimal-pay')[0].checked);
         $('#decimal-pay-tp')[0].disabled = !$('#decimal-pay')[0].checked;
-        console.log($('#decimal-pay-tp')[0].disabled);
     });
     $('#decimal-extra').change(() => {
-        console.log(!$('#decimal-extra')[0].checked);
-        $('#decimal-extra-qty')[0].disabled = !$('#decimal-extra')[0].checked;
         $('#decimal-extra-tp')[0].disabled = !$('#decimal-extra')[0].checked;
-        console.log($('#decimal-extra-qty')[0].disabled);
-        console.log($('#decimal-extra-tp')[0].disabled);
     });
     $('#bd-set-2').on('show.bs.modal', function () {
         loadCalculateProperty();
@@ -804,7 +779,6 @@
                 pay: $('#decimal-pay')[0].checked,
                 payTp: _.toNumber($('#decimal-pay-tp').val()),
                 extra: $('#decimal-extra')[0].checked,
-                extraQty: _.toNumber($('#decimal-extra-qty').val()),
                 extraTp: _.toNumber($('#decimal-extra-tp').val()),
             }
         };
@@ -839,10 +813,6 @@
                     toastr.warning('第一期已审批完成,不可取消其他台账单独设置');
                     return;
                 }
-                if (prop.decimal.extraQty < property.decimal.extraQty) {
-                    toastr.warning('第一期已审批完成,单独设置的其他台账小数位数,不可小于' + property.decimal.extraQty);
-                    return;
-                }
                 if (prop.decimal.extraTp < property.decimal.extraTp) {
                     toastr.warning('第一期已审批完成,单独设置的其他台账小数位数,不可小于' + property.decimal.extraTp);
                     return;