Browse Source

清单对比、清单汇总、台账修订=清单对比,增加暂列金额统计

MaiXinRong 4 years atrás
parent
commit
989c0eea8c

+ 5 - 6
app/const/standard.js

@@ -26,17 +26,16 @@ const nodeType = [
     {text: '其他建安工程', value: 14},
 ];
 
-const chapterFilter = [];
 const jrg = nodeType.find(x => {
     return x.text === '计日工';
 });
-if (jrg) {
-    chapterFilter.push({node_type: jrg.value});
-    chapterFilter.push({field: 'name', part: jrg.text});
-}
+const zlj = nodeType.find(x => {
+    return x.text === '暂列金额';
+});
 
 
 module.exports = {
     nodeType,
-    chapterFilter,
+    jrg,
+    zlj,
 };

+ 5 - 2
app/controller/ledger_controller.js

@@ -699,7 +699,6 @@ module.exports = app => {
                 const renderData = {
                     tender: ctx.tender.data,
                     jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.ledger.gather),
-                    chapterFilter: stdConst.chapterFilter,
                 };
 
                 await this.layout('ledger/gather.ejs', renderData);
@@ -720,7 +719,11 @@ module.exports = app => {
                 const posData = this.ctx.tender.data.measure_type === measureType.tz.value
                     ? await ctx.service.pos.getPosData({ tid: ctx.tender.id }) : [];
                 const dealBills = await ctx.service.dealBills.getAllDataByCondition({ where: { tender_id: this.ctx.tender.id } });
-                ctx.body = { err: 0, msg: '', data: { bills: billsData, pos: posData, dealBills } };
+                const zlj = JSON.parse(JSON.stringify(stdConst.zlj));
+                zlj.deal_bills_tp = ctx.tender.info.deal_param.zanLiePrice;
+                ctx.body = { err: 0, msg: '', data: {
+                    bills: billsData, pos: posData, dealBills, spec: {zlj: zlj, jrg: stdConst.jrg},
+                }};
             } catch (err) {
                 this.log(err);
                 ctx.body = { err: 1, msg: err.toString(), data: [] };

+ 4 - 1
app/controller/revise_controller.js

@@ -991,6 +991,10 @@ module.exports = app => {
                         return await this._loadLastStagePosData(ctx);
                     }
                 case 'dealBills': return await ctx.service.dealBills.getAllDataByCondition({where: {tender_id: ctx.tender.id}});
+                case 'spec':
+                    const spec = {zlj: stdConst.zlj, jrg: stdConst.jrg};
+                    spec.zlj.deal_bills_tp = ctx.tender.info.deal_param.zanLiePrice;;
+                    return spec;
             }
         }
 
@@ -1021,7 +1025,6 @@ module.exports = app => {
             const renderData = {
                 revise,
                 jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.revise.gclCompare),
-                chapterFilter: stdConst.chapterFilter,
             };
             await this.layout('revise/gcl_compare.ejs', renderData);
         }

+ 7 - 1
app/controller/stage_controller.js

@@ -324,12 +324,19 @@ module.exports = app => {
                             responseData.data.dealBills = await ctx.service.dealBills.getAllDataByCondition({
                                 where: { tender_id: this.ctx.tender.id },
                             });
+                            break;
                         case 'tag':
                             responseData.data.tags = await ctx.service.ledgerTag.getDatas(ctx.tender.id, ctx.stage.id);
+                            break;
                         case 'cooperation':
                             responseData.data.cooperation = await this.ctx.service.ledgerCooperation.getValidData(
                                 ctx.tender.id, ctx.session.sessionUser.accountId);
                             break;
+                        case 'spec':
+                            const spec = {zlj: JSON.parse(JSON.stringify(stdConst.zlj)), jrg: stdConst.jrg};
+                            spec.zlj.deal_bills_tp = ctx.tender.info.deal_param.zanLiePrice;
+                            responseData.data.spec = spec;
+                            break;
                     }
                 }
 
