瀏覽代碼

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

Tony Kang 1 年之前
父節點
當前提交
5bde43072e

+ 31 - 4
app/controller/settle_controller.js

@@ -47,6 +47,7 @@ module.exports = app => {
                     auditConst: auditConst.settle,
                     auditType: auditConst.auditType,
                 };
+                renderData.jsFiles = this.app.jsFiles.common.concat(this.app.jsFiles.settle.list);
                 renderData.settles = await ctx.service.settle.getValidSettles(ctx.tender.id);
                 for (const s of renderData.settles) {
                     if (s.status === auditConst.settle.status.uncheck) {
@@ -63,7 +64,7 @@ module.exports = app => {
                 renderData.checkedStageCount = await ctx.service.stage.count({ tid: ctx.tender.id, status: auditConst.stage.status.checked });
                 await this.layout('settle/list.ejs', renderData, 'settle/list_modal.ejs');
             } catch (err) {
-                this.log(err);
+                ctx.log(err);
                 ctx.redirect(this.menu.menu.dashboard.url);
             }
         }
@@ -82,7 +83,7 @@ module.exports = app => {
                 await ctx.service.settle.loadAuditViewData(settle);
                 ctx.body = { err: 0, msg: '', data: settle };
             } catch (error) {
-                this.log(error);
+                ctx.log(error);
                 ctx.body = { err: 1, msg: error.toString(), data: null };
             }
         }
