Browse Source

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

Tony Kang 5 months ago
parent
commit
1dfd3aa875

+ 4 - 5
app/public/js/phase_pay_detail.js

@@ -288,8 +288,7 @@ $(document).ready(() => {
                     }
                     if (p.type === 'left') {
                         iLeftCount += 1;
-                        // if (i !== 0 && (param[i-1].type !== 'calc' || param[i-1].type !== 'left'))
-                        if (i !== 0 && param[i-1].type !== 'calc')
+                        if (i !== 0 && (param[i-1].type !== 'calc' || param[i-1].type !== 'left'))
                             return [false, '输入的表达式非法:(前应有运算符'];
                     }
                     if (p.type === 'right') {
@@ -349,7 +348,7 @@ $(document).ready(() => {
             checkRangeExpr(payNode, text, data) {
                 if (!payNode) return [false, '数据错误'];
 
-                const num = text ? _.toNumber(text) : 0;
+                const num = text ? _.toNumber(text) || 0 : 0;
                 let expr = text ? (num ? '' : text) : '';
                 expr = expr ? $.trim(expr).replace('\t', '').replace('=', '').toLowerCase() : '';
                 const [valid, msg] = this.checkExprValid(expr, ['bqwc', 'ybbqwc', 'bqht', 'bqbg', 'bqyf']);
@@ -379,7 +378,7 @@ $(document).ready(() => {
             checkStartExpr(payNode, text, data) {
                 if (!payNode) return [false, '数据错误'];
 
-                const num = text ? _.toNumber(text) : 0;
+                const num = text ? _.toNumber(text) || 0 : 0;
                 let expr = text ? (num ? '' : text) : '';
                 expr = expr ? $.trim(expr).replace('\t', '').replace('=', '').toLowerCase() : '';
                 const [valid, msg] = this.checkExprValid(expr, ['bqwc', 'ybbqwc', 'bqht', 'bqbg', 'bqyf']);
@@ -552,7 +551,7 @@ $(document).ready(() => {
                 }
                 const preNode = payTree.getPreSiblingNode(select);
                 setObjEnable($('a[name=base-opr][type=add]'), !readOnly && !payUtils.check.isSf(select) && !payUtils.check.isYf(select));
-                const delValid = !payUtils.check.isFixed(select) && !payUtils.check.isStarted(select);
+                const delValid = !payUtils.check.isFixed(select) && !payUtils.check.isStarted(select) && payUtils.check.isOwner(select);
                 setObjEnable($('a[name=base-opr][type=delete]'), !readOnly && delValid);
                 setObjEnable($('a[name=base-opr][type=up-move]'), !readOnly && !payUtils.check.isFixed(select) && preNode);
                 setObjEnable($('a[name=base-opr][type=down-move]'), !readOnly && !payUtils.check.isFixed(select) && !payTree.isLastSibling(select));

+ 37 - 37
app/public/js/shares/phase_pay_audit.js

@@ -106,45 +106,45 @@ $(document).ready(function () {
     // 添加到审批流程
     $('#book-list').on('click', 'dd', function () {
         const id = parseInt($(this).data('id'));
-        if (id !== 0) {
-            postData('audit/add', { auditorId: id }, (datas) => {
-                const html = [];
-                // 如果是重新上报,添加到重新上报列表中
-                const auditorshtml = [];
-                for (const [index, data] of datas.entries()) {
-                    if (index !== 0) {
-                        html.push('<li class="list-group-item d-flex" auditorId="'+ data[0].audit_id +'">');
-                        html.push(`<div class="col-auto">${index}</div>`);
-                        html.push('<div class="col">');
-                        for (const auditor of data) {
-                            html.push(`<div class="d-inline-block mx-1"><i class="fa fa-user text-muted"></i> ${auditor.name} <small class="text-muted">${auditor.role}</small></div>`);
-                        }
-                        html.push('</div>');
-                        html.push('<div class="col-auto">');
-                        // todo 添加会签或签时
-                        // html.push('<span class="badge badge-pill badge-primary badge-bg-small"><small></small></span>');
-                        if (shenpi_status === shenpiConst.sp_status.sqspr || (shenpi_status === shenpiConst.sp_status.gdzs && index+1 !== datas.length)) {
-                            html.push('<a href="javascript: void(0)" class="text-danger pull-right">移除</a>');
-                        }
-                        html.push('</div>');
-                        html.push('</li>');
+        if (!id) return;
+
+        postData('audit/add', { auditorId: id }, (datas) => {
+            const html = [];
+            // 如果是重新上报,添加到重新上报列表中
+            const auditorshtml = [];
+            for (const [index, data] of datas.entries()) {
+                if (index !== 0) {
+                    html.push('<li class="list-group-item d-flex" auditorId="'+ data[0].audit_id +'">');
+                    html.push(`<div class="col-auto">${index}</div>`);
+                    html.push('<div class="col">');
+                    for (const auditor of data) {
+                        html.push(`<div class="d-inline-block mx-1"><i class="fa fa-user text-muted"></i> ${auditor.name} <small class="text-muted">${auditor.role}</small></div>`);
                     }
-                    auditorshtml.push('<li class="list-group-item" data-auditorid="' + data.audit_id + '">');
-                    auditorshtml.push('<i class="fa ' + (index+1 === datas.length ? 'fa-stop-circle' : 'fa-chevron-circle-down') + '"></i> ');
-                    auditorshtml.push(data.name + ' <small class="text-muted">' + data.role + '</small>');
-                    if (index === 0) {
-                        auditorshtml.push('<span class="pull-right">原报</span>');
-                    } else if (index+1 === datas.length) {
-                        auditorshtml.push('<span class="pull-right">终审</span>');
-                    } else {
-                        auditorshtml.push('<span class="pull-right">'+ transFormToChinese(index) +'审</span>');
+                    html.push('</div>');
+                    html.push('<div class="col-auto">');
+                    if (data[0].audit_type !== auditType.key.common)
+                        html.push(`<span class="badge badge-pill badge-${auditType.info[data[0].audit_type].class} p-1"><small>${auditType.info[data[0].audit_type].long}</small></span>`);
+                    if (shenpi_status === shenpiConst.sp_status.sqspr || (shenpi_status === shenpiConst.sp_status.gdzs && index+1 !== datas.length)) {
+                        html.push('<a href="javascript: void(0)" class="text-danger pull-right">移除</a>');
                     }
-                    auditorshtml.push('</li>');
+                    html.push('</div>');
+                    html.push('</li>');
                 }
-                $('#auditors').html(html.join(''));
-                $('#auditors-list').html(auditorshtml.join(''));
-            });
-        }
+                auditorshtml.push('<li class="list-group-item" data-auditorid="' + data.audit_id + '">');
+                auditorshtml.push('<i class="fa ' + (index+1 === datas.length ? 'fa-stop-circle' : 'fa-chevron-circle-down') + '"></i> ');
+                auditorshtml.push(data.name + ' <small class="text-muted">' + data.role + '</small>');
+                if (index === 0) {
+                    auditorshtml.push('<span class="pull-right">原报</span>');
+                } else if (index+1 === datas.length) {
+                    auditorshtml.push('<span class="pull-right">终审</span>');
+                } else {
+                    auditorshtml.push('<span class="pull-right">'+ transFormToChinese(index) +'审</span>');
+                }
+                auditorshtml.push('</li>');
+            }
+            $('#auditors').html(html.join(''));
+            $('#auditors-list').html(auditorshtml.join(''));
+        });
     });
     // 删除审批人
     $('body').on('click', '#auditors li a', function () {
@@ -156,7 +156,7 @@ $(document).ready(function () {
             li.remove();
             for (const rst of result) {
                 const aLi = $('li[auditorId=' + rst.audit_id + ']');
-                $('span', aLi).text(rst.order + ' ' + rst.name + ' ');
+                $('div:first', aLi).text(rst.order);
             }
 
             // 如果是重新上报

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

@@ -461,7 +461,7 @@ $(document).ready(() => {
                 }
                 if (p.type === 'left') {
                     iLeftCount += 1;
-                    if (i !== 0 && param[i-1].type !== 'calc')
+                    if (i !== 0 && (param[i-1].type !== 'calc' && param[i-1].type !== 'left'))
                         return [false, '输入的表达式非法:(前应有运算符'];
                 }
                 if (p.type === 'right') {

+ 2 - 2
app/service/phase_pay.js

@@ -119,7 +119,7 @@ module.exports = app => {
             const result = {};
             for (const stage of relaStage) {
                 result.contract_tp = this.ctx.helper.add(result.contract_tp, stage.contract_tp);
-                result.qc_tp = this.ctx.helper.add(result.contract_tp, stage.qc_tp);
+                result.qc_tp = this.ctx.helper.add(result.qc_tp, stage.qc_tp);
                 result.pc_tp = this.ctx.helper.add(result.pc_tp, stage.pc_tp);
 
                 const qdSum = await this.ctx.service.stageBills.getSumTotalPriceGcl(stage);
@@ -500,7 +500,7 @@ module.exports = app => {
                         await this.loadUser(phasePay);
                     } else if (!shenpiInfo) {
                         // 不存在终审人的状态下这里恢复为授权审批人
-                        this.tender.info.shenpi.phasePay = shenpiConst.sp_status.sqspr;
+                        this.ctx.tender.info.shenpi.phasePay = shenpiConst.sp_status.sqspr;
                     }
                 }
             }

+ 14 - 10
app/service/phase_pay_audit.js

@@ -230,7 +230,9 @@ module.exports = app => {
         }
         // 固定审批流-更新
         async updateNewAuditList(phasePay, newList) {
-            const newAuditsInfo = await this.ctx.service.projectAccount.getAllDataByCondition({ where: { id: newList.map(x => { return x.audit_id; })} });
+            const newAuditsInfo = newList && newList.length > 0
+                ? await this.ctx.service.projectAccount.getAllDataByCondition({ where: { id: newList.map(x => { return x.audit_id; })} })
+                : [];
             const transaction = await this.db.beginTransaction();
             try {
                 // 先删除旧的审批流,再添加新的
@@ -255,11 +257,11 @@ module.exports = app => {
         }
         // 固定终审-更新
         async updateLastAudit(phasePay, auditList, lastId) {
-            const lastUser = await this.ctx.service.projectAccount.getDataById(lastId);
+            const lastUser = lastId ? await this.ctx.service.projectAccount.getDataById(lastId) : null;
             const transaction = await this.db.beginTransaction();
             try {
                 // 先判断auditList里的aid是否与lastId相同,相同则删除并重新更新order
-                const existAudit = auditList.find(x => { return x.audit_id === lastId });
+                const existAudit = lastId ? auditList.find(x => { return x.audit_id === lastId }) : null;
                 let auditOrder = auditList.length > 0 ? auditList.reduce((rst, a) => { return Math.max(rst, a.active_order)}, 0) + 1 : 1; // 最大值 + 1
                 if (existAudit) {
                     await transaction.delete(this.tableName, { phase_id: phasePay.id, audit_times: phasePay.audit_times, audit_id: lastId });
@@ -277,13 +279,15 @@ module.exports = app => {
                     }
                 }
                 // 添加终审
-                const newAuditor = {
-                    tid: phasePay.tid, phase_id: phasePay.id, audit_id: lastId,
-                    name: lastUser.name, company: lastUser.company, role: lastUser.role, mobile: lastUser.mobile,
-                    audit_times: phasePay.audit_times, active_order: auditOrder, audit_status: auditConst.phasePay.status.uncheck,
-                    audit_type: auditType.key.common, audit_order: auditOrder,
-                };
-                await transaction.insert(this.tableName, newAuditor);
+                if (lastUser) {
+                    const newAuditor = {
+                        tid: phasePay.tid, phase_id: phasePay.id, audit_id: lastId,
+                        name: lastUser.name, company: lastUser.company, role: lastUser.role, mobile: lastUser.mobile,
+                        audit_times: phasePay.audit_times, active_order: auditOrder, audit_status: auditConst.phasePay.status.uncheck,
+                        audit_type: auditType.key.common, audit_order: auditOrder,
+                    };
+                    await transaction.insert(this.tableName, newAuditor);
+                }
                 await transaction.commit();
             } catch (err) {
                 await transaction.rollback();

+ 3 - 3
app/service/phase_pay_detail.js

@@ -156,9 +156,9 @@ class PayCalculator {
                 p.start_tp = this.ctx.helper.round(p.start_tp, this.decimal);
             }
             if (p.range_expr) {
-                p.range_price = this.ctx.helper.round(this._calculateExpr(p.range_expr), this.decimal);
-            } else if (p.range_price && !p.range_expr) {
-                p.range_price = this.ctx.helper.round(p.range_price, this.decimal);
+                p.range_tp = this.ctx.helper.round(this._calculateExpr(p.range_expr), this.decimal);
+            } else if (p.range_tp && !p.range_expr) {
+                p.range_tp = this.ctx.helper.round(p.range_tp, this.decimal);
             }
         }
     }

+ 1 - 0
app/view/phase_pay/audit_modal.ejs

@@ -795,6 +795,7 @@
     const shenpi_status = <%- ctx.tender.info.shenpi.phasePay %>;
     const shenpiConst =  JSON.parse('<%- JSON.stringify(shenpiConst) %>');
     const phaseUserId = parseInt('<%= ctx.phasePay.create_user_id %>');
+    const auditType = JSON.parse(unescape('<%- escape(JSON.stringify(auditType)) %>'));
 </script>
 <script>
     $('[name=phase-start]').submit(function (e) {

+ 3 - 3
app/view/phase_pay/index.ejs

@@ -70,11 +70,11 @@
                         </td>
                         <td class="text-center">
                             <% if (pay.audit_status === auditConst.status.uncheck && pay.create_user_id === ctx.session.sessionUser.accountId) { %>
-                            <a href="<%- '/tender/' + pay.tid + '/pay/' + pay.phase_order %>" target="_blank" class="btn <%- auditConst.info[pay.audit_status].btnClass %> btn-sm"><%- auditConst.info[pay.audit_status].btnTitle %></a>
+                            <a href="<%- '/tender/' + pay.tid + '/pay/' + pay.phase_order + '/detail' %>" target="_blank" class="btn <%- auditConst.info[pay.audit_status].btnClass %> btn-sm"><%- auditConst.info[pay.audit_status].btnTitle %></a>
                             <% } else if (pay.status === auditConst.status.checkNo && pay.user_id === ctx.session.sessionUser.accountId) { %>
-                            <a href="<%- '/tender/' + pay.tid + '/pay/' + pay.phase_order %>" target="_blank" class="btn <%- auditConst.info[pay.audit_status].btnClass %> btn-sm"><%- auditConst.info[pay.audit_status].btnTitle %></a>
+                            <a href="<%- '/tender/' + pay.tid + '/pay/' + pay.phase_order + '/detail' %>" target="_blank" class="btn <%- auditConst.info[pay.audit_status].btnClass %> btn-sm"><%- auditConst.info[pay.audit_status].btnTitle %></a>
                             <% } else if ((pay.status === auditConst.status.checking || pay.status === auditConst.status.checkNoPre) && pay.curAuditors && pay.curAuditors.findIndex(x => { return x.aid === ctx.session.sessionUser.accountId; }) >= 0) { %>
-                            <a href="<%- '/tender/' + pay.tid + '/pay/' + pay.phase_order %>" target="_blank" class="btn <%- auditConst.info[pay.audit_status].btnClass %> btn-sm"><%- auditConst.info[pay.audit_status].btnTitle %></a>
+                            <a href="<%- '/tender/' + pay.tid + '/pay/' + pay.phase_order + '/detail' %>" target="_blank" class="btn <%- auditConst.info[pay.audit_status].btnClass %> btn-sm"><%- auditConst.info[pay.audit_status].btnTitle %></a>
                             <% } else { %>
                             <span class="<%- auditConst.info[pay.audit_status].class %>"><%- auditConst.info[pay.audit_status].title %></span>
                             <% } %>