|
@@ -214,6 +214,53 @@ module.exports = app => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ async user(ctx) {
|
|
|
|
+ try {
|
|
|
|
+ this.defaultCheck(ctx);
|
|
|
|
+ const accountList = await ctx.service.projectAccount.getAllDataByCondition({
|
|
|
|
+ columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile', 'company_id'],
|
|
|
|
+ where: { project_id: ctx.subProject.project_id },
|
|
|
|
+ });
|
|
|
|
+ const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
|
|
|
|
+ const accountGroup = unitList.map(item => {
|
|
|
|
+ const groupList = accountList.filter(item1 => item1.company === item.name);
|
|
|
|
+ return { groupName: item.name, groupList };
|
|
|
|
+ }).filter(x => { return x.groupList.length > 0; });
|
|
|
|
+
|
|
|
|
+ const filter = {
|
|
|
|
+ company: ctx.query.company || '',
|
|
|
|
+ keyword: ctx.query.keyword || '',
|
|
|
|
+ };
|
|
|
|
+ const total = await ctx.service.projectAccount.getSubProjectAccountCount(ctx.subProject, filter);
|
|
|
|
+ const subProjectAccountList = await ctx.service.projectAccount.getSubProjectAccountListWithPermission(ctx.subProject, filter);
|
|
|
|
+ const page = ctx.page;
|
|
|
|
+ const pageSize = ctx.pageSize;
|
|
|
|
+ // 过滤数据
|
|
|
|
+ ctx.service.projectAccount.searchFilter(ctx.request.query, projectId);
|
|
|
|
+ const pageInfo = {
|
|
|
|
+ page,
|
|
|
|
+ pageSizeSelect: 1,
|
|
|
|
+ pageSize,
|
|
|
|
+ total_num: total,
|
|
|
|
+ total: Math.ceil(total / pageSize),
|
|
|
|
+ queryData: JSON.stringify(ctx.urlInfo.query),
|
|
|
|
+ };
|
|
|
|
+ const renderData = {
|
|
|
|
+ pageInfo,
|
|
|
|
+ accountList,
|
|
|
|
+ accountGroup,
|
|
|
|
+ subProjectAccountList,
|
|
|
|
+ keyword: filter.keyword,
|
|
|
|
+ company: filter.company,
|
|
|
|
+ jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.setting.user),
|
|
|
|
+ };
|
|
|
|
+ await this.layout('sp_setting/user.ejs', renderData);
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.log(error);
|
|
|
|
+ ctx.redirect(`/sp/${ctx.subProject.id}/dashboard`);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
async logs(ctx) {
|
|
async logs(ctx) {
|
|
try {
|
|
try {
|
|
this.defaultCheck(ctx);
|
|
this.defaultCheck(ctx);
|
|
@@ -264,24 +311,24 @@ module.exports = app => {
|
|
const rule = ctx.service.subProject.rule('fun');
|
|
const rule = ctx.service.subProject.rule('fun');
|
|
ctx.validate(rule);
|
|
ctx.validate(rule);
|
|
|
|
|
|
- const result = await ctx.service.subProject.updateFunRela(ctx.subProject, ctx.request.body);
|
|
|
|
|
|
+ const result = await ctx.service.subProject.updateFunRela(ctx.subProject.id, ctx.request.body);
|
|
if (!result) throw '保存数据失败';
|
|
if (!result) throw '保存数据失败';
|
|
- this.ctx.session.sessionProject.page_show.openChangeProject = data.openChangeProject ? 1 : 0;
|
|
|
|
- this.ctx.session.sessionProject.page_show.openChangeApply = data.openChangeApply ? 1 : 0;
|
|
|
|
- this.ctx.session.sessionProject.page_show.openChangePlan = data.openChangePlan ? 1 : 0;
|
|
|
|
- this.ctx.session.sessionProject.page_show.openChangeWhiteList = data.openChangeWhiteList ? 1 : 0;
|
|
|
|
- this.ctx.session.sessionProject.page_show.openChangeState = data.openChangeState ? 1 : 0;
|
|
|
|
- this.ctx.session.sessionProject.page_show.openMaterialTax = data.openMaterialTax ? 1 : 0;
|
|
|
|
- this.ctx.session.sessionProject.page_show.openMaterialChecklist = data.openMaterialChecklist ? 1 : 0;
|
|
|
|
- this.ctx.session.sessionProject.page_show.openMaterialSelf = data.openMaterialSelf ? 1 : 0;
|
|
|
|
- this.ctx.session.sessionProject.page_show.openMaterialEditForAudit = data.openMaterialEditForAudit ? 1 : 0;
|
|
|
|
- this.ctx.session.sessionProject.page_show.openStageStart = data.openStageStart ? 1 : 0;
|
|
|
|
- const result2 = await ctx.service.subProject.updatePageshow(ctx.subProject);
|
|
|
|
|
|
+ this.ctx.subProject.page_show.openChangeProject = data.openChangeProject ? 1 : 0;
|
|
|
|
+ this.ctx.subProject.page_show.openChangeApply = data.openChangeApply ? 1 : 0;
|
|
|
|
+ this.ctx.subProject.page_show.openChangePlan = data.openChangePlan ? 1 : 0;
|
|
|
|
+ this.ctx.subProject.page_show.openChangeWhiteList = data.openChangeWhiteList ? 1 : 0;
|
|
|
|
+ this.ctx.subProject.page_show.openChangeState = data.openChangeState ? 1 : 0;
|
|
|
|
+ this.ctx.subProject.page_show.openMaterialTax = data.openMaterialTax ? 1 : 0;
|
|
|
|
+ this.ctx.subProject.page_show.openMaterialChecklist = data.openMaterialChecklist ? 1 : 0;
|
|
|
|
+ this.ctx.subProject.page_show.openMaterialSelf = data.openMaterialSelf ? 1 : 0;
|
|
|
|
+ this.ctx.subProject.page_show.openMaterialEditForAudit = data.openMaterialEditForAudit ? 1 : 0;
|
|
|
|
+ this.ctx.subProject.page_show.openStageStart = data.openStageStart ? 1 : 0;
|
|
|
|
+ const result2 = await ctx.service.subProject.updatePageshow(ctx.subProject.id);
|
|
if (!result2) throw '保存数据失败';
|
|
if (!result2) throw '保存数据失败';
|
|
if (data.addFunSet) {
|
|
if (data.addFunSet) {
|
|
const funSet = ctx.subProject.fun_set ? JSON.parse(ctx.subProject.fun_set) : {};
|
|
const funSet = ctx.subProject.fun_set ? JSON.parse(ctx.subProject.fun_set) : {};
|
|
ctx.helper._.defaultsDeep(data.addFunSet, funSet);
|
|
ctx.helper._.defaultsDeep(data.addFunSet, funSet);
|
|
- const result3 = await ctx.service.subProject.updateFunSet(ctx.subProject, data.addFunSet);
|
|
|
|
|
|
+ const result3 = await ctx.service.subProject.updateFunSet(ctx.subProject.id, data.addFunSet);
|
|
if (!result3) throw '保存数据失败';
|
|
if (!result3) throw '保存数据失败';
|
|
}
|
|
}
|
|
|
|
|