From e0434a76c41c5de0eaa3837bac7f51cff961c4c9 Mon Sep 17 00:00:00 2001 From: Timi Date: Sat, 14 Nov 2026 00:00:26 +0800 Subject: [PATCH] style(product): lighter color for in/out stock calendar --- .../component/ProductStockCalendar.vue | 309 +++++++++++++----- 1 file changed, 236 insertions(+), 73 deletions(-) diff --git a/src/pages/product/component/ProductStockCalendar.vue b/src/pages/product/component/ProductStockCalendar.vue index 6631e21..b69f830 100644 --- a/src/pages/product/component/ProductStockCalendar.vue +++ b/src/pages/product/component/ProductStockCalendar.vue @@ -36,10 +36,16 @@ @@ -54,6 +60,7 @@ @@ -63,38 +70,67 @@
- - - - - - - - - 加载更多 - + + + + + + + + + + 加载更多 +
@@ -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)[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 { 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("IN"); const directionOptions = [{ label: "入库", value: "IN" }, { label: "出库", value: "OUT" }]; + async function changeDirection(event: { value: string | number }): Promise { if (event.value === "IN" || event.value === "OUT") await selectDirection(event.value); } + const records = ref([]); 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; + } }