Explorar el Código

Merge branch 'master' of http://192.168.1.41:3000/maixinrong/Calculation

TonyKang hace 5 años
padre
commit
569aadd796

+ 26 - 0
app/controller/login_controller.js

@@ -72,6 +72,32 @@ module.exports = app => {
             ctx.redirect('/');
         }
 
+        /**
+         * 获取项目名
+         *
+         * @param {Object} ctx - egg全局context
+         * @return {void}
+         */
+        async projectName(ctx) {
+            const response = {
+                err: 0,
+                msg: '',
+            };
+            const code = ctx.query.code;
+            try {
+                const data = await ctx.service.project.getProjectByCode(code);
+                if (data) {
+                    response.data = data.name;
+                } else {
+                    throw '项目不存在';
+                }
+            } catch (err) {
+                response.err = 1;
+                response.msg = err;
+            }
+            ctx.body = response;
+        }
+
     }
 
     return LoginController;

+ 7 - 2
app/controller/stage_controller.js

@@ -1119,6 +1119,11 @@ module.exports = app => {
             try {
                 await this._getStageAuditViewData(ctx);
                 const renderData = await this._getDefaultRenderData(ctx);
+                if (ctx.stage.times !== ctx.stage.curTimes) {
+                    renderData.compareAuditors = ctx.stage.auditHistory[ctx.stage.curTimes - 1];
+                } else {
+                    renderData.compareAuditors = ctx.stage.auditors;
+                }
                 [renderData.ledgerSpread, renderData.posSpread] = getCompareSpreadSetting();
                 renderData.jsFiles = this.app.jsFiles.common.concat(this.app.jsFiles.stage.compare);
                 await this.layout('stage/compare.ejs', renderData, 'stage/compare_modal.ejs');
@@ -1142,8 +1147,8 @@ module.exports = app => {
                 }
                 for (const order of data.roles) {
                     const data = { order: order, bills: [], pos: [] };
-                    data.bills = await ctx.service.stageBills.getAuditorStageData(ctx.tender.id, ctx.stage.id, ctx.stage.times, order);
-                    data.pos = await ctx.service.stagePos.getAuditorStageData(ctx.tender.id, ctx.stage.id, ctx.stage.times, order);
+                    data.bills = await ctx.service.stageBills.getAuditorStageData(ctx.tender.id, ctx.stage.id, ctx.stage.curTimes, order);
+                    data.pos = await ctx.service.stagePos.getAuditorStageData(ctx.tender.id, ctx.stage.id, ctx.stage.curTimes, order);
                     result.roles.push(data);
                 }
                 ctx.body = {err: 0, msg: '', data: result};

+ 1 - 1
app/controller/tender_controller.js

@@ -275,7 +275,7 @@ module.exports = app => {
                     tender.deal_tp = sum.deal_tp;
                 }
                 const stages = await ctx.service.stage.getValidStages(ctx.tender.id);
-                const lastStage = stages[0]; //await ctx.service.stage.getLastestStage(ctx.tender.id);
+                const lastStage = stages.length > 0 ? stages[0] : null; //await ctx.service.stage.getLastestStage(ctx.tender.id);
                 if (lastStage) {
                     await this.ctx.service.stage.checkStageGatherData(lastStage);
                     tender.gather_tp = ctx.helper.add(lastStage.contract_tp, lastStage.qc_tp);

+ 1 - 0
app/router.js

@@ -20,6 +20,7 @@ module.exports = app => {
     app.get('/', 'loginController.index');
     app.get('/logout', 'loginController.logout');
     app.post('/login', 'loginController.login');
+    app.get('/project/name', 'loginController.projectName');
 
     app.get('/sign', 'signController.index');
     app.post('/sign/save', 'signController.save');

+ 7 - 3
app/service/report_memory.js

@@ -87,7 +87,11 @@ module.exports = app => {
                 }
 
                 this.ctx.stage = stage;
-                this.ctx.stage.cacheTime = this.ctx.stage.readOnly ? (this.ctx.stage.cache_time_r).getTime(): (this.ctx.stage.cache_time_l).getTime();
+                let time = this.ctx.stage.readOnly ? this.ctx.stage.cache_time_r : this.ctx.stage.cache_time_l;
+                if (!time) {
+                    time = this.ctx.stage.in_time ? this.ctx.stage.in_time : new Date();
+                }
+                this.ctx.stage.cacheTime = time.getTime();//this.ctx.stage.readOnly ? (this.ctx.stage.cache_time_r).getTime(): (this.ctx.stage.cache_time_l).getTime();
             }
         }
 
@@ -186,11 +190,11 @@ module.exports = app => {
             await this._checkStage(sid);
             const cache = await this._getReportMemoryCache('mem_stage_im_tz', tid, sid, this.ctx.stage.cacheTime);
             if (cache) {
-                //console.log('cache');
+                console.log('cache');
                 return cache;
             }
 
-            //console.log('build');
+            console.log('build');
             if (!this.stageImData) {
                 this.stageImData = {};
                 try {

+ 2 - 0
app/service/stage.js

@@ -179,6 +179,8 @@ module.exports = app => {
                 user_id: this.ctx.session.sessionUser.accountId,
                 check_calc: false,
             };
+            newStage.cache_time_l = newStage.in_time;
+            newStage.cache_time_r = newStage.in_time;
             if (preStage) {
                 newStage.im_type = preStage.im_type;
                 newStage.im_pre = preStage.im_pre;

+ 1 - 1
app/service/stage_bills.js

@@ -71,7 +71,7 @@ module.exports = app => {
             const sql = 'SELECT Bills.* FROM ' + this.tableName + ' As Bills ' +
                 '  INNER JOIN ( ' +
                 '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `progress`, `lid`, `tid`, `sid` From ' + this.tableName +
-                '      WHERE `times` < ? OR (`times` = ? AND `order` <= ?) And tid = ? And sid = ?' + lidSql +
+                '      WHERE (`times` < ? OR (`times` = ? AND `order` <= ?)) And tid = ? And sid = ?' + lidSql +
                 '      GROUP BY `lid`' +
                 '  ) As MaxFilter ' +
                 '  ON (Bills.times * ' + timesLen + ' + `order`) = MaxFilter.progress And Bills.lid = MaxFilter.lid' +

+ 43 - 1
app/view/login/login.ejs

@@ -7,13 +7,15 @@
     <title>用户登录-计量支付</title>
     <link rel="stylesheet" href="public/css/bootstrap/bootstrap.min.css">
     <link rel="stylesheet" href="public/css/main.css">
+    <link rel="stylesheet" href="/public/css/toast.css">
     <link rel="stylesheet" href="public/css/font-awesome/font-awesome.min.css">
 </head>
 <body class="login-body">
 <div class="container">
     <!--演示版-->
     <form class="form-signin" method="post" action="/login">
-        <h4 class="d-flex justify-content-center mb-4">纵横云计量</h4>
+        <h4 class="d-flex justify-content-center mb-4"><span id="project_name"></span>纵横云计量</h4>
+        <p class="text-center mb-4 text-muted"></p>
         <!--<nav class="nav nav-tabs nav-justified mb-3" role="tablist" id="login-tab">-->
             <!--<a class="nav-item nav-link" data-toggle="tab" data-type="1" href="#preview" role="tab">演示版登录</a>-->
             <!--<a class="nav-item nav-link active" data-toggle="tab" data-type="2" href="#paid" role="tab">项目版登录</a>-->
@@ -57,6 +59,10 @@
     <!--项目版-->
     <div class="text-white fixed-bottom"><p class="text-center mb-1">Copyright © 2018 <a href="https://smartcost.com.cn" target="_blank" class="text-white">珠海纵横创新软件有限公司</a>.All Rights Reserved.<a class="text-white ml-2" href="http://www.miitbeian.gov.cn" target="_blank">粤ICP备14032472号</a></p></div>
 </div>
+<div class="toast" style="text-align: center">
+    <i class="icon fa"></i>
+    <span class="message"></span>
+</div>
 <!-- JS. -->
 <script src="/public/js/jquery/jquery-3.2.1.min.js"></script>
 <script src="/public/js/popper/popper.min.js"></script>
@@ -64,6 +70,12 @@
 <script src="/public/js/global.js"></script>
 <script type="text/javascript">
 $(document).ready(function() {
+    const lSPName = getLocalCache('project_name');
+    const lSPCode = getLocalCache('project_code');
+    if (lSPName !== undefined) {
+        $('#project_name').text(lSPName);
+        $('#project').val(lSPCode);
+    }
     $("#login-tab a[data-toggle='tab']").on('shown.bs.tab', function () {
         let type = $(this).data('type');
         type = parseInt(type);
@@ -80,6 +92,36 @@ $(document).ready(function() {
     //         $('#error-msg').text('账号格式有误');
     //     }
     // })
+    $('#project').blur(function () {
+        if ($(this).val() == '') {
+            $('#project_name').text('');
+            removeLocalCache('project_code');
+            removeLocalCache('project_name');
+        } else {
+            const pcode = getLocalCache('project_code');
+            if ($(this).val() !== pcode) {
+                const pc = $(this).val();
+                $.ajax({
+                    type: 'get',
+                    url: '/project/name',
+                    data: { code: pc },
+                    dataType: 'json',
+                    success: function (result) {
+                        setLocalCache('project_code', pc);
+                        if (result.err === 1) {
+                            $('#project_name').text('');
+                            console.log(result.msg);
+                            toast(result.msg, 'error', 'exclamation-circle');
+                            removeLocalCache('project_name');
+                        } else {
+                            setLocalCache('project_name', result.data);
+                            $('#project_name').text(result.data);
+                        }
+                    }
+                })
+            }
+        }
+    })
 });
 </script>
 </body>

+ 12 - 6
app/view/stage/compare_modal.ejs

@@ -9,16 +9,22 @@
             <div class="modal-body">
                 <table class="table table-sm">
                     <tr><th>审批人</th><th width="90">选择</th><th></th></tr>
-                    <% for (const [i, a] of ctx.stage.auditors.entries()) { %>
-                    <% if (a.status === auditConst.status.checked || a.status === auditConst.status.checkNoPre || a.status === auditConst.status.checkAgain ||
-                            (a.status === auditConst.status.checking && a.aid === ctx.session.sessionUser.accountId)) { %>
+                    <% for (const [i, a] of compareAuditors.entries()) { %>
                     <tr auditorId="<%- a.aid %>">
                         <td><%- a.name %></td>
-                        <td><% if (a.status !== auditConst.status.checkAgain) {%><input type="checkbox" audit-order="<%- i + 1 %>"><% } %></td>
-                        <td class="text-center <%- auditConst.statusClass[a.status] %>" style="width: 80px"><%- auditConst.statusString[a.status] %></td>
+                        <td>
+                            <% if (a.status === auditConst.status.checked || a.status === auditConst.status.checkNo || a.status === auditConst.status.checkNoPre ||
+                                    (a.status === auditConst.status.checking && a.aid === ctx.session.sessionUser.accountId)) {%>
+                            <input type="checkbox" audit-order="<%- i + 1 %>">
+                            <% } %>
+                        </td>
+                        <td class="text-center <%- auditConst.statusClass[a.status] %>" style="width: 80px">
+                            <% if (a.status !== auditConst.status.uncheck) {%>
+                            <%- auditConst.statusString[a.status] %>
+                            <% } %>
+                        </td>
                     </tr>
                     <% } %>
-                    <% } %>
                 </table>
             </div>
             <div class="modal-footer">

+ 1 - 1
app/view/tender/detail.ejs

@@ -95,7 +95,7 @@
                                 <h5 class="card-title">标段设置</h5>
                                 <a href="#bd-set-1" data-toggle="modal" data-target="#bd-set-1" class="btn btn-sm btn-outline-primary">标段属性</a>
                                 <a href="#bd-set-2" data-toggle="modal" data-target="#bd-set-2" class="btn btn-sm btn-outline-primary">小数位数</a>
-                                <a href="#bd-set-3" data-toggle="modal" data-target="#bd-set-3" class="btn btn-sm btn-outline-primary">清单精度</a>
+                                <a href="#bd-set-3" data-toggle="modal" data-target="#bd-set-3" class="btn btn-sm btn-outline-primary">数量精度</a>
                                 <a href="#bd-set-4" data-toggle="modal" data-target="#bd-set-4" class="btn btn-sm btn-outline-primary">合同参数</a>
                                 <a href="#bd-set-5" data-toggle="modal" data-target="#bd-set-5" class="btn btn-sm btn-outline-primary">显示设置</a>
                                 <a href="#bd-set-6" data-toggle="modal" data-target="#bd-set-6" class="btn btn-sm btn-outline-primary">章节设置</a>

+ 49 - 47
app/view/tender/detail_modal.ejs

@@ -729,8 +729,6 @@
         spread.options.showHorizontalScrollbar = false;
         const sheet = spread.getActiveSheet();
         SpreadJsObj.protectedSheet(sheet);
-        //sheet.options.rowHeaderVisible = false;
-        //sheet.options.colHeaderVisible = false;
         sheet.setText(0, 0, '单位', spreadNS.SheetArea.colHeader);
         sheet.setText(0, 1, '精度', spreadNS.SheetArea.colHeader);
         sheet.setRowHeight(0, 32, spreadNS.SheetArea.colHeader);
@@ -756,7 +754,7 @@
             sheet.setColumnWidth(0, 100);
             sheet.setColumnWidth(1, 60);
             sheet.getRange(0, 0, 13, 1).vAlign(1).backColor('#e4e7ea').locked(true);
-            sheet.getRange(0, 1, 13, 1).vAlign(1).hAlign(2);
+            sheet.getRange(0, 1, 13, 1).vAlign(1).hAlign(2).locked(false);
             sheet.setText(0, 0, 't');
             sheet.setText(1, 0, 'km');
             sheet.setText(2, 0, 'm');
@@ -791,18 +789,14 @@
         });
         SpreadJsObj.addDeleteBind(spread, function (sheet) {
             const sel = sheet.getSelections()[0];
-            let calc = false;
             if (sel) {
                 for (let iRow = sel.row, iRowLength = sel.row + sel.rowCount; iRow < iRowLength; iRow++) {
-                    if (iRow === 3) continue;
                     for (let iCol = sel.col, iColLength = sel.col + sel.colCount; iCol < iColLength; iCol++) {
-                        if (iCol !== 2) continue;
+                        if (iCol !== 1) continue;
                         sheet.setText(iRow, iCol, '0');
-                        if (iRow === 1 || iRow === 2) calc = true;
                     }
                 }
             }
-            if (calc) calcHtjMinusZlj();
         });
         spread.bind(spreadNS.Events.ClipboardPasted, function (e, info) {
             let bHint = false;
@@ -905,38 +899,47 @@
         spread.options.showHorizontalScrollbar = false;
         const sheet = spread.getActiveSheet();
         SpreadJsObj.protectedSheet(sheet);
+        sheet.setText(0, 0, '参数名', spreadNS.SheetArea.colHeader);
+        sheet.setText(0, 1, '参数值', spreadNS.SheetArea.colHeader);
+        sheet.setRowHeight(0, 32, spreadNS.SheetArea.colHeader);
 
         const vStyle = new spreadNS.Style();
         vStyle.font = '12px 微软雅黑';
         sheet.setDefaultStyle(vStyle, spreadNS.SheetArea.viewport);
+        const xStyle = new spreadNS.Style();
+        xStyle.font = '12px 微软雅黑';
+        xStyle.vAlign = 1;
+        xStyle.hAlign = 1;
+        sheet.setDefaultStyle(xStyle, spreadNS.SheetArea.colHeader);
+        const yStyle = new spreadNS.Style();
+        yStyle.font = '12px 微软雅黑';
+        yStyle.vAlign = 1;
+        yStyle.hAlign = 1;
+        sheet.setDefaultStyle(yStyle, spreadNS.SheetArea.rowHeader);
 
         SpreadJsObj.massOperationSheet(sheet, function () {
-            sheet.options.rowHeaderVisible = false;
-            sheet.options.colHeaderVisible = false;
-            sheet.defaults.rowHeight = 25;
-            sheet.setColumnCount(3);
-            sheet.setRowCount(6);
-            sheet.setColumnWidth(0, 1);
+            sheet.defaults.rowHeight = 21;
+            sheet.setColumnCount(2);
+            sheet.setRowCount(5);
+            sheet.setColumnWidth(0, 200);
             sheet.setColumnWidth(1, 200);
-            sheet.setColumnWidth(2, 200);
-            sheet.setRowHeight(0, 1);
-            sheet.getRange(1, 1, 5, 1).vAlign(1).backColor('#e4e7ea').locked(true);
-            sheet.getRange(1, 2, 5, 1).vAlign(1).hAlign(2).locked(true);
-            sheet.setText(1, 1, '签约合同价');
-            sheet.setText(2, 1, '暂列金额');
-            sheet.setText(3, 1, '签约合同价(不含暂列金)');
-            sheet.setText(4, 1, '签约开工预付款');
-            sheet.setText(5, 1, '签约材料预付款');
-            const lineBorder = new spreadNS.LineBorder('#6a696e', spreadNS.LineStyle.thin);
-            sheet.getRange(0, 0, 6, 3).setBorder(lineBorder, {all: true});
-            sheet.getRange(0, 0, 6, 3).formatter('@');
-            sheet.setSelection(1, 2, 1, 1);
+            sheet.getRange(0, 0, 5, 1).vAlign(1).backColor('#e4e7ea').locked(true);
+            sheet.getRange(0, 1, 5, 1).vAlign(1).hAlign(2).locked(false);
+            sheet.setText(0, 0, '签约合同价');
+            sheet.setText(1, 0, '暂列金额');
+            sheet.setText(2, 0, '签约合同价(不含暂列金)');
+            sheet.setText(3, 0, '签约开工预付款');
+            sheet.setText(4, 0, '签约材料预付款');
+            const lineBorder = new spreadNS.LineBorder('#dee2e6', spreadNS.LineStyle.thin);
+            sheet.getRange(0, 0, 5, 2).setBorder(lineBorder, {all: true});
+            sheet.getRange(0, 0, 5, 2).formatter('@');
+            sheet.setSelection(0, 1, 1, 1);
         });
 
         function calcHtjMinusZlj() {
-            const htj = _.toNumber(sheet.getText(1, 2));
-            const zlj = _.toNumber(sheet.getText(2, 2));
-            sheet.setValue(3, 2, ZhCalc.sub(zlj, htj));
+            const htj = _.toNumber(sheet.getText(0, 1));
+            const zlj = _.toNumber(sheet.getText(1, 1));
+            sheet.setValue(2, 1, ZhCalc.sub(htj, zlj));
         }
 
         spread.bind(spreadNS.Events.EditEnded, function (e, info) {
@@ -957,11 +960,11 @@
             let calc = false;
             if (sel) {
                 for (let iRow = sel.row, iRowLength = sel.row + sel.rowCount; iRow < iRowLength; iRow++) {
-                    if (iRow === 3) continue;
+                    if (iRow === 2) continue;
                     for (let iCol = sel.col, iColLength = sel.col + sel.colCount; iCol < iColLength; iCol++) {
-                        if (iCol !== 2) continue;
+                        if (iCol !== 1) continue;
                         sheet.setText(iRow, iCol, '0');
-                        if (iRow === 1 || iRow === 2) calc = true;
+                        if (iRow === 0 || iRow === 1) calc = true;
                     }
                 }
             }
@@ -987,26 +990,25 @@
         });
 
         function loadDealProperty() {
-            $('#hint-4').hide();
-            sheet.setValue(1, 2, property.deal_param.contractPrice);
-            sheet.setValue(2, 2, property.deal_param.zanLiePrice);
-            sheet.setValue(3, 2, ZhCalc.sub(property.deal_param.zanLiePrice, property.deal_param.contractPrice));
-            sheet.setValue(4, 2, property.deal_param.startAdvance);
-            sheet.setValue(5, 2, property.deal_param.materialAdvance);
+            sheet.setValue(0, 1, property.deal_param.contractPrice);
+            sheet.setValue(1, 1, property.deal_param.zanLiePrice);
+            sheet.setValue(2, 1, ZhCalc.sub(property.deal_param.contractPrice, property.deal_param.zanLiePrice));
+            sheet.setValue(3, 1, property.deal_param.startAdvance);
+            sheet.setValue(4, 1, property.deal_param.materialAdvance);
 
         }
         function setReadOnly (readOnly) {
-            sheet.getCell(1, 2).locked(readOnly);
-            sheet.getCell(2, 2).locked(readOnly);
-            sheet.getCell(4, 2).locked(readOnly);
-            sheet.getCell(5, 2).locked(readOnly);
+            sheet.getCell(0, 1).locked(readOnly);
+            sheet.getCell(1, 1).locked(readOnly);
+            sheet.getCell(3, 1).locked(readOnly);
+            sheet.getCell(4, 1).locked(readOnly);
         }
         function getNewDealData () {
             const result = {};
-            result.contractPrice = _.toNumber(sheet.getText(1, 2));
-            result.zanLiePrice = _.toNumber(sheet.getText(2, 2));
-            result.startAdvance = _.toNumber(sheet.getText(4, 2));
-            result.materialAdvance = _.toNumber(sheet.getText(5, 2));
+            result.contractPrice = _.toNumber(sheet.getText(0, 1));
+            result.zanLiePrice = _.toNumber(sheet.getText(1, 1));
+            result.startAdvance = _.toNumber(sheet.getText(3, 1));
+            result.materialAdvance = _.toNumber(sheet.getText(4, 1));
             return result;
         }