refactor: update product structure in task list and enhance key usage in v-for loops

This commit is contained in:
puriphatt 2025-02-20 14:24:32 +07:00
parent a66347414a
commit 6df79dae80

View file

@ -51,7 +51,7 @@ const bankList = ref<BankBook[]>([]);
const worker = ref<Employee[]>([]); const worker = ref<Employee[]>([]);
const taskListGroup = ref< const taskListGroup = ref<
{ {
product: RequestWork['productService']['product']; product: RequestWork['productService'];
list: RequestWork[]; list: RequestWork[];
}[] }[]
>([]); >([]);
@ -59,7 +59,7 @@ const taskListGroup = ref<
const elements = ref<HTMLElement[]>([]); const elements = ref<HTMLElement[]>([]);
const chunks = ref< const chunks = ref<
{ {
product: RequestWork['productService']['product']; product: RequestWork['productService'];
list: RequestWork[]; list: RequestWork[];
}[][] }[][]
>([[]]); >([[]]);
@ -112,6 +112,7 @@ async function getAttachment(quotationId: string) {
} }
async function assignData() { async function assignData() {
console.log(taskListGroup.value);
for (let i = 0; i < taskListGroup.value.length; i++) { for (let i = 0; i < taskListGroup.value.length; i++) {
let el = elements.value.at(-1); let el = elements.value.at(-1);
@ -269,7 +270,7 @@ function print() {
<PrintButton solid @click="print" /> <PrintButton solid @click="print" />
</div> </div>
<div class="row justify-between container color-debit-note"> <div class="row justify-between container color-debit-note">
<section class="content" v-for="chunk in chunks"> <section class="content" v-for="(chunk, i) in chunks" :key="i">
<ViewHeader <ViewHeader
v-if="!!branch && !!customer && !!details" v-if="!!branch && !!customer && !!details"
:branch="branch" :branch="branch"
@ -300,23 +301,31 @@ function print() {
<th>{{ $t('preview.pricePerUnit') }}</th> <th>{{ $t('preview.pricePerUnit') }}</th>
<th>{{ $t('preview.value') }}</th> <th>{{ $t('preview.value') }}</th>
</tr> </tr>
<tr v-for="(v, i) in chunk"> {{ console.log(chunks) }}
{{ console.log(chunk) }}
<tr v-for="(v, i) in chunk" :key="i">
<td class="text-center">{{ i + 1 }}</td> <td class="text-center">{{ i + 1 }}</td>
<td>{{ v.product.code }}</td> <td>{{ v.product.product.code }}</td>
<td>{{ v.product.name }}</td> <td>{{ v.product.product.name }}</td>
<td style="text-align: center"> <td style="text-align: center">
{{ {{
formatNumberDecimal( formatNumberDecimal(
calcPricePerUnit(v.product) + calcPricePerUnit(v.product.product) +
(v.product.calcVat (v.product.product.calcVat
? calcPricePerUnit(v.product) * (config?.vat || 0.07) ? calcPricePerUnit(v.product.product) *
(config?.vat || 0.07)
: 0), : 0),
2, 2,
) )
}} }}
</td> </td>
<td style="text-align: center"> <td style="text-align: center">
{{ formatNumberDecimal(calcPrice(v.product, v.list.length), 2) }} {{
formatNumberDecimal(
calcPrice(v.product.product, v.list.length),
2,
)
}}
</td> </td>
</tr> </tr>
</tbody> </tbody>
@ -513,14 +522,16 @@ function print() {
</section> </section>
<section <section
v-for="item in attachmentList.filter((v) => v.isImage)" v-for="(item, i) in attachmentList.filter((v) => v.isImage)"
:key="i"
class="content" class="content"
> >
<q-img :src="item.url" /> <q-img :src="item.url" />
</section> </section>
<ViewPDF <ViewPDF
v-for="item in attachmentList.filter((v) => v.isPDF)" v-for="(item, i) in attachmentList.filter((v) => v.isPDF)"
:key="i"
:url="item.url" :url="item.url"
/> />
</div> </div>