feat(supply-chain): 精简前置仓页面并新增下单重量
This commit is contained in:
parent
733b98792e
commit
f232e1adab
@ -1,7 +1,15 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect, useRef, useState, type ChangeEvent } from 'react'
|
||||
import { ChevronDown, Download, RotateCcw, Search, Upload } from 'lucide-react'
|
||||
import {
|
||||
ChevronDown,
|
||||
Download,
|
||||
RefreshCw,
|
||||
RotateCcw,
|
||||
Search,
|
||||
Send,
|
||||
Upload,
|
||||
} from 'lucide-react'
|
||||
import {
|
||||
parseFrontWarehouseInventoryFilterValues,
|
||||
type FrontWarehouseInventoryFacets,
|
||||
@ -24,12 +32,15 @@ export function FrontWarehouseInventoryFilters({
|
||||
onFiltersChange,
|
||||
onQuery,
|
||||
onReset,
|
||||
onPush,
|
||||
onRefresh,
|
||||
onExport,
|
||||
onImportFile,
|
||||
onDownloadTemplate,
|
||||
canEdit,
|
||||
canDownload,
|
||||
loading,
|
||||
pushing,
|
||||
exporting,
|
||||
importing,
|
||||
downloadingTemplate,
|
||||
@ -39,12 +50,15 @@ export function FrontWarehouseInventoryFilters({
|
||||
onFiltersChange: (filters: Filters) => void
|
||||
onQuery: (filters: Filters) => void
|
||||
onReset: () => void
|
||||
onPush?: () => void
|
||||
onRefresh?: () => void
|
||||
onExport: () => void
|
||||
onImportFile: (file: File, mode: ImportMode) => void
|
||||
onDownloadTemplate: (mode: ImportMode) => void
|
||||
canEdit: boolean
|
||||
canDownload: boolean
|
||||
loading: boolean
|
||||
pushing?: boolean
|
||||
exporting: boolean
|
||||
importing: boolean
|
||||
downloadingTemplate: boolean
|
||||
@ -167,6 +181,28 @@ export function FrontWarehouseInventoryFilters({
|
||||
<RotateCcw size={14} />
|
||||
重置
|
||||
</button>
|
||||
{onPush ? (
|
||||
<button
|
||||
type="button"
|
||||
className={styles.pushButton}
|
||||
disabled={loading || pushing}
|
||||
onClick={onPush}
|
||||
>
|
||||
<Send size={14} />
|
||||
{pushing ? '推送中…' : '推送到下单表'}
|
||||
</button>
|
||||
) : null}
|
||||
{onRefresh ? (
|
||||
<button
|
||||
type="button"
|
||||
className={styles.secondaryButton}
|
||||
disabled={loading}
|
||||
onClick={onRefresh}
|
||||
>
|
||||
<RefreshCw size={14} className={loading ? styles.spinning : undefined} />
|
||||
刷新数据
|
||||
</button>
|
||||
) : null}
|
||||
{canEdit ? (
|
||||
<div ref={importMenuRef} className={styles.importMenuWrap}>
|
||||
<button
|
||||
|
||||
@ -39,7 +39,13 @@ const initialData: FrontWarehouseInventoryPage = {
|
||||
pageSize: 100,
|
||||
total: 1,
|
||||
totalPages: 1,
|
||||
summary: { total: 1, qualified: 1, transferQty: 0, finalOrderQty: row.finalOrderQty },
|
||||
summary: {
|
||||
total: 1,
|
||||
qualified: 1,
|
||||
transferQty: 0,
|
||||
finalOrderQty: row.finalOrderQty,
|
||||
orderWeight: row.orderWeight,
|
||||
},
|
||||
facets: { ratings: ['A'], purchaseOwners: ['采购A'], purchaseTypes: ['简尚-崔桥工厂仓'] },
|
||||
sourceStatus: {
|
||||
generatedAt: '2026-10-21T03:00:00.000Z',
|
||||
@ -55,18 +61,23 @@ describe('FrontWarehouseInventoryView', () => {
|
||||
it('renders the requirement fields, summary and calculated row', () => {
|
||||
render(<FrontWarehouseInventoryView initialData={initialData} canEdit canDownload />)
|
||||
|
||||
expect(screen.getByRole('heading', { name: '前置仓进销存管理' })).toBeInTheDocument()
|
||||
expect(screen.queryByRole('heading', { name: '前置仓进销存管理' })).not.toBeInTheDocument()
|
||||
expect(screen.getByRole('columnheader', { name: '商品编码' })).toBeInTheDocument()
|
||||
expect(screen.getByRole('columnheader', { name: '是否满足南昌樵舍仓选品需求' })).toBeInTheDocument()
|
||||
expect(screen.getByRole('columnheader', { name: '备货后可使用天数-基于最终下单量' })).toBeInTheDocument()
|
||||
expect(screen.getByRole('columnheader', { name: '条码创建时间' })).toBeInTheDocument()
|
||||
expect(screen.getByRole('columnheader', { name: '下单重量' })).toBeInTheDocument()
|
||||
expect(screen.getByText('BAR001')).toBeInTheDocument()
|
||||
expect(screen.getByText('2025-11-17 07:56')).toBeInTheDocument()
|
||||
const summary = screen.getByText('当前筛选').closest('section')!
|
||||
expect(within(summary).getByText(String(row.finalOrderQty))).toBeInTheDocument()
|
||||
expect(within(summary).getByText('下单重量')).toBeInTheDocument()
|
||||
expect(screen.getByRole('button', { name: '重置' })).toBeInTheDocument()
|
||||
expect(screen.getByRole('button', { name: '导出' })).toBeInTheDocument()
|
||||
expect(screen.getByRole('button', { name: '推送到下单表' })).toBeInTheDocument()
|
||||
const pushButton = screen.getByRole('button', { name: '推送到下单表' })
|
||||
const refreshButton = screen.getByRole('button', { name: '刷新数据' })
|
||||
expect(pushButton).toBeInTheDocument()
|
||||
expect(pushButton.parentElement).toBe(refreshButton.parentElement)
|
||||
const subpageTabs = screen.getByRole('navigation', { name: '前置仓进销存管理子页面' })
|
||||
expect(within(subpageTabs).getByRole('link', { name: '前置仓进销存' }))
|
||||
.toHaveAttribute('aria-current', 'page')
|
||||
@ -290,7 +301,7 @@ describe('FrontWarehouseInventoryView', () => {
|
||||
/>,
|
||||
)
|
||||
|
||||
expect(screen.getByRole('heading', { name: '前置仓下单表' })).toBeInTheDocument()
|
||||
expect(screen.queryByRole('heading', { name: '前置仓下单表' })).not.toBeInTheDocument()
|
||||
expect(screen.queryByRole('button', { name: '推送到下单表' })).not.toBeInTheDocument()
|
||||
expect(screen.queryByRole('spinbutton', { name: '最终下单量 BAR001' }))
|
||||
.not.toBeInTheDocument()
|
||||
@ -298,8 +309,9 @@ describe('FrontWarehouseInventoryView', () => {
|
||||
expect(screen.getByText(/推送 10\/24 11:00/)).toBeInTheDocument()
|
||||
expect(screen.getByRole('link', { name: '前置仓下单表' }))
|
||||
.toHaveAttribute('aria-current', 'page')
|
||||
expect(screen.queryByRole('button', { name: '刷新数据' })).not.toBeInTheDocument()
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: '刷新数据' }))
|
||||
fireEvent.click(screen.getByRole('button', { name: '查询' }))
|
||||
await waitFor(() => expect(fetchMock).toHaveBeenCalledTimes(1))
|
||||
const request = new URL(String(fetchMock.mock.calls[0][0]), 'http://localhost')
|
||||
expect(request.pathname).toBe('/api/supply-chain/management/front-warehouse-order')
|
||||
@ -318,11 +330,12 @@ describe('FrontWarehouseInventoryView', () => {
|
||||
/>,
|
||||
)
|
||||
|
||||
expect(screen.getByRole('heading', { name: '前置仓下单表' })).toBeInTheDocument()
|
||||
expect(screen.queryByRole('heading', { name: '前置仓下单表' })).not.toBeInTheDocument()
|
||||
expect(screen.queryByRole('link', { name: '前置仓进销存' })).not.toBeInTheDocument()
|
||||
expect(screen.getByRole('link', { name: '前置仓下单表' }))
|
||||
.toHaveAttribute('aria-current', 'page')
|
||||
expect(screen.queryByRole('button', { name: '推送到下单表' })).not.toBeInTheDocument()
|
||||
expect(screen.queryByRole('button', { name: '刷新数据' })).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('edits purchase feedback directly in the detail row and saves on blur', async () => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import { ChevronLeft, ChevronRight, RefreshCw, Send } from 'lucide-react'
|
||||
import { ChevronLeft, ChevronRight } from 'lucide-react'
|
||||
import Link from 'next/link'
|
||||
import type { FrontWarehouseInventoryPage } from '@/lib/front-warehouse-inventory'
|
||||
import { FrontWarehouseBatchToolbar } from './FrontWarehouseBatchToolbar'
|
||||
@ -51,44 +51,6 @@ export function FrontWarehouseInventoryView({
|
||||
前置仓下单表
|
||||
</Link>
|
||||
</nav>
|
||||
<header className={styles.header}>
|
||||
<div>
|
||||
<h1>{orderMode ? '前置仓下单表' : '前置仓进销存管理'}</h1>
|
||||
<p>
|
||||
{orderMode
|
||||
? '前置仓进销存管理的冻结数据,仅在进销存管理点击“推送到下单表”后更新'
|
||||
: '按需求文档 1.0 计算南昌樵舍仓选品、移库与补货计划'}
|
||||
</p>
|
||||
</div>
|
||||
<div className={styles.headerActions}>
|
||||
{!orderMode && canEdit ? (
|
||||
<button
|
||||
type="button"
|
||||
className={styles.pushButton}
|
||||
disabled={controller.pushing || controller.loading}
|
||||
onClick={() => void controller.pushToOrderTable()}
|
||||
>
|
||||
<Send size={15} />
|
||||
{controller.pushing ? '推送中…' : '推送到下单表'}
|
||||
</button>
|
||||
) : null}
|
||||
<button
|
||||
type="button"
|
||||
className={styles.refreshButton}
|
||||
disabled={controller.loading}
|
||||
onClick={() => void controller.loadPage(
|
||||
controller.filters,
|
||||
data.page,
|
||||
!orderMode,
|
||||
!orderMode && canEdit,
|
||||
)}
|
||||
>
|
||||
<RefreshCw size={15} className={controller.loading ? styles.spinning : undefined} />
|
||||
刷新数据
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section className={styles.sourceBar} aria-label="数据时间">
|
||||
<span>档案 {formatFrontWarehouseTimestamp(data.sourceStatus.archiveUpdatedAt)}</span>
|
||||
<span>库存 {formatFrontWarehouseTimestamp(data.sourceStatus.inventorySyncedAt)}</span>
|
||||
@ -112,6 +74,10 @@ export function FrontWarehouseInventoryView({
|
||||
<div><span>满足选品</span><strong>{data.summary.qualified.toLocaleString('zh-CN')}</strong></div>
|
||||
<div><span>移库数量</span><strong>{data.summary.transferQty.toLocaleString('zh-CN')}</strong></div>
|
||||
<div><span>最终下单量</span><strong>{data.summary.finalOrderQty.toLocaleString('zh-CN')}</strong></div>
|
||||
<div>
|
||||
<span>下单重量</span>
|
||||
<strong>{data.summary.orderWeight.toLocaleString('zh-CN', { maximumFractionDigits: 3 })} 吨</strong>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<FrontWarehouseInventoryFiltersPanel
|
||||
@ -120,12 +86,20 @@ export function FrontWarehouseInventoryView({
|
||||
onFiltersChange={controller.setFilters}
|
||||
onQuery={(next) => void controller.loadPage(next, 1)}
|
||||
onReset={controller.resetFilters}
|
||||
onPush={!orderMode && canEdit ? () => void controller.pushToOrderTable() : undefined}
|
||||
onRefresh={!orderMode ? () => void controller.loadPage(
|
||||
controller.filters,
|
||||
data.page,
|
||||
true,
|
||||
canEdit,
|
||||
) : undefined}
|
||||
onExport={() => void controller.exportCurrentRows()}
|
||||
onImportFile={(file, mode) => void controller.importFile(file, mode)}
|
||||
onDownloadTemplate={(mode) => void controller.downloadImportTemplate(mode)}
|
||||
canEdit={canEdit}
|
||||
canDownload={canDownload}
|
||||
loading={controller.loading}
|
||||
pushing={controller.pushing}
|
||||
exporting={controller.exporting}
|
||||
importing={controller.importing}
|
||||
downloadingTemplate={controller.downloadingTemplate}
|
||||
|
||||
@ -54,30 +54,6 @@
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
min-height: 52px;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
border-bottom: 1px solid var(--sc-border);
|
||||
background: var(--sc-surface);
|
||||
padding: 0 0 12px;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.header p {
|
||||
margin: 5px 0 0;
|
||||
color: var(--sc-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.refreshButton,
|
||||
.pushButton,
|
||||
.secondaryButton,
|
||||
.primaryButton {
|
||||
@ -102,19 +78,12 @@
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.headerActions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.primaryButton {
|
||||
border-color: var(--wb-accent, #2563eb);
|
||||
background: var(--wb-accent, #2563eb);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.refreshButton:disabled,
|
||||
.pushButton:disabled,
|
||||
.secondaryButton:disabled,
|
||||
.primaryButton:disabled {
|
||||
@ -161,7 +130,7 @@
|
||||
|
||||
.summary {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||
border-bottom: 1px solid var(--sc-border);
|
||||
background: #fff;
|
||||
}
|
||||
@ -1185,11 +1154,6 @@ tbody .stickyColumn {
|
||||
height: 360px;
|
||||
}
|
||||
|
||||
.header {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.subpageTabs {
|
||||
margin-right: calc(var(--wb-panel-inset, 12px) * -1);
|
||||
margin-left: calc(var(--wb-panel-inset, 12px) * -1);
|
||||
@ -1200,11 +1164,11 @@ tbody .stickyColumn {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.summary > div:nth-child(2) {
|
||||
.summary > div:nth-child(even) {
|
||||
border-right: 0;
|
||||
}
|
||||
|
||||
.summary > div:nth-child(3) {
|
||||
.summary > div:nth-child(odd) {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
|
||||
@ -259,6 +259,7 @@ describe('front warehouse inventory calculations', () => {
|
||||
|
||||
expect(row.finalOrderQty).toBe(300)
|
||||
expect(row.availableDaysAfterFinalOrder).toBe(160)
|
||||
expect(row.orderWeight).toBe(3)
|
||||
expect(row.transferWeight).toBe(3)
|
||||
})
|
||||
|
||||
|
||||
@ -133,6 +133,7 @@ export type FrontWarehouseInventoryRow = {
|
||||
orderQtyAfterTransfer: number
|
||||
availableDaysAfterTransfer: number | null
|
||||
finalOrderQty: number
|
||||
orderWeight: number
|
||||
availableDaysAfterFinalOrder: number | null
|
||||
transferOutQty: number
|
||||
transferWarehouse: string
|
||||
@ -197,6 +198,7 @@ export const FRONT_WAREHOUSE_INVENTORY_COLUMNS: readonly FrontWarehouseInventory
|
||||
{ key: 'orderQtyAfterTransfer', label: '移库后需下单量', group: '库存与补货', width: 124, align: 'right' },
|
||||
{ key: 'availableDaysAfterTransfer', label: '备货后可使用天数-基于移库后', group: '库存与补货', width: 180, align: 'right' },
|
||||
{ key: 'finalOrderQty', label: '最终下单量', group: '库存与补货', width: 104, align: 'right' },
|
||||
{ key: 'orderWeight', label: '下单重量', group: '库存与补货', width: 104, align: 'right', fractionDigits: 3, hint: '单位:吨' },
|
||||
{ key: 'availableDaysAfterFinalOrder', label: '备货后可使用天数-基于最终下单量', group: '库存与补货', width: 196, align: 'right' },
|
||||
{ key: 'transferOutQty', label: '移仓数量', group: '移仓', width: 96, align: 'right' },
|
||||
{ key: 'transferWarehouse', label: '移仓仓库', group: '移仓', width: 128 },
|
||||
@ -236,6 +238,7 @@ export type FrontWarehouseInventorySummary = {
|
||||
qualified: number
|
||||
transferQty: number
|
||||
finalOrderQty: number
|
||||
orderWeight: number
|
||||
}
|
||||
|
||||
export type FrontWarehouseInventorySourceStatus = {
|
||||
@ -468,6 +471,7 @@ export function applyFrontWarehouseManualFinalOrderQty(
|
||||
(finalOrderQty + row.transferQty) * (row.weight ?? 0) / 1000,
|
||||
3,
|
||||
),
|
||||
orderWeight: rounded(finalOrderQty * (row.weight ?? 0) / 1000, 3),
|
||||
}
|
||||
}
|
||||
|
||||
@ -598,6 +602,7 @@ export function buildFrontWarehouseInventoryRow(input: {
|
||||
(finalOrderQty + transferQty) * (archive.weight ?? 0) / 1000,
|
||||
3,
|
||||
)
|
||||
const orderWeight = rounded(finalOrderQty * (archive.weight ?? 0) / 1000, 3)
|
||||
const adjustment = input.adjustment
|
||||
|
||||
return {
|
||||
@ -624,6 +629,7 @@ export function buildFrontWarehouseInventoryRow(input: {
|
||||
orderQtyAfterTransfer,
|
||||
availableDaysAfterTransfer,
|
||||
finalOrderQty,
|
||||
orderWeight,
|
||||
availableDaysAfterFinalOrder,
|
||||
transferOutQty: transferQty,
|
||||
transferWarehouse,
|
||||
@ -685,7 +691,8 @@ export function summarizeFrontWarehouseInventoryRows(rows: readonly FrontWarehou
|
||||
qualified: summary.qualified + (row.qualifies ? 1 : 0),
|
||||
transferQty: summary.transferQty + row.transferQty,
|
||||
finalOrderQty: summary.finalOrderQty + row.finalOrderQty,
|
||||
}), { total: 0, qualified: 0, transferQty: 0, finalOrderQty: 0 })
|
||||
orderWeight: summary.orderWeight + row.orderWeight,
|
||||
}), { total: 0, qualified: 0, transferQty: 0, finalOrderQty: 0, orderWeight: 0 })
|
||||
}
|
||||
|
||||
export function frontWarehouseColumnGroups(
|
||||
|
||||
@ -54,6 +54,7 @@ function rowFromStorage(row: StoredRow): FrontWarehouseInventoryRow {
|
||||
throw new Error(`前置仓下单表条码 ${row.barcode} 的快照内容损坏`)
|
||||
}
|
||||
const payload = row.payload as unknown as FrontWarehouseInventoryRow
|
||||
const finalOrderQty = row.finalOrderQty ?? payload.finalOrderQty
|
||||
return applyFrontWarehouseManualFinalOrderQty({
|
||||
...payload,
|
||||
barcode: row.barcode,
|
||||
@ -63,7 +64,10 @@ function rowFromStorage(row: StoredRow): FrontWarehouseInventoryRow {
|
||||
truckScheduledAt: row.truckScheduledAt,
|
||||
truckQuantity: row.truckQuantity,
|
||||
adjustmentUpdatedAt: row.feedbackUpdatedAt?.toISOString() ?? null,
|
||||
}, row.finalOrderQty ?? payload.finalOrderQty)
|
||||
orderWeight: typeof payload.orderWeight === 'number'
|
||||
? payload.orderWeight
|
||||
: finalOrderQty * (payload.weight ?? 0) / 1000,
|
||||
}, finalOrderQty)
|
||||
}
|
||||
|
||||
export class FrontWarehouseOrderRepositoryClass implements FrontWarehouseOrderRepository {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user