Просмотр исходного кода

1. 会签或签相关
2. 更新publish步骤

MaiXinRong 1 год назад
Родитель
Сommit
db8f2820f0

+ 1 - 41
app/controller/spss_controller.js

@@ -40,49 +40,9 @@ module.exports = app => {
         }
 
         async _checkStage(tid, sorder) {
-            const _ = this.ctx.helper._;
             const stage = await this.service.stage.getDataByCondition({ tid: tid, order: sorder });
             if (!stage) throw '期数据错误';
-
-            // 读取原报、审核人数据
-            stage.auditors = await this.service.stageAudit.getAuditors(stage.id, stage.times);
-            stage.curAuditor = await this.service.stageAudit.getCurAuditor(stage.id, stage.times);
-            const accountId = this.ctx.session.sessionUser.accountId, auditorIds = _.map(stage.auditors, 'aid'), shareIds = [];
-            const permission = this.ctx.session.sessionUser.permission;
-
-            if (accountId === stage.user_id) { // 原报
-                stage.curTimes = stage.times;
-                if (stage.status === status.uncheck || stage.status === status.checkNo) {
-                    stage.curOrder = 0;
-                } else if (stage.status === status.checked) {
-                    stage.curOrder = _.max(_.map(stage.auditors, 'order'));
-                } else {
-                    stage.curOrder = stage.curAuditor.aid === accountId ? stage.curAuditor.order : stage.curAuditor.order - 1;
-                }
-            } else if (auditorIds.indexOf(accountId) !== -1) { // 审批人
-                if (stage.status === status.uncheck) {
-                    throw '您无权查看该数据';
-                }
-                stage.curTimes = stage.status === status.checkNo ? stage.times - 1 : stage.times;
-                if (stage.status === status.checked) {
-                    stage.curOrder = _.max(_.map(stage.auditors, 'order'));
-                } else if (stage.status === status.checkNo) {
-                    const audit = await this.service.stageAudit.getDataByCondition({
-                        sid: stage.id, times: stage.times - 1, status: status.checkNo
-                    });
-                    stage.curOrder = audit.order;
-                } else {
-                    stage.curOrder = accountId === stage.curAuditor.aid ? stage.curAuditor.order : stage.curAuditor.order - 1;
-                }
-            } else if (shareIds.indexOf(accountId) !== -1 || (permission !== null && permission.tender !== undefined && permission.tender.indexOf('2') !== -1)) { // 分享人
-                if (stage.status === status.uncheck) {
-                    throw '您无权查看该数据';
-                }
-                stage.curTimes = stage.status === status.checkNo ? stage.times - 1 : stage.times;
-                stage.curOrder = stage.status === status.checked ? _.max(_.map(stage.auditors, 'order')) : stage.curAuditor.order - 1;
-            } else { // 其他不可见
-                throw '您无权查看该数据';
-            }
+            await this.service.stage.doCheckStage(stage);
             return stage;
         }
 

+ 0 - 1
app/controller/stage_rela_controller.js

@@ -102,7 +102,6 @@ module.exports = app => {
                 [renderData.ledgerSpread, renderData.posSpread] = await spreadSetting.getStageSpreadSetting(ctx, null, true, {minusNoValue: renderData.minusNoValue});
                 renderData.measureType = measureType;
                 renderData.whiteList = this.ctx.app.config.multipart.whitelist;
-                renderData.curAuditor = ctx.stage.curAuditor;
                 renderData.auditConst = auditConst;
                 renderData.thirdParty = {
                     gxby: ctx.session.sessionProject.gxby_status, dagl: ctx.session.sessionProject.dagl_status,

+ 1 - 1
app/middleware/stage_check.js

@@ -21,7 +21,7 @@ module.exports = options => {
      * 写入ctx.stage数据
      * 其中:
      * stage.auditors: 审批人列表(退回原报时,加载上一流程)
-     * stage.curAuditor: 当前审批人(未上报为空,审批通过 or 退回原报时,为空)
+     * stage.curAuditors: 当前审批人(未上报为空,审批通过 or 退回原报时,为空)
      * stage.readonly: 登录人,是否可操作
      * stage.curTimes: 当前登录人,操作、查阅数据times
      * stage.curOrder: 当前登录人,操作、查阅数据order

+ 5 - 1
app/public/report/js/rpt_custom.js

@@ -219,8 +219,12 @@ const rptCustomObj = (function () {
     const getStageFlowSelectHtml = function (select, id) {
         const html = [];
         html.push('<select style="width: 80%" id="' + id + '" sf-title="' + select.title + '">');
+        const maxOrder = stageFlow.reduce((rst, sf) => { return sf.audit_order && sf.audit_order > rst ? sf.audit_order : rst;}, 1);
         for (const sf of stageFlow) {
-            html.push(`<option ${sf.visible ? '' : 'style="display: none"'}>${sf.name}-${sf.role}</option>`);
+            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('</select>');
         return html.join('');

+ 4 - 1
app/service/stage.js

@@ -207,6 +207,8 @@ module.exports = app => {
                 if (stage.status !== status.checkNo) {
                     // 找出当前操作人上一个审批人,包括审批完成的和退回上一个审批人的,同时当前操作人为第一人时,就是则为原报
                     if (stage.flowAuditors.find(x => { return x.status !== auditConst.stage.status.checking})) return; // 当前流程存在审批人审批通过时,不可撤回
+                    const flowAssists = stage.auditAssists.filter(x => { return stage.flowAuditorIds.indexOf(x.user_id) >= 0; });
+                    if (flowAssists.find(x => { return x.confirm; })) return; //当前流程存在协审人确认时,不可撤回
                     if (stage.curAuditorIds.indexOf(accountId) < 0 && stage.flowAuditorIds.indexOf(accountId) >= 0) {
                         stage.cancancel = 5; // 会签未全部审批通过时,审批人撤回审批通过
                         return;
@@ -832,7 +834,8 @@ module.exports = app => {
             for (const sid of stage_id_list) {
                 const stage = await this.getDataById(sid);
                 stage.auditors = await this.service.stageAudit.getAuditors(stage.id, stage.times);
-                stage.curAuditor = await this.service.stageAudit.getCurAuditor(stage.id, stage.times);
+                // todo 不确定是否使用,暂时注释,待测试验证
+                // stage.curAuditor = await this.service.stageAudit.getCurAuditor(stage.id, stage.times);
                 stage.curOrder = _.max(_.map(stage.auditors, 'order'));
                 stage.curTimes = stage.times;
                 list.push(stage);

+ 2 - 2
app/service/stage_detail.js

@@ -149,7 +149,7 @@ module.exports = app => {
         async saveDetailData(data) {
             if (data.uuid) {
                 const org = await this.getLastestImStageData(this.ctx.tender.id, this.ctx.stage.id, data.lid, data.uuid);
-                const order = this.ctx.stage.curAuditor ? this.ctx.stage.curAuditor.order : 0;
+                const order = this.ctx.stage.curAuditors.length > 0 ? this.ctx.stage.curAuditors[0].order : 0;
                 if (org.times === this.ctx.stage.times && org.order === order) {
                     delete org.flow;
                     const newData = this._.assign(org, data);
@@ -169,7 +169,7 @@ module.exports = app => {
                 data.tid = this.ctx.tender.id;
                 data.sid = this.ctx.stage.id;
                 data.times = this.ctx.stage.times;
-                data.order = this.ctx.stage.curAuditor ? this.ctx.stage.curAuditor.order : 0;
+                data.order = this.ctx.stage.curAuditors.length > 0 ? this.ctx.stage.curAuditors[0].order : 0;
                 await this.db.insert(this.tableName, data);
                 return data;
             }

+ 1 - 1
app/service/stage_stash.js

@@ -176,7 +176,7 @@ module.exports = app => {
             const result = await this.db.insert(this.tableName, {
                 pid: this.ctx.session.sessionProject.id, tid: stage.tid, sid: stage.id, sorder: stage.order,
                 uid: this.ctx.session.sessionUser.accountId, uname: this.ctx.session.sessionUser.name,
-                filepath, info: JSON.stringify({ status: stage.status, flow: stage.curAuditor ? stage.curAuditor.user_id : stage.uid }), remark
+                filepath, info: JSON.stringify({ status: stage.status, flow: stage.curAuditorIds.length > 0 ? stage.curAuditorIds : stage.uid }), remark
             });
             return result.insertId;
         }

+ 2 - 2
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.curAuditor && stage.status !== auditConst.status.checked) { %>
-                            <%- stage.curAuditor.name %><%if (stage.curAuditor.role !== '' && stage.curAuditor.role !== null) { %>-<%- stage.curAuditor.role %><% } %>
+                        <% 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 : '')) %>
                         <% } %>
                         <%- stage.status === auditConst.status.checked ? '审批完成' : auditConst.auditProgress[stage.status] %>
                         </span>

+ 109 - 0
db_script/audit_order.js

@@ -0,0 +1,109 @@
+const BaseUtil = require('./baseUtils');
+const querySql = BaseUtil.querySql;
+const sp_status = {
+    sqspr: 1, // 授权审批人
+    gdspl: 2, // 固定审批流
+    gdzs: 3, // 固定终审
+};
+// 审批类型
+const sp_type = {
+    advance: 1,
+    ledger: 2,
+    revise: 3,
+    stage: 4,
+    change: 5,
+    material: 6,
+};
+
+const errorStageTimes = [];
+
+const updateShenpiAudit = async function (tender, type) {
+    const shenpiData = await querySql('Select * From zh_shenpi_audit where tid = ? AND sp_type = ? AND sp_status = ? ORDER BY id', [tender.id, type, sp_status.gdspl]);
+    if (shenpiData.length === 0) return;
+
+    for (const [i, spd] of shenpiData.entries()) {
+        if (spd.audit_order > 0) continue;
+        await querySql('UPDATE zh_shenpi_audit SET audit_order = ? WHERE id = ?', [i+1, spd.id]);
+    }
+};
+
+const updateShenpi = async function (tender) {
+    updateShenpiAudit(tender, sp_type.advance);
+    updateShenpiAudit(tender, sp_type.ledger);
+    updateShenpiAudit(tender, sp_type.revise);
+    updateShenpiAudit(tender, sp_type.stage);
+    updateShenpiAudit(tender, sp_type.change);
+    updateShenpiAudit(tender, sp_type.material);
+};
+
+const updateStageTimes = async function (stage, times) {
+    const auditData = await querySql('SELECT * FROM zh_stage_audit WHERE sid = ? AND times = ? ORDER BY `order`', [stage.id, times]);
+    if (auditData.length === 0) return;
+
+    const auditIds = [], filterIds = [];
+    for (const ad of auditData) {
+        if (ad.audit_order) {
+            if (filterIds.indexOf(ad.aid) < 0) filterIds.push(ad.aid);
+        } else if (auditIds.indexOf(ad.aid) < 0) auditIds.push(ad.aid);
+    }
+    if (auditIds.length === 0) return;
+    if (filterIds.length > 0 && auditIds.length > 0) errorStageTimes.push({ tid: stage.tid, sid: stage.id, times });
+    for (const [i, aid] of auditIds.entries()) {
+        await querySql('UPDATE zh_stage_audit SET audit_order = ? WHERE sid = ? AND times = ? AND aid = ?', [i+1, stage.id, times, aid]);
+    }
+};
+
+const updateStage = async function (stage) {
+    for (let i = 1; i <= stage.times; i++) {
+        await updateStageTimes(stage, i);
+    }
+};
+
+const doCompleteTest = async function(id) {
+    try {
+        const tender = await querySql('Select * From zh_tender where id = ?', [id]);
+        for (const t of tender) {
+            console.log(`Update Tender ${t.name}(${t.id}):`);
+            await updateShenpi(t);
+            const stages = await querySql('Select * From zh_stage where tid = ?', [t.id]);
+            for (const s of stages) {
+                await updateStage(s);
+            }
+        }
+    } catch (err) {
+        console.log(err);
+    }
+    BaseUtil.closePool();
+    if (errorStageTimes.length > 0) {
+        console.log('ERROR stage info: ');
+        console.log(errorStageTimes);
+    }
+};
+
+const doComplete = async function() {
+    try {
+        const tenders = await querySql('Select * From zh_tender');
+        for (const t of tenders) {
+            console.log(`Update Tender ${t.name}(${t.id}):`);
+            await updateShenpi(t);
+            const stages = await querySql('Select * From zh_stage where tid = ?', [t.id]);
+            for (const s of stages) {
+                await updateStage(s);
+            }
+        }
+    } catch (err) {
+        console.log(err);
+    }
+    BaseUtil.closePool();
+    if (errorStageTimes.length > 0) {
+        console.log('ERROR stage info: ');
+        console.log(errorStageTimes);
+    }
+};
+
+const tenderId = process.argv[3];
+if (tenderId) {
+    doCompleteTest(tenderId);
+} else {
+    doComplete()
+}

+ 16 - 0
publish.md

@@ -10,6 +10,22 @@
 ##特殊操作
 如果没有特殊说明,则在第默认操作的第3步前,执行相关脚本,如果有特殊要求,需特别说明
 
+
+
+### V3.5.34.xxxx
+2023-7-28 ~ uat ~ prod
+1. 执行脚本
+#### uat
+```shell
+$ cd db_script
+$ node audit_order uat
+```
+#### prod
+```shell
+$ cd db_script
+$ node audit_order default
+```
+
 ### V3.5.33.0755
 2023-7-21 ~ 2023-7-28(uat/prod)