| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- 'use strict';
- /**
- * weapp控制器
- *
- * @author Lan
- * @date 2025/12/22
- * @version
- */
- module.exports = app => {
- class WeappSubpController extends app.BaseController {
- async subProjectList(ctx) {
- try {
- const list = await ctx.service.subProject.getSubProject(ctx.project.id, ctx.projectAccount.id, ctx.projectAccount.is_admin);
- ctx.body = {
- code: 0, msg: '', data: {
- list,
- },
- };
- } catch (error) {
- this.log(error);
- ctx.body = { code: -1, msg: '', data: null };
- }
- }
- async subProjectDetail(ctx) {
- try {
- const { id: subProjectId } = ctx.query;
- if (!subProjectId) {
- ctx.body = { code: -1, msg: '子项目ID不能为空', data: null };
- return;
- }
- const subProject = await ctx.service.subProject.getDataById(subProjectId);
- if (!subProject) {
- ctx.body = { code: -1, msg: '子项目不存在', data: null };
- return;
- }
- const pageShow = subProject.page_show ? JSON.parse(subProject.page_show) : {};
- const auditList = [];
- // 获取待审批的计量期列表
- const auditStages = await ctx.service.stageAudit.getAuditStageByWap(ctx.projectAccount.id, subProjectId);
- auditList.push(...(auditStages.map(item => ({ ...item, type: 'stage', subType: 'stage' }))));
- // 获取待审批的变更期
- const auditChanges = await ctx.service.changeAudit.getAuditChangeByWap(ctx.projectAccount.id, subProjectId);
- auditList.push(...(auditChanges.map(item => ({ ...item, type: 'change', subType: 'change' }))));
- // 获取待审批的变更立项
- if (pageShow.openChangeProject) {
- const changeProjects = await ctx.service.changeProjectAudit.getAuditChangeProjectByWap(ctx.projectAccount.id, subProjectId);
- auditList.push(...(changeProjects.map(item => ({ ...item, type: 'change', subType: 'changeProject' }))));
- }
- // 获取待审批的变更申请
- if (pageShow.openChangeApply) {
- const changeApplys = await ctx.service.changeApplyAudit.getAuditChangeApplyByWap(ctx.projectAccount.id, subProjectId);
- auditList.push(...(changeApplys.map(item => ({ ...item, type: 'change', subType: 'changeApply' }))));
- }
- // 获取待审批的变更方案
- if (pageShow.openChangePlan) {
- const changePlans = await ctx.service.changePlanAudit.getAuditChangePlanByWap(ctx.projectAccount.id, subProjectId);
- auditList.push(...(changePlans.map(item => ({ ...item, type: 'change', subType: 'changePlan' }))));
- }
- // 获取待审批的台账修订
- const ledgerRevises = await ctx.service.reviseAudit.getAuditReviseByWap(ctx.projectAccount.id, subProjectId);
- auditList.push(...(ledgerRevises.map(item => ({ ...item, type: 'revise', subType: 'revise' }))));
- // 获取待审批的预付款
- const auditAdvance = await ctx.service.advanceAudit.getAuditAdvanceByWap(ctx.projectAccount.id, subProjectId);
- auditList.push(...(auditAdvance.map(item => ({ ...item, type: 'advance', subType: 'advance' }))));
- // 获取待审批的材料调差
- if (pageShow.openMaterial) {
- const materialList = await ctx.service.materialAudit.getAuditMaterialByWap(ctx.projectAccount.id, subProjectId);
- auditList.push(...(materialList.map(item => ({ ...item, type: 'material', subType: 'material' }))));
- }
- // 获取待审批的质量巡检单
- if (pageShow.qualityInspection) {
- const qualityInspectionList = await ctx.service.qualityInspectionAudit.getAuditInspectionByWap(ctx.projectAccount.id, subProjectId);
- auditList.push(...(qualityInspectionList.map(item => ({ ...item, type: 'qualityInspection', subType: 'qualityInspection' }))));
- }
- // 获取待审批的安全巡检
- if (pageShow.safeInspection) {
- const safeInspectionList = await ctx.service.safeInspectionAudit.getAuditInspectionByWap(ctx.projectAccount.id, subProjectId);
- auditList.push(...(safeInspectionList.map(item => ({ ...item, type: 'safeInspection', subType: 'safeInspection' }))));
- }
- // 按照审批时间倒序排序
- auditList.sort((a, b) => new Date(b.begin_time).getTime() - new Date(a.begin_time).getTime());
- // 获取消息列表
- const msgList = await ctx.service.message.getMsgList(ctx.project.id, subProjectId, 1);
- ctx.body = {
- code: 0, msg: '', data: {
- auditList,
- msgList,
- },
- };
- } catch (error) {
- this.log(error);
- ctx.body = { code: -1, msg: '', data: null };
- }
- }
- }
- return WeappSubpController;
- };
|