diff --git a/src/modules/02_users/components/05_responsIbilities/DialogResponsibilities.vue b/src/modules/02_users/components/05_responsIbilities/DialogResponsibilities.vue index 6cc3035e..48c8b683 100644 --- a/src/modules/02_users/components/05_responsIbilities/DialogResponsibilities.vue +++ b/src/modules/02_users/components/05_responsIbilities/DialogResponsibilities.vue @@ -69,31 +69,45 @@ function closeDialog() { /** ฟังก์ชันยืนยันการบันทึกข้อมูลกำหนดหน้าที่ความรับผิดชอบ*/ function onSubmit() { - if (sysType.value.length !== 0) { - dialogConfirm($q, async () => { - const body = { - posMasterId: posMasterId.value, - assignIds: sysType.value, - }; - showLoader(); - await http - .post(config.API.posAssign, body) - .then(async () => { - await props.fetchDataTable( - props.reqMaster.id, - props.reqMaster.revisionId, - props.reqMaster.type - ); - success($q, "บันทึกข้อมูลสำเร็จ"); - closeDialog(); - }) - .catch((err) => { - messageError($q, err); - }) - .finally(() => { - hideLoader(); - }); - }); + dialogConfirm($q, async () => { + const body = { + posMasterId: posMasterId.value, + assignIds: sysType.value, + }; + showLoader(); + await http + .post(config.API.posAssign, body) + .then(async () => { + await props.fetchDataTable( + props.reqMaster.id, + props.reqMaster.revisionId, + props.reqMaster.type + ); + closeDialog(); + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); + }); +} + +function onSelectAll(type: string) { + isChangData.value = true; + switch (type) { + case "in": + const allAssginsIds = sysTypeOptions.value.reduce((acc, item) => { + const ids = item.assgins.map((assign) => assign.id); // ดึง id ใน assgins + return acc.concat(ids); // รวม id เข้ากับอาร์เรย์สะสม + }, [] as string[]); + sysType.value = allAssginsIds; + break; + case "out": + sysType.value = []; + break; } } @@ -113,6 +127,7 @@ watch( const assignId = props.dataPosMaster.posMasterAssigns.map( (r: PosMaster) => r.assignId ); + sysType.value = assignId; isChangData.value = false; } @@ -128,6 +143,18 @@ watch( +
+ + +