Browse Source

输出报表展示调差和未完成的预付款入口

ellisran 10 months ago
parent
commit
8dbd263cda

+ 8 - 0
app/controller/report_archive_controller.js

@@ -19,6 +19,7 @@ const sendToWormhole = require('stream-wormhole');
 const pushOperate = require('../const/spec_3f').pushOperate;
 const sourceTypeConst = require('../const/source_type');
 const rptArchiveConst = require('../const/rpt_archive');
+const advanceConst = require('../const/advance');
 
 module.exports = app => {
     class ReportArchiveController extends app.BaseController {
@@ -136,6 +137,7 @@ module.exports = app => {
                 isAdmin,
                 needFileMsg,
                 auditType: auditConst.auditType,
+                advanceConst,
             };
             if (stage_id === -1) {
                 await this.layout('report/index_archive.ejs', renderData, 'report/archive_popup.ejs');
@@ -213,6 +215,12 @@ module.exports = app => {
                     case 'change_plan':
                         changes = await ctx.service.changePlan.getListByArchives(tenderId, ctx.helper._.map(allArchives, 'business_id'));
                         break;
+                    case 'advance':
+                        changes = await ctx.service.advance.getListByArchives(tenderId, ctx.helper._.map(allArchives, 'business_id'));
+                        break;
+                    case 'material':
+                        changes = await ctx.service.material.getListByArchives(tenderId, ctx.helper._.map(allArchives, 'business_id'));
+                        break;
                     default: break;
                 }
                 postBody.changes = changes;

+ 1 - 1
app/controller/report_controller.js

@@ -348,7 +348,7 @@ module.exports = app => {
                     source_type: 1,
                     bglObj: 'null',
                     changes: 'null',
-
+                    advanceConst,
                 };
                 await this.layout('report/index.ejs', renderData, 'report/rpt_all_popup.ejs');
                 // await this.layout('report/index.ejs', renderData);

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

@@ -2017,10 +2017,10 @@ $(document).ready(() => {
         }
     });
 
-    $('#set-site-btn').click(function () {
+    $('#set-site-btn').click(async function () {
         if (changeOrder) {
             const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
-            postDataAsync(window.location.pathname + '/save', { type:'order_site', listid: select ? select.id : null }, function (result) {
+            await postDataAsync(window.location.pathname + '/save', { type:'order_site', listid: select ? select.id : null }, function (result) {
             });
         }
         window.location.href = window.location.pathname + '/revise';

+ 10 - 0
app/service/advance.js

@@ -266,6 +266,16 @@ module.exports = app => {
                 throw err;
             }
         }
+
+        async getListByArchives(tid, ids) {
+            if (ids.length === 0) return [];
+            const sql = 'SELECT c.* FROM ?? as c LEFT JOIN (SELECT vid, MAX(end_time) as end_time FROM ?? WHERE ' +
+                'tid = ? AND vid in (' + this.ctx.helper.getInArrStrSqlFilter(ids) + ') GROUP BY vid) as ca ON c.id = ca.vid WHERE' +
+                ' c.tid = ? AND c.id in (' + this.ctx.helper.getInArrStrSqlFilter(ids) + ') AND c.status = ? ORDER BY ca.end_time DESC';
+            const params = [this.tableName, this.ctx.service.advanceAudit.tableName, tid, tid, auditConst.status.checked];
+            const list = await this.db.query(sql, params);
+            return list;
+        }
     }
     return Advance;
 };

+ 10 - 0
app/service/material.js

@@ -511,6 +511,16 @@ module.exports = app => {
                 return false;
             }
         }
+
+        async getListByArchives(tid, ids) {
+            if (ids.length === 0) return [];
+            const sql = 'SELECT c.* FROM ?? as c LEFT JOIN (SELECT mid, MAX(end_time) as end_time FROM ?? WHERE ' +
+                'tid = ? AND mid in (' + this.ctx.helper.getInArrStrSqlFilter(ids) + ') GROUP BY mid) as ca ON c.id = ca.mid WHERE' +
+                ' c.tid = ? AND c.id in (' + this.ctx.helper.getInArrStrSqlFilter(ids) + ') AND c.status = ? ORDER BY ca.end_time DESC';
+            const params = [this.tableName, this.ctx.service.materialAudit.tableName, tid, tid, auditConst.status.checked];
+            const list = await this.db.query(sql, params);
+            return list;
+        }
     }
 
     return Material;

+ 191 - 2
app/view/report/index_archive.ejs

@@ -26,6 +26,8 @@
                             <a class="dropdown-item" href="javascript:void(0);" data-type="change_project">变更立项</a>
                             <a class="dropdown-item" href="javascript:void(0);" data-type="change_apply">变更申请</a>
                             <a class="dropdown-item" href="javascript:void(0);" data-type="change_plan">变更方案</a>
+                            <a class="dropdown-item" href="javascript:void(0);" data-type="advance">预付款</a>
+                            <a class="dropdown-item" href="javascript:void(0);" data-type="material">材料调差</a>
                         </div>
                     </div>
                 </div>
@@ -71,7 +73,7 @@
                             padding: 0.175rem 0.5rem;
                         }
                     </style>
-                    <div id="divSelectableChanges" class="" style="display: none;">
+                    <div id="divSelectableChanges" class="" style="display: none;min-width: 90px;">
                         <select id="optionSelectableChanges" class="form-control form-control-sm"></select>
                     </div>
 <!--                    <div class="dropdown" id="divSelectableChanges" style="display: none">-->
@@ -79,6 +81,28 @@
 <!--                        <div class="dropdown-menu" aria-labelledby="dropdownMenuButton" id="optionSelectableChanges"></div>-->
 <!--                    </div>-->
                 </div>
+                <div class="d-inline-block">
+                    <div class="dropdown" style="display: none" id="divSelectableAdvances">
+                        <button class="btn btn-sm btn-light dropdown-toggle text-primary" type="button" id="btnCurrentAdvance" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><%- advanceConst.typeCol[0].name %></button>
+                        <div class="dropdown-menu" aria-labelledby="allPrepayButton" id="optionSelectableAdvances">
+                            <% for (const type of advanceConst.typeCol) { %>
+                            <a class="dropdown-item" href="javascript:void(0);" data-type="<%- type.key %>" <% if (type.value === 0) { %>style="display: none"<% } %>><%- type.name %></a>
+                            <% } %>
+                        </div>
+                    </div>
+                </div>
+                <div class="d-inline-block">
+                    <div class="dropdown" id="divSelectableAdvancePays" style="display:none;">
+                        <button class="btn btn-sm btn-light dropdown-toggle text-primary" type="button" id="btnCurrentAdvancePay" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>
+                        <div class="dropdown-menu" aria-labelledby="dropdownMenuButton" id="optionSelectableAdvancePays"></div>
+                    </div>
+                </div>
+                <div class="d-inline-block">
+                    <div class="dropdown" id="divSelectableMaterials" style="display:none;">
+                        <button class="btn btn-sm btn-light dropdown-toggle text-primary" type="button" id="btnCurrentMaterial" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>
+                        <div class="dropdown-menu" aria-labelledby="dropdownMenuButton" id="optionSelectableMaterials"></div>
+                    </div>
+                </div>
                 <% if (ctx.session.sessionUser.accountId === ctx.tender.data.user_id) { %>
                 <div class="d-inline-block">
                     <button id="file-msg" class="btn btn-sm btn-primary" type="button" onclick="sendReportFileMsg();" <% if (!needFileMsg.stage.valid) { %>style="display: none;"<% } %>>同步档案系统</button>
@@ -246,6 +270,11 @@
     let business_type = 'stage';
     let CHANGE_LIST = [], current_change_id = -1, current_change_code = '';
     let CHANGE_ID = -1, BUSINESS_ID = -1;
+    let current_advance_id = -1;  // 预付款期id
+    let current_material_id = -1; // 材差期id
+    let current_material_order = -1; // 材差期order
+    let ADVANCE_LIST = [];
+    let MATERIAL_LIST = [];
 
     const FOLDER_SEPERATER = '->';
 
@@ -397,6 +426,44 @@
         // }
     }
 
+    function buildAdvancePaySelection(adList) {
+        $("#optionSelectableAdvancePays").empty();
+        $("#btnCurrentAdvancePay")[0].innerText = '';
+        let hasMatch = false;
+        if (current_advance_id !== -1) {}
+        for (const advance of adList) {
+            if (current_advance_id === advance.id) {
+                hasMatch = true; // 预付款有好几种类型,需要考虑不同类型的转换检测
+                break;
+            }
+        }
+        adList.forEach((advance, adIndex) => {
+            let dispStr = '';
+            if (!hasMatch && adIndex === 0 || current_advance_id === advance.id) {
+                current_advance_id = advance.id;
+                $("#btnCurrentAdvancePay")[0].innerText = `第${adIndex + 1}期`;
+                dispStr = ';display:none';
+            }
+            const str = `<a class="dropdown-item" style="cursor:pointer${dispStr}" onclick="changeCurrentAdvance(this)" advance_id = "${advance.id}">第${adIndex + 1}期</a>`;
+            $("#optionSelectableAdvancePays").append(str);
+        });
+    }
+
+    function buildMaterialSelection() {
+        $("#optionSelectableMaterials").empty();
+        $("#btnCurrentMaterial")[0].innerText = '';
+        MATERIAL_LIST.forEach((materialAdj, maIndex) => {
+            let dispStr = '';
+            if (current_material_id === -1 && maIndex === 0 || current_material_id === materialAdj.id) {
+                current_material_id = materialAdj.id;
+                $("#btnCurrentMaterial")[0].innerText = `第${materialAdj.order}期`;
+                dispStr = ';display:none';
+            }
+            const str = `<a class="dropdown-item" style="cursor:pointer${dispStr}" onclick="changeCurrentMaterial(this)" material_id = "${materialAdj.id}">第${materialAdj.order}期</a>`;
+            $("#optionSelectableMaterials").append(str);
+        });
+    }
+
     function changeCurrentStage(ele) {
         // alert('you are selecting: ' + ele.innerText);
         current_stage_order = parseInt(ele.attributes.stg_order.value);
@@ -461,6 +528,33 @@
         );
     }
 
+    function changeCurrentMaterial(ele) {
+        $('#optionSelectableMaterials a').show();
+        $(ele).hide();
+        current_material_id = +ele.attributes[3].value;
+        $('#optionSelectableMaterials').siblings('button').text($(ele).text());
+        // BUSINESS_ID = material_id;
+        buildMaterialSelection();
+        //还有必要触发归档报表刷新!
+        //rptArchiveObj.onClick(null, null, rptArchiveObj.currentNode);
+        const params = {tenderId: TENDER_ID, business_type, bzId: current_material_id};
+        $.bootstrapLoading.start();
+        CommonAjax.postXsrfEx("/tender/report_api/getReportArchive4bz", params, 10000, true, getCookie('csrfToken_j'),
+            function(result){
+                $.bootstrapLoading.end();
+                ARCHIVE_LIST = result.data;
+                ARCHIVE_ENCRYPTION_LIST = result.encryptionData;
+                TOP_TREE_NODES = JSON.parse(JSON.stringify(result.rpt_tpl_data));
+                buildTplTree();
+                rptArchiveObj.iniPage();
+            }, function(err){
+                $.bootstrapLoading.end();
+            }, function(ex){
+                $.bootstrapLoading.end();
+            }
+        );
+    }
+
 
     function sendReportFileMsg() {
         if (!needFileMsg[business_type] || !needFileMsg[business_type].valid) return;
@@ -538,6 +632,27 @@
             }
         });
 
