หมายหน้าที่ความรับผิดชอบ
This commit is contained in:
parent
63a468d732
commit
1cedcf539f
1 changed files with 53 additions and 26 deletions
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue