fix: แก้ function clos ลบ ตัวสุดท้าย เเต่ index ไม่เปลี่ยน
This commit is contained in:
parent
085f77bf5c
commit
710426280c
1 changed files with 23 additions and 22 deletions
|
|
@ -1,14 +1,12 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { CustomerBranchCreate } from 'stores/customer/types';
|
import { CustomerBranchCreate } from 'stores/customer/types';
|
||||||
|
|
||||||
const customerBranch = defineModel<CustomerBranchCreate[]>('customerBranch', {
|
const customerBranch = defineModel<CustomerBranchCreate[]>('customerBranch', {
|
||||||
default: [],
|
default: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
const indexTab = defineModel<number>('indexTab');
|
const tab = defineModel<number>('tabIndex', { required: true });
|
||||||
|
|
||||||
const tab = ref<string>('');
|
|
||||||
|
|
||||||
const index = ref<number>(0);
|
const index = ref<number>(0);
|
||||||
|
|
||||||
|
|
@ -34,16 +32,19 @@ function addData() {
|
||||||
districtId: '',
|
districtId: '',
|
||||||
provinceId: '',
|
provinceId: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tab.value = customerBranch.value.length - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function close(index: number) {
|
||||||
|
console.log(customerBranch.value.length, index);
|
||||||
|
if (customerBranch.value.length - 1 === index) {
|
||||||
|
tab.value = tab.value - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function close(index: number) {
|
|
||||||
if (customerBranch.value.length > 1) {
|
if (customerBranch.value.length > 1) {
|
||||||
customerBranch.value.splice(index, 1);
|
customerBranch.value.splice(index, 1);
|
||||||
}
|
}
|
||||||
// tab.value = await tabList.value[tabList.value.length - 1].name;
|
|
||||||
setTimeout(() => {
|
|
||||||
tab.value = `สาขาที่ ${customerBranch.value.length.toString()}`;
|
|
||||||
}, 10);
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -65,10 +66,9 @@ async function close(index: number) {
|
||||||
:key="index"
|
:key="index"
|
||||||
:name="index"
|
:name="index"
|
||||||
:label="`${$t('customerBranchFormTab')} ${index + 1}`"
|
:label="`${$t('customerBranchFormTab')} ${index + 1}`"
|
||||||
@click="indexTab = index"
|
@click="tab = index"
|
||||||
no-caps
|
no-caps
|
||||||
/>
|
>
|
||||||
|
|
||||||
<q-btn
|
<q-btn
|
||||||
round
|
round
|
||||||
flat
|
flat
|
||||||
|
|
@ -77,8 +77,9 @@ async function close(index: number) {
|
||||||
padding="xs"
|
padding="xs"
|
||||||
color="red"
|
color="red"
|
||||||
:class="{ dark: $q.dark.isActive }"
|
:class="{ dark: $q.dark.isActive }"
|
||||||
@click="close(index)"
|
@click.stop="close(index)"
|
||||||
/>
|
/>
|
||||||
|
</q-tab>
|
||||||
</q-tabs>
|
</q-tabs>
|
||||||
</div>
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue