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