แก้ เก็บ ข้อมูลเเต่อาเรย์ที่ 0 เป็น inUse

This commit is contained in:
setthawutttty 2025-02-17 10:15:51 +07:00
parent 5f2d8cd481
commit d6d0d535aa
2 changed files with 6 additions and 4 deletions

View file

@ -1556,7 +1556,7 @@ onMounted(async () => {
</q-card> </q-card>
</q-dialog> </q-dialog>
<DialogSortEducation v-model:modal="modalSort" :data-sort="dataSort" /> <DialogSortEducation v-model:modal="modalSort" :data-sort="dataSort" :fetch-data="fetchData"/>
</template> </template>
<style scoped> <style scoped>

View file

@ -35,6 +35,7 @@ const modal = defineModel<boolean>("modal", { required: true });
const props = defineProps({ const props = defineProps({
dataSort: Array as PropType<ResponseObject[]>, dataSort: Array as PropType<ResponseObject[]>,
fetchData: Function,
}); });
const profileId = ref<string>(route.params.id.toString()); //id profile const profileId = ref<string>(route.params.id.toString()); //id profile
@ -247,6 +248,7 @@ function onSubmit() {
.then(async () => { .then(async () => {
await success($q, "บันทึกข้อมูลสำเร็จ"); await success($q, "บันทึกข้อมูลสำเร็จ");
modal.value = false; modal.value = false;
props.fetchData?.(profileId.value);
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
@ -259,8 +261,9 @@ function onSubmit() {
watch(modal, async () => { watch(modal, async () => {
if (modal.value && props.dataSort) { if (modal.value && props.dataSort) {
rows.value = props.dataSort; const dataList = props.dataSort;
selected.value.push(rows.value[0]); rows.value = dataList;
selected.value = dataList.filter((item: any) => item.isUse == true);
} else { } else {
selected.value = []; selected.value = [];
rows.value = []; rows.value = [];
@ -276,7 +279,6 @@ watch(modal, async () => {
:close="() => (modal = false)" :close="() => (modal = false)"
/> />
<q-separator /> <q-separator />
<q-card-section style="max-height: 70vh" class="scroll"> <q-card-section style="max-height: 70vh" class="scroll">
<q-table <q-table
v-if="rows.length > 0" v-if="rows.length > 0"