feat(freight): shop freight templates, server-side checkout fees, company dictionary (add-freight-templates)
This commit is contained in:
@@ -1,15 +1,23 @@
|
||||
<script setup lang="ts">
|
||||
import type { Shipment } from "@vmall/shared";
|
||||
import { t as localized } from "@vmall/shared";
|
||||
import type { Shipment, ShippingCompany } from "@vmall/shared";
|
||||
|
||||
definePageMeta({ middleware: "auth" });
|
||||
|
||||
const { $api } = useNuxtApp();
|
||||
const { locale, t: translate } = useI18n();
|
||||
const shipments = ref<Shipment[]>([]);
|
||||
const companies = ref<ShippingCompany[]>([]);
|
||||
const loading = ref(true);
|
||||
const error = ref("");
|
||||
const actionId = ref("");
|
||||
|
||||
function companyName(code: string | null | undefined): string {
|
||||
if (!code) return "—";
|
||||
const company = companies.value.find((item) => item.code === code);
|
||||
return company ? localized(company.name, locale.value) : code;
|
||||
}
|
||||
|
||||
function statusClass(value: Shipment["status"]): "green" | "blue" | "orange" {
|
||||
return value === "delivered" ? "green" : value === "shipped" ? "blue" : "orange";
|
||||
}
|
||||
@@ -22,7 +30,12 @@ async function loadShipments(): Promise<void> {
|
||||
loading.value = true;
|
||||
error.value = "";
|
||||
try {
|
||||
shipments.value = await $api.shop.listShipments();
|
||||
const [loadedShipments, loadedCompanies] = await Promise.all([
|
||||
$api.shop.listShipments(),
|
||||
$api.listShippingCompanies(),
|
||||
]);
|
||||
shipments.value = loadedShipments;
|
||||
companies.value = loadedCompanies;
|
||||
} catch (err: unknown) {
|
||||
error.value = err instanceof Error ? err.message : translate("common.error");
|
||||
} finally {
|
||||
@@ -57,6 +70,7 @@ onMounted(loadShipments);
|
||||
<th>{{ $t("shipment.shipmentNo") }}</th>
|
||||
<th>{{ $t("shop.orderNo") }}</th>
|
||||
<th>{{ $t("shop.carrier") }}</th>
|
||||
<th>{{ $t("shop.shippingCompany") }}</th>
|
||||
<th>{{ $t("shop.trackingNo") }}</th>
|
||||
<th>{{ $t("common.status") }}</th>
|
||||
<th>{{ $t("shop.created") }}</th>
|
||||
@@ -72,6 +86,7 @@ onMounted(loadShipments);
|
||||
}}</NuxtLink>
|
||||
</td>
|
||||
<td>{{ shipment.carrier }}</td>
|
||||
<td>{{ companyName(shipment.shipping_company_code) }}</td>
|
||||
<td>{{ shipment.tracking_no }}</td>
|
||||
<td>
|
||||
<VBadge :tone="statusClass(shipment.status)">{{
|
||||
|
||||
Reference in New Issue
Block a user