Merge remote-tracking branch 'origin/codex/xuxiake-mainline' into codex/xuxiake-owner-config-preserve-departed-20261125
This commit is contained in:
commit
d5cc3fd3cd
@ -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(() => {
|
||||
|
||||
@ -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<WorkflowConfigColumnKey, number>
|
||||
>(() => Object.fromEntries(
|
||||
WORKFLOW_CONFIG_COLUMNS.map((column) => [column.key, column.width]),
|
||||
) as Record<WorkflowConfigColumnKey, number>)
|
||||
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<string, unknown>
|
||||
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<ColumnSetting[]>(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<HTMLSpanElement>,
|
||||
key: WorkflowConfigColumnKey,
|
||||
) => {
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
event.currentTarget.setPointerCapture(event.pointerId)
|
||||
workflowColumnResizeRef.current = {
|
||||
key,
|
||||
clientX: event.clientX,
|
||||
width: workflowColumnWidths[key],
|
||||
}
|
||||
}
|
||||
|
||||
const handleWorkflowColumnResizeMove = (
|
||||
event: ReactPointerEvent<HTMLSpanElement>,
|
||||
) => {
|
||||
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<HTMLSpanElement>,
|
||||
) => {
|
||||
workflowColumnResizeRef.current = null
|
||||
if (event.currentTarget.hasPointerCapture(event.pointerId)) {
|
||||
event.currentTarget.releasePointerCapture(event.pointerId)
|
||||
}
|
||||
}
|
||||
|
||||
const handleWorkflowColumnResizeKeyDown = (
|
||||
event: ReactKeyboardEvent<HTMLSpanElement>,
|
||||
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<WorkflowConfigColumnKey, number>)
|
||||
}
|
||||
|
||||
const load = useCallback(async (targetPage: number, activeFilters: AppliedFilters) => {
|
||||
setLoading(true)
|
||||
setLoadError('')
|
||||
@ -6457,7 +6605,7 @@ export function ProductionStopDemandsView({
|
||||
>
|
||||
<section
|
||||
className={styles.dialog}
|
||||
style={{ width: 'min(1180px, 96vw)' }}
|
||||
style={{ width: 'min(1680px, 98vw)' }}
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label="需求确认配置"
|
||||
@ -6502,19 +6650,60 @@ export function ProductionStopDemandsView({
|
||||
<Plus size={14} />
|
||||
新增节点
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={styles.button}
|
||||
onClick={resetWorkflowColumnWidths}
|
||||
disabled={workflowBusy}
|
||||
>
|
||||
重置列宽
|
||||
</button>
|
||||
</div>
|
||||
<div className={styles.workflowConfigTableWrap}>
|
||||
<table className={styles.workflowConfigTable}>
|
||||
<table
|
||||
className={styles.workflowConfigTable}
|
||||
style={{ width: workflowConfigTableWidth, minWidth: '100%' }}
|
||||
>
|
||||
<colgroup>
|
||||
{WORKFLOW_CONFIG_COLUMNS.map((column) => (
|
||||
<col
|
||||
key={column.key}
|
||||
style={{ width: workflowColumnWidths[column.key] }}
|
||||
/>
|
||||
))}
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>需求确认流程节点</th>
|
||||
<th>需求确认人</th>
|
||||
<th>需求确认时间节点</th>
|
||||
<th>需求确认时效天数</th>
|
||||
<th>超时未确认是否自动同意停产</th>
|
||||
<th>即将超时预警时效(按小时配置)</th>
|
||||
<th>需求确认注释</th>
|
||||
<th>操作</th>
|
||||
{WORKFLOW_CONFIG_COLUMNS.map((column) => (
|
||||
<th key={column.key} aria-label={column.label}>
|
||||
<div className={styles.headerCell}>
|
||||
<span
|
||||
className={styles.headerLabel}
|
||||
title={column.label}
|
||||
>
|
||||
{column.label}
|
||||
</span>
|
||||
<span
|
||||
role="separator"
|
||||
aria-label={`调整${column.label}列宽`}
|
||||
aria-valuemin={column.minWidth}
|
||||
aria-valuemax={MAX_COLUMN_WIDTH}
|
||||
aria-valuenow={workflowColumnWidths[column.key]}
|
||||
tabIndex={0}
|
||||
className={styles.columnResizer}
|
||||
onPointerDown={(event) => (
|
||||
handleWorkflowColumnResizeStart(event, column.key)
|
||||
)}
|
||||
onPointerMove={handleWorkflowColumnResizeMove}
|
||||
onPointerUp={handleWorkflowColumnResizeEnd}
|
||||
onPointerCancel={handleWorkflowColumnResizeEnd}
|
||||
onKeyDown={(event) => (
|
||||
handleWorkflowColumnResizeKeyDown(event, column.key)
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -6700,6 +6889,9 @@ export function ProductionStopDemandsView({
|
||||
<span className={styles.hint}>
|
||||
指定兜底确认人用于二级、三级负责人缺失时自动承接,可维护为具体人员。
|
||||
</span>
|
||||
<span className={styles.hint}>
|
||||
拖动表头右侧分隔线可调整列宽;配置超出当前窗口时可横向滚动。
|
||||
</span>
|
||||
</div>
|
||||
</>
|
||||
) : null}
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user