แก้ไข profile employee

This commit is contained in:
AnandaTon 2024-05-29 18:18:32 +07:00
parent 20703b6afb
commit fb4b4c16c6

View file

@ -315,20 +315,25 @@ export class ProfileEmployeeController extends Controller {
const _child4 = child4 ? `${child4.orgChild4Name}/` : "";
const Profile = {
CitizenId: profiles?.citizenId ?? null,
CitizenId:
profiles.citizenId != null ? Extension.ToThaiNumber(profiles.citizenId.toString()) : "",
Prefix: profiles?.prefix != null ? profiles.prefix : "",
FirstName: profiles?.firstName != null ? profiles.firstName : "",
LastName: profiles?.lastName != null ? profiles.lastName : "",
FullName: `${profiles?.prefix} ${profiles?.firstName} ${profiles?.lastName}`,
BirthDay: profiles?.birthDate ? new Date(profiles.birthDate).getDate().toString() : null,
BirthDay: profiles?.birthDate
? Extension.ToThaiNumber(new Date(profiles.birthDate).getDate().toString())
: null,
BirthDayText:
profiles.birthDate != null
? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate).toString())
: "",
BirthMonth: profiles?.birthDate
? new Date(profiles.birthDate).getMonth() + (1).toString()
? Extension.ToThaiNumber(new Date(profiles.birthDate).getMonth() + (1).toString())
: null, // Months are zero-based
BirthYear: profiles?.birthDate ? new Date(profiles.birthDate).getFullYear().toString() : null,
BirthYear: profiles?.birthDate
? Extension.ToThaiNumber(new Date(profiles.birthDate).getFullYear().toString())
: null,
BirthYearText:
profiles.birthDate != null
? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate).toString())
@ -339,24 +344,21 @@ export class ProfileEmployeeController extends Controller {
Province: "",
Telephone: profiles?.telephoneNumber ?? null,
CoupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null,
CouplePrefix:
profileFamilyCouple?.couplePrefix != null ? profileFamilyCouple.couplePrefix : "",
CouplePrefix: profileFamilyCouple?.couplePrefix ?? "",
CoupleFullName:
profileFamilyCouple?.couplePrefix ||
profileFamilyCouple?.coupleFirstName ||
profileFamilyCouple?.coupleLastNameOld
? `${profileFamilyCouple?.couplePrefix ?? ""} ${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastNameOld ?? ""}`.trim()
: null,
FatherPrefix:
profileFamilyFather?.fatherPrefix != null ? profileFamilyFather.fatherPrefix : "",
FatherPrefix: profileFamilyFather?.fatherPrefix ?? "",
FatherFullName:
profileFamilyFather?.fatherPrefix ||
profileFamilyFather?.fatherFirstName ||
profileFamilyFather?.fatherLastName
? `${profileFamilyFather?.fatherPrefix ?? ""} ${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim()
: null,
MotherPrefix:
profileFamilyMother?.motherPrefix != null ? profileFamilyMother.motherPrefix : "",
MotherPrefix: profileFamilyMother?.motherPrefix ?? "",
MotherFullName:
profileFamilyMother?.motherPrefix ||
profileFamilyMother?.motherFirstName ||
@ -367,9 +369,14 @@ export class ProfileEmployeeController extends Controller {
Division: "",
Institute: "",
StartDate: profiles?.dateStart,
AppointDate: profiles?.dateAppoint,
BirthDate: profiles?.birthDate ? Extension.ToThaiShortDate(profiles.birthDate) : null,
RetireDate: profiles?.dateRetireLaw,
AppointDate: profiles?.dateAppoint ?? "",
BirthDate: profiles?.birthDate
? Extension.ToThaiNumber(Extension.ToThaiShortDate(profiles.birthDate))
: null,
RetireDate:
profiles.dateRetireLaw != null
? Extension.ToThaiNumber(profiles.dateRetireLaw.toString())
: "",
// AvatarId: profiles?.avatar ?? null,
};
@ -388,12 +395,22 @@ export class ProfileEmployeeController extends Controller {
where: { profileEmployeeId: id },
});
const Training = trainings.map((item) => ({
institute: item.department ?? null,
start: Extension.ToThaiShortDate(item.startDate).toString() ?? null,
end: Extension.ToThaiShortDate(item.endDate).toString() ?? null,
level: "",
degree: "",
field: item.place ?? null,
Institute: item.department ?? "",
Start:
item.startDate == null
? ""
: Extension.ToThaiNumber(new Date(item.startDate).getFullYear().toString()),
End:
item.endDate == null
? ""
: Extension.ToThaiNumber(new Date(item.endDate).getFullYear().toString()),
Date:
item.startDate && item.endDate
? `${Extension.ToThaiNumber(new Date(item.startDate).getFullYear().toString())} - ${Extension.ToThaiNumber(new Date(item.endDate).getFullYear().toString())}`
: "",
Level: "",
Degree: item.name,
Field: "",
}));
const disciplines = await this.disciplineRepository.find({
@ -414,9 +431,13 @@ export class ProfileEmployeeController extends Controller {
Institute: item.institute ?? null,
Start: new Date(item.startDate).getFullYear().toString() ?? null,
End: new Date(item.endDate).getFullYear().toString() ?? null,
Date:
item.startDate && item.endDate
? `${Extension.ToThaiNumber(new Date(item.startDate).getFullYear().toString())} - ${Extension.ToThaiNumber(new Date(item.endDate).getFullYear().toString())}`
: "",
Level: item.educationLevel ?? null,
Degree: item.degree ?? null,
Field: item.field ?? null,
Degree: item.degree && item.field ? `${item.degree} ${item.field}` : "",
Field: item.field ?? "-",
}));
const salarys = await this.salaryRepository.find({
select: [
@ -444,7 +465,7 @@ export class ProfileEmployeeController extends Controller {
FullName: `${profiles?.prefix} ${profiles?.firstName} ${profiles?.lastName}`,
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
}));
return new HttpSuccess({ Profile, Cert, Training, Discipline, Education, Salary });
return new HttpSuccess({ Profile: [Profile], Cert, Training, Discipline, Education, Salary });
}
/**