Browse Source

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

MaiXinRong 10 months ago
parent
commit
d9141966f8

+ 12 - 18
app/controller/change_controller.js

@@ -433,9 +433,8 @@ module.exports = app => {
                 // 获取用户人验证手机号
                 // 获取用户人验证手机号
                 const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
                 const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
                 const auth_mobile = pa.auth_mobile;
                 const auth_mobile = pa.auth_mobile;
-                const userPermission = pa !== undefined && pa.permission !== ''
-                    ? JSON.parse(pa.permission) : null;
-                const deleteFilePermission = userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1;
+                const userPermission = pa && pa.permission ? JSON.parse(pa.permission) : null;
+                const deleteFilePermission = !!(userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1);
                 const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
                 const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
                 const settleBills = ctx.change.readySettle ? await ctx.service.settleBills.getAllDataByCondition({ where: { settle_id: ctx.change.readySettle.id } }) : [];
                 const settleBills = ctx.change.readySettle ? await ctx.service.settleBills.getAllDataByCondition({ where: { settle_id: ctx.change.readySettle.id } }) : [];
                 const settlePos = ctx.change.readySettle ? await ctx.service.settlePos.getAllDataByCondition({ where: { settle_id: ctx.change.readySettle.id } }) : [];
                 const settlePos = ctx.change.readySettle ? await ctx.service.settlePos.getAllDataByCondition({ where: { settle_id: ctx.change.readySettle.id } }) : [];
@@ -1267,9 +1266,8 @@ module.exports = app => {
                     throw '该文件不存在';
                     throw '该文件不存在';
                 }
                 }
                 const accountInfo = await this.ctx.service.projectAccount.getDataById(this.ctx.session.sessionUser.accountId);
                 const accountInfo = await this.ctx.service.projectAccount.getDataById(this.ctx.session.sessionUser.accountId);
-                const userPermission = accountInfo !== undefined && accountInfo.permission !== ''
-                    ? JSON.parse(accountInfo.permission) : null;
-                const deleteFilePermission = userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1;
+                const userPermission = accountInfo && accountInfo.permission ? JSON.parse(accountInfo.permission) : null;
+                const deleteFilePermission = !!(userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1);
                 if (!fileInfo.extra_upload && change.status === audit.change.status.checked && !deleteFilePermission) {
                 if (!fileInfo.extra_upload && change.status === audit.change.status.checked && !deleteFilePermission) {
                     throw '无权限删除';
                     throw '无权限删除';
                 }
                 }
@@ -2175,9 +2173,8 @@ module.exports = app => {
                 // 获取用户人验证手机号
                 // 获取用户人验证手机号
                 const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
                 const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
                 const auth_mobile = pa.auth_mobile;
                 const auth_mobile = pa.auth_mobile;
-                const userPermission = pa !== undefined && pa.permission !== ''
-                    ? JSON.parse(pa.permission) : null;
-                const deleteFilePermission = userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1;
+                const userPermission = pa && pa.permission ? JSON.parse(pa.permission) : null;
+                const deleteFilePermission = !!(userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1);
                 // 判断并更新
                 // 判断并更新
                 const renderData = {
                 const renderData = {
                     tender: ctx.tender,
                     tender: ctx.tender,
@@ -3031,9 +3028,8 @@ module.exports = app => {
                 // 获取用户人验证手机号
                 // 获取用户人验证手机号
                 const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
                 const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
                 const auth_mobile = pa.auth_mobile;
                 const auth_mobile = pa.auth_mobile;
-                const userPermission = pa !== undefined && pa.permission !== ''
-                    ? JSON.parse(pa.permission) : null;
-                const deleteFilePermission = userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1;
+                const userPermission = pa && pa.permission ? JSON.parse(pa.permission) : null;
+                const deleteFilePermission = !!(userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1);
                 const renderData = {
                 const renderData = {
                     tender,
                     tender,
                     change: ctx.change,
                     change: ctx.change,
@@ -3088,9 +3084,8 @@ module.exports = app => {
                 const fileList = await ctx.service.changeApplyAtt.getAllChangeApplyAtt(ctx.tender.id, ctx.change.id);
                 const fileList = await ctx.service.changeApplyAtt.getAllChangeApplyAtt(ctx.tender.id, ctx.change.id);
                 await this._getChangeApplyAuditViewData(ctx);
                 await this._getChangeApplyAuditViewData(ctx);
                 const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
                 const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
-                const userPermission = pa !== undefined && pa.permission !== ''
-                    ? JSON.parse(pa.permission) : null;
-                const deleteFilePermission = userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1;
+                const userPermission = pa && pa.permission ? JSON.parse(pa.permission) : null;
+                const deleteFilePermission = !!(userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1);
                 const renderData = {
                 const renderData = {
                     tender,
                     tender,
                     change: ctx.change,
                     change: ctx.change,
@@ -3866,9 +3861,8 @@ module.exports = app => {
                 // 获取用户人验证手机号
                 // 获取用户人验证手机号
                 const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
                 const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
                 const auth_mobile = pa.auth_mobile;
                 const auth_mobile = pa.auth_mobile;
-                const userPermission = pa !== undefined && pa.permission !== ''
-                    ? JSON.parse(pa.permission) : null;
-                const deleteFilePermission = userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1;
+                const userPermission = pa && pa.permission ? JSON.parse(pa.permission) : null;
+                const deleteFilePermission = !!(userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1);
                 const changeClass = await this._getOrUpdateClass(ctx, 'changePlan');
                 const changeClass = await this._getOrUpdateClass(ctx, 'changePlan');
                 const renderData = {
                 const renderData = {
                     tender,
                     tender,

+ 20 - 2
app/controller/report_controller.js

@@ -958,6 +958,7 @@ module.exports = app => {
         }
         }
 
 
         async _commonGetAudit(ctx, params, stgAudit) {
         async _commonGetAudit(ctx, params, stgAudit) {
+            const COMMON_INVALID_STATUS_FOR_ORG = [1, 6]; // 对原报来说,待上报、重新上报状态就不能默认为审核通过
             switch (params.stage_id) {
             switch (params.stage_id) {
                 case -300: // 变更令
                 case -300: // 变更令
                     const changeAudit = await ctx.service.changeAudit.getAuditors(params.change_id, params.change_times, 'asc', true);
                     const changeAudit = await ctx.service.changeAudit.getAuditors(params.change_id, params.change_times, 'asc', true);
@@ -1003,11 +1004,13 @@ module.exports = app => {
                     const advanceList = await ctx.service.advance.getAdvanceListDirectly(params.tender_id);
                     const advanceList = await ctx.service.advance.getAdvanceListDirectly(params.tender_id);
                     for (const advance of advanceList) {
                     for (const advance of advanceList) {
                         if (advance.id === params.advance_id) {
                         if (advance.id === params.advance_id) {
-                            stgAudit.push({ aid: advance.uid, status: 3, opinion: '同意', end_time: advance.end_time || (new Date()), order: 0 }); // 加上原报,默认status为3
+                            stgAudit.push({ aid: advance.uid, status: 3, opinion: '同意', end_time: advance.create_time || (new Date()), order: 0 }); // 加上原报,默认status为3
+                            if (COMMON_INVALID_STATUS_FOR_ORG.includes(advance.status)) stgAudit[0].status = advance.status;
                             break;
                             break;
                         }
                         }
                     }
                     }
                     const advanceAuditList = await ctx.service.advanceAudit.getAuditAdvanceByTender(params.tender_id);
                     const advanceAuditList = await ctx.service.advanceAudit.getAuditAdvanceByTender(params.tender_id);
+                    // let maxTimes = -1;
                     advanceAuditList.forEach(advAudit => {
                     advanceAuditList.forEach(advAudit => {
                         if (advAudit.vid === params.advance_id) {
                         if (advAudit.vid === params.advance_id) {
                             stgAudit.push({ aid: advAudit.audit_id, status: advAudit.status, opinion: advAudit.opinion || '同意', end_time: advAudit.end_time || (new Date()), times: advAudit.times, order: advAudit.order });
                             stgAudit.push({ aid: advAudit.audit_id, status: advAudit.status, opinion: advAudit.opinion || '同意', end_time: advAudit.end_time || (new Date()), times: advAudit.times, order: advAudit.order });
@@ -1019,11 +1022,26 @@ module.exports = app => {
                     for (const material of materialList) {
                     for (const material of materialList) {
                         if (material.id === params.material_id) {
                         if (material.id === params.material_id) {
                             stgAudit.push({ aid: material.user_id, status: 3, opinion: '同意', end_time: material.in_time, order: 0 }); // 加上原报,默认status为3
                             stgAudit.push({ aid: material.user_id, status: 3, opinion: '同意', end_time: material.in_time, order: 0 }); // 加上原报,默认status为3
+                            if (COMMON_INVALID_STATUS_FOR_ORG.includes(material.status)) stgAudit[0].status = material.status;
+                            break;
                         }
                         }
                     }
                     }
                     const materialAdjAuditList = await ctx.service.materialAudit.getAuditorsByTender(params.tender_id);
                     const materialAdjAuditList = await ctx.service.materialAudit.getAuditorsByTender(params.tender_id);
+                    let maxTimes = -1;
+                    // let orgTime = null;
                     materialAdjAuditList.forEach(material => {
                     materialAdjAuditList.forEach(material => {
-                        if (material.id === params.material_id) {
+                        if (material.mid === params.material_id) {
+                            if (material.times > maxTimes) {
+                                maxTimes = material.times;
+                                if (material.order === 1) {
+                                    // orgTime = material.begin_time;
+                                    stgAudit[0].end_time = material.begin_time || stgAudit[0].end_time; // 如果是待上报,没有begin_time,则保留时间
+                                }
+                            }
+                        }
+                    });
+                    materialAdjAuditList.forEach(material => {
+                        if (material.mid === params.material_id) {
                             stgAudit.push({ aid: material.aid, status: material.status, opinion: material.opinion, end_time: material.end_time, order: material.order }); // 加上原报
                             stgAudit.push({ aid: material.aid, status: material.status, opinion: material.opinion, end_time: material.end_time, order: material.order }); // 加上原报
                         }
                         }
                     });
                     });

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

@@ -948,8 +948,8 @@ let rptSignatureHelper = {
                 // break; //因为实际业务中会有反复,所以就不break了,一直判断,以最后一个为准
                 // break; //因为实际业务中会有反复,所以就不break了,一直判断,以最后一个为准
             }
             }
         }
         }
-        if (!rst) {
-            // 还有原报需要检测
+        if (!rst && current_stage_id > 0) {
+            // 还有原报需要检测(这里是计量期单独的判断)
             for (const stg_ort_rpt of STAGE_LIST) {
             for (const stg_ort_rpt of STAGE_LIST) {
                 if (role_rel.acc_id === stg_ort_rpt.user_id) {
                 if (role_rel.acc_id === stg_ort_rpt.user_id) {
                     if (stg_ort_rpt.status !== 1 && stg_ort_rpt.status !== 4) {
                     if (stg_ort_rpt.status !== 1 && stg_ort_rpt.status !== 4) {