fix ข้อมูล

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-11-26 18:15:24 +07:00
parent 70bebf6e7e
commit 9ff4389045
4 changed files with 39 additions and 16 deletions

View file

@ -95,17 +95,19 @@ function onSubmit() {
});
}
function onSelectAll(type: string) {
const isPromiss = ref<boolean | null>(null);
function onSelectAll(val: boolean) {
isChangData.value = true;
switch (type) {
case "in":
switch (val) {
case true:
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":
case false:
sysType.value = [];
break;
}
@ -129,7 +131,16 @@ watch(
);
sysType.value = assignId;
console.log(sysTypeOptions.value.length);
console.log(sysType.value.length);
isChangData.value = false;
isPromiss.value =
sysType.value.length === 0
? false
: sysTypeOptions.value.length === sysType.value.length
? true
: null;
}
}
);
@ -144,7 +155,14 @@ watch(
<q-card-section style="max-height: 80vh" class="scroll">
<div class="row q-gutter-sm">
<q-btn
<q-checkbox
color="primary"
keep-color
v-model="isPromiss"
label="เลือกสิทธิ์ทั้งหมด"
@update:model-value="onSelectAll"
/>
<!-- <q-btn
color="primary"
label="เลือกสิทธิ์ทั้งหมด"
@click="onSelectAll('in')"
@ -153,7 +171,7 @@ watch(
color="secondary"
label="สิทธิ์ออกทั้งหมด"
@click="onSelectAll('out')"
/>
/> -->
</div>
<div
v-for="(item, index) in sysTypeOptions"
@ -185,7 +203,9 @@ watch(
dense
v-model="sysType"
:val="op.id"
@update:model-value="isChangData = true"
@update:model-value="
(isChangData = true), (isPromiss = null)
"
/>
</q-item-section>