소스 검색

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

MaiXinRong 3 년 전
부모
커밋
947c21cbfc

+ 46 - 2
app/controller/datacollect_controller.js

@@ -46,8 +46,9 @@ module.exports = app => {
         async index(ctx) {
             try {
                 // 获取标段审批信息
-                const noticeList = await ctx.service.noticePush.getNotice(ctx.session.sessionProject.id);
-                console.log(noticeList);
+                const tenderidList = [];
+                console.log(ctx.session.sessionProject.dataCollect);
+                const noticeList = await ctx.service.noticePush.getNoticeByDataCollect(ctx.session.sessionProject.id, tenderidList);
                 const renderData = {
                     noticeList,
                     acLedger: auditConst.ledger,
@@ -65,6 +66,49 @@ module.exports = app => {
                 ctx.redirect(this.menu.menu.dashboard.url);
             }
         }
+
+        async loadData(ctx) {
+            try {
+                const responseData = { err: 0, msg: '', data: {} };
+                // const tenderidList = [];
+                // const noticeList = await ctx.service.noticePush.getNoticeByDataCollect(ctx.session.sessionProject.id, tenderidList);
+                const tenderList = await ctx.service.tender.getList('', null, 1);
+                const thisMonth = new Date();
+                const [startMonth, endMonth] = ctx.helper.getStartEndMonth(thisMonth);
+                for (const t of tenderList) {
+                    const tenderInfo = await ctx.service.tenderInfo.getTenderInfo(t.id);
+                    t.contract_price = tenderInfo.deal_param.contractPrice;
+
+                    if (t.ledger_status === auditConst.ledger.status.checkNo || t.ledger_status === auditConst.ledger.status.uncheck) {
+                        const sum = await ctx.service.ledger.addUp({ tender_id: t.id/* , is_leaf: true*/ });
+                        t.total_price = sum.total_price;
+                        t.deal_tp = sum.deal_tp;
+                    }
+                    t.advance_tp = await ctx.service.advance.getSumAdvance(t.id);
+
+                    if (t.ledger_status === auditConst.ledger.status.checked) {
+                        t.lastStage = await ctx.service.stage.getLastestStage(t.id, true);
+                        if (t.lastStage && t.lastStage.status === auditConst.stage.status.uncheck &&
+                            t.lastStage.user_id !== ctx.session.sessionUser.accountId) {
+                            t.lastStage = await ctx.service.stage.getLastestStage(t.id);
+                        }
+                        if (t.lastStage) await ctx.service.stage.checkStageGatherData(t.lastStage);
+                        t.completeStage = await ctx.service.stage.getLastestCompleteStage(t.id);
+                    }
+                    t.material_tp = await ctx.service.material.getSumMaterial(t.id);
+                    // 获取本标段 本月计量期审批通过数目,变更令审批通过数目,台账修订通过数目,材料调差通过数目
+                    t.month_stage_num = await this.ctx.service.stageAudit.getNumByMonth(t.id, startMonth, endMonth);
+                    t.month_change_num = await this.ctx.service.changeAudit.getNumByMonth(t.id, startMonth, endMonth);
+                    t.month_revise_num = await this.ctx.service.reviseAudit.getNumByMonth(t.id, startMonth, endMonth);
+                    t.month_material_num = await this.ctx.service.materialAudit.getNumByMonth(t.id, startMonth, endMonth);
+                }
+                responseData.data.tenderList = tenderList;
+                ctx.body = responseData;
+            } catch (err) {
+                this.log(err);
+                ctx.body = { err: 1, msg: err.toString(), data: null };
+            }
+        }
     }
 
     return DatacollectController;

+ 4 - 0
app/controller/material_controller.js

@@ -367,6 +367,8 @@ module.exports = app => {
 
                 renderData.materialType = JSON.stringify(materialConst);
                 renderData.jsFiles = this.app.jsFiles.common.concat(this.app.jsFiles.material.info);
+                // 判断之前期有无调用过材料税
+                renderData.old_had_tax = await ctx.service.material.getOldMaterialTax(ctx.tender.id, ctx.params.order);
                 await this.layout('material/info.ejs', renderData, 'material/info_modal.ejs');
             } catch (err) {
                 this.log(err);
@@ -504,6 +506,8 @@ module.exports = app => {
                 renderData.ex_pre_tp_hs = await ctx.service.material.getExPreTpHs(ctx.tender.id, ctx.material.order);
                 renderData.materialType = materialConst;
                 renderData.jsFiles = this.app.jsFiles.common.concat(this.app.jsFiles.material.exponent);
+                // 判断之前期有无调用过材料税
+                renderData.old_had_tax = await ctx.service.material.getOldMaterialTax(ctx.tender.id, ctx.params.order);
                 await this.layout('material/exponent.ejs', renderData, 'material/exponent_modal.ejs');
             } catch (err) {
                 this.log(err);

+ 9 - 0
app/extend/helper.js

@@ -1430,4 +1430,13 @@ module.exports = {
         }
         return result.content;
     },
+
+    getStartEndMonth(month) {
+        // month = new Date('2021-10-03');
+        // const startMonth = new Date(month.getFullYear(), month.getMonth(), 1);
+        // const endMonth = new Date(month.getFullYear(), month.getMonth() + 1, 1);
+        const startMonth = moment(month).startOf('month').format('YYYY-MM-DD HH:mm:ss');
+        const endMonth = moment(month).endOf('month').format('YYYY-MM-DD HH:mm:ss');
+        return [startMonth, endMonth];
+    },
 };

BIN
app/public/images/juecedaping01.png


BIN
app/public/images/juecedaping02.png


BIN
app/public/images/juecedaping03.png


BIN
app/public/images/juecedaping04.png


+ 59 - 0
app/public/js/datacollect_scroll.js

@@ -30,3 +30,62 @@ function rollStart() {
         ulbox.scrollTop++;
     }
 }
+
+// tableScroll('tableId', '100%', 30, 10);
+var MyMarhq;
+function tableScroll(tableid, hei, speed, len) {
+    clearTimeout(MyMarhq);
+    $('#' + tableid).parent().find('.tableid_').remove()
+    $('#' + tableid).parent().prepend(
+        '<table class="tableid_"><thead>' + $('#' + tableid + ' thead').html() + '</thead></table>'
+    ).css({
+        'position': 'relative',
+        'overflow': 'hidden',
+        'height': hei + 'px'
+    })
+    $(".tableid_").find('th').each(function(i) {
+        $(this).css('width', $('#' + tableid).find('th:eq(' + i + ')').width());
+    });
+    $(".tableid_").css({
+        'position': 'absolute',
+        'top': 0,
+        'left': 0,
+        'z-index': 9
+    })
+    $('#' + tableid).css({
+        'position': 'absolute',
+        'top': 0,
+        'left': 0,
+        'z-index': 1
+    })
+
+    if ($('#' + tableid).find('tbody tr').length > len) {
+        $('#' + tableid).find('tbody').html($('#' + tableid).find('tbody').html() + $('#' + tableid).find('tbody').html());
+        $(".tableid_").css('top', 0);
+        $('#' + tableid).css('top', 0);
+        var tblTop = 0;
+        var outerHeight = $('#' + tableid).find('tbody').find("tr").outerHeight();
+        function Marqueehq() {
+            if (tblTop <= -outerHeight * $('#' + tableid).find('tbody').find("tr").length) {
+                tblTop = 0;
+            } else {
+                tblTop -= 1;
+            }
+            $('#' + tableid).css('margin-top', tblTop + 'px');
+            clearTimeout(MyMarhq);
+            MyMarhq = setTimeout(function() {
+                Marqueehq()
+            }, speed);
+        }
+
+        MyMarhq = setTimeout(Marqueehq, speed);
+        $('#' + tableid).find('tbody').hover(function() {
+            clearTimeout(MyMarhq);
+        }, function() {
+            clearTimeout(MyMarhq);
+            if ($('#' + tableid).find('tbody tr').length > len) {
+                MyMarhq = setTimeout(Marqueehq, speed);
+            }
+        })
+    }
+};

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

@@ -121,7 +121,7 @@ $(document).ready(() => {
         {title: '工料分类', colSpan: '1', rowSpan: '2', field: 'm_type', hAlign: 1, width: 60, readOnly: 'readOnly.isEdit', cellType: 'customizeCombo', comboItems: materialType.m_type, cellTypeKey: 2},
     ];
     if (materialTax) {
-        materialSpreadSettingCols.push({title: '税率', colSpan: '1', rowSpan: '2', field: 'm_tax', hAlign: 2, width: 50, type: 'Number', readOnly: 'readOnly.isEdit'});
+        materialSpreadSettingCols.push({title: '税率(%)', colSpan: '1', rowSpan: '2', field: 'm_tax', hAlign: 2, width: 50, type: 'Number', readOnly: 'readOnly.isEdit'});
     }
     materialSpreadSettingCols = _.concat(materialSpreadSettingCols, [
         {title: '本期应耗数量', colSpan: '1', rowSpan: '2', field: 'quantity', hAlign: 2, width: 90, type: 'Number', readOnly: true},

+ 3 - 2
app/public/report/js/rpt_jspdf.js

@@ -42,7 +42,8 @@ let JpcJsPDFHelper = {
         let strReplaceReg1 = new RegExp('\n\r', 'gm'),
             strReplaceReg2 = new RegExp('\r\n', 'gm'),
             strReplaceReg3 = new RegExp('\n', 'gm'),
-            strReplaceReg4 = new RegExp('\r', 'gm')
+            strReplaceReg4 = new RegExp('\r', 'gm'),
+            strReplaceReg5 = new RegExp('〜', 'gm')
         ;
         // let newName = pdfName;
         let pageObj = pageData;
@@ -282,7 +283,7 @@ let JpcJsPDFHelper = {
         function _preHandleSpliter(orgVal) {
             let rst = orgVal;
             if (rst !== null && rst !== '') {
-                rst = rst.replace(strReplaceReg1, '|').replace(strReplaceReg2, '|').replace(strReplaceReg3, '|').replace(strReplaceReg4, '|');
+                rst = rst.replace(strReplaceReg1, '|').replace(strReplaceReg2, '|').replace(strReplaceReg3, '|').replace(strReplaceReg4, '|').replace(strReplaceReg5, '~');
             }
             return rst;
         }

+ 1 - 0
app/router.js

@@ -574,6 +574,7 @@ module.exports = app => {
 
     // 决策大屏
     app.get('/datacollect', sessionAuth, 'datacollectController.index');
+    app.post('/datacollect/load', sessionAuth, 'datacollectController.loadData');
 
     // 概算投资
     app.get('/budget', sessionAuth, 'budgetController.list');

+ 7 - 0
app/service/change_audit.js

@@ -634,6 +634,13 @@ module.exports = app => {
             }
             return true;
         }
+
+        async getNumByMonth(tid, startMonth, endMonth) {
+            const sql = 'SELECT COUNT(*) as num FROM ?? WHERE id in (SELECT b.id FROM (SELECT * FROM ?? WHERE tid = ? GROUP BY id ORDER BY usort DESC) as b GROUP BY b.cid) AND status = ? AND sin_time between ? and ?';
+            const sqlParam = [this.tableName, this.tableName, tid, auditConst.auditStatus.checked, startMonth, endMonth];
+            const result = await this.db.queryOne(sql, sqlParam);
+            return result ? result.num : 0;
+        }
     }
 
     return ChangeAudit;

+ 14 - 1
app/service/material.js

@@ -151,7 +151,7 @@ module.exports = app => {
                     newMaterial.rate = preMaterial.rate;
                     newMaterial.pre_tp = this.ctx.helper.add(preMaterial.m_tp, preMaterial.pre_tp);
                     newMaterial.ex_pre_tp = this.ctx.helper.add(preMaterial.ex_tp, preMaterial.ex_pre_tp);
-                    newMaterial.tax_pre_tp = this.ctx.helper.add(preMaterial.m_tax_tp, preMaterial.tax_pre_tp);
+                    newMaterial.m_tax_pre_tp = preMaterial.material_tax ? this.ctx.helper.add(preMaterial.m_tax_tp, preMaterial.m_tax_pre_tp) : preMaterial.m_tax_pre_tp;
                 }
                 // 新增期记录
                 const result = await transaction.insert(this.tableName, newMaterial);
@@ -356,6 +356,19 @@ module.exports = app => {
             const info = await this.getDataById(id);
             return info.m_tax_tp;
         }
+
+        async getSumMaterial(tid) {
+            const sql = 'Select sum(m_tp + ex_tp) as tp From ' + this.tableName + ' where tid = ?';
+            const result = await this.db.queryOne(sql, [tid]);
+            return result ? result.tp : 0;
+        }
+
+        async getOldMaterialTax(tid, order) {
+            const sql = 'SELECT COUNT(id) as count FROM ?? WHERE `tid` = ? AND `order` <= ? AND `material_tax` = 1';
+            const sqlParam = [this.tableName, tid, order];
+            const result = await this.db.queryOne(sql, sqlParam);
+            return result && result.count !== 0;
+        }
     }
 
     return Material;

+ 7 - 0
app/service/material_audit.js

@@ -933,6 +933,13 @@ module.exports = app => {
                 throw err;
             }
         }
+
+        async getNumByMonth(tid, startMonth, endMonth) {
+            const sql = 'SELECT COUNT(*) as num FROM ?? WHERE id in (SELECT MAX(id) FROM ?? WHERE tid = ? GROUP BY mid) AND status = ? AND end_time between ? and ?';
+            const sqlParam = [this.tableName, this.tableName, tid, auditConst.status.checked, startMonth, endMonth];
+            const result = await this.db.queryOne(sql, sqlParam);
+            return result ? result.num : 0;
+        }
     }
 
     return MaterialAudit;

+ 2 - 2
app/service/material_bills.js

@@ -263,7 +263,7 @@ module.exports = app => {
                     m_tp: newTp,
                     pre_tp: mb.m_tp !== null ? this.ctx.helper.round(this.ctx.helper.add(mb.pre_tp, mb.m_tp), 2) : mb.pre_tp,
                     m_tax_tp: this.ctx.helper.round(this.ctx.helper.mul(newTp, (1 + this.ctx.helper.div(mb.m_tax, 100))), 2),
-                    m_tax_pre_tp: mb.m_tax_tp !== null ? this.ctx.helper.round(this.ctx.helper.add(mb.m_tax_pre_tp, mb.m_tax_tp), 2) : mb.m_tax_pre_tp,
+                    tax_pre_tp: mb.m_tax_tp !== null ? this.ctx.helper.round(this.ctx.helper.add(mb.tax_pre_tp, mb.m_tax_tp), 2) : mb.tax_pre_tp,
                 };
                 await transaction.update(this.tableName, updateData);
                 const m_tp = mb.is_summary === 1 ? await this.ctx.helper.round(this.ctx.helper.mul(mb_quantity.quantity, newm_spread), 2) : 0;
@@ -283,7 +283,7 @@ module.exports = app => {
                     m_tp: newTp,
                     pre_tp: mb.m_tp !== null ? this.ctx.helper.round(this.ctx.helper.add(mb.pre_tp, mb.m_tp), 2) : mb.pre_tp,
                     m_tax_tp: this.ctx.helper.round(this.ctx.helper.mul(newTp, (1 + this.ctx.helper.div(mb.m_tax, 100))), 2),
-                    m_tax_pre_tp: mb.m_tax_tp !== null ? this.ctx.helper.round(this.ctx.helper.add(mb.m_tax_pre_tp, mb.m_tax_tp), 2) : mb.m_tax_pre_tp,
+                    tax_pre_tp: mb.m_tax_tp !== null ? this.ctx.helper.round(this.ctx.helper.add(mb.tax_pre_tp, mb.m_tax_tp), 2) : mb.tax_pre_tp,
                 };
                 await transaction.update(this.tableName, updateData);
                 const m_tp = mb.is_summary === 1 ? await this.ctx.helper.round(this.ctx.helper.mul(quantity, newm_spread), 2) : 0;

+ 21 - 0
app/service/notice_push.js

@@ -52,6 +52,27 @@ module.exports = app => {
             })
             return notice
         }
+
+        /**
+         * 查询所有推送记录
+         * @param {Integer} pid - 项目id
+         * @param {Integer} uid - 查询人id
+         */
+        async getNoticeByDataCollect(pid, tenderIds = []) {
+            const wheres = { pid };
+            let notice = await this.db.select(this.tableName, {
+                where: wheres,
+                orders: [['create_time', 'desc']],
+                limit: 10,
+                offset: 0
+            })
+            notice = notice.map(v => {
+                const extra = JSON.parse(v.content)
+                delete v.content
+                return { ...v, ...extra }
+            })
+            return notice
+        }
     }
     return NoticePush
 }

+ 7 - 0
app/service/revise_audit.js

@@ -803,6 +803,13 @@ module.exports = app => {
                 throw err;
             }
         }
+
+        async getNumByMonth(tid, startMonth, endMonth) {
+            const sql = 'SELECT COUNT(*) as num FROM ?? WHERE id in (SELECT MAX(id) FROM ?? WHERE tender_id = ? GROUP BY rid) AND status = ? AND end_time between ? and ?';
+            const sqlParam = [this.tableName, this.tableName, tid, auditConst.status.checked, startMonth, endMonth];
+            const result = await this.db.queryOne(sql, sqlParam);
+            return result ? result.num : 0;
+        }
     }
 
     return ReviseAudit;

+ 7 - 0
app/service/stage_audit.js

@@ -1368,6 +1368,13 @@ module.exports = app => {
             }
             return result;
         }
+
+        async getNumByMonth(tid, startMonth, endMonth) {
+            const sql = 'SELECT COUNT(*) as num FROM ?? WHERE id in (SELECT MAX(id) FROM ?? WHERE tid = ? GROUP BY sid) AND status = ? AND end_time between ? and ?';
+            const sqlParam = [this.tableName, this.tableName, tid, auditConst.status.checked, startMonth, endMonth];
+            const result = await this.db.queryOne(sql, sqlParam);
+            return result ? result.num : 0;
+        }
     }
 
     return StageAudit;

+ 1 - 1
app/view/change/information.ejs

@@ -383,7 +383,7 @@
     </div>
 </div>
 <script>
-    const tenderName = '<%- tender.name %>';
+    const tenderName = JSON.parse(unescape('<%- escape(JSON.stringify(tender.name)) %>'));
     const tenderId = '<%- tender.id %>';
     const totalPriceUnit = '<%- tpUnit %>';
     const unitPriceUnit = '<%- upUnit %>';

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 662 - 338
app/view/datacollect/index.ejs


+ 1 - 1
app/view/material/exponent.ejs

@@ -49,7 +49,7 @@
                             </select>
                         </div>
                     </div>
-                    <% if (!material.material_tax) { %>
+                    <% if (!material.material_tax && !old_had_tax) { %>
                         <div class="sp-wrap" style="max-width: 800px;min-width: 500px;">
                             <div class="col-12 p-0">
                                 <table class="table table-sm table-bordered">

+ 5 - 5
app/view/material/info.ejs

@@ -54,7 +54,7 @@
                             </select>
                         </div>
                     </div>
-                    <% if (!material.material_tax) { %>
+                    <% if (!material.material_tax && !old_had_tax) { %>
                     <div class="sp-wrap" style="max-width: 800px;min-width: 500px;">
                         <div class="col-12 p-0">
                             <table class="table table-sm table-bordered">
@@ -94,14 +94,14 @@
                                     <td class="text-center"><%= material.ex_tp !== null || material.ex_pre_tp !== null ? ctx.helper.round(ctx.helper.add(material.ex_pre_tp, material.ex_tp), 2) : null %></td>
                                 </tr>
                                 <tr id="rate_set"><td>材料价差费用(含材料税)</td>
-                                    <td class="text-center"><%= material.m_tax_tp !== null ? material.m_tax_tp : null %></td>
-                                    <td class="text-center"><%= material.m_tax_tp !== null || material.tax_pre_tp !== null ? ctx.helper.round(ctx.helper.add(material.tax_pre_tp, material.m_tax_tp), 2) : null %></td>
+                                    <td class="text-center"><%= material.material_tax ? (material.m_tax_tp !== null ? material.m_tax_tp : null) : '-' %></td>
+                                    <td class="text-center"><%= material.material_tax ? (material.m_tax_tp !== null || material.m_tax_pre_tp !== null ? ctx.helper.round(ctx.helper.add(material.m_tax_pre_tp, material.m_tax_tp), 2) : null) : material.m_tax_pre_tp %></td>
                                     <td class="text-center">-</td>
                                     <td class="text-center">-</td>
                                 </tr>
                                 <tr><td>材料价差费用(含建筑税)</td>
-                                    <td class="text-center">-</td>
-                                    <td class="text-center"><%= pre_tp_hs !== null ? pre_tp_hs : '-' %></td>
+                                    <td class="text-center"><%= !material.material_tax ? (material.m_tp !== null ? ctx.helper.round(ctx.helper.mul(material.m_tp, 1+material.rate/100), 2) : null) : '-' %></td>
+                                    <td class="text-center"><%= !material.material_tax ? (material.m_tp !== null || pre_tp_hs !== null ? ctx.helper.round(ctx.helper.add(pre_tp_hs, ctx.helper.round(ctx.helper.mul(material.m_tp, 1+material.rate/100), 2)), 2) : null) : pre_tp_hs !== null ? pre_tp_hs : '-' %></td>
                                     <td class="text-center"><%= material.ex_tp !== null ? ctx.helper.round(ctx.helper.mul(material.ex_tp, 1+material.rate/100), 2) : null %></td>
                                     <td class="text-center"><%= material.ex_tp !== null || ex_pre_tp_hs !== null ? ctx.helper.round(ctx.helper.add(ex_pre_tp_hs, ctx.helper.round(ctx.helper.mul(material.ex_tp, 1+material.rate/100), 2)), 2) : null %></td>
                                 </tr>

+ 3 - 0
app/view/report/index.ejs

@@ -578,6 +578,9 @@
                 zTreeOprObj.onClick(null, null, zTreeOprObj.currentNode);
                 zTreeOprObj.countChkedRptTpl();
                 //console.log(ARCHIVE_LIST);
+                if (zTreeOprObj.currentNode) {
+                    zTreeOprObj.treeObj.selectNode(zTreeOprObj.currentNode, false);
+                }
             }, function(err){
                 $.bootstrapLoading.end();
             }, function(ex){

+ 1 - 0
app/view/tender/info.ejs

@@ -9,6 +9,7 @@
 </div>
 <script>
     const tenders = JSON.parse(unescape('<%- escape(JSON.stringify(tenderList)) %>'));
+    console.log(tenders);
     const categoryType = JSON.parse('<%- JSON.stringify(settingConst.cType) %>');
     const category = JSON.parse(unescape('<%- escape(JSON.stringify(categoryData)) %>'));
     const auditConst = JSON.parse('<%- JSON.stringify(auditConst) %>');

+ 3 - 3
config/menu.js

@@ -19,8 +19,8 @@ const menu = {
     },
     datacollect: {
         name: '决策大屏',
-        icon: 'fa-pie-chart',
-        display: false,
+        icon: 'fa-th-large',
+        display: true,
         url: '/datacollect',
         children: null,
         caption: '决策大屏',
@@ -309,7 +309,7 @@ const settingMenu = {
     },
     datacollect: {
         name: '决策大屏',
-        display: false,
+        display: true,
         url: '/setting/datacollect',
         caption: '决策大屏',
     },

+ 1 - 1
config/web.js

@@ -882,7 +882,7 @@ const JsFiles = {
         },
         datacollect: {
             index: {
-                files: ['/public/js/echarts/echarts.min.js', '/public/js/decimal.min.js', '/public/js/bootstrap/bootstrap-colorpicker.min.js', '/public/js/table/tableSlipe.js'],
+                files: ['/public/js/echarts/echarts.min.js', '/public/js/decimal.min.js', '/public/js/bootstrap/bootstrap-colorpicker.min.js'],
                 mergeFiles: [
                     '/public/js/zh_calc.js',
                 ],