Bläddra i källkod

清单对比,查找定位,新增合计

MaiXinRong 2 år sedan
förälder
incheckning
b366d9ee91
2 ändrade filer med 21 tillägg och 5 borttagningar
  1. 14 4
      app/public/js/ledger_gather.js
  2. 7 1
      app/public/js/shares/cs_tools.js

+ 14 - 4
app/public/js/ledger_gather.js

@@ -198,10 +198,12 @@ $(document).ready(() => {
         searchRangeStr: '清单编号/名称',
         resultSpreadSetting: {
             cols: [
-                {title: '清单编号', field: 'b_code', hAlign: 0, width: 100, formatter: '@'},
-                {title: '名称', field: 'name', width: 230, hAlign: 0, formatter: '@'},
-                {title: '单位', field: 'unit', width: 60, hAlign: 1, formatter: '@'},
-                {title: '单价', field: 'unit_price', hAlign: 2, width: 60},
+                {title: '清单编号', field: 'b_code', hAlign: 0, width: 80, formatter: '@'},
+                {title: '名称', field: 'name', width: 150, hAlign: 0, formatter: '@'},
+                {title: '单位', field: 'unit', width: 50, hAlign: 1, formatter: '@'},
+                {title: '单价', field: 'unit_price', hAlign: 2, width: 50},
+                {title: '台账数量', field: 'quantity', hAlign: 2, width: 60},
+                {title: '台账金额', field: 'total_price', hAlign: 2, width: 60},
             ],
             emptyRows: 0,
             headRows: 1,
@@ -220,6 +222,14 @@ $(document).ready(() => {
         },
         afterLocated: function () {
             loadLeafXmjData();
+        },
+        calcSum: function (result) {
+            const sum = { name: '合计', searchIndex: -1 };
+            for (const r of result) {
+                sum.quantity = ZhCalc.add(r.quantity, sum.quantity);
+                sum.total_price = ZhCalc.add(r.total_price, sum.total_price);
+            }
+            return sum;
         }
     });
     // 展开收起附件

+ 7 - 1
app/public/js/shares/cs_tools.js

@@ -649,6 +649,10 @@ const showSelectTab = function(select, spread, afterShow) {
                 searchList();
             }
         };
+        const calulateSum = function () {
+            if (searchResult.length === 0 || !setting.calcSum) return;
+            searchResult.unshift(setting.calcSum(searchResult));
+        };
         const searchList = function () {
             const keyword = $('#searchKeyword', obj).val();
             searchResult = [];
@@ -661,6 +665,7 @@ const showSelectTab = function(select, spread, afterShow) {
                     searchResult.push(data);
                 }
             }
+            calulateSum();
             SpreadJsObj.loadSheetData(resultSpread.getActiveSheet(), 'data', searchResult);
         };
         const getCheckFun = function (key) {
@@ -682,6 +687,7 @@ const showSelectTab = function(select, spread, afterShow) {
                     }
                 }
             }
+            calulateSum();
             SpreadJsObj.loadSheetData(resultSpread.getActiveSheet(), 'data', searchResult);
         };
 
@@ -691,7 +697,7 @@ const showSelectTab = function(select, spread, afterShow) {
         $('button', obj).bind('click', () => {search()});
         resultSpread.getActiveSheet().bind(spreadNS.Events.CellDoubleClick, function (e, info) {
             const cur = SpreadJsObj.getSelectObject(info.sheet);
-            if (!cur) return;
+            if (!cur || cur.searchIndex < 0) return;
 
             SpreadJsObj.locateRow(searchSheet, cur.searchIndex);
             if (setting.afterLocated) {