feat: emit Customer เก็บใน form
This commit is contained in:
parent
75246296ae
commit
b7d4178d63
1 changed files with 15 additions and 6 deletions
|
|
@ -4,7 +4,7 @@ import AppBox from 'components/app/AppBox.vue';
|
|||
import BranchCardCustomer from 'components/03_customer-management/BranchCardCustomer.vue';
|
||||
import { onMounted } from 'vue';
|
||||
import useCustomerStore from 'src/stores/customer';
|
||||
import { CustomerBranch } from 'src/stores/customer/types';
|
||||
import { CustomerBranch, Customer } from 'src/stores/customer/types';
|
||||
|
||||
const userCustomer = useCustomerStore();
|
||||
const { fetchListById } = userCustomer;
|
||||
|
|
@ -13,8 +13,9 @@ const inputSearch = ref<string>('');
|
|||
|
||||
const branch = defineModel<CustomerBranch[]>('branch');
|
||||
const currentCustomerName = defineModel<string>('currentCustomerName');
|
||||
const currentCustomerUrlImage = defineModel<string>('currentCustomerUrlImage');
|
||||
const currentCustomerUrlImage = ref<string | null>();
|
||||
|
||||
const returnCustomer = ref<Customer & { branch: CustomerBranch[] }>();
|
||||
const prop = withDefaults(
|
||||
defineProps<{
|
||||
color?: 'purple' | 'green';
|
||||
|
|
@ -25,15 +26,20 @@ const prop = withDefaults(
|
|||
},
|
||||
);
|
||||
|
||||
defineEmits<{
|
||||
const emit = defineEmits<{
|
||||
(e: 'back'): void;
|
||||
(e: 'viewDetail'): void;
|
||||
(
|
||||
e: 'viewDetail',
|
||||
returnCustomer: Customer & { branch: CustomerBranch[] },
|
||||
): void;
|
||||
|
||||
(e: 'dialog'): void;
|
||||
}>();
|
||||
|
||||
onMounted(async () => {
|
||||
const result = await fetchListById(prop.customerId);
|
||||
if (result) {
|
||||
returnCustomer.value = result;
|
||||
currentCustomerName.value = result.customerName;
|
||||
currentCustomerUrlImage.value = result.imageUrl;
|
||||
branch.value = result.branch;
|
||||
|
|
@ -140,9 +146,12 @@ onMounted(async () => {
|
|||
</q-btn>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row q-pa-lg q-col-gutter-xl">
|
||||
<div class="row q-pa-lg q-col-gutter-xl" v-if="!!returnCustomer">
|
||||
<div v-for="(br, i) in branch" :key="i" class="col-4">
|
||||
<BranchCardCustomer :data="br" @view-detail="$emit('viewDetail')" />
|
||||
<BranchCardCustomer
|
||||
:data="br"
|
||||
@view-detail="emit('viewDetail', { ...returnCustomer, branch: [br] })"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</AppBox>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue