fix: wrong status

This commit is contained in:
Methapon Metanipat 2024-11-01 10:55:20 +07:00
parent 88d0e1df14
commit 1325f79bc2

View file

@ -269,19 +269,19 @@ async function fetchStatus() {
statusQuotationForm.value = [
{
title: 'ใบเสนอราคา',
status: getStatus(quotationFormData.value.quotationStatus, -1, -1),
status: getStatus(quotationFormData.value.quotationStatus, 0, -1),
active: () => view.value === View.Quotation,
handler: () => (view.value = View.Quotation),
},
{
title: 'ลูกค้าตอบรับ',
status: getStatus(quotationFormData.value.quotationStatus, 0, -1),
status: getStatus(quotationFormData.value.quotationStatus, 1, 0),
active: () => view.value === View.Accepted,
handler: () => (view.value = View.Accepted),
},
{
title: 'ใบแจ้งหนี้',
status: getStatus(quotationFormData.value.quotationStatus, 4, 0),
status: getStatus(quotationFormData.value.quotationStatus, 4, 1),
active: () =>
view.value === View.Invoice || view.value === View.InvoicePre,
handler: () => {
@ -889,9 +889,13 @@ function getStatus(
doneIndex: number,
doingIndex: number,
) {
return QUOTATION_STATUS.findIndex((v) => v === status) > doneIndex
console.log(
status,
QUOTATION_STATUS.findIndex((v) => v === status),
);
return QUOTATION_STATUS.findIndex((v) => v === status) >= doneIndex
? 'done'
: QUOTATION_STATUS.findIndex((v) => v === status) > doingIndex
: QUOTATION_STATUS.findIndex((v) => v === status) >= doingIndex
? 'doing'
: 'waiting';
}