fix ==> โครงสร้างอัตรากำลัง ไม่ส่ง ID ตอน คัดลองและเพิ่มตำแหน่ง

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-08-25 12:11:16 +07:00
parent 1ff82f0a88
commit 1ebfc83452

View file

@ -280,6 +280,8 @@ function onSubmit() {
} else { } else {
// dialog // dialog
dialogConfirm($q, async () => { dialogConfirm($q, async () => {
const isAddOrCopy =
props.actionType === "ADD" || props.actionType === "COPY";
const positionsData = rows.value.map( const positionsData = rows.value.map(
(e: RowDetailPositions, index: number) => ({ (e: RowDetailPositions, index: number) => ({
id: !e.isNew ? e.id : null, //id 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 = { const body = {
posMasterNoPrefix: formData.prefixNo, //*Prefix Optional (/) posMasterNoPrefix: formData.prefixNo, //*Prefix Optional (/)
posMasterNo: Number(formData.positionNo), //* posMasterNo: Number(formData.positionNo), //*
@ -313,16 +320,14 @@ function onSubmit() {
orgChild2Id: getOrgIdByLevel(2), orgChild2Id: getOrgIdByLevel(2),
orgChild3Id: getOrgIdByLevel(3), orgChild3Id: getOrgIdByLevel(3),
orgChild4Id: getOrgIdByLevel(4), orgChild4Id: getOrgIdByLevel(4),
positions: positionsData, positions: positionNew,
}; };
showLoader(); showLoader();
try { try {
const isAddOrCopy =
props.actionType === "ADD" || props.actionType === "COPY";
if (isAddOrCopy) { if (isAddOrCopy) {
await http.post(config.API.orgPosMaster, body); await http.post(config.API.orgPosMaster, body);
await Promise.all([ await Promise.all([
props.fetchDataTable?.( props.fetchDataTable?.(
reqMaster.value.id, reqMaster.value.id,