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" theme="primary"
content="赠送" 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> </div>
<span class="can-fulfill" v-text="getItemDescription(item)" /> <span class="can-fulfill" v-text="getItemDescription(item)" />
</div> </div>
</div> </div>
<div class="input"> <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"> <div class="quantity">
<t-stepper <t-stepper
v-model="quantityMap[item.id || '']" v-model="quantityMap[item.id || '']"
@@ -604,20 +604,12 @@ onUnmounted(() => {
.items { .items {
margin: 0 1rem; margin: 0 1rem;
background: var(--td-bg-color-container);
box-shadow: var(--td-shadow-1);
border-radius: 1rem; border-radius: 1rem;
overflow: hidden;
.item { .item {
padding: 10px; padding: 10px;
min-width: 0; min-width: 0;
:deep(.t-form__controls),
:deep(.t-form__controls-content) {
min-width: 0;
}
.content { .content {
gap: .5rem; gap: .5rem;
width: 100%; width: 100%;
@@ -682,7 +674,6 @@ onUnmounted(() => {
.input { .input {
gap: .5rem; gap: .5rem;
display: flex; display: flex;
margin-top: .5rem;
flex-direction: column; flex-direction: column;
.sku-tags { .sku-tags {
+172 -108
View File
@@ -92,70 +92,87 @@
placeholder="请输入成交价" placeholder="请输入成交价"
/> />
</t-form-item> </t-form-item>
<t-form-item v-if="config" label="购买权益明细" label-align="top"> <t-form-item v-if="config" class="detail" label-width="0">
<t-form class="items" label-width="2.5rem"> <t-form class="items" label-width="0">
<span v-if="!canPriceOverride">当前账号无定制权限,仅可等值转换单位</span> <span v-if="!canPriceOverride">当前账号无定制权限,仅可等值转换单位</span>
<t-form-item <t-form-item
v-for="(item, index) in packagePurchaseItemList" v-for="(item, index) in packagePurchaseItemList"
:key="`${index}-${item.skuId}-${item.skuUnitId}-${item.gifted}`" :key="`${index}-${item.skuId}-${item.skuUnitId}-${item.gifted}`"
class="item" 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="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"> <div class="main">
<span class="name" v-text="getItemLabel(item)" /> <div class="title">
<t-tag v-if="item.gifted" size="small" theme="success" content="赠" /> <div class="heading">
<t-input <div class="name-tags">
class="input" <strong v-text="getItemName(item)" />
:model-value="item.totalQuantity" <div v-if="hasItemSkuText(item)" class="sku-tags">
type="number" <product-sku-tags
:readonly="!canEditItem(item)" :product-name="getItemName(item)"
placeholder="总权益数量" :fallback="getItemSkuFallback(item)"
borderless />
align="right" </div>
@update:model-value="updateItemQuantity(index, $event)" <t-tag v-if="item.gifted" size="small" theme="success" content="赠" />
> </div>
</t-input> <t-button
<div class="actions"> v-if="canRemoveItem(item)"
<t-button class="remove"
size="extra-small" size="extra-small"
variant="outline" theme="danger"
:content="getItemUnit(item)?.name || '选择单位'" variant="text"
@click="openItemUnitPicker(index)" content="移除"
/> @click="removePurchaseItem(index)"
<t-button />
v-if="canRemoveItem(item)" </div>
class="remove" </div>
size="extra-small" <div class="input">
theme="danger" <div class="quantity">
variant="text" <t-stepper
content="移除" :model-value="getItemQuantity(item)"
@click="removePurchaseItem(index)" 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>
</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> </div>
</t-form-item> </t-form-item>
<product-select-form-item <product-select-form-item
@@ -325,6 +342,7 @@ import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
import CustomerSelector from "@/components/CustomerSelector.vue"; import CustomerSelector from "@/components/CustomerSelector.vue";
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue"; import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
import ProductSelectFormItem from "@/components/productSelector/ProductSelectFormItem.vue"; import ProductSelectFormItem from "@/components/productSelector/ProductSelectFormItem.vue";
import ProductSkuTags from "@/components/ProductSkuTags.vue";
import ProductStockPreview from "@/components/ProductStockPreview.vue"; import ProductStockPreview from "@/components/ProductStockPreview.vue";
import { usePackagePurchase } from "@/pages/package/usePackagePurchase"; import { usePackagePurchase } from "@/pages/package/usePackagePurchase";
import type { Customer } from "@/types/Customer"; import type { Customer } from "@/types/Customer";
@@ -347,7 +365,7 @@ import { permissionCodes } from "@/utils/permission";
import { buildProductStockPreview, getProductStockShortageMessage, mergeProductStockRequirements } from "@/utils/productStock"; import { buildProductStockPreview, getProductStockShortageMessage, mergeProductStockRequirements } from "@/utils/productStock";
import type { ProductStockPreviewItem } from "@/utils/productStock"; import type { ProductStockPreviewItem } from "@/utils/productStock";
import { uploadPhotoList } from "@/utils/photo"; 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}` : ""}`; 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 configItem = config.value?.itemList?.find(configItem => configItem.skuId === item.skuId);
const product = item.gifted ? giftProductMap[item.skuId] : undefined; const sku = getItemSku(item);
const productName = item.gifted if (item.gifted) {
? product?.name || item.productNameSnapshot || "未命名产品" return item.specSummarySnapshot || item.skuNameSnapshot || sku?.specSummary || sku?.name || "";
: configItem?.productNameSnapshot || "未命名产品"; }
const skuName = item.gifted ? item.skuNameSnapshot || getItemSku(item)?.name : configItem?.skuNameSnapshot; return configItem?.specSummarySnapshot || configItem?.skuNameSnapshot || sku?.specSummary || sku?.name || "";
const specSummary = item.gifted ? item.specSummarySnapshot || getItemSku(item)?.specSummary : configItem?.specSummarySnapshot; }
const skuText = getProductSkuSnapshotText(productName, skuName, specSummary);
return skuText ? `${productName} · ${skuText}` : productName; 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 { function getItemName(item: PackagePurchaseItem): string {
@@ -1013,63 +1041,99 @@ watch(config, value => {
} }
} }
.items { .detail {
gap: .5rem; padding: 0;
flex: 1;
margin: 0;
display: grid;
.title { .items {
font-size: .8125rem; --td-button-extra-small-height: 24px;
margin-bottom: .5rem;
}
.item { width: 100%;
padding: 6px; margin: 0;
box-shadow: .25rem .25rem 1rem rgba(0, 0, 0, .08);
border-radius: 1rem;
.avatar { .item {
width: 2rem; min-width: 0;
height: 2rem;
border-radius: .5rem !important;
}
&::after { .content {
display: none; gap: .5rem;
} width: 100%;
min-width: 0;
.content { flex: 1 1 auto;
gap: .25rem;
display: flex;
flex-direction: column;
.main {
gap: .25rem;
display: flex; display: flex;
align-items: center;
.name { .photo {
min-width: 0; display: flex;
overflow: hidden;
text-overflow: ellipsis; .avatar {
white-space: nowrap; width: 3.5rem;
height: 3.5rem;
border-radius: .5rem !important;
}
} }
.input { .main {
flex: 1; flex: 1;
min-width: 0; min-width: 0;
margin-top: .2rem;
}
.actions {
gap: .25rem;
margin: .1rem 0 0 .75rem;
display: flex; display: flex;
} flex-direction: column;
justify-content: space-between;
.gift-remark { .title {
padding: 0; 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;
}
}
} }
} }
} }