Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 50s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 50s
* develop: fix sort probation
This commit is contained in:
commit
759c6d9733
2 changed files with 69 additions and 12 deletions
|
|
@ -147,11 +147,13 @@ export class PersonalController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("list")
|
@Get("list")
|
||||||
async ListPersonal(
|
async ListPersonal(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
@Query() status: string = "",
|
@Query() status: string = "",
|
||||||
@Query() keyword: string = "",
|
@Query() keyword: string = "",
|
||||||
@Query("page") page: number = 1,
|
@Query("page") page: number = 1,
|
||||||
@Query("pageSize") pageSize: number = 10,
|
@Query("pageSize") pageSize: number = 10,
|
||||||
@Request() request: RequestWithUser
|
@Query("sortBy") sortBy?: string,
|
||||||
|
@Query("descending") descending?: boolean
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
// await new permission().PermissionList(request, "SYS_PROBATION");
|
// await new permission().PermissionList(request, "SYS_PROBATION");
|
||||||
|
|
@ -215,7 +217,7 @@ export class PersonalController extends Controller {
|
||||||
|
|
||||||
const searchKeyword = await (keyword ? keyword.trim() : null);
|
const searchKeyword = await (keyword ? keyword.trim() : null);
|
||||||
|
|
||||||
const [lists, total] = await AppDataSource.getRepository(Personal)
|
let query = await AppDataSource.getRepository(Personal)
|
||||||
.createQueryBuilder("personal")
|
.createQueryBuilder("personal")
|
||||||
.andWhere(
|
.andWhere(
|
||||||
_data.root != undefined && _data.root != null
|
_data.root != undefined && _data.root != null
|
||||||
|
|
@ -303,10 +305,42 @@ export class PersonalController extends Controller {
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.orderBy("updatedAt", "DESC")
|
if (sortBy) {
|
||||||
.skip((page - 1) * pageSize)
|
if(sortBy === "position_line"){
|
||||||
.take(pageSize)
|
query = query.orderBy(
|
||||||
.getManyAndCount();
|
`personal.positionName`,
|
||||||
|
descending ? "DESC" : "ASC"
|
||||||
|
);
|
||||||
|
}else if(sortBy === "position_level"){
|
||||||
|
query = query.orderBy(
|
||||||
|
`personal.positionLevelName`,
|
||||||
|
descending ? "DESC" : "ASC"
|
||||||
|
);
|
||||||
|
}else if(sortBy === "position_type"){
|
||||||
|
query = query.orderBy(
|
||||||
|
`personal.positionTypeName`,
|
||||||
|
descending ? "DESC" : "ASC"
|
||||||
|
);
|
||||||
|
}else if(sortBy === "name"){
|
||||||
|
query = query
|
||||||
|
.orderBy(`personal.prefixName`,descending ? "DESC" : "ASC")
|
||||||
|
.addOrderBy(`personal.firstName`,descending ? "DESC" : "ASC")
|
||||||
|
.addOrderBy(`personal.lastName`,descending ? "DESC" : "ASC");
|
||||||
|
}else{
|
||||||
|
query = query.orderBy(
|
||||||
|
`personal.${sortBy}`,
|
||||||
|
descending ? "DESC" : "ASC"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
query = query.orderBy("updatedAt", "DESC")
|
||||||
|
}
|
||||||
|
|
||||||
|
const [lists, total] = await query
|
||||||
|
.skip((page - 1) * pageSize)
|
||||||
|
.take(pageSize)
|
||||||
|
.getManyAndCount();
|
||||||
|
|
||||||
|
|
||||||
if (!lists) {
|
if (!lists) {
|
||||||
throw new HttpError(
|
throw new HttpError(
|
||||||
|
|
|
||||||
|
|
@ -119,11 +119,13 @@ export class SurveyController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("/admin")
|
@Get("/admin")
|
||||||
async GetSurveyAdmin(
|
async GetSurveyAdmin(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
@Query() year: number = new Date().getFullYear(),
|
@Query() year: number = new Date().getFullYear(),
|
||||||
@Query() keyword: string = "",
|
@Query() keyword: string = "",
|
||||||
@Query("page") page: number = 1,
|
@Query("page") page: number = 1,
|
||||||
@Query("pageSize") pageSize: number = 10,
|
@Query("pageSize") pageSize: number = 10,
|
||||||
@Request() request: RequestWithUser
|
@Query("sortBy") sortBy?: string,
|
||||||
|
@Query("descending") descending?: boolean
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
const start = new Date("01-01-" + year);
|
const start = new Date("01-01-" + year);
|
||||||
|
|
@ -131,7 +133,7 @@ export class SurveyController extends Controller {
|
||||||
|
|
||||||
const searchKeyword = await (keyword ? keyword.trim() : null);
|
const searchKeyword = await (keyword ? keyword.trim() : null);
|
||||||
|
|
||||||
const [lists, total] = await AppDataSource.getRepository(Survey)
|
let query = await AppDataSource.getRepository(Survey)
|
||||||
.createQueryBuilder("survey")
|
.createQueryBuilder("survey")
|
||||||
.leftJoinAndSelect("survey.personal", "personal")
|
.leftJoinAndSelect("survey.personal", "personal")
|
||||||
.where(
|
.where(
|
||||||
|
|
@ -157,10 +159,31 @@ export class SurveyController extends Controller {
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.orderBy("survey.createdAt", "DESC")
|
|
||||||
.skip((page - 1) * pageSize)
|
if (sortBy) {
|
||||||
.take(pageSize)
|
if(sortBy === "fullname"){
|
||||||
.getManyAndCount();
|
query = query
|
||||||
|
.orderBy(`personal.prefixName`,descending ? "DESC" : "ASC")
|
||||||
|
.addOrderBy(`personal.firstName`,descending ? "DESC" : "ASC")
|
||||||
|
.addOrderBy(`personal.lastName`,descending ? "DESC" : "ASC");
|
||||||
|
}else if(sortBy === "position"){
|
||||||
|
query = query
|
||||||
|
.orderBy(`personal.positionName`,descending ? "DESC" : "ASC")
|
||||||
|
.addOrderBy(`personal.positionLevelName`,descending ? "DESC" : "ASC")
|
||||||
|
}else{
|
||||||
|
query = query.orderBy(
|
||||||
|
`survey.${sortBy}`,
|
||||||
|
descending ? "DESC" : "ASC"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
query = query.orderBy("survey.createdAt", "DESC")
|
||||||
|
}
|
||||||
|
|
||||||
|
const [lists, total] = await query
|
||||||
|
.skip((page - 1) * pageSize)
|
||||||
|
.take(pageSize)
|
||||||
|
.getManyAndCount();
|
||||||
|
|
||||||
const data = lists.map((item) => {
|
const data = lists.map((item) => {
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue