|
@@ -817,13 +817,13 @@ module.exports = app => {
|
|
|
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, payStage.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, payStage.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, payStage.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, payStage.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, payStage.id, status, filterTids, used, 1);
|
|
|
+ filter.count[filter.status.pending] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, null, payStage.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, null, payStage.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, null, payStage.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, null, payStage.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, null, payStage.id, status, filterTids, used, 1);
|
|
|
const userTenderList = await ctx.service.financialPay.getUserTenderList(ctx.subProject.id, ctx.session.sessionUser.accountId, payStage.id);
|
|
|
- const total = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, payStage.id, status, filterTids, used);
|
|
|
+ const total = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, null, payStage.id, status, filterTids, used);
|
|
|
// 分页相关
|
|
|
const page = ctx.page;
|
|
|
const pageSize = ctx.pageSize;
|
|
@@ -1006,7 +1006,6 @@ module.exports = app => {
|
|
|
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) {
|
|
@@ -1030,20 +1029,23 @@ module.exports = app => {
|
|
|
const userCompanyList = await ctx.service.financialPayStage.getUserCompanyList(ctx.subProject.id, userCompany ? userCompany.id : 0, unitList, qi);
|
|
|
const userOrderList = await ctx.service.financialPayStage.getUserOrderList(ctx.subProject.id, userCompany ? userCompany.id : 0, companyInfo ? companyInfo.id : null);
|
|
|
const userTenderList = await ctx.service.financialPay.getUserTenderList(ctx.subProject.id, ctx.session.sessionUser.accountId);
|
|
|
+ const filterTids = tid === null ? (ctx.session.sessionUser.is_admin ? null : userTenderList.length > 0 ? ctx.helper._.map(userTenderList, 'tid') : []) : [tid];
|
|
|
let fpsidList = null;
|
|
|
if (company || qi) {
|
|
|
const fpstageList = await ctx.service.financialPayStage.getListByStatus(ctx.subProject.id, companyInfo ? companyInfo.id : null, userCompany ? userCompany.id : 0, qi, 0);
|
|
|
fpsidList = fpstageList.length > 0 ? ctx.helper._.map(fpstageList, 'id') : 0;
|
|
|
}
|
|
|
+ const allPayStages = !ctx.session.sessionUser.is_admin ? await ctx.service.financialPayStage.getListByStatus(ctx.subProject.id, null, userCompany ? userCompany.id : 0, null, 0) : null;
|
|
|
+ const allFpsidList = !ctx.session.sessionUser.is_admin ? ctx.helper._.map(allPayStages, 'id') : null;
|
|
|
// const payList = await ctx.service.financialPayStage.getListByStatus(ctx.subProject.id, companyInfo ? companyInfo.id : null, userCompany ? userCompany.id : 0, qi);
|
|
|
const filter = JSON.parse(JSON.stringify(auditConst.financial.filter));
|
|
|
filter.count = [];
|
|
|
- filter.count[filter.status.pending] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, fpsidList !== null ? fpsidList : null, filter.status.pending, filterTids, used);
|
|
|
- filter.count[filter.status.uncheck] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, fpsidList !== null ? fpsidList : null, filter.status.uncheck, filterTids, used);
|
|
|
- filter.count[filter.status.checking] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, fpsidList !== null ? fpsidList : null, filter.status.checking, filterTids, used);
|
|
|
- filter.count[filter.status.checked] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, fpsidList !== null ? fpsidList : null, filter.status.checked, filterTids, used);
|
|
|
- const payList = await ctx.service.financialPay.getListByStatus(ctx.subProject.id, fpsidList !== null ? fpsidList : null, status, filterTids, used, 1);
|
|
|
- const total = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, fpsidList !== null ? fpsidList : null, status, filterTids, used);
|
|
|
+ filter.count[filter.status.pending] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, allFpsidList, fpsidList !== null ? fpsidList : null, filter.status.pending, filterTids, used);
|
|
|
+ filter.count[filter.status.uncheck] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, allFpsidList, fpsidList !== null ? fpsidList : null, filter.status.uncheck, filterTids, used);
|
|
|
+ filter.count[filter.status.checking] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, allFpsidList, fpsidList !== null ? fpsidList : null, filter.status.checking, filterTids, used);
|
|
|
+ filter.count[filter.status.checked] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, allFpsidList, fpsidList !== null ? fpsidList : null, filter.status.checked, filterTids, used);
|
|
|
+ const payList = await ctx.service.financialPay.getListByStatus(ctx.subProject.id, allFpsidList, fpsidList !== null ? fpsidList : null, status, filterTids, used, 1);
|
|
|
+ const total = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, allFpsidList, fpsidList !== null ? fpsidList : null, status, filterTids, used);
|
|
|
// 分页相关
|
|
|
const page = ctx.page;
|
|
|
const pageSize = ctx.pageSize;
|
|
@@ -1055,8 +1057,9 @@ module.exports = app => {
|
|
|
total: Math.ceil(total / pageSize),
|
|
|
queryData: JSON.stringify(ctx.urlInfo.query),
|
|
|
};
|
|
|
+ const allTenders = await ctx.service.tender.getAllDataByCondition({ where: { spid: ctx.subProject.id, filter_fund: 0 }, columns: ['id', 'name', 'category'] });
|
|
|
for (const pay of payList) {
|
|
|
- const t = ctx.helper._.find(tenders, { id: pay.tid });
|
|
|
+ const t = ctx.helper._.find(allTenders, { id: pay.tid });
|
|
|
pay.tenderName = t ? t.name : '';
|
|
|
const userInfo = ctx.helper._.find(accountList, { id: pay.uid });
|
|
|
pay.username = userInfo ? userInfo.name : '';
|
|
@@ -1159,7 +1162,9 @@ module.exports = app => {
|
|
|
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 = ctx.session.sessionUser.is_admin ? null : fptAuditTids;
|
|
|
+ const userTenderList = await ctx.service.financialPay.getUserTenderList(ctx.subProject.id, ctx.session.sessionUser.accountId);
|
|
|
+ const filterTids = ctx.session.sessionUser.is_admin ? null : userTenderList.length > 0 ? ctx.helper._.map(userTenderList, 'tid') : [];
|
|
|
+ // const filterTids = ctx.session.sessionUser.is_admin ? null : fptAuditTids;
|
|
|
const tenderCondition = { spid: ctx.subProject.id, filter_fund: 0 };
|
|
|
let hadTender = false;
|
|
|
if (ctx.session.sessionUser.is_admin) {
|
|
@@ -1173,7 +1178,6 @@ module.exports = app => {
|
|
|
}
|
|
|
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 allPays = await ctx.service.financialPay.getListByStatus(ctx.subProject.id, null, 0, filterTids);
|
|
|
const transfersCondition = { spid: ctx.subProject.id };
|
|
|
if (filterTids) {
|
|
|
transfersCondition.tid = filterTids;
|
|
@@ -1186,6 +1190,9 @@ module.exports = app => {
|
|
|
throw '请联系管理员添加用户所在单位信息';
|
|
|
}
|
|
|
const allPayStages = await ctx.service.financialPayStage.getListByStatus(ctx.subProject.id, null, userCompany ? userCompany.id : 0, null, 0);
|
|
|
+ // const allPayStages = !ctx.session.sessionUser.is_admin ? await ctx.service.financialPayStage.getListByStatus(ctx.subProject.id, null, userCompany ? userCompany.id : 0, null, 0) : null;
|
|
|
+ const allFpsidList = !ctx.session.sessionUser.is_admin ? ctx.helper._.map(allPayStages, 'id') : null;
|
|
|
+ const allPays = await ctx.service.financialPay.getListByStatus(ctx.subProject.id, allFpsidList, null, 0, filterTids);
|
|
|
for (const t of tenders) {
|
|
|
t.category = t.category && t.category !== '' ? JSON.parse(t.category) : null;
|
|
|
const tenderPays = ctx.helper._.filter(allPays, { tid: t.id });
|
|
@@ -1709,7 +1716,16 @@ module.exports = app => {
|
|
|
responseData.data.tenders = hadTender ? await ctx.service.tender.getAllDataByCondition({ where: tenderCondition, columns: ['id', 'name'] }) : [];
|
|
|
responseData.data.transferList = tid === null ? await ctx.service.financialTransfer.getAllDataByCondition({ where: { spid: ctx.subProject.id } }) : [];
|
|
|
responseData.data.transferTenderList = tid === null ? await ctx.service.financialTransferTender.getAllDataByCondition({ where: { spid: ctx.subProject.id } }) : [];
|
|
|
- responseData.data.payList = await ctx.service.financialPay.getListByStatus(ctx.subProject.id, null, 0, filterTids);
|
|
|
+ const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject, ['id', 'account', 'name', 'company', 'company_id', 'role', 'enable', 'is_admin', 'account_group', 'mobile']);
|
|
|
+ const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
|
|
|
+ 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 allPayStages = !ctx.session.sessionUser.is_admin ? await ctx.service.financialPayStage.getListByStatus(ctx.subProject.id, null, userCompany ? userCompany.id : 0, null, 0) : null;
|
|
|
+ const allFpsidList = !ctx.session.sessionUser.is_admin ? ctx.helper._.map(allPayStages, 'id') : null;
|
|
|
+ responseData.data.payList = await ctx.service.financialPay.getListByStatus(ctx.subProject.id, allFpsidList, null, 0, filterTids);
|
|
|
ctx.body = responseData;
|
|
|
} catch (err) {
|
|
|
this.log(err);
|