Initial admin edits
This commit is contained in:
@@ -24,6 +24,8 @@ import {
|
||||
import { formatNumber } from '@/utils/format'
|
||||
import { colorSwatchStyle } from '@/utils/colorSwatch'
|
||||
import { demoProductsFor, findMockCalite } from '@/data/caliteCollections'
|
||||
import { isProductUnavailable } from '@/utils/productAvailability'
|
||||
import { useAppToast } from '@/composables/useAppToast'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@@ -32,6 +34,7 @@ const catalogStore = useCatalogStore()
|
||||
const crm = useCrmStore()
|
||||
const cartStore = useCartStore()
|
||||
const favorites = useFavoritesStore()
|
||||
const appToast = useAppToast()
|
||||
|
||||
const catalogId = computed(() => String(route.params.catalogId ?? ''))
|
||||
const catalog = ref<Catalog | null>(null)
|
||||
@@ -39,7 +42,6 @@ const products = ref<CatalogProductCard[]>([])
|
||||
const loading = ref(true)
|
||||
const error = ref<string | null>(null)
|
||||
const adding = ref(false)
|
||||
const toast = ref('')
|
||||
const tab = ref<'all' | PatternKind>('all')
|
||||
|
||||
const title = computed(() => catalogDisplayTitle(catalog.value?.name || 'کالیته'))
|
||||
@@ -186,18 +188,18 @@ function toCartProduct(item: CatalogProductCard): Product {
|
||||
minMeterage: item.minMeterage ?? 30,
|
||||
orderMultiplier: item.orderMultiplier ?? 10,
|
||||
basePrice: item.basePrice,
|
||||
isActive: true,
|
||||
isActive: item.isActive !== false,
|
||||
}
|
||||
}
|
||||
|
||||
async function addAllToInquiry() {
|
||||
if (!products.value.length || adding.value) return
|
||||
adding.value = true
|
||||
toast.value = ''
|
||||
let added = 0
|
||||
let failed = ''
|
||||
try {
|
||||
for (const item of products.value) {
|
||||
if (isProductUnavailable(item)) continue
|
||||
const product = toCartProduct(item)
|
||||
const result = await cartStore.addItem(
|
||||
product,
|
||||
@@ -207,11 +209,16 @@ async function addAllToInquiry() {
|
||||
if (result.success) added += 1
|
||||
else failed = result.message || failed
|
||||
}
|
||||
toast.value = added
|
||||
const text = added
|
||||
? `${formatNumber(added)} طرح به سبد استعلام اضافه شد.`
|
||||
: failed || 'افزودن به سبد ناموفق بود.'
|
||||
if (added) {
|
||||
window.setTimeout(() => router.push('/cart'), 650)
|
||||
appToast.show(text, {
|
||||
tone: 'success',
|
||||
onDismiss: () => router.push('/cart'),
|
||||
})
|
||||
} else {
|
||||
appToast.show(text, { tone: failed ? 'error' : 'warning' })
|
||||
}
|
||||
} finally {
|
||||
adding.value = false
|
||||
@@ -348,6 +355,10 @@ async function addAllToInquiry() {
|
||||
class="pattern-card__photo"
|
||||
:style="pattern.imageUrl ? { backgroundImage: `url(${pattern.imageUrl})` } : undefined"
|
||||
>
|
||||
<span
|
||||
v-if="pattern.items.every((p) => isProductUnavailable(p))"
|
||||
class="pattern-card__oos"
|
||||
>ناموجود</span>
|
||||
<button
|
||||
type="button"
|
||||
class="pattern-card__fav"
|
||||
@@ -394,7 +405,6 @@ async function addAllToInquiry() {
|
||||
<small>{{ formatNumber(patterns.length) }} طرح انتخاب میشود</small>
|
||||
</button>
|
||||
</div>
|
||||
<p v-if="toast" class="toast">{{ toast }}</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -662,6 +672,19 @@ async function addAllToInquiry() {
|
||||
background-position: center;
|
||||
}
|
||||
|
||||
.pattern-card__oos {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
inset-inline-end: 8px;
|
||||
z-index: 1;
|
||||
padding: 3px 8px;
|
||||
border-radius: 999px;
|
||||
background: #b91c1c;
|
||||
color: #fff;
|
||||
font-size: 0.65rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.pattern-card__fav {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
@@ -749,20 +772,6 @@ async function addAllToInquiry() {
|
||||
color: #8a847c;
|
||||
}
|
||||
|
||||
.toast {
|
||||
position: fixed;
|
||||
left: 50%;
|
||||
bottom: calc(var(--nav-height) + 84px);
|
||||
z-index: 20;
|
||||
transform: translateX(-50%);
|
||||
padding: 8px 14px;
|
||||
border-radius: 999px;
|
||||
background: var(--color-primary);
|
||||
color: #fff;
|
||||
font-size: 0.75rem;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
html.dark .calite-detail {
|
||||
background: #0b0f14;
|
||||
color: #eef2f8;
|
||||
@@ -912,10 +921,6 @@ html.dark .calite-detail__footer.sticky-footer {
|
||||
margin-inline: auto;
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.toast {
|
||||
bottom: 32px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1200px) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import IconSuccessCircle from '@/components/icons/IconSuccessCircle.vue'
|
||||
import { formatCurrency, formatDateTime } from '@/utils/format'
|
||||
import { useRequirePricedOrder } from '@/composables/useRequirePricedOrder'
|
||||
import type { BankAccount } from '@/types'
|
||||
import { PAYMENT_RECIPIENT_COMPANY_SLUG } from '@/utils/constants'
|
||||
|
||||
const router = useRouter()
|
||||
const orderStore = useOrderStore()
|
||||
@@ -16,7 +17,13 @@ const catalogStore = useCatalogStore()
|
||||
const bankAccounts = ref<BankAccount[]>([])
|
||||
|
||||
const { orderId, order } = useRequirePricedOrder()
|
||||
const companyName = computed(() => order.value?.companyName ?? '')
|
||||
|
||||
const paymentRecipientName = computed(() => {
|
||||
const fromCatalog = catalogStore.companies.find(
|
||||
(c) => c.slug === PAYMENT_RECIPIENT_COMPANY_SLUG,
|
||||
)?.name
|
||||
return fromCatalog ?? 'نادمی تکس'
|
||||
})
|
||||
|
||||
watch(
|
||||
orderId,
|
||||
@@ -49,12 +56,9 @@ const expiryMessage = computed(() => {
|
||||
return `مهلت پرداخت این فاکتور تا ${formatDateTime(expiry)} است.`
|
||||
})
|
||||
|
||||
const accountsSectionTitle = computed(() => {
|
||||
const name = companyName.value.replace(/^شرکت\s+/u, '')
|
||||
return name
|
||||
? `شماره حسابهای واریز — ${name}`
|
||||
: 'شماره حسابهای واریز'
|
||||
})
|
||||
const accountsSectionTitle = computed(
|
||||
() => `شماره حسابهای واریز — ${paymentRecipientName.value}`,
|
||||
)
|
||||
|
||||
function formatCardNumber(value: string) {
|
||||
const digits = value.replace(/\D/g, '')
|
||||
|
||||
@@ -49,7 +49,11 @@ const checks = computed<CheckData[]>(() => {
|
||||
|
||||
return orderStore
|
||||
.userOrders(authStore.user.id)
|
||||
.filter((o) => o.settlementType === 'check' && o.checks?.length)
|
||||
.filter(
|
||||
(o) =>
|
||||
(o.settlementType === 'check' || o.settlementType === 'cash_check') &&
|
||||
o.checks?.length,
|
||||
)
|
||||
.flatMap((o) => o.checks ?? [])
|
||||
})
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useOrderStore } from '@/stores/order'
|
||||
import PageHeader from '@/components/layout/PageHeader.vue'
|
||||
@@ -11,9 +11,21 @@ import IconCheckBook from '@/components/icons/IconCheckBook.vue'
|
||||
import { formatCurrency } from '@/utils/format'
|
||||
import { isInvoicePriced } from '@/utils/orderInvoice'
|
||||
import { useRequirePricedOrder } from '@/composables/useRequirePricedOrder'
|
||||
import { usePublicContact } from '@/composables/usePublicContact'
|
||||
import type { SettlementType } from '@/types'
|
||||
|
||||
const router = useRouter()
|
||||
const orderStore = useOrderStore()
|
||||
const {
|
||||
load: loadPublicSettings,
|
||||
defaultSettlementCash,
|
||||
defaultSettlementCheck,
|
||||
defaultSettlementCashCheck,
|
||||
} = usePublicContact()
|
||||
|
||||
onMounted(() => {
|
||||
void loadPublicSettings()
|
||||
})
|
||||
|
||||
const { orderId, order, invoiceReady } = useRequirePricedOrder()
|
||||
const submitting = ref(false)
|
||||
@@ -31,7 +43,7 @@ const invoiceLabel = computed(() =>
|
||||
order.value?.finalAmount ? formatCurrency(order.value.finalAmount) : '—',
|
||||
)
|
||||
|
||||
async function selectType(type: 'cash' | 'check') {
|
||||
async function selectType(type: SettlementType) {
|
||||
if (submitting.value || !isInvoicePriced(order.value)) {
|
||||
formError.value = 'تا قبل از قیمتگذاری مدیریت، امکان انتخاب روش تسویه وجود ندارد.'
|
||||
return
|
||||
@@ -40,7 +52,7 @@ async function selectType(type: 'cash' | 'check') {
|
||||
formError.value = ''
|
||||
try {
|
||||
await orderStore.chooseSettlement(orderId.value, type)
|
||||
if (type === 'cash') {
|
||||
if (type === 'cash' || type === 'cash_check') {
|
||||
router.replace(`/orders/${orderId.value}/cash`)
|
||||
} else {
|
||||
orderStore.startCheckDraft(orderId.value)
|
||||
@@ -87,6 +99,7 @@ async function selectType(type: 'cash' | 'check') {
|
||||
|
||||
<div class="settlement-mobile-options">
|
||||
<button
|
||||
v-if="defaultSettlementCash"
|
||||
type="button"
|
||||
class="settlement-card"
|
||||
:disabled="submitting"
|
||||
@@ -99,6 +112,7 @@ async function selectType(type: 'cash' | 'check') {
|
||||
<p>پرداخت از طریق واریز به حساب شرکت</p>
|
||||
</button>
|
||||
<button
|
||||
v-if="defaultSettlementCheck"
|
||||
type="button"
|
||||
class="settlement-card"
|
||||
:disabled="submitting"
|
||||
@@ -110,6 +124,22 @@ async function selectType(type: 'cash' | 'check') {
|
||||
<h3>تسویه چکی</h3>
|
||||
<p>پرداخت بر اساس مبلغ فاکتور با ثبت چک</p>
|
||||
</button>
|
||||
<button
|
||||
v-if="defaultSettlementCashCheck"
|
||||
type="button"
|
||||
class="settlement-card"
|
||||
:disabled="submitting"
|
||||
@click="selectType('cash_check')"
|
||||
>
|
||||
<span
|
||||
class="settlement-card__icon settlement-card__icon--check settlement-card__icon--hybrid"
|
||||
>
|
||||
<IconCashSettlement :size="28" />
|
||||
<IconCheckBook :size="28" />
|
||||
</span>
|
||||
<h3>تسویه نقدی-چکی</h3>
|
||||
<p>ابتدا واریز نقدی، سپس ثبت چک برای مابقی تسویه</p>
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
@@ -155,6 +185,7 @@ async function selectType(type: 'cash' | 'check') {
|
||||
|
||||
<div v-else class="desktop-settlement-grid">
|
||||
<button
|
||||
v-if="defaultSettlementCash"
|
||||
type="button"
|
||||
class="settlement-card settlement-card--desktop"
|
||||
:disabled="submitting"
|
||||
@@ -167,6 +198,7 @@ async function selectType(type: 'cash' | 'check') {
|
||||
<p>پرداخت از طریق واریز به حساب شرکت</p>
|
||||
</button>
|
||||
<button
|
||||
v-if="defaultSettlementCheck"
|
||||
type="button"
|
||||
class="settlement-card settlement-card--desktop"
|
||||
:disabled="submitting"
|
||||
@@ -178,6 +210,20 @@ async function selectType(type: 'cash' | 'check') {
|
||||
<h3>تسویه چکی</h3>
|
||||
<p>پرداخت بر اساس مبلغ فاکتور با ثبت چک</p>
|
||||
</button>
|
||||
<button
|
||||
v-if="defaultSettlementCashCheck"
|
||||
type="button"
|
||||
class="settlement-card settlement-card--desktop"
|
||||
:disabled="submitting"
|
||||
@click="selectType('cash_check')"
|
||||
>
|
||||
<span class="settlement-card__icon settlement-card__icon--check settlement-card__icon--hybrid">
|
||||
<IconCashSettlement :size="32" />
|
||||
<IconCheckBook :size="32" />
|
||||
</span>
|
||||
<h3>تسویه نقدی-چکی</h3>
|
||||
<p>ابتدا واریز نقدی، سپس ثبت چک برای مابقی تسویه</p>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -331,6 +377,10 @@ async function selectType(type: 'cash' | 'check') {
|
||||
background: var(--color-primary-light);
|
||||
}
|
||||
|
||||
.settlement-card__icon--hybrid {
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.settlement-card h3 {
|
||||
margin: 0 0 8px;
|
||||
font-size: 1.0625rem;
|
||||
|
||||
@@ -208,7 +208,10 @@ function customerStatusClass(status: CustomerStatus) {
|
||||
@back="router.push('/customers')"
|
||||
>
|
||||
<template v-if="tab === 'info'" #trailing>
|
||||
<button type="button" class="edit-btn" @click="openEdit">ویرایش</button>
|
||||
<button type="button" class="edit-btn edit-btn--compact" aria-label="ویرایش" @click="openEdit">
|
||||
<IconEditPen :size="18" />
|
||||
<span class="edit-btn__label">ویرایش</span>
|
||||
</button>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
@@ -853,6 +856,10 @@ function customerStatusClass(status: CustomerStatus) {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.edit-btn--compact svg {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.meeting-filters {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
||||
import { useMediaQuery } from '@vueuse/core'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { useCrmStore } from '@/stores/crm'
|
||||
@@ -24,6 +25,8 @@ import PageSkeleton from '@/components/ui/PageSkeleton.vue'
|
||||
import UserAvatar from '@/components/ui/UserAvatar.vue'
|
||||
import HomeSuggestionsSection from '@/components/home/HomeSuggestionsSection.vue'
|
||||
import { useTouchSwipe } from '@/composables/useTouchSwipe'
|
||||
import { isProductUnavailable } from '@/utils/productAvailability'
|
||||
import { followBannerLink } from '@/utils/bannerLink'
|
||||
|
||||
const router = useRouter()
|
||||
const { goBack } = useGoBack('/')
|
||||
@@ -77,6 +80,7 @@ const suggestionsForHome = computed(() => {
|
||||
colorImages: item.colorImages?.some(Boolean)
|
||||
? item.colorImages
|
||||
: product?.colorImages,
|
||||
productIsActive: item.productIsActive ?? product?.isActive,
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -101,6 +105,8 @@ let bannerTimer: number | undefined
|
||||
|
||||
const banner = computed(() => banners.value[bannerIndex.value] ?? FALLBACK_BANNER)
|
||||
|
||||
const bannerImageLink = computed(() => banner.value.bannerLink?.trim() || '')
|
||||
|
||||
const heroHasCopy = computed(() => {
|
||||
const item = banner.value
|
||||
return (
|
||||
@@ -156,6 +162,12 @@ const { onTouchStart: onHeroTouchStart, onTouchEnd: onHeroTouchEnd } = useTouchS
|
||||
|
||||
const displayFirst = computed(() => auth.user?.firstName || 'کاربر')
|
||||
const displayLast = computed(() => auth.user?.lastName || '')
|
||||
|
||||
const isNarrowHeader = useMediaQuery('(max-width: 467px)')
|
||||
const homeAvatarSize = computed(() => (isNarrowHeader.value ? 36 : 44))
|
||||
const homeGreetingName = computed(() =>
|
||||
isNarrowHeader.value ? displayFirst.value : `${displayFirst.value} ${displayLast.value}`.trim(),
|
||||
)
|
||||
const homeLevel = computed(() => {
|
||||
if (agentLevel.value) return agentLevel.value
|
||||
const u = auth.user
|
||||
@@ -223,6 +235,13 @@ function goBanner() {
|
||||
go(banner.value.ctaLink.trim() || '/categories')
|
||||
}
|
||||
|
||||
function onHeroBannerClick(event: MouseEvent) {
|
||||
if (!bannerImageLink.value) return
|
||||
const target = event.target as HTMLElement
|
||||
if (target.closest('.hero-banner__cta, .hero-banner__dots')) return
|
||||
followBannerLink(bannerImageLink.value, router)
|
||||
}
|
||||
|
||||
async function toggleFavorite(productId: string) {
|
||||
favError.value = null
|
||||
try {
|
||||
@@ -244,11 +263,11 @@ async function toggleFavorite(productId: string) {
|
||||
class="home-header__avatar"
|
||||
:src="auth.user?.avatarUrl"
|
||||
:initials="displayFirst.charAt(0)"
|
||||
:size="44"
|
||||
:size="homeAvatarSize"
|
||||
/>
|
||||
<div>
|
||||
<div class="home-header__text">
|
||||
<p class="home-header__hello">
|
||||
سلام، {{ displayFirst }} {{ displayLast }}
|
||||
سلام، {{ homeGreetingName }}
|
||||
</p>
|
||||
<p class="home-header__welcome">خوش آمدید</p>
|
||||
</div>
|
||||
@@ -279,7 +298,9 @@ async function toggleFavorite(productId: string) {
|
||||
<template v-else>
|
||||
<section
|
||||
class="hero-banner"
|
||||
:class="{ 'hero-banner--linked': !!bannerImageLink }"
|
||||
:aria-label="banner.title"
|
||||
@click="onHeroBannerClick"
|
||||
@touchstart.passive="onHeroTouchStart"
|
||||
@touchend.passive="onHeroTouchEnd"
|
||||
>
|
||||
@@ -306,7 +327,7 @@ async function toggleFavorite(productId: string) {
|
||||
v-if="banner.showCta !== false && banner.ctaLabel"
|
||||
type="button"
|
||||
class="hero-banner__cta"
|
||||
@click="goBanner"
|
||||
@click.stop="goBanner"
|
||||
>
|
||||
{{ banner.ctaLabel }}
|
||||
</button>
|
||||
@@ -322,7 +343,7 @@ async function toggleFavorite(productId: string) {
|
||||
:class="{ 'dot--active': index === bannerIndex }"
|
||||
:aria-label="item.title"
|
||||
:aria-selected="index === bannerIndex"
|
||||
@click="setBanner(index)"
|
||||
@click.stop="setBanner(index)"
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
@@ -409,7 +430,11 @@ async function toggleFavorite(productId: string) {
|
||||
:class="`product-card__image--${index % 3}`"
|
||||
:style="item.imageUrl ? { backgroundImage: `url(${item.imageUrl})` } : undefined"
|
||||
>
|
||||
<span v-if="item.isNew" class="product-card__badge">جدید</span>
|
||||
<span
|
||||
v-if="isProductUnavailable(item)"
|
||||
class="product-card__badge product-card__badge--oos"
|
||||
>ناموجود</span>
|
||||
<span v-else-if="item.isNew" class="product-card__badge">جدید</span>
|
||||
</div>
|
||||
<div class="product-card__body">
|
||||
<strong class="product-card__name">{{ item.name }}</strong>
|
||||
@@ -471,10 +496,15 @@ async function toggleFavorite(productId: string) {
|
||||
}
|
||||
|
||||
.home-header__avatar {
|
||||
flex-shrink: 0;
|
||||
background: var(--color-primary-soft);
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.home-header__text {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.home-header__hello {
|
||||
margin: 0;
|
||||
font-size: 0.95rem;
|
||||
@@ -518,6 +548,10 @@ async function toggleFavorite(productId: string) {
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
.hero-banner--linked {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.hero-banner {
|
||||
--hero-image: #8a7a65;
|
||||
position: relative;
|
||||
@@ -928,6 +962,10 @@ html.dark .quick-card__label {
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.product-card__badge--oos {
|
||||
background: #b91c1c;
|
||||
}
|
||||
|
||||
.product-card__body {
|
||||
position: relative;
|
||||
display: flex;
|
||||
|
||||
@@ -3,6 +3,7 @@ import { ref, computed, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useMediaQuery } from '@vueuse/core'
|
||||
import { useOrderStore } from '@/stores/order'
|
||||
import type { Order } from '@/types'
|
||||
import BaseButton from '@/components/ui/BaseButton.vue'
|
||||
import BaseInput from '@/components/ui/BaseInput.vue'
|
||||
import CurrencyInput from '@/components/ui/CurrencyInput.vue'
|
||||
@@ -33,6 +34,13 @@ import OrderTrackingTimeline from '@/components/orders/OrderTrackingTimeline.vue
|
||||
import OrderStatusHero from '@/components/orders/OrderStatusHero.vue'
|
||||
import OrderTrackingSummary from '@/components/orders/OrderTrackingSummary.vue'
|
||||
import { canSubmitCashReceipt, isInvoicePriced, orderItemMeterage } from '@/utils/orderInvoice'
|
||||
import {
|
||||
isInCashPaymentPhase,
|
||||
isInCheckPhase,
|
||||
settlementTypeLabel,
|
||||
usesCashReceiptPhase,
|
||||
usesCheckSettlement,
|
||||
} from '@/utils/settlement'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@@ -152,9 +160,18 @@ const trackingFooterLabel = computed(() =>
|
||||
order.value ? getTrackingFooterLabel(order.value.status) : 'مشاهده جزئیات سفارش',
|
||||
)
|
||||
|
||||
function settlementLabel(type: 'cash' | 'check' | null) {
|
||||
if (!type) return 'در انتظار انتخاب مشتری'
|
||||
return type === 'cash' ? 'تسویه نقدی' : 'تسویه چکی'
|
||||
function settlementLabel(type: Order['settlementType']) {
|
||||
return settlementTypeLabel(type)
|
||||
}
|
||||
|
||||
function showCashTracking(order: Order) {
|
||||
if (!usesCashReceiptPhase(order.settlementType)) return false
|
||||
return isInCashPaymentPhase(order) || !!order.cashReceipt
|
||||
}
|
||||
|
||||
function showCheckTracking(order: Order) {
|
||||
if (!usesCheckSettlement(order.settlementType)) return false
|
||||
return isInCheckPhase(order) || (order.checks?.length ?? 0) > 0
|
||||
}
|
||||
|
||||
type NextAction = { label: string; to?: string; receipt?: boolean }
|
||||
@@ -419,7 +436,7 @@ async function submitReceipt() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template v-if="order.settlementType === 'cash'">
|
||||
<template v-if="showCashTracking(order)">
|
||||
<div v-if="order.cashInvoiceExpiresAt" class="tracking-alert">
|
||||
اعتبار فاکتور: {{ formatDateTime(order.cashInvoiceExpiresAt) }}
|
||||
</div>
|
||||
@@ -454,7 +471,7 @@ async function submitReceipt() {
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-if="order.settlementType === 'check' && order.checks">
|
||||
<template v-if="showCheckTracking(order) && order.checks">
|
||||
<div class="tracking-collapse__section">
|
||||
<h3 class="tracking-card__title">رأس چکها</h3>
|
||||
<div class="rass-display">{{ order.checkRassDays }} روز</div>
|
||||
|
||||
@@ -8,6 +8,7 @@ import { useCrmStore } from '@/stores/crm'
|
||||
import type { CatalogProductCard } from '@/types/crm'
|
||||
import { formatNumber } from '@/utils/format'
|
||||
import { colorSwatchStyle, colorVariantThumb, productListThumb } from '@/utils/colorSwatch'
|
||||
import { isProductUnavailable } from '@/utils/productAvailability'
|
||||
import IconBookmark from '@/components/icons/IconBookmark.vue'
|
||||
import IconChevronLeft from '@/components/icons/IconChevronLeft.vue'
|
||||
|
||||
@@ -87,7 +88,8 @@ async function remove(id: string) {
|
||||
<div class="product-item__head">
|
||||
<div class="product-item__title">
|
||||
<strong>{{ item.name }}</strong>
|
||||
<span v-if="item.isNew" class="new-tag">جدید</span>
|
||||
<span v-if="isProductUnavailable(item)" class="new-tag new-tag--oos">ناموجود</span>
|
||||
<span v-else-if="item.isNew" class="new-tag">جدید</span>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
@@ -200,6 +202,11 @@ async function remove(id: string) {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.new-tag--oos {
|
||||
background: rgba(185, 28, 28, 0.12);
|
||||
color: #b91c1c;
|
||||
}
|
||||
|
||||
.bookmark {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
|
||||
@@ -27,6 +27,7 @@ import { useCatalogRequest } from '@/composables/useCatalogRequest'
|
||||
import AddressCompletionModal from '@/components/catalogs/AddressCompletionModal.vue'
|
||||
import ProductOrderModal from '@/components/products/ProductOrderModal.vue'
|
||||
import { useTouchSwipe } from '@/composables/useTouchSwipe'
|
||||
import { isProductUnavailable } from '@/utils/productAvailability'
|
||||
|
||||
const USAGE_CHIP_LABEL: Record<string, string> = {
|
||||
suit: 'پارچه کتشلواری',
|
||||
@@ -67,10 +68,9 @@ const {
|
||||
closeAddressModal,
|
||||
} = useCatalogRequest()
|
||||
const rollMeters = computed(() => product.value?.rollMeters ?? 50)
|
||||
const outOfStock = computed(() => {
|
||||
const stock = product.value?.stock
|
||||
return stock != null && stock <= 0
|
||||
})
|
||||
const outOfStock = computed(() =>
|
||||
product.value ? isProductUnavailable(product.value) : false,
|
||||
)
|
||||
const galleryImages = computed(() => {
|
||||
const urls = product.value?.imageUrls ?? []
|
||||
return urls.filter((url) => typeof url === 'string' && url.trim().length > 0)
|
||||
@@ -109,12 +109,8 @@ const minOrderMeters = computed(() => {
|
||||
const minRolls = computed(() =>
|
||||
Math.max(1, Math.ceil(minOrderMeters.value / rollMeters.value)),
|
||||
)
|
||||
const usageLabel = computed(
|
||||
() => USAGE_CHIP_LABEL[product.value?.categoryId ?? ''] || '—',
|
||||
)
|
||||
const seasonLabel = computed(
|
||||
() => SEASON_CHIP_LABEL[product.value?.season ?? ''] || '—',
|
||||
)
|
||||
const productSpecsText = computed(() => product.value?.specs?.trim() ?? '')
|
||||
const hasProductSpecs = computed(() => productSpecsText.value.length > 0)
|
||||
|
||||
const categoryChips = computed(() => {
|
||||
const p = product.value
|
||||
@@ -208,7 +204,7 @@ function toCartProduct(p: CatalogProductCard, colorIndex = selectedColor.value):
|
||||
minMeterage: min,
|
||||
orderMultiplier: step,
|
||||
basePrice: p.basePrice,
|
||||
isActive: true,
|
||||
isActive: p.isActive !== false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,7 +427,8 @@ function onAddressSubmit(address: string) {
|
||||
<div class="pd-body">
|
||||
<div class="title-row">
|
||||
<h1>{{ product.name }}</h1>
|
||||
<span v-if="product.isNew" class="new-badge">جدید</span>
|
||||
<span v-if="outOfStock" class="pd-stock-badge">ناموجود</span>
|
||||
<span v-else-if="product.isNew" class="new-badge">جدید</span>
|
||||
</div>
|
||||
<p class="code">کد محصول: {{ product.code }}</p>
|
||||
|
||||
@@ -467,17 +464,17 @@ function onAddressSubmit(address: string) {
|
||||
<strong>{{ product.weaveType || '—' }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="specs-more" @click="showAllSpecs = !showAllSpecs">
|
||||
{{ showAllSpecs ? 'بستن مشخصات' : 'مشاهده همه مشخصات' }}
|
||||
<svg class="specs-more__chevron" :class="{ 'is-open': showAllSpecs }" viewBox="0 0 12 12" aria-hidden="true">
|
||||
<path d="M3 4.5 6 8l3-3.5" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" />
|
||||
</svg>
|
||||
</button>
|
||||
<div v-if="showAllSpecs" class="specs-extra">
|
||||
<p>فصل: {{ seasonLabel }}</p>
|
||||
<p>دسته: {{ usageLabel }}</p>
|
||||
<p>جمع سفارش: {{ formatNumber(orderMeters) }} متر</p>
|
||||
</div>
|
||||
<template v-if="hasProductSpecs">
|
||||
<button type="button" class="specs-more" @click="showAllSpecs = !showAllSpecs">
|
||||
{{ showAllSpecs ? 'بستن مشخصات' : 'مشاهده همه مشخصات' }}
|
||||
<svg class="specs-more__chevron" :class="{ 'is-open': showAllSpecs }" viewBox="0 0 12 12" aria-hidden="true">
|
||||
<path d="M3 4.5 6 8l3-3.5" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" />
|
||||
</svg>
|
||||
</button>
|
||||
<div v-if="showAllSpecs" class="specs-extra">
|
||||
<p class="specs-extra__text">{{ productSpecsText }}</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<section class="pd-section pd-section--boxed">
|
||||
<div class="section-head">
|
||||
@@ -879,6 +876,11 @@ function onAddressSubmit(address: string) {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.specs-extra__text {
|
||||
margin: 0;
|
||||
white-space: pre-line;
|
||||
}
|
||||
|
||||
.pd-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -16,7 +16,6 @@ const {
|
||||
products,
|
||||
meterages,
|
||||
errors,
|
||||
toast,
|
||||
cartStore,
|
||||
adjustMeterage,
|
||||
setMeterage,
|
||||
@@ -39,7 +38,6 @@ const {
|
||||
:errors="errors"
|
||||
:total-meterage="cartStore.totalMeterage"
|
||||
:item-count="cartStore.itemCount"
|
||||
:toast="toast"
|
||||
@back="goBack"
|
||||
@update:color-filter="colorFilter = $event"
|
||||
@adjust="adjustMeterage"
|
||||
@@ -62,7 +60,6 @@ const {
|
||||
:item-count="cartStore.itemCount"
|
||||
:total-meterage="cartStore.totalMeterage"
|
||||
:remaining-capacity="cartStore.remainingCapacity"
|
||||
:toast="toast"
|
||||
@update:color-filter="colorFilter = $event"
|
||||
@adjust="adjustMeterage"
|
||||
@set-meterage="setMeterage"
|
||||
|
||||
@@ -18,6 +18,8 @@ import { colorSwatchStyle, colorVariantThumb } from '@/utils/colorSwatch'
|
||||
import { categoryIconOf, usageCategoryIconKey } from '@/utils/categoryIcons'
|
||||
import { useSlotBanners } from '@/composables/useSlotBanners'
|
||||
import { useTouchSwipe } from '@/composables/useTouchSwipe'
|
||||
import { isProductUnavailable } from '@/utils/productAvailability'
|
||||
import { followBannerLink } from '@/utils/bannerLink'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@@ -108,11 +110,16 @@ function seasonIconKey(item: SeasonCategory) {
|
||||
function goBannerCta() {
|
||||
const link = bannerCopy.value.ctaLink?.trim()
|
||||
if (!link) return
|
||||
if (/^https?:\/\//i.test(link)) {
|
||||
window.location.assign(link)
|
||||
return
|
||||
}
|
||||
router.push(link)
|
||||
followBannerLink(link, router)
|
||||
}
|
||||
|
||||
const bannerImageLink = computed(() => productsHero.value?.bannerLink?.trim() || '')
|
||||
|
||||
function onCatBannerClick(event: MouseEvent) {
|
||||
if (!bannerImageLink.value) return
|
||||
const target = event.target as HTMLElement
|
||||
if (target.closest('.cat-banner__cta, .cat-banner__dots')) return
|
||||
followBannerLink(bannerImageLink.value, router)
|
||||
}
|
||||
|
||||
const bannerCopy = computed(() => {
|
||||
@@ -494,8 +501,12 @@ onUnmounted(() => {
|
||||
<template v-else>
|
||||
<section
|
||||
class="cat-banner"
|
||||
:class="{ 'cat-banner--photo': !!bannerImageUrl }"
|
||||
:class="{
|
||||
'cat-banner--photo': !!bannerImageUrl,
|
||||
'cat-banner--linked': !!bannerImageLink,
|
||||
}"
|
||||
:style="bannerStyle"
|
||||
@click="onCatBannerClick"
|
||||
@touchstart.passive="onBannerTouchStart"
|
||||
@touchend.passive="onBannerTouchEnd"
|
||||
>
|
||||
@@ -513,7 +524,7 @@ onUnmounted(() => {
|
||||
v-if="bannerCopy.ctaLabel"
|
||||
type="button"
|
||||
class="cat-banner__cta"
|
||||
@click="goBannerCta"
|
||||
@click.stop="goBannerCta"
|
||||
>
|
||||
{{ bannerCopy.ctaLabel }}
|
||||
</button>
|
||||
@@ -539,7 +550,7 @@ onUnmounted(() => {
|
||||
:class="{ 'cat-banner__dot--active': i === productsHeroIndex }"
|
||||
:aria-label="item.title"
|
||||
:aria-selected="i === productsHeroIndex"
|
||||
@click="setProductsHeroSlide(i)"
|
||||
@click.stop="setProductsHeroSlide(i)"
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
@@ -637,7 +648,8 @@ onUnmounted(() => {
|
||||
<div class="product-item__head">
|
||||
<div class="product-item__title">
|
||||
<strong>{{ item.name }}</strong>
|
||||
<span v-if="item.isNew" class="new-tag">جدید</span>
|
||||
<span v-if="isProductUnavailable(item)" class="new-tag new-tag--oos">ناموجود</span>
|
||||
<span v-else-if="item.isNew" class="new-tag">جدید</span>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
@@ -863,6 +875,10 @@ onUnmounted(() => {
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.cat-banner--linked {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cat-banner {
|
||||
position: relative;
|
||||
touch-action: pan-y;
|
||||
@@ -1173,6 +1189,11 @@ onUnmounted(() => {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.new-tag--oos {
|
||||
background: rgba(185, 28, 28, 0.12);
|
||||
color: #b91c1c;
|
||||
}
|
||||
|
||||
.bookmark {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
|
||||
@@ -18,7 +18,6 @@ defineProps<{
|
||||
itemCount: number
|
||||
totalMeterage: number
|
||||
remainingCapacity: number
|
||||
toast: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -69,10 +68,12 @@ const emit = defineEmits<{
|
||||
<div class="product-desktop-card__head">
|
||||
<h3>{{ product.name }}</h3>
|
||||
<span>کد: {{ product.code }}</span>
|
||||
<span v-if="!product.isActive" class="product-oos">ناموجود</span>
|
||||
</div>
|
||||
<p class="product-desktop-card__meta">
|
||||
حداقل سفارش: {{ formatMeterage(product.minMeterage) }}
|
||||
</p>
|
||||
<template v-if="product.isActive">
|
||||
<div class="meterage-input-row">
|
||||
<button
|
||||
type="button"
|
||||
@@ -110,6 +111,7 @@ const emit = defineEmits<{
|
||||
<IconCart :size="16" />
|
||||
افزودن
|
||||
</BaseButton>
|
||||
</template>
|
||||
<p v-if="errors[product.id]" class="error-text">{{ errors[product.id] }}</p>
|
||||
</div>
|
||||
</article>
|
||||
@@ -145,7 +147,6 @@ const emit = defineEmits<{
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<div v-if="toast" class="product-desktop-toast">{{ toast }}</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -254,6 +255,11 @@ const emit = defineEmits<{
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.product-oos {
|
||||
color: #b91c1c;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.product-desktop-card__meta {
|
||||
margin: 0 0 10px;
|
||||
font-size: 0.8125rem;
|
||||
@@ -299,20 +305,6 @@ const emit = defineEmits<{
|
||||
margin: 6px 0 0;
|
||||
}
|
||||
|
||||
.product-desktop-toast {
|
||||
position: fixed;
|
||||
bottom: 24px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
background: var(--color-text);
|
||||
color: var(--color-bg);
|
||||
padding: 10px 20px;
|
||||
border-radius: var(--radius-sm);
|
||||
z-index: 150;
|
||||
box-shadow: var(--shadow-md);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.desktop-summary-panel__action :deep(.btn) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -17,7 +17,6 @@ defineProps<{
|
||||
errors: Record<string, string>
|
||||
totalMeterage: number
|
||||
itemCount: number
|
||||
toast: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -59,9 +58,10 @@ const emit = defineEmits<{
|
||||
<div class="product-mobile-card__head">
|
||||
<h3>{{ product.name }}</h3>
|
||||
<span>کد: {{ product.code }}</span>
|
||||
<span v-if="!product.isActive" class="product-oos">ناموجود</span>
|
||||
</div>
|
||||
<p class="product-mobile-card__meta">حداقل سفارش: {{ formatMeterage(product.minMeterage) }}</p>
|
||||
<div class="meterage-input-row">
|
||||
<div v-if="product.isActive" class="meterage-input-row">
|
||||
<button
|
||||
type="button"
|
||||
class="qty-btn"
|
||||
@@ -94,7 +94,7 @@ const emit = defineEmits<{
|
||||
+
|
||||
</button>
|
||||
</div>
|
||||
<BaseButton block @click="emit('add', product.id)">افزودن</BaseButton>
|
||||
<BaseButton v-if="product.isActive" block @click="emit('add', product.id)">افزودن</BaseButton>
|
||||
<p v-if="errors[product.id]" class="error-text">{{ errors[product.id] }}</p>
|
||||
</article>
|
||||
</div>
|
||||
@@ -106,8 +106,6 @@ const emit = defineEmits<{
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-if="toast" class="toast">{{ toast }}</div>
|
||||
|
||||
<div v-if="itemCount > 0" class="sticky-footer">
|
||||
<CartMeterageFooter
|
||||
:total-meterage="totalMeterage"
|
||||
@@ -186,6 +184,11 @@ const emit = defineEmits<{
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.product-oos {
|
||||
color: #b91c1c !important;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.product-mobile-card__meta {
|
||||
margin: 0 0 12px;
|
||||
font-size: 0.8125rem;
|
||||
@@ -225,19 +228,4 @@ const emit = defineEmits<{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.toast {
|
||||
position: fixed;
|
||||
bottom: calc(var(--nav-height) + 72px);
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
background: var(--color-text);
|
||||
color: var(--color-bg);
|
||||
padding: 10px 20px;
|
||||
border-radius: var(--radius-sm);
|
||||
z-index: 150;
|
||||
box-shadow: var(--shadow-md);
|
||||
font-size: 0.875rem;
|
||||
white-space: nowrap;
|
||||
max-width: calc(100% - 32px);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -262,7 +262,7 @@ async function save() {
|
||||
|
||||
<div class="profile-edit__actions">
|
||||
<BaseButton class="profile-edit__save" :loading="saving" @click="save">
|
||||
ذخیره تغییرات
|
||||
ثبت تغییرات
|
||||
</BaseButton>
|
||||
<p v-if="saved" class="profile-edit__saved">ذخیره شد ✓</p>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user