1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- 'use strict';
- /**
- * 变更申请
- *
- * @author Mai
- * @date
- * @version
- */
- const RptMemBase = require('./base');
- const bindData = {};
- class rptMemChange extends RptMemBase {
- constructor(ctx) {
- super(ctx, bindData);
- }
- async doCheckChangeApply(id) {
- if (this.ctx.change_apply) return;
- this.ctx.change_apply = await this.ctx.service.changeApply.getDataById(id);
- }
- async doCheckTender(tenderId) {
- if (this.ctx.tender) return;
- this.ctx.tender = { id: tenderId };
- this.ctx.tender.data = await this.ctx.service.tender.getTender(tenderId);
- this.ctx.tender.info = await this.ctx.service.tenderInfo.getTenderInfo(tenderId);
- }
- async doBeforeLoadReport(params) {
- await this.doCheckChangeApply(params.change_apply_id);
- await this.doCheckTender(this.ctx.change_apply.tid);
- }
- async _getChangeApplyBills() {
- const helper = this.ctx.helper;
- const decimal = this.ctx.tender.info.decimal;
- const apply = this.ctx.change_apply;
- const bills = await this.ctx.service.changeApplyList.getAllDataByCondition({ where: { caid: apply.id} });
- bills.forEach(x => {
- const a_decimal = apply.decimal ? JSON.parse(apply.decimal) : { tp: decimal.tp, up: decimal.up };
- x.o_tp = helper.mul(x.oamount, x.unit_price, a_decimal.tp);
- x.c_tp = helper.mul(x.camount, x.unit_price, a_decimal.tp);
- });
- bills.sort(function(a, b ) {
- return helper.compareCode(a.code, b.code);
- });
- return bills;
- }
- async _getChangeApplyAudit() {
- const changeAudit = await this.ctx.service.changeApplyAudit.getAllDataByCondition({ where: { caid: this.ctx.change_apply.id, times: this.ctx.change_apply.times }});
- return this.ctx.helper.filterLastestData(changeAudit, ['aid']);
- }
- getCommonData(params, tableName, fields, customDefine, customSelect) {
- switch (tableName) {
- case 'mem_change_apply':
- return [this.ctx.change_apply];
- case 'mem_change_apply_bills':
- return this._getChangeApplyBills();
- case 'mem_change_apply_audit':
- return this._getChangeApplyAudit();
- case 'mem_change_apply_att':
- return this.ctx.service.changeApplyAtt.getAllChangeApplyAtt(this.ctx.change_apply.tid, this.ctx.change_apply.id);
- case 'mem_project':
- return this.ctx.service.project.getDataByCondition({ id: this.ctx.session.sessionProject.id });
- case 'mem_tender':
- return [this.ctx.tender.data];
- case 'mem_tender_info':
- return [this.ctx.tender.info];
- default:
- return [];
- }
- }
- }
- module.exports = rptMemChange;
|