ปรับ template #898
This commit is contained in:
parent
325c45592d
commit
e943b3037c
1 changed files with 207 additions and 43 deletions
|
|
@ -1320,8 +1320,9 @@ export class CommandController extends Controller {
|
|||
: command.isBangkok == "BANGKOK"
|
||||
? "กรุงเทพมหานคร"
|
||||
: null;
|
||||
let orgRevisionActive: any;
|
||||
if (issue == null) {
|
||||
const orgRevisionActive = await this.orgRevisionRepository.findOne({
|
||||
orgRevisionActive = await this.orgRevisionRepository.findOne({
|
||||
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||
relations: ["posMasters", "posMasters.orgRoot"],
|
||||
});
|
||||
|
|
@ -1333,7 +1334,7 @@ export class CommandController extends Controller {
|
|||
});
|
||||
if (profile != null) {
|
||||
issue =
|
||||
orgRevisionActive?.posMasters?.filter((x) => x.current_holderId == profile.id)[0]
|
||||
orgRevisionActive?.posMasters?.filter((x:any) => x.current_holderId == profile.id)[0]
|
||||
?.orgRoot?.orgRootName || null;
|
||||
}
|
||||
}
|
||||
|
|
@ -1350,47 +1351,210 @@ export class CommandController extends Controller {
|
|||
.catch((x) => {});
|
||||
}
|
||||
|
||||
let _command = {
|
||||
issue: issue,
|
||||
commandNo: command.commandNo == null ? "" : Extension.ToThaiNumber(command.commandNo),
|
||||
commandYear:
|
||||
command.commandYear == null
|
||||
? ""
|
||||
: Extension.ToThaiNumber(Extension.ToThaiYear(command.commandYear).toString()),
|
||||
commandTitle: command.issue,
|
||||
detailHeader: command.detailHeader,
|
||||
detailBody: command.detailBody,
|
||||
detailFooter: command.detailFooter,
|
||||
commandDate:
|
||||
command.commandAffectDate == null
|
||||
? ""
|
||||
: Extension.ToThaiNumber(Extension.ToThaiFullDate2(command.commandAffectDate)),
|
||||
commandExcecuteDate:
|
||||
command.commandExcecuteDate == null
|
||||
? ""
|
||||
: Extension.ToThaiNumber(Extension.ToThaiFullDate2(command.commandExcecuteDate)),
|
||||
name: "...................................",
|
||||
position: "...................................",
|
||||
authorizedUserFullName: "...................................",
|
||||
authorizedPosition: "...................................",
|
||||
commandAffectDate: "...................................",
|
||||
name1:
|
||||
res && res.length > 0
|
||||
? `๑. ${res[0].name}.........${res[0].role}`
|
||||
: "๑. ..........................ประธาน",
|
||||
name2:
|
||||
res && res.length > 1
|
||||
? `๒. ${res[1].name}.........${res[1].role}`
|
||||
: "๒. ..........................กรรมการ",
|
||||
name3:
|
||||
res && res.length > 2
|
||||
? `๓. ${res[2].name}.........${res[2].role}`
|
||||
: "๓. ..........................กรรมการ",
|
||||
name4:
|
||||
res && res.length > 3
|
||||
? `๔. ${res[3].name}.........${res[3].role}`
|
||||
: "๔. ..........................กรรมการ",
|
||||
};
|
||||
let _command;
|
||||
let commandCode = command && command.commandType ? command.commandType.code : "";
|
||||
if (!["C-PM-21", "C-PM-23"].includes(commandCode)) {
|
||||
_command = {
|
||||
issue: issue,
|
||||
commandNo: command.commandNo == null ? "" : Extension.ToThaiNumber(command.commandNo),
|
||||
commandYear:
|
||||
command.commandYear == null
|
||||
? ""
|
||||
: Extension.ToThaiNumber(Extension.ToThaiYear(command.commandYear).toString()),
|
||||
commandTitle: command.issue,
|
||||
detailHeader: command.detailHeader,
|
||||
detailBody: command.detailBody,
|
||||
detailFooter: command.detailFooter,
|
||||
commandDate:
|
||||
command.commandAffectDate == null
|
||||
? ""
|
||||
: Extension.ToThaiNumber(Extension.ToThaiFullDate2(command.commandAffectDate)),
|
||||
commandExcecuteDate:
|
||||
command.commandExcecuteDate == null
|
||||
? ""
|
||||
: Extension.ToThaiNumber(Extension.ToThaiFullDate2(command.commandExcecuteDate)),
|
||||
name: "...................................",
|
||||
position: "...................................",
|
||||
authorizedUserFullName: "...................................",
|
||||
authorizedPosition: "...................................",
|
||||
commandAffectDate: "...................................",
|
||||
name1:
|
||||
res && res.length > 0
|
||||
? `๑. ${res[0].name}.........${res[0].role}`
|
||||
: "๑. ..........................ประธาน",
|
||||
name2:
|
||||
res && res.length > 1
|
||||
? `๒. ${res[1].name}.........${res[1].role}`
|
||||
: "๒. ..........................กรรมการ",
|
||||
name3:
|
||||
res && res.length > 2
|
||||
? `๓. ${res[2].name}.........${res[2].role}`
|
||||
: "๓. ..........................กรรมการ",
|
||||
name4:
|
||||
res && res.length > 3
|
||||
? `๔. ${res[3].name}.........${res[3].role}`
|
||||
: "๔. ..........................กรรมการ",
|
||||
};
|
||||
} else {
|
||||
let _persons: any;
|
||||
_persons = await Promise.all(
|
||||
command.commandRecives.map(async(x, idx) => {
|
||||
const profile = await this.profileEmployeeRepository.findOne({
|
||||
where: {
|
||||
id: x.profileId,
|
||||
},
|
||||
relations: [
|
||||
"posLevel",
|
||||
"posType",
|
||||
"current_holders",
|
||||
"current_holders.orgRevision",
|
||||
"current_holders.orgRoot",
|
||||
"current_holders.orgChild1",
|
||||
"current_holders.orgChild2",
|
||||
"current_holders.orgChild3",
|
||||
"current_holders.orgChild4",
|
||||
],
|
||||
});
|
||||
const shortName =
|
||||
profile?.current_holders.length == 0
|
||||
? null
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) != null &&
|
||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild4 !=
|
||||
null
|
||||
? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild4.orgChild4ShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}`
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) != null &&
|
||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgChild3 != null
|
||||
? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild3.orgChild3ShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}`
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) != null &&
|
||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgChild2 != null
|
||||
? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild2.orgChild2ShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}`
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) !=
|
||||
null &&
|
||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgChild1 != null
|
||||
? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild1.orgChild1ShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}`
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) !=
|
||||
null &&
|
||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgRoot != null
|
||||
? `${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot.orgRootShortName}${profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.posMasterNo}`
|
||||
: null;
|
||||
|
||||
const root =
|
||||
profile?.current_holders == null ||
|
||||
profile?.current_holders.length == 0 ||
|
||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
|
||||
? null
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgRoot;
|
||||
|
||||
const child1 =
|
||||
profile?.current_holders == null ||
|
||||
profile?.current_holders.length == 0 ||
|
||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
|
||||
? null
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild1;
|
||||
|
||||
const child2 =
|
||||
profile?.current_holders == null ||
|
||||
profile?.current_holders.length == 0 ||
|
||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
|
||||
? null
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild2;
|
||||
|
||||
const child3 =
|
||||
profile?.current_holders == null ||
|
||||
profile?.current_holders.length == 0 ||
|
||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
|
||||
? null
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild3;
|
||||
|
||||
const child4 =
|
||||
profile?.current_holders == null ||
|
||||
profile?.current_holders.length == 0 ||
|
||||
profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) == null
|
||||
? null
|
||||
: profile?.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild4;
|
||||
|
||||
let _child1 = child1 == null ? "" : `${child1.orgChild1Name}/`;
|
||||
let _child2 = child2 == null ? "" : `${child2.orgChild2Name}/`;
|
||||
let _child3 = child3 == null ? "" : `${child3.orgChild3Name}/`;
|
||||
let _child4 = child4 == null ? "" : `${child4.orgChild4Name}/`;
|
||||
let _root = root == null ? "" : `${root.orgRootName}`;
|
||||
|
||||
return {
|
||||
no: Extension.ToThaiNumber((idx+1).toString()),
|
||||
org: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
||||
fullName: `${x.prefix}${x.firstName} ${x.lastName}`,
|
||||
citizenId: Extension.ToThaiNumber(x.citizenId),
|
||||
position: profile?.position
|
||||
? profile?.position
|
||||
: "-",
|
||||
posLevel: profile?.posType && profile?.posLevel
|
||||
? Extension.ToThaiNumber(`${profile?.posType.posTypeShortName} ${profile?.posLevel.posLevelName}`)
|
||||
: "-",
|
||||
posNo: shortName
|
||||
? Extension.ToThaiNumber(shortName)
|
||||
: "-",
|
||||
amount: x.amount
|
||||
? Extension.ToThaiNumber(x.amount.toString())
|
||||
: "-",
|
||||
dateRetire: profile?.dateRetire
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile?.dateRetire))
|
||||
: "-",
|
||||
dateExecute: command.commandExcecuteDate
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(command.commandExcecuteDate))
|
||||
: "-",
|
||||
remark: x.remarkVertical
|
||||
? x.remarkVertical
|
||||
: "-"
|
||||
}
|
||||
})
|
||||
);
|
||||
_command = {
|
||||
issue: issue,
|
||||
commandNo: command.commandNo == null ? "" : Extension.ToThaiNumber(command.commandNo),
|
||||
commandYear:
|
||||
command.commandYear == null
|
||||
? ""
|
||||
: Extension.ToThaiNumber(Extension.ToThaiYear(command.commandYear).toString()),
|
||||
commandTitle: command.issue,
|
||||
detailHeader: command.detailHeader,
|
||||
detailBody: command.detailBody,
|
||||
detailFooter: command.detailFooter,
|
||||
commandDate:
|
||||
command.commandAffectDate == null
|
||||
? ""
|
||||
: Extension.ToThaiNumber(Extension.ToThaiFullDate2(command.commandAffectDate)),
|
||||
commandExcecuteDate:
|
||||
command.commandExcecuteDate == null
|
||||
? ""
|
||||
: Extension.ToThaiNumber(Extension.ToThaiFullDate2(command.commandExcecuteDate)),
|
||||
name: "...................................",
|
||||
position: "...................................",
|
||||
authorizedUserFullName: "...................................",
|
||||
authorizedPosition: "...................................",
|
||||
commandAffectDate: "...................................",
|
||||
name1:
|
||||
res && res.length > 0
|
||||
? `๑. ${res[0].name}.........${res[0].role}`
|
||||
: "๑. ..........................ประธาน",
|
||||
name2:
|
||||
res && res.length > 1
|
||||
? `๒. ${res[1].name}.........${res[1].role}`
|
||||
: "๒. ..........................กรรมการ",
|
||||
name3:
|
||||
res && res.length > 2
|
||||
? `๓. ${res[2].name}.........${res[2].role}`
|
||||
: "๓. ..........................กรรมการ",
|
||||
name4:
|
||||
res && res.length > 3
|
||||
? `๔. ${res[3].name}.........${res[3].role}`
|
||||
: "๔. ..........................กรรมการ",
|
||||
persons: _persons
|
||||
};
|
||||
}
|
||||
|
||||
return new HttpSuccess({
|
||||
template: command.commandType.fileCover,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue