Commit 9317fa44 authored by 任国军's avatar 任国军

report add categoryId & options categoryList add report_id

parent dbafe985
......@@ -153,9 +153,11 @@ class OptionService extends Service {
}
// 智能选课要判断是否有报告
let reportFilterIds = [];
let userReportList = [];
if (type === 3) {
const userReportList = await ctx.classModel.V5.CourseUserReport.findAll({ where: { user_uuid: ctx.userUuid, status: 1, is_deleted: 0 }, attributes: [ 'cat_id' ] });
userReportList = await ctx.classModel.V5.CourseUserReport.findAll({ where: { user_uuid: ctx.userUuid, status: 1, is_deleted: 0 }, attributes: [ 'id', 'cat_id' ], raw: true });
reportFilterIds = R.pluck('cat_id', userReportList);
userReportList = _.groupBy(userReportList, 'cat_id');
}
const results = [];
......@@ -170,7 +172,7 @@ class OptionService extends Service {
is_open: v.is_open,
url: v.url,
is_valid: filterIds.includes(v.id) ? 0 : 1,
is_have: reportFilterIds.includes(v.id) ? 1 : 0,
report_id: reportFilterIds.includes(v.id) ? (ctx.isEmpty(userReportList[v.id]) ? 0 : userReportList[v.id][0].id) : 0,
sort: v.sort,
});
}
......
......@@ -91,7 +91,7 @@ class ReportService extends Service {
ctx.failed('尚未生成报告');
}
const category = await ctx.classModel.V5.CourseV5Category.findOne({ where: { id: userReportInfo.cat_id }, attributes: [ 'name', 'url' ] });
const category = await ctx.classModel.V5.CourseV5Category.findOne({ where: { id: userReportInfo.cat_id }, attributes: [ 'id', 'name', 'url' ] });
const userBabyInfo = await ctx.classModel.V5.CourseV5UserBaby.findOne({ where: { user_uuid: userReportInfo.user_uuid, status: 1, is_deleted: 0 }, attributes: [ 'user_uuid', 'baby_sex', 'baby_name', 'baby_age' ] });
// 获取年龄对应的报告选项
const ageToReport = await ctx.classModel.V5.CourseV5AgeToReportColumnDetail.findAll({ where: { age_id: userBabyInfo.baby_age, status: 1, is_deleted: 0 } });
......@@ -138,7 +138,7 @@ class ReportService extends Service {
ctx.failed('尚未生成报告');
}
const category = await ctx.classModel.V5.CourseV5Category.findOne({ where: { id: userReportInfo.cat_id }, attributes: [ 'name', 'url' ] });
const category = await ctx.classModel.V5.CourseV5Category.findOne({ where: { id: userReportInfo.cat_id }, attributes: [ 'id', 'name', 'url' ] });
const userBabyInfo = await ctx.classModel.V5.CourseV5UserBaby.findOne({ where: { user_uuid: userReportInfo.user_uuid, status: 1, is_deleted: 0 }, attributes: [ 'user_uuid', 'baby_sex', 'baby_name', 'baby_age' ] });
// 获取年龄对应的报告选项
const ageToReport = await ctx.classModel.V5.CourseV5AgeToReportColumnDetail.findAll({ where: { age_id: userBabyInfo.baby_age, status: 1, is_deleted: 0 } });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment