refactor: by value at viewHeader
This commit is contained in:
parent
d5dec2aa49
commit
8095c1c167
2 changed files with 87 additions and 30 deletions
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue