update PackagePurchase.vue style

This commit is contained in:
Timi
2026-10-24 17:35:02 +08:00
parent d85a2038c4
commit b33e48fd2c
2 changed files with 182 additions and 127 deletions
@@ -50,21 +50,21 @@
theme="primary"
content="赠送"
/>
<div
v-if="item.skuCodeSnapshot || item.skuSpecSnapshot?.length || item.skuNameSnapshot || item.specSummarySnapshot || item.unitSnapshot"
class="sku-tags"
>
<product-sku-tags
:product-name="item.productNameSnapshot"
:snapshot="item.skuSpecSnapshot"
:fallback="item.specSummarySnapshot || item.skuNameSnapshot"
/>
</div>
</div>
<span class="can-fulfill" v-text="getItemDescription(item)" />
</div>
</div>
<div class="input">
<div
v-if="item.skuCodeSnapshot || item.skuSpecSnapshot?.length || item.skuNameSnapshot || item.specSummarySnapshot || item.unitSnapshot"
class="sku-tags"
>
<product-sku-tags
:product-name="item.productNameSnapshot"
:snapshot="item.skuSpecSnapshot"
:fallback="item.specSummarySnapshot || item.skuNameSnapshot"
/>
</div>
<div class="quantity">
<t-stepper
v-model="quantityMap[item.id || '']"
@@ -604,20 +604,12 @@ onUnmounted(() => {
.items {
margin: 0 1rem;
background: var(--td-bg-color-container);
box-shadow: var(--td-shadow-1);
border-radius: 1rem;
overflow: hidden;
.item {
padding: 10px;
min-width: 0;
:deep(.t-form__controls),
:deep(.t-form__controls-content) {
min-width: 0;
}
.content {
gap: .5rem;
width: 100%;
@@ -682,7 +674,6 @@ onUnmounted(() => {
.input {
gap: .5rem;
display: flex;
margin-top: .5rem;
flex-direction: column;
.sku-tags {
+172 -108
View File
@@ -92,70 +92,87 @@
placeholder="请输入成交价"
/>
</t-form-item>
<t-form-item v-if="config" label="购买权益明细" label-align="top">
<t-form class="items" label-width="2.5rem">
<t-form-item v-if="config" class="detail" label-width="0">
<t-form class="items" label-width="0">
<span v-if="!canPriceOverride">当前账号无定制权限,仅可等值转换单位</span>
<t-form-item
v-for="(item, index) in packagePurchaseItemList"
:key="`${index}-${item.skuId}-${item.skuUnitId}-${item.gifted}`"
class="item"
>
<template #label>
<t-image
v-if="getItemPhotoURL(item)"
:src="getItemPhotoURL(item)"
:alt="getItemName(item)"
fit="cover"
class="avatar"
/>
<div
v-else
class="avatar fallback"
v-text="getItemName(item).slice(0, 1)"
/>
</template>
<div class="content">
<div class="photo">
<t-image
v-if="getItemPhotoURL(item)"
:src="getItemPhotoURL(item)"
:alt="getItemName(item)"
fit="cover"
class="avatar"
/>
<div
v-else
class="avatar fallback"
v-text="getItemName(item).slice(0, 1)"
/>
</div>
<div class="main">
<span class="name" v-text="getItemLabel(item)" />
<t-tag v-if="item.gifted" size="small" theme="success" content="赠" />
<t-input
class="input"
:model-value="item.totalQuantity"
type="number"
:readonly="!canEditItem(item)"
placeholder="总权益数量"
borderless
align="right"
@update:model-value="updateItemQuantity(index, $event)"
>
</t-input>
<div class="actions">
<t-button
size="extra-small"
variant="outline"
:content="getItemUnit(item)?.name || '选择单位'"
@click="openItemUnitPicker(index)"
/>
<t-button
v-if="canRemoveItem(item)"
class="remove"
size="extra-small"
theme="danger"
variant="text"
content="移除"
@click="removePurchaseItem(index)"
<div class="title">
<div class="heading">
<div class="name-tags">
<strong v-text="getItemName(item)" />
<div v-if="hasItemSkuText(item)" class="sku-tags">
<product-sku-tags
:product-name="getItemName(item)"
:fallback="getItemSkuFallback(item)"
/>
</div>
<t-tag v-if="item.gifted" size="small" theme="success" content="赠" />
</div>
<t-button
v-if="canRemoveItem(item)"
class="remove"
size="extra-small"
theme="danger"
variant="text"
content="移除"
@click="removePurchaseItem(index)"
/>
</div>
</div>
<div class="input">
<div class="quantity">
<t-stepper
:model-value="getItemQuantity(item)"
class="stepper"
size="large"
:max="Number.MAX_SAFE_INTEGER"
:min="0"
:step="getQuantityStep(item)"
:integer="!getItemSku(item)?.allowDecimalQuantity"
:disabled="!canEditItem(item)"
theme="outline"
@update:model-value="updateItemQuantity(index, $event)"
/>
<t-button
class="unit"
size="extra-small"
variant="outline"
:content="getItemUnit(item)?.name || '选择单位'"
:disabled="!canEditItem(item)"
@click.stop="openItemUnitPicker(index)"
/>
</div>
<t-input
v-if="item.gifted"
class="gift-remark"
:model-value="item.remark || ''"
align="right"
borderless
placeholder="赠送说明(选填)"
@update:model-value="updateItemRemark(index, $event)"
/>
</div>
</div>
<t-input
v-if="item.gifted"
class="gift-remark"
:model-value="item.remark || ''"
align="right"
borderless
placeholder="赠送说明(选填)"
@update:model-value="updateItemRemark(index, $event)"
/>
</div>
</t-form-item>
<product-select-form-item
@@ -325,6 +342,7 @@ import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
import CustomerSelector from "@/components/CustomerSelector.vue";
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
import ProductSelectFormItem from "@/components/productSelector/ProductSelectFormItem.vue";
import ProductSkuTags from "@/components/ProductSkuTags.vue";
import ProductStockPreview from "@/components/ProductStockPreview.vue";
import { usePackagePurchase } from "@/pages/package/usePackagePurchase";
import type { Customer } from "@/types/Customer";
@@ -347,7 +365,7 @@ import { permissionCodes } from "@/utils/permission";
import { buildProductStockPreview, getProductStockShortageMessage, mergeProductStockRequirements } from "@/utils/productStock";
import type { ProductStockPreviewItem } from "@/utils/productStock";
import { uploadPhotoList } from "@/utils/photo";
import { getProductPhotoURL, getProductSkuSnapshotText } from "@/utils/product";
import { getProductPhotoURL, getProductQuantityStep, getProductSkuSnapshotText } from "@/utils/product";
@@ -586,16 +604,26 @@ function getConfigProductText(item: PackageConfigItem): string {
return `${item.productNameSnapshot || "未命名产品"}${skuText ? `(${skuText})` : " "}${quantity}${item.unitSnapshot ? ` ${item.unitSnapshot}` : ""}`;
}
function getItemLabel(item: PackagePurchaseItem): string {
function getItemSkuFallback(item: PackagePurchaseItem): string {
const configItem = config.value?.itemList?.find(configItem => configItem.skuId === item.skuId);
const product = item.gifted ? giftProductMap[item.skuId] : undefined;
const productName = item.gifted
? product?.name || item.productNameSnapshot || "未命名产品"
: configItem?.productNameSnapshot || "未命名产品";
const skuName = item.gifted ? item.skuNameSnapshot || getItemSku(item)?.name : configItem?.skuNameSnapshot;
const specSummary = item.gifted ? item.specSummarySnapshot || getItemSku(item)?.specSummary : configItem?.specSummarySnapshot;
const skuText = getProductSkuSnapshotText(productName, skuName, specSummary);
return skuText ? `${productName} · ${skuText}` : productName;
const sku = getItemSku(item);
if (item.gifted) {
return item.specSummarySnapshot || item.skuNameSnapshot || sku?.specSummary || sku?.name || "";
}
return configItem?.specSummarySnapshot || configItem?.skuNameSnapshot || sku?.specSummary || sku?.name || "";
}
function hasItemSkuText(item: PackagePurchaseItem): boolean {
return Boolean(getProductSkuSnapshotText(getItemName(item), getItemSkuFallback(item)));
}
function getItemQuantity(item: PackagePurchaseItem): number {
const quantity = Number(item.totalQuantity);
return Number.isFinite(quantity) && 0 < quantity ? quantity : 0;
}
function getQuantityStep(item: PackagePurchaseItem): number {
return getProductQuantityStep(getItemSku(item));
}
function getItemName(item: PackagePurchaseItem): string {
@@ -1013,63 +1041,99 @@ watch(config, value => {
}
}
.items {
gap: .5rem;
flex: 1;
margin: 0;
display: grid;
.detail {
padding: 0;
.title {
font-size: .8125rem;
margin-bottom: .5rem;
}
.items {
--td-button-extra-small-height: 24px;
.item {
padding: 6px;
box-shadow: .25rem .25rem 1rem rgba(0, 0, 0, .08);
border-radius: 1rem;
width: 100%;
margin: 0;
.avatar {
width: 2rem;
height: 2rem;
border-radius: .5rem !important;
}
.item {
min-width: 0;
&::after {
display: none;
}
.content {
gap: .25rem;
display: flex;
flex-direction: column;
.main {
gap: .25rem;
.content {
gap: .5rem;
width: 100%;
min-width: 0;
flex: 1 1 auto;
display: flex;
align-items: center;
.name {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
.photo {
display: flex;
.avatar {
width: 3.5rem;
height: 3.5rem;
border-radius: .5rem !important;
}
}
.input {
.main {
flex: 1;
min-width: 0;
margin-top: .2rem;
}
.actions {
gap: .25rem;
margin: .1rem 0 0 .75rem;
display: flex;
}
flex-direction: column;
justify-content: space-between;
.gift-remark {
padding: 0;
.title {
min-width: 0;
display: flex;
flex-direction: column;
.heading {
gap: .5rem;
display: flex;
min-width: 0;
align-items: baseline;
.name-tags {
gap: .5rem;
flex: 1 1 0;
min-width: 0;
display: flex;
overflow: hidden;
align-items: center;
strong {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
}
}
}
.input {
gap: .5rem;
min-width: 0;
display: flex;
flex-direction: column;
}
.sku-tags {
gap: .375rem;
display: flex;
flex-wrap: wrap;
align-items: center;
}
.gift-remark {
padding: 0;
}
.quantity {
gap: .5rem;
display: flex;
min-width: 0;
align-items: center;
justify-content: end;
.unit {
font-size: .875rem;
}
}
}
}
}