@@ -1178,7 +1185,6 @@ module.exports = app => {
                 [renderData.gclSpread, renderData.leafXmjSpread] = this._getGatherSpreadSetting();
 
                 renderData.jsFiles = this.app.jsFiles.common.concat(this.app.jsFiles.stage.gather);
-                renderData.chapterFilter = stdConst.chapterFilter;
                 await this.layout('stage/gather.ejs', renderData, 'stage/gather_modal.ejs');
             } catch (err) {
                 this.log(err);

+ 0 - 1
app/lib/gcl_gather.js

@@ -321,7 +321,6 @@ const gclGatherModel = class {
 
         this.gclList = [];
         this.leafXmjs = [];
-        this.xmjPos = [];
 
         this.recursiveGatherGclData(this.billsTree.children, null);
         this.gatherDealBillsData(deal);

+ 30 - 13
app/public/js/gcl_gather.js

@@ -420,8 +420,8 @@ const gclGatherModel = (function () {
         }
     }
 
-    function _getCalcChapter(chapter) {
-        const gclChapter = [], otherChapter = [];
+    function _getCalcChapter(chapter, option) {
+        const gclChapter = [], otherChapter = [], gclChapterFilter = [];
         let serialNo = 1;
         for (const c of chapter) {
             const cc = { code: c.code, name: c.name, cType: 1 };
@@ -429,11 +429,24 @@ const gclGatherModel = (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++ });
+
         otherChapter.push({ name: '清单小计(A)', cType: 11, serialNo: serialNo++ });
+
         otherChapter.push({ name: '非清单项费用(B)', cType: 31, serialNo: serialNo++ });
-        otherChapter.push({ name: '合计(C=A+B)', cType: 41, serialNo: serialNo });
-        return [gclChapter, otherChapter];
+
+        gclChapterFilter.push({node_type: option.jrg.value});
+        gclChapterFilter.push({field: 'name', part: option.jrg.text});
+        const zlChapter = {
+            name: '暂列金额(Z)', cType: 32, serialNo: serialNo++,
+            deal_bills_tp: option.zlj.deal_bills_tp, match: [], matchPath: []
+        };
+        zlChapter.match.push({node_type: option.zlj.value});
+        zlChapter.match.push({field: 'name', part: option.zlj.text});
+        otherChapter.push(zlChapter);
+
+        otherChapter.push({ name: '合计(C=A+B+Z)', cType: 41, serialNo: serialNo });
+        return [gclChapter, otherChapter, gclChapterFilter];
     }
 
     function _gatherChapterFields(chapter, data, fields) {
@@ -466,26 +479,30 @@ const gclGatherModel = (function () {
         return false;
     }
 
-    function gatherChapterData(chapter, fields, filter = []) {
-        const filterPath = [];
-        const checkFilterPath = function (data) {
+    function gatherChapterData(chapter, option, fields) {
+        const calcFilterPath = [], chapterFilterPath = [];
+        const checkFilterPath = function (data, filterPath) {
             for (const fp of filterPath) {
                 if (data.full_path.indexOf(fp + '-') === 0 || data.full_path === fp) return true;
             }
             return false;
         };
 
-        const [gclChapter, otherChapter] = _getCalcChapter(chapter, filter);
+        const [gclChapter, otherChapter, gclChapterFilter] = _getCalcChapter(chapter, option);
         for (const d of gsTree.nodes) {
-            if (_checkFilter(d, filter)) {
-                filterPath.push(d.full_path);
-            }
+            if (_checkFilter(d, gclChapterFilter)) chapterFilterPath.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, fields);
                 }
+                if (c.cType === 32 && _checkFilter(d, c.match)) {
+                    gatherfields(c, d, fields);
+                    calcFilterPath.push(d.full_path);
+                    continue;
+                }
                 if (c.cType === 11 && (d.b_code)) {
                     gatherfields(c, d, fields);
                 }
@@ -495,7 +512,7 @@ const gclGatherModel = (function () {
             }
 
             if (d.b_code) {
-                const c = checkFilterPath(d)
+                const c = checkFilterPath(d, chapterFilterPath)
                     ? gclChapter.find(x => { return x.cType === 21})
                     : _getGclChapter(gclChapter, d);
                 gatherfields(c, d, fields);

+ 1 - 1
app/public/js/ledger_gather.js

@@ -176,7 +176,7 @@ $(document).ready(() => {
         checkCompareData();
         loadLeafXmjData(0);
 
-        const chapterData = gclGatherModel.gatherChapterData(chapter, ['total_price'], filter);
+        const chapterData = gclGatherModel.gatherChapterData(chapter, data.spec, ['total_price']);
         for (const c of chapterData) {
             c.compare_tp = ZhCalc.sub(c.total_price, c.deal_bills_tp);
         }

+ 2 - 2
app/public/js/revise_gcl_compare.js

@@ -149,7 +149,7 @@ $(document).ready(() => {
         $('#chapter-list').html(html.join(''));
     }
 
-    postData('/tender/' + window.location.pathname.split('/')[2] + '/revise/load', {filter: 'bills;pos;reviseBills;revisePos;dealBills'}, function (data) {
+    postData('/tender/' + window.location.pathname.split('/')[2] + '/revise/load', {filter: 'bills;pos;reviseBills;revisePos;dealBills,spec'}, function (data) {
         const setting = {
             tree: {
                 id: 'ledger_id',
@@ -165,7 +165,7 @@ $(document).ready(() => {
             posFields: ['quantity'],
             chapterFields: ['total_price'],
         };
-        gclCompareModel.init(gclData, chapter, filter);
+        gclCompareModel.init(gclData, chapter, data.spec);
         setting.prefix = 'new_';
         gclCompareModel.gatherLedgerData(data.reviseBills, data.revisePos, setting);
         setting.prefix = 'org_';

+ 29 - 14
app/public/js/shares/gcl_gather_compare.js

@@ -11,7 +11,7 @@
 
 const gclCompareModel = (function () {
     const leafXmjs = [], mergeChar = ';';
-    let gclList, gclChapter, otherChapter, chapterfilter;
+    let gclList, gclChapter, otherChapter, gclChapterFilter;
     let ledgerSetting, gsTree;
 
     function gatherfields(obj, src, fields, prefix = '') {
@@ -257,8 +257,8 @@ const gclCompareModel = (function () {
         }
     }
 
-    function _getCalcChapter(chapter) {
-        const gclChapter = [], otherChapter = [];
+    function _getCalcChapter(chapter, option) {
+        const gclChapter = [], otherChapter = [], gclChapterFilter = [];
         let serialNo = 1;
         for (const c of chapter) {
             const cc = { code: c.code, name: c.name, cType: 1 };
@@ -266,11 +266,23 @@ 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++ });
+
         otherChapter.push({ name: '清单小计(A)', cType: 11, serialNo: serialNo++ });
+
         otherChapter.push({ name: '非清单项费用(B)', cType: 31, serialNo: serialNo++ });
-        otherChapter.push({ name: '合计(C=A+B)', cType: 41, serialNo: serialNo });
-        return [gclChapter, otherChapter];
+
+        gclChapterFilter.push({node_type: option.jrg.value});
+        gclChapterFilter.push({field: 'name', part: option.jrg.text});
+        const zlChapter = {
+            name: '暂列金额(Z)', cType: 32, serialNo: serialNo++,
+            deal_bills_tp: option.zlj.deal_bills_tp, match: [], matchPath: []
+        };
+        zlChapter.match.push({node_type: option.zlj.value});
+        zlChapter.match.push({field: 'name', part: option.zlj.text});
+        otherChapter.push(zlChapter);
+
+        otherChapter.push({ name: '合计(C=A+B+Z)', cType: 41, serialNo: serialNo });
     }
 
     function _gatherChapterFields(chapter, data, fields) {
@@ -304,8 +316,8 @@ const gclCompareModel = (function () {
     }
 
     function _gatherChapter() {
-        const filterPath = [];
-        const checkFilterPath = function (data) {
+        const calcFilterPath = [], chapterFilterPath = [];
+        const checkFilterPath = function (data, filterPath) {
             for (const fp of filterPath) {
                 if (data.full_path.indexOf(fp + '-') === 0 || data.full_path === fp) return true;
             }
@@ -313,15 +325,19 @@ const gclCompareModel = (function () {
         };
 
         for (const d of gsTree.nodes) {
-            if (_checkFilter(d, chapterfilter)) {
-                filterPath.push(d.full_path);
-            }
+            if (_checkFilter(d, gclChapterFilter)) chapterFilterPath.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);
+                    continue;
+                }
                 if (c.cType === 11 && (d.b_code)) {
                     gatherfields(c, d, ledgerSetting.chapterFields, ledgerSetting.prefix);
                 }
@@ -341,10 +357,9 @@ const gclCompareModel = (function () {
         }
     }
 
-    function init (gclData, chapter, filter) {
+    function init (gclData, chapter, option) {
         gclList = gclData;
-        [gclChapter, otherChapter] = _getCalcChapter(chapter);
-        chapterfilter = filter || [];
+        [gclChapter, otherChapter, gclChapterFilter] = _getCalcChapter(chapter, option);
     }
 
     /**

+ 2 - 2
app/public/js/stage_gather.js

@@ -114,7 +114,7 @@ $(document).ready(function () {
         SpreadJsObj.reLoadSheetData(gclSpread.getActiveSheet());
     });
 
-    postData(preUrl + '/load', { filter: 'ledger;pos;dealBills' }, function (result) {
+    postData(preUrl + '/load', { filter: 'ledger;pos;dealBills,spec' }, function (result) {
         // 解析清单汇总数据
         gclGatherModel.loadLedgerData(result.ledgerData);
         gclGatherModel.loadPosData(result.posData);
@@ -126,7 +126,7 @@ $(document).ready(function () {
         SpreadJsObj.loadSheetData(gclSpread.getActiveSheet(), SpreadJsObj.DataType.Data, gclGatherData);
         loadLeafXmjData(0);
         // 章节合计
-        const chapterData = gclGatherModel.gatherChapterData(chapter, ['total_price', 'contract_tp', 'qc_tp', 'pre_contract_tp', 'pre_qc_tp'], filter);
+        const chapterData = gclGatherModel.gatherChapterData(chapter, data.spec, ['total_price', 'contract_tp', 'qc_tp', 'pre_contract_tp', 'pre_qc_tp']);
         for (const c of chapterData) {
             c.gather_tp = ZhCalc.add(c.contract_tp, c.qc_tp);
             c.end_contract_tp = ZhCalc.add(c.contract_tp, c.pre_contract_tp);

+ 0 - 1
app/view/ledger/gather.ejs

@@ -68,5 +68,4 @@
 <script>
     const chapter = JSON.parse('<%- JSON.stringify(ctx.tender.info.chapter) %>');
     const thousandth = <%- ctx.tender.info.display.thousandth %>;
-    const filter = JSON.parse('<%- JSON.stringify(chapterFilter) %>');
 </script>

+ 0 - 1
app/view/revise/gcl_compare.ejs

@@ -76,5 +76,4 @@
 <script>
     const chapter = JSON.parse('<%- JSON.stringify(ctx.tender.info.chapter) %>');
     const thousandth = <%- ctx.tender.info.display.thousandth %>;
-    const filter = JSON.parse('<%- JSON.stringify(chapterFilter) %>');
 </script>

+ 0 - 1
app/view/stage/gather.ejs

@@ -103,5 +103,4 @@
     }
     const chapter = JSON.parse('<%- JSON.stringify(ctx.tender.info.chapter) %>');
     const thousandth = <%- ctx.tender.info.display.thousandth %>;
-    const filter = JSON.parse('<%- JSON.stringify(chapterFilter) %>');
 </script>