Merge branch 'develop' of github.com:Frappet/bma-ehr-salary into develop
This commit is contained in:
commit
ab9bf7cc80
3 changed files with 9 additions and 22 deletions
|
|
@ -280,15 +280,12 @@ export class Salary extends Controller {
|
||||||
@Query("pageSize") pageSize: number = 10,
|
@Query("pageSize") pageSize: number = 10,
|
||||||
@Query("keyword") keyword?: string,
|
@Query("keyword") keyword?: string,
|
||||||
) {
|
) {
|
||||||
//ssss total ผิด
|
|
||||||
// try {
|
|
||||||
const [salary, total] = await this.salaryRepository.findAndCount({
|
const [salary, total] = await this.salaryRepository.findAndCount({
|
||||||
relations: ["posLevel_", "posType_"],
|
relations: ["posLevel_", "posType_"],
|
||||||
order: {
|
order: {
|
||||||
startDate: "DESC",
|
startDate: "DESC",
|
||||||
},
|
},
|
||||||
skip: (page - 1) * pageSize,
|
...(keyword ? {} : { skip: (page - 1) * pageSize, take: pageSize }),
|
||||||
take: pageSize,
|
|
||||||
});
|
});
|
||||||
if (keyword != undefined && keyword !== "") {
|
if (keyword != undefined && keyword !== "") {
|
||||||
const filteredSalary = salary.filter(
|
const filteredSalary = salary.filter(
|
||||||
|
|
@ -318,8 +315,8 @@ export class Salary extends Controller {
|
||||||
endDate: item.endDate,
|
endDate: item.endDate,
|
||||||
details: item.details,
|
details: item.details,
|
||||||
}));
|
}));
|
||||||
|
const slicedData = formattedData.slice((page - 1) * pageSize, page * pageSize);
|
||||||
return new HttpSuccess({ data: formattedData, total: formattedData.length });
|
return new HttpSuccess({ data: slicedData, total: formattedData.length });
|
||||||
}
|
}
|
||||||
|
|
||||||
const formattedData = salary.map((item) => ({
|
const formattedData = salary.map((item) => ({
|
||||||
|
|
@ -337,9 +334,7 @@ export class Salary extends Controller {
|
||||||
details: item.details,
|
details: item.details,
|
||||||
}));
|
}));
|
||||||
return new HttpSuccess({ data: formattedData, total });
|
return new HttpSuccess({ data: formattedData, total });
|
||||||
// } catch (error: any) {
|
|
||||||
// throw new Error(error);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,7 @@ export class SalaryPeriodController extends Controller {
|
||||||
@Body() requestBody: CreateSalaryPeriod,
|
@Body() requestBody: CreateSalaryPeriod,
|
||||||
@Request() request: { user: Record<string, any> },
|
@Request() request: { user: Record<string, any> },
|
||||||
) {
|
) {
|
||||||
//ssss ไม่ต้องเช็ค?
|
|
||||||
const salaryPeriod = Object.assign(new SalaryPeriod(), requestBody);
|
const salaryPeriod = Object.assign(new SalaryPeriod(), requestBody);
|
||||||
if (!salaryPeriod) {
|
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
||||||
}
|
|
||||||
|
|
||||||
const chk_toUpper = ["SPECIAL", "APR", "OCT"];
|
const chk_toUpper = ["SPECIAL", "APR", "OCT"];
|
||||||
if (!chk_toUpper.includes(salaryPeriod.period.toUpperCase())) {
|
if (!chk_toUpper.includes(salaryPeriod.period.toUpperCase())) {
|
||||||
|
|
|
||||||
|
|
@ -156,8 +156,7 @@ export class SalaryRanksController extends Controller {
|
||||||
@Query("pageSize") pageSize: number = 10,
|
@Query("pageSize") pageSize: number = 10,
|
||||||
@Query("keyword") keyword?: string,
|
@Query("keyword") keyword?: string,
|
||||||
) {
|
) {
|
||||||
//ssss total ผิด
|
|
||||||
// try {
|
|
||||||
const [salaryRank, total] = await this.salaryRankRepository.findAndCount({
|
const [salaryRank, total] = await this.salaryRankRepository.findAndCount({
|
||||||
where: {
|
where: {
|
||||||
salaryId: id,
|
salaryId: id,
|
||||||
|
|
@ -177,8 +176,7 @@ export class SalaryRanksController extends Controller {
|
||||||
salary: "DESC",
|
salary: "DESC",
|
||||||
salaryHalf: "DESC",
|
salaryHalf: "DESC",
|
||||||
},
|
},
|
||||||
skip: (page - 1) * pageSize,
|
...(keyword ? {} : { skip: (page - 1) * pageSize, take: pageSize }),
|
||||||
take: pageSize,
|
|
||||||
});
|
});
|
||||||
if (keyword != undefined && keyword !== "") {
|
if (keyword != undefined && keyword !== "") {
|
||||||
const filteredSalaryRank = salaryRank.filter(
|
const filteredSalaryRank = salaryRank.filter(
|
||||||
|
|
@ -191,12 +189,10 @@ export class SalaryRanksController extends Controller {
|
||||||
x.salaryFullHalf?.toString().includes(keyword) ||
|
x.salaryFullHalf?.toString().includes(keyword) ||
|
||||||
x.salaryFullHalfSpecial?.toString().includes(keyword),
|
x.salaryFullHalfSpecial?.toString().includes(keyword),
|
||||||
);
|
);
|
||||||
return new HttpSuccess({ data: filteredSalaryRank, total: filteredSalaryRank.length });
|
const slicedData = filteredSalaryRank.slice((page - 1) * pageSize, page * pageSize);
|
||||||
|
return new HttpSuccess({ data: slicedData, total: filteredSalaryRank.length });
|
||||||
}
|
}
|
||||||
|
|
||||||
return new HttpSuccess({ data: salaryRank, total });
|
return new HttpSuccess({ data: salaryRank, total });
|
||||||
// } catch (error: any) {
|
|
||||||
// throw new Error(error);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue