changes 1
This commit is contained in:
@@ -261,7 +261,7 @@
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 0.875rem;
|
||||
min-width: 720px;
|
||||
min-width: 860px;
|
||||
}
|
||||
|
||||
.orders-table th {
|
||||
@@ -297,6 +297,12 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.orders-table__fabric {
|
||||
font-weight: 600;
|
||||
max-width: 240px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.orders-table__amount {
|
||||
font-weight: 600;
|
||||
font-variant-numeric: tabular-nums;
|
||||
|
||||
@@ -47,6 +47,7 @@ function toProductCard(item: ProductSuggestionDto): CatalogProductCard {
|
||||
season: 'all_season',
|
||||
widthCm: item.widthCm ?? 0,
|
||||
composition: item.composition ?? '',
|
||||
weightGrams: item.weightGrams,
|
||||
colors: item.colors ?? (item.color ? [item.color] : []),
|
||||
colorImages: item.colorImages,
|
||||
tags: [],
|
||||
@@ -84,6 +85,11 @@ function widthText(item: ProductSuggestionDto) {
|
||||
if (item.widthCm) return `${formatNumber(item.widthCm)} cm`
|
||||
return '—'
|
||||
}
|
||||
|
||||
function weightText(item: ProductSuggestionDto) {
|
||||
if (item.weightGrams) return `${formatNumber(item.weightGrams)} گرم`
|
||||
return '—'
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -182,6 +188,20 @@ function widthText(item: ProductSuggestionDto) {
|
||||
</span>
|
||||
</div>
|
||||
<div class="suggest-product__spec-divider" aria-hidden="true" />
|
||||
<div class="suggest-product__spec">
|
||||
<span class="suggest-product__spec-icon" aria-hidden="true">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
||||
<path d="M12 3v18" stroke-linecap="round" />
|
||||
<path d="M8 7h8l-1.2 10.2a2 2 0 0 1-2 1.8h-1.6a2 2 0 0 1-2-1.8L8 7Z" stroke-linejoin="round" />
|
||||
<path d="M7 7h10" stroke-linecap="round" />
|
||||
</svg>
|
||||
</span>
|
||||
<span class="suggest-product__spec-copy">
|
||||
<span class="suggest-product__spec-key">وزن</span>
|
||||
<span class="suggest-product__spec-val">{{ weightText(item) }}</span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="suggest-product__spec-divider" aria-hidden="true" />
|
||||
<div class="suggest-product__spec">
|
||||
<span class="suggest-product__spec-icon" aria-hidden="true">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
||||
@@ -298,8 +318,8 @@ function widthText(item: ProductSuggestionDto) {
|
||||
}
|
||||
|
||||
.suggest-product {
|
||||
flex: 0 0 min(82vw, 268px);
|
||||
width: min(82vw, 268px);
|
||||
flex: 0 0 min(88vw, 312px);
|
||||
width: min(88vw, 312px);
|
||||
scroll-snap-align: start;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 16px;
|
||||
@@ -397,9 +417,9 @@ function widthText(item: ProductSuggestionDto) {
|
||||
|
||||
.suggest-product__specs {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto 1fr;
|
||||
grid-template-columns: minmax(0, 1.15fr) auto minmax(0, 0.9fr) auto minmax(0, 0.9fr);
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
margin-bottom: 12px;
|
||||
padding: 8px 0;
|
||||
}
|
||||
@@ -407,7 +427,7 @@ function widthText(item: ProductSuggestionDto) {
|
||||
.suggest-product__spec {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 6px;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
font-size: 0.68rem;
|
||||
color: var(--color-text-muted);
|
||||
@@ -436,8 +456,9 @@ function widthText(item: ProductSuggestionDto) {
|
||||
}
|
||||
|
||||
.suggest-product__spec-icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
margin-top: 1px;
|
||||
flex-shrink: 0;
|
||||
color: #9aa3ad;
|
||||
display: grid;
|
||||
@@ -445,8 +466,8 @@ function widthText(item: ProductSuggestionDto) {
|
||||
}
|
||||
|
||||
.suggest-product__spec-icon svg {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
|
||||
.suggest-product__spec-divider {
|
||||
@@ -505,8 +526,8 @@ html.dark .suggest-panel__all {
|
||||
}
|
||||
|
||||
.suggest-product {
|
||||
flex: 0 0 min(36%, 280px);
|
||||
width: min(36%, 280px);
|
||||
flex: 0 0 min(36%, 320px);
|
||||
width: min(36%, 320px);
|
||||
}
|
||||
|
||||
.suggest-product__media {
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||
import { computed, onMounted, onUnmounted, ref, watch, nextTick } from 'vue'
|
||||
import { onClickOutside } from '@vueuse/core'
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import IconHeadset from '@/components/icons/IconHeadset.vue'
|
||||
import IconPhone from '@/components/icons/IconPhone.vue'
|
||||
import IconMail from '@/components/icons/IconMail.vue'
|
||||
import { usePublicContact } from '@/composables/usePublicContact'
|
||||
import type { SupportLinkKind } from '@/utils/supportLinks'
|
||||
|
||||
const POS_KEY = 'nademitex.supportFab.position'
|
||||
const DRAG_THRESHOLD = 8
|
||||
const EDGE = 10
|
||||
|
||||
type FabAnchor = { bottom: number; inlineEnd: number }
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
/** فاصله از نوار پایین موبایل */
|
||||
@@ -21,17 +23,202 @@ const { load, loaded, supportLinks, hasSupportLinks } = usePublicContact()
|
||||
const open = ref(false)
|
||||
const rootRef = ref<HTMLElement | null>(null)
|
||||
const panelRef = ref<HTMLElement | null>(null)
|
||||
const placed = ref<FabAnchor | null>(null)
|
||||
const dragging = ref(false)
|
||||
|
||||
const LINK_ICON: Record<SupportLinkKind, string> = {
|
||||
whatsapp: 'vuesax-linear:message',
|
||||
telegram: 'vuesax-linear:sms',
|
||||
instagram: 'vuesax-linear:category',
|
||||
phone: 'call',
|
||||
email: 'mail',
|
||||
let pointerId: number | null = null
|
||||
let originX = 0
|
||||
let originY = 0
|
||||
let originBottom = 0
|
||||
let originInlineEnd = 0
|
||||
let dragMoved = false
|
||||
let suppressClick = false
|
||||
let suppressTimer = 0
|
||||
let fitFrame = 0
|
||||
let prevBodyCursor = ''
|
||||
let prevUserSelect = ''
|
||||
|
||||
const BADGE_KINDS = new Set<SupportLinkKind>(['email', 'telegram'])
|
||||
|
||||
const widgetStyle = computed(() => {
|
||||
if (!placed.value) return undefined
|
||||
return {
|
||||
bottom: `${placed.value.bottom}px`,
|
||||
insetInlineEnd: `${placed.value.inlineEnd}px`,
|
||||
}
|
||||
})
|
||||
|
||||
function isRtl() {
|
||||
return document.documentElement.dir === 'rtl'
|
||||
}
|
||||
|
||||
function readAnchor(el: HTMLElement): FabAnchor {
|
||||
const rect = el.getBoundingClientRect()
|
||||
return {
|
||||
bottom: window.innerHeight - rect.bottom,
|
||||
inlineEnd: isRtl() ? rect.left : window.innerWidth - rect.right,
|
||||
}
|
||||
}
|
||||
|
||||
function clampAnchor(anchor: FabAnchor, el: HTMLElement): FabAnchor {
|
||||
const rect = el.getBoundingClientRect()
|
||||
const maxBottom = Math.max(EDGE, window.innerHeight - rect.height - EDGE)
|
||||
const maxInlineEnd = Math.max(EDGE, window.innerWidth - rect.width - EDGE)
|
||||
return {
|
||||
bottom: Math.min(Math.max(anchor.bottom, EDGE), maxBottom),
|
||||
inlineEnd: Math.min(Math.max(anchor.inlineEnd, EDGE), maxInlineEnd),
|
||||
}
|
||||
}
|
||||
|
||||
function readStored(): FabAnchor | null {
|
||||
try {
|
||||
const raw = localStorage.getItem(POS_KEY)
|
||||
if (!raw) return null
|
||||
const data = JSON.parse(raw) as Partial<FabAnchor>
|
||||
if (typeof data.bottom !== 'number' || typeof data.inlineEnd !== 'number') return null
|
||||
if (!Number.isFinite(data.bottom) || !Number.isFinite(data.inlineEnd)) return null
|
||||
return { bottom: data.bottom, inlineEnd: data.inlineEnd }
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
function persist(anchor: FabAnchor) {
|
||||
try {
|
||||
localStorage.setItem(POS_KEY, JSON.stringify(anchor))
|
||||
} catch {
|
||||
/* موقعیت فقط برای همین نشست میماند */
|
||||
}
|
||||
}
|
||||
|
||||
function restorePosition() {
|
||||
const saved = readStored()
|
||||
const el = rootRef.value
|
||||
if (!saved || !el || el.getBoundingClientRect().width === 0) return
|
||||
placed.value = clampAnchor(saved, el)
|
||||
}
|
||||
|
||||
function equalizePills() {
|
||||
const root = rootRef.value
|
||||
if (!root) return
|
||||
const pills = [...root.querySelectorAll<HTMLElement>('.support-widget__link, .support-widget__fab')]
|
||||
if (!pills.length) return
|
||||
for (const pill of pills) pill.style.width = 'max-content'
|
||||
const width = Math.ceil(Math.max(...pills.map((pill) => pill.getBoundingClientRect().width)))
|
||||
for (const pill of pills) pill.style.width = ''
|
||||
root.style.setProperty('--support-pill-width', `${width}px`)
|
||||
}
|
||||
|
||||
function fitPanel() {
|
||||
const panel = panelRef.value
|
||||
const root = rootRef.value
|
||||
if (!root || !open.value) return
|
||||
|
||||
root.style.transform = ''
|
||||
if (panel) {
|
||||
panel.style.maxHeight = ''
|
||||
panel.style.overflowY = ''
|
||||
}
|
||||
equalizePills()
|
||||
|
||||
const rect = root.getBoundingClientRect()
|
||||
const overflowLeft = EDGE - rect.left
|
||||
const overflowRight = rect.right - (window.innerWidth - EDGE)
|
||||
let shift = 0
|
||||
if (overflowLeft > 0 && overflowRight > 0) shift = overflowLeft
|
||||
else {
|
||||
if (overflowLeft > 0) shift += overflowLeft
|
||||
if (overflowRight > 0) shift -= overflowRight
|
||||
}
|
||||
if (shift) root.style.transform = `translateX(${shift}px)`
|
||||
|
||||
if (!panel) return
|
||||
const panelRect = panel.getBoundingClientRect()
|
||||
if (panelRect.top < EDGE) {
|
||||
const nextHeight = Math.max(80, panelRect.height - (EDGE - panelRect.top))
|
||||
panel.style.maxHeight = `${Math.min(nextHeight, 360)}px`
|
||||
panel.style.overflowY = 'auto'
|
||||
}
|
||||
}
|
||||
|
||||
function scheduleFitPanel() {
|
||||
if (fitFrame) return
|
||||
fitFrame = window.requestAnimationFrame(() => {
|
||||
fitFrame = 0
|
||||
fitPanel()
|
||||
})
|
||||
}
|
||||
|
||||
function onFabPointerDown(event: PointerEvent) {
|
||||
if (event.button !== 0) return
|
||||
const el = rootRef.value
|
||||
const handle = event.currentTarget
|
||||
if (!el || !(handle instanceof HTMLElement)) return
|
||||
pointerId = event.pointerId
|
||||
dragMoved = false
|
||||
originX = event.clientX
|
||||
originY = event.clientY
|
||||
el.style.transform = ''
|
||||
const anchor = readAnchor(el)
|
||||
originBottom = anchor.bottom
|
||||
originInlineEnd = anchor.inlineEnd
|
||||
handle.setPointerCapture(event.pointerId)
|
||||
}
|
||||
|
||||
function onFabPointerMove(event: PointerEvent) {
|
||||
if (pointerId !== event.pointerId || !rootRef.value) return
|
||||
const dx = event.clientX - originX
|
||||
const dy = event.clientY - originY
|
||||
if (!dragMoved) {
|
||||
if (Math.hypot(dx, dy) < DRAG_THRESHOLD) return
|
||||
dragMoved = true
|
||||
dragging.value = true
|
||||
}
|
||||
const next = clampAnchor(
|
||||
{
|
||||
bottom: originBottom - dy,
|
||||
inlineEnd: isRtl() ? originInlineEnd + dx : originInlineEnd - dx,
|
||||
},
|
||||
rootRef.value,
|
||||
)
|
||||
placed.value = next
|
||||
originX = event.clientX
|
||||
originY = event.clientY
|
||||
originBottom = next.bottom
|
||||
originInlineEnd = next.inlineEnd
|
||||
}
|
||||
|
||||
function finishPointer(event: PointerEvent) {
|
||||
if (pointerId !== event.pointerId) return
|
||||
const handle = event.currentTarget
|
||||
if (handle instanceof HTMLElement && handle.hasPointerCapture(event.pointerId)) {
|
||||
handle.releasePointerCapture(event.pointerId)
|
||||
}
|
||||
pointerId = null
|
||||
dragging.value = false
|
||||
if (open.value) scheduleFitPanel()
|
||||
if (!dragMoved || !placed.value) return
|
||||
persist(placed.value)
|
||||
suppressClick = true
|
||||
window.clearTimeout(suppressTimer)
|
||||
suppressTimer = window.setTimeout(() => {
|
||||
suppressClick = false
|
||||
}, 400)
|
||||
}
|
||||
|
||||
function onFabClick() {
|
||||
if (suppressClick) {
|
||||
suppressClick = false
|
||||
window.clearTimeout(suppressTimer)
|
||||
return
|
||||
}
|
||||
toggleOpen()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void load()
|
||||
document.addEventListener('keydown', onEscape)
|
||||
window.addEventListener('resize', onResize)
|
||||
})
|
||||
|
||||
onClickOutside(rootRef, () => {
|
||||
@@ -56,14 +243,56 @@ function onEscape(event: KeyboardEvent) {
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => document.addEventListener('keydown', onEscape))
|
||||
onUnmounted(() => document.removeEventListener('keydown', onEscape))
|
||||
function onResize() {
|
||||
const el = rootRef.value
|
||||
if (placed.value && el) placed.value = clampAnchor(placed.value, el)
|
||||
if (open.value) scheduleFitPanel()
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
document.removeEventListener('keydown', onEscape)
|
||||
window.removeEventListener('resize', onResize)
|
||||
window.clearTimeout(suppressTimer)
|
||||
if (fitFrame) window.cancelAnimationFrame(fitFrame)
|
||||
if (dragging.value) {
|
||||
document.body.style.cursor = prevBodyCursor
|
||||
document.body.style.userSelect = prevUserSelect
|
||||
}
|
||||
})
|
||||
|
||||
const showWidget = computed(() => loaded.value && hasSupportLinks.value)
|
||||
|
||||
watch(hasSupportLinks, (ok) => {
|
||||
if (!ok) open.value = false
|
||||
})
|
||||
|
||||
const showWidget = computed(() => loaded.value && hasSupportLinks.value)
|
||||
watch(showWidget, (show) => {
|
||||
if (!show) return
|
||||
void nextTick(() => requestAnimationFrame(() => restorePosition()))
|
||||
})
|
||||
|
||||
watch(open, (isOpen) => {
|
||||
if (!isOpen) {
|
||||
if (rootRef.value) {
|
||||
rootRef.value.style.transform = ''
|
||||
rootRef.value.style.removeProperty('--support-pill-width')
|
||||
}
|
||||
return
|
||||
}
|
||||
void nextTick(() => fitPanel())
|
||||
})
|
||||
|
||||
watch(dragging, (isDragging) => {
|
||||
if (isDragging) {
|
||||
prevBodyCursor = document.body.style.cursor
|
||||
prevUserSelect = document.body.style.userSelect
|
||||
document.body.style.cursor = 'grabbing'
|
||||
document.body.style.userSelect = 'none'
|
||||
return
|
||||
}
|
||||
document.body.style.cursor = prevBodyCursor
|
||||
document.body.style.userSelect = prevUserSelect
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -72,49 +301,72 @@ const showWidget = computed(() => loaded.value && hasSupportLinks.value)
|
||||
ref="rootRef"
|
||||
class="support-widget"
|
||||
:class="{ 'support-widget--above-nav': props.aboveBottomNav }"
|
||||
:style="widgetStyle"
|
||||
>
|
||||
<Transition name="support-pop">
|
||||
<Transition name="support-pop" @after-enter="fitPanel">
|
||||
<div
|
||||
v-if="open"
|
||||
ref="panelRef"
|
||||
class="support-widget__panel"
|
||||
role="dialog"
|
||||
aria-labelledby="support-widget-title"
|
||||
aria-label="پشتیبانی"
|
||||
aria-modal="false"
|
||||
>
|
||||
<header class="support-widget__head">
|
||||
<h2 id="support-widget-title" class="support-widget__title">پشتیبانی</h2>
|
||||
<p class="support-widget__lead">از راههای زیر با ما در ارتباط باشید</p>
|
||||
<button
|
||||
type="button"
|
||||
class="support-widget__close"
|
||||
aria-label="بستن"
|
||||
@click="open = false"
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</header>
|
||||
<ul class="support-widget__list">
|
||||
<li v-for="link in supportLinks" :key="link.kind">
|
||||
<a
|
||||
class="support-widget__link"
|
||||
:href="link.href"
|
||||
:title="link.subtitle"
|
||||
:aria-label="link.subtitle ? `${link.label}، ${link.subtitle}` : link.label"
|
||||
:target="link.kind === 'phone' || link.kind === 'email' ? undefined : '_blank'"
|
||||
:rel="link.kind === 'phone' || link.kind === 'email' ? undefined : 'noopener noreferrer'"
|
||||
>
|
||||
<span class="support-widget__icon" aria-hidden="true">
|
||||
<IconPhone v-if="link.kind === 'phone'" :size="20" color="var(--color-primary)" />
|
||||
<IconMail v-else-if="link.kind === 'email'" :size="20" color="var(--color-primary)" />
|
||||
<BasicIcon
|
||||
v-else
|
||||
:icon="LINK_ICON[link.kind]"
|
||||
:size="20"
|
||||
color="var(--color-primary)"
|
||||
/>
|
||||
</span>
|
||||
<span class="support-widget__link-text">
|
||||
<span class="support-widget__link-label">{{ link.label }}</span>
|
||||
<span class="support-widget__link-sub" dir="ltr">{{ link.subtitle }}</span>
|
||||
<span class="support-widget__link-label">{{ link.label }}</span>
|
||||
<span
|
||||
class="support-widget__mark"
|
||||
:class="{ 'support-widget__mark--badge': BADGE_KINDS.has(link.kind) }"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<svg v-if="link.kind === 'phone'" viewBox="0 0 24 24" width="18" height="18" fill="none">
|
||||
<path
|
||||
d="M8.2 4.8h2l1.1 2.6-1.5 1.1a11 11 0 0 0 5.7 5.7l1.1-1.5 2.6 1.1v2a1.6 1.6 0 0 1-1.7 1.6A13.4 13.4 0 0 1 6.6 6.5a1.6 1.6 0 0 1 1.6-1.7Z"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.6"
|
||||
stroke-linejoin="round"
|
||||
stroke-linecap="round"
|
||||
/>
|
||||
</svg>
|
||||
<svg v-else-if="link.kind === 'email'" viewBox="0 0 24 24" width="12" height="12" fill="none">
|
||||
<path d="M4 7.5h16v10H4v-10Z" stroke="currentColor" stroke-width="2" stroke-linejoin="round" />
|
||||
<path
|
||||
d="m4.5 8 7.5 5.5L19.5 8"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
<svg v-else-if="link.kind === 'telegram'" viewBox="0 0 24 24" width="12" height="12" fill="none">
|
||||
<path
|
||||
d="M4.5 11.5 19 6.2l-4.8 12.2-3.2-4.6-6.5-2.3Z"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.8"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
<svg v-else-if="link.kind === 'instagram'" viewBox="0 0 24 24" width="18" height="18" fill="none">
|
||||
<rect x="4.5" y="4.5" width="15" height="15" rx="4" stroke="currentColor" stroke-width="1.6" />
|
||||
<circle cx="12" cy="12" r="3.2" stroke="currentColor" stroke-width="1.6" />
|
||||
</svg>
|
||||
<svg v-else viewBox="0 0 24 24" width="18" height="18" fill="none">
|
||||
<path
|
||||
d="M12 5.25A6.75 6.75 0 0 0 6.1 16.2c.2.36.26.78.16 1.18l-.4 1.58a.55.55 0 0 0 .68.67l1.58-.4c.4-.1.82-.04 1.18.16A6.75 6.75 0 1 0 12 5.25Z"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.6"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
@@ -125,14 +377,31 @@ const showWidget = computed(() => loaded.value && hasSupportLinks.value)
|
||||
<button
|
||||
type="button"
|
||||
class="support-widget__fab"
|
||||
:class="{ 'support-widget__fab--open': open }"
|
||||
:class="{
|
||||
'support-widget__fab--open': open,
|
||||
'support-widget__fab--dragging': dragging,
|
||||
}"
|
||||
aria-label="پشتیبانی"
|
||||
:aria-expanded="open"
|
||||
aria-haspopup="dialog"
|
||||
@click="toggleOpen"
|
||||
@pointerdown="onFabPointerDown"
|
||||
@pointermove="onFabPointerMove"
|
||||
@pointerup="finishPointer"
|
||||
@pointercancel="finishPointer"
|
||||
@click="onFabClick"
|
||||
@keydown="onFabKeydown"
|
||||
@contextmenu.prevent
|
||||
>
|
||||
<IconHeadset :size="26" color="#fff" />
|
||||
<span class="support-widget__fab-label">پشتیبانی</span>
|
||||
<svg class="support-widget__fab-icon" viewBox="0 0 24 24" width="18" height="18" aria-hidden="true">
|
||||
<path
|
||||
d="M12 5.25A6.75 6.75 0 0 0 6.1 16.2c.2.36.26.78.16 1.18l-.4 1.58a.55.55 0 0 0 .68.67l1.58-.4c.4-.1.82-.04 1.18.16A6.75 6.75 0 1 0 12 5.25Z"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.6"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -143,10 +412,12 @@ const showWidget = computed(() => loaded.value && hasSupportLinks.value)
|
||||
z-index: 110;
|
||||
inset-inline-end: 16px;
|
||||
bottom: calc(16px + env(safe-area-inset-bottom, 0));
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
gap: 10px;
|
||||
display: grid;
|
||||
grid-auto-flow: row;
|
||||
justify-items: stretch;
|
||||
row-gap: 8px;
|
||||
width: max-content;
|
||||
max-width: calc(100vw - 20px);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
@@ -170,23 +441,51 @@ const showWidget = computed(() => loaded.value && hasSupportLinks.value)
|
||||
}
|
||||
|
||||
.support-widget__fab {
|
||||
width: 52px;
|
||||
height: 52px;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
background: var(--color-primary);
|
||||
color: #fff;
|
||||
display: inline-flex;
|
||||
width: min(var(--support-pill-width, max-content), calc(100vw - 20px));
|
||||
height: 38px;
|
||||
padding-inline: 14px 11px;
|
||||
border: 1px solid rgba(21, 32, 51, 0.06);
|
||||
border-radius: 999px;
|
||||
background: #fff;
|
||||
color: #152033;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 6px 20px rgba(15, 23, 42, 0.22);
|
||||
transition: transform 0.15s ease, box-shadow 0.15s ease;
|
||||
gap: 8px;
|
||||
cursor: grab;
|
||||
box-shadow:
|
||||
0 1px 2px rgba(15, 23, 42, 0.05),
|
||||
0 8px 22px rgba(15, 23, 42, 0.12);
|
||||
font-family: inherit;
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 600;
|
||||
line-height: 1;
|
||||
touch-action: none;
|
||||
user-select: none;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
transition:
|
||||
background 0.15s ease,
|
||||
box-shadow 0.15s ease;
|
||||
}
|
||||
|
||||
.support-widget__fab:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.26);
|
||||
.support-widget__fab-label {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.support-widget__fab-icon {
|
||||
display: block;
|
||||
flex-shrink: 0;
|
||||
margin-inline-start: auto;
|
||||
color: #1fc16b;
|
||||
}
|
||||
|
||||
.support-widget__fab:hover:not(.support-widget__fab--dragging) {
|
||||
box-shadow:
|
||||
0 2px 4px rgba(15, 23, 42, 0.06),
|
||||
0 12px 28px rgba(15, 23, 42, 0.14);
|
||||
}
|
||||
|
||||
.support-widget__fab:active:not(.support-widget__fab--dragging) {
|
||||
background: #f3f5f7;
|
||||
}
|
||||
|
||||
.support-widget__fab:focus-visible {
|
||||
@@ -195,118 +494,123 @@ const showWidget = computed(() => loaded.value && hasSupportLinks.value)
|
||||
}
|
||||
|
||||
.support-widget__fab--open {
|
||||
transform: scale(0.96);
|
||||
background: #f3f5f7;
|
||||
}
|
||||
|
||||
.support-widget__fab--dragging {
|
||||
cursor: grabbing;
|
||||
box-shadow:
|
||||
0 6px 16px rgba(15, 23, 42, 0.1),
|
||||
0 16px 36px rgba(15, 23, 42, 0.16);
|
||||
}
|
||||
|
||||
:global(html.dark) .support-widget__fab {
|
||||
background: #fff;
|
||||
color: #152033;
|
||||
box-shadow:
|
||||
0 1px 2px rgba(0, 0, 0, 0.28),
|
||||
0 12px 30px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
:global(html.dark) .support-widget__fab--open,
|
||||
:global(html.dark) .support-widget__fab:active:not(.support-widget__fab--dragging) {
|
||||
background: #eef1f4;
|
||||
}
|
||||
|
||||
.support-widget__panel {
|
||||
width: min(300px, calc(100vw - 32px));
|
||||
padding: 14px 14px 10px;
|
||||
border-radius: 16px;
|
||||
border: 1px solid var(--color-border);
|
||||
background: var(--color-surface);
|
||||
box-shadow: var(--shadow-card, 0 12px 40px rgba(15, 23, 42, 0.14));
|
||||
transform-origin: bottom right;
|
||||
}
|
||||
|
||||
.support-widget__head {
|
||||
position: relative;
|
||||
padding-inline-end: 28px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.support-widget__title {
|
||||
margin: 0;
|
||||
font-size: 1rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.support-widget__lead {
|
||||
margin: 4px 0 0;
|
||||
font-size: 0.75rem;
|
||||
color: var(--color-text-muted);
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.support-widget__close {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
inset-inline-end: 0;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--color-text-muted);
|
||||
font-size: 1.25rem;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.support-widget__close:focus-visible {
|
||||
outline: 2px solid var(--color-primary);
|
||||
outline-offset: 2px;
|
||||
box-shadow: none;
|
||||
overflow: visible;
|
||||
transform-origin: bottom center;
|
||||
}
|
||||
|
||||
.support-widget__list {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.support-widget__list > li {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.support-widget__link {
|
||||
width: min(var(--support-pill-width, max-content), calc(100vw - 20px));
|
||||
height: 38px;
|
||||
padding-inline: 14px 11px;
|
||||
border: 1px solid rgba(21, 32, 51, 0.06);
|
||||
border-radius: 999px;
|
||||
background: #fff;
|
||||
color: #152033;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 10px 12px;
|
||||
border-radius: 12px;
|
||||
gap: 8px;
|
||||
text-decoration: none;
|
||||
color: var(--color-text);
|
||||
background: var(--color-elevated, #f6f7f8);
|
||||
transition: background 0.12s ease;
|
||||
min-height: 48px;
|
||||
box-shadow:
|
||||
0 1px 2px rgba(15, 23, 42, 0.05),
|
||||
0 8px 22px rgba(15, 23, 42, 0.12);
|
||||
font-family: inherit;
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 600;
|
||||
line-height: 1;
|
||||
white-space: nowrap;
|
||||
transition:
|
||||
background 0.15s ease,
|
||||
box-shadow 0.15s ease;
|
||||
}
|
||||
|
||||
.support-widget__link:hover {
|
||||
background: var(--color-primary-soft);
|
||||
box-shadow:
|
||||
0 2px 4px rgba(15, 23, 42, 0.06),
|
||||
0 12px 28px rgba(15, 23, 42, 0.14);
|
||||
}
|
||||
|
||||
.support-widget__link:active {
|
||||
background: #f3f5f7;
|
||||
}
|
||||
|
||||
.support-widget__link:focus-visible {
|
||||
outline: 2px solid var(--color-primary);
|
||||
outline-offset: 2px;
|
||||
outline-offset: 3px;
|
||||
}
|
||||
|
||||
.support-widget__icon {
|
||||
flex-shrink: 0;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 50%;
|
||||
background: var(--color-surface);
|
||||
.support-widget__link-label {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.support-widget__mark {
|
||||
display: inline-flex;
|
||||
flex-shrink: 0;
|
||||
margin-inline-start: auto;
|
||||
color: #1fc16b;
|
||||
}
|
||||
|
||||
.support-widget__mark--badge {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 50%;
|
||||
background: #14b8a6;
|
||||
color: #fff;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.support-widget__link-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
:global(html.dark) .support-widget__link {
|
||||
background: #fff;
|
||||
color: #152033;
|
||||
box-shadow:
|
||||
0 1px 2px rgba(0, 0, 0, 0.28),
|
||||
0 12px 30px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.support-widget__link-label {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.support-widget__link-sub {
|
||||
font-size: 0.75rem;
|
||||
color: var(--color-text-muted);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
:global(html.dark) .support-widget__link:active {
|
||||
background: #eef1f4;
|
||||
}
|
||||
|
||||
.support-pop-enter-active,
|
||||
@@ -321,15 +625,4 @@ const showWidget = computed(() => loaded.value && hasSupportLinks.value)
|
||||
opacity: 0;
|
||||
transform: translateY(8px) scale(0.97);
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.support-widget__panel {
|
||||
position: fixed;
|
||||
inset-inline: 12px;
|
||||
bottom: calc(var(--nav-height, 56px) + 72px + env(safe-area-inset-bottom, 0));
|
||||
width: auto;
|
||||
max-height: min(50vh, 360px);
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -3,7 +3,6 @@ import { useRouter } from 'vue-router'
|
||||
import { useCartStore } from '@/stores/cart'
|
||||
import { useOrderStore } from '@/stores/order'
|
||||
import { confirm } from '@/composables/useConfirm'
|
||||
import { addressesApi, type SavedAddress } from '@/services/addresses'
|
||||
|
||||
export function useCartPage() {
|
||||
const router = useRouter()
|
||||
@@ -12,11 +11,6 @@ export function useCartPage() {
|
||||
const showFullDialog = ref(false)
|
||||
const submitting = ref(false)
|
||||
const submitError = ref('')
|
||||
const addressPickerOpen = ref(false)
|
||||
const addresses = ref<SavedAddress[]>([])
|
||||
const selectedAddressId = ref('')
|
||||
const newAddress = ref('')
|
||||
const addressBusy = ref(false)
|
||||
|
||||
const items = computed(() => cartStore.activeCart?.items ?? [])
|
||||
const isEmpty = computed(() => items.value.length === 0)
|
||||
@@ -39,54 +33,10 @@ export function useCartPage() {
|
||||
}
|
||||
|
||||
/**
|
||||
* ثبت سفارش بدون انتخاب تسویه؛ قیمتگذاری و انتخاب روش تسویه
|
||||
* بعد از بررسی مدیریت انجام میشود.
|
||||
* ثبت سفارش بدون آدرس و بدون انتخاب تسویه.
|
||||
* سفارش هنوز نهایی نیست؛ قیمتگذاری و روش تسویه بعد از بررسی مدیریت است.
|
||||
*/
|
||||
function chosenAddressText(): string {
|
||||
const saved = addresses.value.find((row) => row.id === selectedAddressId.value)
|
||||
return (saved?.text || newAddress.value).trim()
|
||||
}
|
||||
|
||||
async function openAddressPicker() {
|
||||
submitError.value = ''
|
||||
addressPickerOpen.value = true
|
||||
addressBusy.value = true
|
||||
try {
|
||||
addresses.value = await addressesApi.list()
|
||||
selectedAddressId.value =
|
||||
addresses.value.find((row) => row.isDefault)?.id ?? addresses.value[0]?.id ?? ''
|
||||
} catch (e) {
|
||||
submitError.value = e instanceof Error ? e.message : 'دریافت آدرسها ناموفق بود.'
|
||||
addressPickerOpen.value = false
|
||||
} finally {
|
||||
addressBusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function confirmAddressAndOrder() {
|
||||
const text = chosenAddressText()
|
||||
if (text.length < 3) {
|
||||
submitError.value = 'یک آدرس انتخاب کنید یا آدرس جدید بنویسید.'
|
||||
return
|
||||
}
|
||||
addressBusy.value = true
|
||||
try {
|
||||
if (!selectedAddressId.value) {
|
||||
const created = await addressesApi.create({ text })
|
||||
selectedAddressId.value = created.id
|
||||
addresses.value = await addressesApi.list()
|
||||
newAddress.value = ''
|
||||
}
|
||||
addressPickerOpen.value = false
|
||||
await submitOrder(text)
|
||||
} catch (e) {
|
||||
submitError.value = e instanceof Error ? e.message : 'ذخیره آدرس ناموفق بود.'
|
||||
} finally {
|
||||
addressBusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function submitOrder(shippingAddress?: string) {
|
||||
async function submitOrder() {
|
||||
if (!cartStore.activeCart || items.value.length === 0 || submitting.value) return
|
||||
submitting.value = true
|
||||
submitError.value = ''
|
||||
@@ -96,7 +46,7 @@ export function useCartPage() {
|
||||
submitError.value = 'سبد خرید خالی است یا با سرور همگام نشد.'
|
||||
return
|
||||
}
|
||||
const order = await orderStore.submitOrder(cartStore.activeCart, shippingAddress)
|
||||
const order = await orderStore.submitOrder(cartStore.activeCart)
|
||||
await cartStore.hydrate()
|
||||
router.replace(`/orders/${order.id}/success`)
|
||||
} catch (e) {
|
||||
@@ -113,12 +63,12 @@ export function useCartPage() {
|
||||
showFullDialog.value = true
|
||||
return
|
||||
}
|
||||
void openAddressPicker()
|
||||
void submitOrder()
|
||||
}
|
||||
|
||||
function proceedAnyway() {
|
||||
showFullDialog.value = false
|
||||
void openAddressPicker()
|
||||
void submitOrder()
|
||||
}
|
||||
|
||||
async function createNewInvoice() {
|
||||
@@ -140,12 +90,6 @@ export function useCartPage() {
|
||||
showFullDialog,
|
||||
submitting,
|
||||
submitError,
|
||||
addressPickerOpen,
|
||||
addresses,
|
||||
selectedAddressId,
|
||||
newAddress,
|
||||
addressBusy,
|
||||
confirmAddressAndOrder,
|
||||
removeItem,
|
||||
proceedToCheckout,
|
||||
proceedAnyway,
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
type DesktopOrderFilterId,
|
||||
} from '@/utils/orderStatusGroups'
|
||||
import { toPersianDigits } from '@/utils/format'
|
||||
import { orderFabricLabel } from '@/utils/orderFabric'
|
||||
|
||||
const DESKTOP_PAGE_SIZE = 5
|
||||
const MOBILE_PAGE_SIZE = 5
|
||||
@@ -81,7 +82,8 @@ export function useOrderList() {
|
||||
const needle = q.trim().toLowerCase()
|
||||
return (
|
||||
order.orderNumber.toLowerCase().includes(needle) ||
|
||||
order.companyName.toLowerCase().includes(needle)
|
||||
order.companyName.toLowerCase().includes(needle) ||
|
||||
orderFabricLabel(order.items).toLowerCase().includes(needle)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ export type ProductSuggestionDto = {
|
||||
colorImages?: Array<string | null>
|
||||
widthCm?: number
|
||||
composition?: string
|
||||
weightGrams?: number
|
||||
isNew?: boolean
|
||||
productIsActive?: boolean
|
||||
note?: string
|
||||
|
||||
+9
-8
@@ -9,7 +9,7 @@ import type {
|
||||
CheckRegistrationMode,
|
||||
} from '@/types'
|
||||
import { generateId } from '@/utils/format'
|
||||
import { calculateCheckRass } from '@/utils/checkRass'
|
||||
import { calculateCheckRass, invoiceAnchorDate } from '@/utils/checkRass'
|
||||
import { apiRequest, ApiError, getAccessToken } from '@/services/http'
|
||||
import { useCatalogStore } from './catalog'
|
||||
|
||||
@@ -75,7 +75,9 @@ export const useOrderStore = defineStore('order', () => {
|
||||
}
|
||||
|
||||
function getDraftRass(baseDate?: Date) {
|
||||
return calculateCheckRass(draftChecks.value, baseDate ?? new Date())
|
||||
const order = draftOrderId.value ? getOrderById(draftOrderId.value) : undefined
|
||||
const anchor = baseDate ?? (order ? invoiceAnchorDate(order) : new Date(0))
|
||||
return calculateCheckRass(draftChecks.value, anchor)
|
||||
}
|
||||
|
||||
async function hydrate() {
|
||||
@@ -119,7 +121,7 @@ export const useOrderStore = defineStore('order', () => {
|
||||
* روش تسویه را انتخاب میکند.
|
||||
* اقلام همه شرکتها در یک فاکتور واحد ثبت میشوند.
|
||||
*/
|
||||
async function submitOrder(cart: Cart, shippingAddress?: string): Promise<Order> {
|
||||
async function submitOrder(cart: Cart): Promise<Order> {
|
||||
if (!cart.items.length) {
|
||||
throw new Error('سبد خرید خالی است.')
|
||||
}
|
||||
@@ -134,10 +136,7 @@ export const useOrderStore = defineStore('order', () => {
|
||||
throw new Error('شرکت سبد مشخص نیست. سبد را خالی کنید و دوباره اضافه کنید.')
|
||||
}
|
||||
|
||||
const addressLine = shippingAddress?.trim()
|
||||
? `آدرس ارسال: ${shippingAddress.trim()}`
|
||||
: ''
|
||||
const notes = [addressLine, cart.notes?.trim()].filter(Boolean).join('\n')
|
||||
const notes = cart.notes?.trim() || ''
|
||||
|
||||
try {
|
||||
const order = await apiRequest<Order>('/orders', {
|
||||
@@ -193,7 +192,9 @@ export const useOrderStore = defineStore('order', () => {
|
||||
amount: receipt.amount,
|
||||
transferDate: receipt.transferDate,
|
||||
transferTime: receipt.transferTime,
|
||||
trackingNumber: receipt.trackingNumber,
|
||||
...(receipt.trackingNumber?.trim()
|
||||
? { trackingNumber: receipt.trackingNumber.trim() }
|
||||
: {}),
|
||||
destinationAccountId: receipt.destinationAccountId,
|
||||
receiptImage: receipt.receiptImage,
|
||||
notes: receipt.notes,
|
||||
|
||||
+1
-1
@@ -145,7 +145,7 @@ export interface CashPaymentReceipt {
|
||||
amount: number
|
||||
transferDate: string
|
||||
transferTime: string
|
||||
trackingNumber: string
|
||||
trackingNumber?: string
|
||||
destinationAccountId: string
|
||||
receiptImage?: string
|
||||
notes?: string
|
||||
|
||||
+21
-3
@@ -1,6 +1,24 @@
|
||||
import type { CheckData, CheckRassResult } from '@/types'
|
||||
import { parseISODate, toISODate } from '@/utils/jalali'
|
||||
|
||||
const INVOICE_ISSUED_STATUS = 'awaiting_settlement'
|
||||
|
||||
/** مبدأ راس، تاریخ صدور فاکتور است. اگر دوباره ارسال شده باشد آخرین صدور ملاک است. */
|
||||
export function invoiceAnchorDate(order: {
|
||||
createdAt: string
|
||||
statusHistory?: { toStatus: string; changedAt: string }[]
|
||||
}): Date {
|
||||
const history = order.statusHistory ?? []
|
||||
for (let i = history.length - 1; i >= 0; i -= 1) {
|
||||
const row = history[i]
|
||||
if (row?.toStatus !== INVOICE_ISSUED_STATUS) continue
|
||||
const issued = new Date(row.changedAt)
|
||||
if (!Number.isNaN(issued.getTime())) return issued
|
||||
}
|
||||
const created = new Date(order.createdAt)
|
||||
return Number.isNaN(created.getTime()) ? new Date(0) : created
|
||||
}
|
||||
|
||||
function emptyRass(): CheckRassResult {
|
||||
return {
|
||||
checkCount: 0,
|
||||
@@ -14,7 +32,7 @@ function emptyRass(): CheckRassResult {
|
||||
|
||||
export function calculateCheckRass(
|
||||
checks: CheckData[],
|
||||
baseDate: Date = new Date(),
|
||||
baseDate: Date,
|
||||
): CheckRassResult {
|
||||
if (checks.length === 0) return emptyRass()
|
||||
|
||||
@@ -61,8 +79,8 @@ export function calculateCheckRass(
|
||||
}
|
||||
}
|
||||
|
||||
export function daysUntilDue(dueDate: string): number {
|
||||
const base = new Date()
|
||||
export function daysFromBase(dueDate: string, baseDate: Date): number {
|
||||
const base = new Date(baseDate)
|
||||
base.setHours(0, 0, 0, 0)
|
||||
const due = parseISODate(dueDate)
|
||||
if (Number.isNaN(due.getTime())) return 0
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import type { OrderItem } from '@/types'
|
||||
|
||||
function fabricName(item: OrderItem): string {
|
||||
return item.productName.trim() || item.productCode.trim() || item.catalogCode.trim()
|
||||
}
|
||||
|
||||
/** نام پارچههای سفارش، برای تشخیص فاکتور در فهرست. */
|
||||
export function orderFabricLabel(items: OrderItem[] | null | undefined): string {
|
||||
if (!items?.length) return ''
|
||||
const names = [...new Set(items.map(fabricName).filter(Boolean))]
|
||||
return names.join('، ')
|
||||
}
|
||||
@@ -18,12 +18,6 @@ const {
|
||||
showFullDialog,
|
||||
submitting,
|
||||
submitError,
|
||||
addressPickerOpen,
|
||||
addresses,
|
||||
selectedAddressId,
|
||||
newAddress,
|
||||
addressBusy,
|
||||
confirmAddressAndOrder,
|
||||
removeItem,
|
||||
proceedToCheckout,
|
||||
proceedAnyway,
|
||||
@@ -71,49 +65,6 @@ function goToOrdering() {
|
||||
@back="goToOrdering"
|
||||
/>
|
||||
|
||||
<div
|
||||
v-if="addressPickerOpen"
|
||||
class="dialog-overlay"
|
||||
@click.self="addressPickerOpen = false"
|
||||
>
|
||||
<div class="dialog card">
|
||||
<h3>آدرس ارسال</h3>
|
||||
<p class="text-sm">یکی از آدرسهای ذخیرهشده را انتخاب کنید، یا آدرس تازه بنویسید.</p>
|
||||
<ul v-if="addresses.length" class="address-pick">
|
||||
<li v-for="row in addresses" :key="row.id">
|
||||
<label class="address-card" :class="{ 'is-on': selectedAddressId === row.id && !newAddress.trim() }">
|
||||
<input v-model="selectedAddressId" type="radio" :value="row.id" @change="newAddress = ''" />
|
||||
<span class="address-card__body">
|
||||
<span class="address-card__title">
|
||||
<strong>{{ row.label || 'آدرس' }}</strong>
|
||||
<em v-if="row.isDefault">پیشفرض</em>
|
||||
</span>
|
||||
<small>{{ row.text }}</small>
|
||||
</span>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
<label class="address-new" :class="{ 'is-on': Boolean(newAddress.trim()) }">
|
||||
<span>آدرس جدید</span>
|
||||
<textarea
|
||||
v-model="newAddress"
|
||||
rows="3"
|
||||
maxlength="500"
|
||||
placeholder="خیابان، پلاک، واحد…"
|
||||
@input="selectedAddressId = ''"
|
||||
/>
|
||||
</label>
|
||||
<div class="dialog-actions">
|
||||
<BaseButton variant="outline" :disabled="addressBusy" @click="addressPickerOpen = false">
|
||||
انصراف
|
||||
</BaseButton>
|
||||
<BaseButton :loading="addressBusy || submitting" @click="confirmAddressAndOrder">
|
||||
ثبت سفارش
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="showFullDialog" class="dialog-overlay" @click.self="showFullDialog = false">
|
||||
<div class="dialog card">
|
||||
<h3>سقف متراژ تکمیل شد</h3>
|
||||
@@ -148,115 +99,6 @@ function goToOrdering() {
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
|
||||
.address-pick {
|
||||
list-style: none;
|
||||
margin: 12px 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.address-card {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 10px;
|
||||
min-width: 0;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid #e7e5e4;
|
||||
border-radius: 14px;
|
||||
background: #fafaf9;
|
||||
}
|
||||
|
||||
.address-card.is-on {
|
||||
border-color: #1e293b;
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
.address-card input {
|
||||
margin-top: 4px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.address-card__body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.address-card__title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.address-card__title strong {
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.address-card__title em {
|
||||
flex-shrink: 0;
|
||||
padding: 1px 8px;
|
||||
border-radius: 999px;
|
||||
background: #1e293b;
|
||||
color: #fff;
|
||||
font-style: normal;
|
||||
font-size: 0.7rem;
|
||||
}
|
||||
|
||||
.address-card small {
|
||||
display: block;
|
||||
color: var(--color-text-muted);
|
||||
line-height: 1.7;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.address-new {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
margin-top: 4px;
|
||||
padding: 12px;
|
||||
border: 1px dashed #cbd5e1;
|
||||
border-radius: 16px;
|
||||
background: #f8fafc;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.address-new.is-on {
|
||||
border-style: solid;
|
||||
border-color: #1e293b;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.address-new span {
|
||||
font-weight: 700;
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
.address-new textarea {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
min-height: 88px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
font: inherit;
|
||||
line-height: 1.7;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.address-new textarea:focus {
|
||||
outline: none;
|
||||
border-color: #1e293b;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.cart-view {
|
||||
flex: 1 0 auto;
|
||||
|
||||
@@ -8,7 +8,7 @@ import FormErrorBanner from '@/components/ui/FormErrorBanner.vue'
|
||||
import EmptyState from '@/components/ui/EmptyState.vue'
|
||||
import IconChevronBack from '@/components/icons/IconChevronBack.vue'
|
||||
import { formatCurrency, formatDate, formatNumber, toPersianDigits } from '@/utils/format'
|
||||
import { calculateCheckRass } from '@/utils/checkRass'
|
||||
import { calculateCheckRass, invoiceAnchorDate } from '@/utils/checkRass'
|
||||
import { confirm } from '@/composables/useConfirm'
|
||||
import { useRequirePricedOrder } from '@/composables/useRequirePricedOrder'
|
||||
import type { CheckData } from '@/types'
|
||||
@@ -58,8 +58,10 @@ const checks = computed<CheckData[]>(() => {
|
||||
})
|
||||
|
||||
const rass = computed(() => {
|
||||
if (orderStore.draftChecks.length > 0) return orderStore.getDraftRass()
|
||||
return calculateCheckRass(checks.value, new Date())
|
||||
const anchor = order.value ? invoiceAnchorDate(order.value) : undefined
|
||||
if (orderStore.draftChecks.length > 0) return orderStore.getDraftRass(anchor)
|
||||
if (!anchor) return calculateCheckRass([], new Date(0))
|
||||
return calculateCheckRass(checks.value, anchor)
|
||||
})
|
||||
|
||||
const invoiceAmount = computed(() => order.value?.finalAmount ?? 0)
|
||||
|
||||
@@ -76,6 +76,7 @@ const suggestionsForHome = computed(() => {
|
||||
...item,
|
||||
composition: item.composition?.trim() || product?.composition?.trim() || '',
|
||||
widthCm: item.widthCm ?? product?.widthCm,
|
||||
weightGrams: item.weightGrams ?? product?.weightGrams,
|
||||
colors: item.colors?.length ? item.colors : product?.colors ?? [],
|
||||
colorImages: item.colorImages?.some(Boolean)
|
||||
? item.colorImages
|
||||
|
||||
@@ -5,7 +5,6 @@ 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'
|
||||
import PersianDateInput from '@/components/ui/PersianDateInput.vue'
|
||||
import TimeInput from '@/components/ui/TimeInput.vue'
|
||||
@@ -22,7 +21,7 @@ import {
|
||||
parseFormattedNumber,
|
||||
} from '@/utils/format'
|
||||
import { validateImageFile, fileToBase64 } from '@/utils/validation'
|
||||
import { daysUntilDue } from '@/utils/checkRass'
|
||||
import { daysFromBase, invoiceAnchorDate } from '@/utils/checkRass'
|
||||
import {
|
||||
FORM_VALIDATION_SUMMARY,
|
||||
clearFieldError,
|
||||
@@ -56,7 +55,6 @@ const showOrderDetails = ref(route.query.receipt === '1')
|
||||
const receiptAmount = ref('')
|
||||
const receiptDate = ref('')
|
||||
const receiptTime = ref('')
|
||||
const trackingNumber = ref('')
|
||||
const destinationAccountId = ref('')
|
||||
const receiptImage = ref('')
|
||||
const fieldErrors = ref<FieldErrors>({})
|
||||
@@ -103,10 +101,6 @@ watch(receiptDate, () => {
|
||||
fieldErrors.value = clearFieldError(fieldErrors.value, 'receiptDate')
|
||||
if (!hasFieldErrors(fieldErrors.value)) formError.value = ''
|
||||
})
|
||||
watch(trackingNumber, () => {
|
||||
fieldErrors.value = clearFieldError(fieldErrors.value, 'trackingNumber')
|
||||
if (!hasFieldErrors(fieldErrors.value)) formError.value = ''
|
||||
})
|
||||
watch(destinationAccountId, () => {
|
||||
fieldErrors.value = clearFieldError(fieldErrors.value, 'destinationAccountId')
|
||||
if (!hasFieldErrors(fieldErrors.value)) formError.value = ''
|
||||
@@ -269,9 +263,6 @@ async function submitReceipt() {
|
||||
if (!receiptDate.value) {
|
||||
errors.receiptDate = 'تاریخ واریز الزامی است.'
|
||||
}
|
||||
if (!trackingNumber.value.trim()) {
|
||||
errors.trackingNumber = 'شماره پیگیری الزامی است.'
|
||||
}
|
||||
if (!destinationAccountId.value) {
|
||||
errors.destinationAccountId = 'حساب مقصد را انتخاب کنید.'
|
||||
}
|
||||
@@ -287,7 +278,6 @@ async function submitReceipt() {
|
||||
amount,
|
||||
transferDate: receiptDate.value,
|
||||
transferTime: receiptTime.value || '12:00',
|
||||
trackingNumber: trackingNumber.value,
|
||||
destinationAccountId: destinationAccountId.value,
|
||||
receiptImage: receiptImage.value || undefined,
|
||||
})
|
||||
@@ -464,7 +454,7 @@ async function submitReceipt() {
|
||||
<span>مبلغ</span>
|
||||
<span>{{ formatCurrency(order.cashReceipt.amount) }}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<div v-if="order.cashReceipt.trackingNumber" class="detail-row">
|
||||
<span>شماره پیگیری</span>
|
||||
<span>{{ order.cashReceipt.trackingNumber }}</span>
|
||||
</div>
|
||||
@@ -492,7 +482,7 @@ async function submitReceipt() {
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span>سررسید</span>
|
||||
<span>{{ formatDate(check.dueDate) }} ({{ daysUntilDue(check.dueDate) }} روز)</span>
|
||||
<span>{{ formatDate(check.dueDate) }} ({{ daysFromBase(check.dueDate, invoiceAnchorDate(order)) }} روز)</span>
|
||||
</div>
|
||||
<img v-if="check.frontImage" :src="check.frontImage" class="check-img" alt="چک" />
|
||||
</div>
|
||||
@@ -550,13 +540,6 @@ async function submitReceipt() {
|
||||
placeholder="مثلاً ۱۴:۳۰"
|
||||
hint="با گام ۵ دقیقه"
|
||||
/>
|
||||
<BaseInput
|
||||
v-model="trackingNumber"
|
||||
label="شماره پیگیری"
|
||||
inputmode="numeric"
|
||||
dir="ltr"
|
||||
:error="fieldErrors.trackingNumber"
|
||||
/>
|
||||
<AppSelect
|
||||
v-model="destinationAccountId"
|
||||
label="حساب مقصد"
|
||||
|
||||
@@ -10,6 +10,7 @@ import IconFilter from '@/components/icons/IconFilter.vue'
|
||||
import IconMoreVertical from '@/components/icons/IconMoreVertical.vue'
|
||||
import IconChevronLeft from '@/components/icons/IconChevronLeft.vue'
|
||||
import { formatDateTime, formatNumber } from '@/utils/format'
|
||||
import { orderFabricLabel } from '@/utils/orderFabric'
|
||||
import type { Order } from '@/types'
|
||||
import type { DesktopOrderFilterId } from '@/utils/orderStatusGroups'
|
||||
|
||||
@@ -122,6 +123,7 @@ const emit = defineEmits<{
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">شماره سفارش</th>
|
||||
<th scope="col">پارچه</th>
|
||||
<th scope="col">شرکت</th>
|
||||
<th scope="col">مبلغ فاکتور (تومان)</th>
|
||||
<th scope="col">وضعیت</th>
|
||||
@@ -132,6 +134,7 @@ const emit = defineEmits<{
|
||||
<tbody>
|
||||
<tr v-for="order in paginatedOrders" :key="order.id">
|
||||
<td class="orders-table__number">{{ order.orderNumber }}</td>
|
||||
<td class="orders-table__fabric">{{ orderFabricLabel(order.items) || '—' }}</td>
|
||||
<td>{{ order.companyName }}</td>
|
||||
<td class="orders-table__amount">
|
||||
{{ order.finalAmount ? formatNumber(order.finalAmount) : '—' }}
|
||||
|
||||
@@ -9,6 +9,7 @@ import IconParLogo from '@/components/icons/IconParLogo.vue'
|
||||
import IconFamBaftLogo from '@/components/icons/IconFamBaftLogo.vue'
|
||||
import AuthThemeToggle from '@/components/ui/AuthThemeToggle.vue'
|
||||
import { formatCurrency, formatNumber, toPersianDigits } from '@/utils/format'
|
||||
import { orderFabricLabel } from '@/utils/orderFabric'
|
||||
import type { Order } from '@/types'
|
||||
|
||||
defineProps<{
|
||||
@@ -62,6 +63,10 @@ const emit = defineEmits<{
|
||||
<div class="order-card__content">
|
||||
<span class="order-card__label">سفارش شماره</span>
|
||||
<strong class="order-card__number">{{ order.orderNumber }}</strong>
|
||||
<template v-if="orderFabricLabel(order.items)">
|
||||
<span class="order-card__label">پارچه</span>
|
||||
<strong class="order-card__fabric">{{ orderFabricLabel(order.items) }}</strong>
|
||||
</template>
|
||||
<p class="order-card__company">{{ order.companyName }}</p>
|
||||
<p v-if="order.finalAmount" class="order-card__amount">
|
||||
{{ formatCurrency(order.finalAmount) }}
|
||||
@@ -214,6 +219,14 @@ const emit = defineEmits<{
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.order-card__fabric {
|
||||
font-size: 0.9375rem;
|
||||
font-weight: 700;
|
||||
margin-bottom: 6px;
|
||||
color: var(--color-text);
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.order-card__company {
|
||||
margin: 0 0 6px;
|
||||
font-size: 0.875rem;
|
||||
|
||||
Reference in New Issue
Block a user