refactor: by value at viewHeader

This commit is contained in:
Thanaphon Frappet 2024-10-18 16:23:44 +07:00
parent d5dec2aa49
commit 8095c1c167
2 changed files with 87 additions and 30 deletions

View file

@ -15,7 +15,11 @@ import { commaInput } from 'stores/utils';
// NOTE Import Types
import { BankBook, Branch } from 'stores/branch/types';
import { QuotationPayload } from 'src/stores/quotations/types';
import {
QuotationPayload,
CustomerBranchRelation,
Details,
} from 'src/stores/quotations/types';
// NOTE: Import Components
import ViewHeader from './ViewHeader.vue';
@ -49,13 +53,16 @@ type SummaryPrice = {
finalPrice: number;
};
const customer = ref<CustomerBranchRelation>();
const branch = ref<Branch>();
const productList = ref<Product[]>([]);
const bankList = ref<BankBook[]>([]);
const elements = ref<HTMLElement[]>([]);
const chunks = ref<Product[][]>([[]]);
const data = ref<QuotationPayload>();
const data = ref<
QuotationPayload & { customerBranch: CustomerBranchRelation }
>();
const summaryPrice = ref<SummaryPrice>({
totalPrice: 0,
@ -102,6 +109,8 @@ function getHeight(el: HTMLElement) {
return height;
}
const details = ref<Details>();
onMounted(async () => {
let str =
localStorage.getItem('quotation-preview') ||
@ -119,15 +128,29 @@ onMounted(async () => {
data.value = 'data' in parsed ? parsed.data : undefined;
customer.value = parsed.meta.source.customerBranch;
if (data.value) {
const res = await branchStore.fetchById(data.value?.registeredBranchId);
details.value = {
code: parsed.meta.source.code,
createdAt: parsed.meta.source.createdAt,
createdBy: `${parsed.meta.createdBy} ${parsed.meta.source.createdBy.telephoneNo}`,
payCondition: parsed.meta.source.payCondition,
contactName: parsed.meta.source.contactName,
contactTel: parsed.meta.source.contactTel,
workName: parsed.meta.source.workName,
};
if (res) {
branch.value = res;
const resBranch = await branchStore.fetchById(
data.value?.registeredBranchId,
);
bankList.value = res.bank.map((v) => ({
if (resBranch) {
branch.value = resBranch;
bankList.value = resBranch.bank.map((v) => ({
...v,
bankUrl: `${baseUrl}/branch/${res.id}/bank-qr/${v.id}?ts=${Date.now()}`,
bankUrl: `${baseUrl}/branch/${resBranch.id}/bank-qr/${v.id}?ts=${Date.now()}`,
}));
}
@ -200,7 +223,12 @@ function print() {
</div>
<div class="row justify-between container">
<section class="content" v-for="chunk in chunks">
<ViewHeader />
<ViewHeader
v-if="!!branch && !!customer && !!details"
:branch="branch"
:customer="customer"
:details="details"
/>
<span
class="q-mb-sm q-mt-md"
@ -344,7 +372,12 @@ function print() {
</section>
<section class="content">
<ViewHeader class="q-mb-lg" />
<ViewHeader
v-if="!!branch && !!customer && !!details"
:branch="branch"
:customer="customer"
:details="details"
/>
<span
class="q-mb-sm q-mt-md"
@ -368,7 +401,12 @@ function print() {
</section>
<section class="content">
<ViewHeader class="q-mb-lg" />
<ViewHeader
v-if="!!branch && !!customer && !!details"
:branch="branch"
:customer="customer"
:details="details"
/>
<span
class="q-mb-sm"

View file

@ -1,8 +1,18 @@
<script lang="ts" setup>
import { dateFormat } from 'src/utils/datetime';
// NOTE: Import stores
// NOTE Import Types
import { Branch } from 'src/stores/branch/types';
import { CustomerBranchRelation, Details } from 'src/stores/quotations/types';
// NOTE: Import Components
defineProps<{
branch: Branch;
customer: CustomerBranchRelation;
details: Details;
}>();
</script>
<template>
@ -21,53 +31,62 @@
<article class="detail-card">
<section class="detail-customer-info">
<article>
<b>
บร นำคนตางดาวมาทำงานในประเทศ อบส เวคเกอร เซอร จำก
(สำนกงานใหญ)
</b>
<b>บร {{ branch.name }}</b>
<span>
49,51,53 .ขสวสด แขวงราษฏรรณะ เขตราษฏรรณะ กรงเทพมหานคร
10140
หม.{{ branch.moo }} .{{ branch.subDistrict?.name }} .{{
branch.district?.name
}}
.{{ branch.province?.name }} {{ branch.subDistrict?.zipCode }}
</span>
<span>เลขประจำตวผเสยภาษ 0225566001988</span>
<span>เบอรโทร 02-018-8688</span>
<span>https://www.jobsworkerservice.com</span>
<span>เลขประจำตวผเสยภาษ {{ branch.taxNo }}</span>
<span>เบอรโทร {{ branch.telephoneNo }}</span>
<span>{{ branch.webUrl }}</span>
</article>
<article>
<b>กค</b>
<span>
49,51,53 .ขสวสด แขวงราษฏรรณะ เขตราษฏรรณะ กรงเทพมหานคร
10140
.{{ customer.subDistrict?.name }} .{{
customer.district?.name
}}
.{{ customer.province?.name }} {{ customer.subDistrict?.zipCode }}
</span>
<span>เลขประจำตวผเสยภาษ 0225566001988</span>
<span>เบอรโทร 02-018-8688</span>
<span>https://www.jobsworkerservice.com</span>
<span>เลขประจำตวผเสยภาษ {{ customer.citizenId }}</span>
<span>เบอรโทร {{ customer.telephoneNo }}</span>
</article>
</section>
<section class="detail-quotation-info">
<div>
<div>เลขทใบเสนอราคา</div>
<div>QT240120S0003</div>
<div>{{ details.code }}</div>
</div>
<div>
<div>นทใบเสนอราคา</div>
<div>20/01/2024 10:36</div>
<div>{{ dateFormat(details.createdAt, true, false, true) }}</div>
</div>
<div>
<div>ขาย</div>
<div>นายสดใส ใจงาม 084-363-5222</div>
<div>{{ details.createdBy }}</div>
</div>
<div>
<div>เงอนไขการชำระ</div>
<div>เงนสด - เตมจำนวน</div>
<div>
{{
{
Full: $t('quotation.type.fullAmountCash'),
Split: $t('quotation.type.installmentsCash'),
BillFull: $t('quotation.type.fullAmountBill'),
BillSplit: $t('quotation.type.installmentsBill'),
}[details.payCondition]
}}
</div>
</div>
<div>
<div>องาน</div>
<div>MOU Myanmar (Re-turn)</div>
<div>{{ details.workName }}</div>
</div>
<div>
<div>ดต</div>
<div> เจรญงาม</div>
<div>{{ details.contactName }}</div>
</div>
<div>
<div>นครบกำหนดชำระ</div>