|
@@ -233,10 +233,37 @@ module.exports = app => {
|
|
|
return surplus;
|
|
|
}
|
|
|
|
|
|
- async _getStageLedgerData(ctx) {
|
|
|
+ _getLedgerColumn(sjsRela) {
|
|
|
+ const tender = this.ctx.tender;
|
|
|
+ const ledgerColumn = [
|
|
|
+ 'id', 'tender_id', 'ledger_id', 'ledger_pid', 'level', 'order', 'full_path', 'is_leaf',
|
|
|
+ 'code', 'b_code', 'name', 'unit', 'unit_price',
|
|
|
+ 'quantity', 'total_price', 'memo', 'drawing_code'];
|
|
|
+ if (this.ctx.session.sessionProject.gxby) ledgerColumn.push('gxby_status', 'gxby_url', 'gxby_limit');
|
|
|
+ if (this.ctx.session.sessionProject.dagl) ledgerColumn.push('dagl_status', 'dagl_url', 'dagl_limit');
|
|
|
+ if (tender.data.measureType === measureType.gcl.value) ledgerColumn.push('deal_qty', 'deal_tp', 'sjcl_qty', 'sjcl_expr', 'sjcl_tp');
|
|
|
+ if (tender.info.display.ledger.dgnQty) ledgerColumn.push('dgn_qty1', 'dgn_qty2');
|
|
|
+ const posColumn = ['id', 'tid', 'lid', 'name', 'position', 'porder', 'quantity'];
|
|
|
+ if (tender.info.display.stage.realComplete) posColumn.push('real_qty');
|
|
|
+ if (this.ctx.session.sessionProject.gxby) posColumn.push('gxby_status', 'gxby_url', 'gxby_limit');
|
|
|
+ if (this.ctx.session.sessionProject.dagl) posColumn.push('dagl_status', 'dagl_url', 'dagl_limit');
|
|
|
+ if (tender.data.measureType === measureType.gcl.value) ledgerColumn.push('sjcl_qty', 'sjcl_expr');
|
|
|
+ for (const field of sjsRela.ledgerCol) {
|
|
|
+ if (field.show) {
|
|
|
+ ledgerColumn.push(field.field);
|
|
|
+ posColumn.push(field.field);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return [ledgerColumn, posColumn];
|
|
|
+ }
|
|
|
+
|
|
|
+ async _getStageLedgerData(ctx, ledgerColumn) {
|
|
|
+ // const ledgerData = ctx.stage.ledgerHis
|
|
|
+ // ? await ctx.helper.loadLedgerDataFromOss(ctx.stage.ledgerHis.bills_file)
|
|
|
+ // : await ctx.service.ledger.getAllDataByCondition({ where: { tender_id: ctx.tender.id } });
|
|
|
const ledgerData = ctx.stage.ledgerHis
|
|
|
? await ctx.helper.loadLedgerDataFromOss(ctx.stage.ledgerHis.bills_file)
|
|
|
- : await ctx.service.ledger.getData(ctx.tender.id);
|
|
|
+ : await ctx.service.ledger.getAllDataByCondition({ columns: ledgerColumn, where: { tender_id: ctx.tender.id } });
|
|
|
const dgnData = await ctx.service.stageBillsDgn.getDgnData(ctx.tender.id);
|
|
|
for (const d of dgnData) {
|
|
|
const l = ctx.app._.find(ledgerData, { id: d.id });
|
|
@@ -266,10 +293,11 @@ module.exports = app => {
|
|
|
]);
|
|
|
return ledgerData;
|
|
|
}
|
|
|
- async _getStagePosData(ctx) {
|
|
|
+ async _getStagePosData(ctx, posColumn) {
|
|
|
let curStageData,
|
|
|
preStageData;
|
|
|
- const posData = await ctx.service.pos.getPosDataWithAddStageOrder({ tid: ctx.tender.id });
|
|
|
+ // const posData = await ctx.service.pos.getAllDataByCondition({ where: { tid: ctx.tender.id } });
|
|
|
+ const posData = await ctx.service.pos.getAllDataByCondition({ columns: posColumn, where: { tid: ctx.tender.id } });
|
|
|
// 根据当前人,或指定对象查询数据
|
|
|
// console.time('cur');
|
|
|
if (ctx.stage.readOnly) {
|
|
@@ -313,21 +341,33 @@ module.exports = app => {
|
|
|
return await ctx.service.stageChange.getAuditorAllStageData(ctx.tender.id, ctx.stage.id, ctx.stage.curTimes, ctx.stage.curOrder);
|
|
|
}
|
|
|
return await ctx.service.stageChange.getLastestAllStageData(ctx.tender.id, ctx.stage.id);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
async getStageData(ctx) {
|
|
|
try {
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
const filter = data.filter.split(';');
|
|
|
- const responseData = { err: 0, msg: '', data: {} };
|
|
|
+ const responseData = { err: 0, msg: '', data: {}, hpack: [] };
|
|
|
+ const hpack = true;
|
|
|
+ const sjsRela = await this.ctx.service.project.getSjsRela(ctx.session.sessionProject.id);
|
|
|
+ const [ledgerColumn, posColumn] = this._getLedgerColumn(sjsRela);
|
|
|
for (const f of filter) {
|
|
|
switch (f) {
|
|
|
case 'ledger':
|
|
|
- responseData.data.ledgerData = await this._getStageLedgerData(ctx);
|
|
|
+ if (hpack) {
|
|
|
+ responseData.hpack.push('ledgerData');
|
|
|
+ responseData.data.ledgerData = this.ctx.helper.hpackArr(await this._getStageLedgerData(ctx, ledgerColumn));
|
|
|
+ } else {
|
|
|
+ responseData.data.ledgerData = await this._getStageLedgerData(ctx, ledgerColumn);
|
|
|
+ }
|
|
|
break;
|
|
|
case 'pos':
|
|
|
- responseData.data.posData = await this._getStagePosData(ctx);
|
|
|
+ if (hpack) {
|
|
|
+ responseData.hpack.push('posData');
|
|
|
+ responseData.data.posData = this.ctx.helper.hpackArr(await this._getStagePosData(ctx, posColumn));
|
|
|
+ } else {
|
|
|
+ responseData.data.posData = await this._getStagePosData(ctx, posColumn);
|
|
|
+ }
|
|
|
break;
|
|
|
case 'detail':
|
|
|
responseData.data.detailData = await this._getStageDetailData(ctx);
|