diff --git a/furniture-3d-system/src/app/supply-chain/management/production-stop-demands/ProductionStopDemandsView.test.tsx b/furniture-3d-system/src/app/supply-chain/management/production-stop-demands/ProductionStopDemandsView.test.tsx index 99b307e4..5c0a4b17 100644 --- a/furniture-3d-system/src/app/supply-chain/management/production-stop-demands/ProductionStopDemandsView.test.tsx +++ b/furniture-3d-system/src/app/supply-chain/management/production-stop-demands/ProductionStopDemandsView.test.tsx @@ -1210,6 +1210,26 @@ describe('停产需求管理视图', () => { ]) { expect(within(dialog).getByRole('columnheader', { name: header })).toBeInTheDocument() } + for (const resizerName of [ + '调整需求确认时间节点列宽', + '调整需求确认时效天数列宽', + '调整超时未确认是否自动同意停产列宽', + '调整即将超时预警时效(按小时配置)列宽', + ]) { + expect(within(dialog).getByRole('separator', { name: resizerName })).toBeInTheDocument() + } + const timeColumnResizer = within(dialog).getByRole('separator', { + name: '调整需求确认时间节点列宽', + }) + expect(timeColumnResizer).toHaveAttribute('aria-valuenow', '120') + fireEvent.keyDown(timeColumnResizer, { key: 'ArrowRight' }) + await waitFor(() => { + expect(timeColumnResizer).toHaveAttribute('aria-valuenow', '130') + }) + fireEvent.click(within(dialog).getByRole('button', { name: '重置列宽' })) + await waitFor(() => { + expect(timeColumnResizer).toHaveAttribute('aria-valuenow', '120') + }) expect(within(dialog).getByLabelText('即将超时预警时效(按小时配置)1')).toHaveValue(6) const addNodeButton = within(dialog).getByRole('button', { name: '新增节点' }) expect(addNodeButton).not.toBeDisabled() @@ -1221,7 +1241,9 @@ describe('停产需求管理视图', () => { sortOrder: 5, })) }) - const nameInputs = within(dialog).getAllByLabelText(/需求确认流程节点/) + const nameInputs = within(dialog).getAllByRole('textbox', { + name: /需求确认流程节点/, + }) fireEvent.change(nameInputs[0], { target: { value: '一级运营部门确认' } }) fireEvent.click(within(dialog).getAllByRole('button', { name: '保存' })[0]) await waitFor(() => { diff --git a/furniture-3d-system/src/app/supply-chain/management/production-stop-demands/ProductionStopDemandsView.tsx b/furniture-3d-system/src/app/supply-chain/management/production-stop-demands/ProductionStopDemandsView.tsx index d871daf0..84db3916 100644 --- a/furniture-3d-system/src/app/supply-chain/management/production-stop-demands/ProductionStopDemandsView.tsx +++ b/furniture-3d-system/src/app/supply-chain/management/production-stop-demands/ProductionStopDemandsView.tsx @@ -272,6 +272,29 @@ const PROCESS_STEPS: Array<{ }, ] const COLUMN_WIDTHS_STORAGE_KEY = 'supply-chain.production-stop-demands.column-widths.v1' +const WORKFLOW_COLUMN_WIDTHS_STORAGE_KEY = + 'supply-chain.production-stop-demands.workflow-column-widths.v1' +const WORKFLOW_CONFIG_COLUMNS = [ + { key: 'name', label: '需求确认流程节点', width: 140, minWidth: 110 }, + { key: 'confirmer', label: '需求确认人', width: 160, minWidth: 120 }, + { key: 'timeNode', label: '需求确认时间节点', width: 120, minWidth: 96 }, + { key: 'delayDays', label: '需求确认时效天数', width: 110, minWidth: 90 }, + { + key: 'timeoutAutoAgree', + label: '超时未确认是否自动同意停产', + width: 170, + minWidth: 140, + }, + { + key: 'nearDueWarningHours', + label: '即将超时预警时效(按小时配置)', + width: 150, + minWidth: 120, + }, + { key: 'note', label: '需求确认注释', width: 300, minWidth: 180 }, + { key: 'actions', label: '操作', width: 104, minWidth: 96 }, +] as const +type WorkflowConfigColumnKey = typeof WORKFLOW_CONFIG_COLUMNS[number]['key'] const COLUMN_SETTINGS_STORAGE_KEY = 'supply-chain.production-stop-demands.column-settings.v1' const COLUMN_SETTINGS_REVISION_STORAGE_KEY = 'supply-chain.production-stop-demands.column-settings-revision.v1' const COLUMN_SETTINGS_DEFAULT_ORDER_REVISION = '2026-11-21-user-default-order-v2' @@ -720,6 +743,17 @@ export function ProductionStopDemandsView({ ) const columnResizeRef = useRef<{ key: string; clientX: number; width: number } | null>(null) const widthsHydrated = useRef(false) + const [workflowColumnWidths, setWorkflowColumnWidths] = useState< + Record + >(() => Object.fromEntries( + WORKFLOW_CONFIG_COLUMNS.map((column) => [column.key, column.width]), + ) as Record) + const workflowColumnResizeRef = useRef<{ + key: WorkflowConfigColumnKey + clientX: number + width: number + } | null>(null) + const workflowWidthsHydrated = useRef(false) useEffect(() => { try { @@ -753,6 +787,45 @@ export function ProductionStopDemandsView({ } }, [columnWidths]) + useEffect(() => { + try { + const raw = window.localStorage.getItem(WORKFLOW_COLUMN_WIDTHS_STORAGE_KEY) + if (raw) { + const parsed = JSON.parse(raw) as Record + setWorkflowColumnWidths((current) => { + const next = { ...current } + for (const column of WORKFLOW_CONFIG_COLUMNS) { + const value = Number(parsed[column.key]) + if ( + Number.isFinite(value) + && value >= column.minWidth + && value <= MAX_COLUMN_WIDTH + ) { + next[column.key] = Math.round(value) + } + } + return next + }) + } + } catch { + // 本地列宽缓存不可用时忽略,继续使用默认列宽。 + } finally { + workflowWidthsHydrated.current = true + } + }, []) + + useEffect(() => { + if (!workflowWidthsHydrated.current) return + try { + window.localStorage.setItem( + WORKFLOW_COLUMN_WIDTHS_STORAGE_KEY, + JSON.stringify(workflowColumnWidths), + ) + } catch { + // 本地存储不可用时忽略列宽记忆。 + } + }, [workflowColumnWidths]) + // 列设置:显隐 + 拖动排序,按浏览器本地记忆(个人偏好,不影响其他用户)。 const [columnSettings, setColumnSettings] = useState(defaultColumnSettings) const [settingsOpen, setSettingsOpen] = useState(false) @@ -1719,6 +1792,81 @@ export function ProductionStopDemandsView({ setColumnWidths((current) => ({ ...current, [key]: fallback })) } + const workflowConfigTableWidth = WORKFLOW_CONFIG_COLUMNS.reduce( + (total, column) => total + workflowColumnWidths[column.key], + 0, + ) + + const workflowColumnMinWidth = (key: WorkflowConfigColumnKey) => ( + WORKFLOW_CONFIG_COLUMNS.find((column) => column.key === key)?.minWidth + ?? MIN_COLUMN_WIDTH + ) + + const handleWorkflowColumnResizeStart = ( + event: ReactPointerEvent, + key: WorkflowConfigColumnKey, + ) => { + event.preventDefault() + event.stopPropagation() + event.currentTarget.setPointerCapture(event.pointerId) + workflowColumnResizeRef.current = { + key, + clientX: event.clientX, + width: workflowColumnWidths[key], + } + } + + const handleWorkflowColumnResizeMove = ( + event: ReactPointerEvent, + ) => { + const start = workflowColumnResizeRef.current + if (!start) return + const nextWidth = Math.min( + MAX_COLUMN_WIDTH, + Math.max( + workflowColumnMinWidth(start.key), + start.width + event.clientX - start.clientX, + ), + ) + setWorkflowColumnWidths((current) => ({ + ...current, + [start.key]: Math.round(nextWidth), + })) + } + + const handleWorkflowColumnResizeEnd = ( + event: ReactPointerEvent, + ) => { + workflowColumnResizeRef.current = null + if (event.currentTarget.hasPointerCapture(event.pointerId)) { + event.currentTarget.releasePointerCapture(event.pointerId) + } + } + + const handleWorkflowColumnResizeKeyDown = ( + event: ReactKeyboardEvent, + key: WorkflowConfigColumnKey, + ) => { + if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight') return + event.preventDefault() + setWorkflowColumnWidths((current) => ({ + ...current, + [key]: Math.min( + MAX_COLUMN_WIDTH, + Math.max( + workflowColumnMinWidth(key), + current[key] + (event.key === 'ArrowRight' ? 10 : -10), + ), + ), + })) + } + + const resetWorkflowColumnWidths = () => { + setWorkflowColumnWidths(Object.fromEntries( + WORKFLOW_CONFIG_COLUMNS.map((column) => [column.key, column.width]), + ) as Record) + } + const load = useCallback(async (targetPage: number, activeFilters: AppliedFilters) => { setLoading(true) setLoadError('') @@ -6457,7 +6605,7 @@ export function ProductionStopDemandsView({ >
新增节点 +
- +
+ + {WORKFLOW_CONFIG_COLUMNS.map((column) => ( + + ))} + - - - - - - - - + {WORKFLOW_CONFIG_COLUMNS.map((column) => ( + + ))} @@ -6700,6 +6889,9 @@ export function ProductionStopDemandsView({ 指定兜底确认人用于二级、三级负责人缺失时自动承接,可维护为具体人员。 + + 拖动表头右侧分隔线可调整列宽;配置超出当前窗口时可横向滚动。 + ) : null} diff --git a/furniture-3d-system/src/app/supply-chain/management/production-stop-demands/production-stop-demands.module.css b/furniture-3d-system/src/app/supply-chain/management/production-stop-demands/production-stop-demands.module.css index 9c3894e2..47a6a3ca 100644 --- a/furniture-3d-system/src/app/supply-chain/management/production-stop-demands/production-stop-demands.module.css +++ b/furniture-3d-system/src/app/supply-chain/management/production-stop-demands/production-stop-demands.module.css @@ -2281,11 +2281,12 @@ border: 1px solid var(--sc-border); border-radius: 10px; background: var(--sc-surface); + overscroll-behavior-x: contain; } .workflowConfigTable { width: 100%; - min-width: 1200px; + min-width: 980px; border-collapse: collapse; table-layout: fixed; } @@ -2322,42 +2323,16 @@ white-space: nowrap; } -.workflowConfigTable th:nth-child(1) { - width: 140px; -} - -.workflowConfigTable th:nth-child(2) { - width: 160px; -} - -.workflowConfigTable th:nth-child(3) { - width: 120px; -} - -.workflowConfigTable th:nth-child(4) { - width: 110px; -} - -.workflowConfigTable th:nth-child(5) { - width: 170px; -} - .workflowConfigTable th:nth-child(6) { - width: 150px; line-height: 1.35; white-space: normal; } -.workflowConfigTable th:nth-child(7) { - width: 300px; -} - -.workflowConfigTable th:nth-child(8) { - width: 104px; -} - -.workflowConfigTable td:nth-child(6) input { - max-width: 96px; +.workflowConfigTable th .headerLabel { + overflow: visible; + padding-right: 6px; + text-overflow: clip; + white-space: normal; } .workflowConfigTable input,
需求确认流程节点需求确认人需求确认时间节点需求确认时效天数超时未确认是否自动同意停产即将超时预警时效(按小时配置)需求确认注释操作 +
+ + {column.label} + + ( + handleWorkflowColumnResizeStart(event, column.key) + )} + onPointerMove={handleWorkflowColumnResizeMove} + onPointerUp={handleWorkflowColumnResizeEnd} + onPointerCancel={handleWorkflowColumnResizeEnd} + onKeyDown={(event) => ( + handleWorkflowColumnResizeKeyDown(event, column.key) + )} + /> +
+