add product stock preview

This commit is contained in:
Timi
2026-09-16 14:53:36 +08:00
parent 443d0a6190
commit f8a9c0e649
12 changed files with 456 additions and 86 deletions
+10 -2
View File
@@ -123,7 +123,7 @@
<script setup lang="ts">
import { BottomPopup } from "timi-tdesign-mobile";
import ProductAPI from "@/api/ProductAPI";
import type { Product, ProductSku, ProductSkuUnit, ProductSpec, ProductSpecValue } from "@/types/Product";
import type { Product, ProductSelection, ProductSku, ProductSkuUnit, ProductSpec, ProductSpecValue } from "@/types/Product";
import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message";
import { formatProductAmount, getProductPhotoURL, getProductSkuSpecEntries } from "@/utils/product";
@@ -137,7 +137,10 @@ interface Props {
}
const props = withDefaults(defineProps<Props>(), { label: "产品", requiredMark: false, placeholder: "请选择产品 SKU" });
const emit = defineEmits<{ "update:modelValue": [value: Props["modelValue"]] }>();
const emit = defineEmits<{
"update:modelValue": [value: Props["modelValue"]];
select: [selection: ProductSelection];
}>();
const visible = ref(false);
const loading = ref(false);
const keyword = ref("");
@@ -242,6 +245,11 @@ function selectUnit(sku: ProductSku, skuUnitId: string): void {
if (!sku.id || !skuUnitId) {
return;
}
const product = activeProduct.value;
const unit = sku.unitList?.find(item => item.id === skuUnitId);
if (product && unit) {
emit("select", { product, sku, unit });
}
emit("update:modelValue", { skuId: sku.id, skuUnitId });
close();
}