|
@@ -15,6 +15,14 @@ const path = require('path');
|
|
|
module.exports = app => {
|
|
|
class SubProjController extends app.BaseController {
|
|
|
|
|
|
+ async _loadCount(projectList){
|
|
|
+ for (const p of projectList) {
|
|
|
+ p.tender_count = await this.ctx.service.tender.count({ spid: p.id });
|
|
|
+ p.contract_count = await this.ctx.service.contract.count({ spid: p.id });
|
|
|
+ p.file_count = await this.ctx.service.file.count({ spid: p.id, is_deleted: 0 });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 概算投资
|
|
|
*
|
|
@@ -29,11 +37,7 @@ module.exports = app => {
|
|
|
};
|
|
|
renderData.budgetStd = await ctx.service.budgetStd.getDataByProjectId(ctx.session.sessionProject.id);
|
|
|
renderData.projectList = await ctx.service.subProject.getSubProject(ctx.session.sessionProject.id, ctx.session.sessionUser.accountId, ctx.session.sessionUser.is_admin);
|
|
|
- for (const p of renderData.projectList) {
|
|
|
- p.tender_count = await ctx.service.tender.count({ spid: p.id });
|
|
|
- p.contract_count = await ctx.service.contract.count({ spid: p.id });
|
|
|
- p.file_count = await ctx.service.file.count({ spid: p.id, is_deleted: 0 });
|
|
|
- }
|
|
|
+ await this._loadCount(renderData.projectList);
|
|
|
renderData.tenderList = await ctx.service.tender.getManageTenderList(ctx.session.sessionProject.id);
|
|
|
const accountList = await ctx.service.projectAccount.getAllDataByCondition({
|
|
|
columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
|
|
@@ -62,6 +66,7 @@ module.exports = app => {
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
if (!data.name || data.name.length > 100) throw '文件夹名称有误';
|
|
|
const result = await ctx.service.subProject.addFolder(data);
|
|
|
+ await this._loadCount(result);
|
|
|
ctx.body = { err: 0, msg: '', data: result };
|
|
|
} catch (err) {
|
|
|
ctx.log(err);
|
|
@@ -74,6 +79,7 @@ module.exports = app => {
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
if (!data.name || data.name.length > 100) throw '项目名称有误';
|
|
|
const result = await ctx.service.subProject.addSubProject(data);
|
|
|
+ await this._loadCount(result);
|
|
|
ctx.body = { err: 0, msg: '', data: result };
|
|
|
} catch (err) {
|
|
|
ctx.log(err);
|
|
@@ -86,6 +92,7 @@ module.exports = app => {
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
if (!data.drag_id || !data.drop_id) throw '提交数据错误';
|
|
|
const result = await ctx.service.subProject.dragTo(data);
|
|
|
+ await this._loadCount(result);
|
|
|
ctx.body = { err: 0, msg: '', data: result };
|
|
|
} catch (err) {
|
|
|
ctx.log(err);
|
|
@@ -98,6 +105,7 @@ module.exports = app => {
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
if (!data.id || !data.type) throw '提交数据错误';
|
|
|
const result = await ctx.service.subProject.move(data);
|
|
|
+ await this._loadCount(result);
|
|
|
ctx.body = { err: 0, msg: '', data: result };
|
|
|
} catch (err) {
|
|
|
ctx.log(err);
|