feat: show meter price and hide supplier quota
Customers see the admin unit price after pricing, and the preorder cart no longer shows the supplier cap or remaining meterage. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
@@ -1,10 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { useRouter } from 'vue-router'
|
||||
import AuthWave from '@/components/auth/AuthWave.vue'
|
||||
import IconChevronBack from '@/components/icons/IconChevronBack.vue'
|
||||
import logoUrl from '@/assets/images/nademitex-auth-logo.png'
|
||||
|
||||
defineProps<{
|
||||
backTo?: string
|
||||
wave?: boolean
|
||||
}>()
|
||||
|
||||
const router = useRouter()
|
||||
@@ -12,6 +14,7 @@ const router = useRouter()
|
||||
|
||||
<template>
|
||||
<div class="auth-shell">
|
||||
<AuthWave v-if="wave" />
|
||||
<button
|
||||
v-if="backTo"
|
||||
type="button"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import waveUrl from '@/assets/images/auth-wave.png'
|
||||
import waveUrl from '@/assets/images/nademitex-fade.png'
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -11,7 +11,7 @@ import waveUrl from '@/assets/images/auth-wave.png'
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: min(70vw, 270px);
|
||||
width: min(150px, 40%);
|
||||
height: auto;
|
||||
pointer-events: none;
|
||||
user-select: none;
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
usesCashReceiptPhase,
|
||||
usesCheckSettlement,
|
||||
} from '@/utils/settlement'
|
||||
import { orderUnitPriceRows } from '@/utils/orderInvoice'
|
||||
|
||||
const props = defineProps<{
|
||||
order: Order
|
||||
@@ -15,11 +16,16 @@ const props = defineProps<{
|
||||
const checksTotal = computed(() =>
|
||||
props.order.checks?.reduce((sum, check) => sum + check.amount, 0) ?? 0,
|
||||
)
|
||||
const unitPriceRows = computed(() => orderUnitPriceRows(props.order))
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="tracking-summary">
|
||||
<div v-for="row in unitPriceRows" :key="row.id" class="tracking-summary__row">
|
||||
<span>{{ row.label }}</span>
|
||||
<strong>{{ formatCurrency(row.price) }}</strong>
|
||||
</div>
|
||||
<div class="tracking-summary__row">
|
||||
<span>مبلغ فاکتور</span>
|
||||
<strong>
|
||||
|
||||
@@ -8,6 +8,39 @@ export function orderItemMeterage(
|
||||
return item.confirmedMeterage ?? item.requestedMeterage
|
||||
}
|
||||
|
||||
/** قیمت پرداختی هر متر، بعد از کسر تخفیف قلم. */
|
||||
export function orderItemUnitPrice(
|
||||
item: Pick<OrderItem, 'unitPrice' | 'discount'>,
|
||||
): number | null {
|
||||
if (item.unitPrice == null) return null
|
||||
const price = Number(item.unitPrice)
|
||||
if (!Number.isFinite(price) || price <= 0) return null
|
||||
const discount = Number(item.discount ?? 0)
|
||||
const net = price - (Number.isFinite(discount) ? discount : 0)
|
||||
return net > 0 ? net : null
|
||||
}
|
||||
|
||||
export function orderUnitPriceRows(
|
||||
order: Order | null | undefined,
|
||||
): { id: string; label: string; price: number }[] {
|
||||
if (!isInvoicePriced(order) || !order) return []
|
||||
const priced = order.items.flatMap((item) => {
|
||||
const price = orderItemUnitPrice(item)
|
||||
if (price == null) return []
|
||||
return [{ id: item.id, name: item.productName, price }]
|
||||
})
|
||||
if (!priced.length) return []
|
||||
const first = priced[0]
|
||||
if (!first || !priced.every((row) => row.price === first.price)) {
|
||||
return priced.map((row) => ({
|
||||
id: row.id,
|
||||
label: `قیمت هر متر · ${row.name}`,
|
||||
price: row.price,
|
||||
}))
|
||||
}
|
||||
return [{ id: 'unit-price', label: 'قیمت هر متر', price: first.price }]
|
||||
}
|
||||
|
||||
/** سفارش وقتی قابل تسویه/چک است که مبلغ فاکتور توسط ادمین تعیین شده باشد. */
|
||||
export function isInvoicePriced(order: Order | null | undefined): boolean {
|
||||
return !!order && order.finalAmount != null && Number(order.finalAmount) > 0
|
||||
|
||||
@@ -71,7 +71,7 @@ async function submit() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AuthShell back-to="/welcome">
|
||||
<AuthShell back-to="/welcome" wave>
|
||||
<h1 class="auth-title">به نادمی تکس خوش آمدید</h1>
|
||||
<p class="auth-lead">برای ادامه، وارد حساب کاربری خود شوید</p>
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ async function submit() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AuthShell back-to="/login">
|
||||
<AuthShell back-to="/login" wave>
|
||||
<h1 class="auth-title">ثبتنام</h1>
|
||||
<p class="auth-lead">برای ساخت حساب کاربری، اطلاعات زیر را وارد کنید</p>
|
||||
|
||||
|
||||
@@ -165,17 +165,6 @@ const quickLinks = [
|
||||
</span>
|
||||
<strong>{{ formatMeterage(totalMeterage) }}</strong>
|
||||
</div>
|
||||
<div
|
||||
v-for="row in companySummaries ?? []"
|
||||
:key="row.companyId"
|
||||
class="cart-summary-card__row cart-summary-card__row--sub"
|
||||
>
|
||||
<span class="cart-summary-card__row-label">{{ row.companyName }}</span>
|
||||
<strong>
|
||||
{{ formatMeterage(row.meterage) }}
|
||||
<span class="cart-summary-card__cap">/ {{ formatMeterage(row.maxMeterage) }}</span>
|
||||
</strong>
|
||||
</div>
|
||||
<div class="cart-summary-card__row cart-summary-card__row--hint">
|
||||
<span class="cart-summary-card__row-label">
|
||||
<IconOrders :size="16" />
|
||||
@@ -217,10 +206,6 @@ const quickLinks = [
|
||||
</h3>
|
||||
<p class="cart-guide-card__text">
|
||||
محصولات موردنظر را به سبد اضافه کنید، متراژ کل را بررسی کنید و «ثبت پیشسفارش» را بزنید.
|
||||
<template v-if="!isEmpty">
|
||||
سقف مجاز: {{ formatMeterage(maxMeterage) }} — باقیمانده:
|
||||
{{ formatMeterage(remainingCapacity) }}.
|
||||
</template>
|
||||
پس از قیمتگذاری، از صفحه سفارش روش تسویه را انتخاب میکنید.
|
||||
</p>
|
||||
</div>
|
||||
@@ -510,17 +495,6 @@ const quickLinks = [
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
.cart-summary-card__row--sub {
|
||||
padding-block: 6px;
|
||||
font-size: 0.8125rem;
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.cart-summary-card__cap {
|
||||
font-weight: 500;
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.cart-summary-card__row:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
@@ -82,27 +82,6 @@ const emit = defineEmits<{
|
||||
<span>جمع متراژ کل</span>
|
||||
<strong>{{ formatMeterage(totalMeterage) }}</strong>
|
||||
</div>
|
||||
<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">
|
||||
<span>حداکثر مجاز</span>
|
||||
<strong>{{ formatMeterage(maxMeterage) }}</strong>
|
||||
</div>
|
||||
<div class="cart-mobile-summary__row cart-mobile-summary__row--remain">
|
||||
<span>باقی مانده</span>
|
||||
<strong>{{ formatMeterage(remainingCapacity) }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
<PreorderPaymentFields
|
||||
:settlement-type="settlementType"
|
||||
@@ -296,22 +275,7 @@ const emit = defineEmits<{
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.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);
|
||||
}
|
||||
|
||||
.cart-mobile-summary__row:not(:last-child) {
|
||||
border-bottom: 1px solid #e8edf3;
|
||||
}
|
||||
|
||||
.cart-mobile-summary__row--remain strong {
|
||||
color: #1e293b;
|
||||
font-weight: 800;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -33,7 +33,13 @@ import { getStatusHero, getTrackingFooterLabel } from '@/utils/orderTracking'
|
||||
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 {
|
||||
canSubmitCashReceipt,
|
||||
isInvoicePriced,
|
||||
orderItemMeterage,
|
||||
orderItemUnitPrice,
|
||||
orderUnitPriceRows,
|
||||
} from '@/utils/orderInvoice'
|
||||
import {
|
||||
isInCashPaymentPhase,
|
||||
isInCheckPhase,
|
||||
@@ -49,6 +55,7 @@ const isDesktopLayout = useMediaQuery('(min-width: 768px)')
|
||||
|
||||
const orderId = computed(() => route.params.id as string)
|
||||
const order = computed(() => orderStore.getOrderById(orderId.value))
|
||||
const unitPriceRows = computed(() => orderUnitPriceRows(order.value))
|
||||
const showTracking = ref(route.query.track === '1' || route.query.receipt === '1')
|
||||
const showReceiptForm = ref(false)
|
||||
const showTimeline = ref(true)
|
||||
@@ -410,6 +417,13 @@ async function submitReceipt() {
|
||||
<BaseButton block :loading="planSaving" @click="savePaymentPlan">ثبت روش پرداخت</BaseButton>
|
||||
</div>
|
||||
|
||||
<div v-for="row in unitPriceRows" :key="row.id" class="order-info-card__row">
|
||||
<span class="order-info-card__key">{{ row.label }}</span>
|
||||
<span class="order-info-card__value order-info-card__value--accent">
|
||||
{{ formatCurrency(row.price) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="order-info-card__row order-info-card__row--last">
|
||||
<span class="order-info-card__key">مبلغ فاکتور</span>
|
||||
<strong class="order-info-card__amount">
|
||||
@@ -487,6 +501,9 @@ async function submitReceipt() {
|
||||
<div>
|
||||
<strong>{{ item.productName }}</strong>
|
||||
<p class="item-row__meta">کالیته {{ item.catalogCode }} · {{ item.color }}</p>
|
||||
<p v-if="orderItemUnitPrice(item) != null" class="item-row__meta">
|
||||
قیمت هر متر: {{ formatCurrency(orderItemUnitPrice(item)!) }}
|
||||
</p>
|
||||
</div>
|
||||
<span>{{ formatMeterage(orderItemMeterage(item)) }}</span>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user