ソースを参照

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

Tony Kang 1 年間 前
コミット
7826eb4e72

+ 4 - 2
app/controller/wap_controller.js

@@ -315,14 +315,15 @@ module.exports = app => {
                     tpUnit: ctx.tender.info.decimal.tp,
                     monthProgress,
                     stagesEcharts: JSON.parse(JSON.stringify(stages)).reverse(),
+                    auditType: auditConst.auditType,
                 };
                 if (stages.length > 0) {
                     for (const s of stages) {
                         // s.curAuditor = null;
                         // 根据期状态返回展示用户
-                        s.curAuditor = await ctx.service.stageAudit.getAuditorByStatus(s.id, s.status, s.times);
+                        s.curAuditors = await ctx.service.stageAudit.getAuditorsByStatus(s.id, s.status, s.times);
                         if (s.status === auditConst.stage.status.checkNoPre) {
-                            s.curAuditor2 = await ctx.service.stageAudit.getAuditorByStatus(s.id, auditConst.stage.status.checking);
+                            s.curAuditors2 = await ctx.service.stageAudit.getAuditorsByStatus(s.id, auditConst.stage.status.checking);
                         }
                     }
                     renderData.stage = stages[0];
@@ -364,6 +365,7 @@ module.exports = app => {
                 renderData.stage.auditors = await ctx.service.stageAudit.getAuditors(renderData.stage.id, times);
                 // 获取审批流程中左边列表
                 renderData.stage.auditors2 = await ctx.service.stageAudit.getAuditGroupByList(renderData.stage.id, times);
+                renderData.stage.lastAuditors = await ctx.service.stageAudit.getAuditorsByStatus(stage.id, stage.status, stage.times);
                 await ctx.render('wap/shenpi_stage.ejs', renderData);
             } catch (err) {
                 this.log(err);

+ 24 - 22
app/lib/revise_price.js

@@ -272,29 +272,31 @@ class revisePriceCalc {
         const said = this.ctx.session.sessionUser.accountId;
         billsTree.calculateAll(node => {
             if (node.children && node.children.length > 0) return;
-            const priceDiff = helper.sub(node.unit_price, node.pre_unit_price);
-            if (!priceDiff) return;
+            // const priceDiff = helper.sub(node.unit_price, node.pre_unit_price);
+            // if (!priceDiff) return;
             if (node.cur_id && (node.cur_contract_qty || node.cur_qc_qty)) {
-                node.cur_contract_tp = helper.mul(node.cur_contract_qty, node.unit_price, decimal.tp);
-                node.cur_qc_tp = helper.mul(node.cur_qc_qty, node.unit_price, decimal.tp);
-                node.cur_positive_qc_tp = helper.mul(node.cur_positive_qc_qty, node.unit_price, decimal.tp);
-                node.cur_negative_qc_tp = helper.mul(node.cur_negative_qc_qty, node.unit_price, decimal.tp);
-                if (node.cur_times === stage.times && node.cur_order === 0) {
-                    result.ubData.push({
-                        id: node.cur_id,
-                        contract_tp: node.cur_contract_tp, qc_tp: node.cur_qc_tp,
-                        positive_qc_tp: node.cur_positive_qc_tp, negative_qc_tp: node.cur_negative_qc_tp,
-                    });
-                } else {
-                    result.ibData.push({
-                        tid: stage.tid, sid: stage.id, said,
-                        lid: node.id, times: stage.times, order: 0,
-                        contract_qty: node.cur_contract_qty, contract_tp: node.cur_contract_tp,
-                        qc_qty: node.cur_qc_qty, qc_tp: node.cur_qc_tp,
-                        positive_qc_qty: node.cur_positive_qc_qty, positive_qc_tp: node.cur_positive_qc_tp,
-                        negative_qc_qty: node.cur_negative_qc_qty, negative_qc_tp: node.cur_negative_qc_tp,
-                        postil: node.cur_postil,
-                    });
+                const cur_contract_tp = helper.mul(node.cur_contract_qty, node.unit_price, decimal.tp);
+                const cur_qc_tp = helper.mul(node.cur_qc_qty, node.unit_price, decimal.tp);
+                const cur_positive_qc_tp = helper.mul(node.cur_positive_qc_qty, node.unit_price, decimal.tp);
+                const cur_negative_qc_tp = helper.mul(node.cur_negative_qc_qty, node.unit_price, decimal.tp);
+                if (cur_contract_tp !== node.cur_contract_tp || cur_qc_tp !== node.cur_qc_tp || cur_positive_qc_tp !== node.cur_positive_qc_tp || cur_negative_qc_tp !== node.cur_positive_qc_tp) {
+                    if (node.cur_times === stage.times && node.cur_order === 0) {
+                        result.ubData.push({
+                            id: node.cur_id,
+                            contract_tp: cur_contract_tp, qc_tp: cur_qc_tp,
+                            positive_qc_tp: cur_positive_qc_tp, negative_qc_tp: cur_negative_qc_tp,
+                        });
+                    } else {
+                        result.ibData.push({
+                            tid: stage.tid, sid: stage.id, said,
+                            lid: node.id, times: stage.times, order: 0,
+                            contract_qty: node.cur_contract_qty, contract_tp: cur_contract_tp,
+                            qc_qty: node.cur_qc_qty, qc_tp: cur_qc_tp,
+                            positive_qc_qty: node.cur_positive_qc_qty, positive_qc_tp: cur_positive_qc_tp,
+                            negative_qc_qty: node.cur_negative_qc_qty, negative_qc_tp: cur_negative_qc_tp,
+                            postil: node.cur_postil,
+                        });
+                    }
                 }
             }
             if (node.pre_id && (node.pre_contract_qty || node.pre_qc_qty)) {

+ 2 - 2
app/middleware/session_auth.js

@@ -52,12 +52,12 @@ module.exports = options => {
                         if (accountInfo.company_id) {
                             companyInfo = yield this.service.datacollectAudit.getDataByCondition({
                                 pid: projectData.id,
-                                company_id: accountInfo.company_id
+                                company_id: accountInfo.company_id,
                             });
                         } else {
                             const cuInfo = yield this.service.constructionUnit.getDataByCondition({
                                 pid: projectData.id,
-                                name: accountInfo.company
+                                name: accountInfo.company,
                             });
                             if (cuInfo) {
                                 companyInfo = yield this.service.datacollectAudit.getDataByCondition({

+ 3 - 0
app/public/js/global.js

@@ -1204,6 +1204,9 @@ const spreadColor = {
     },
     safe: {
         differ: '#F2DEDE',
+    },
+    revise: {
+        used: '#F2F2F2',
     }
 };
 

+ 4 - 0
app/public/js/revise.js

@@ -89,6 +89,10 @@ $(document).ready(() => {
             },
         },
     ];
+    billsSpreadSetting.getColor = function(sheet, data, row, col, defaultColor) {
+        if (!data) return defaultColor;
+        return data.used ? spreadColor.revise.used : defaultColor;
+    };
     sjsSettingObj.setNodeTypeCol(billsSpreadSetting.cols, [{field: 'node_type'}]);
     SpreadJsObj.initSheet(billsSheet, billsSpreadSetting);
     const posSpread = SpreadJsObj.createNewSpread($('#pos-spread')[0]);

+ 1 - 2
app/public/js/setting.js

@@ -227,8 +227,7 @@ $(document).ready(() => {
     })
 
     // 参建单位页切换单位右侧显示
-    $('#unit_list tr').on('click', function () {
-        console.log('hello');
+    $('body').on('click', '#unit_list tr', function () {
         const id = parseInt($(this).data('id'));
         $(this).siblings('tr').removeClass('table-warning');
         $(this).addClass('table-warning');

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

@@ -534,7 +534,7 @@ $(document).ready(function () {
                     _self.parents('li').remove();
                     const aid_num = parseInt(_selflc.children('ul').find('li.d-flex').length);
                     if (aid_num === 0) {
-                        _selflc.html(auditUtils.getAuditGroupHtml(this_code, [], 1));
+                        _selflc.children('ul').html(auditUtils.getAuditGroupHtml(this_code, [], 1));
                     } else {
                         for (let i = 0; i < aid_num; i++) {
                             _selflc.find('li.d-flex').eq(i).find('.col-auto').text(transFormToChinese(i+1) + '审');

+ 0 - 3
app/public/js/sr_detail.js

@@ -179,9 +179,6 @@ $(document).ready(() => {
             node.end_final_1_qty = ZhCalc.add(node.end_qc_qty, node.final_1_qty);
         }
         node.gather_tp = ZhCalc.add(node.contract_tp, node.qc_tp);
-        node.end_contract_tp = ZhCalc.add(node.pre_contract_tp, node.contract_tp);
-        node.end_qc_tp = ZhCalc.add(node.pre_qc_tp, node.qc_tp);
-        node.end_gather_tp = ZhCalc.add(node.pre_gather_tp, node.gather_tp);
         node.end_gather_tp = ZhCalc.add(node.end_contract_tp, node.end_qc_tp);
         node.end_final_tp = ZhCalc.add(node.end_qc_tp, node.total_price);
         node.end_final_1_tp = ZhCalc.add(node.end_qc_tp, node.final_1_tp);

+ 1 - 0
app/public/js/stage.js

@@ -2626,6 +2626,7 @@ $(document).ready(() => {
             this.spreadSetting = {
                 cols: [
                     {title: '编号', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 80, formatter: '@', readOnly: true},
+                    {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 80, formatter: '@', readOnly: true},
                     {title: '中间计量表号', colSpan: '1', rowSpan: '1', field: 'im_code', hAlign: 0, width: 85, formatter: '@', readOnly: true},
                     {title: '交工证书/凭证号', colSpan: '1', rowSpan: '1', field: 'doc_code', hAlign: 0, width: 110, formatter: '@'},
                     {

+ 2 - 2
app/public/report/js/rpt_custom.js

@@ -224,7 +224,7 @@ const rptCustomObj = (function () {
             const flow = sf.audit_order
                 ? ( sf.audit_order === maxOrder ? '终审' : transFormToChinese(sf.audit_order) + '审')
                 : '原报';
-            html.push(`<option ${sf.visible ? '' : 'style="display: none"'}>${sf.name}-${sf.role}(${flow})</option>`);
+            html.push(`<option ${sf.visible ? '' : 'style="display: none"'} value="${sf.audit_order}">${sf.name}-${sf.role}(${flow})</option>`);
         }
         html.push('</select>');
         return html.join('');
@@ -528,7 +528,7 @@ const rptCustomObj = (function () {
                 $('#audit-select-hint').html('未选择' + s.attributes['sf-title'].value).show();
                 return;
             }
-            data.audit_select.push({...sf, sort: s.selectedIndex});
+            data.audit_select.push({...sf, sort: sf.audit_order});
         }
         $('#audit-select-hint').hide();
         postData('/report/cDefine', data, function (result) {

+ 0 - 1
app/service/ledger_history.js

@@ -49,7 +49,6 @@ module.exports = app => {
 
             const billsHis = `${this.ctx.session.sessionProject.id}/${tender.id}/ledger/bills${timestamp}.json`;
             const bills = await this.ctx.service.ledger.getData(tender.id);
-            console.log(bills[0]);
             await this.ctx.hisOss.put(this.ctx.hisOssPath + billsHis, Buffer.from(JSON.stringify(bills), 'utf8'));
 
             const posHis = `${this.ctx.session.sessionProject.id}/${tender.id}/ledger/pos${timestamp}.json`;

+ 10 - 8
app/service/report_memory.js

@@ -604,19 +604,21 @@ module.exports = app => {
             if (this.stageValidRole && this.stageValidRole.length > 0) return;
 
             const result = [{dataOrder: 0, flowOrder: 0, uid: this.ctx.stage.user_id}];
-            for (const auditor of this.ctx.stage.auditors) {
-                if (auditor.status === audit.stage.status.checked ||
-                    (auditor.status === audit.stage.status.checking && !this.ctx.stage.readOnly)) {
+            for (const auditorGroup of this.ctx.stage.auditorGroups) {
+                const hasChecked = auditorGroup.find(x => { return x.status === audit.stage.status.checked });
+                const hasOtherStatus = auditorGroup.find(x => { return x.status === audit.stage.status.checkNo || x.status === audit.stage.status.checkNoPre || x.status === audit.stage.status.checkAgain || x.status === audit.stage.status.checkCancel });
+                const isCur = auditorGroup.find(x => { return x.status === audit.stage.status.checking}) && (!this.ctx.stage.readOnly || this.ctx.stage.canCheck);
+                if ((hasChecked && !hasOtherStatus) || isCur) {
                     const role = result.find(function (r) {
-                        return r.uid === auditor.aid;
+                        return r.uid === auditorGroup.map(x => { return x.aid }).join(',');
                     });
                     if (role) {
-                        role.dataOrder = auditor.order;
+                        role.dataOrder = auditorGroup[0].order;
                     } else {
                         result.push({
-                            dataOrder: auditor.order,
-                            flowOrder: result.length,
-                            uid: auditor.aid
+                            dataOrder: auditorGroup[0].order,
+                            flowOrder: auditorGroup[0].audit_order,
+                            uid: auditorGroup.map(x => { return x.aid }).join(',')
                         })
                     }
                 }

+ 5 - 2
app/service/shenpi_audit.js

@@ -102,9 +102,12 @@ module.exports = app => {
             };
             const audit = await this.getDataByCondition(delData);
             const allAudit = await this.getAllDataByCondition({ where: { tid: this.ctx.tender.id, sp_type: data.code, sp_status: data.status } });
+            const sameOrder = allAudit.filter(x => { return x.audit_order === audit.audit_order });
             const updateData = [];
-            for (const aa of allAudit) {
-                if (aa.audit_order > audit.audit_order) updateData.push({ id: aa.id, audit_order: aa.audit_order - 1});
+            if (sameOrder.length === 1) {
+                for (const aa of allAudit) {
+                    if (aa.audit_order > audit.audit_order) updateData.push({ id: aa.id, audit_order: aa.audit_order - 1});
+                }
             }
             const transaction = await this.db.beginTransaction();
             try {

+ 14 - 3
app/service/stage_audit.js

@@ -203,6 +203,7 @@ module.exports = app => {
                 let [newOrder, newAuditOrder] = await this.getNewOrder(stageId, times);
                 // 判断是否存在固定终审,存在则newOrder - 1并使终审order+1
                 newOrder = is_gdzs === 1 ? newOrder - 1 : newOrder;
+                newAuditOrder = is_gdzs === 1 ? newAuditOrder - 1 : newAuditOrder;
                 if (is_gdzs) await this._syncOrderByDelete(transaction, stageId, newOrder, times, '+');
                 const data = {
                     tid: this.ctx.tender.id,
@@ -276,8 +277,9 @@ module.exports = app => {
                 if (!auditor) {
                     throw '该审核人不存在';
                 }
+                // 移除整个流程的人
+                await transaction.delete(this.tableName, { sid: stageId, order: auditor.order, times});
                 await this._syncOrderByDelete(transaction, stageId, auditor.order, times);
-                await transaction.delete(this.tableName, condition);
                 await transaction.commit();
             } catch (err) {
                 await transaction.rollback();
@@ -555,6 +557,15 @@ module.exports = app => {
                     }
                     // 上报/审批 - 检查三方特殊推送
                     await this.ctx.service.specMsg.addStageMsg(transaction, pid, this.ctx.stage, pushOperate.stage.flow);
+                } else {
+                    // 同步 期信息
+                    await transaction.update(this.ctx.service.stage.tableName, {
+                        id: stageId,
+                        status: auditConst.status.checking,
+                        ...stageTp,
+                        tp_history: JSON.stringify(this.ctx.stage.tp_history),
+                        cache_time_r: this.ctx.stage.cache_time_l,
+                    });
                 }
                 await transaction.commit();
             } catch (err) {
@@ -1648,8 +1659,8 @@ module.exports = app => {
 
                     sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`sid`, la.`order`, la.audit_order, la.audit_type ' +
                         '  FROM ?? AS la Left Join ?? AS pa On la.`aid` = pa.`id` ' +
-                        '  WHERE la.`sid` = ? and la.`order` = ?';
-                    sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, stageId, cur.order];
+                        '  WHERE la.`sid` = ? and la.`order` = ? and times = ?';
+                    sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, stageId, cur.order, times];
                     auditor = await this.db.query(sql, sqlParam);
                     break;
                 case auditConst.status.checkNo:

+ 2 - 2
app/view/ledger/audit_modal.ejs

@@ -483,9 +483,9 @@
         const btn = $(this);
 
         $.ajax({
-            url: '/profile/code?_csrf_j=' + csrf,
+            url: '/profile/code?_csrf_j=<%= ctx.csrf %>',
             type: 'post',
-            data: { mobile: authMobile, type: 'shenpi' },
+            data: { mobile: '<%- authMobile %>', type: 'shenpi' },
             dataTye: 'json',
             error: function() {
                 isPosting = false;

+ 4 - 4
app/view/wap/shenpi_stage.ejs

@@ -47,8 +47,8 @@
             <dl class="mb-2 mt-3">
                 <dt class="bg-light p-2 d-flex justify-content-between"><span>第<%- stage.order %>期</span>
                     <span class="<%- auditConst.auditStringClass[stage.status] %>">
-                        <% if (stage.curAuditors && stage.status !== auditConst.status.checked) { %>
-                            <%- (stage.curAuditors[0].audit_type === 1 ? ctx.helper.transFormToChinese(stage.curAuditors[0].audit_order) + '审' : stage.curAuditors[0].name + (stage.curAuditors[0].role ? '-' + stage.curAuditors[0].role : '')) %>
+                        <% if (stage.lastAuditors.length && stage.status !== auditConst.status.checked) { %>
+                            <%- (stage.lastAuditors[0].audit_type !== 1 ? ctx.helper.transFormToChinese(stage.lastAuditors[0].audit_order) + '审' : stage.lastAuditors[0].name + (stage.lastAuditors[0].role ? '-' + stage.lastAuditors[0].role : '')) %>
                         <% } %>
                         <%- stage.status === auditConst.status.checked ? '审批完成' : auditConst.auditProgress[stage.status] %>
                         </span>
@@ -132,7 +132,7 @@
                                 <% } %>
                             <% } else if (auditors[iA].status === auditConst.status.checkNoPre) { %>
                                 <% const auditorIndex = stage.auditors2.findIndex(function (item) { return item.aid === auditors[iA].aid }) %>
-                                <span class="text-warning pull-right"><small><%- auditors[iA].end_time.toLocaleDateString() %></small>审批退回 <%- stage.auditors2[auditorIndex-1].name %></span>
+                                <span class="text-warning pull-right"><small><%- auditors[iA].end_time.toLocaleDateString() %></small>审批退回 </span>
                                 <h5 class="card-title"><i class="<%- (iA < auditors.length - 1 ? 'fa fa-chevron-circle-down text-warning' : 'fa fa-stop-circle text-warning') %>"></i> <%- auditors[iA].name %> <small class="text-muted"><%- auditors[iA].role %></small></h5>
                                 <p class="card-text"><%- auditors[iA].opinion %></p>
                             <% } else if (auditors[iA].status === auditConst.status.checkNo) { %>
@@ -213,7 +213,7 @@
                     <% const auditorIndex = stage.auditors2.findIndex(function (item) { return item.aid === audit.aid }) %>
                     <div class="custom-control custom-radio custom-control-inline">
                         <input class="custom-control-input" type="radio" name="checkType" id="customRadioInline2" value="<%- auditConst.status.checkNoPre %>" checked>
-                        <label class="custom-control-label" for="customRadioInline2">退回上一审批人 <%- stage.auditors2[auditorIndex-1].name %></label>
+                        <label class="custom-control-label" for="customRadioInline2">退回上一审批人</label>
                     </div>
                     <% } %>
                 </div>

+ 7 - 3
app/view/wap/tender.ejs

@@ -141,8 +141,12 @@
                     <% for (const s of stages) { %>
                     <dt class="bg-light p-2 d-flex justify-content-between"><span>第<%- s.order %>期</span>
                         <span class="<%- auditConst.auditStringClass[s.status] %>">
-                            <% if (s.curAuditor && s.status !== auditConst.status.checked) { %>
-                                <%- s.curAuditor.name %><%if (s.curAuditor.role !== '' && s.curAuditor.role !== null) { %>-<%- s.curAuditor.role %><% } %>
+                            <% if (s.curAuditors.length > 0 && s.status !== auditConst.status.checked) { %>
+                                <% if (s.curAuditors[0].audit_type === auditType.key.common) { %>
+                                <%- s.curAuditors[0].name %><%if (s.curAuditors[0].role !== '' && s.curAuditors[0].role !== null) { %>-<%- s.curAuditors[0].role %><% } %>
+                                <% } else { %>
+                                <%- ctx.helper.transFormToChinese(s.curAuditors[0].audit_order) + '审' %>
+                                <% } %>
                             <% } %>
                                 <%- s.status === auditConst.status.checked ? '审批完成' : auditConst.auditProgress[s.status] %>
                         </span>
@@ -191,7 +195,7 @@
                                 </td>
                             </tr>
                             <% } %>
-                            <% if (s.curAuditor && s.status == auditConst.status.checking && s.curAuditor.aid === ctx.session.sessionUser.accountId) { %>
+                            <% if (s.curAuditors.length > 0 && s.status == auditConst.status.checking && s.curAuditors.find(x => { return x.aid === ctx.session.sessionUser.accountId})) { %>
                             <tr>
                                 <td colspan="2">
                                     <a class="btn btn-block btn-success" href="/wap/tender/<%- s.tid %>/measure/stage/<%- s.order %>">审批本期</a>

+ 2 - 2
publish.md

@@ -12,8 +12,8 @@
 
 
 
-### V3.5.34.xxxx
-2023-7-28 ~ uat ~ prod
+### V3.5.34.0841
+2023-7-28 ~ 2023-8-21(uat) ~ prod
 1. 执行脚本
 #### uat
 ```shell

+ 2 - 2
sql/update.sql

@@ -5,11 +5,11 @@ MODIFY COLUMN `stage_flow_pre_uid`  varchar(1000) NOT NULL DEFAULT 0 COMMENT '
 
 ALTER TABLE `zh_shenpi_audit`
 ADD COLUMN `audit_type`  tinyint(4) UNSIGNED NOT NULL DEFAULT 1 COMMENT '审批类型(1个人,2会签,3或签)' AFTER `audit_id`,
-ADD COLUMN `audit_order`  tinyint(4) UNSIGNED ZEROFILL NOT NULL DEFAULT 0 COMMENT '审批顺序' AFTER `audit_type`;
+ADD COLUMN `audit_order`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '审批顺序' AFTER `audit_type`;
 
 ALTER TABLE `zh_stage_audit`
 ADD COLUMN `audit_type`  tinyint(4) UNSIGNED NOT NULL DEFAULT 1 COMMENT '审批类型(1个人,2会签,3或签)' AFTER `is_old`,
-ADD COLUMN `audit_order`  tinyint(4) UNSIGNED ZEROFILL NOT NULL DEFAULT 0 COMMENT '审批顺序' AFTER `audit_type`;
+ADD COLUMN `audit_order`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '审批顺序' AFTER `audit_type`;
 
 ALTER TABLE `zh_payment_tender_info`
 ADD COLUMN `pay_account`  varchar(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '付款账号' AFTER `tech_param`;