|
@@ -31,16 +31,26 @@ module.exports = app => {
|
|
ctx.showTitle = true;
|
|
ctx.showTitle = true;
|
|
}
|
|
}
|
|
|
|
|
|
- async _list(view, setting, modal = '', listStatus = '') {
|
|
|
|
|
|
+ async _list(view, modal = '') {
|
|
try {
|
|
try {
|
|
// 获取用户新建标段权利
|
|
// 获取用户新建标段权利
|
|
const accountInfo = await this.ctx.service.projectAccount.getDataById(this.ctx.session.sessionUser.accountId);
|
|
const accountInfo = await this.ctx.service.projectAccount.getDataById(this.ctx.session.sessionUser.accountId);
|
|
const userPermission = accountInfo !== undefined && accountInfo.permission !== '' ? JSON.parse(accountInfo.permission) : null;
|
|
const userPermission = accountInfo !== undefined && accountInfo.permission !== '' ? JSON.parse(accountInfo.permission) : null;
|
|
|
|
|
|
- const tenderList = await this.ctx.service.tender.getList(listStatus, userPermission);
|
|
|
|
|
|
+ const tenderList = await this.ctx.service.tender.getList('', userPermission);
|
|
for (const t of tenderList) {
|
|
for (const t of tenderList) {
|
|
- t.lastStage = await this.ctx.service.stage.getLastestStage(t.id, true);
|
|
|
|
- t.completeStage = await this.ctx.service.stage.getLastestCompleteStage(t.id);
|
|
|
|
|
|
+ if (t.user_id === this.ctx.session.sessionUser.accountId && (
|
|
|
|
+ t.ledger_status === auditConst.ledger.status.checkNo || t.ledger_status === auditConst.ledger.status.uncheck)) {
|
|
|
|
+ const sum = await this.ctx.service.ledger.addUp({tender_id: t.id, is_leaf: true});
|
|
|
|
+ t.total_price = sum.total_price;
|
|
|
|
+ t.deal_tp = sum.deal_tp;
|
|
|
|
+ }
|
|
|
|
+ if (t.ledger_status === auditConst.ledger.status.checked) {
|
|
|
|
+ t.lastStage = await this.ctx.service.stage.getLastestStage(t.id, true);
|
|
|
|
+ if (t.lastStage) {
|
|
|
|
+ await this.ctx.service.stage.checkStageGatherData(t.lastStage);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
const categoryData = await this.ctx.service.category.getAllCategory(this.ctx.session.sessionProject.id);
|
|
const categoryData = await this.ctx.service.category.getAllCategory(this.ctx.session.sessionProject.id);
|
|
const valuations = await this.ctx.service.valuation.getProjectValidValuation(this.ctx.session.sessionProject.id);
|
|
const valuations = await this.ctx.service.valuation.getProjectValidValuation(this.ctx.session.sessionProject.id);
|
|
@@ -49,7 +59,6 @@ module.exports = app => {
|
|
tenderConst,
|
|
tenderConst,
|
|
settingConst,
|
|
settingConst,
|
|
categoryData,
|
|
categoryData,
|
|
- tableColSetting: setting,
|
|
|
|
measureType: tenderConst.measureType,
|
|
measureType: tenderConst.measureType,
|
|
jsFiles: this.app.jsFiles.common.concat(this.jsFiles),
|
|
jsFiles: this.app.jsFiles.common.concat(this.jsFiles),
|
|
auditConst,
|
|
auditConst,
|
|
@@ -58,6 +67,7 @@ module.exports = app => {
|
|
};
|
|
};
|
|
await this.layout(view, renderData, modal);
|
|
await this.layout(view, renderData, modal);
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
|
+ console.log(err);
|
|
this.log(err);
|
|
this.log(err);
|
|
this.ctx.redirect('/dashboard');
|
|
this.ctx.redirect('/dashboard');
|
|
}
|
|
}
|
|
@@ -71,7 +81,7 @@ module.exports = app => {
|
|
*/
|
|
*/
|
|
async listInfo(ctx) {
|
|
async listInfo(ctx) {
|
|
this.jsFiles = this.app.jsFiles.tender.list;
|
|
this.jsFiles = this.app.jsFiles.tender.list;
|
|
- await this._list('tender/index.ejs', tenderConst.infoTableCol, 'tender/modal.ejs');
|
|
|
|
|
|
+ await this._list('tender/index.ejs', 'tender/modal.ejs');
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -82,7 +92,7 @@ module.exports = app => {
|
|
*/
|
|
*/
|
|
async listProgress(ctx) {
|
|
async listProgress(ctx) {
|
|
this.jsFiles = this.app.jsFiles.tender.progress;
|
|
this.jsFiles = this.app.jsFiles.tender.progress;
|
|
- await this._list('tender/progress.ejs', tenderConst.progressTableCol, 'tender/modal.ejs');
|
|
|
|
|
|
+ await this._list('tender/progress.ejs', 'tender/modal.ejs');
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -97,10 +107,31 @@ module.exports = app => {
|
|
const accountInfo = await this.ctx.service.projectAccount.getDataById(this.ctx.session.sessionUser.accountId);
|
|
const accountInfo = await this.ctx.service.projectAccount.getDataById(this.ctx.session.sessionUser.accountId);
|
|
const userPermission = accountInfo !== undefined && accountInfo.permission !== '' ? JSON.parse(accountInfo.permission) : null;
|
|
const userPermission = accountInfo !== undefined && accountInfo.permission !== '' ? JSON.parse(accountInfo.permission) : null;
|
|
if (userPermission !== null && userPermission.tender !== undefined && userPermission.tender.indexOf('1') !== -1) {
|
|
if (userPermission !== null && userPermission.tender !== undefined && userPermission.tender.indexOf('1') !== -1) {
|
|
- this.jsFiles = this.app.jsFiles.tender.manage;
|
|
|
|
- await this._list('tender/manage.ejs', tenderConst.manageTableCol, 'tender/manage_modal.ejs', 'manage');
|
|
|
|
|
|
+ // 获取用户新建标段权利
|
|
|
|
+ const accountInfo = await this.ctx.service.projectAccount.getDataById(this.ctx.session.sessionUser.accountId);
|
|
|
|
+ const userPermission = accountInfo !== undefined && accountInfo.permission !== '' ? JSON.parse(accountInfo.permission) : null;
|
|
|
|
+
|
|
|
|
+ const tenderList = await this.ctx.service.tender.getList('manage', userPermission);
|
|
|
|
+ for (const t of tenderList) {
|
|
|
|
+ t.lastStage = await this.ctx.service.stage.getLastestStage(t.id, true);
|
|
|
|
+ t.completeStage = await this.ctx.service.stage.getLastestCompleteStage(t.id);
|
|
|
|
+ }
|
|
|
|
+ const categoryData = await this.ctx.service.category.getAllCategory(this.ctx.session.sessionProject.id);
|
|
|
|
+ const valuations = await this.ctx.service.valuation.getProjectValidValuation(this.ctx.session.sessionProject.id);
|
|
|
|
+ const renderData = {
|
|
|
|
+ tenderList,
|
|
|
|
+ tenderConst,
|
|
|
|
+ settingConst,
|
|
|
|
+ categoryData,
|
|
|
|
+ measureType: tenderConst.measureType,
|
|
|
|
+ jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.tender.manage),
|
|
|
|
+ auditConst,
|
|
|
|
+ userPermission,
|
|
|
|
+ valuations,
|
|
|
|
+ };
|
|
|
|
+ await this.layout('tender/manage.ejs', renderData, 'tender/manage_modal.ejs');
|
|
} else {
|
|
} else {
|
|
- this.ctx.redirect('/dashboard');
|
|
|
|
|
|
+ this.ctx.redirect(ctx.request.header.referer);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|