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