|
@@ -9,8 +9,10 @@ import "dayjs/locale/zh-cn";
|
|
import weekOfYear from 'dayjs/plugin/weekOfYear';
|
|
import weekOfYear from 'dayjs/plugin/weekOfYear';
|
|
import {PrjFile} from "@core-models/PrjFile";
|
|
import {PrjFile} from "@core-models/PrjFile";
|
|
import {is_project_member} from "@src/utils/prj_premission_helper";
|
|
import {is_project_member} from "@src/utils/prj_premission_helper";
|
|
|
|
+
|
|
dayjs.locale("zh-cn");
|
|
dayjs.locale("zh-cn");
|
|
dayjs.extend(weekOfYear);
|
|
dayjs.extend(weekOfYear);
|
|
|
|
+
|
|
interface IData {
|
|
interface IData {
|
|
/**
|
|
/**
|
|
* 多个附件的object name数组
|
|
* 多个附件的object name数组
|
|
@@ -42,7 +44,7 @@ function existsGuard(json: IRequest, cached_data: ICachedData): Promise<void> {
|
|
if (!prj) return reject(Resp.gen_err(Resp.ResourceNotFound, '项目不存在'));
|
|
if (!prj) return reject(Resp.gen_err(Resp.ResourceNotFound, '项目不存在'));
|
|
// 检查用户是否是本项目的负责人或成员
|
|
// 检查用户是否是本项目的负责人或成员
|
|
if (!await is_project_member(cached_data.user_id, prj.id)) {
|
|
if (!await is_project_member(cached_data.user_id, prj.id)) {
|
|
- return reject(Resp.gen_err(Resp.Forbidden, '您不是项目成员,无法创建项目周报。'));
|
|
|
|
|
|
+ return reject(Resp.gen_err(Resp.Forbidden, '您不是本项目的项目成员,无法创建项目周报。'));
|
|
}
|
|
}
|
|
resolve();
|
|
resolve();
|
|
});
|
|
});
|
|
@@ -53,8 +55,17 @@ function add(json: IRequest, params: IMethodParams, cached_data: ICachedData): P
|
|
let t = await PrjInfo.sequelize!.transaction();
|
|
let t = await PrjInfo.sequelize!.transaction();
|
|
try {
|
|
try {
|
|
let data = <IData>json.data;
|
|
let data = <IData>json.data;
|
|
- let week = dayjs().week();
|
|
|
|
- let report = await PrjWeekReport.findOne({where: {prj_id: data.prj_id, week: week, reporter_id: cached_data.user_id}, transaction: t});
|
|
|
|
|
|
+ let date = dayjs();
|
|
|
|
+ let week = date.week();
|
|
|
|
+ let year = date.year();
|
|
|
|
+ let report = await PrjWeekReport.findOne({
|
|
|
|
+ where: {
|
|
|
|
+ prj_id: data.prj_id,
|
|
|
|
+ year: year,
|
|
|
|
+ week: week,
|
|
|
|
+ reporter_id: cached_data.user_id
|
|
|
|
+ }, transaction: t
|
|
|
|
+ });
|
|
if (report) throw Resp.gen_err(Resp.DataExists, '您的本周周报已创建,不可重复创建。');
|
|
if (report) throw Resp.gen_err(Resp.DataExists, '您的本周周报已创建,不可重复创建。');
|
|
let id = IdGen.id();
|
|
let id = IdGen.id();
|
|
let value: any = {
|
|
let value: any = {
|
|
@@ -66,7 +77,7 @@ function add(json: IRequest, params: IMethodParams, cached_data: ICachedData): P
|
|
created_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
|
created_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
|
reporter_id: cached_data.user_id,
|
|
reporter_id: cached_data.user_id,
|
|
year: dayjs().year(),
|
|
year: dayjs().year(),
|
|
- month: dayjs().month()+1,
|
|
|
|
|
|
+ month: dayjs().month() + 1,
|
|
week: week,
|
|
week: week,
|
|
begin_from: dayjs().day(1).format('YYYY-MM-DD'),
|
|
begin_from: dayjs().day(1).format('YYYY-MM-DD'),
|
|
end_to: dayjs().day(7).format('YYYY-MM-DD')
|
|
end_to: dayjs().day(7).format('YYYY-MM-DD')
|