Bladeren bron

暂列金计算问题

MaiXinRong 4 jaren geleden
bovenliggende
commit
278023cb22
2 gewijzigde bestanden met toevoegingen van 50 en 63 verwijderingen
  1. 27 33
      app/public/js/gcl_gather.js
  2. 23 30
      app/public/js/shares/gcl_gather_compare.js

+ 27 - 33
app/public/js/gcl_gather.js

@@ -421,7 +421,7 @@ const gclGatherModel = (function () {
     }
 
     function _getCalcChapter(chapter, option) {
-        const gclChapter = [], otherChapter = [], gclChapterFilter = [];
+        const gclChapter = [], otherChapter = {}, gclChapterFilter = [];
         let serialNo = 1;
         for (const c of chapter) {
             const cc = { code: c.code, name: c.name, cType: 1 };
@@ -431,7 +431,7 @@ const gclGatherModel = (function () {
         }
         gclChapter.push({ name: '未计入章节清单合计', cType: 21, serialNo: serialNo+1 });
 
-        otherChapter.push({ name: '合计(C=A+B+Z)', cType: 41, serialNo: serialNo+5, deal_bills_tp: option.zlj.deal_bills_tp });
+        otherChapter.hj = { name: '合计(C=A+B+Z)', cType: 41, serialNo: serialNo+5, deal_bills_tp: option.zlj.deal_bills_tp };
         gclChapterFilter.push({node_type: option.jrg.value});
         gclChapterFilter.push({field: 'name', part: option.jrg.text});
         const zlChapter = {
@@ -440,10 +440,10 @@ const gclGatherModel = (function () {
         };
         zlChapter.match.push({node_type: option.zlj.value});
         zlChapter.match.push({field: 'name', part: option.zlj.text});
-        otherChapter.push(zlChapter);
+        otherChapter.zlj = zlChapter;
 
-        otherChapter.push({ name: '清单小计(A)', cType: 11, serialNo: serialNo+2 });
-        otherChapter.push({ name: '非清单项费用(B)', cType: 31, serialNo: serialNo+3 });
+        otherChapter.qd = { name: '清单小计(A)', cType: 11, serialNo: serialNo+2 };
+        otherChapter.fqd = { name: '非清单项费用(B)', cType: 31, serialNo: serialNo+3 };
 
         return [gclChapter, otherChapter, gclChapterFilter];
     }
@@ -479,7 +479,7 @@ const gclGatherModel = (function () {
     }
 
     function gatherChapterData(chapter, option, fields) {
-        const calcFilterPath = [], chapterFilterPath = [];
+        const chapterFilterPath = [];
         const checkFilterPath = function (data, filterPath) {
             for (const fp of filterPath) {
                 if (data.full_path.indexOf(fp + '-') === 0 || data.full_path === fp) return true;
@@ -490,46 +490,40 @@ const gclGatherModel = (function () {
         const [gclChapter, otherChapter, gclChapterFilter] = _getCalcChapter(chapter, option);
         for (const d of gsTree.nodes) {
             if (_checkFilter(d, gclChapterFilter)) chapterFilterPath.push(d.full_path);
+            if (_checkFilter(d, otherChapter.zlj.match)) otherChapter.zlj.matchPath.push(d.full_path);
             if (d.children && d.children.length > 0) continue;
-            if (checkFilterPath(d, calcFilterPath)) continue;
 
-            for (const c of otherChapter) {
-                if (d.name.indexOf('暂列金额') > -1) console.log(c);
-                if (c.cType === 41) {
-                    gatherfields(c, d, fields);
-                }
-                if (c.cType === 32 && _checkFilter(d, c.match)) {
-                    gatherfields(c, d, fields);
-                    calcFilterPath.push(d.full_path);
-                    break;
+            if (checkFilterPath(d,otherChapter.zlj.matchPath)) {
+                gatherfields(otherChapter.zlj, d, fields);
+                gatherfields(otherChapter.hj, d, fields);
+            } else {
+                gatherfields(otherChapter.hj, d, fields);
+                if (d.b_code) {
+                    gatherfields(otherChapter.qd, d, fields);
                 }
-                if (c.cType === 11 && (d.b_code)) {
-                    gatherfields(c, d, fields);
+                if (!d.b_code || d.b_code === '') {
+                    gatherfields(otherChapter.fqd, d, fields);
                 }
-                if (c.cType === 31 && (!d.b_code || d.b_code === '')) {
+
+                if (d.b_code) {
+                    const c = checkFilterPath(d, chapterFilterPath)
+                        ? gclChapter.find(x => { return x.cType === 21})
+                        : _getGclChapter(gclChapter, d);
                     gatherfields(c, d, fields);
                 }
             }
-
-            if (d.b_code) {
-                const c = checkFilterPath(d, chapterFilterPath)
-                    ? gclChapter.find(x => { return x.cType === 21})
-                    : _getGclChapter(gclChapter, d);
-                gatherfields(c, d, fields);
-            }
         }
         for (const d of deal) {
             if (!d.quantity || !d.unit_price) continue;
-            for (const c of otherChapter) {
-                if (c.cType === 41 || c.cType === 11) {
-                    c.deal_bills_tp = ZhCalc.add(c.deal_bills_tp, d.total_price);
-                }
-            }
+            otherChapter.hj.deal_bills_tp = ZhCalc.add(otherChapter.hj.deal_bills_tp, d.total_price);
+            otherChapter.qd.deal_bills_tp = ZhCalc.add(otherChapter.qd.deal_bills_tp, d.total_price);
             const c = _getGclChapter(gclChapter, d);
             c.deal_bills_tp = ZhCalc.add(c.deal_bills_tp, d.total_price);
         }
-        otherChapter.sort((x, y) => {return x.serialNo - y.serialNo});
-        return gclChapter.concat(otherChapter);
+
+        const result = gclChapter.concat([otherChapter.hj, otherChapter.zlj, otherChapter.qd, otherChapter.fqd]);
+        result.sort((x, y) => {return x.serialNo - y.serialNo});
+        return result;
     }
 
     return {

+ 23 - 30
app/public/js/shares/gcl_gather_compare.js

@@ -269,9 +269,9 @@ const gclCompareModel = (function () {
             cc.filter = '^[^0-9]*' + c.code.substr(0, c.code.length - 2) + '[0-9]{2}-';
             gclChapter.push(cc);
         }
-        gclChapter.push({ name: '未计入章节清单合计', cType: 21, serialNo: serialNo++ });
+        gclChapter.push({ name: '未计入章节清单合计', cType: 21, serialNo: serialNo+1 });
 
-        otherChapter.push({ name: '合计(C=A+B+Z)', cType: 41, serialNo: serialNo+5, deal_bills_tp: option.zlj.deal_bills_tp });
+        otherChapter.hj = { name: '合计(C=A+B+Z)', cType: 41, serialNo: serialNo+5, deal_bills_tp: option.zlj.deal_bills_tp };
         gclChapterFilter.push({node_type: option.jrg.value});
         gclChapterFilter.push({field: 'name', part: option.jrg.text});
         const zlChapter = {
@@ -280,10 +280,10 @@ const gclCompareModel = (function () {
         };
         zlChapter.match.push({node_type: option.zlj.value});
         zlChapter.match.push({field: 'name', part: option.zlj.text});
-        otherChapter.push(zlChapter);
+        otherChapter.zlj = zlChapter;
 
-        otherChapter.push({ name: '清单小计(A)', cType: 11, serialNo: serialNo+2 });
-        otherChapter.push({ name: '非清单项费用(B)', cType: 31, serialNo: serialNo+3 });
+        otherChapter.qd = { name: '清单小计(A)', cType: 11, serialNo: serialNo+2 };
+        otherChapter.fqd = { name: '非清单项费用(B)', cType: 31, serialNo: serialNo+3 };
     }
 
     function _gatherChapterFields(chapter, data, fields) {
@@ -317,7 +317,7 @@ const gclCompareModel = (function () {
     }
 
     function _gatherChapter() {
-        const calcFilterPath = [], chapterFilterPath = [];
+        const chapterFilterPath = [];
         const checkFilterPath = function (data, filterPath) {
             for (const fp of filterPath) {
                 if (data.full_path.indexOf(fp + '-') === 0 || data.full_path === fp) return true;
@@ -327,36 +327,29 @@ const gclCompareModel = (function () {
 
         for (const d of gsTree.nodes) {
             if (_checkFilter(d, gclChapterFilter)) chapterFilterPath.push(d.full_path);
+            if (_checkFilter(d, otherChapter.zlj.match)) otherChapter.zlj.matchPath.push(d.full_path);
             if (d.children && d.children.length > 0) continue;
-            if (checkFilterPath(d, calcFilterPath)) continue;
 
-            for (const c of otherChapter) {
-                if (c.cType === 41) {
-                    gatherfields(c, d, ledgerSetting.chapterFields, ledgerSetting.prefix);
-                }
-                if (c.cType === 32 && _checkFilter(d, c.match)) {
-                    gatherfields(c, d, ledgerSetting.chapterFields, ledgerSetting.prefix);
-                    calcFilterPath.push(d.full_path);
-                    break;
+            if (checkFilterPath(d,otherChapter.zlj.matchPath)) {
+                gatherfields(otherChapter.zlj, d, fields);
+                gatherfields(otherChapter.hj, d, fields);
+            } else {
+                gatherfields(otherChapter.hj, d, fields);
+                if (d.b_code) {
+                    gatherfields(otherChapter.qd, d, fields);
                 }
-                if (c.cType === 11 && (d.b_code)) {
-                    gatherfields(c, d, ledgerSetting.chapterFields, ledgerSetting.prefix);
+                if (!d.b_code || d.b_code === '') {
+                    gatherfields(otherChapter.fqd, d, fields);
                 }
-                if (c.cType === 31 && (!d.b_code || d.b_code === '')) {
-                    gatherfields(c, d, ledgerSetting.chapterFields, ledgerSetting.prefix);
+
+                if (d.b_code) {
+                    const c = checkFilterPath(d, chapterFilterPath)
+                        ? gclChapter.find(x => { return x.cType === 21})
+                        : _getGclChapter(gclChapter, d);
+                    gatherfields(c, d, fields);
                 }
             }
-            for (const fp of filterPath) {
-                if (d.full_path.indexOf(fp + '-') === 0 || d.full_path === fp) continue;
-            }
-            if (d.b_code) {
-                const c = checkFilterPath(d)
-                    ? gclChapter.find(x => { return x.cType === 21})
-                    : _getGclChapter(gclChapter, d);
-                gatherfields(c, d, ledgerSetting.chapterFields, ledgerSetting.prefix);
-            }
         }
-        otherChapter.sort((x, y) => {return x.serialNo - y.serialNo});
     }
 
     function init (gclData, chapter, option) {
@@ -486,7 +479,7 @@ const gclCompareModel = (function () {
     }
 
     function chapterData () {
-        return gclChapter.concat(otherChapter);
+        return gclChapter.concat([otherChapter.qd, otherChapter.fqd, otherChapter.zlj, otherChapter.hj]);
     }
 
     return {