|
|
@@ -4,6 +4,7 @@
|
|
|
* Created by Tony on 2019/7/5.
|
|
|
*/
|
|
|
|
|
|
+const audit = require('../const/audit');
|
|
|
const tenderMenu = require('../../config/menu').tenderMenu;
|
|
|
const measureType = require('../const/tender').measureType;
|
|
|
const auditConst = require('../const/audit');
|
|
|
@@ -1411,21 +1412,174 @@ module.exports = app => {
|
|
|
await this._indexForContract(ctx, sourceTypeConst.sourceType.contract, -600, preUrl, thisUrl);
|
|
|
}
|
|
|
|
|
|
- async indexForCostManager(ctx) {
|
|
|
+ async getTypeStages(ctx, stage_type, sort = 'DESC') {
|
|
|
+ const stages = await this.ctx.service.costStage.getAllStages(ctx.tender.id, stage_type, sort);
|
|
|
+ for (const s of stages) {
|
|
|
+ if (s.audit_status !== audit.common.status.checked) {
|
|
|
+ await this.ctx.service.costStage.loadUser(s);
|
|
|
+ s.is_join = s.userIds.indexOf(this.ctx.session.sessionUser.accountId) >= 0;
|
|
|
+ // 实时计算 // 暂不开放
|
|
|
+ // await this.ctx.service.costStage.calcRealtime(s);
|
|
|
+ } else {
|
|
|
+ const auditors = await this.ctx.service.costStageAudit.getAuditors(s.id, s.audit_times);
|
|
|
+ s.is_join = auditors.findIndex(a => { return a.audit_id === this.ctx.session.sessionUser.accountId; }) >= 0;
|
|
|
+ }
|
|
|
+ s.can_del = (s.create_user_id === ctx.session.sessionUser.accountId || ctx.session.sessionUser.is_admin)
|
|
|
+ && (s.audit_status === audit.common.status.uncheck || s.audit_status === audit.common.status.checkNo);
|
|
|
+ }
|
|
|
+ if (this.ctx.session.sessionUser.is_admin || this.ctx.permission.cost.visitor || this.ctx.permission.cost[stage_type + '_add']) return stages;
|
|
|
+ return stages.filter(s => { return s.is_join; });
|
|
|
+ }
|
|
|
+
|
|
|
+ async indexForCostManager(ctx, source_type, show_stage_id) {
|
|
|
// 成本管理报表入口
|
|
|
try {
|
|
|
- const ledge_stage_type = this.ctx.service.costStage.stageType.ledger.key;
|
|
|
+ // const ledge_stage_type = this.ctx.service.costStage.stageType.ledger.key;
|
|
|
+ // const ledge_stages = await this.getTypeStages(ctx, ledge_stage_type);
|
|
|
+ // const book_stage_type = this.ctx.service.costStage.stageType.book.key;
|
|
|
+ // const book_stages = await this.getTypeStages(ctx, book_stage_type);
|
|
|
const analysis_stage_type = this.ctx.service.costStage.stageType.analysis.key;
|
|
|
- const book_stage_type = this.ctx.service.costStage.stageType.book.key;
|
|
|
- const ledge_stages = await this.getTypeStages(ctx, ledge_stage_type);
|
|
|
const analysis_stages = await this.getTypeStages(ctx, analysis_stage_type);
|
|
|
- const book_stages = await this.getTypeStages(ctx, book_stage_type);
|
|
|
// await this._getCostManagerViewData(ctx);
|
|
|
+ // 普通报表界面需要的信息
|
|
|
+ const pageShow = ctx.session.sessionProject.page_show;
|
|
|
+ pageShow.closeWatermark = 1;
|
|
|
+ pageShow.showArchive = 1;
|
|
|
+ pageShow.closeShowAllCustomized = 0;
|
|
|
+ // const tenderId = ctx.params.tid || -1; // 标段级别有
|
|
|
+ const tenderId = ctx.params.tid || -1;
|
|
|
+ const bglObj = {};
|
|
|
+ // const bglObj = { status: stage_status };
|
|
|
+ bglObj.BUSINESS_ID = ctx.params.id;
|
|
|
+ // cost_stage_id: uuid
|
|
|
+ const stage = analysis_stages[0]; // 默认取最新的cost- analysis stage
|
|
|
+ const stage_order = stage.stage_order;
|
|
|
+ const sorder = -1;
|
|
|
+ const stage_times = stage.audit_times;
|
|
|
+ // const stage_status = -1;
|
|
|
+ const stage_status = stage.audit_status;
|
|
|
+ const project_id = ctx.subProject.id;
|
|
|
+ // const { treeNodes, custCfg, commonArrs } = await this._createNodes(ctx, sourceTypeConst.sourceType.contract, project_id);
|
|
|
+ const { treeNodes, custCfg, commonArrs, allTreeItems, allIndivTreeItems } = await this._createNodes(ctx, source_type, project_id);
|
|
|
+ // const custTreeFolders = await this._getCustFolder(ctx, this.ctx.session.sessionUser.accountId, tenderId);
|
|
|
+ const custTreeFolders = [];
|
|
|
+ const rpt_tpl_items = { customize: [], common: [] };
|
|
|
+ if (custTreeFolders.length > 0) {
|
|
|
+ const cust_select_item = JSON.parse(custTreeFolders[0].rpt_tpl_items);
|
|
|
+ if (cust_select_item.common) rpt_tpl_items.common = cust_select_item.common;
|
|
|
+ if (cust_select_item.customize) rpt_tpl_items.customize = cust_select_item.customize;
|
|
|
+ }
|
|
|
+ const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: project_id } }); // 找公司章用的
|
|
|
+ const cust_select_keys = JSON.stringify(['common', 'customize']);
|
|
|
+ const roleList = await ctx.service.signatureRole.getSignatureRolesByTenderId(tenderId);
|
|
|
+ const usedList = await ctx.service.signatureUsed.getSignatureUsedByTenderId(tenderId);
|
|
|
+ const prjAccList = await this._getPrjAccList(ctx, pageShow);
|
|
|
+ this._resetAccCompanySignPath(ctx, prjAccList);
|
|
|
+
|
|
|
+ // 分类列表
|
|
|
+ const categoryData = await this.ctx.service.category.getAllCategory(ctx.subProject);
|
|
|
+ // 获取用户权限
|
|
|
+ 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 tenderList = await this.ctx.service.tender.getList('', userPermission);
|
|
|
+ for (const t of tenderList) {
|
|
|
+ if (t.ledger_status === auditConst.ledger.status.checked) {
|
|
|
+ t.lastStage = await this.ctx.service.stage.getLastestStage(t.id, true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const { accountList, newAccountGroup, advance } = await this._getInvolveAcc(ctx, tenderId);
|
|
|
+
|
|
|
+ const cid = this.ctx.helper._.map(treeNodes, 'id');
|
|
|
+ const customSelects = {};
|
|
|
+ customSelects.audit_select = [];
|
|
|
+ customSelects.gather_select = await ctx.service.rptCustomDefine.getCustomSelectByRpt(cid,
|
|
|
+ reportConst.rptCustomType[JV.NODE_CUS_GATHER_SELECT], tenderId, -1);
|
|
|
+ customSelects.stage_select = await ctx.service.rptCustomDefine.getCustomSelectByRpt(cid,
|
|
|
+ reportConst.rptCustomType[JV.NODE_CUS_STAGE_SELECT], tenderId, -1);
|
|
|
+ customSelects.change_select = await ctx.service.rptCustomDefine.getCustomSelectByRpt(cid,
|
|
|
+ reportConst.rptCustomType[JV.NODE_CUS_CHANGE_SELECT], tenderId, -1);
|
|
|
+ customSelects.material_sum_select = await ctx.service.rptCustomDefine.getCustomSelectByRpt(cid,
|
|
|
+ reportConst.rptCustomType[JV.NODE_CUS_MATERIAL_SUM_SELECT], tenderId, -1);
|
|
|
+
|
|
|
+
|
|
|
+ const renderData = {
|
|
|
+ accountGroup: newAccountGroup,
|
|
|
+ accountList,
|
|
|
+ unitList: JSON.stringify(unitList),
|
|
|
+ tender: null,
|
|
|
+ tenderInfo: null,
|
|
|
+ rpt_tpl_data: JSON.stringify(treeNodes),
|
|
|
+ cust_tpl_data: JSON.stringify(rpt_tpl_items),
|
|
|
+ all_common_tpl_data: JSON.stringify(allTreeItems),
|
|
|
+ all_indivi_tpl_data: JSON.stringify(allIndivTreeItems),
|
|
|
+ cust_select_keys,
|
|
|
+ cust_cfg: JSON.stringify(custCfg),
|
|
|
+ project_id,
|
|
|
+ tender_id: tenderId,
|
|
|
+ budget_id: -1,
|
|
|
+ sp_id: -1,
|
|
|
+ tender_name: '',
|
|
|
+ detail_id: -1,
|
|
|
+ stg_id: show_stage_id,
|
|
|
+ stg_order: stage_order,
|
|
|
+ cur_order: sorder,
|
|
|
+ stg_times: stage_times,
|
|
|
+ stg_status: stage_status,
|
|
|
+ stage_list: '[]',
|
|
|
+ prj_account_list: JSON.stringify(prjAccList),
|
|
|
+ role_list: JSON.stringify(roleList),
|
|
|
+ used_list: JSON.stringify(usedList),
|
|
|
+ tenderMenu,
|
|
|
+ // preUrl,
|
|
|
+ // thisUrl,
|
|
|
+ measureType,
|
|
|
+ categoryData,
|
|
|
+ tenderList,
|
|
|
+ auditConst: auditConst.stage,
|
|
|
+ ledgerAuditConst: auditConst.ledger,
|
|
|
+ jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.report.main),
|
|
|
+ customSelects,
|
|
|
+ rptCustomType: reportConst.rptCustomType,
|
|
|
+ advanceList: JSON.stringify([]),
|
|
|
+ advanceAuditList: JSON.stringify([]),
|
|
|
+ materialAdjList: JSON.stringify([]),
|
|
|
+ materialAdjAuditList: JSON.stringify([]),
|
|
|
+ materialList: [],
|
|
|
+ stages: [],
|
|
|
+ dataSelects: {},
|
|
|
+ pageShow,
|
|
|
+ // authMobile: accountInfo.auth_mobile,
|
|
|
+ shenpiConst,
|
|
|
+ archiveList: [],
|
|
|
+ lastAuditor: null,
|
|
|
+ rpt_id: ctx.query.rpt_id,
|
|
|
+ isAdmin: false,
|
|
|
+ prePay: JSON.stringify(advance),
|
|
|
+ OSS_PATH: ctx.app.config.fujianOssPath,
|
|
|
+ viewPmData: PermissionCheck.viewPmData(this.ctx.session.sessionUser.permission),
|
|
|
+ source_type,
|
|
|
+ bglObj: JSON.stringify(bglObj),
|
|
|
+ changes: 'null',
|
|
|
+ otherChangeList: 'null',
|
|
|
+ otherHintName: '',
|
|
|
+ bizId: bglObj.BUSINESS_ID,
|
|
|
+ permissions: '[]',
|
|
|
+ types_from: '',
|
|
|
+ is_setting: false,
|
|
|
+ };
|
|
|
+ await this.layout('report/index.ejs', renderData, 'report/rpt_all_popup.ejs');
|
|
|
} catch (err) {
|
|
|
+ console.log(err);
|
|
|
+ this.log(err);
|
|
|
//
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ async indexForCostAnalysis(ctx) {
|
|
|
+ await this.indexForCostManager(ctx, sourceTypeConst.sourceType.cost_analysis, -800);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 报表打印页面
|
|
|
*
|