feat: สร้าง form ได้เรื่อยๆ
This commit is contained in:
parent
4b3d1b52ca
commit
dca19a73ab
1 changed files with 55 additions and 32 deletions
|
|
@ -1,32 +1,51 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue';
|
import { ref, onMounted } from 'vue';
|
||||||
|
import { CustomerBranchCreate } from 'stores/customer/types';
|
||||||
|
|
||||||
import AppBox from './app/AppBox.vue';
|
const customerBranch = defineModel<CustomerBranchCreate[]>('customerBranch', {
|
||||||
|
default: [],
|
||||||
|
});
|
||||||
|
|
||||||
|
const indexTab = defineModel<number>('indexTab');
|
||||||
|
|
||||||
const tab = ref<string>('');
|
const tab = ref<string>('');
|
||||||
|
|
||||||
const tabList = ref<{ name: string; label: string }[]>([]);
|
const index = ref<number>(0);
|
||||||
|
|
||||||
function test() {
|
function addData() {
|
||||||
tabList.value.push({
|
index.value++;
|
||||||
name: `สาขาที่ ${tabList.value.length + 1}`,
|
customerBranch.value.push({
|
||||||
label: `สาขาที่ ${tabList.value.length + 1}`,
|
status: 'CREATED',
|
||||||
|
legalPersonNo: '',
|
||||||
|
taxNo: '',
|
||||||
|
name: '',
|
||||||
|
nameEN: '',
|
||||||
|
addressEN: '',
|
||||||
|
address: '',
|
||||||
|
zipCode: '',
|
||||||
|
email: '',
|
||||||
|
telephoneNo: '',
|
||||||
|
longitude: '',
|
||||||
|
latitude: '',
|
||||||
|
registerName: '',
|
||||||
|
registerDate: null,
|
||||||
|
authorizedCapital: '',
|
||||||
|
subDistrictId: '',
|
||||||
|
districtId: '',
|
||||||
|
provinceId: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
tab.value = tabList.value[tabList.value.length - 1].name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function close(index: number) {
|
async function close(index: number) {
|
||||||
if (tabList.value.length > 1) {
|
if (customerBranch.value.length > 1) {
|
||||||
tabList.value.splice(index, 1);
|
customerBranch.value.splice(index, 1);
|
||||||
}
|
}
|
||||||
// tab.value = await tabList.value[tabList.value.length - 1].name;
|
// tab.value = await tabList.value[tabList.value.length - 1].name;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
tab.value = `สาขาที่ ${tabList.value.length.toString()}`;
|
tab.value = `สาขาที่ ${customerBranch.value.length.toString()}`;
|
||||||
}, 10);
|
}, 10);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<q-tabs
|
<q-tabs
|
||||||
|
|
@ -40,31 +59,35 @@ async function close(index: number) {
|
||||||
class="text-grey"
|
class="text-grey"
|
||||||
style="width: 960px; background-color: var(--_body-bg)"
|
style="width: 960px; background-color: var(--_body-bg)"
|
||||||
>
|
>
|
||||||
<q-tab icon="mdi-plus" @click="test()" />
|
<q-tab icon="mdi-plus" @click="addData()" />
|
||||||
<q-tab
|
<q-tab
|
||||||
v-for="(v, index) in tabList"
|
v-for="(v, index) in customerBranch"
|
||||||
:key="index - 4"
|
:key="index"
|
||||||
:name="v.name"
|
:name="index"
|
||||||
:label="`${$t('branchLabel')} ${index + 1}`"
|
:label="`${$t('customerBranchFormTab')} ${index + 1}`"
|
||||||
|
@click="indexTab = index"
|
||||||
no-caps
|
no-caps
|
||||||
>
|
/>
|
||||||
<q-btn
|
|
||||||
round
|
<q-btn
|
||||||
flat
|
round
|
||||||
id="closeDialog"
|
flat
|
||||||
icon="mdi-close"
|
id="closeDialog"
|
||||||
padding="xs"
|
icon="mdi-close"
|
||||||
color="red"
|
padding="xs"
|
||||||
:class="{ dark: $q.dark.isActive }"
|
color="red"
|
||||||
@click="close(index)"
|
:class="{ dark: $q.dark.isActive }"
|
||||||
/>
|
@click="close(index)"
|
||||||
</q-tab>
|
/>
|
||||||
</q-tabs>
|
</q-tabs>
|
||||||
</div>
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<q-tab-panels v-model="tab" class="rounded-borders">
|
<q-tab-panels v-model="tab" class="rounded-borders">
|
||||||
<q-tab-panel v-for="v in tabList" :key="v.name" :name="v.name">
|
<q-tab-panel
|
||||||
{{ tab }}
|
v-for="(v, index) in customerBranch"
|
||||||
|
:key="index"
|
||||||
|
:name="index"
|
||||||
|
>
|
||||||
<slot name="about"></slot>
|
<slot name="about"></slot>
|
||||||
<slot name="address"></slot>
|
<slot name="address"></slot>
|
||||||
<slot name="businessInformation"></slot>
|
<slot name="businessInformation"></slot>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue