Unify order items layout across cart and orders

This commit is contained in:
Ruslan Bakiev
2026-04-04 14:49:34 +07:00
parent 685f84c428
commit ad1f6b8a35
7 changed files with 299 additions and 84 deletions

View File

@@ -10,7 +10,6 @@ import {
formatPrice,
orderLogisticsStateText,
orderDeliveryStateText,
orderLineStateText,
} from '~/composables/useOrderDetailPresentation';
definePageMeta({
@@ -76,19 +75,6 @@ function parseMoneyDraft(value: string) {
return Math.round((normalized + Number.EPSILON) * 100) / 100;
}
function draftUnitPrice(itemId: string, fallback?: number | null) {
return parseMoneyDraft(itemPriceDrafts[itemId] ?? '') ?? fallback ?? null;
}
function draftLineTotal(item: ManagerOrderItem['items'][number]) {
const unitPrice = draftUnitPrice(item.id, item.unitPrice);
if (unitPrice == null) {
return null;
}
return Math.round((unitPrice * item.quantity + Number.EPSILON) * 100) / 100;
}
const draftDeliveryTerms = computed(() => deliveryTermsDraft.value.trim() || currentOrder.value?.deliveryTerms || null);
const draftDeliveryFee = computed(() => parseMoneyDraft(deliveryFeeDraft.value) ?? currentOrder.value?.deliveryFee ?? null);
const canEditOffer = computed(() => (
@@ -233,29 +219,17 @@ watch(
audience="manager"
/>
<div class="surface-card rounded-3xl p-5">
<div>
<h2 class="text-xl font-bold text-[#123824]">Состав заказа</h2>
<ul class="mt-4 space-y-3">
<li v-for="item in currentOrder.items" :key="item.id" class="manager-mini-card space-y-3">
<div class="space-y-1">
<p class="text-sm font-semibold text-[#123824]">{{ item.productName }} × {{ item.quantity }}</p>
<p class="text-sm text-[#5c7b69]">{{ orderLineStateText(draftUnitPrice(item.id, item.unitPrice), draftLineTotal(item)) }}</p>
</div>
<label class="form-control">
<span class="mb-2 text-xs font-semibold uppercase tracking-[0.22em] text-[#6a8a76]">Цена за единицу</span>
<input
v-model="itemPriceDrafts[item.id]"
type="number"
min="0"
step="0.01"
placeholder="Например, 125.50"
class="input input-bordered w-full rounded-2xl bg-white"
:disabled="!canEditOffer"
>
</label>
</li>
</ul>
<OrdersOrderItemsTable
class="mt-4"
:items="currentOrder.items"
:calculation-payload="currentOrder.calculationPayload"
:editable="true"
:unit-price-drafts="itemPriceDrafts"
:disabled="!canEditOffer"
@update:unit-price="({ itemId, value }) => { itemPriceDrafts[itemId] = value; }"
/>
</div>
<div class="surface-card rounded-3xl p-5">