Преглед на файлове

单价调整,应用变更令历史

MaiXinRong преди 2 години
родител
ревизия
b7b4d702b9
променени са 3 файла, в които са добавени 15 реда и са изтрити 1 реда
  1. 7 0
      app/lib/revise_price.js
  2. 6 0
      app/public/js/revise_price.js
  3. 2 1
      sql/update.sql

+ 7 - 0
app/lib/revise_price.js

@@ -32,6 +32,7 @@ class revisePriceCalc {
                 x.rela_cid = x.rela_cid.split(',');
                 this.rela_price_c.push(x);
             } else {
+                x.his_rela_cid = [];
                 this.common_price_c.push(x);
             }
         });
@@ -209,6 +210,7 @@ class revisePriceCalc {
             if (p) {
                 updateBills.push({ id: b.id, unit_price: p.new_price });
                 bills_tp = this.ctx.helper.mul(p.new_price, b.spamount, change.tp_decimal || decimal.tp);
+                if (!p.rela_cid) p.his_rela_cid.push(change.cid);
             } else {
                 bills_tp = this.ctx.helper.mul(b.unit_price, b.spamount, change.tp_decimal || decimal.tp);
             }
@@ -235,6 +237,11 @@ class revisePriceCalc {
         for (const c of change) {
             await this.calcChange(c, transaction);
         }
+        const revisePriceUpdate = [];
+        for (const p of this.common_price_c) {
+            if (p.his_rela_cid.length > 0) revisePriceUpdate.push({id: p.id, his_rela_cid: p.his_rela_cid.join(',')});
+        }
+        await transaction.updateRows(this.ctx.service.revisePrice.tableName, revisePriceUpdate);
     }
     async _calcStage(stage, bills, transaction) {
         // 无单价变更不执行

+ 6 - 0
app/public/js/revise_price.js

@@ -211,6 +211,12 @@ $(document).ready(() => {
                     c.rela = choose.indexOf(c.cid + '') >= 0;
                     c.valid = !!c.rela;
                 }
+            } else if (readOnly && price.his_rela_cid) {
+                const his = price.his_rela_cid.split(',');
+                for (const c of this.change) {
+                    c.rela = his.indexOf(c.cid + '') >= 0;
+                    c.valid = !!c.rela;
+                }
             } else {
                 const invalid = [];
                 for (const sp of samePrice) {

+ 2 - 1
sql/update.sql

@@ -2,9 +2,10 @@ ALTER TABLE `zh_project_account` CHANGE `stamp_path` `stamp_path` VARCHAR(5000)
 
 ALTER TABLE `zh_revise_price`
 ADD COLUMN `rela_lid`  varchar(1000) NOT NULL DEFAULT '' COMMENT '关联台账id(zh_ledger.ledger_id)' AFTER `use_stage_order`;
-
 ALTER TABLE `zh_revise_price`
 ADD COLUMN `rela_cid`  varchar(5000) NOT NULL DEFAULT '' COMMENT '关联变更令id(zh_change.cid)' AFTER `rela_lid`;
+ALTER TABLE `zh_revise_price`
+ADD COLUMN `his_rela_cid`  varchar(5000) NOT NULL DEFAULT '' COMMENT '审批通过后,关联变更令id(zh_change.cid)' AFTER `rela_cid`;
 
 CREATE TABLE `zh_audit_ass` (
   `id` bigint(20) NOT NULL AUTO_INCREMENT,