|
@@ -40,6 +40,46 @@ module.exports = app => {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ async getAuditStageAss(ass_user_id) {
|
|
|
+ // 找出待上报或待审批的协同字段
|
|
|
+ const accountStageAssData = await this.getAllDataByCondition({ where: { ass_user_id, confirm: 0 } });
|
|
|
+ const result = [];
|
|
|
+ const accountAssData = await this.ctx.service.auditAss.getAllDataByCondition({ where: { ass_user_id } });
|
|
|
+ for (const as of accountStageAssData) {
|
|
|
+ const index = accountAssData.findIndex(x => { return x.tid === as.tid && x.user_id === as.user_id; });
|
|
|
+ if (index >= 0) {
|
|
|
+ accountAssData.splice(index, 1);
|
|
|
+ result.push(as);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.push(...accountAssData);
|
|
|
+ // 判断该标段是否存在待审批或待上报的协同人,同时到本人协同阶段
|
|
|
+ const result2 = [];
|
|
|
+ if (result.length > 0) {
|
|
|
+ for (const r of result) {
|
|
|
+ const t = await this.ctx.service.tender.getDataById(r.tid);
|
|
|
+ const s = r.sid ? await this.ctx.service.stage.getDataById(r.sid) : await this.ctx.service.stage.getLastestStage(r.tid);
|
|
|
+ if (s) {
|
|
|
+ r.tender_name = t.name;
|
|
|
+ r.sstatus = s.status;
|
|
|
+ r.sorder = s.order;
|
|
|
+ if (s && s.status === auditConst.stage.status.checkNo && s.user_id === r.user_id) {
|
|
|
+ const lastAudit = await this.ctx.service.stageAudit.getLastestAuditor(s.id, s.times - 1, auditConst.stage.status.checkNo);
|
|
|
+ r.begin_time = lastAudit ? lastAudit.end_time : s.in_time;
|
|
|
+ result2.push(r);
|
|
|
+ } else {
|
|
|
+ const curAudits = await this.ctx.service.stageAudit.getCurAuditors(s.id, s.times);
|
|
|
+ if (curAudits.length > 0 && this._.findIndex(curAudits, { user_id: r.user_id }) !== -1) {
|
|
|
+ r.begin_time = curAudits[0].begin_time;
|
|
|
+ result2.push(r);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result2;
|
|
|
+ }
|
|
|
+
|
|
|
async getUserAssist(stage, user_id) {
|
|
|
const stageData = await this.getAllDataByCondition({ where: { sid: stage.id, times: stage.times, user_id } });
|
|
|
if (stage.status === auditConst.stage.status.checked) return stageData;
|