+        function advancePayClick(ele = null) {
+            $('#optionSelectableAdvances a').show();
+            const thisEle = ele === null ? this : ele;
+            $(thisEle).hide();
+            $('#optionSelectableAdvances').siblings('button').text($(thisEle).text());
+            const type = $(thisEle).data('type');
+            const typeStr = ['start', 'material', 'safe', 'dust'];
+            const tIdx = typeStr.indexOf(type)
+            const adList = [];
+            ADVANCE_LIST.forEach(advance => {
+                if (advance.type === tIdx) {
+                    adList.push(advance);
+                }
+            });
+            buildAdvancePaySelection(adList);
+        }
+
+        $('#optionSelectableAdvances a').on('click', function (){
+            advancePayClick(this);
+        });
+
         $('#select-item a').on('click', function () {
            $('#select-item a').show();
            $(this).hide();
@@ -549,6 +664,9 @@
            if (type === 'stage') {
                $('#divSelectableStages').show();
                $('#divSelectableChanges').hide();
+               $('#divSelectableAdvances').hide();
+               $('#divSelectableAdvancePays').hide();
+               $('#divSelectableMaterials').hide();
                // const info = _.find(STAGE_LIST, { order: current_stage_order });
                for (let i = STAGE_LIST.length; i > 0; i--) {
                    if (parseInt(STAGE_LIST[i - 1].status) === 3) {
@@ -580,9 +698,12 @@
                        $.bootstrapLoading.end();
                    }
                );
-           } else {
+           } else if (_.indexOf(type, 'change') !== -1) {
                $('#divSelectableStages').hide();
+               $('#divSelectableAdvances').hide();
+               $('#divSelectableAdvancePays').hide();
                $('#divSelectableChanges').show();
+               $('#divSelectableMaterials').hide();
                // 下列树结构重新加载
                //rptArchiveObj.onClick(null, null, rptArchiveObj.currentNode);
                const params = {tenderId: TENDER_ID, business_type: type};
@@ -613,6 +734,74 @@
                        $.bootstrapLoading.end();
                    }
                );
+           } else if (type === 'advance') {
+               $('#divSelectableStages').hide();
+               $('#divSelectableChanges').hide();
+               $('#divSelectableAdvances').show();
+               $('#divSelectableAdvancePays').show();
+               $('#divSelectableMaterials').hide();
+               // 下列树结构重新加载
+               //rptArchiveObj.onClick(null, null, rptArchiveObj.currentNode);
+               const params = {tenderId: TENDER_ID, business_type: type};
+               $.bootstrapLoading.start();
+               // ARCHIVE_LIST = [];
+               // ARCHIVE_ENCRYPTION_LIST = [];
+               // TOP_TREE_NODES = JSON.parse(JSON.stringify(ORG_TOP_TREE_NODES));
+               // rptArchiveObj.iniPage();
+               CommonAjax.postXsrfEx("/tender/report_api/getReportArchive4bz", params, 10000, true, getCookie('csrfToken_j'),
+                   function(result){
+                       $.bootstrapLoading.end();
+                       // console.log(result);
+                       ARCHIVE_LIST = result.data;
+                       ARCHIVE_ENCRYPTION_LIST = result.encryptionData;
+                       ADVANCE_LIST = result.changes;
+                       current_advance_id = ADVANCE_LIST.length > 0 ? ADVANCE_LIST[0].id : -1;
+                       TOP_TREE_NODES = JSON.parse(JSON.stringify(result.rpt_tpl_data));
+                       BUSINESS_ID = ADVANCE_LIST.length > 0 ? ADVANCE_LIST[0].id : -1;
+                       advancePayClick( $('#optionSelectableAdvances a')[0]);
+                       buildTplTree();
+                       rptArchiveObj.iniPage();
+                       current_stage_id = result.stgId;
+                   }, function(err){
+                       $.bootstrapLoading.end();
+                   }, function(ex){
+                       $.bootstrapLoading.end();
+                   }
+               );
+           } else if (type === 'material') {
+               $('#divSelectableStages').hide();
+               $('#divSelectableChanges').hide();
+               $('#divSelectableAdvances').hide();
+               $('#divSelectableAdvancePays').hide();
+               $('#divSelectableMaterials').show();
+               // 下列树结构重新加载
+               //rptArchiveObj.onClick(null, null, rptArchiveObj.currentNode);
+               const params = {tenderId: TENDER_ID, business_type: type};
+               $.bootstrapLoading.start();
+               // ARCHIVE_LIST = [];
+               // ARCHIVE_ENCRYPTION_LIST = [];
+               // TOP_TREE_NODES = JSON.parse(JSON.stringify(ORG_TOP_TREE_NODES));
+               // rptArchiveObj.iniPage();
+               CommonAjax.postXsrfEx("/tender/report_api/getReportArchive4bz", params, 10000, true, getCookie('csrfToken_j'),
+                   function(result){
+                       $.bootstrapLoading.end();
+                       // console.log(result);
+                       ARCHIVE_LIST = result.data;
+                       ARCHIVE_ENCRYPTION_LIST = result.encryptionData;
+                       MATERIAL_LIST = result.changes;
+                       current_material_id = MATERIAL_LIST.length > 0 ? MATERIAL_LIST[0].id : -1;
+                       TOP_TREE_NODES = JSON.parse(JSON.stringify(result.rpt_tpl_data));
+                       // BUSINESS_ID = MATERIAL_LIST.length > 0 ? MATERIAL_LIST[0].id : -1;
+                       buildMaterialSelection();
+                       buildTplTree();
+                       rptArchiveObj.iniPage();
+                       current_stage_id = result.stgId;
+                   }, function(err){
+                       $.bootstrapLoading.end();
+                   }, function(ex){
+                       $.bootstrapLoading.end();
+                   }
+               );
            }
            if (needFileMsg[type] && needFileMsg[type].valid) {
                $('#file-msg').show();