jws-frontend/src/components/TabComponent.vue

108 lines
2.4 KiB
Vue
Raw Normal View History

2024-04-23 11:37:27 +07:00
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { CustomerBranchCreate } from 'stores/customer/types';
2024-04-23 11:37:27 +07:00
const customerBranch = defineModel<CustomerBranchCreate[]>('customerBranch', {
default: [],
});
const indexTab = defineModel<number>('indexTab');
2024-04-23 11:37:27 +07:00
const tab = ref<string>('');
const index = ref<number>(0);
2024-04-23 11:37:27 +07:00
function addData() {
index.value++;
customerBranch.value.push({
status: 'CREATED',
legalPersonNo: '',
taxNo: '',
name: '',
nameEN: '',
addressEN: '',
address: '',
zipCode: '',
email: '',
telephoneNo: '',
longitude: '',
latitude: '',
registerName: '',
registerDate: null,
authorizedCapital: '',
subDistrictId: '',
districtId: '',
provinceId: '',
2024-04-23 11:37:27 +07:00
});
}
2024-04-23 17:20:29 +07:00
async function close(index: number) {
if (customerBranch.value.length > 1) {
customerBranch.value.splice(index, 1);
2024-04-23 17:20:29 +07:00
}
// tab.value = await tabList.value[tabList.value.length - 1].name;
setTimeout(() => {
tab.value = `สาขาที่ ${customerBranch.value.length.toString()}`;
2024-04-23 17:20:29 +07:00
}, 10);
}
2024-04-23 11:37:27 +07:00
</script>
<template>
<div class="column">
<q-tabs
active-bg-color="white"
active-color="primary"
indicator-color="white"
2024-04-23 17:20:29 +07:00
active-class="active-tab"
2024-04-23 11:37:27 +07:00
v-model="tab"
align="left"
inline-label
2024-04-23 17:20:29 +07:00
class="text-grey"
style="width: 960px; background-color: var(--_body-bg)"
2024-04-23 11:37:27 +07:00
>
<q-tab icon="mdi-plus" @click="addData()" />
2024-04-23 11:37:27 +07:00
<q-tab
v-for="(v, index) in customerBranch"
:key="index"
:name="index"
:label="`${$t('customerBranchFormTab')} ${index + 1}`"
@click="indexTab = index"
2024-04-23 17:20:29 +07:00
no-caps
/>
<q-btn
round
flat
id="closeDialog"
icon="mdi-close"
padding="xs"
color="red"
:class="{ dark: $q.dark.isActive }"
@click="close(index)"
/>
2024-04-23 11:37:27 +07:00
</q-tabs>
</div>
<div class="column">
<q-tab-panels v-model="tab" class="rounded-borders">
<q-tab-panel
v-for="(v, index) in customerBranch"
:key="index"
:name="index"
>
2024-04-23 11:37:27 +07:00
<slot name="about"></slot>
<slot name="address"></slot>
<slot name="businessInformation"></slot>
<slot name="contactInformation"></slot>
<slot name="otherDocuments"></slot>
</q-tab-panel>
</q-tab-panels>
</div>
</template>
2024-04-23 17:20:29 +07:00
<style scoped>
.active-tab {
border: 1px solid #e0dcdc;
border-bottom: none;
}
</style>