หมายหน้าที่ความรับผิดชอบ

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-11-19 16:26:18 +07:00
parent 63a468d732
commit 1cedcf539f

View file

@ -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(
<q-separator />
<q-card-section style="max-height: 80vh" class="scroll">
<div class="row q-gutter-sm">
<q-btn
color="primary"
label="เลือกสิทธิ์ทั้งหมด"
@click="onSelectAll('in')"
/>
<q-btn
color="secondary"
label="สิทธิ์ออกทั้งหมด"
@click="onSelectAll('out')"
/>
</div>
<div
v-for="(item, index) in sysTypeOptions"
:key="index"
@ -175,7 +202,7 @@ watch(
<q-separator />
<q-card-actions align="right">
<q-btn
:disable="sysType.length === 0 || !isChangData"
:disable="!isChangData"
label="บันทึก"
color="secondary"
type="submit"