feat: add installments validate
This commit is contained in:
parent
85e27613e8
commit
1e660682a6
6 changed files with 35 additions and 31 deletions
|
|
@ -23,6 +23,7 @@ const props = defineProps<{
|
|||
readonly?: boolean;
|
||||
separator?: boolean;
|
||||
treeView?: boolean;
|
||||
installments?: number;
|
||||
|
||||
priceDisplay?: {
|
||||
price: boolean;
|
||||
|
|
@ -188,9 +189,10 @@ watch(
|
|||
:key="work.id"
|
||||
:index="index"
|
||||
:length="workItems.length"
|
||||
:workIndex="index"
|
||||
:readonly="readonly"
|
||||
:priceDisplay="priceDisplay"
|
||||
:work-index="index"
|
||||
:readonly
|
||||
:price-display
|
||||
:installments
|
||||
v-model:work-name="workItems[index].name"
|
||||
v-model:product-items="work.product"
|
||||
v-model:attributes="work.attributes"
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ const optionStore = useOptionStore();
|
|||
const workflowStore = useWorkflowTemplate();
|
||||
|
||||
const { fetchListOfWork } = productServiceStore;
|
||||
const { splitPay, workNameItems } = storeToRefs(productServiceStore);
|
||||
const { workNameItems } = storeToRefs(productServiceStore);
|
||||
|
||||
const { data: workflowData } = storeToRefs(workflowStore);
|
||||
|
||||
|
|
@ -28,6 +28,7 @@ const props = withDefaults(
|
|||
length: number;
|
||||
index: number;
|
||||
readonly?: boolean;
|
||||
installments?: number;
|
||||
|
||||
priceDisplay?: {
|
||||
price: boolean;
|
||||
|
|
@ -445,7 +446,7 @@ watch(
|
|||
<q-input
|
||||
v-if="!readonly && $q.screen.gt.xs"
|
||||
outlined
|
||||
:max="splitPay"
|
||||
:max="installments"
|
||||
input-class="text-right no-padding"
|
||||
for="input-bankbook"
|
||||
hide-bottom-space
|
||||
|
|
@ -454,12 +455,6 @@ watch(
|
|||
type="number"
|
||||
v-model="product.installmentNo"
|
||||
min="0"
|
||||
@update:model-value="
|
||||
(v) => {
|
||||
if (Number(v) > splitPay)
|
||||
product.installmentNo = splitPay;
|
||||
}
|
||||
"
|
||||
/>
|
||||
</span>
|
||||
</span>
|
||||
|
|
|
|||
|
|
@ -1026,6 +1026,8 @@ export default {
|
|||
'An error has occurred, causing the system to be unable to function. Please try again later.',
|
||||
invalideData: 'The information is incorrect. Please try again later.',
|
||||
authFailed: 'Authentication Failed. Please try again later. ',
|
||||
installmentsValidateFailed:
|
||||
'Validation failed. Each installment must include at least one product. Please review and update the installments accordingly.',
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -1012,6 +1012,8 @@ export default {
|
|||
'เกิดข้อผิดพลาดทำให้ระบบไม่สามารถทำงานได้ กรุณาลองใหม่ในภายหลัง',
|
||||
invalideData: 'ข้อมูลไม่ถูกต้อง กรุณาตรวจสอบใหม่อีกครั้ง',
|
||||
authFailed: 'การยืนยันตัวตนล้มเหลว กรุณาลองใหม่ในภายหลัง',
|
||||
installmentsValidateFailed:
|
||||
'ข้อมูลงวดไม่ถูกต้อง กรุณาตรวจสอบและยืนยันว่าแต่ละงวดมีสินค้าอย่างน้อยหนึ่งรายการ',
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -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="
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ export interface ServiceById {
|
|||
productGroupId: string;
|
||||
selectedImage: string;
|
||||
registeredBranchId: string;
|
||||
installments: number;
|
||||
}
|
||||
|
||||
export interface ProductOnWork {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue