|
@@ -1471,9 +1471,11 @@ module.exports = app => {
|
|
|
let result = [];
|
|
|
if (!PermissionCheck.viewPmData(this.ctx.session.sessionUser.permission)) return result;
|
|
|
|
|
|
- const selects = await this.ctx.service.project.getPmDealCache(this.ctx.session.sessionProject.id);
|
|
|
- const pm = require('../lib/pm');
|
|
|
- this.pmDeal = await pm.dealData(this.ctx, this.ctx.session.sessionProject.code, selects);
|
|
|
+ if (!this.pmDeal) {
|
|
|
+ const selects = await this.ctx.service.project.getPmDealCache(this.ctx.session.sessionProject.id);
|
|
|
+ const pm = require('../lib/pm');
|
|
|
+ this.pmDeal = await pm.dealData(this.ctx, this.ctx.session.sessionProject.code, selects);
|
|
|
+ }
|
|
|
|
|
|
result = this.pmDeal.contracts ? this.pmDeal.contracts.filter(x => { return x.ContractsType === 2 }) : [];
|
|
|
const fields = ['Code', 'Name', 'ContractName', 'ContractCode', 'ContractPrice', 'ContractReturned', 'ContractsPaid', 'ContractStatus', 'ContractLocking', 'CreateTime'], self = this;
|
|
@@ -1496,6 +1498,36 @@ module.exports = app => {
|
|
|
});
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ async getPmDealTree() {
|
|
|
+ const result = [];
|
|
|
+ if (!PermissionCheck.viewPmData(this.ctx.session.sessionUser.permission)) return result;
|
|
|
+
|
|
|
+ if (!this.pmDeal) {
|
|
|
+ const selects = await this.ctx.service.project.getPmDealCache(this.ctx.session.sessionProject.id);
|
|
|
+ const pm = require('../lib/pm');
|
|
|
+ this.pmDeal = await pm.dealData(this.ctx, this.ctx.session.sessionProject.code, selects);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (const tc of this.pmDeal.tree_contracts) {
|
|
|
+ tc.children = this.pmDeal.tree_contracts.filter(x => { return x.ParentId === tc.TreeId})
|
|
|
+ }
|
|
|
+ const root = this.pmDeal.tree_contracts.filter(x => { return x.Depth === 0});
|
|
|
+ root.sort((x, y) => {
|
|
|
+ const type = x.TreeType - y.TreeType;
|
|
|
+ return type ? type : x.Serail - y.Serail;
|
|
|
+ });
|
|
|
+ const sortChildren = function (children, data) {
|
|
|
+ if (!children || children.length === 0) return;
|
|
|
+ for (const c of children) {
|
|
|
+ data.push(c);
|
|
|
+ sortChildren(c.children, data);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ sortChildren(root, result);
|
|
|
+ result.forEach(x => { delete x.children });
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return ReportMemory;
|