@@ -150,7 +151,6 @@ module.exports = app => {
         async _getDefaultRenderData(ctx) {
             const data = {
                 tender: ctx.tender.data,
-                tenderMenu: JSON.parse(JSON.stringify(this.menu.settleMenu)),
                 auditConst: auditConst.settle,
                 measureType,
                 preUrl: '/tender/' + ctx.tender.id + '/settle/' + ctx.params.sorder,
@@ -194,6 +194,7 @@ module.exports = app => {
                 renderData.whiteList = this.ctx.app.config.multipart.whitelist;
                 await this.layout('settle/index.ejs', renderData, 'settle/modal.ejs');
             } catch(err) {
+                console.log(err);
                 ctx.log(err);
                 ctx.redirect('/tender/' + ctx.tender.id + '/settle');
             }
@@ -236,10 +237,36 @@ module.exports = app => {
 
                 ctx.body = responseData;
             } catch (err) {
-                this.log(err);
+                ctx.log(err);
                 ctx.body = { err: 1, msg: err.toString(), data: null };
             }
         }
+
+        async loadGatherData(ctx) {
+            try {
+                const settle = await this.ctx.service.settle.getLatestCompleteSettle(ctx.tender.id);
+                const bills = await this.ctx.service.settleBillsFinal.getDataByCondition({ where: { settle_id: settle.id }});
+                const pos = await this.ctx.service.settlePosFinal.getDataByCondition({ where: { settle_id: settle.id }});
+                ctx.body = { err: 0, msg: '', data: { bills, pos } };
+            } catch(err) {
+                ctx.log(err);
+                ctx.ajaxErrorBody(err, '获取结算汇总数据错误');
+            }
+        }
+
+        async gather(ctx) {
+            try {
+                const renderData = {
+                    tender: ctx.tender.data,
+                    preUrl: `/tender/${ctx.tender.id}/measure/stage`,
+                };
+                renderData.jsFiles = this.app.jsFiles.common.concat(this.app.jsFiles.settle.gather);
+                await this.layout('settle/gather.ejs', renderData, 'settle/gather_modal.ejs');
+            } catch (err) {
+                ctx.log(err);
+                ctx.redirect(this.menu.menu.dashboard.url);
+            }
+        }
     }
 
     return SettleController;

+ 1 - 1
app/middleware/settle_check.js

@@ -16,7 +16,7 @@ module.exports = options => {
      * @param {function} next - 中间件继续执行的方法
      * @return {void}
      */
-    return function* stageCheck(next) {
+    return function* settleCheck(next) {
         try {
             // 读取标段数据
             const settleOrder = parseInt(this.params.sorder);

+ 3 - 11
app/public/js/ledger.js

@@ -563,7 +563,6 @@ $(document).ready(function() {
                 }
                 if (col.field === 'node_type' && newValue && newValue !== '0' && newValue !== '19') {
                     const sameNodeType = sortData.find(x => { return x.node_type == newValue; });
-                    console.log(newValue, sameNodeType);
                     if (sameNodeType) {
                         toastr.error('已存在该费用类别,请勿重复选择');
                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
@@ -598,7 +597,6 @@ $(document).ready(function() {
                 } else {
                     data[col.field] = newValue;
                 }
-                if(col.field === 'node_type') console.log(data);
                 // 更新至服务器
                 postData(window.location.pathname + '/update', {postType: 'update', postData: data}, function (result) {
                     const refreshNode = ledgerTree.loadPostData(result);
@@ -992,11 +990,6 @@ $(document).ready(function() {
                 case 'dgn_qty2':
                     info.cancel = !_.isEmpty(node.b_code);
                     break;
-                case 'node_type':
-                    const parent = tree.getParent(node);
-                    const topParent = tree.getTopParent(node);
-                    info.cancel = !parent || !topParent || [1, 5].indexOf(topParent.node_type) < 0;
-                    break;
             }
         },
         sortCode: function (sheet) {
@@ -1084,7 +1077,7 @@ $(document).ready(function() {
     //     {title: 'full_path', colSpan: '1', rowSpan: '2', field: 'full_path', hAlign: 2, width: 60, type: 'Number', readOnly: true},
     //     {title: 'node_type', colSpan: '1', rowSpan: '2', field: 'node_type', hAlign: 2, width: 60, type: 'Number', readOnly: true}
     // );
-    sjsSettingObj.setNodeTypeCol(ledgerSpreadSetting.cols, [{field: 'node_type'}]);
+    sjsSettingObj.setNodeTypeCol(ledgerSpreadSetting.cols, [{ field: 'node_type' }]);
     SpreadJsObj.initSheet(ledgerSpread.getActiveSheet(), ledgerSpreadSetting);
     SpreadJsObj.selChangedRefreshBackColor(ledgerSpread.getActiveSheet());
     // 绑定事件
@@ -3682,8 +3675,8 @@ $(document).ready(function() {
           toastr.error('附件信息获取失败');
       }
   });
-  // $('body').on('click', '.alllist-table a', handleFileList);
-  $('body').on('click', '#btn-att a', function () {
+    // $('body').on('click', '.alllist-table a', handleFileList);
+    $('body').on('click', '#btn-att a', function () {
       const content = $(this).attr('content');
       const fid = $('#showAttachment').attr('file-id');
       const node = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
@@ -3876,7 +3869,6 @@ $(document).ready(function() {
           // const url = `/tender/${tender.id}/ledger/compresse/file?fileIds=${JSON.stringify(fileIds)}`;
       }
   });
-
   // 监听附件check是否选中
   $('.list-table').on('click', '.check-file', function() {
       const checkedList = $(this).parents('.list-table').children().find('input:checked');

+ 15 - 15
app/public/js/revise.js

@@ -399,21 +399,21 @@ $(document).ready(() => {
                         return;
                     }
                 }
-            } else if (type === 'up-level') {
-                const parent = tree.getParent(node);
-                const children = parent ? parent.children : tree.children;
-                const index = children.indexOf(node);
-                for (let i = index; i < children.length; i++) {
-                    const child = children[index];
-                    if (tree.checkNodeUsed(child, pos)) {
-                        if (i >= index + count) {
-                            toastr.warning('其后节点已计量,选中的节点不可升级');
-                        } else {
-                            toastr.warning('选中的节点已计量,不可升级');
-                        }
-                        return;
-                    }
-                }
+            // } else if (type === 'up-level') {
+            //     const parent = tree.getParent(node);
+            //     const children = parent ? parent.children : tree.children;
+            //     const index = children.indexOf(node);
+            //     for (let i = index; i < children.length; i++) {
+            //         const child = children[index];
+            //         if (tree.checkNodeUsed(child, pos)) {
+            //             if (i >= index + count) {
+            //                 toastr.warning('其后节点已计量,选中的节点不可升级');
+            //             } else {
+            //                 toastr.warning('选中的节点已计量,不可升级');
+            //             }
+            //             return;
+            //         }
+            //     }
             } else if (type === 'down-level') {
                 const parent = tree.getParent(node);
                 const children = parent ? parent.children : tree.children;

+ 5 - 1
app/router.js

@@ -429,6 +429,10 @@ module.exports = app => {
     app.post('/tender/:id/settle/delete', sessionAuth, tenderCheck, uncheckTenderCheck, tenderBuildCheck, 'settleController.delete');
     // 结算期
     app.get('/tender/:id/settle/:sorder', sessionAuth, tenderCheck, uncheckTenderCheck, settleCheck, 'settleController.index');
+    app.post('/tender/:id/settle/:sorder/load', sessionAuth, tenderCheck, uncheckTenderCheck, settleCheck, 'settleController.loadSettleData');
+    // 结算汇总
+    app.get('/tender/:id/settle/gather', sessionAuth, tenderCheck, uncheckTenderCheck, 'settleController.gather');
+    app.get('/tender/:id/settle/gather/load', sessionAuth, tenderCheck, uncheckTenderCheck, 'settleController.loadGatherData');
 
     // 报表
     app.get('/tender/:id/report', sessionAuth, tenderCheck, uncheckTenderCheck, 'reportController.index');
@@ -474,7 +478,7 @@ module.exports = app => {
     app.post('/tender/report_api/updateArchiveEncryption', sessionAuth, 'reportArchiveController.updateReportArchiveEncryption');
     app.post('/tender/report_api/removeArchiveEncryption', sessionAuth, 'reportArchiveController.removeReportArchiveEncryption');
     app.post('/tender/:id/sendReportFileMsg', sessionAuth, tenderCheck, uncheckTenderCheck, 'reportArchiveController.sendFileMsg');
-    app.get('/tender/:id/measure/stage/:order/sendReportFileMsg', sessionAuth, tenderCheck, uncheckTenderCheck, stageCheck, 'reportArchiveController.sendFileMsg');
+    app.post('/tender/:id/measure/stage/:order/sendReportFileMsg', sessionAuth, tenderCheck, uncheckTenderCheck, stageCheck, 'reportArchiveController.sendFileMsg');
 
     // 电子签名
     app.get('/tender/:id/signReport', sessionAuth, tenderCheck, uncheckTenderCheck, 'reportArchiveController.signReport');

+ 4 - 4
app/service/change.js

@@ -267,10 +267,10 @@ module.exports = app => {
                 switch (status) {
                     case 0: // 包含你的所有变更令
                         sql =
-                            'SELECT a.* FROM ?? AS a WHERE a.tid = ? AND ' +
-                            '(a.uid = ? OR (a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times = b.times GROUP BY b.cid))' +
+                            'SELECT a.* FROM ?? AS a WHERE a.tid = ? AND' +
+                            ' (a.uid = ? OR (a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times = b.times GROUP BY b.cid))' +
                             ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times - 1 = b.times GROUP BY b.cid))' +
-                            'OR a.status = ? )' + stateSql;
+                            ' OR a.status = ?)' + stateSql;
                         sqlParam = [
                             this.tableName,
                             tenderId,
@@ -1903,7 +1903,7 @@ module.exports = app => {
                 } else {
                     const lastAuditors = await this.service.changeAudit.getAuditors(change.cid, change.times - 1);
                     const onAuditor = this._.findLast(lastAuditors, { status: auditStatus.back });
-                    if (onAuditor.uid === accountId) {
+                    if (onAuditor && onAuditor.uid === accountId) {
                         change.cancancel = 4;// 审批人撤回退回原报
                     }
                 }

+ 2 - 2
app/service/payment_safe_bills.js

@@ -533,8 +533,8 @@ module.exports = app => {
                     nd.unit_price = calcUp ? this.ctx.helper.round(cd.unit_price, decimal.up) : cd.unit_price;
                     nd.cur_qty = calcQty ? this.ctx.helper.round(cd.cur_qty, decimal.qty) : cd.cur_qty;
                     nd.cur_tp = this.ctx.helper.mul(nd.unit_price, nd.cur_qty, decimal.tp);
-                    nd.end_qty = this.ctx.helper.add(nd.pre_qty, nd.cur_qty);
-                    nd.end_tp = this.ctx.helper.add(nd.pre_tp, nd.cur_tp);
+                    nd.end_qty = this.ctx.helper.add(cd.pre_qty, nd.cur_qty);
+                    nd.end_tp = this.ctx.helper.add(cd.pre_tp, nd.cur_tp);
                     updateData.push(nd);
                 }
             }

+ 9 - 0
app/service/settle.js

@@ -45,6 +45,15 @@ module.exports = app => {
             return settles;
         }
 
+        async getLatestCompleteSettle(tenderId) {
+            const settles = await this.getAllDataByCondition({
+                where: { tid: tenderId, status: auditConst.settle.status.checked },
+                order: [['settle_order', 'desc']],
+                limit: 1, offset: 0
+            });
+            return settles[0];
+        }
+
         /**
          * 新增结算期
          * @param tenderId - 标段id

+ 2 - 2
app/view/settle/list.ejs

@@ -1,8 +1,8 @@
-<% include ../tender/tender_sub_menu.ejs %>
+<% include ./list_menu.ejs %>
 <div class="panel-content">
     <div class="panel-title">
         <div class="title-main d-flex">
-            <% include ../tender/tender_sub_mini_menu.ejs %>
+            <% include ./list_mini_menu.ejs %>
             <h2>
                 结算期列表
             </h2>

+ 14 - 0
app/view/settle/list_menu.ejs

@@ -0,0 +1,14 @@
+<div class="panel-sidebar" id="sub-menu">
+    <div class="sidebar-title" data-toggle="tooltip" data-placement="right" data-original-title="<%- ctx.tender.data.name %>">
+        <%- (ctx.tender.data.name.length > 15 ? ctx.tender.data.name.substring(0,15) + '...' : ctx.tender.data.name) %>
+    </div>
+    <div class="scrollbar-auto">
+        <% include ./list_menu_list.ejs %>
+        <div class="side-fold"><a href="javascript: void(0)" data-toggle="tooltip" data-placement="top" data-original-title="折叠侧栏" id="to-mini-menu"><i class="fa fa-upload fa-rotate-270"></i></a></div>
+    </div>
+    <script>
+        new Vue({
+            el: '.scrollbar-auto',
+        });
+    </script>
+</div>

+ 3 - 0
app/view/settle/list_menu_list.ejs

@@ -0,0 +1,3 @@
+<nav-menu title="返回" url="/tender/<%= ctx.tender.id %>/measure/stage" tclass="text-primary" ml="1" icon="fa-chevron-left"></nav-menu>
+<nav-menu title="结算列表" url="/tender/<%= ctx.tender.id %>/settle" ml="3" active="<%= (ctx.url.indexOf('gather') < 0 ? 1 : -1) %>"></nav-menu>
+<nav-menu title="汇总台账" url="/tender/<%= ctx.tender.id %>/settle/gather" ml="3" active="<%= (ctx.url.indexOf('gather') > 0 ? 1 : -1) %>"></nav-menu>

+ 16 - 0
app/view/settle/list_mini_menu.ejs

@@ -0,0 +1,16 @@
+<!--折起的菜单-->
+<div class="min-side" id="sub-mini-menu" style="display: none;">
+    <div id="sub-mini-hint" class="side-switch" data-container="body" data-toggle="popover" data-placement="bottom" data-content="这里打开收起的菜单栏"></div>
+    <div class="side-switch">
+        <i class="fa fa-bars"></i>
+    </div>
+    <div class="side-menu" id="mini-menu-list" style="display: none">
+        <% include ./list_menu_list.ejs %>
+        <div class="side-fold"><a href="javascript: void(0);" data-toggle="tooltip" data-placement="top" data-original-title="展开侧栏" id="to-menu"><i class="fa fa-upload fa-rotate-90"></i></a></div>
+    </div>
+</div>
+<script>
+    new Vue({
+        el: '.side-menu',
+    });
+</script>

+ 14 - 0
app/view/settle/settle_menu.ejs

@@ -0,0 +1,14 @@
+<div class="panel-sidebar" id="sub-menu">
+    <div class="sidebar-title" data-toggle="tooltip" data-placement="right" data-original-title="第<%- ctx.stage.order%>期 - 关联台账">
+        关联台账
+    </div>
+    <div class="scrollbar-auto">
+        <% include ./settle_menu_list.ejs %>
+        <div class="side-fold"><a href="javascript: void(0)" data-toggle="tooltip" data-placement="top" data-original-title="折叠侧栏" id="to-mini-menu"><i class="fa fa-upload fa-rotate-270"></i></a></div>
+    </div>
+    <script>
+        new Vue({
+            el: '.scrollbar-auto',
+        });
+    </script>
+</div>

+ 3 - 0
app/view/settle/settle_menu_list.ejs

@@ -0,0 +1,3 @@
+<nav-menu title="返回" url="/tender/<%= ctx.tender.id %>/settle" tclass="text-primary" ml="1" icon="fa-chevron-left"></nav-menu>
+<nav-menu title="结算列表" url="/tender/<%= ctx.tender.id %>/settle/<%= ctx.settle.settle_order%>" ml="3" active="<%= (ctx.url.indexOf(ctx.settle.settle.order) > 0 ? 1 : -1) %>"></nav-menu>
+<nav-menu title="汇总台账" url="/tender/<%= ctx.tender.id %>/settle/gather" ml="3" active="<%= (ctx.url.indexOf('gather') > 0 ? 1 : -1) %>"></nav-menu>

+ 16 - 0
app/view/settle/settle_mini_menu.ejs

@@ -0,0 +1,16 @@
+<!--折起的菜单-->
+<div class="min-side" id="sub-mini-menu" style="display: none;">
+    <div id="sub-mini-hint" class="side-switch" data-container="body" data-toggle="popover" data-placement="bottom" data-content="这里打开收起的菜单栏"></div>
+    <div class="side-switch">
+        <i class="fa fa-bars"></i>
+    </div>
+    <div class="side-menu" id="mini-menu-list" style="display: none">
+        <% include ./settle_menu_list.ejs %>
+        <div class="side-fold"><a href="javascript: void(0);" data-toggle="tooltip" data-placement="top" data-original-title="展开侧栏" id="to-menu"><i class="fa fa-upload fa-rotate-90"></i></a></div>
+    </div>
+</div>
+<script>
+    new Vue({
+        el: '.side-menu',
+    });
+</script>

+ 10 - 0
config/web.js

@@ -1337,6 +1337,16 @@ const JsFiles = {
                 mergeFile: 'setting_manage',
             },
         },
+        settle: {
+            list: {
+                files: [],
+                mergeFiles: [
+                    '/public/js/component/menu.js',
+                    '/public/js/sub_menu.js',
+                ],
+                mergeFile: 'settle_list',
+            },
+        }
     },
 };
 

+ 14 - 2
db_script/test_query.js

@@ -11,17 +11,29 @@ const saveJSON = async function(obj, file) {
 };
 
 const loadReportArchiveData = async function() {
-    const tid = 4417, sOrder = 2;
+    //const tid = 4417, sOrder = 2;
+    const tid = 3698, sOrder = 7;
     const stage = await querySql('SELECT * FROM zh_stage where tid = ? and `order` = ?', [tid, sOrder]);
     const rptArchive = await querySql('SELECT * FROM zh_rpt_archive where stage_id = ?', [stage[0].id]);
     for (const ra of rptArchive) {
         ra.content = ra.content ? JSON.parse(ra.content) : [];
         console.log(BaseUtil.getFileName('rptArchive.json'));
         await saveJSON(ra, BaseUtil.getFileName('rptArchive.json'));
+
+        const roleContent = [];
+        for (const c of ra.content) {
+            console.log(c.rpt_id, stage[0].id);
+            const rptRole = await querySql('SELECT * FROM zh_role_rpt_rel WHERE sid = ? and rpt_id = ?', [stage[0].id, c.rpt_id]);
+            if (rptRole.length > 0) {
+                if (rptRole[0].rel_content) roleContent.push(JSON.stringify(rptRole[0].rel_content));
+            }
+        }
+        await saveJSON(roleContent, BaseUtil.getFileName('roleContent.json'));
     }
-    const rptSign = await querySql('SELECT* FROM zh_rpt_archive_encryption where stage_id = ?', [stage[0].id]);
+    const rptSign = await querySql('SELECT * FROM zh_rpt_archive_encryption where stage_id = ?', [stage[0].id]);
     for (const rs of rptSign) {
         rs.content = rs.content ? JSON.parse(rs.content) : [];
+        console.log(BaseUtil.getFileName('rptSign.json'));
         await saveJSON(rs, BaseUtil.getFileName('rptSign.json'));
     }
 };

+ 13 - 0
publish.md

@@ -10,6 +10,19 @@
 ##特殊操作
 如果没有特殊说明,则在第默认操作的第3步前,执行相关脚本,如果有特殊要求,需特别说明
 
+
+### V3.5.xx 2023-12-15 update
+#### uat
+```shell
+$ cd db_script
+$ node change_bills uat
+```
+#### prod
+```shell
+$ cd db_script
+$ node change_bills default
+```
+
 ### V3.5.35
 #### uat
 ```shell