diff --git a/src/components/ui/AdminSelect.vue b/src/components/ui/AdminSelect.vue index 00e830b..5343be4 100644 --- a/src/components/ui/AdminSelect.vue +++ b/src/components/ui/AdminSelect.vue @@ -1,5 +1,5 @@ - + + + + + موردی یافت نشد + + form.customerId.length > 0 && form.companyId.length > 0, ) - const activeCustomers = computed(() => customers.value.filter((c) => c.isActive)) + const activeCustomers = computed(() => { + const list = [...customers.value] + list.sort((a, b) => Number(b.isActive) - Number(a.isActive) || a.name.localeCompare(b.name, 'fa')) + return list + }) function applyCustomer(customerId: string) { const customer = customers.value.find((c) => c.id === customerId) @@ -48,6 +52,14 @@ export function useOrdersPage() { form.customerPhone = customer?.phone ?? '' } + async function loadCustomers() { + try { + customers.value = await customersApi.list() + } catch (err) { + toast.error(err instanceof ApiError ? err.message : 'بارگذاری مشتریان انجام نشد.') + } + } + const filteredOrders = computed(() => { let list = orderList.value if (activeTab.value !== 'all') { @@ -200,6 +212,7 @@ export function useOrdersPage() { Object.assign(form, emptyForm()) formError.value = '' showAddModal.value = true + void loadCustomers() } function closeAddModal() { @@ -241,6 +254,7 @@ export function useOrdersPage() { customers, activeCustomers, applyCustomer, + loadCustomers, orderList, activeTab, selectedOrderId, diff --git a/src/views/orders/components/OrderAddModal.vue b/src/views/orders/components/OrderAddModal.vue index 5cf577e..1382be5 100644 --- a/src/views/orders/components/OrderAddModal.vue +++ b/src/views/orders/components/OrderAddModal.vue @@ -21,12 +21,14 @@ const companyOptions = computed(() => ) const customerOptions = computed(() => - activeCustomers.value.map((customer) => ({ - value: customer.id, - label: customer.phone - ? `${customer.name} — ${customer.phone}` - : customer.name, - })), + activeCustomers.value.map((customer) => { + const phone = customer.phone ? ` — ${customer.phone}` : '' + const inactive = customer.isActive === false ? ' (غیرفعال)' : '' + return { + value: customer.id, + label: `${customer.name}${phone}${inactive}`, + } + }), ) const settlementOptions = [ @@ -53,16 +55,21 @@ watch( {{ formError }} - نام مشتری * + + نام مشتری * + - مشتری فعالی یافت نشد. ابتدا از بخش مشتریان ثبت کنید. + مشتریای در سیستم نیست. ابتدا از بخش «مشتریان» یک مشتری ثبت کنید.
{{ formError }}
- مشتری فعالی یافت نشد. ابتدا از بخش مشتریان ثبت کنید. + مشتریای در سیستم نیست. ابتدا از بخش «مشتریان» یک مشتری ثبت کنید.