|
@@ -189,54 +189,36 @@ module.exports = app => {
|
|
|
if (!transferInfo) {
|
|
|
throw '该资金划拨信息不存在';
|
|
|
}
|
|
|
+ const categoryData = await this.ctx.service.category.getAllCategory(ctx.subProject);
|
|
|
const transferTenderList = await ctx.service.financialTransferTender.getList(trid, true);
|
|
|
- const total = await ctx.service.financialTransferTender.count({ trid });
|
|
|
- // 分页相关
|
|
|
- const page = ctx.page;
|
|
|
- const pageSize = ctx.pageSize;
|
|
|
- const pageInfo = {
|
|
|
- page,
|
|
|
- pageSizeSelect: 1,
|
|
|
- pageSize,
|
|
|
- total_num: total,
|
|
|
- total: Math.ceil(total / pageSize),
|
|
|
- queryData: JSON.stringify(ctx.urlInfo.query),
|
|
|
- };
|
|
|
const tenders = await ctx.service.tender.getAllDataByCondition({ where: { spid: ctx.subProject.id, filter_fund: 0 } });
|
|
|
- for (const tt of transferTenderList) {
|
|
|
- const tenderIndex = ctx.helper._.findIndex(tenders, { id: tt.tid });
|
|
|
- if (tenderIndex !== -1) {
|
|
|
- tenders.splice(tenderIndex, 1);
|
|
|
+ const needTenders = [];
|
|
|
+ for (const t of tenders) {
|
|
|
+ await ctx.service.tenderCache.loadTenderCache(t, this.ctx.session.sessionUser.accountId);
|
|
|
+ if (t.stage_complete_count && t.stage_complete_count >= 1) {
|
|
|
+ t.category = t.category && t.category !== '' ? JSON.parse(t.category) : null;
|
|
|
+ needTenders.push(t);
|
|
|
}
|
|
|
}
|
|
|
- const allTransferTenders = await ctx.service.financialTransferTender.getAllDataByCondition({ where: { spid: ctx.subProject.id } });
|
|
|
- for (const t of tenders) {
|
|
|
- const stages = await ctx.service.stage.getAllDataByCondition({ where: { tid: t.id, status: auditConst.stage.status.checked } });
|
|
|
- const allTenderStages = ctx.helper._.filter(allTransferTenders, { tid: t.id });
|
|
|
- for (const ts of allTenderStages) {
|
|
|
- const sorderArray = ts.sorder ? ts.sorder.split(',') : [];
|
|
|
- for (const sorder of sorderArray) {
|
|
|
- const stageIndex = ctx.helper._.findIndex(stages, function(item) {
|
|
|
- return item.order === parseInt(sorder);
|
|
|
- });
|
|
|
- if (stageIndex !== -1) {
|
|
|
- stages.splice(stageIndex, 1);
|
|
|
- }
|
|
|
- }
|
|
|
+ for (const tt of transferTenderList) {
|
|
|
+ const tenderIndex = ctx.helper._.findIndex(needTenders, { id: tt.tid });
|
|
|
+ if (tenderIndex !== -1) {
|
|
|
+ // 合并tenders[tenderIndex]到tt
|
|
|
+ const cloneTender = ctx.helper._.cloneDeep(needTenders[tenderIndex]);
|
|
|
+ delete cloneTender.id;
|
|
|
+ Object.assign(tt, cloneTender);
|
|
|
}
|
|
|
- t.stages = stages;
|
|
|
}
|
|
|
-
|
|
|
const renderData = {
|
|
|
financialPermission,
|
|
|
transferInfo,
|
|
|
transferTenderList,
|
|
|
- tenders,
|
|
|
+ categoryData,
|
|
|
+ tenders: needTenders,
|
|
|
moment,
|
|
|
preUrl: '/sp/' + ctx.subProject.id + '/financial/transfer',
|
|
|
jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.financial.transferTender),
|
|
|
whiteList: ctx.app.config.multipart.whitelist,
|
|
|
- pageInfo,
|
|
|
};
|
|
|
await this.layout('financial/transfer_tender.ejs', renderData, 'financial/transfer_tender_modal.ejs');
|
|
|
} catch (err) {
|
|
@@ -298,10 +280,13 @@ module.exports = app => {
|
|
|
}
|
|
|
break;
|
|
|
case 'del-tender':
|
|
|
- responseData.data = await ctx.service.financialTransferTender.delTenders(data.postData.node);
|
|
|
+ responseData.data = await ctx.service.financialTransferTender.delTenders(transferInfo, data.postData.node);
|
|
|
break;
|
|
|
case 'update-hb_tp':
|
|
|
- responseData.data = await ctx.service.financialTransferTender.updateHbTp(data.postData.node, data.postData.hb_tp);
|
|
|
+ responseData.data = await ctx.service.financialTransferTender.updateHbTp(transferInfo, data.postData.node, data.postData.hb_tp);
|
|
|
+ break;
|
|
|
+ case 'update-tender':
|
|
|
+ responseData.data = await ctx.service.financialTransferTender.updateTender(transferInfo, data.postData);
|
|
|
break;
|
|
|
default:
|
|
|
throw '未知操作';
|
|
@@ -586,34 +571,15 @@ module.exports = app => {
|
|
|
*/
|
|
|
async pay(ctx) {
|
|
|
try {
|
|
|
- const status = parseInt(ctx.query.status) || 0;
|
|
|
- const tid = parseInt(ctx.query.tid) || null;
|
|
|
- const used = ctx.query.used || null;
|
|
|
- await this._filterPay(ctx, status, tid, used);
|
|
|
+ const company = ctx.query.company || null;
|
|
|
+ await this._filterPay(ctx, company);
|
|
|
} catch (err) {
|
|
|
this.log(err);
|
|
|
ctx.redirect(`/sp/${ctx.subProject.id}/dashboard`);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // /**
|
|
|
- // * 变更管理 状态筛选 页面 (Get)
|
|
|
- // * @param {Object} ctx - egg全局变量
|
|
|
- // * @return {void}
|
|
|
- // */
|
|
|
- // async payStatus(ctx) {
|
|
|
- // try {
|
|
|
- // const status = parseInt(ctx.query.status);
|
|
|
- // const tid = parseInt(ctx.params.tid) || null;
|
|
|
- // const used = ctx.params.used || null;
|
|
|
- // await this._filterPay(ctx, status, tid, used);
|
|
|
- // } catch (err) {
|
|
|
- // this.logger.error(err);
|
|
|
- // ctx.redirect('/financial');
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- async _filterPay(ctx, status = 0, tid = null, used = null) {
|
|
|
+ async _filterPay(ctx, company = null) {
|
|
|
const financialPermission = await ctx.service.subProjPermission.getFinancailPermission(ctx.subProject.permission.fund_trans_permission, ctx.subProject.permission.fund_pay_permission);
|
|
|
if (!financialPermission.pay_show) {
|
|
|
throw '没有查看权限';
|
|
@@ -621,7 +587,7 @@ module.exports = app => {
|
|
|
const fptAudits = await ctx.service.financialPayTenderAudit.getAllDataByCondition({ where: { spid: ctx.subProject.id, uid: ctx.session.sessionUser.accountId } });
|
|
|
const fptAuditTids = ctx.helper._.map(fptAudits, 'tid');
|
|
|
const fptReportTids = ctx.helper._.map(ctx.helper._.filter(fptAudits, { is_report: 1 }), 'tid');
|
|
|
- const filterTids = tid === null ? (ctx.session.sessionUser.is_admin ? null : fptAuditTids) : [tid];
|
|
|
+ const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
|
|
|
const tenderCondition = { spid: ctx.subProject.id, filter_fund: 0 };
|
|
|
let hadTender = false;
|
|
|
if (ctx.session.sessionUser.is_admin) {
|
|
@@ -633,15 +599,18 @@ module.exports = app => {
|
|
|
hadTender = false;
|
|
|
tenderCondition.id = -1;
|
|
|
}
|
|
|
- const tenders = hadTender ? await ctx.service.tender.getAllDataByCondition({ where: tenderCondition, columns: ['id', 'name'] }) : [];
|
|
|
- const filter = JSON.parse(JSON.stringify(auditConst.financial.filter));
|
|
|
- filter.count = [];
|
|
|
- filter.count[filter.status.pending] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, filter.status.pending, filterTids, used);// await ctx.service.change.pendingDatas(tender.id, ctx.session.sessionUser.accountId);
|
|
|
- filter.count[filter.status.uncheck] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, filter.status.uncheck, filterTids, used);// await ctx.service.change.checkingDatas(tender.id, ctx.session.sessionUser.accountId);
|
|
|
- filter.count[filter.status.checking] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, filter.status.checking, filterTids, used);// await ctx.service.change.checkedDatas(tender.id, ctx.session.sessionUser.accountId);
|
|
|
- filter.count[filter.status.checked] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, filter.status.checked, filterTids, used);// await ctx.service.change.pendingDatas(tender.id, ctx.session.sessionUser.accountId);
|
|
|
- const payList = await ctx.service.financialPay.getListByStatus(ctx.subProject.id, status, filterTids, used, 1);
|
|
|
- const total = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, status, filterTids, used);
|
|
|
+ const categoryData = await this.ctx.service.category.getAllCategory(ctx.subProject);
|
|
|
+ const tenders = hadTender ? await ctx.service.tender.getAllDataByCondition({ where: tenderCondition, columns: ['id', 'name', 'category'] }) : [];
|
|
|
+ const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject, ['id', 'account', 'name', 'company', 'company_id', 'role', 'enable', 'is_admin', 'account_group', 'mobile']);
|
|
|
+ const user = accountList.find(item => item.id === ctx.session.sessionUser.accountId) || null;
|
|
|
+ const userCompany = user ? ctx.helper._.find(unitList, { name: user.company }) : null;
|
|
|
+ if (!userCompany) {
|
|
|
+ throw '请联系管理员添加用户所在单位信息';
|
|
|
+ }
|
|
|
+ const userCompanyList = await ctx.service.financialPayCompany.getUserCompanyList(ctx.subProject.id, userCompany ? userCompany.id : 0, unitList);
|
|
|
+ const companyInfo = company ? ctx.helper._.find(unitList, { name: company }) : null;
|
|
|
+ const payList = await ctx.service.financialPayCompany.getListByStatus(ctx.subProject.id, companyInfo ? companyInfo.id : null, userCompany ? userCompany.id : 0);
|
|
|
+ const total = await ctx.service.financialPayCompany.getCountByStatus(ctx.subProject.id, companyInfo ? companyInfo.id : null, userCompany ? userCompany.id : 0);
|
|
|
// 分页相关
|
|
|
const page = ctx.page;
|
|
|
const pageSize = ctx.pageSize;
|
|
@@ -653,45 +622,25 @@ module.exports = app => {
|
|
|
total: Math.ceil(total / pageSize),
|
|
|
queryData: JSON.stringify(ctx.urlInfo.query),
|
|
|
};
|
|
|
- // 获取所有项目参与者
|
|
|
- const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject, ['id', 'account', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile']);
|
|
|
const payTenders = await ctx.service.financialPayTender.getAllDataByCondition({ where: { spid: ctx.subProject.id } });
|
|
|
if (tenders.length > 0) {
|
|
|
- const allLastPay = await ctx.service.financialPay.getAllDataByCondition({ where: { spid: ctx.subProject.id, tid: ctx.helper._.map(tenders, 'id') }, columns: ['id', 'code'], orders: [['id', 'desc']] });
|
|
|
const tenderInfos = await ctx.service.tenderInfo.getAllDataByCondition({ where: { tid: ctx.helper._.map(tenders, 'id') }, columns: ['tid', 'pay_account', 'deal_info'] });
|
|
|
for (const t of tenders) {
|
|
|
+ t.category = t.category && t.category !== '' ? JSON.parse(t.category) : null;
|
|
|
const info = ctx.helper._.find(tenderInfos, { tid: t.id });
|
|
|
t.pay_account = info && info.pay_account ? JSON.parse(info.pay_account).project : '';
|
|
|
const pt = ctx.helper._.find(payTenders, { tid: t.id });
|
|
|
t.pt = pt ? pt : { id: 0, tid: t.id, name: '', bank: '', bank_account: '', contact: '', phone: '' };
|
|
|
if (ctx.session.sessionUser.is_admin || ctx.helper._.includes(fptReportTids, t.id)) {
|
|
|
t.dealCode = info && info.deal_info ? JSON.parse(info.deal_info).dealCode : '';
|
|
|
- const lastPay = ctx.helper._.filter(allLastPay, { tid: t.id });
|
|
|
- t.startNum = 1;
|
|
|
- if (lastPay.length > 0) {
|
|
|
- const startArray = lastPay[0].code.split('-');
|
|
|
- t.startNum = parseInt(startArray[startArray.length - 1]) + 1;
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
for (const pay of payList) {
|
|
|
- const t = ctx.helper._.find(tenders, { id: pay.tid });
|
|
|
- pay.tenderName = t ? t.name : '';
|
|
|
+ const t = ctx.helper._.find(unitList, { id: pay.company_id });
|
|
|
+ pay.company = t ? t.name : '';
|
|
|
const userInfo = ctx.helper._.find(accountList, { id: pay.uid });
|
|
|
pay.username = userInfo ? userInfo.name : '';
|
|
|
- if (pay.status !== auditConst.financial.status.checked || !pay.final_auditor_str) {
|
|
|
- pay.curAuditors = await ctx.service.financialPayAudit.getAuditorsByStatus(pay.id, pay.status, pay.times);
|
|
|
- if (pay.status === auditConst.financial.status.checked && pay.curAuditors.length > 0) {
|
|
|
- const final_auditor_str = pay.curAuditors[0].audit_type === auditConst.auditType.key.common
|
|
|
- ? pay.curAuditors[0].name + (pay.curAuditors[0].role ? '-' + pay.curAuditors[0].role : '')
|
|
|
- : ctx.helper.transFormToChinese(pay.curAuditors[0].audit_order) + '审';
|
|
|
- await ctx.service.financialPay.defaultUpdate({ final_auditor_str }, { where: { id: pay.id } });
|
|
|
- }
|
|
|
- }
|
|
|
- if (pay.status !== auditConst.financial.status.checked) {
|
|
|
- pay.entities = await ctx.service.financialPayContract.getEntities(pay.id);
|
|
|
- }
|
|
|
}
|
|
|
if (ctx.session.sessionUser.is_admin && tenders.length > 0) {
|
|
|
const allPermissionList = await ctx.service.financialPayTenderAudit.getAllList(ctx.subProject.id, ctx.helper._.map(tenders, 'id'), accountList);
|
|
@@ -703,25 +652,24 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
const renderData = {
|
|
|
+ categoryData,
|
|
|
tenders,
|
|
|
financialPermission,
|
|
|
usedList: financialConst.used,
|
|
|
auditConst: auditConst.financial,
|
|
|
- filter,
|
|
|
- tid,
|
|
|
- status,
|
|
|
- used,
|
|
|
+ company,
|
|
|
payList,
|
|
|
fptAuditTids,
|
|
|
fptReportTids,
|
|
|
+ userCompanyList,
|
|
|
+ unitList,
|
|
|
moment,
|
|
|
+ user,
|
|
|
auditType: auditConst.auditType,
|
|
|
- // preUrl: '/financial',
|
|
|
jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.financial.pay),
|
|
|
pageInfo,
|
|
|
};
|
|
|
if (ctx.session.sessionUser.is_admin) {
|
|
|
- const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
|
|
|
renderData.accountList = accountList;
|
|
|
renderData.accountGroup = unitList.map(item => {
|
|
|
const groupList = accountList.filter(item1 => item1.company === item.name);
|
|
@@ -785,11 +733,14 @@ module.exports = app => {
|
|
|
case 'copy-shenpi-audit':
|
|
|
responseData.data = await ctx.service.financialPayTenderAudit.copyShenpi2otherTender(ctx.subProject.id, data, data.this_tid);
|
|
|
break;
|
|
|
- case 'add-pay':
|
|
|
- responseData.data = await ctx.service.financialPay.addPay(ctx.subProject.id, data.updateData);
|
|
|
+ case 'copy-tender-bank':
|
|
|
+ responseData.data = await ctx.service.financialPayTender.copyBank2otherTender(ctx.subProject.id, data.tenders, data.this_tender);
|
|
|
break;
|
|
|
- case 'del-pay':
|
|
|
- responseData.data = await ctx.service.financialPay.delPay(data.postData.node);
|
|
|
+ case 'add-pay-company':
|
|
|
+ responseData.data = await ctx.service.financialPayCompany.addPayCompany(ctx.subProject.id, data.updateData);
|
|
|
+ break;
|
|
|
+ case 'del-pay-company':
|
|
|
+ responseData.data = await ctx.service.financialPayCompany.delPayCompany(data.postData.node);
|
|
|
break;
|
|
|
case 'set-pay-tender':
|
|
|
responseData.data = await ctx.service.financialPayTender.savePayTender(ctx.subProject.id, data.updateData);
|
|
@@ -810,6 +761,193 @@ module.exports = app => {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 变更管理 页面 (Get)
|
|
|
+ *
|
|
|
+ * @param {Object} ctx - egg全局变量
|
|
|
+ * @return {void}
|
|
|
+ */
|
|
|
+ async payCompany(ctx) {
|
|
|
+ try {
|
|
|
+ const status = parseInt(ctx.query.status) || 0;
|
|
|
+ const tid = parseInt(ctx.query.tid) || null;
|
|
|
+ const used = ctx.query.used || null;
|
|
|
+ await this._filterPayCompany(ctx, status, tid, used);
|
|
|
+ } catch (err) {
|
|
|
+ this.log(err);
|
|
|
+ ctx.redirect(`/sp/${ctx.subProject.id}/dashboard`);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ async _filterPayCompany(ctx, status = 0, tid = null, used = null) {
|
|
|
+ const financialPermission = await ctx.service.subProjPermission.getFinancailPermission(ctx.subProject.permission.fund_trans_permission, ctx.subProject.permission.fund_pay_permission);
|
|
|
+ if (!financialPermission.pay_show) {
|
|
|
+ throw '没有查看权限';
|
|
|
+ }
|
|
|
+ const payCompany = await ctx.service.financialPayCompany.getOnePayCompany(ctx.params.fpcid);
|
|
|
+ if (!payCompany) {
|
|
|
+ throw '该支付单位期不存在';
|
|
|
+ }
|
|
|
+ const fptAudits = await ctx.service.financialPayTenderAudit.getAllDataByCondition({ where: { spid: ctx.subProject.id, uid: ctx.session.sessionUser.accountId } });
|
|
|
+ const fptAuditTids = ctx.helper._.map(fptAudits, 'tid');
|
|
|
+ const fptReportTids = ctx.helper._.map(ctx.helper._.filter(fptAudits, { is_report: 1 }), 'tid');
|
|
|
+ const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
|
|
|
+ const filterTids = tid === null ? (ctx.session.sessionUser.is_admin ? null : fptAuditTids) : [tid];
|
|
|
+ const tenderCondition = { spid: ctx.subProject.id, filter_fund: 0 };
|
|
|
+ let hadTender = false;
|
|
|
+ if (ctx.session.sessionUser.is_admin) {
|
|
|
+ hadTender = true;
|
|
|
+ } else if (fptAuditTids.length !== 0) {
|
|
|
+ hadTender = true;
|
|
|
+ tenderCondition.id = fptAuditTids;
|
|
|
+ } else {
|
|
|
+ hadTender = false;
|
|
|
+ tenderCondition.id = -1;
|
|
|
+ }
|
|
|
+ const categoryData = await this.ctx.service.category.getAllCategory(ctx.subProject);
|
|
|
+ const tenders = hadTender ? await ctx.service.tender.getAllDataByCondition({ where: tenderCondition, columns: ['id', 'name', 'category'] }) : [];
|
|
|
+ const filter = JSON.parse(JSON.stringify(auditConst.financial.filter));
|
|
|
+ filter.count = [];
|
|
|
+ filter.count[filter.status.pending] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, payCompany.id, filter.status.pending, filterTids, used);// await ctx.service.change.pendingDatas(tender.id, ctx.session.sessionUser.accountId);
|
|
|
+ filter.count[filter.status.uncheck] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, payCompany.id, filter.status.uncheck, filterTids, used);// await ctx.service.change.checkingDatas(tender.id, ctx.session.sessionUser.accountId);
|
|
|
+ filter.count[filter.status.checking] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, payCompany.id, filter.status.checking, filterTids, used);// await ctx.service.change.checkedDatas(tender.id, ctx.session.sessionUser.accountId);
|
|
|
+ filter.count[filter.status.checked] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, payCompany.id, filter.status.checked, filterTids, used);// await ctx.service.change.pendingDatas(tender.id, ctx.session.sessionUser.accountId);
|
|
|
+ const payList = await ctx.service.financialPay.getListByStatus(ctx.subProject.id, payCompany.id, status, filterTids, used, 1);
|
|
|
+ const total = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, payCompany.id, status, filterTids, used);
|
|
|
+ // 分页相关
|
|
|
+ const page = ctx.page;
|
|
|
+ const pageSize = ctx.pageSize;
|
|
|
+ const pageInfo = {
|
|
|
+ page,
|
|
|
+ pageSizeSelect: 1,
|
|
|
+ pageSize,
|
|
|
+ total_num: total,
|
|
|
+ total: Math.ceil(total / pageSize),
|
|
|
+ queryData: JSON.stringify(ctx.urlInfo.query),
|
|
|
+ };
|
|
|
+ // 获取所有项目参与者
|
|
|
+ const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject, ['id', 'account', 'name', 'company', 'company_id', 'role', 'enable', 'is_admin', 'account_group', 'mobile']);
|
|
|
+ const payTenders = await ctx.service.financialPayTender.getAllDataByCondition({ where: { spid: ctx.subProject.id } });
|
|
|
+ if (tenders.length > 0) {
|
|
|
+ const allLastPay = await ctx.service.financialPay.getAllDataByCondition({ where: { spid: ctx.subProject.id, tid: ctx.helper._.map(tenders, 'id') }, columns: ['id', 'tid', 'code'], orders: [['id', 'desc']] });
|
|
|
+ const tenderInfos = await ctx.service.tenderInfo.getAllDataByCondition({ where: { tid: ctx.helper._.map(tenders, 'id') }, columns: ['tid', 'pay_account', 'deal_info'] });
|
|
|
+ for (const t of tenders) {
|
|
|
+ t.category = t.category && t.category !== '' ? JSON.parse(t.category) : null;
|
|
|
+ const info = ctx.helper._.find(tenderInfos, { tid: t.id });
|
|
|
+ t.pay_account = info && info.pay_account ? JSON.parse(info.pay_account).project : '';
|
|
|
+ const pt = ctx.helper._.find(payTenders, { tid: t.id });
|
|
|
+ t.pt = pt ? pt : { id: 0, tid: t.id, name: '', bank: '', bank_account: '', contact: '', phone: '' };
|
|
|
+ if (ctx.session.sessionUser.is_admin || ctx.helper._.includes(fptReportTids, t.id)) {
|
|
|
+ t.dealCode = info && info.deal_info ? JSON.parse(info.deal_info).dealCode : '';
|
|
|
+ const lastPay = ctx.helper._.filter(allLastPay, { tid: t.id });
|
|
|
+ t.startNum = 1;
|
|
|
+ if (lastPay.length > 0) {
|
|
|
+ const startArray = lastPay[0].code.split('-');
|
|
|
+ t.startNum = parseInt(startArray[startArray.length - 1]) + 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (const pay of payList) {
|
|
|
+ const t = ctx.helper._.find(tenders, { id: pay.tid });
|
|
|
+ pay.tenderName = t ? t.name : '';
|
|
|
+ const userInfo = ctx.helper._.find(accountList, { id: pay.uid });
|
|
|
+ pay.username = userInfo ? userInfo.name : '';
|
|
|
+ if (pay.status !== auditConst.financial.status.checked || !pay.final_auditor_str) {
|
|
|
+ pay.curAuditors = await ctx.service.financialPayAudit.getAuditorsByStatus(pay.id, pay.status, pay.times);
|
|
|
+ if (pay.status === auditConst.financial.status.checked && pay.curAuditors.length > 0) {
|
|
|
+ const final_auditor_str = pay.curAuditors[0].audit_type === auditConst.auditType.key.common
|
|
|
+ ? pay.curAuditors[0].name + (pay.curAuditors[0].role ? '-' + pay.curAuditors[0].role : '')
|
|
|
+ : ctx.helper.transFormToChinese(pay.curAuditors[0].audit_order) + '审';
|
|
|
+ await ctx.service.financialPay.defaultUpdate({ final_auditor_str }, { where: { id: pay.id } });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (pay.status !== auditConst.financial.status.checked) {
|
|
|
+ pay.entities = await ctx.service.financialPayContract.getEntities(pay.id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ctx.session.sessionUser.is_admin && tenders.length > 0) {
|
|
|
+ const allPermissionList = await ctx.service.financialPayTenderAudit.getAllList(ctx.subProject.id, ctx.helper._.map(tenders, 'id'), accountList);
|
|
|
+ const allAuditGroupList = await ctx.service.shenpiAudit.getAllAuditGroupList(ctx.helper._.map(tenders, 'id'), shenpiConst.sp_other_type.financial, shenpiConst.sp_status.gdspl);
|
|
|
+ for (const t of tenders) {
|
|
|
+ t.permissionList = ctx.helper._.filter(allPermissionList, { tid: t.id }) || [];
|
|
|
+ // t.auditGroupList = await ctx.service.shenpiAudit.getAuditGroupList(t.id, shenpiConst.sp_other_type.financial, shenpiConst.sp_status.gdspl);
|
|
|
+ t.auditGroupList = ctx.helper._.find(allAuditGroupList, { tid: t.id }) ? ctx.helper._.find(allAuditGroupList, { tid: t.id }).audits : [];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const notCompanyPays = await ctx.service.financialPay.getAllDataByCondition({ where: { spid: ctx.subProject.id, fpcid: null } });
|
|
|
+ for (const pay of notCompanyPays) {
|
|
|
+ const t = ctx.helper._.find(tenders, { id: pay.tid });
|
|
|
+ pay.tenderName = t ? t.name : '';
|
|
|
+ const userInfo = ctx.helper._.find(accountList, { id: pay.uid });
|
|
|
+ pay.username = userInfo ? userInfo.name : '';
|
|
|
+ }
|
|
|
+ const renderData = {
|
|
|
+ categoryData,
|
|
|
+ tenders,
|
|
|
+ financialPermission,
|
|
|
+ usedList: financialConst.used,
|
|
|
+ auditConst: auditConst.financial,
|
|
|
+ filter,
|
|
|
+ tid,
|
|
|
+ status,
|
|
|
+ used,
|
|
|
+ payList,
|
|
|
+ payCompany,
|
|
|
+ notCompanyPays,
|
|
|
+ fptAuditTids,
|
|
|
+ fptReportTids,
|
|
|
+ unitList,
|
|
|
+ moment,
|
|
|
+ auditType: auditConst.auditType,
|
|
|
+ // preUrl: '/financial',
|
|
|
+ jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.financial.payCompany),
|
|
|
+ pageInfo,
|
|
|
+ };
|
|
|
+ if (ctx.session.sessionUser.is_admin) {
|
|
|
+ renderData.accountList = accountList;
|
|
|
+ renderData.accountGroup = unitList.map(item => {
|
|
|
+ const groupList = accountList.filter(item1 => item1.company === item.name);
|
|
|
+ return { groupName: item.name, groupList };
|
|
|
+ }).filter(x => { return x.groupList.length > 0; });
|
|
|
+ renderData.auditType = auditConst.auditType;
|
|
|
+ renderData.shenpi = shenpiConst;
|
|
|
+ }
|
|
|
+ await this.layout('financial/pay_company.ejs', renderData, 'financial/pay_company_modal.ejs');
|
|
|
+ }
|
|
|
+
|
|
|
+ async payCompanySave(ctx) {
|
|
|
+ try {
|
|
|
+ const responseData = {
|
|
|
+ err: 0, msg: '', data: {},
|
|
|
+ };
|
|
|
+ const data = JSON.parse(ctx.request.body.data);
|
|
|
+ if (!data.type) {
|
|
|
+ throw '提交数据错误';
|
|
|
+ }
|
|
|
+ const payCompany = await ctx.service.financialPayCompany.getDataById(ctx.params.fpcid);
|
|
|
+ if (!payCompany) {
|
|
|
+ throw '资金支付单位期不存在';
|
|
|
+ }
|
|
|
+ switch (data.type) {
|
|
|
+ case 'batch-old-pays':
|
|
|
+ await ctx.service.financialPay.batchOldPays(ctx.subProject.id, payCompany, data.postData.payIds);
|
|
|
+ break;
|
|
|
+ case 'add-pay':
|
|
|
+ responseData.data = await ctx.service.financialPay.addPay(ctx.subProject.id, payCompany, data.updateData);
|
|
|
+ break;
|
|
|
+ case 'del-pay':
|
|
|
+ responseData.data = await ctx.service.financialPay.delPay(payCompany, data.postData.node);
|
|
|
+ break;
|
|
|
+ default: throw '参数有误';
|
|
|
+ }
|
|
|
+ ctx.body = responseData;
|
|
|
+ } catch (err) {
|
|
|
+ this.log(err);
|
|
|
+ ctx.body = { err: 1, msg: err.toString(), data: {} };
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 获取审批界面所需的 原报、审批人数据等
|
|
|
* @param ctx
|
|
|
* @return {Promise<void>}
|
|
@@ -862,6 +1000,9 @@ module.exports = app => {
|
|
|
if (!ctx.financialPay) {
|
|
|
throw '数据错误';
|
|
|
}
|
|
|
+ if (!ctx.financialPay.fpcid || !ctx.financialPay.payCompany) {
|
|
|
+ throw '未关联资金支付单位期无法进行任何操作';
|
|
|
+ }
|
|
|
if (ctx.financialPay.uid !== ctx.session.sessionUser.accountId) {
|
|
|
throw '您无权上报该资金支付数据';
|
|
|
}
|
|
@@ -889,6 +1030,9 @@ module.exports = app => {
|
|
|
if (!ctx.financialPay || ctx.financialPay.status !== auditConst.financial.status.checking) {
|
|
|
throw '当前资金支付数据有误';
|
|
|
}
|
|
|
+ if (!ctx.financialPay.fpcid || !ctx.financialPay.payCompany) {
|
|
|
+ throw '未关联资金支付单位期无法进行任何操作';
|
|
|
+ }
|
|
|
if (ctx.financialPay.curAuditorIds.length === 0 || ctx.financialPay.curAuditorIds.indexOf(ctx.session.sessionUser.accountId) === -1) {
|
|
|
throw '您无权进行该操作';
|
|
|
}
|
|
@@ -916,6 +1060,9 @@ module.exports = app => {
|
|
|
*/
|
|
|
async checkPayAgain(ctx) {
|
|
|
try {
|
|
|
+ if (!ctx.financialPay.fpcid || !ctx.financialPay.payCompany) {
|
|
|
+ throw '未关联资金支付单位期无法进行任何操作';
|
|
|
+ }
|
|
|
// 获取终审
|
|
|
// const auditInfo = await this.ctx.service.changeProjectAudit.getAuditorByStatus(ctx.change.id, audit.changeProject.status.checked);
|
|
|
// if (ctx.change.status !== audit.changeProject.status.checked || ctx.session.sessionUser.accountId !== auditInfo.aid) {
|
|
@@ -964,6 +1111,9 @@ module.exports = app => {
|
|
|
const responseData = {
|
|
|
err: 0, msg: '', data: {},
|
|
|
};
|
|
|
+ if (!ctx.financialPay.fpcid || !ctx.financialPay.payCompany) {
|
|
|
+ throw '未关联资金支付单位期无法进行任何操作';
|
|
|
+ }
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
if (!data.type) {
|
|
|
throw '提交数据错误';
|
|
@@ -994,13 +1144,13 @@ module.exports = app => {
|
|
|
responseData.data = await ctx.service.financialPayContract.addContracts(ctx.financialPay, data.contract_ids);
|
|
|
break;
|
|
|
case 'contract_del':
|
|
|
- responseData.data = await ctx.service.financialPayContract.delContract(ctx.financialPay.id, data.ids);
|
|
|
+ responseData.data = await ctx.service.financialPayContract.delContract(ctx.financialPay.id, ctx.financialPay.payCompany, data.ids);
|
|
|
break;
|
|
|
case 'contract_update':
|
|
|
- responseData.data = await ctx.service.financialPayContract.updateContract(ctx.financialPay.id, data.updateData);
|
|
|
+ responseData.data = await ctx.service.financialPayContract.updateContract(ctx.financialPay.id, ctx.financialPay.payCompany, data.updateData);
|
|
|
break;
|
|
|
case 'contract_paste':
|
|
|
- responseData.data = await ctx.service.financialPayContract.updateContracts(ctx.financialPay.id, data.updateData);
|
|
|
+ responseData.data = await ctx.service.financialPayContract.updateContracts(ctx.financialPay.id, ctx.financialPay.payCompany, data.updateData);
|
|
|
break;
|
|
|
case 'file_bill':
|
|
|
responseData.data = await ctx.service.financialPayAtt.updateBill(data.id, data.bill);
|
|
@@ -1024,6 +1174,9 @@ module.exports = app => {
|
|
|
const parts = this.ctx.multipart({
|
|
|
autoFields: true,
|
|
|
});
|
|
|
+ if (!ctx.financialPay.fpcid || !ctx.financialPay.payCompany) {
|
|
|
+ throw '未关联资金支付单位期无法进行任何操作';
|
|
|
+ }
|
|
|
const files = [];
|
|
|
const create_time = Date.parse(new Date()) / 1000;
|
|
|
let idx = 0;
|
|
@@ -1083,6 +1236,9 @@ module.exports = app => {
|
|
|
*/
|
|
|
async payDeleteFile(ctx) {
|
|
|
try {
|
|
|
+ if (!ctx.financialPay.fpcid || !ctx.financialPay.payCompany) {
|
|
|
+ throw '未关联资金支付单位期无法进行任何操作';
|
|
|
+ }
|
|
|
const { fpcid, id } = JSON.parse(ctx.request.body.data);
|
|
|
const fileInfo = await ctx.service.financialPayAtt.getDataById(id);
|
|
|
if (fileInfo || Object.keys(fileInfo).length) {
|