add product
This commit is contained in:
@@ -29,9 +29,9 @@
|
||||
</div>
|
||||
<t-form-item
|
||||
v-for="(item, index) in itemList"
|
||||
:key="`${index}-${item.productName}-${item.unit}`"
|
||||
:key="`${index}-${item.productId}-${item.productUnitId}`"
|
||||
class="item"
|
||||
:label="item.productName"
|
||||
:label="getItemLabel(item)"
|
||||
>
|
||||
<t-input
|
||||
:model-value="item.totalQuantity"
|
||||
@@ -43,7 +43,7 @@
|
||||
@update:model-value="updateItemQuantity(index, $event)"
|
||||
>
|
||||
<template #suffix-icon>
|
||||
<span class="unit" v-text="item.unit" />
|
||||
<span class="unit" v-text="getItemUnit(item)" />
|
||||
</template>
|
||||
</t-input>
|
||||
</t-form-item>
|
||||
@@ -68,6 +68,15 @@ const props = defineProps<Props>();
|
||||
const saleAmount = defineModel<string>("saleAmount", { required: true });
|
||||
const itemList = defineModel<PackagePurchaseItem[]>("itemList", { required: true });
|
||||
|
||||
function getItemLabel(item: PackagePurchaseItem): string {
|
||||
const configItem = props.packageConfig?.itemList?.find(config => config.productId === item.productId && config.productUnitId === item.productUnitId);
|
||||
return configItem ? `${configItem.productNameSnapshot || "未命名产品"} · ${configItem.unitSnapshot || "未设置单位"}` : "产品权益";
|
||||
}
|
||||
|
||||
function getItemUnit(item: PackagePurchaseItem): string {
|
||||
return props.packageConfig?.itemList?.find(config => config.productId === item.productId && config.productUnitId === item.productUnitId)?.unitSnapshot || "";
|
||||
}
|
||||
|
||||
function updateItemQuantity(index: number, value: string | number): void {
|
||||
itemList.value = itemList.value.map((item, itemIndex) => itemIndex === index ? {
|
||||
...item,
|
||||
|
||||
Reference in New Issue
Block a user