feat: add installments validate
This commit is contained in:
parent
85e27613e8
commit
1e660682a6
6 changed files with 35 additions and 31 deletions
|
|
@ -97,7 +97,7 @@ const {
|
|||
deleteWork,
|
||||
} = productServiceStore;
|
||||
|
||||
const { workNameItems, splitPay } = storeToRefs(productServiceStore);
|
||||
const { workNameItems } = storeToRefs(productServiceStore);
|
||||
const allStat = ref<{ mode: string; count: number }[]>([]);
|
||||
const stat = ref<
|
||||
{
|
||||
|
|
@ -916,7 +916,7 @@ const prevService = ref<ServiceCreate>({
|
|||
|
||||
const currentService = ref<ServiceById>();
|
||||
|
||||
async function assignFormDataProductService(id: string) {
|
||||
async function assignFormService(id: string) {
|
||||
const res = await fetchListServiceById(id);
|
||||
|
||||
if (res) {
|
||||
|
|
@ -942,6 +942,7 @@ async function assignFormDataProductService(id: string) {
|
|||
status: res.status,
|
||||
productGroupId: res.productGroupId,
|
||||
selectedImage: res.selectedImage,
|
||||
installments: res.installments,
|
||||
};
|
||||
|
||||
formService.value = { ...prevService.value };
|
||||
|
|
@ -962,13 +963,6 @@ async function assignFormDataProductService(id: string) {
|
|||
formService.value.work = prevService.value.work;
|
||||
|
||||
workItems.value = res.work.map((item) => {
|
||||
const maxInstallmentsNo = item.productOnWork.map(
|
||||
(productOnWorkItem) => productOnWorkItem.installmentNo || 0,
|
||||
);
|
||||
|
||||
if (splitPay.value < Math.max(...maxInstallmentsNo))
|
||||
splitPay.value = Math.max(...maxInstallmentsNo);
|
||||
|
||||
return {
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
|
|
@ -1085,7 +1079,6 @@ function clearFormService() {
|
|||
productGroupId: '',
|
||||
};
|
||||
tempWorkItems.value = [];
|
||||
splitPay.value = 0;
|
||||
workItems.value = [];
|
||||
selectProduct.value = [];
|
||||
dialogService.value = false;
|
||||
|
|
@ -1151,16 +1144,19 @@ async function submitService(notClose = false) {
|
|||
if (res) {
|
||||
allStat.value[1].count = allStat.value[1].count + 1;
|
||||
stat.value[1].count = stat.value[1].count + 1;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
totalService.value = totalService.value + 1;
|
||||
productAndServiceTab.value = 'service';
|
||||
}
|
||||
|
||||
if (dialogServiceEdit.value) {
|
||||
await editService(currentIdService.value, {
|
||||
const res = await editService(currentIdService.value, {
|
||||
...formService.value,
|
||||
status: statusToggle.value ? formService.value.status : 'INACTIVE',
|
||||
});
|
||||
if (!res) return;
|
||||
}
|
||||
|
||||
if (!notClose) clearFormService();
|
||||
|
|
@ -1191,17 +1187,21 @@ async function submitProduct(notClose = false) {
|
|||
if (res) {
|
||||
allStat.value[2].count = allStat.value[2].count + 1;
|
||||
stat.value[2].count = stat.value[2].count + 1;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
productAndServiceTab.value = 'product';
|
||||
}
|
||||
|
||||
if (dialogProductEdit.value) {
|
||||
await editProduct(currentIdProduct.value, {
|
||||
const res = await editProduct(currentIdProduct.value, {
|
||||
...formProduct.value,
|
||||
status: statusToggle.value ? 'ACTIVE' : 'INACTIVE',
|
||||
document: formProductDocument.value,
|
||||
});
|
||||
|
||||
if (!res) return;
|
||||
}
|
||||
totalProduct.value = totalProduct.value + 1;
|
||||
if (!notClose) clearFormProduct();
|
||||
|
|
@ -1246,7 +1246,7 @@ function submitAddWorkProduct() {
|
|||
if (!productExists) {
|
||||
workItems.value[currentWorkIndex.value].product.push({
|
||||
...i,
|
||||
installmentNo: splitPay.value > 0 ? 1 : 0,
|
||||
installmentNo: !!formService.value.installments ? 1 : 0,
|
||||
nameEn: '',
|
||||
});
|
||||
workItems.value[currentWorkIndex.value].attributes.workflowStep.forEach(
|
||||
|
|
@ -2896,7 +2896,7 @@ watch(
|
|||
if (props.row.type === 'service') {
|
||||
currentIdService = props.row.id;
|
||||
infoServiceEdit = false;
|
||||
assignFormDataProductService(props.row.id);
|
||||
assignFormService(props.row.id);
|
||||
dialogServiceEdit = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -2915,7 +2915,7 @@ watch(
|
|||
if (props.row.type === 'service') {
|
||||
currentIdService = props.row.id;
|
||||
infoServiceEdit = false;
|
||||
assignFormDataProductService(props.row.id);
|
||||
assignFormService(props.row.id);
|
||||
dialogServiceEdit = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -2931,7 +2931,7 @@ watch(
|
|||
if (props.row.type === 'service') {
|
||||
currentIdService = props.row.id;
|
||||
infoServiceEdit = true;
|
||||
assignFormDataProductService(props.row.id);
|
||||
assignFormService(props.row.id);
|
||||
dialogServiceEdit = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -2986,7 +2986,7 @@ watch(
|
|||
if (row.type === 'service') {
|
||||
currentIdService = row.id;
|
||||
infoServiceEdit = false;
|
||||
assignFormDataProductService(row.id);
|
||||
assignFormService(row.id);
|
||||
dialogServiceEdit = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -3002,7 +3002,7 @@ watch(
|
|||
if (row.type === 'service') {
|
||||
currentIdService = row.id;
|
||||
infoServiceEdit = true;
|
||||
assignFormDataProductService(row.id);
|
||||
assignFormService(row.id);
|
||||
dialogServiceEdit = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -4082,7 +4082,7 @@ watch(
|
|||
class="split-pay q-mx-sm"
|
||||
input-class="text-caption text-right"
|
||||
type="number"
|
||||
v-model="splitPay"
|
||||
v-model="formService.installments"
|
||||
/>
|
||||
{{ $t('quotation.receiptDialog.installments') }}
|
||||
</span>
|
||||
|
|
@ -4158,6 +4158,7 @@ watch(
|
|||
v-model:workflow="currWorkflow"
|
||||
:tree-view="serviceTreeView"
|
||||
:service="formService"
|
||||
:installments="formService.installments"
|
||||
dense
|
||||
@add-product="
|
||||
async (index) => {
|
||||
|
|
@ -4513,7 +4514,7 @@ watch(
|
|||
class="split-pay q-mx-sm"
|
||||
input-class="text-caption text-right"
|
||||
type="number"
|
||||
v-model="splitPay"
|
||||
v-model="formService.installments"
|
||||
/>
|
||||
{{ $t('quotation.receiptDialog.installments') }}
|
||||
</span>
|
||||
|
|
@ -4547,6 +4548,7 @@ watch(
|
|||
:service="formService"
|
||||
:tree-view="serviceTreeView"
|
||||
:readonly="!infoServiceEdit"
|
||||
:installments="formService.installments"
|
||||
:price-display="priceDisplay"
|
||||
dense
|
||||
@add-product="
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue