fix(leave-detail): delete dialogMessageNotify selected.length === 0
This commit is contained in:
parent
5f4b5bbead
commit
4e9cf9fe1d
1 changed files with 54 additions and 61 deletions
|
|
@ -142,70 +142,63 @@ async function getData() {
|
|||
}
|
||||
|
||||
function onSubmit() {
|
||||
if (selected.value.length !== 0) {
|
||||
dialogConfirm($q, () => {
|
||||
const body = selected.value.map((items: any, index: any) => ({
|
||||
seq: index,
|
||||
prefix: items.prefix,
|
||||
firstName: items.firstName,
|
||||
lastName: items.lastName,
|
||||
positionName: items.position,
|
||||
positionSign: items.positionSign ?? items.posExecutiveName,
|
||||
profileId: items.id,
|
||||
keycloakId: items.keycloakId,
|
||||
positionLeaveName:
|
||||
items.posType == "บริหาร" || items.posType == "อำนวยการ"
|
||||
? items.posType + items.posLevel
|
||||
: items.posLevel,
|
||||
posExecutiveName: items.posExecutiveName,
|
||||
organizationName: [
|
||||
items.orgChild4,
|
||||
items.orgChild3,
|
||||
items.orgChild2,
|
||||
items.orgChild1,
|
||||
items.orgRoot,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" "),
|
||||
}));
|
||||
dialogConfirm($q, async () => {
|
||||
const body = selected.value.map((items: any, index: any) => ({
|
||||
seq: index,
|
||||
prefix: items.prefix,
|
||||
firstName: items.firstName,
|
||||
lastName: items.lastName,
|
||||
positionName: items.position,
|
||||
positionSign: items.positionSign ?? items.posExecutiveName,
|
||||
profileId: items.id,
|
||||
keycloakId: items.keycloakId,
|
||||
positionLeaveName:
|
||||
items.posType == "บริหาร" || items.posType == "อำนวยการ"
|
||||
? items.posType + items.posLevel
|
||||
: items.posLevel,
|
||||
posExecutiveName: items.posExecutiveName,
|
||||
organizationName: [
|
||||
items.orgChild4,
|
||||
items.orgChild3,
|
||||
items.orgChild2,
|
||||
items.orgChild1,
|
||||
items.orgRoot,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" "),
|
||||
}));
|
||||
|
||||
console.log(body);
|
||||
const hasCommander = selected.value.some((e) =>
|
||||
props.commandersList?.some((i: any) => i === e.id)
|
||||
);
|
||||
|
||||
const hasCommander = selected.value.some((e) =>
|
||||
props.commandersList?.some((i: any) => i === e.id)
|
||||
);
|
||||
if (hasCommander) {
|
||||
dialogMessageNotify($q, "ไม่สามารถเลือกได้ เนื่องจากเลือกรายชื่อซ้ำ");
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasCommander) {
|
||||
dialogMessageNotify($q, "ไม่สามารถเลือกได้ เนื่องจากเลือกรายชื่อซ้ำ");
|
||||
return;
|
||||
}
|
||||
|
||||
showLoader();
|
||||
http
|
||||
.post(
|
||||
config.API.addApproverByType(
|
||||
props.type?.toLocaleLowerCase() as string,
|
||||
// props.profileType?.toLocaleLowerCase() as string,
|
||||
"officer",
|
||||
pageId.value
|
||||
),
|
||||
body
|
||||
)
|
||||
.then(async () => {
|
||||
await props.fetchDetailLeave?.(pageId.value);
|
||||
closeDialog();
|
||||
success($q, "บันทึกสำเร็จ");
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
dialogMessageNotify($q, "กรุณาเลือกอย่างน้อย 1 คน");
|
||||
}
|
||||
showLoader();
|
||||
await http
|
||||
.post(
|
||||
config.API.addApproverByType(
|
||||
props.type?.toLocaleLowerCase() as string,
|
||||
"officer",
|
||||
pageId.value
|
||||
),
|
||||
body.length > 0 ? body : []
|
||||
)
|
||||
.then(async () => {
|
||||
await props.fetchDetailLeave?.(pageId.value);
|
||||
closeDialog();
|
||||
success($q, "บันทึกสำเร็จ");
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function closeDialog() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue