|
@@ -19,6 +19,7 @@ const path = require('path');
|
|
const audit = require('../const/audit');
|
|
const audit = require('../const/audit');
|
|
const codeRuleConst = require('../const/code_rule');
|
|
const codeRuleConst = require('../const/code_rule');
|
|
const changeConst = require('../const/change');
|
|
const changeConst = require('../const/change');
|
|
|
|
+const auditType = require('../const/audit').auditType;
|
|
const accountGroup = require('../const/account_group').group;
|
|
const accountGroup = require('../const/account_group').group;
|
|
const shenpiConst = require('../const/shenpi');
|
|
const shenpiConst = require('../const/shenpi');
|
|
const tenderMenu = require('../../config/menu').tenderMenu;
|
|
const tenderMenu = require('../../config/menu').tenderMenu;
|
|
@@ -59,50 +60,17 @@ module.exports = app => {
|
|
let page_total = 0;
|
|
let page_total = 0;
|
|
const tp = await ctx.service.change.getTp(tender.id, status);
|
|
const tp = await ctx.service.change.getTp(tender.id, status);
|
|
if (changes !== null) {
|
|
if (changes !== null) {
|
|
- let i = 0;
|
|
|
|
for (const c of changes) {
|
|
for (const c of changes) {
|
|
- page_total = ctx.helper.add(page_total, c.total_price);
|
|
|
|
- const status = c.status === audit.flow.status.uncheck ? 0 : 1;
|
|
|
|
- // 根据审批人对当前变更令的状态取不同的展示方式。
|
|
|
|
- let changeAudit = '';
|
|
|
|
- let auditStatus = 0;
|
|
|
|
- switch (c.status) {
|
|
|
|
- case 1:
|
|
|
|
- auditStatus = 1;
|
|
|
|
- break;
|
|
|
|
- case 2:
|
|
|
|
- changeAudit = await ctx.service.changeAudit.getLastUser(c.cid, c.times, status);
|
|
|
|
- auditStatus = changeAudit.uid === ctx.session.sessionUser.accountId ? 1 : 0;
|
|
|
|
- break;
|
|
|
|
- case 3:
|
|
|
|
- case 4:
|
|
|
|
- auditStatus = 0;
|
|
|
|
- changeAudit = await ctx.service.changeAudit.getLastUser(c.cid, c.times, status);
|
|
|
|
- break;
|
|
|
|
- case 5:
|
|
|
|
- changeAudit = await ctx.service.changeAudit.getLastUser(c.cid, c.times - 1, status);
|
|
|
|
- auditStatus = c.uid === ctx.session.sessionUser.accountId ? 1 : 0;
|
|
|
|
- const back_changeUsedData = await ctx.service.stageChange.getFinalUsedData(ctx.tender.id, c.cid);
|
|
|
|
- c.stageChangeNum = this.ctx.helper.sum(back_changeUsedData.map(x => { return Math.abs(x.qty); }));
|
|
|
|
- c.isSettle = await ctx.service.changeSettleList.isSettle(c.cid);
|
|
|
|
- break;
|
|
|
|
- case 6:
|
|
|
|
- changeAudit = await ctx.service.changeAudit.getLastBackUser(c.cid, c.times);
|
|
|
|
- const checkingAudit = await ctx.service.changeAudit.getLastUser(c.cid, c.times, status);
|
|
|
|
- auditStatus = checkingAudit.uid === ctx.session.sessionUser.accountId ? 1 : 0;
|
|
|
|
- break;
|
|
|
|
- case 9:
|
|
|
|
- auditStatus = c.uid === ctx.session.sessionUser.accountId ? 9 : 0;
|
|
|
|
- const changeUsedData = await ctx.service.stageChange.getFinalUsedData(ctx.tender.id, c.cid);
|
|
|
|
- c.stageChangeNum = this.ctx.helper.sum(changeUsedData.map(x => { return Math.abs(x.qty); }));
|
|
|
|
- c.isSettle = await ctx.service.changeSettleList.isSettle(c.cid);
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- break;
|
|
|
|
|
|
+ c.curAuditors = await ctx.service.changeAudit.getAuditorsByStatus(c.cid, c.status, c.times);
|
|
|
|
+ if (c.status === audit.change.status.checkNoPre) {
|
|
|
|
+ c.curAuditors2 = await ctx.service.stageAudit.getAuditorsByStatus(c.cid, audit.change.status.checking, c.times);
|
|
|
|
+ }
|
|
|
|
+ if (c.status === audit.change.status.checkNo || c.status === audit.change.status.revise) {
|
|
|
|
+ const changeUsedData = await ctx.service.stageChange.getAllFinalUsedData(ctx.tender.id, c.cid);
|
|
|
|
+ c.stageChangeNum = this.ctx.helper.sum(changeUsedData.map(x => { return Math.abs(x.qty); }));
|
|
|
|
+ c.isSettle = await ctx.service.changeSettleList.isSettle(c.cid);
|
|
}
|
|
}
|
|
- changes[i].changeAudit = changeAudit;
|
|
|
|
- changes[i].auditStatus = auditStatus;
|
|
|
|
- i++;
|
|
|
|
|
|
+ page_total = ctx.helper.add(page_total, c.total_price);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -157,7 +125,6 @@ module.exports = app => {
|
|
const apLists = allPlanCodes.length > 0 ? ctx.app._.uniq(ctx.app._.map(allPlanCodes, 'plan_code')) : [];
|
|
const apLists = allPlanCodes.length > 0 ? ctx.app._.uniq(ctx.app._.map(allPlanCodes, 'plan_code')) : [];
|
|
|
|
|
|
const renderData = {
|
|
const renderData = {
|
|
- uid: ctx.session.sessionUser.accountId,
|
|
|
|
moment,
|
|
moment,
|
|
tender,
|
|
tender,
|
|
// tenderList,
|
|
// tenderList,
|
|
@@ -169,7 +136,7 @@ module.exports = app => {
|
|
status,
|
|
status,
|
|
codeRule,
|
|
codeRule,
|
|
dealCode: ctx.tender.info.deal_info.dealCode,
|
|
dealCode: ctx.tender.info.deal_info.dealCode,
|
|
- auditConst: audit.flow,
|
|
|
|
|
|
+ auditConst: audit.change,
|
|
changeConst,
|
|
changeConst,
|
|
state,
|
|
state,
|
|
ruleType: codeRuleConst.ruleType.change,
|
|
ruleType: codeRuleConst.ruleType.change,
|
|
@@ -179,6 +146,7 @@ module.exports = app => {
|
|
tpUnit: ctx.tender.info.decimal.tp,
|
|
tpUnit: ctx.tender.info.decimal.tp,
|
|
changePlanList,
|
|
changePlanList,
|
|
apLists,
|
|
apLists,
|
|
|
|
+ auditType,
|
|
};
|
|
};
|
|
|
|
|
|
if (ctx.session.sessionProject.page_show.openChangeState) {
|
|
if (ctx.session.sessionProject.page_show.openChangeState) {
|
|
@@ -210,6 +178,25 @@ module.exports = app => {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 审批流程(Get)
|
|
|
|
+ * @param ctx
|
|
|
|
+ * @return {Promise<void>}
|
|
|
|
+ */
|
|
|
|
+ async changeAuditors(ctx) {
|
|
|
|
+ try {
|
|
|
|
+ const cid = JSON.parse(ctx.request.body.data).cid;
|
|
|
|
+ const tenderId = ctx.params.id;
|
|
|
|
+ const changeInfo = await ctx.service.change.getDataByCondition({ cid });
|
|
|
|
+ await ctx.service.change.loadChangeUser(changeInfo);
|
|
|
|
+ await ctx.service.change.loadChangeAuditViewData(changeInfo);
|
|
|
|
+ ctx.body = { err: 0, msg: '', data: changeInfo };
|
|
|
|
+ } catch (error) {
|
|
|
|
+ this.log(error);
|
|
|
|
+ ctx.body = { err: 1, msg: error.toString(), data: null };
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
*
|
|
*
|
|
* @param {Object} ctx - egg全局变量
|
|
* @param {Object} ctx - egg全局变量
|
|
* @return {void}
|
|
* @return {void}
|
|
@@ -327,277 +314,14 @@ module.exports = app => {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 变更信息 页面 (Get)
|
|
|
|
- *
|
|
|
|
- * @param {Object} ctx - egg全局变量
|
|
|
|
- * @return {void}
|
|
|
|
|
|
+ * 获取审批界面所需的 原报、审批人数据等
|
|
|
|
+ * @param ctx
|
|
|
|
+ * @return {Promise<void>}
|
|
|
|
+ * @private
|
|
*/
|
|
*/
|
|
- async info(ctx) {
|
|
|
|
- try {
|
|
|
|
- const whiteList = this.ctx.app.config.multipart.whitelist;
|
|
|
|
- const tenderid = ctx.params.id !== undefined ? ctx.params.id : ctx.session.sessionUser.tenderId;
|
|
|
|
- ctx.session.sessionUser.tenderId = tenderid;
|
|
|
|
- const tender = await ctx.service.tender.getDataById(tenderid);
|
|
|
|
- const change = await ctx.service.change.getDataByCondition({ cid: ctx.params.cid });
|
|
|
|
-
|
|
|
|
- // 后台判断当前人查看info状态
|
|
|
|
- const auditStatus = await ctx.service.changeAudit.getStatusByChange(change);
|
|
|
|
-
|
|
|
|
- // 获取附件列表
|
|
|
|
- const attList = await ctx.service.changeAtt.getChangeAttachment(ctx.params.cid);
|
|
|
|
-
|
|
|
|
- // 获取其他变更令数据
|
|
|
|
- const othersChange = await ctx.service.change.getOthersChange(ctx.params.id, ctx.params.cid);
|
|
|
|
-
|
|
|
|
- // 根据auditStatus获取审批人列表
|
|
|
|
- const auditList = await ctx.service.changeAudit.getListByStatus(change, auditStatus);
|
|
|
|
- // 获取已选清单
|
|
|
|
- let changeList = await ctx.service.changeAuditList.getAllDataByCondition({ where: { cid: ctx.params.cid } });
|
|
|
|
-
|
|
|
|
- // 获取用户人验证手机号
|
|
|
|
- const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
|
|
|
|
- const auth_mobile = pa.auth_mobile;
|
|
|
|
- const renderData = {
|
|
|
|
- uid: ctx.session.sessionUser.accountId,
|
|
|
|
- tender,
|
|
|
|
- change,
|
|
|
|
- othersChange,
|
|
|
|
- changeConst,
|
|
|
|
- auditStatus,
|
|
|
|
- auditConst: audit.flow,
|
|
|
|
- ledgerConsts: audit.ledger.status,
|
|
|
|
- attList,
|
|
|
|
- whiteList,
|
|
|
|
- auditList,
|
|
|
|
- changeList,
|
|
|
|
- tpUnit: change.tp_decimal !== null ? change.tp_decimal : ctx.tender.info.decimal.tp,
|
|
|
|
- upUnit: change.up_decimal !== null ? change.up_decimal : ctx.tender.info.decimal.up,
|
|
|
|
- authMobile: auth_mobile,
|
|
|
|
- shenpiConst,
|
|
|
|
- };
|
|
|
|
- // 根据auditStatus状态获取的不同的数据
|
|
|
|
- if (auditStatus === 1 || auditStatus === 2 || auditStatus === 9) {
|
|
|
|
- renderData.changeUnits = changeConst.units;
|
|
|
|
- renderData.precision = ctx.tender.info.precision;
|
|
|
|
- // renderData.accountGroup = accountGroup;
|
|
|
|
- // 获取所有项目参与者
|
|
|
|
- const accountList = await ctx.service.projectAccount.getAllDataByCondition({
|
|
|
|
- where: { project_id: ctx.session.sessionProject.id, enable: 1 },
|
|
|
|
- columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group'],
|
|
|
|
- });
|
|
|
|
- renderData.accountList = accountList;
|
|
|
|
- const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
|
|
|
|
- renderData.accountGroup = unitList.map(item => {
|
|
|
|
- const groupList = accountList.filter(item1 => item1.company === item.name);
|
|
|
|
- return { groupName: item.name, groupList };
|
|
|
|
- });
|
|
|
|
- // 重新上报获取审批流程
|
|
|
|
- if (auditStatus === 2 || auditStatus === 9) {
|
|
|
|
- const auditList2 = await ctx.service.changeAudit.getListByBack(change.cid, change.times);
|
|
|
|
- // 展示页右侧审批流程列表
|
|
|
|
- const auditList3 = [];
|
|
|
|
- for (let time = 1; time <= change.times - 1; time++) {
|
|
|
|
- const auditTimeList = [];
|
|
|
|
- let max_sort = 1;
|
|
|
|
- for (const al of auditList2) {
|
|
|
|
- if (al.times === time) {
|
|
|
|
- auditTimeList.push(al);
|
|
|
|
- if (al.usite > max_sort) {
|
|
|
|
- max_sort = al.usite;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- for (const i in auditTimeList) {
|
|
|
|
- auditTimeList[i].max_sort = max_sort;
|
|
|
|
- }
|
|
|
|
- auditList3.push(auditTimeList);
|
|
|
|
- }
|
|
|
|
- renderData.auditList3 = auditList3;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 根据清单获取提交数据和计算总金额
|
|
|
|
- const changeListData = [];
|
|
|
|
- const changeWhiteListData = [];
|
|
|
|
- let ototalCost = 0;
|
|
|
|
- let ctotalCost = 0;
|
|
|
|
- for (const cl of changeList) {
|
|
|
|
- const cLArray = [
|
|
|
|
- cl.code,
|
|
|
|
- cl.name,
|
|
|
|
- cl.bwmx,
|
|
|
|
- cl.unit,
|
|
|
|
- cl.unit_price,
|
|
|
|
- cl.oamount,
|
|
|
|
- cl.camount,
|
|
|
|
- cl.detail,
|
|
|
|
- cl.lid,
|
|
|
|
- cl.xmj_code,
|
|
|
|
- cl.xmj_jldy,
|
|
|
|
- cl.gcl_id,
|
|
|
|
- ];
|
|
|
|
- ototalCost += cl.unit_price === null ? 0 : ctx.helper.mul(cl.unit_price, cl.oamount, ctx.tender.info.decimal.tp);
|
|
|
|
- ctotalCost += cl.unit_price === null ? 0 : ctx.helper.mul(cl.unit_price, cl.camount, ctx.tender.info.decimal.tp);
|
|
|
|
- if (cl.lid !== '0') {
|
|
|
|
- changeListData.push(cLArray.join('*;*'));
|
|
|
|
- } else {
|
|
|
|
- changeWhiteListData.push(cLArray.join('*;*'));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- renderData.changeListData = changeListData.join('^_^');
|
|
|
|
- renderData.changeWhiteListData = changeWhiteListData.join('^_^');
|
|
|
|
- renderData.ototalCost = ototalCost;
|
|
|
|
- renderData.ctotalCost = ctotalCost;
|
|
|
|
-
|
|
|
|
- // 获取公司列表
|
|
|
|
- const companyList = await ctx.service.changeCompany.getAllDataByCondition({ where: { tid: tenderid } });
|
|
|
|
- renderData.companyList = companyList;
|
|
|
|
- } else if (auditStatus === 3 || auditStatus === 4 || auditStatus === 5 || auditStatus === 7) {
|
|
|
|
- // 展示页左侧审批流程列表和清单审批列表数据
|
|
|
|
- const times = change.status === audit.flow.status.back ?
|
|
|
|
- change.times - 1 : change.times;
|
|
|
|
- const auditList2 = await ctx.service.changeAudit.getListGroupByTimes(change.cid, times);
|
|
|
|
-
|
|
|
|
- // 展示页右侧审批流程列表
|
|
|
|
- const auditList3 = [];
|
|
|
|
- for (let time = 1; time <= times; time++) {
|
|
|
|
- const auditTimeList = [];
|
|
|
|
- let max_sort = 1;
|
|
|
|
- for (const al of auditList) {
|
|
|
|
- if (al.times === time) {
|
|
|
|
- auditTimeList.push(al);
|
|
|
|
- if (al.usite > max_sort) {
|
|
|
|
- max_sort = al.usite;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- for (const i in auditTimeList) {
|
|
|
|
- auditTimeList[i].max_sort = max_sort;
|
|
|
|
- }
|
|
|
|
- auditList3.push(auditTimeList);
|
|
|
|
- }
|
|
|
|
- renderData.auditList3 = auditList3;
|
|
|
|
-
|
|
|
|
- changeList = JSON.parse(JSON.stringify(changeList.sort())).sort().sort();
|
|
|
|
- renderData.changeList = changeList;
|
|
|
|
- let ototalCost = 0;
|
|
|
|
- let ctotalCost = 0;
|
|
|
|
- let stotalCost = 0;
|
|
|
|
- const auditTotalCost = [];
|
|
|
|
- for (const cl of changeList) {
|
|
|
|
- // ototalCost += cl.unit_price === null ? 0 : parseFloat(ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.oamount), renderData.tpUnit));
|
|
|
|
- ototalCost += cl.unit_price === null ? 0 : ctx.helper.mul(cl.unit_price, cl.oamount, renderData.tpUnit);
|
|
|
|
- // ctotalCost += cl.unit_price === null ? 0 : parseFloat(ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.camount), renderData.tpUnit));
|
|
|
|
- ctotalCost += cl.unit_price === null ? 0 : ctx.helper.mul(cl.unit_price, cl.camount, renderData.tpUnit);
|
|
|
|
- // stotalCost += cl.samount !== '' && cl.unit_price !== null ? parseFloat(ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.samount), renderData.tpUnit)) : 0;
|
|
|
|
- stotalCost += cl.samount !== '' && cl.unit_price !== null ? ctx.helper.mul(cl.unit_price, cl.samount, renderData.tpUnit) : 0;
|
|
|
|
- const audit_amount = cl.audit_amount !== null && cl.audit_amount !== '' ? cl.audit_amount.split(',') : '';
|
|
|
|
- auditTotalCost.push(audit_amount);
|
|
|
|
- }
|
|
|
|
- renderData.ototalCost = ototalCost;
|
|
|
|
- renderData.ctotalCost = ctotalCost;
|
|
|
|
- renderData.stotalCost = stotalCost;
|
|
|
|
-
|
|
|
|
- // 清单表页赋值
|
|
|
|
- for (const [index, au] of auditList2.entries()) {
|
|
|
|
- if (au.usite !== 0) {
|
|
|
|
- au.list_amount = [];
|
|
|
|
- au.totalCost = 0;
|
|
|
|
- for (const [auindex, at] of auditTotalCost.entries()) {
|
|
|
|
- au.list_amount.push(at[index - 1]);
|
|
|
|
- // au.totalCost += at[index - 1] !== undefined && changeList[auindex].unit_price !== null ? parseFloat(ctx.helper.roundNum(ctx.helper.accMul(changeList[auindex].unit_price, at[index - 1]), renderData.tpUnit)) : 0;
|
|
|
|
- au.totalCost += at[index - 1] !== undefined && changeList[auindex].unit_price !== null ? ctx.helper.mul(changeList[auindex].unit_price, at[index - 1], renderData.tpUnit) : 0;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- renderData.auditList2 = auditList2;
|
|
|
|
- } else if (auditStatus === 6) {
|
|
|
|
- // 展示页左侧审批流程列表和清单审批列表数据
|
|
|
|
- const auditList2 = await ctx.service.changeAudit.getListGroupByTimes(change.cid, change.times);
|
|
|
|
- renderData.auditList2 = auditList2;
|
|
|
|
- const auditList3 = await ctx.service.changeAudit.getListOrderByTimes(change.cid, change.times);
|
|
|
|
- for (const i in auditList3) {
|
|
|
|
- auditList3[i].max_sort = auditList2.length - 1;
|
|
|
|
- }
|
|
|
|
- renderData.auditList3 = auditList3;
|
|
|
|
-
|
|
|
|
- // 展示页右侧审批流程列表
|
|
|
|
- const auditList5 = await ctx.service.changeAudit.getListByBack(change.cid, change.times);
|
|
|
|
- const auditList4 = [];
|
|
|
|
- for (let time = 1; time <= change.times; time++) {
|
|
|
|
- const auditTimeList = [];
|
|
|
|
- let max_sort = 1;
|
|
|
|
- for (const al of auditList5) {
|
|
|
|
- if (al.times === time) {
|
|
|
|
- auditTimeList.push(al);
|
|
|
|
- if (al.usite > max_sort) {
|
|
|
|
- max_sort = al.usite;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- for (const i in auditTimeList) {
|
|
|
|
- auditTimeList[i].max_sort = max_sort;
|
|
|
|
- }
|
|
|
|
- if (auditTimeList.length > 0) {
|
|
|
|
- auditList4.push(auditTimeList);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- renderData.auditList4 = auditList4;
|
|
|
|
-
|
|
|
|
- changeList = JSON.parse(JSON.stringify(changeList.sort())).sort().sort();
|
|
|
|
- renderData.changeList = changeList;
|
|
|
|
- let ototalCost = 0;
|
|
|
|
- let ctotalCost = 0;
|
|
|
|
- const auditTotalCost = [];
|
|
|
|
- const auditUnit = [];
|
|
|
|
- for (const cl of changeList) {
|
|
|
|
- // ototalCost += cl.unit_price === null ? 0 : parseFloat(ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.oamount), renderData.tpUnit));
|
|
|
|
- ototalCost += cl.unit_price === null ? 0 : ctx.helper.mul(cl.unit_price, cl.oamount, renderData.tpUnit);
|
|
|
|
- // ctotalCost += cl.unit_price === null ? 0 : parseFloat(ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.camount), renderData.tpUnit));
|
|
|
|
- ctotalCost += cl.unit_price === null ? 0 : ctx.helper.mul(cl.unit_price, cl.camount, renderData.tpUnit);
|
|
|
|
- const audit_amount = cl.audit_amount !== null && cl.audit_amount !== '' ? cl.audit_amount.split(',') : '';
|
|
|
|
- auditTotalCost.push(audit_amount);
|
|
|
|
- }
|
|
|
|
- renderData.ototalCost = ototalCost;
|
|
|
|
- renderData.ctotalCost = ctotalCost;
|
|
|
|
-
|
|
|
|
- // 清单表页赋值
|
|
|
|
- for (const [index, au] of auditList.entries()) {
|
|
|
|
- if (au.usite !== 0) {
|
|
|
|
- au.list_amount = [];
|
|
|
|
- au.totalCost = 0;
|
|
|
|
- if (au.uid === renderData.uid) {
|
|
|
|
- for (const [auindex, at] of auditTotalCost.entries()) {
|
|
|
|
- // if (at[index - 2] !== undefined) {
|
|
|
|
- // au.list_amount.push(at[index - 2]);
|
|
|
|
- // au.totalCost += parseFloat(ctx.helper.roundNum(ctx.helper.accMul(changeList[auindex].unit_price, at[index - 2]), renderData.tpUnit));
|
|
|
|
- // } else if (at[index - 2] === undefined) {
|
|
|
|
- // au.list_amount.push(changeList[auindex].camount);
|
|
|
|
- // au.totalCost += parseFloat(ctx.helper.roundNum(ctx.helper.accMul(changeList[auindex].unit_price, changeList[auindex].camount), renderData.tpUnit));
|
|
|
|
- // }
|
|
|
|
- au.list_amount.push(changeList[auindex].spamount);
|
|
|
|
- // au.totalCost += changeList[auindex].unit_price === null ? 0 : parseFloat(ctx.helper.roundNum(ctx.helper.accMul(changeList[auindex].unit_price, changeList[auindex].spamount), renderData.tpUnit));
|
|
|
|
- au.totalCost += changeList[auindex].unit_price === null ? 0 : ctx.helper.mul(changeList[auindex].unit_price, changeList[auindex].spamount, renderData.tpUnit);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- for (const [auindex, at] of auditTotalCost.entries()) {
|
|
|
|
- au.list_amount.push(at[index - 1]);
|
|
|
|
- // au.totalCost += at[index - 1] !== undefined && changeList[auindex].unit_price !== null ? parseFloat(ctx.helper.roundNum(ctx.helper.accMul(changeList[auindex].unit_price, at[index - 1]), renderData.tpUnit)) : 0;
|
|
|
|
- au.totalCost += at[index - 1] !== undefined && changeList[auindex].unit_price !== null ? ctx.helper.mul(changeList[auindex].unit_price, at[index - 1], renderData.tpUnit) : 0;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- renderData.auditList = auditList;
|
|
|
|
-
|
|
|
|
- // 获取是否已存在调用变更令
|
|
|
|
- const changeUsedData = await ctx.service.stageChange.getFinalUsedData(ctx.tender.id, change.cid);
|
|
|
|
- renderData.stageChangeNum = this.ctx.helper.sum(changeUsedData.map(x => { return Math.abs(x.qty); }));
|
|
|
|
- await this.layout('change/info.ejs', renderData, 'change/info_modal.ejs');
|
|
|
|
- } catch (err) {
|
|
|
|
- this.log(err);
|
|
|
|
- ctx.redirect('/tender/' + ctx.params.id + '/change');
|
|
|
|
- }
|
|
|
|
|
|
+ async _getChangeAuditViewData(ctx) {
|
|
|
|
+ await ctx.service.change.loadChangeAuditViewData(ctx.change);
|
|
|
|
+ // await this._checkStageStart(ctx);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -609,10 +333,9 @@ module.exports = app => {
|
|
async information(ctx) {
|
|
async information(ctx) {
|
|
try {
|
|
try {
|
|
const whiteList = this.ctx.app.config.multipart.whitelist;
|
|
const whiteList = this.ctx.app.config.multipart.whitelist;
|
|
- const tender = await ctx.service.tender.getDataById(ctx.tender.id);
|
|
|
|
|
|
+ await this._getChangeAuditViewData(ctx);
|
|
|
|
+ const tender = ctx.tender;
|
|
const change = ctx.change;
|
|
const change = ctx.change;
|
|
- // 后台判断当前人查看info状态
|
|
|
|
- const auditStatus = await ctx.service.changeAudit.getStatusByChange(change);
|
|
|
|
|
|
|
|
// 获取附件列表
|
|
// 获取附件列表
|
|
const attList = await ctx.service.changeAtt.getChangeAttachment(change.cid, 'desc');
|
|
const attList = await ctx.service.changeAtt.getChangeAttachment(change.cid, 'desc');
|
|
@@ -620,20 +343,38 @@ module.exports = app => {
|
|
// 获取其他变更令数据
|
|
// 获取其他变更令数据
|
|
const othersChange = await ctx.service.change.getOthersChange(ctx.tender.id, change.cid);
|
|
const othersChange = await ctx.service.change.getOthersChange(ctx.tender.id, change.cid);
|
|
|
|
|
|
- // 根据auditStatus获取审批人列表
|
|
|
|
- const auditList = await ctx.service.changeAudit.getListByStatus(change, auditStatus);
|
|
|
|
-
|
|
|
|
// 获取变更方案的清单
|
|
// 获取变更方案的清单
|
|
let planList = [];
|
|
let planList = [];
|
|
let showPlanBtn = false;
|
|
let showPlanBtn = false;
|
|
if (ctx.session.sessionProject.page_show.openChangePlan) {
|
|
if (ctx.session.sessionProject.page_show.openChangePlan) {
|
|
- const planInfo = change.plan_code ? await ctx.service.changePlan.getDataByCondition({ tid: ctx.tender.id, code: change.plan_code }) : null;
|
|
|
|
|
|
+ const planInfo = change.plan_code ? await ctx.service.changePlan.getDataByCondition({ tid: tender.id, code: change.plan_code }) : null;
|
|
showPlanBtn = change.plan_code !== null && change.plan_code !== '';
|
|
showPlanBtn = change.plan_code !== null && change.plan_code !== '';
|
|
if (planInfo && planInfo.id) {
|
|
if (planInfo && planInfo.id) {
|
|
planList = await ctx.service.changePlanList.getAllDataByCondition({ where: { cpid: planInfo.id } });
|
|
planList = await ctx.service.changePlanList.getAllDataByCondition({ where: { cpid: planInfo.id } });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 获取清单
|
|
|
|
+ const changeList = await ctx.service.changeAuditList.getList(change.cid);
|
|
|
|
+ if (change.status === audit.change.status.checked || change.status === audit.change.status.checking || change.status === audit.change.status.checkNoPre) {
|
|
|
|
+ for (const cl of changeList) {
|
|
|
|
+ const audit_amount = cl.audit_amount !== null && cl.audit_amount !== '' ? cl.audit_amount.split(',') : '';
|
|
|
|
+ // 清单表页赋值
|
|
|
|
+ for (const au in change.userGroups) {
|
|
|
|
+ if (change.userGroups[au][0].audit_order !== 0) {
|
|
|
|
+ cl['audit_amount_' + change.userGroups[au][0].audit_order] =
|
|
|
|
+ (change.userGroups[au][0].audit_type === auditType.key.and &&
|
|
|
|
+ ctx.helper._.findIndex(change.userGroups[au], { uid: ctx.session.sessionUser.accountId, status: audit.change.status.checked }) !== -1) ||
|
|
|
|
+ (change.shenpiPower && ctx.helper._.findIndex(change.userGroups[au], { uid: ctx.session.sessionUser.accountId }) !== -1) ?
|
|
|
|
+ cl.spamount : (audit_amount[au - 1] !== undefined ? parseFloat(audit_amount[au - 1]) : null);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (change.readOnly && !change.shenpiPower) {
|
|
|
|
+ cl.checked_amount = audit_amount.length > 0 ? parseFloat(audit_amount[audit_amount.length - 1]) : 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
// 工程变更类别读取
|
|
// 工程变更类别读取
|
|
const projectData = await ctx.service.project.getDataById(ctx.session.sessionProject.id);
|
|
const projectData = await ctx.service.project.getDataById(ctx.session.sessionProject.id);
|
|
const fun_set = await ctx.service.project.getFunSet(projectData.fun_set);
|
|
const fun_set = await ctx.service.project.getFunSet(projectData.fun_set);
|
|
@@ -642,18 +383,13 @@ 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 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 } });
|
|
-
|
|
|
|
- if (change && change.status !== audit.flow.status.checked && ctx.session.sessionUser.is_admin) {
|
|
|
|
- change.auditors2 = await ctx.service.changeAudit.getListGroupByWithoutYB(change.cid, change.times);
|
|
|
|
- }
|
|
|
|
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 } }) : [];
|
|
// 判断并是否更新结算清单数据
|
|
// 判断并是否更新结算清单数据
|
|
await ctx.service.change.checkSettleUpdate(ctx.tender.id, ctx.change.readySettle);
|
|
await ctx.service.change.checkSettleUpdate(ctx.tender.id, ctx.change.readySettle);
|
|
- // 获取清单
|
|
|
|
- const changeList = await ctx.service.changeAuditList.getList(change.cid);
|
|
|
|
|
|
+
|
|
// 处理清单数据
|
|
// 处理清单数据
|
|
- const removeSettleNum = change.status !== audit.flow.status.checked ? await ctx.service.changeSettleList.updateChangeList(change.cid, settleBills, settlePos, changeList) : 0;
|
|
|
|
|
|
+ const removeSettleNum = change.status !== audit.change.status.checked ? await ctx.service.changeSettleList.updateChangeList(change.cid, settleBills, settlePos, changeList) : 0;
|
|
const renderData = {
|
|
const renderData = {
|
|
tender,
|
|
tender,
|
|
change,
|
|
change,
|
|
@@ -661,12 +397,12 @@ module.exports = app => {
|
|
changeConst,
|
|
changeConst,
|
|
changeClass: fun_set.change_class,
|
|
changeClass: fun_set.change_class,
|
|
changeState: fun_set.change_state,
|
|
changeState: fun_set.change_state,
|
|
- auditStatus,
|
|
|
|
- auditConst: audit.flow,
|
|
|
|
|
|
+ auditConst: audit.change,
|
|
ledgerConsts: audit.ledger.status,
|
|
ledgerConsts: audit.ledger.status,
|
|
|
|
+ auditType,
|
|
|
|
+ auditorGroups: change.userGroups,
|
|
attList,
|
|
attList,
|
|
whiteList,
|
|
whiteList,
|
|
- auditList,
|
|
|
|
showPlanBtn,
|
|
showPlanBtn,
|
|
planList,
|
|
planList,
|
|
tpUnit: change.tp_decimal ? change.tp_decimal : ctx.tender.info.decimal.tp,
|
|
tpUnit: change.tp_decimal ? change.tp_decimal : ctx.tender.info.decimal.tp,
|
|
@@ -683,66 +419,35 @@ module.exports = app => {
|
|
removeSettleNum,
|
|
removeSettleNum,
|
|
};
|
|
};
|
|
// 获取是否已存在调用变更令
|
|
// 获取是否已存在调用变更令
|
|
- let changeUsedData = await ctx.service.stageChange.getFinalUsedData(ctx.tender.id, change.cid);
|
|
|
|
|
|
+ let changeUsedData = await ctx.service.stageChange.getAllFinalUsedData(ctx.tender.id, change.cid);
|
|
changeUsedData = ctx.helper._.orderBy(ctx.helper._.filter(changeUsedData, function(item) {
|
|
changeUsedData = ctx.helper._.orderBy(ctx.helper._.filter(changeUsedData, function(item) {
|
|
return item.qty !== null;
|
|
return item.qty !== null;
|
|
}), ['sorder'], ['desc']);
|
|
}), ['sorder'], ['desc']);
|
|
const useChangeUsedData = [];
|
|
const useChangeUsedData = [];
|
|
if (changeUsedData.length > 0) { // 防止未创建期时调用
|
|
if (changeUsedData.length > 0) { // 防止未创建期时调用
|
|
- // const stage = await this.ctx.service.stage.getLastestStage(ctx.tender.id, true);
|
|
|
|
for (const cu of changeUsedData) {
|
|
for (const cu of changeUsedData) {
|
|
- // if (cu.sorder !== 0 ||
|
|
|
|
- // (cu.sorder === 0 && !(stage.status === audit.stage.status.uncheck || stage.status === audit.stage.status.checkNo))) {
|
|
|
|
const index = ctx.helper._.findIndex(useChangeUsedData, { cbid: cu.cbid });
|
|
const index = ctx.helper._.findIndex(useChangeUsedData, { cbid: cu.cbid });
|
|
if (index !== -1) {
|
|
if (index !== -1) {
|
|
useChangeUsedData[index].qty = ctx.helper.add(useChangeUsedData[index].qty, cu.qty);
|
|
useChangeUsedData[index].qty = ctx.helper.add(useChangeUsedData[index].qty, cu.qty);
|
|
} else {
|
|
} else {
|
|
useChangeUsedData.push(cu);
|
|
useChangeUsedData.push(cu);
|
|
}
|
|
}
|
|
- // }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
renderData.changeUsedData = useChangeUsedData;
|
|
renderData.changeUsedData = useChangeUsedData;
|
|
renderData.stageChangeNum = this.ctx.helper.sum(changeUsedData.map(x => { return Math.abs(x.qty); }));
|
|
renderData.stageChangeNum = this.ctx.helper.sum(changeUsedData.map(x => { return Math.abs(x.qty); }));
|
|
- if (auditStatus === 1 || auditStatus === 2 || auditStatus === 9 || ctx.session.sessionUser.is_admin) {
|
|
|
|
|
|
+ if (!change.readOnly || ctx.session.sessionUser.is_admin) {
|
|
// 获取所有项目参与者
|
|
// 获取所有项目参与者
|
|
const accountList = await ctx.service.projectAccount.getAllDataByCondition({
|
|
const accountList = await ctx.service.projectAccount.getAllDataByCondition({
|
|
where: { project_id: ctx.session.sessionProject.id, enable: 1 },
|
|
where: { project_id: ctx.session.sessionProject.id, enable: 1 },
|
|
- columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group'],
|
|
|
|
|
|
+ columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
|
|
});
|
|
});
|
|
renderData.accountList = accountList;
|
|
renderData.accountList = accountList;
|
|
renderData.accountGroup = unitList.map(item => {
|
|
renderData.accountGroup = unitList.map(item => {
|
|
const groupList = accountList.filter(item1 => item1.company === item.name);
|
|
const groupList = accountList.filter(item1 => item1.company === item.name);
|
|
return { groupName: item.name, groupList };
|
|
return { groupName: item.name, groupList };
|
|
});
|
|
});
|
|
- }
|
|
|
|
- // 根据auditStatus状态获取的不同的数据
|
|
|
|
- if (auditStatus === 1 || auditStatus === 2 || auditStatus === 9) {
|
|
|
|
renderData.changeUnits = changeConst.units;
|
|
renderData.changeUnits = changeConst.units;
|
|
- // 重新上报获取审批流程
|
|
|
|
- if (auditStatus === 2 || auditStatus === 9) {
|
|
|
|
- const auditList2 = await ctx.service.changeAudit.getListByBack(change.cid, change.times);
|
|
|
|
- // 展示页右侧审批流程列表
|
|
|
|
- const auditList3 = [];
|
|
|
|
- for (let time = 1; time <= change.times - 1; time++) {
|
|
|
|
- const auditTimeList = [];
|
|
|
|
- let max_sort = 1;
|
|
|
|
- for (const al of auditList2) {
|
|
|
|
- if (al.times === time) {
|
|
|
|
- auditTimeList.push(al);
|
|
|
|
- if (al.usite > max_sort) {
|
|
|
|
- max_sort = al.usite;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- for (const i in auditTimeList) {
|
|
|
|
- auditTimeList[i].max_sort = max_sort;
|
|
|
|
- }
|
|
|
|
- auditList3.push(auditTimeList);
|
|
|
|
- }
|
|
|
|
- renderData.auditList3 = auditList3;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// 获取公司列表
|
|
// 获取公司列表
|
|
const companyList = await ctx.service.changeCompany.getAllDataByCondition({ where: { tid: ctx.tender.id } });
|
|
const companyList = await ctx.service.changeCompany.getAllDataByCondition({ where: { tid: ctx.tender.id } });
|
|
renderData.companyList = companyList;
|
|
renderData.companyList = companyList;
|
|
@@ -780,95 +485,11 @@ module.exports = app => {
|
|
renderData.change.class = ctx.helper._.find(fun_set.change_class, { checked: true }).value;
|
|
renderData.change.class = ctx.helper._.find(fun_set.change_class, { checked: true }).value;
|
|
await ctx.service.change.saveInfo({ class: ctx.helper._.find(fun_set.change_class, { checked: true }).value });
|
|
await ctx.service.change.saveInfo({ class: ctx.helper._.find(fun_set.change_class, { checked: true }).value });
|
|
}
|
|
}
|
|
- } else if (auditStatus === 3 || auditStatus === 4 || auditStatus === 5 || auditStatus === 7 || auditStatus === 8) {
|
|
|
|
- // 展示页左侧审批流程列表和清单审批列表数据
|
|
|
|
- const times = change.status === audit.flow.status.back ?
|
|
|
|
- change.times - 1 : change.times;
|
|
|
|
- const auditList2 = await ctx.service.changeAudit.getListGroupByTimes(change.cid, times);
|
|
|
|
-
|
|
|
|
- // 展示页右侧审批流程列表
|
|
|
|
- const auditList3 = [];
|
|
|
|
- for (let time = 1; time <= times; time++) {
|
|
|
|
- const auditTimeList = [];
|
|
|
|
- let max_sort = 1;
|
|
|
|
- for (const al of auditList) {
|
|
|
|
- if (al.times === time) {
|
|
|
|
- auditTimeList.push(al);
|
|
|
|
- if (al.usite > max_sort) {
|
|
|
|
- max_sort = al.usite;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- for (const i in auditTimeList) {
|
|
|
|
- auditTimeList[i].max_sort = max_sort;
|
|
|
|
- }
|
|
|
|
- auditList3.push(auditTimeList);
|
|
|
|
- }
|
|
|
|
- renderData.auditList3 = auditList3;
|
|
|
|
- for (const cl of changeList) {
|
|
|
|
- const audit_amount = cl.audit_amount !== null && cl.audit_amount !== '' ? cl.audit_amount.split(',') : '';
|
|
|
|
- // 清单表页赋值
|
|
|
|
- for (const [index, au] of auditList2.entries()) {
|
|
|
|
- if (au.usite !== 0) {
|
|
|
|
- cl['audit_amount_' + au.uid] = audit_amount[index - 1] !== undefined ? audit_amount[index - 1] : null;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- cl.changed_amount = ctx.helper._.indexOf([audit.flow.status.backnew, audit.flow.status.checking, audit.flow.status.checked], change.status) !== -1 ?
|
|
|
|
- (audit_amount !== '' ? audit_amount[audit_amount.length - 1] :
|
|
|
|
- (ctx.helper._.indexOf([audit.flow.status.backnew, audit.flow.status.checking], change.status) !== -1 ? cl.camount : 0)) : cl.camount;
|
|
|
|
- // cl.changed_amount = ctx.helper.add(cl.oamount ? parseFloat(cl.oamount) : 0, changed_amount ? parseFloat(changed_amount) : 0);
|
|
|
|
- }
|
|
|
|
- renderData.auditList2 = auditList2;
|
|
|
|
- } else if (auditStatus === 6) {
|
|
|
|
- // 展示页左侧审批流程列表和清单审批列表数据
|
|
|
|
- const auditList2 = await ctx.service.changeAudit.getListGroupByTimes(change.cid, change.times);
|
|
|
|
- renderData.auditList2 = auditList2;
|
|
|
|
- const auditList3 = await ctx.service.changeAudit.getListOrderByTimes(change.cid, change.times);
|
|
|
|
- for (const i in auditList3) {
|
|
|
|
- auditList3[i].max_sort = auditList2.length - 1;
|
|
|
|
- }
|
|
|
|
- renderData.auditList3 = auditList3;
|
|
|
|
-
|
|
|
|
- // 展示页右侧审批流程列表
|
|
|
|
- const auditList5 = await ctx.service.changeAudit.getListByBack(change.cid, change.times);
|
|
|
|
- const auditList4 = [];
|
|
|
|
- for (let time = 1; time <= change.times; time++) {
|
|
|
|
- const auditTimeList = [];
|
|
|
|
- let max_sort = 1;
|
|
|
|
- for (const al of auditList5) {
|
|
|
|
- if (al.times === time) {
|
|
|
|
- auditTimeList.push(al);
|
|
|
|
- if (al.usite > max_sort) {
|
|
|
|
- max_sort = al.usite;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- for (const i in auditTimeList) {
|
|
|
|
- auditTimeList[i].max_sort = max_sort;
|
|
|
|
- }
|
|
|
|
- if (auditTimeList.length > 0) {
|
|
|
|
- auditList4.push(auditTimeList);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- renderData.auditList4 = auditList4;
|
|
|
|
- for (const cl of changeList) {
|
|
|
|
- const audit_amount = cl.audit_amount !== null && cl.audit_amount !== '' ? cl.audit_amount.split(',') : '';
|
|
|
|
- // 清单表页赋值
|
|
|
|
- for (const [index, au] of auditList2.entries()) {
|
|
|
|
- if (au.usite !== 0) {
|
|
|
|
- cl['audit_amount_' + au.uid] = au.uid === ctx.session.sessionUser.accountId ? cl.spamount : (audit_amount[index - 1] !== undefined ? audit_amount[index - 1] : null);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- cl.changed_amount = ctx.helper._.indexOf([audit.flow.status.backnew, audit.flow.status.checking, audit.flow.status.checked], change.status) !== -1 ?
|
|
|
|
- (audit_amount !== '' ? audit_amount[audit_amount.length - 1] :
|
|
|
|
- (ctx.helper._.indexOf([audit.flow.status.backnew, audit.flow.status.checking], change.status) !== -1 ? cl.camount : 0)) : cl.camount;
|
|
|
|
- // cl.changed_amount = ctx.helper.add(cl.oamount ? parseFloat(cl.oamount) : 0, changed_amount ? parseFloat(changed_amount) : 0);
|
|
|
|
- }
|
|
|
|
|
|
+ } else if (change.readOnly && change.shenpiPower) {
|
|
renderData.changeLedgerList = await ctx.service.changeLedger.getAllDataByCondition({ where: { tender_id: ctx.tender.id } });
|
|
renderData.changeLedgerList = await ctx.service.changeLedger.getAllDataByCondition({ where: { tender_id: ctx.tender.id } });
|
|
renderData.changePosList = await ctx.service.changePos.getAllDataByCondition({ where: { tid: ctx.tender.id } });
|
|
renderData.changePosList = await ctx.service.changePos.getAllDataByCondition({ where: { tid: ctx.tender.id } });
|
|
}
|
|
}
|
|
renderData.changeList = changeList;
|
|
renderData.changeList = changeList;
|
|
- renderData.auditList = auditList;
|
|
|
|
await this.layout('change/information.ejs', renderData, 'change/information_modal.ejs');
|
|
await this.layout('change/information.ejs', renderData, 'change/information_modal.ejs');
|
|
} catch (err) {
|
|
} catch (err) {
|
|
this.log(err);
|
|
this.log(err);
|
|
@@ -919,7 +540,7 @@ module.exports = app => {
|
|
await ctx.service.changeAuditList.saveLedgerListDatas(data.updateData, data.postData);
|
|
await ctx.service.changeAuditList.saveLedgerListDatas(data.updateData, data.postData);
|
|
// 取所有工料表
|
|
// 取所有工料表
|
|
responseData.data = { changeList: await ctx.service.changeAuditList.getList(ctx.change.cid),
|
|
responseData.data = { changeList: await ctx.service.changeAuditList.getList(ctx.change.cid),
|
|
- usedList: await ctx.service.stageChange.getFinalUsedData(ctx.tender.id, ctx.change.cid) };
|
|
|
|
|
|
+ usedList: await ctx.service.stageChange.getAllFinalUsedData(ctx.tender.id, ctx.change.cid) };
|
|
break;
|
|
break;
|
|
case 'remove_list':
|
|
case 'remove_list':
|
|
await ctx.service.changeAuditList.removeLedgerListDatas(data.updateData);
|
|
await ctx.service.changeAuditList.removeLedgerListDatas(data.updateData);
|
|
@@ -999,20 +620,20 @@ module.exports = app => {
|
|
if (ctx.change.uid !== ctx.session.sessionUser.accountId) {
|
|
if (ctx.change.uid !== ctx.session.sessionUser.accountId) {
|
|
throw '您无权上报该变更令数据';
|
|
throw '您无权上报该变更令数据';
|
|
}
|
|
}
|
|
- if (!(ctx.change.status === audit.flow.status.uncheck || ctx.change.status === audit.flow.status.back || ctx.change.status === audit.flow.status.revise)) {
|
|
|
|
|
|
+ if (!(ctx.change.status === audit.change.status.uncheck || ctx.change.status === audit.change.status.checkNo || ctx.change.status === audit.change.status.revise)) {
|
|
throw '该变更令当前无法上报';
|
|
throw '该变更令当前无法上报';
|
|
}
|
|
}
|
|
// 判断是否是修订,判断有无审批人员作弊
|
|
// 判断是否是修订,判断有无审批人员作弊
|
|
- if ((ctx.change.status === audit.flow.status.revise || ctx.change.is_revise) && ctx.tender.info.shenpi.change === shenpiConst.sp_status.sqspr) {
|
|
|
|
|
|
+ if ((ctx.change.status === audit.change.status.revise || ctx.change.is_revise) && ctx.tender.info.shenpi.change === shenpiConst.sp_status.sqspr) {
|
|
// 获取上一次的审批人流程
|
|
// 获取上一次的审批人流程
|
|
- const lastUserList = await ctx.service.changeAudit.getListGroupByTimes(ctx.change.cid, ctx.change.times - 1);
|
|
|
|
|
|
+ const lastUserList = await ctx.service.changeAudit.getUniqAuditor(ctx.change.cid, ctx.change.times - 1);
|
|
const lastUidList = ctx.helper._.map(lastUserList, 'uid');
|
|
const lastUidList = ctx.helper._.map(lastUserList, 'uid');
|
|
// 判断上一次审批是否为非原报为审批人
|
|
// 判断上一次审批是否为非原报为审批人
|
|
const nowUidList = ctx.helper._.map(ctx.change.auditors, 'uid');
|
|
const nowUidList = ctx.helper._.map(ctx.change.auditors, 'uid');
|
|
// 判断条件修订可上报条件
|
|
// 判断条件修订可上报条件
|
|
// 1.有原报,不管有无其他人 可以添加原报作为审核人,但是不能只原报上报
|
|
// 1.有原报,不管有无其他人 可以添加原报作为审核人,但是不能只原报上报
|
|
// 2.无原报,有其他人 不可以添加原报
|
|
// 2.无原报,有其他人 不可以添加原报
|
|
- // const noYBUidList = ctx.change.status === audit.flow.status.revise ? ctx.helper._.initial(ctx.helper._.tail(lastUidList)) : ctx.helper._.tail(lastUidList);
|
|
|
|
|
|
+ // const noYBUidList = ctx.change.status === audit.change.status.revise ? ctx.helper._.initial(ctx.helper._.tail(lastUidList)) : ctx.helper._.tail(lastUidList);
|
|
const noYBUidList = ctx.helper._.tail(lastUidList);
|
|
const noYBUidList = ctx.helper._.tail(lastUidList);
|
|
// if (!ctx.helper._.isEqual(lastUidList, nowUidList) && ctx.helper._.includes(noYBUidList, lastUidList[0]) && nowUidList.length === 2 && nowUidList[0] === nowUidList[1]) {
|
|
// if (!ctx.helper._.isEqual(lastUidList, nowUidList) && ctx.helper._.includes(noYBUidList, lastUidList[0]) && nowUidList.length === 2 && nowUidList[0] === nowUidList[1]) {
|
|
if (nowUidList.length === 2 && nowUidList[0] === nowUidList[1]) {
|
|
if (nowUidList.length === 2 && nowUidList[0] === nowUidList[1]) {
|
|
@@ -1048,7 +669,7 @@ module.exports = app => {
|
|
if (ctx.change.uid !== ctx.session.sessionUser.accountId) {
|
|
if (ctx.change.uid !== ctx.session.sessionUser.accountId) {
|
|
throw '您无权添加审核人';
|
|
throw '您无权添加审核人';
|
|
}
|
|
}
|
|
- if (ctx.change.status === audit.flow.status.checking || ctx.change.status === audit.flow.status.checked) {
|
|
|
|
|
|
+ if (ctx.change.status === audit.change.status.checking || ctx.change.status === audit.change.status.checked) {
|
|
throw '当前不允许添加审核人';
|
|
throw '当前不允许添加审核人';
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1065,8 +686,7 @@ module.exports = app => {
|
|
throw '添加审核人失败';
|
|
throw '添加审核人失败';
|
|
}
|
|
}
|
|
|
|
|
|
- // const auditors = await ctx.service.changeAudit.getAuditorsWithOwner(ctx.change.id, ctx.change.times);
|
|
|
|
- const auditors = null;
|
|
|
|
|
|
+ const auditors = await ctx.service.changeAudit.getUserGroup(ctx.change.cid, ctx.change.times);
|
|
ctx.body = { err: 0, msg: '', data: auditors };
|
|
ctx.body = { err: 0, msg: '', data: auditors };
|
|
} catch (err) {
|
|
} catch (err) {
|
|
this.log(err);
|
|
this.log(err);
|
|
@@ -1184,8 +804,8 @@ module.exports = app => {
|
|
}
|
|
}
|
|
const status = parseInt(ctx.request.body.status);
|
|
const status = parseInt(ctx.request.body.status);
|
|
// 判断是否到你审批,如果不是则无法审批
|
|
// 判断是否到你审批,如果不是则无法审批
|
|
- const curAuditor = await ctx.service.changeAudit.getCurAuditor(changeData.cid, changeData.times);
|
|
|
|
- if (!curAuditor || (curAuditor && curAuditor.uid !== ctx.session.sessionUser.accountId)) {
|
|
|
|
|
|
+ const curAuditor = await ctx.service.changeAudit.getCurAuditors(changeData.cid, changeData.times);
|
|
|
|
+ if (!curAuditor || (curAuditor && ctx.helper._.findIndex(curAuditor, { uid: ctx.session.sessionUser.accountId }) === -1)) {
|
|
throw '该变更令当前您无权操作';
|
|
throw '该变更令当前您无权操作';
|
|
}
|
|
}
|
|
const readySettle = await ctx.service.settle.getReadySettle(changeData.tid);
|
|
const readySettle = await ctx.service.settle.getReadySettle(changeData.tid);
|
|
@@ -1198,14 +818,14 @@ module.exports = app => {
|
|
case 3:// 审批通过
|
|
case 3:// 审批通过
|
|
result = await ctx.service.change.approvalSuccess(pid, ctx.request.body, changeData);
|
|
result = await ctx.service.change.approvalSuccess(pid, ctx.request.body, changeData);
|
|
break;
|
|
break;
|
|
- case 4:// 审批终止
|
|
|
|
- result = await ctx.service.change.approvalStop(ctx.request.body);
|
|
|
|
- break;
|
|
|
|
|
|
+ // case 4:// 审批终止
|
|
|
|
+ // result = await ctx.service.change.approvalStop(ctx.request.body);
|
|
|
|
+ // break;
|
|
case 5:// 审批退回到原报人
|
|
case 5:// 审批退回到原报人
|
|
- result = await ctx.service.change.approvalBack(pid, ctx.request.body, changeData);
|
|
|
|
|
|
+ result = await ctx.service.change.approvalCheckNo(pid, ctx.request.body, changeData);
|
|
break;
|
|
break;
|
|
case 6:// 审批退回到上一个审批人
|
|
case 6:// 审批退回到上一个审批人
|
|
- result = await ctx.service.change.approvalBackNew(pid, ctx.request.body, changeData);
|
|
|
|
|
|
+ result = await ctx.service.change.approvalCheckNoPre(pid, ctx.request.body, changeData);
|
|
break;
|
|
break;
|
|
default:break;
|
|
default:break;
|
|
}
|
|
}
|
|
@@ -1283,7 +903,7 @@ module.exports = app => {
|
|
const files = [];
|
|
const files = [];
|
|
let index = 0;
|
|
let index = 0;
|
|
const change = await ctx.service.change.getDataByCondition({ cid: ctx.params.cid });
|
|
const change = await ctx.service.change.getDataByCondition({ cid: ctx.params.cid });
|
|
- const extra_upload = change.status === audit.flow.status.checked;
|
|
|
|
|
|
+ const extra_upload = change.status === audit.change.status.checked;
|
|
while ((stream = await parts()) !== undefined) {
|
|
while ((stream = await parts()) !== undefined) {
|
|
// 判断用户是否选择上传文件
|
|
// 判断用户是否选择上传文件
|
|
if (!stream.filename) {
|
|
if (!stream.filename) {
|
|
@@ -1467,7 +1087,7 @@ module.exports = app => {
|
|
if (!fileInfo || !Object.keys(fileInfo).length) {
|
|
if (!fileInfo || !Object.keys(fileInfo).length) {
|
|
throw '该文件不存在';
|
|
throw '该文件不存在';
|
|
}
|
|
}
|
|
- if (!fileInfo.extra_upload && change.status === audit.flow.status.checked) {
|
|
|
|
|
|
+ if (!fileInfo.extra_upload && change.status === audit.change.status.checked) {
|
|
throw '无权限删除';
|
|
throw '无权限删除';
|
|
}
|
|
}
|
|
if (fileInfo !== undefined && fileInfo !== '') {
|
|
if (fileInfo !== undefined && fileInfo !== '') {
|
|
@@ -1549,16 +1169,7 @@ module.exports = app => {
|
|
*/
|
|
*/
|
|
async checkAgain(ctx) {
|
|
async checkAgain(ctx) {
|
|
try {
|
|
try {
|
|
- const changeData = await ctx.service.change.getDataByCondition({ cid: ctx.request.body.cid });
|
|
|
|
- if (!changeData) {
|
|
|
|
- throw '变更令数据错误';
|
|
|
|
- }
|
|
|
|
- // 获取终审
|
|
|
|
- const auditInfo = await ctx.service.changeAudit.getAuditorByStatus(changeData.cid, changeData.times, audit.flow.status.checked);
|
|
|
|
- if (changeData.status !== audit.flow.status.checked || ctx.session.sessionUser.accountId !== auditInfo.uid) {
|
|
|
|
- throw '您无权进行该操作';
|
|
|
|
- }
|
|
|
|
- const readySettle = await ctx.service.settle.getReadySettle(changeData.tid);
|
|
|
|
|
|
+ const readySettle = await ctx.service.settle.getReadySettle(ctx.change.tid);
|
|
if (readySettle && readySettle.settle_order !== ctx.tender.data.settle_order) {
|
|
if (readySettle && readySettle.settle_order !== ctx.tender.data.settle_order) {
|
|
throw '结算数据发生变化,请刷新页面再提交';
|
|
throw '结算数据发生变化,请刷新页面再提交';
|
|
}
|
|
}
|
|
@@ -1576,16 +1187,20 @@ module.exports = app => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 重新审批
|
|
// 重新审批
|
|
- const result = await ctx.service.change.checkAgain(changeData.cid);
|
|
|
|
- if (!result) {
|
|
|
|
- throw '重新审批失败';
|
|
|
|
|
|
+ if ((ctx.change.finalAuditorIds.indexOf(ctx.session.sessionUser.accountId) >= 0) && ctx.change.status === audit.change.status.checked) {
|
|
|
|
+ const result = await ctx.service.change.checkAgain(ctx.change);
|
|
|
|
+ if (!result) {
|
|
|
|
+ throw '重新审批失败';
|
|
|
|
+ }
|
|
|
|
+ // ctx.redirect('/tender/' + changeData.tid + '/change/' + changeData.cid + '/info');
|
|
|
|
+ ctx.body = {
|
|
|
|
+ err: 0,
|
|
|
|
+ url: ctx.request.header.referer,
|
|
|
|
+ msg: '',
|
|
|
|
+ };
|
|
|
|
+ } else {
|
|
|
|
+ throw '您无权进行该操作';
|
|
}
|
|
}
|
|
- // ctx.redirect('/tender/' + changeData.tid + '/change/' + changeData.cid + '/info');
|
|
|
|
- ctx.body = {
|
|
|
|
- err: 0,
|
|
|
|
- url: ctx.request.header.referer,
|
|
|
|
- msg: '',
|
|
|
|
- };
|
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
console.log(err);
|
|
console.log(err);
|
|
// ctx.redirect(ctx.request.header.referer);
|
|
// ctx.redirect(ctx.request.header.referer);
|
|
@@ -1604,14 +1219,10 @@ module.exports = app => {
|
|
*/
|
|
*/
|
|
async checkRevise(ctx) {
|
|
async checkRevise(ctx) {
|
|
try {
|
|
try {
|
|
- const changeData = await ctx.service.change.getDataByCondition({ cid: ctx.request.body.cid });
|
|
|
|
- if (!changeData) {
|
|
|
|
- throw '变更令数据错误';
|
|
|
|
- }
|
|
|
|
- if (changeData.status !== audit.flow.status.checked || ctx.session.sessionUser.accountId !== changeData.uid) {
|
|
|
|
|
|
+ if (ctx.change.status !== audit.change.status.checked || ctx.session.sessionUser.accountId !== ctx.change.uid) {
|
|
throw '您无权进行该操作';
|
|
throw '您无权进行该操作';
|
|
}
|
|
}
|
|
- const readySettle = await ctx.service.settle.getReadySettle(changeData.tid);
|
|
|
|
|
|
+ const readySettle = await ctx.service.settle.getReadySettle(ctx.change.tid);
|
|
if (readySettle && readySettle.settle_order !== ctx.tender.data.settle_order) {
|
|
if (readySettle && readySettle.settle_order !== ctx.tender.data.settle_order) {
|
|
throw '结算数据发生变化,请刷新页面再提交';
|
|
throw '结算数据发生变化,请刷新页面再提交';
|
|
}
|
|
}
|
|
@@ -1630,13 +1241,13 @@ module.exports = app => {
|
|
}
|
|
}
|
|
|
|
|
|
// 获取是否已存在调用变更令
|
|
// 获取是否已存在调用变更令
|
|
- // const changeUsedData = await ctx.service.stageChange.getFinalUsedData(ctx.tender.id, changeData.cid);
|
|
|
|
|
|
+ // const changeUsedData = await ctx.service.stageChange.getAllFinalUsedData(ctx.tender.id, changeData.cid);
|
|
// const stageChangeNum = this.ctx.helper.sum(changeUsedData.map(x => { return Math.abs(x.qty); }));
|
|
// const stageChangeNum = this.ctx.helper.sum(changeUsedData.map(x => { return Math.abs(x.qty); }));
|
|
// if (stageChangeNum !== 0) {
|
|
// if (stageChangeNum !== 0) {
|
|
// throw '该变更令已被调用,无法重新审批';
|
|
// throw '该变更令已被调用,无法重新审批';
|
|
// }
|
|
// }
|
|
// 重新审批
|
|
// 重新审批
|
|
- const result = await ctx.service.change.checkRevise(changeData.cid);
|
|
|
|
|
|
+ const result = await ctx.service.change.checkRevise(ctx.change);
|
|
if (!result) {
|
|
if (!result) {
|
|
throw '修订发起失败';
|
|
throw '修订发起失败';
|
|
}
|
|
}
|
|
@@ -1664,19 +1275,15 @@ module.exports = app => {
|
|
*/
|
|
*/
|
|
async cancelRevise(ctx) {
|
|
async cancelRevise(ctx) {
|
|
try {
|
|
try {
|
|
- const changeData = await ctx.service.change.getDataByCondition({ cid: ctx.request.body.cid });
|
|
|
|
- if (!changeData) {
|
|
|
|
- throw '变更令数据错误';
|
|
|
|
- }
|
|
|
|
- if (!(changeData.status === audit.flow.status.revise && (ctx.session.sessionUser.accountId === changeData.uid || ctx.session.sessionUser.accountId === ctx.session.sessionUser.is_admin))) {
|
|
|
|
|
|
+ if (!(ctx.change.status === audit.change.status.revise && (ctx.session.sessionUser.accountId === ctx.change.uid || ctx.session.sessionUser.accountId === ctx.session.sessionUser.is_admin))) {
|
|
throw '您无权进行该操作';
|
|
throw '您无权进行该操作';
|
|
}
|
|
}
|
|
- const readySettle = await ctx.service.settle.getReadySettle(changeData.tid);
|
|
|
|
|
|
+ const readySettle = await ctx.service.settle.getReadySettle(ctx.change.tid);
|
|
if (readySettle && readySettle.settle_order !== ctx.tender.data.settle_order) {
|
|
if (readySettle && readySettle.settle_order !== ctx.tender.data.settle_order) {
|
|
throw '结算数据发生变化,请刷新页面再提交';
|
|
throw '结算数据发生变化,请刷新页面再提交';
|
|
}
|
|
}
|
|
// 重新审批
|
|
// 重新审批
|
|
- const result = await ctx.service.change.cancelRevise(changeData.cid, changeData.times);
|
|
|
|
|
|
+ const result = await ctx.service.change.cancelRevise(ctx.change.cid, ctx.change.times);
|
|
if (!result) {
|
|
if (!result) {
|
|
throw '撤销修订失败';
|
|
throw '撤销修订失败';
|
|
}
|
|
}
|
|
@@ -1700,9 +1307,9 @@ module.exports = app => {
|
|
// throw '台账修订中,请勿修改提交期数据';
|
|
// throw '台账修订中,请勿修改提交期数据';
|
|
// }
|
|
// }
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
- if (ctx.session.sessionUser.is_admin && ctx.change.status !== audit.flow.status.checked) {
|
|
|
|
|
|
+ if (ctx.session.sessionUser.is_admin && ctx.change.status !== audit.change.status.checked) {
|
|
await ctx.service.changeAudit.saveAudit(ctx.change.cid, ctx.change.times, data);
|
|
await ctx.service.changeAudit.saveAudit(ctx.change.cid, ctx.change.times, data);
|
|
- const auditors = await ctx.service.changeAudit.getListGroupByTimes(ctx.change.cid, ctx.change.times);
|
|
|
|
|
|
+ const auditors = await ctx.service.changeAudit.getUniqUserGroup(ctx.change.cid, ctx.change.times);
|
|
ctx.body = { err: 0, msg: '', data: auditors };
|
|
ctx.body = { err: 0, msg: '', data: auditors };
|
|
} else {
|
|
} else {
|
|
throw '您无权进行该操作';
|
|
throw '您无权进行该操作';
|
|
@@ -1807,7 +1414,7 @@ module.exports = app => {
|
|
const change = ctx.change;
|
|
const change = ctx.change;
|
|
let edit = true;
|
|
let edit = true;
|
|
let changing = false;
|
|
let changing = false;
|
|
- if (change.status !== audit.flow.status.uncheck && change.status !== audit.flow.status.back && change.status !== audit.flow.status.revise) {
|
|
|
|
|
|
+ if (change.status !== audit.change.status.uncheck && change.status !== audit.change.status.checkNo && change.status !== audit.change.status.revise) {
|
|
// throw '本条变更审批中或已完成,无法操作台账数据';
|
|
// throw '本条变更审批中或已完成,无法操作台账数据';
|
|
edit = false;
|
|
edit = false;
|
|
changing = true;
|
|
changing = true;
|
|
@@ -1861,7 +1468,7 @@ module.exports = app => {
|
|
if (!data.postType || !data.postData) throw '数据错误';
|
|
if (!data.postType || !data.postData) throw '数据错误';
|
|
const responseData = { err: 0, msg: '', data: {} };
|
|
const responseData = { err: 0, msg: '', data: {} };
|
|
const change = ctx.change;
|
|
const change = ctx.change;
|
|
- if (change.status !== audit.flow.status.uncheck && change.status !== audit.flow.status.back && change.status !== audit.flow.status.revise) {
|
|
|
|
|
|
+ if (change.status !== audit.change.status.uncheck && change.status !== audit.change.status.checkNo && change.status !== audit.change.status.revise) {
|
|
throw '该变更令正在审批中或已完成,无法操作新增部位数据';
|
|
throw '该变更令正在审批中或已完成,无法操作新增部位数据';
|
|
}
|
|
}
|
|
// 判断是否在修订中,是则无法操作本页
|
|
// 判断是否在修订中,是则无法操作本页
|