1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- 'use strict';
- /**
- *
- *
- * @author Mai
- * @date
- * @version
- */
- const RptMemBase = require('./base');
- const bindData = {};
- const Ledger = require('../ledger');
- class rptMemContract extends RptMemBase {
- constructor(ctx) {
- super(ctx, bindData);
- }
- async _getContractTree(condition) {
- const data = await this.ctx.service.contractTree.getAllDataByCondition({ where: condition });
- const contract_data = await this.ctx.service.contract.getAllDataByCondition({ where: condition });
- const tree = new Ledger.billsTree(this.ctx, {
- id: 'contract_id',
- pid: 'contract_pid',
- order: 'order',
- level: 'level',
- rootId: -1,
- calcFields: [ 'total_price', 'pay_price', 'debit_price', 'yf_price', 'sf_price'],
- calc: function (node, helper, decimal) {},
- });
- tree.loadDatas([...data, ...contract_data]);
- return tree.getDefaultDatas();
- }
- async _getContract(condition) {
- const data = await this.ctx.service.contract.getAllDataByCondition({ where: condition });
- return data;
- }
- async _getContractPay(condition) {
- const data = await this.ctx.service.contractPay.getAllDataByCondition({ where: condition, orders: [['cid', 'asc'], ['create_time', 'asc']] });
- return data;
- }
- async getSpContractTree(contract_type) {
- if (!this.ctx.subProject) return [];
- return await this._getContractTree({ spid: this.ctx.subProject.id, contract_type });
- }
- async getSpContract(contract_type) {
- if (!this.ctx.subProject) return [];
- return await this._getContract({ spid: this.ctx.subProject.id, contract_type });
- }
- async getSpContractPay(contract_type) {
- if (!this.ctx.subProject) return [];
- return await this._getContractPay({ spid: this.ctx.subProject.id, contract_type });
- }
- getCommonData(params, tableName, fields, customDefine, customSelect) {
- switch (tableName) {
- case 'sp_contract_tree_1':
- return this.getSpContractTree(1);
- case 'sp_contract_1':
- return this.getSpContract(1);
- case 'sp_contract_pay_1':
- return this.getSpContractPay(1);
- case 'sp_contract_tree_2':
- return this.getSpContractTree(2);
- case 'sp_contract_2':
- return this.getSpContract(2);
- case 'sp_contract_pay_2':
- return this.getSpContractPay(2);
- default:
- return [];
- }
- }
- }
- module.exports = rptMemContract;
|