fix: paysplit assign & info display

This commit is contained in:
puriphatt 2024-10-17 14:51:42 +07:00
parent b55437fa7e
commit 3a192c0d77
3 changed files with 17 additions and 3 deletions

View file

@ -275,6 +275,12 @@ async function convertDataToFormSubmit() {
),
);
quotationFormData.value.paySplit = JSON.parse(
JSON.stringify(
quotationFormData.value.paySplit.map((p) => ({ ...p, no: undefined })),
),
);
quotationFormData.value = {
id: quotationFormData.value.id,
productServiceList: quotationFormData.value.productServiceList,
@ -828,6 +834,7 @@ async function searchEmployee(text: string) {
:class="{ 'full-height': $q.screen.gt.xs }"
>
<QuotationFormInfo
:mode="quotationFormState.mode"
:quotation-no="(quotationFull && quotationFull.code) || ''"
v-model:urgent="quotationFormData.urgent"
:actor="quotationFormState.createdBy?.($i18n.locale) || ''"
@ -993,7 +1000,6 @@ async function searchEmployee(text: string) {
"
@search="
(id, text, mode) => {
console.log(mode);
if (mode === 'service') {
getAllService(id, { force: true, query: text, pageSize: 50 });
}

View file

@ -13,9 +13,10 @@ import SelectInput from 'src/components/shared/SelectInput.vue';
import { storeToRefs } from 'pinia';
import { precisionRound } from 'src/utils/arithmetic';
defineProps<{
const props = defineProps<{
readonly?: boolean;
quotationNo?: string;
mode?: null | 'info' | 'create' | 'edit';
data?: {
total: number;
discount: number;
@ -182,6 +183,7 @@ function installmentsDate(date: Date | string) {
watch(
() => payType.value,
(v) => {
if (props.mode === 'info') return;
if (v === 'Split' || v === 'BillSplit') {
paySplitCount.value = 1;
} else {
@ -193,6 +195,7 @@ watch(
watch(
() => [paySplitCount.value, summaryPrice.value.finalPrice],
([newCount, _newF], [oldCount, _oldF]) => {
if (props.mode === 'info') return;
calculateInstallments({ newCount: newCount || 0, oldCount: oldCount || 0 });
if (newCount !== oldCount) {
paySplit.value[0].date && installmentsDate(paySplit.value[0].date);
@ -366,7 +369,7 @@ watch(
class="row app-text-muted items-center"
:class="{ 'q-mb-sm': i !== paySplit.length }"
>
{{ `${$t('quotation.periodNo')} ${period.no}` }}
{{ `${$t('quotation.periodNo')} ${i + 1}` }}
<q-input
class="col q-mx-sm"
:label="$t('quotation.amount')"

View file

@ -109,6 +109,11 @@ export const useQuotationForm = defineStore('form-quotation', () => {
})),
dueDate: new Date(data.dueDate),
payBillDate: data.payBillDate ? new Date(data.payBillDate) : undefined,
paySplit: data.paySplit.map((p, index) => ({
no: index + 1,
date: p.date,
amount: p.amount,
})),
worker: data.worker.map((v) =>
Object.assign(v.employee, {
dateOfBirth: new Date(v.employee.dateOfBirth),