Procházet zdrojové kódy

工程变更,调整台账清单加载方式

maixinrong před 5 roky
rodič
revize
b9cbbbc701

+ 12 - 9
app/controller/change_controller.js

@@ -291,15 +291,6 @@ module.exports = app => {
                 };
                 // 根据auditStatus状态获取的不同的数据
                 if (auditStatus === 1 || auditStatus === 2) {
-                    // 获取标准清单列表
-                    const dealBillList = await ctx.service.dealBills.getAllDataByCondition({ where: { tender_id: tenderid } });
-                    // 获取清单列表和台账清单列表
-                    const ledger = await ctx.service.ledger.getData(tenderid);
-                    const pos = await ctx.service.pos.getPosData({ tid: tenderid });
-                    renderData.ledger = ledger;
-                    renderData.pos = pos;
-
-                    renderData.dealBillList = dealBillList;
                     renderData.changeUnits = changeConst.units;
                     renderData.precision = ctx.tender.info.precision;
                     renderData.accountGroup = accountGroup;
@@ -482,6 +473,18 @@ module.exports = app => {
             }
         }
 
+        async defaultBills(ctx) {
+            try {
+                const ledgerData = await ctx.service.ledger.getData(ctx.tender.id);
+                const posData = await ctx.service.pos.getPosData({tid: ctx.tender.id});
+                const dealBills = await ctx.service.dealBills.getAllDataByCondition({ where: { tender_id: ctx.tender.id } });
+                ctx.body = { err: 0, msg: '', data: {bills: ledgerData, pos: posData, dealBills: dealBills} };
+            } catch (err) {
+                this.log(err);
+                ctx.body = { err: 1, msg: err.toString(), data: [] };
+            }
+        }
+
         /**
          * 变更令上报和保存
          * @param {Object} ctx - egg全局变量

+ 6 - 19
app/controller/stage_controller.js

@@ -279,6 +279,11 @@ module.exports = app => {
                         case 'change':
                             responseData.data.changeData = await this._getStageChangeData(ctx);
                             break;
+                        case 'dealBills':
+                            responseData.data.dealBills = await ctx.service.dealBills.getAllDataByCondition({
+                                where: {tender_id: this.ctx.tender.id}
+                            });
+                            break;
                     }
                 }
 
@@ -1077,24 +1082,6 @@ module.exports = app => {
                 await this._getStageAuditViewData(ctx);
                 const renderData = await this._getDefaultRenderData(ctx);
                 [renderData.gclSpread, renderData.leafXmjSpread] = this._getGatherSpreadSetting();
-                renderData.ledger = await ctx.service.ledger.getData(ctx.tender.id);
-                renderData.curLedgerData = await ctx.service.stageBills.getAuditorStageData(ctx.tender.id, ctx.stage.id, ctx.stage.curTimes, ctx.stage.curOrder);
-                if (ctx.stage.order > 1) {
-                    renderData.preLedgerData = await ctx.service.stageBillsFinal.getFinalData(ctx.tender.data, ctx.stage.order - 1);
-                } else {
-                    renderData.preLedgerData = [];
-                }
-
-                renderData.pos = await ctx.service.pos.getPosData({tid: ctx.tender.id});
-                // todo 根据当前人,或指定对象查询数据
-                renderData.curPosData = await ctx.service.stagePos.getAuditorStageData(ctx.tender.id,
-                    ctx.stage.id, ctx.stage.curTimes, ctx.stage.curOrder);
-                if (ctx.stage.order > 1) {
-                    renderData.prePosData = await ctx.service.stagePosFinal.getFinalData(ctx.tender.data, ctx.stage.order - 1);
-                } else {
-                    renderData.prePosData = [];
-                }
-                renderData.dealBills = await ctx.service.dealBills.getAllDataByCondition({ where: {tender_id: this.ctx.tender.id} });
 
                 renderData.jsFiles = this.app.jsFiles.common.concat(this.app.jsFiles.stage.gather);
                 await this.layout('stage/gather.ejs', renderData, 'stage/gather_modal.ejs');
@@ -1103,7 +1090,7 @@ module.exports = app => {
                 ctx.redirect('/tender/' + ctx.tender.id + '/measure/stage/' + ctx.params.order);
             }
         }
-
+ 
         /**
          * 审核比较 页面 (Get)
          * @param ctx

+ 63 - 57
app/public/js/change_set.js

@@ -40,64 +40,70 @@ $(document).ready(() => {
         }
     }
 
-    gclGatherModel.loadLedgerData(ledger);
-    gclGatherModel.loadPosData(pos);
-    const gclGatherData = gclGatherModel.gatherGclData();
-    for (const ggd in gclGatherData) {
-        gclGatherData[ggd].code = gclGatherData[ggd].b_code;
-    }
-    // 数组去重
-    for (const db of gclGatherData) {
-        const exist_index = dealBillList.findIndex(function (item) {
-            return item.code === db.code && item.name === db.name && item.unit === db.unit && item.unit_price === db.unit_price;
-        });
-        if (exist_index !== -1) {
-            dealBillList.splice(exist_index, 1);
+    const preUrl = window.location.pathname.split('/').slice(0, 4).join('/');
+    let changeListData;
+    postData(preUrl + '/defaultBills', {}, function (result) {
+        gclGatherModel.loadLedgerData(result.bills);
+        gclGatherModel.loadPosData(result.pos);
+
+        const gclGatherData = gclGatherModel.gatherGclData();
+        for (const ggd in gclGatherData) {
+            gclGatherData[ggd].code = gclGatherData[ggd].b_code;
         }
-    }
-    const changeListData = gclGatherData.concat(dealBillList).sort(sortByCode);
-    console.log(changeListData);
-    // 先加载台账数据
-    let listHtml = '';
-    let list_index = 1;
-    let gcl_index = 0;
-    for (const gcl of changeListData) {
-        const unit = gcl.unit !== undefined && gcl.unit !== null ? gcl.unit : '';
-        const quantity = gcl.quantity !== null && gcl.quantity !== undefined ? (unit !== '' ? roundnum(gcl.quantity, findDecimal(gcl.unit)) : gcl.quantity) : 0;
-        const unit_price = gcl.unit_price !== null && gcl.unit_price !== undefined ? gcl.unit_price : 0;
-        let gclhtml = gcl.leafXmjs !== undefined && gcl.leafXmjs !== null ? ' data-gcl="' + gcl_index + '"': '';
-        gcl_index = gclhtml !== '' ? ++gcl_index : gcl_index;
-        const lid = gcl.leafXmjs !== undefined && gcl.leafXmjs !== null ? gcl.leafXmjs[0].gcl_id : gcl.id;
-        listHtml += '<tr data-lid="' + lid + '"'+ gclhtml +' data-index="' + list_index + '" data-bwmx="">' +
-            '<td>' + list_index + '</td>' +
-            '<td>' + gcl.code + '</td>' +
-            '<td>' + gcl.name + '</td>' +
-            '<td>' + unit + '</td>' +
-            '<td>' + roundnum(unit_price, unitPriceUnit) + '</td>' +
-            '<td>' + quantity + '</td>' +
-            // '<td>' + roundnum(parseFloat(gcl.unit_price).mul(parseFloat(gcl.quantity)), totalPriceUnit) + '</td>' +
-            '</tr>';
-        list_index++;
-    }
-    // // 再加载签约清单
-    // for (const db of dealBillList) {
-    //     const unit = db.unit !== undefined && db.unit !== null ? db.unit : '';
-    //     const quantity = db.quantity !== null && db.quantity !== undefined ? (unit !== '' ? roundnum(db.quantity, findDecimal(db.unit)) : db.quantity) : 0;
-    //     const unit_price = db.unit_price !== null && db.unit_price !== undefined ? db.unit_price : 0;
-    //     listHtml += '<tr data-lid="' + db.id + '" data-index="' + list_index + '" data-bwmx="">' +
-    //         '<td>' + list_index + '</td>' +
-    //         '<td>' + db.code + '</td>' +
-    //         '<td>' + db.name + '</td>' +
-    //         '<td>' + unit + '</td>' +
-    //         '<td>' + roundnum(unit_price, unitPriceUnit) + '</td>' +
-    //         '<td>' + quantity + '</td>' +
-    //         // '<td>' + roundnum(parseFloat(db.unit_price).mul(parseFloat(db.quantity)), totalPriceUnit) + '</td>' +
-    //         '</tr>';
-    //     list_index++;
-    // }
-    $('#table-list-select').html(listHtml);
-    tableDataRemake(changeListData);
-    maketablelist();
+        // 数组去重
+        const dealBillList = result.dealBills;
+        for (const db of gclGatherData) {
+            const exist_index = dealBillList.findIndex(function (item) {
+                return item.code === db.code && item.name === db.name && item.unit === db.unit && item.unit_price === db.unit_price;
+            });
+            if (exist_index !== -1) {
+                dealBillList.splice(exist_index, 1);
+            }
+        }
+        changeListData = gclGatherData.concat(dealBillList).sort(sortByCode);
+        console.log(changeListData);
+        // 先加载台账数据
+        let listHtml = '';
+        let list_index = 1;
+        let gcl_index = 0;
+        for (const gcl of changeListData) {
+            const unit = gcl.unit !== undefined && gcl.unit !== null ? gcl.unit : '';
+            const quantity = gcl.quantity !== null && gcl.quantity !== undefined ? (unit !== '' ? roundnum(gcl.quantity, findDecimal(gcl.unit)) : gcl.quantity) : 0;
+            const unit_price = gcl.unit_price !== null && gcl.unit_price !== undefined ? gcl.unit_price : 0;
+            let gclhtml = gcl.leafXmjs !== undefined && gcl.leafXmjs !== null ? ' data-gcl="' + gcl_index + '"': '';
+            gcl_index = gclhtml !== '' ? ++gcl_index : gcl_index;
+            const lid = gcl.leafXmjs !== undefined && gcl.leafXmjs !== null ? gcl.leafXmjs[0].gcl_id : gcl.id;
+            listHtml += '<tr data-lid="' + lid + '"'+ gclhtml +' data-index="' + list_index + '" data-bwmx="">' +
+                '<td>' + list_index + '</td>' +
+                '<td>' + gcl.code + '</td>' +
+                '<td>' + gcl.name + '</td>' +
+                '<td>' + unit + '</td>' +
+                '<td>' + roundnum(unit_price, unitPriceUnit) + '</td>' +
+                '<td>' + quantity + '</td>' +
+                // '<td>' + roundnum(parseFloat(gcl.unit_price).mul(parseFloat(gcl.quantity)), totalPriceUnit) + '</td>' +
+                '</tr>';
+            list_index++;
+        }
+        // // 再加载签约清单
+        // for (const db of dealBillList) {
+        //     const unit = db.unit !== undefined && db.unit !== null ? db.unit : '';
+        //     const quantity = db.quantity !== null && db.quantity !== undefined ? (unit !== '' ? roundnum(db.quantity, findDecimal(db.unit)) : db.quantity) : 0;
+        //     const unit_price = db.unit_price !== null && db.unit_price !== undefined ? db.unit_price : 0;
+        //     listHtml += '<tr data-lid="' + db.id + '" data-index="' + list_index + '" data-bwmx="">' +
+        //         '<td>' + list_index + '</td>' +
+        //         '<td>' + db.code + '</td>' +
+        //         '<td>' + db.name + '</td>' +
+        //         '<td>' + unit + '</td>' +
+        //         '<td>' + roundnum(unit_price, unitPriceUnit) + '</td>' +
+        //         '<td>' + quantity + '</td>' +
+        //         // '<td>' + roundnum(parseFloat(db.unit_price).mul(parseFloat(db.quantity)), totalPriceUnit) + '</td>' +
+        //         '</tr>';
+        //     list_index++;
+        // }
+        $('#table-list-select').html(listHtml);
+        tableDataRemake(changeListData);
+        maketablelist();
+    });
 
     // 上报时按钮点击
     $('a[data-target="#sub-ap"]').on('click', function () {

+ 45 - 39
app/public/js/stage_gather.js

@@ -42,6 +42,7 @@ function generateChapterHtml(data) {
 }
 
 $(document).ready(function () {
+    const preUrl = window.location.pathname.split('/').slice(0, 6).join('/');
     let per = _.toNumber(getLocalCache('StageGatherOverPercent'));
     if (per && !_.isNaN(per)) {
         $('#over-percent').val(per >= 50 ? (per <= 100 ? per : 100) : 50);
@@ -62,31 +63,7 @@ $(document).ready(function () {
     const leafXmjSpread = SpreadJsObj.createNewSpread($('#leaf-xmj-spread')[0]);
     SpreadJsObj.initSheet(leafXmjSpread.getActiveSheet(), leafXmjSpreadSetting);
 
-    $.subMenu({
-        menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
-        toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
-        key: 'menu.1.0.0',
-        miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',
-        callback: function (info) {
-            if (info.mini) {
-                $('.panel-title').addClass('fluid');
-                $('#sub-menu').removeClass('panel-sidebar');
-            } else {
-                $('.panel-title').removeClass('fluid');
-                $('#sub-menu').addClass('panel-sidebar');
-            }
-            autoFlashHeight();
-            gclSpread.refresh();
-            leafXmjSpread.refresh();
-        }
-    });
-
-    // 解析清单汇总数据
-    gclGatherModel.loadLedgerData(ledger, curLedgerData, preLedgerData);
-    gclGatherModel.loadPosData(pos, curPosData, prePosData);
-    gclGatherModel.loadDealBillsData(dealBills);
-    const gclGatherData = gclGatherModel.gatherGclData();
-    gclGatherModel.checkDiffer(gclGatherData);
+    let gclGatherData;
     // 获取项目节数据
     function loadLeafXmjData(iGclRow) {
         const gcl = gclGatherData[iGclRow];
@@ -112,10 +89,6 @@ $(document).ready(function () {
             }
         }
     }
-    // 加载清单数据
-    checkOverRange(gclGatherData);
-    SpreadJsObj.loadSheetData(gclSpread.getActiveSheet(), SpreadJsObj.DataType.Data, gclGatherData);
-    loadLeafXmjData(0);
     // 切换清单行,读取所属项目节数据
     gclSpread.getActiveSheet().bind(spreadNS.Events.SelectionChanged, function (e, info) {
         const iOldRow = info.oldSelections[0].row, iNewRow = info.newSelections[0].row;
@@ -136,16 +109,30 @@ $(document).ready(function () {
         checkOverRange(gclGatherData);
         SpreadJsObj.reLoadSheetData(gclSpread.getActiveSheet());
     });
-    const chapterData = gclGatherModel.gatherChapterData(chapter, ['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);
-        c.end_qc_tp = ZhCalc.add(c.qc_tp, c.pre_qc_tp);
-        c.end_gather_tp = ZhCalc.add(c.end_contract_tp, c.end_qc_tp);
-        c.end_final_tp = ZhCalc.add(c.end_qc_tp, c.total_price);
-        c.end_final_ratio = ZhCalc.mul(ZhCalc.div(c.end_gather_tp, c.end_final_tp), 100, 2);
-    }
-    generateChapterHtml(chapterData);
+
+    postData(preUrl + '/load', { filter: 'ledger;pos;dealBills' }, function (result) {
+        // 解析清单汇总数据
+        gclGatherModel.loadLedgerData(result.ledgerData);
+        gclGatherModel.loadPosData(result.posData);
+        gclGatherModel.loadDealBillsData(result.dealBills);
+        gclGatherData = gclGatherModel.gatherGclData();
+        gclGatherModel.checkDiffer(gclGatherData);
+        checkOverRange(gclGatherData);
+        // 加载清单数据        
+        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']);
+        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);
+            c.end_qc_tp = ZhCalc.add(c.qc_tp, c.pre_qc_tp);
+            c.end_gather_tp = ZhCalc.add(c.end_contract_tp, c.end_qc_tp);
+            c.end_final_tp = ZhCalc.add(c.end_qc_tp, c.total_price);
+            c.end_final_ratio = ZhCalc.mul(ZhCalc.div(c.end_gather_tp, c.end_final_tp), 100, 2);
+        }
+        generateChapterHtml(chapterData);
+    });
 
     // 展开收起附件
     $('a', '.right-nav').bind('click', function () {
@@ -205,4 +192,23 @@ $(document).ready(function () {
             leafXmjSpread.refresh();
         }
     });
+    // 导航栏
+    $.subMenu({
+        menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
+        toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
+        key: 'menu.1.0.0',
+        miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',
+        callback: function (info) {
+            if (info.mini) {
+                $('.panel-title').addClass('fluid');
+                $('#sub-menu').removeClass('panel-sidebar');
+            } else {
+                $('.panel-title').removeClass('fluid');
+                $('#sub-menu').addClass('panel-sidebar');
+            }
+            autoFlashHeight();
+            gclSpread.refresh();
+            leafXmjSpread.refresh();
+        }
+    });
 });

+ 1 - 4
app/router.js

@@ -96,9 +96,7 @@ module.exports = app => {
     app.post('/tender/:id/ledger/get-children', sessionAuth, tenderCheck, 'ledgerController.getChildren');
     app.post('/tender/:id/ledger/update', sessionAuth, tenderCheck, 'ledgerController.update');
     app.post('/tender/:id/ledger/upload-excel/:ueType', sessionAuth, tenderCheck, 'ledgerController.uploadExcel');
-    //app.post('/tender/:id/ledger/upload-excel', sessionAuth, tenderCheck, 'ledgerController.uploadExcel');
     app.get('/tender/:id/ledger/download/:file', sessionAuth, tenderCheck, 'ledgerController.download');
-    //app.post('/tender/:id/pos', sessionAuth, tenderCheck, 'ledgerController.pos');
     app.post('/tender/:id/pos/update', sessionAuth, tenderCheck, 'ledgerController.posUpdate');
     app.post('/tender/:id/pos/paste', sessionAuth, tenderCheck, 'ledgerController.posPaste');
     // 台账审批相关
@@ -171,8 +169,6 @@ module.exports = app => {
     app.post('/tender/:id/measure/stage/:order/detail/save', sessionAuth, tenderCheck, stageCheck, 'stageController.saveDetailData');
     app.post('/tender/:id/measure/stage/:order/detail/add-img', sessionAuth, tenderCheck, stageCheck, 'stageController.addCalcImage');
     app.post('/tender/:id/measure/stage/:order/detail/merge-img', sessionAuth, tenderCheck, stageCheck, 'stageController.mergeCalcImage');
-    // 其他台账
-    //app.get('/tender/:id/measure/stage/:order/extra', sessionAuth, tenderCheck, stageCheck, 'stageController.extra');
     // 合同支付
     app.get('/tender/:id/measure/stage/:order/pay', sessionAuth, tenderCheck, stageCheck, 'stageController.pay');
     app.post('/tender/:id/measure/stage/:order/pay/detail', sessionAuth, tenderCheck, stageCheck, 'stageController.chapterDetail');
@@ -215,6 +211,7 @@ module.exports = app => {
     app.get('/tender/:id/change/status/:status', sessionAuth, tenderCheck, 'changeController.status');
     app.post('/tender/:id/change/newCode', sessionAuth, tenderCheck, 'changeController.newCode');
     app.post('/tender/:id/change/add', sessionAuth, tenderCheck, 'changeController.add');
+    app.post('/tender/:id/change/defaultBills', sessionAuth, tenderCheck, 'changeController.defaultBills');
     app.get('/tender/:id/change/:cid/info', sessionAuth, tenderCheck, 'changeController.info');
     app.post('/change/upload/file', sessionAuth, 'changeController.uploadFile');
     app.get('/change/download/file/:id', sessionAuth, 'changeController.downloadFile');

+ 0 - 3
app/view/change/info.ejs

@@ -762,9 +762,6 @@
             leftColumns: 6
         }
     }
-    const ledger = JSON.parse('<%- JSON.stringify(ledger) %>');
-    const pos = JSON.parse('<%- JSON.stringify(pos) %>');
-    const dealBillList = JSON.parse('<%- JSON.stringify(dealBillList) %>');
     let back_changeInfo = {
         code: '<%- change.code %>',
         name: '<%- change.name %>',

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

@@ -88,12 +88,5 @@
     const stage = JSON.parse('<%- JSON.stringify(ctx.stage) %>');
     const gclSpreadSetting = JSON.parse('<%- JSON.stringify(gclSpread) %>');
     const leafXmjSpreadSetting = JSON.parse('<%- JSON.stringify(leafXmjSpread) %>');
-    const ledger = JSON.parse('<%- JSON.stringify(ledger) %>');
-    const curLedgerData = JSON.parse('<%- JSON.stringify(curLedgerData) %>');
-    const preLedgerData = JSON.parse('<%- JSON.stringify(preLedgerData) %>');
-    const pos = JSON.parse('<%- JSON.stringify(pos) %>');
-    const curPosData = JSON.parse('<%- JSON.stringify(curPosData) %>');
-    const prePosData = JSON.parse('<%- JSON.stringify(prePosData) %>');
-    const dealBills = JSON.parse('<%- JSON.stringify(dealBills) %>');
     chapter = JSON.parse('<%- JSON.stringify(ctx.tender.info.chapter) %>');
 </script>