style(product): lighter color for in/out stock calendar

This commit is contained in:
Timi
2026-11-14 00:00:26 +08:00
parent 1f5c80cd7d
commit e0434a76c4
@@ -36,10 +36,16 @@
</template>
<template #day="{ day }">
<template v-if="selection">
<span v-if="daily(day)?.inQuantity" class="quantity in"
v-text="formatQuantity(daily(day)?.inQuantity)" />
<span v-if="daily(day)?.outQuantity" class="quantity out"
v-text="formatQuantity(daily(day)?.outQuantity)" />
<span
v-if="daily(day)?.inQuantity"
class="quantity in"
v-text="formatQuantity(daily(day)?.inQuantity)"
/>
<span
v-if="daily(day)?.outQuantity"
class="quantity out"
v-text="formatQuantity(daily(day)?.outQuantity)"
/>
</template>
<span class="movement-bar" :style="movementStyle(day)" />
</template>
@@ -54,6 +60,7 @@
<bottom-popup
v-model="visible"
:title="`${selectedDate} 库存流水`"
height="80vh"
left-button-text="关闭"
@left-button-click="visible = false"
>
@@ -63,38 +70,67 @@
<t-segmented block :value="direction" :options="directionOptions" @change="changeDirection" />
</div>
<div class="record-list">
<t-cell-group v-if="records.length" class="list empty-cell-title-margin" theme="card">
<t-cell v-for="record in records" :key="record.id" class="item">
<template #leftIcon>
<t-image v-if="getCustomerPhotoURL(record.customer, 64)" :src="getCustomerPhotoURL(record.customer, 64)"
:alt="getCustomerText(record)" fit="cover" class="avatar" />
<div v-else-if="record.customer" class="avatar fallback" v-text="getCustomerText(record).slice(0, 1)" />
<t-image v-else-if="record.operator" :src="getOperatorAvatar(record)" :alt="getOperatorText(record)" fit="cover" class="avatar" />
<span v-else class="icon" :class="getDeltaClass(record.onHandDelta)"><t-icon name="history" size="1.25rem" /></span>
</template>
<template #title>
<div class="record-title">
<span v-if="record.customer" class="actor" v-text="getCustomerText(record)" />
<span v-else-if="record.operator" class="actor" v-text="getOperatorText(record)" />
<strong class="operation" :class="getOperationClass(record.operationType)" v-text="getStockOperationText(record.operationType)" />
<strong class="product-name" v-text="record.productNameSnapshot || '未命名产品'" />
<t-tag v-if="record.skuNameSnapshot && record.productNameSnapshot !== record.skuNameSnapshot"
size="small" :content="record.skuNameSnapshot" />
<span v-if="record.quantity !== undefined && record.quantity !== null && record.quantity !== ''"
class="record-quantity" v-text="`${getProductQuantityText(record.quantity)} ${record.unitSnapshot || ''}`" />
</div>
</template>
<template #description>
<div class="description">
<time-label :timestamp="record.occurredAt" underline />
<div><span class="delta" :class="getDeltaClass(record.onHandDelta)" v-text="getDeltaText(record.onHandDelta)" /></div>
</div>
</template>
</t-cell>
</t-cell-group>
<t-empty v-else-if="!recordsLoading" description="当天暂无流水" />
<t-button v-if="!noMore" block variant="text" :loading="recordsLoading" @click="loadRecords">加载更多
</t-button>
<t-cell-group v-if="records.length" class="list empty-cell-title-margin" theme="card">
<t-cell v-for="record in records" :key="record.id" class="item">
<template #leftIcon>
<t-image
v-if="getCustomerPhotoURL(record.customer, 64)"
:src="getCustomerPhotoURL(record.customer, 64)"
:alt="getCustomerText(record)"
fit="cover"
class="avatar"
/>
<div
v-else-if="record.customer"
class="avatar fallback"
v-text="getCustomerText(record).slice(0, 1)"
/>
<t-image
v-else-if="record.operator"
:src="getOperatorAvatar(record)"
:alt="getOperatorText(record)"
fit="cover"
class="avatar"
/>
<span
v-else
class="icon"
:class="getDeltaClass(record.onHandDelta)"
>
<t-icon name="history" size="1.25rem" />
</span>
</template>
<template #title>
<div class="record-title">
<span v-if="record.customer" class="actor" v-text="getCustomerText(record)" />
<span v-else-if="record.operator" class="actor"
v-text="getOperatorText(record)" />
<strong class="operation" :class="getOperationClass(record.operationType)"
v-text="getStockOperationText(record.operationType)" />
<strong class="product-name"
v-text="record.productNameSnapshot || '未命名产品'" />
<t-tag
v-if="record.skuNameSnapshot && record.productNameSnapshot !== record.skuNameSnapshot"
size="small" :content="record.skuNameSnapshot" />
<span
v-if="record.quantity !== undefined && record.quantity !== null && record.quantity !== ''"
class="record-quantity"
v-text="`${getProductQuantityText(record.quantity)} ${record.unitSnapshot || ''}`" />
</div>
</template>
<template #description>
<div class="description">
<time-label :timestamp="record.occurredAt" underline />
<div><span class="delta" :class="getDeltaClass(record.onHandDelta)"
v-text="getDeltaText(record.onHandDelta)" /></div>
</div>
</template>
</t-cell>
</t-cell-group>
<t-empty v-else-if="!recordsLoading" description="当天暂无流水" />
<t-button v-if="!noMore" block variant="text" :loading="recordsLoading" @click="loadRecords">
加载更多
</t-button>
</div>
</template>
<t-empty v-else description="暂无库存流水查看权限" />
@@ -152,25 +188,39 @@ function getCustomerText(record: StockRecord): string {
function getOperatorText(record: StockRecord): string {
return record.operator?.nick || record.operator?.name || "未知操作人";
}
function getOperatorAvatar(record: StockRecord): string {
return UserAPI.getAvatarURL(record.operator) || buildFallbackAvatar(getOperatorText(record), "#0f766e");
}
function getOperationClass(type?: string): string {
return ({
INITIAL_IN: "initial-in", MANUAL_IN: "manual-in", MANUAL_OUT: "manual-out", MANUAL_REVOKE: "manual-revoke",
ORDER_RESERVE: "order-reserve", ORDER_RELEASE: "order-release", ORDER_OUT: "order-out", ORDER_REVOKE: "order-revoke",
ORDER_RETURN_IN: "return-in", POINT_REDEMPTION_OUT: "manual-out", POINT_REDEMPTION_RETURN_IN: "return-in",
STOCKTAKE_GAIN: "stocktake-gain", STOCKTAKE_LOSS: "stocktake-loss"
INITIAL_IN: "initial-in",
MANUAL_IN: "manual-in",
MANUAL_OUT: "manual-out",
MANUAL_REVOKE: "manual-revoke",
ORDER_RESERVE: "order-reserve",
ORDER_RELEASE: "order-release",
ORDER_OUT: "order-out",
ORDER_REVOKE: "order-revoke",
ORDER_RETURN_IN: "return-in",
POINT_REDEMPTION_OUT: "manual-out",
POINT_REDEMPTION_RETURN_IN: "return-in",
STOCKTAKE_GAIN: "stocktake-gain",
STOCKTAKE_LOSS: "stocktake-loss"
} as Record<string, string>)[type || ""] || "unknown";
}
function getDeltaClass(value?: number | string): string {
const amount = Number(value || 0);
return 0 < amount ? "positive" : amount < 0 ? "negative" : "gray";
}
function getDeltaText(value?: number | string): string {
const amount = Number(value || 0);
return `${0 < amount ? "+" : amount < 0 ? "-" : ""}${getProductQuantityText(String(value || "0").replace(/^-/, ""))}`;
}
function nextUnit(): void {
unitIndex.value = (unitIndex.value + 1) % units.value.length;
}
@@ -186,7 +236,7 @@ function movementStyle(day: MonthCalendarDay): Record<string, string> {
const outgoing = Math.abs(Number(item?.outQuantity) || 0);
if (!incoming && !outgoing) return { background: "var(--td-component-stroke)" };
const percentage = incoming / (incoming + outgoing) * 100;
return { background: `linear-gradient(90deg, var(--tui-green) ${percentage}%, var(--tui-red) ${percentage}%)` };
return { background: `linear-gradient(90deg, var(--td-success-color-4) ${percentage}%, var(--td-error-color-4) ${percentage}%)` };
}
function selectProduct(value: ProductSelection): void {
@@ -251,9 +301,11 @@ const selectedDate = ref("");
const selectedStart = ref(0);
const direction = ref<StockRecordDirection>("IN");
const directionOptions = [{ label: "入库", value: "IN" }, { label: "出库", value: "OUT" }];
async function changeDirection(event: { value: string | number }): Promise<void> {
if (event.value === "IN" || event.value === "OUT") await selectDirection(event.value);
}
const records = ref<StockRecord[]>([]);
const recordsLoading = ref(false);
const noMore = ref(false);
@@ -388,9 +440,25 @@ watch(() => props.storeId, () => {
height: 3.5rem;
}
.list { margin: 0; }
.item { padding: .625rem; min-width: 0; }
.icon { width: 2.25rem; height: 2.25rem; display: inline-flex; background: var(--td-bg-color-secondarycontainer); align-items: center; border-radius: 50%; justify-content: center; }
.list {
margin: 0;
}
.item {
padding: .625rem;
min-width: 0;
}
.icon {
width: 2.25rem;
height: 2.25rem;
display: inline-flex;
background: var(--td-bg-color-secondarycontainer);
align-items: center;
border-radius: 50%;
justify-content: center;
}
.record-title {
gap: .25rem;
display: flex;
@@ -399,40 +467,135 @@ watch(() => props.storeId, () => {
font-size: .75rem;
align-items: center;
white-space: nowrap;
.actor { flex: 0 0 auto; color: var(--td-text-color-brand); }
.operation, .record-quantity { flex: 0 0 auto; }
.actor {
flex: 0 0 auto;
color: var(--td-text-color-brand);
}
.operation, .record-quantity {
flex: 0 0 auto;
}
.operation {
color: var(--operation-color, var(--td-text-color-secondary));
&.initial-in { --operation-color: #2563eb; }
&.manual-in { --operation-color: #15803d; }
&.manual-out { --operation-color: #c2410c; }
&.manual-revoke { --operation-color: #be123c; }
&.order-reserve { --operation-color: #7c3aed; }
&.order-release { --operation-color: #0891b2; }
&.order-out { --operation-color: #dc2626; }
&.order-revoke { --operation-color: #4f46e5; }
&.return-in { --operation-color: #15803d; }
&.stocktake-gain { --operation-color: #0f766e; }
&.stocktake-loss { --operation-color: #a16207; }
&.initial-in {
--operation-color: #2563eb;
}
&.manual-in {
--operation-color: #15803d;
}
&.manual-out {
--operation-color: #c2410c;
}
&.manual-revoke {
--operation-color: #be123c;
}
&.order-reserve {
--operation-color: #7c3aed;
}
&.order-release {
--operation-color: #0891b2;
}
&.order-out {
--operation-color: #dc2626;
}
&.order-revoke {
--operation-color: #4f46e5;
}
&.return-in {
--operation-color: #15803d;
}
&.stocktake-gain {
--operation-color: #0f766e;
}
&.stocktake-loss {
--operation-color: #a16207;
}
}
.product-name {
overflow: hidden;
flex: 0 1 auto;
text-overflow: ellipsis;
}
.record-quantity {
color: var(--td-text-color-secondary);
}
.product-name { overflow: hidden; flex: 0 1 auto; text-overflow: ellipsis; }
.record-quantity { color: var(--td-text-color-secondary); }
}
.description { gap: .5rem; display: flex; font-size: .75rem; align-items: center; justify-content: space-between; }
.delta { font-size: 1.25rem; }
.positive { color: var(--td-success-color); }
.negative { color: var(--td-error-color); }
.description {
gap: .5rem;
display: flex;
font-size: .75rem;
align-items: center;
justify-content: space-between;
}
.delta {
font-size: 1.25rem;
}
.positive {
color: var(--td-success-color);
}
.negative {
color: var(--td-error-color);
}
}
:global(html.theme-dark) .records .operation {
&.initial-in { --operation-color: #93c5fd; }
&.manual-in, &.return-in { --operation-color: #86efac; }
&.manual-out { --operation-color: #fdba74; }
&.manual-revoke { --operation-color: #fda4af; }
&.order-reserve { --operation-color: #c4b5fd; }
&.order-release { --operation-color: #67e8f9; }
&.order-out { --operation-color: #fca5a5; }
&.order-revoke { --operation-color: #a5b4fc; }
&.stocktake-gain { --operation-color: #5eead4; }
&.stocktake-loss { --operation-color: #fcd34d; }
&.initial-in {
--operation-color: #93c5fd;
}
&.manual-in, &.return-in {
--operation-color: #86efac;
}
&.manual-out {
--operation-color: #fdba74;
}
&.manual-revoke {
--operation-color: #fda4af;
}
&.order-reserve {
--operation-color: #c4b5fd;
}
&.order-release {
--operation-color: #67e8f9;
}
&.order-out {
--operation-color: #fca5a5;
}
&.order-revoke {
--operation-color: #a5b4fc;
}
&.stocktake-gain {
--operation-color: #5eead4;
}
&.stocktake-loss {
--operation-color: #fcd34d;
}
}
</style>