2026-08-03 09:57:24 +02:00
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
|
import BaseButton from '@/components/ui/BaseButton.vue'
|
2026-08-06 17:12:57 +03:30
|
|
|
|
import EmptyState from '@/components/ui/EmptyState.vue'
|
2026-08-03 09:57:24 +02:00
|
|
|
|
import IconTrash from '@/components/icons/IconTrash.vue'
|
|
|
|
|
|
import IconChevronBack from '@/components/icons/IconChevronBack.vue'
|
|
|
|
|
|
import { formatMeterage, formatNumber } from '@/utils/format'
|
|
|
|
|
|
import type { CartItem } from '@/types'
|
|
|
|
|
|
|
|
|
|
|
|
defineProps<{
|
|
|
|
|
|
items: CartItem[]
|
|
|
|
|
|
companyName: string
|
2026-08-15 08:30:57 +02:00
|
|
|
|
companySummaries?: {
|
|
|
|
|
|
companyId: string
|
|
|
|
|
|
companyName: string
|
|
|
|
|
|
meterage: number
|
|
|
|
|
|
maxMeterage: number
|
|
|
|
|
|
remaining: number
|
|
|
|
|
|
}[]
|
2026-08-03 09:57:24 +02:00
|
|
|
|
totalMeterage: number
|
|
|
|
|
|
maxMeterage: number
|
|
|
|
|
|
remainingCapacity: number
|
|
|
|
|
|
isEmpty: boolean
|
2026-08-09 12:00:18 +03:30
|
|
|
|
submitting?: boolean
|
2026-08-03 09:57:24 +02:00
|
|
|
|
}>()
|
|
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
|
|
back: []
|
|
|
|
|
|
remove: [id: string]
|
|
|
|
|
|
checkout: []
|
|
|
|
|
|
selectCompany: []
|
|
|
|
|
|
}>()
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
|
<div class="cart-mobile-page">
|
|
|
|
|
|
<header class="cart-mobile-page__nav">
|
|
|
|
|
|
<button type="button" class="nav-btn" aria-label="بازگشت" @click="emit('back')">
|
|
|
|
|
|
<IconChevronBack :size="20" />
|
|
|
|
|
|
</button>
|
|
|
|
|
|
<h1 class="cart-mobile-page__title">سبد خرید</h1>
|
|
|
|
|
|
<button type="button" class="nav-btn nav-btn--ghost" aria-hidden="true" tabindex="-1">
|
|
|
|
|
|
<IconChevronBack :size="18" class="nav-btn__flip" />
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</header>
|
|
|
|
|
|
|
|
|
|
|
|
<div v-if="!isEmpty" class="cart-mobile-page__body">
|
2026-08-05 14:07:42 +02:00
|
|
|
|
<p class="cart-mobile-page__company">
|
|
|
|
|
|
{{ companyName ? `شرکتها: ${companyName}` : 'سبد خرید مشترک' }}
|
|
|
|
|
|
</p>
|
2026-08-03 09:57:24 +02:00
|
|
|
|
|
|
|
|
|
|
<div class="cart-mobile-page__scroll">
|
|
|
|
|
|
<div class="cart-mobile-table">
|
|
|
|
|
|
<div class="cart-mobile-table__head">
|
|
|
|
|
|
<span>محصول</span>
|
|
|
|
|
|
<span>متراژ (متر)</span>
|
|
|
|
|
|
<span>حذف</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-for="item in items" :key="item.id" class="cart-mobile-table__row">
|
|
|
|
|
|
<div class="col-product">
|
|
|
|
|
|
<strong>{{ item.productName }}</strong>
|
|
|
|
|
|
<span>کد: {{ item.productCode }}</span>
|
2026-08-05 14:07:42 +02:00
|
|
|
|
<span v-if="item.companyName" class="col-product__company">{{ item.companyName }}</span>
|
2026-08-03 09:57:24 +02:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="col-meterage">{{ formatNumber(item.meterage) }}</div>
|
|
|
|
|
|
<div class="col-delete">
|
|
|
|
|
|
<button type="button" aria-label="حذف" @click="emit('remove', item.id)">
|
|
|
|
|
|
<IconTrash :size="20" />
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="cart-mobile-page__footer">
|
|
|
|
|
|
<div class="cart-mobile-summary">
|
|
|
|
|
|
<div class="cart-mobile-summary__row">
|
2026-08-15 08:30:57 +02:00
|
|
|
|
<span>جمع متراژ کل</span>
|
2026-08-03 09:57:24 +02:00
|
|
|
|
<strong>{{ formatMeterage(totalMeterage) }}</strong>
|
|
|
|
|
|
</div>
|
2026-08-15 08:30:57 +02:00
|
|
|
|
<template v-if="companySummaries?.length">
|
|
|
|
|
|
<div
|
|
|
|
|
|
v-for="row in companySummaries"
|
|
|
|
|
|
:key="row.companyId"
|
|
|
|
|
|
class="cart-mobile-summary__row cart-mobile-summary__row--sub"
|
|
|
|
|
|
>
|
|
|
|
|
|
<span>{{ row.companyName }}</span>
|
|
|
|
|
|
<strong>
|
|
|
|
|
|
{{ formatMeterage(row.meterage) }}
|
|
|
|
|
|
<span class="cart-mobile-summary__cap">/ {{ formatMeterage(row.maxMeterage) }}</span>
|
|
|
|
|
|
</strong>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<div v-else class="cart-mobile-summary__row">
|
2026-08-03 09:57:24 +02:00
|
|
|
|
<span>حداکثر مجاز</span>
|
|
|
|
|
|
<strong>{{ formatMeterage(maxMeterage) }}</strong>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="cart-mobile-summary__row">
|
|
|
|
|
|
<span>باقی مانده</span>
|
|
|
|
|
|
<strong>{{ formatMeterage(remainingCapacity) }}</strong>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-08-09 12:00:18 +03:30
|
|
|
|
<p class="cart-mobile-page__hint">
|
2026-08-15 08:30:57 +02:00
|
|
|
|
پس از ثبت، برای هر شرکت یک پیشسفارش جداگانه ساخته میشود و مدیریت قیمتگذاری میکند.
|
2026-08-09 12:00:18 +03:30
|
|
|
|
</p>
|
2026-08-09 14:32:10 +02:00
|
|
|
|
<BaseButton block :loading="submitting" @click="emit('checkout')">ثبت پیشسفارش</BaseButton>
|
2026-08-03 09:57:24 +02:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2026-08-06 17:12:57 +03:30
|
|
|
|
<EmptyState v-else variant="cart" message="برای شروع سفارش، یک شرکت انتخاب کنید">
|
2026-08-03 09:57:24 +02:00
|
|
|
|
<BaseButton @click="emit('selectCompany')">انتخاب شرکت</BaseButton>
|
2026-08-06 17:12:57 +03:30
|
|
|
|
</EmptyState>
|
2026-08-03 09:57:24 +02:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.cart-mobile-page {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
min-height: 0;
|
2026-08-06 17:12:57 +03:30
|
|
|
|
width: 100%;
|
|
|
|
|
|
background: var(--color-bg);
|
|
|
|
|
|
color: var(--color-text);
|
2026-08-03 09:57:24 +02:00
|
|
|
|
padding: 12px 0 0;
|
2026-08-06 17:12:57 +03:30
|
|
|
|
overflow: hidden;
|
2026-08-03 09:57:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cart-mobile-page__nav {
|
|
|
|
|
|
display: grid;
|
|
|
|
|
|
grid-template-columns: 40px 1fr 40px;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
margin-bottom: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-09 12:00:18 +03:30
|
|
|
|
.cart-mobile-page__hint {
|
|
|
|
|
|
margin: 0 0 10px;
|
|
|
|
|
|
font-size: 0.75rem;
|
|
|
|
|
|
line-height: 1.6;
|
|
|
|
|
|
color: var(--color-text-muted);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-03 09:57:24 +02:00
|
|
|
|
.cart-mobile-page__title {
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
font-size: 1.0625rem;
|
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
|
text-align: center;
|
2026-08-06 17:12:57 +03:30
|
|
|
|
color: var(--color-text);
|
2026-08-03 09:57:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.nav-btn {
|
|
|
|
|
|
width: 40px;
|
|
|
|
|
|
height: 40px;
|
|
|
|
|
|
border: none;
|
|
|
|
|
|
background: none;
|
2026-08-06 17:12:57 +03:30
|
|
|
|
color: var(--color-text);
|
2026-08-03 09:57:24 +02:00
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.nav-btn--ghost {
|
|
|
|
|
|
visibility: hidden;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.nav-btn__flip {
|
|
|
|
|
|
transform: scaleX(-1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cart-mobile-page__body {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
min-height: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cart-mobile-page__company {
|
|
|
|
|
|
margin: 0 0 16px;
|
|
|
|
|
|
font-size: 0.875rem;
|
|
|
|
|
|
color: var(--color-text-muted);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cart-mobile-page__scroll {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
min-height: 0;
|
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cart-mobile-table {
|
|
|
|
|
|
border: 1px solid var(--color-border);
|
|
|
|
|
|
border-radius: var(--radius-md);
|
|
|
|
|
|
overflow: hidden;
|
2026-08-06 17:12:57 +03:30
|
|
|
|
background: var(--color-elevated);
|
2026-08-03 09:57:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cart-mobile-table__head,
|
|
|
|
|
|
.cart-mobile-table__row {
|
|
|
|
|
|
display: grid;
|
|
|
|
|
|
grid-template-columns: 1fr 88px 52px;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
padding: 10px 12px;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cart-mobile-table__head {
|
2026-08-06 17:12:57 +03:30
|
|
|
|
background: var(--color-summary-bg);
|
2026-08-03 09:57:24 +02:00
|
|
|
|
font-size: 0.75rem;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
color: var(--color-text-muted);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cart-mobile-table__row {
|
|
|
|
|
|
border-top: 1px solid var(--color-border);
|
2026-08-06 17:12:57 +03:30
|
|
|
|
color: var(--color-text);
|
2026-08-03 09:57:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.col-product strong {
|
|
|
|
|
|
display: block;
|
|
|
|
|
|
font-size: 0.875rem;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.col-product span {
|
2026-08-05 14:07:42 +02:00
|
|
|
|
display: block;
|
2026-08-03 09:57:24 +02:00
|
|
|
|
font-size: 0.75rem;
|
|
|
|
|
|
color: var(--color-text-muted);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-05 14:07:42 +02:00
|
|
|
|
.col-product__company {
|
|
|
|
|
|
margin-top: 2px;
|
|
|
|
|
|
color: var(--color-primary) !important;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-03 09:57:24 +02:00
|
|
|
|
.col-meterage {
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.col-delete {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.col-delete button {
|
|
|
|
|
|
border: none;
|
|
|
|
|
|
background: none;
|
|
|
|
|
|
cursor: pointer;
|
2026-08-06 17:12:57 +03:30
|
|
|
|
color: var(--color-text-muted);
|
2026-08-03 09:57:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cart-mobile-page__footer {
|
|
|
|
|
|
flex-shrink: 0;
|
2026-08-06 17:12:57 +03:30
|
|
|
|
margin: 0;
|
|
|
|
|
|
padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0));
|
2026-08-03 09:57:24 +02:00
|
|
|
|
border-top: 1px solid var(--color-border);
|
2026-08-06 17:12:57 +03:30
|
|
|
|
background: var(--color-bg);
|
2026-08-03 09:57:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cart-mobile-summary {
|
|
|
|
|
|
margin-bottom: 12px;
|
|
|
|
|
|
padding: 14px 16px;
|
2026-08-06 17:12:57 +03:30
|
|
|
|
background: var(--color-elevated);
|
|
|
|
|
|
border: 1px solid var(--color-border);
|
2026-08-03 09:57:24 +02:00
|
|
|
|
border-radius: var(--radius-md);
|
2026-08-06 17:12:57 +03:30
|
|
|
|
color: var(--color-text);
|
|
|
|
|
|
box-shadow: var(--shadow-sm);
|
2026-08-03 09:57:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cart-mobile-summary__row {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
2026-08-15 08:30:57 +02:00
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 12px;
|
2026-08-03 09:57:24 +02:00
|
|
|
|
padding: 8px 0;
|
|
|
|
|
|
font-size: 0.875rem;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-15 08:30:57 +02:00
|
|
|
|
.cart-mobile-summary__row--sub {
|
|
|
|
|
|
color: var(--color-text-muted);
|
|
|
|
|
|
font-size: 0.8125rem;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cart-mobile-summary__cap {
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
color: var(--color-text-muted);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-03 09:57:24 +02:00
|
|
|
|
.cart-mobile-summary__row:not(:last-child) {
|
2026-08-06 17:12:57 +03:30
|
|
|
|
border-bottom: 1px solid var(--color-border);
|
2026-08-03 09:57:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
</style>
|