Browse Source

差值对比标红

laiguoran 3 years atrás
parent
commit
bb1f4486dc
1 changed files with 14 additions and 3 deletions
  1. 14 3
      app/public/js/change_information.js

+ 14 - 3
app/public/js/change_information.js

@@ -342,6 +342,13 @@ $(document).ready(() => {
         }
     };
     const czSpreadObj = {
+        makeBackColor: function () {
+            const rowCount = czSpread.getActiveSheet().getRowCount();
+            console.log();
+            for (let i = 0; i < rowCount; i++) {
+                if (czSpread.getActiveSheet().zh_data[i].color) czSpread.getActiveSheet().getRange(i, -1, 1, -1).backColor('#f5c6cb');
+            }
+        },
         makeSjsFooter: function () {
             // 增加汇总行并设为锁定禁止编辑状态
             czSpread.getActiveSheet().addRows(czSpread.getActiveSheet().getRowCount(), 1);
@@ -354,7 +361,7 @@ $(document).ready(() => {
             let pSum = 0,
                 cSum = 0,
                 czSum = 0;
-            for (var i = 0; i < rowCount - 1; i++) {
+            for (let i = 0; i < rowCount - 1; i++) {
                 pSum = ZhCalc.add(pSum, czSpread.getActiveSheet().getValue(i, 5));
                 cSum = ZhCalc.add(cSum, czSpread.getActiveSheet().getValue(i, 7));
                 czSum = ZhCalc.add(czSum, czSpread.getActiveSheet().getValue(i, 9));
@@ -387,22 +394,26 @@ $(document).ready(() => {
         for (const c of cList) {
             const planInfo = _.find(newPlanList, { code: c.code, name: c.name, unit: c.unit, unit_price: c.unit_price });
             const pamount = planInfo ? planInfo.spamount : null;
+            let color = true;
             if (planInfo) {
                 _.remove(newPlanList, (item) => item === planInfo);
+                color = false;
             }
-            czList.push({ code: c.code, name: c.name, unit: c.unit, unit_price: c.unit_price, camount: c.spamount, pamount });
+            czList.push({ code: c.code, name: c.name, unit: c.unit, unit_price: c.unit_price, camount: c.spamount, pamount, color });
         }
         if (newPlanList.length > 0) {
             for (const np of newPlanList) {
-                czList.push({ code: np.code, name: np.name, unit: np.unit, unit_price: np.unit_price, camount: null, pamount: np.spamount });
+                czList.push({ code: np.code, name: np.name, unit: np.unit, unit_price: np.unit_price, camount: null, pamount: np.spamount, color: true });
             }
         }
         if (czList.length > 0) {
             // 按清单编号排序
             czList.sort(sortByCode);
         }
+        console.log(czList);
         // sjs设置
         SpreadJsObj.loadSheetData(czSpread.getActiveSheet(), SpreadJsObj.DataType.Data, czList);
+        czSpreadObj.makeBackColor();
         czSpreadObj.makeSjsFooter();
     });