|
@@ -21,6 +21,7 @@ const billsPosConvert = require('../lib/bills_pos_convert');
|
|
const path = require('path');
|
|
const path = require('path');
|
|
const sendToWormhole = require('stream-wormhole');
|
|
const sendToWormhole = require('stream-wormhole');
|
|
const scheduleConst = require('../const/schedule');
|
|
const scheduleConst = require('../const/schedule');
|
|
|
|
+const SumLoad = require('../lib/sum_load');
|
|
|
|
|
|
module.exports = app => {
|
|
module.exports = app => {
|
|
|
|
|
|
@@ -291,66 +292,6 @@ module.exports = app => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- async listLoad(ctx) {
|
|
|
|
- try {
|
|
|
|
- const data = JSON.parse(ctx.request.body.data);
|
|
|
|
- if (!data.tid && !data.lid && !data.type) throw '数据错误';
|
|
|
|
- const responseData = {
|
|
|
|
- err: 0,
|
|
|
|
- msg: '',
|
|
|
|
- data: { ledgerAuditConst: auditConst.ledger, stageAuditConst: auditConst.stage },
|
|
|
|
- };
|
|
|
|
- responseData.data.category = await this.ctx.service.category.getAllCategory(this.ctx.session.sessionProject.id);
|
|
|
|
- // 获取用户权限
|
|
|
|
- const accountInfo = await this.ctx.service.projectAccount.getDataById(this.ctx.session.sessionUser.accountId);
|
|
|
|
- const userPermission = accountInfo !== undefined && accountInfo.permission !== '' ? JSON.parse(accountInfo.permission) : null;
|
|
|
|
- const tenderList = await this.ctx.service.tender.getList('', userPermission);
|
|
|
|
- for (const t of tenderList) {
|
|
|
|
- if (t.ledger_status === auditConst.ledger.status.checked) {
|
|
|
|
- t.lastStage = await this.ctx.service.stage.getLastestStage(t.id, false);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (data.type === 'ledger') {
|
|
|
|
- responseData.data.tenders = tenderList.filter(x => {
|
|
|
|
- return x.ledger_status === auditConst.ledger.status.checked;
|
|
|
|
- });
|
|
|
|
- const history = await this.ctx.service.sumLoadHistory.getLedgerHistory(data.tid, data.lid);
|
|
|
|
- if (history) responseData.data.history = { tenders: history.tender, load_time: history.load_time, type: 'ledger' };
|
|
|
|
- } else if (data.type === 'stage') {
|
|
|
|
- responseData.data.tenders = tenderList.filter(x => {
|
|
|
|
- return x.ledger_status === auditConst.ledger.status.checked && !!x.lastStage;
|
|
|
|
- });
|
|
|
|
- let history = await this.ctx.service.sumLoadHistory.getStageHistory(data.tid, data.lid);
|
|
|
|
- if (history) {
|
|
|
|
- responseData.data.history = { tenders: history.tender, load_time: history.load_time, type: 'stage' };
|
|
|
|
- } else {
|
|
|
|
- history = await this.ctx.service.sumLoadHistory.getReviseHistory(data.tid, data.lid);
|
|
|
|
- if (history) {
|
|
|
|
- responseData.data.history = { tenders: history.tender, load_time: history.load_time, type: 'revise' };
|
|
|
|
- } else {
|
|
|
|
- history = await this.ctx.service.sumLoadHistory.getLedgerHistory(data.tid, data.lid);
|
|
|
|
- if (history) responseData.data.history = { tenders: history.tender, load_time: history.load_time, type: 'ledger' };
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else if (data.type === 'revise') {
|
|
|
|
- responseData.data.tenders = tenderList.filter(x => {
|
|
|
|
- return x.ledger_status === auditConst.ledger.status.checked;
|
|
|
|
- });
|
|
|
|
- let history = await this.ctx.service.sumLoadHistory.getReviseHistory(data.tid, data.lid);
|
|
|
|
- if (history) {
|
|
|
|
- responseData.data.history = { tenders: history.tender, load_time: history.load_time, type: 'revise' };
|
|
|
|
- } else {
|
|
|
|
- history = await this.ctx.service.sumLoadHistory.getLedgerHistory(data.tid, data.lid);
|
|
|
|
- if (history) responseData.data.history = { tenders: history.tender, load_time: history.load_time, type: 'ledger' };
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- ctx.body = responseData;
|
|
|
|
- } catch(err) {
|
|
|
|
- this.log(err);
|
|
|
|
- this.ajaxErrorBody(err, '获取标段列表错误');
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 新增标段(Ajax)
|
|
* 新增标段(Ajax)
|
|
*
|
|
*
|
|
@@ -1092,6 +1033,101 @@ module.exports = app => {
|
|
ctx.body = this.ajaxErrorBody(err, '书签数据错误');
|
|
ctx.body = this.ajaxErrorBody(err, '书签数据错误');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ async listLoad(ctx) {
|
|
|
|
+ try {
|
|
|
|
+ const data = JSON.parse(ctx.request.body.data);
|
|
|
|
+ if (!data.tid || !data.lid || !data.type) throw '数据错误';
|
|
|
|
+ const responseData = {
|
|
|
|
+ err: 0,
|
|
|
|
+ msg: '',
|
|
|
|
+ data: { ledgerAuditConst: auditConst.ledger, stageAuditConst: auditConst.stage },
|
|
|
|
+ };
|
|
|
|
+ responseData.data.category = await this.ctx.service.category.getAllCategory(this.ctx.session.sessionProject.id);
|
|
|
|
+ // 获取用户权限
|
|
|
|
+ const accountInfo = await this.ctx.service.projectAccount.getDataById(this.ctx.session.sessionUser.accountId);
|
|
|
|
+ const userPermission = accountInfo !== undefined && accountInfo.permission !== '' ? JSON.parse(accountInfo.permission) : null;
|
|
|
|
+ const tenderList = await this.ctx.service.tender.getList('', userPermission);
|
|
|
|
+ for (const t of tenderList) {
|
|
|
|
+ if (t.ledger_status === auditConst.ledger.status.checked) {
|
|
|
|
+ t.lastStage = await this.ctx.service.stage.getLastestStage(t.id, false);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (data.type === 'ledger') {
|
|
|
|
+ responseData.data.tenders = tenderList.filter(x => {
|
|
|
|
+ return x.ledger_status === auditConst.ledger.status.checked;
|
|
|
|
+ });
|
|
|
|
+ const history = await this.ctx.service.sumLoadHistory.getLedgerHistory(data.tid, data.lid);
|
|
|
|
+ if (history) responseData.data.history = { tenders: history.tender, load_time: history.load_time, type: 'ledger' };
|
|
|
|
+ } else if (data.type === 'stage') {
|
|
|
|
+ responseData.data.tenders = tenderList.filter(x => {
|
|
|
|
+ return x.ledger_status === auditConst.ledger.status.checked && !!x.lastStage;
|
|
|
|
+ });
|
|
|
|
+ let history = await this.ctx.service.sumLoadHistory.getStageHistory(data.tid, data.lid);
|
|
|
|
+ if (history) {
|
|
|
|
+ responseData.data.history = { tenders: history.tender, load_time: history.load_time, type: 'stage' };
|
|
|
|
+ } else {
|
|
|
|
+ history = await this.ctx.service.sumLoadHistory.getReviseHistory(data.tid, data.lid);
|
|
|
|
+ if (history) {
|
|
|
|
+ responseData.data.history = { tenders: history.tender, load_time: history.load_time, type: 'revise' };
|
|
|
|
+ } else {
|
|
|
|
+ history = await this.ctx.service.sumLoadHistory.getLedgerHistory(data.tid, data.lid);
|
|
|
|
+ if (history) responseData.data.history = { tenders: history.tender, load_time: history.load_time, type: 'ledger' };
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (data.type === 'revise') {
|
|
|
|
+ responseData.data.tenders = tenderList.filter(x => {
|
|
|
|
+ return x.ledger_status === auditConst.ledger.status.checked;
|
|
|
|
+ });
|
|
|
|
+ let history = await this.ctx.service.sumLoadHistory.getReviseHistory(data.tid, data.lid);
|
|
|
|
+ if (history) {
|
|
|
|
+ responseData.data.history = { tenders: history.tender, load_time: history.load_time, type: 'revise' };
|
|
|
|
+ } else {
|
|
|
|
+ history = await this.ctx.service.sumLoadHistory.getLedgerHistory(data.tid, data.lid);
|
|
|
|
+ if (history) responseData.data.history = { tenders: history.tender, load_time: history.load_time, type: 'ledger' };
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ctx.body = responseData;
|
|
|
|
+ } catch(err) {
|
|
|
|
+ this.log(err);
|
|
|
|
+ this.ajaxErrorBody(err, '获取标段列表错误');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ async _sumLoadRevise() {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ async _sumLoadStage() {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ async sumLoad(ctx) {
|
|
|
|
+ try {
|
|
|
|
+ const data = JSON.parse(ctx.request.body.data);
|
|
|
|
+
|
|
|
|
+ if (!data.lid || !data.type || !data.tenders) throw '数据错误';
|
|
|
|
+
|
|
|
|
+ switch (data.type) {
|
|
|
|
+ case 'ledger':
|
|
|
|
+ const refreshData = await this.ctx.service.ledger.sumLoad(data.lid, data.tenders);
|
|
|
|
+ ctx.body = {err: 0, msg: '', data: refreshData};
|
|
|
|
+ break;
|
|
|
|
+ case 'revise':
|
|
|
|
+ ctx.body = await this._sumLoadRevise(data.tid, data.lid, data.tenders);
|
|
|
|
+ break;
|
|
|
|
+ case 'stage':
|
|
|
|
+ ctx.body = await this._sumLoadStage(data.tid, data.lid, data.tenders);
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ throw '数据错误';
|
|
|
|
+ }
|
|
|
|
+ } catch (err) {
|
|
|
|
+ console.log(err);
|
|
|
|
+ this.log(err);
|
|
|
|
+ this.ajaxErrorBody(err, '导入数据失败');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
return TenderController;
|
|
return TenderController;
|