Unify order items layout across cart and orders
This commit is contained in:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user