fix ==> โครงสร้างอัตรากำลัง ไม่ส่ง ID ตอน คัดลองและเพิ่มตำแหน่ง
This commit is contained in:
parent
1ff82f0a88
commit
1ebfc83452
1 changed files with 9 additions and 4 deletions
|
|
@ -280,6 +280,8 @@ function onSubmit() {
|
|||
} else {
|
||||
//ถ้ามีแสดง dialog ยืนยัน
|
||||
dialogConfirm($q, async () => {
|
||||
const isAddOrCopy =
|
||||
props.actionType === "ADD" || props.actionType === "COPY";
|
||||
const positionsData = rows.value.map(
|
||||
(e: RowDetailPositions, index: number) => ({
|
||||
id: !e.isNew ? e.id : null, //id รายการตำแหน่ง
|
||||
|
|
@ -299,6 +301,11 @@ function onSubmit() {
|
|||
})
|
||||
);
|
||||
|
||||
// สร้างข้อมูลตำแหน่งใหม่ ถ้าเป็นการเพิ่มหรือคัดลอกไม่เอา ID
|
||||
const positionNew = isAddOrCopy
|
||||
? positionsData.map(({ id, ...rest }) => rest)
|
||||
: positionsData;
|
||||
|
||||
const body = {
|
||||
posMasterNoPrefix: formData.prefixNo, //*Prefix นำหน้าเลขที่ตำแหน่ง เป็น Optional (ไม่ใช่อักษรย่อของหน่วยงาน/ส่วนราชการ)
|
||||
posMasterNo: Number(formData.positionNo), //*เลขที่ตำแหน่ง เป็นตัวเลข
|
||||
|
|
@ -313,16 +320,14 @@ function onSubmit() {
|
|||
orgChild2Id: getOrgIdByLevel(2),
|
||||
orgChild3Id: getOrgIdByLevel(3),
|
||||
orgChild4Id: getOrgIdByLevel(4),
|
||||
positions: positionsData,
|
||||
positions: positionNew,
|
||||
};
|
||||
|
||||
showLoader();
|
||||
try {
|
||||
const isAddOrCopy =
|
||||
props.actionType === "ADD" || props.actionType === "COPY";
|
||||
|
||||
if (isAddOrCopy) {
|
||||
await http.post(config.API.orgPosMaster, body);
|
||||
|
||||
await Promise.all([
|
||||
props.fetchDataTable?.(
|
||||
reqMaster.value.id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue