Commit 4bb714cf by chenwq

Merge branch 'v1.0.0' of http://192.168.3.233:8090/ujia/uj-store into v1.0.0

2 parents 21c5299a 5770bb5b
Pipeline #363 for 4bb714cf failed in 0 seconds
...@@ -315,5 +315,7 @@ function lineStyle(line: number): CSSProperties { ...@@ -315,5 +315,7 @@ function lineStyle(line: number): CSSProperties {
overflow: 'hidden', overflow: 'hidden',
WebkitBoxOrient: 'vertical', WebkitBoxOrient: 'vertical',
WebkitLineClamp: line, WebkitLineClamp: line,
whiteSpace: 'pre-wrap',
overflowWrap: 'anywhere',
}; };
} }
...@@ -278,7 +278,7 @@ export function ApprovalAuditTrail({ ...@@ -278,7 +278,7 @@ export function ApprovalAuditTrail({
const approved = detail.status === 'APPROVED'; const approved = detail.status === 'APPROVED';
const showHours = const showHours =
typeof pendingHours === 'number' && Number.isFinite(pendingHours) && pendingHours >= 0; typeof pendingHours === 'number' && Number.isFinite(pendingHours) && pendingHours >= 0;
const futureCaption = roles.length === 1 ? '通过后即可生效' : '全部审批节点通过后自动生效'; const futureCaption = level === roles.length ? '通过后即可生效' : '全部审批节点通过后自动生效';
return ( return (
<section className="approval-detail-audit" aria-label="审批留痕列表"> <section className="approval-detail-audit" aria-label="审批留痕列表">
...@@ -332,6 +332,22 @@ export function ApprovalAuditTrail({ ...@@ -332,6 +332,22 @@ export function ApprovalAuditTrail({
</div> </div>
</div> </div>
</article> </article>
{roles.slice(level).map((role, index) => (
<article key={role} className="approval-detail-chaincard" aria-label="后续审批节点">
<span
className="approval-detail-chaincard__icon approval-detail-chaincard__icon--waiting"
aria-hidden="true"
>
{level + index + 1}
</span>
<div className="approval-detail-chaincard__content">
<div className="approval-detail-chaincard__title">
{role} · 第 {level + index + 1} 级审批节点(待流转)
</div>
<div className="approval-detail-chaincard__meta">待前序节点通过</div>
</div>
</article>
))}
<article className="approval-detail-chaincard" aria-label="待生效节点"> <article className="approval-detail-chaincard" aria-label="待生效节点">
<span <span
className="approval-detail-chaincard__icon approval-detail-chaincard__icon--waiting" className="approval-detail-chaincard__icon approval-detail-chaincard__icon--waiting"
......
...@@ -325,6 +325,40 @@ describe('store detail presentation', () => { ...@@ -325,6 +325,40 @@ describe('store detail presentation', () => {
expect(screen.getByText(/192\.0\.2\.1/)).toBeInTheDocument(); expect(screen.getByText(/192\.0\.2\.1/)).toBeInTheDocument();
}); });
it('includes the future finance node between the current business node and activation', () => {
show({
initialTab: 'logs',
detail: {
...detail,
approvalLogs: [
{ action: 'SUBMIT', operatorName: '运营甲', operateTime: detail.submitTime },
],
},
});
const trail = within(screen.getByLabelText('审批留痕列表'));
const cards = trail.getAllByRole('article');
expect(cards).toHaveLength(4);
expect(cards[1]).toHaveTextContent('优加商务经理');
expect(cards[2]).toHaveTextContent('优加财务经理');
expect(cards[2]).toHaveTextContent('待前序节点通过');
expect(cards[2]).not.toHaveTextContent('当前节点');
expect(cards[3]).toHaveTextContent('生效 · 写入门店列表');
});
it.each([1, 2])(
'does not duplicate finance or imply more approval at final level %s',
(totalLevel) => {
show({
initialTab: 'logs',
detail: { ...detail, totalLevel, currentLevel: totalLevel, approvalLogs: [] },
});
const trail = within(screen.getByLabelText('审批留痕列表'));
expect(trail.getAllByText(/优加财务经理/)).toHaveLength(1);
expect(trail.queryByLabelText('后续审批节点')).not.toBeInTheDocument();
expect(trail.getByLabelText('当前审批节点')).toHaveTextContent('通过后即可生效');
},
);
it('opens listing history directly and shows newest changes first', () => { it('opens listing history directly and shows newest changes first', () => {
show({ mode: 'listing', initialTab: 'history', detail: { ...detail, status: 'APPROVED' } }); show({ mode: 'listing', initialTab: 'history', detail: { ...detail, status: 'APPROVED' } });
expect(screen.getByRole('tab', { name: '变更历史' })).toHaveAttribute('aria-selected', 'true'); expect(screen.getByRole('tab', { name: '变更历史' })).toHaveAttribute('aria-selected', 'true');
......
...@@ -110,6 +110,28 @@ function actionDialog(confirmLabel: string) { ...@@ -110,6 +110,28 @@ function actionDialog(confirmLabel: string) {
} }
describe('门店审批页面', () => { describe('门店审批页面', () => {
it.each(['handleOpinion', 'rejectReason'] as const)(
'我已办的长意见支持换行省略和悬停查看全文(%s)',
async (source) => {
const opinion = '请核对政策。\n' + '产品分类与业务场景需要逐项确认。'.repeat(12) + 'END-OF-OPINION';
api.listApprovals.mockResolvedValue({
records: [{ ...row, [source]: opinion }],
total: 1,
current: 1,
size: 10,
pages: 1,
});
mount();
fireEvent.click(screen.getByRole('tab', { name: /我已办/ }));
const text = await screen.findByText(opinion, { exact: true, normalizer: (value) => value });
fireEvent.mouseOver(text);
const tooltip = await screen.findByRole('tooltip');
expect(tooltip).toHaveTextContent('END-OF-OPINION');
expect(tooltip).toHaveTextContent('产品分类与业务场景需要逐项确认。');
expect(text).toHaveStyle({ whiteSpace: 'pre-wrap', overflowWrap: 'anywhere' });
},
);
it('按原型展示分类摘要、无币种前缀的权威成本、提交时间和停留时长', async () => { it('按原型展示分类摘要、无币种前缀的权威成本、提交时间和停留时长', async () => {
pending = [ pending = [
{ {
......
.store-approve-table-card {
/* 保留表格自然高度,由页面内容区滚动,避免 flex 收缩后裁掉底部行和分页。 */
flex-shrink: 0;
}
.store-approve-table.ant-table-wrapper .ant-table .ant-table-thead > tr > th { .store-approve-table.ant-table-wrapper .ant-table .ant-table-thead > tr > th {
height: 38px; height: 38px;
padding: 0 12px; padding: 0 12px;
......
import { render, screen, within } from '@testing-library/react';
import { describe, expect, it, vi } from 'vitest';
import type { ApprovalRow } from '@/api';
import { ApprovalActionModal, type ApprovalActionType } from './ApprovalActionModal';
function renderAction(
levels: Array<Pick<ApprovalRow, 'currentLevel' | 'totalLevel'>>,
type: ApprovalActionType = 'pass',
) {
const records: ApprovalRow[] = levels.map((level, index) => ({
listingId: String(index + 1),
storeName: `门店${index + 1}`,
merchantNo: `SQ00${index + 1}`,
businessScene: '精品升级',
status: 'PENDING',
...level,
}));
render(
<ApprovalActionModal
action={{ type, records }}
pending={false}
confirmed={false}
reason=""
onConfirmed={vi.fn()}
onReason={vi.fn()}
onCancel={vi.fn()}
onConfirm={vi.fn()}
/>,
);
return within(screen.getByRole('dialog')).getByRole('alert');
}
describe('通过确认的审批结果提示', () => {
it.each([
{ currentLevel: 2, totalLevel: 2 },
{ currentLevel: 1, totalLevel: 1 },
{ currentLevel: 3, totalLevel: 3 },
])('第 $currentLevel / $totalLevel 级终审通过后提示生效,不提示还有后续审批', (level) => {
const alert = renderAction([level]);
expect(alert).toHaveTextContent('通过当前审批节点后,记录将立即生效并进入门店列表。');
expect(alert).not.toHaveTextContent('后续审批');
});
it('中间审批节点提示仍需后续审批', () => {
const alert = renderAction([{ currentLevel: 1, totalLevel: 2 }]);
expect(alert).toHaveTextContent('记录将继续后续审批');
expect(alert).not.toHaveTextContent('立即生效');
});
it('批量全部终审时提示生效,不受终审总层级差异影响', () => {
const alert = renderAction(
[
{ currentLevel: 1, totalLevel: 1 },
{ currentLevel: 2, totalLevel: 2 },
],
'batch',
);
expect(alert).toHaveTextContent('记录将立即生效并进入门店列表');
expect(alert).not.toHaveTextContent('后续审批');
});
it('批量包含不同审批阶段时分别说明终审生效和继续后续审批', () => {
const alert = renderAction(
[
{ currentLevel: 2, totalLevel: 2 },
{ currentLevel: 1, totalLevel: 2 },
],
'batch',
);
expect(alert).toHaveTextContent('终审记录通过后将立即生效并进入门店列表');
expect(alert).toHaveTextContent('其余记录将继续后续审批');
});
it.each([
{},
{ currentLevel: null, totalLevel: null },
{ currentLevel: 0, totalLevel: 0 },
{ currentLevel: 3, totalLevel: 2 },
])('缺少或非法审批层级不承诺立即生效,也不假定还有后续审批:%j', (level) => {
const alert = renderAction([level]);
expect(alert).toHaveTextContent('系统将按记录的审批进度处理');
expect(alert).not.toHaveTextContent('立即生效');
expect(alert).not.toHaveTextContent('继续后续审批');
});
it('批量存在未知层级时不会将已知终审结果套用到全部记录', () => {
const alert = renderAction([{ currentLevel: 2, totalLevel: 2 }, {}], 'batch');
expect(alert).toHaveTextContent('系统将按记录的审批进度处理');
expect(alert).not.toHaveTextContent('立即生效');
});
});
...@@ -21,6 +21,30 @@ const buttons: Record<ApprovalActionType, string> = { ...@@ -21,6 +21,30 @@ const buttons: Record<ApprovalActionType, string> = {
batch: '确认批量通过', batch: '确认批量通过',
revoke: '确认撤回', revoke: '确认撤回',
}; };
function approvalResultMessage(records: ApprovalRow[]) {
const hasUnknownLevel = records.some(
({ currentLevel, totalLevel }) =>
typeof currentLevel !== 'number' ||
typeof totalLevel !== 'number' ||
!Number.isInteger(currentLevel) ||
!Number.isInteger(totalLevel) ||
currentLevel < 1 ||
totalLevel < currentLevel,
);
if (!records.length || hasUnknownLevel) {
return '通过当前审批节点后,系统将按记录的审批进度处理;完成全部审批节点后生效并进入门店列表。';
}
const finalCount = records.filter((row) => row.currentLevel === row.totalLevel).length;
if (finalCount === records.length) {
return '通过当前审批节点后,记录将立即生效并进入门店列表。';
}
if (finalCount > 0) {
return '本次审批包含不同审批阶段的记录:终审记录通过后将立即生效并进入门店列表;其余记录将继续后续审批,全部节点通过后生效。';
}
return '通过当前审批节点后,记录将继续后续审批;全部节点通过后才会生效并进入门店列表。';
}
interface Props { interface Props {
action?: ApprovalAction; action?: ApprovalAction;
spec?: StoreDictionaries; spec?: StoreDictionaries;
...@@ -71,7 +95,7 @@ export function ApprovalActionModal({ ...@@ -71,7 +95,7 @@ export function ApprovalActionModal({
type="info" type="info"
showIcon showIcon
title="审批范围为门店+业务场景下的全部产品分类" title="审批范围为门店+业务场景下的全部产品分类"
description="通过当前审批节点后,记录将继续后续审批;全部节点通过后才会生效并进入门店列表。" description={approvalResultMessage(action?.records ?? [])}
/> />
) : type === 'revoke' ? ( ) : type === 'revoke' ? (
<UAlert type="warning" showIcon title="撤回后记录将退出当前审批流程。" /> <UAlert type="warning" showIcon title="撤回后记录将退出当前审批流程。" />
......
...@@ -313,7 +313,7 @@ export default function StoreApprove() { ...@@ -313,7 +313,7 @@ export default function StoreApprove() {
) : list.isPending ? ( ) : list.isPending ? (
<Skeleton variant="table" /> <Skeleton variant="table" />
) : ( ) : (
<div className="store-table-card"> <div className="store-table-card store-approve-table-card">
<DataTable<ApprovalRow> <DataTable<ApprovalRow>
className="store-approve-table" className="store-approve-table"
columns={buildApproveColumns(tab, STORE_DICTIONARIES)} columns={buildApproveColumns(tab, STORE_DICTIONARIES)}
......
import type { ColumnsType } from 'antd/es/table'; import type { DataTableColumnsType } from '@/components/DataTable';
import { UTag, UTooltip } from '@uj/ui'; import { UTag, UTooltip } from '@uj/ui';
import { StatusTag } from '@/components/StatusTag'; import { StatusTag } from '@/components/StatusTag';
import type { ApprovalRow, ApproveTab } from '@/api'; import type { ApprovalRow, ApproveTab } from '@/api';
...@@ -16,8 +16,8 @@ function formatSubmitTime(value?: string | null): string { ...@@ -16,8 +16,8 @@ function formatSubmitTime(value?: string | null): string {
export function buildApproveColumns( export function buildApproveColumns(
tab: ApproveTab, tab: ApproveTab,
spec?: StoreDictionaries, spec?: StoreDictionaries,
): ColumnsType<ApprovalRow> { ): DataTableColumnsType<ApprovalRow> {
const columns: ColumnsType<ApprovalRow> = [ const columns: DataTableColumnsType<ApprovalRow> = [
{ {
title: '门店名称', title: '门店名称',
dataIndex: 'storeName', dataIndex: 'storeName',
...@@ -140,7 +140,9 @@ export function buildApproveColumns( ...@@ -140,7 +140,9 @@ export function buildApproveColumns(
{ title: '处理时间', dataIndex: 'handleTime', width: 150, render: formatDateTime }, { title: '处理时间', dataIndex: 'handleTime', width: 150, render: formatDateTime },
{ {
title: '处理意见', title: '处理意见',
key: 'handleOpinion',
width: 220, width: 220,
line: 2,
render: (_, row) => row.handleOpinion || row.rejectReason || '—', render: (_, row) => row.handleOpinion || row.rejectReason || '—',
}, },
{ title: '记录状态', width: 100, render: (_, row) => <StatusTag status={row.status} /> }, { title: '记录状态', width: 100, render: (_, row) => <StatusTag status={row.status} /> },
......
...@@ -80,16 +80,17 @@ function NodeIcon({ status, index }: NodeIconProps) { ...@@ -80,16 +80,17 @@ function NodeIcon({ status, index }: NodeIconProps) {
); );
} }
const lineColor = (status: ChainNodeStatus) => (status === 'done' ? '#16A34A' : '#E5E7EB');
function NodeLine({ status }: { status: ChainNodeStatus }) { function NodeLine({ status }: { status: ChainNodeStatus }) {
const bg = status === 'done' ? '#16A34A' : '#E5E7EB';
return ( return (
<div <div
style={{ style={{
flex: 1, flex: 1,
height: 2, height: 2,
background: bg, background: lineColor(status),
alignSelf: 'center', alignSelf: 'flex-start',
marginTop: -16, marginTop: 15,
}} }}
/> />
); );
...@@ -159,10 +160,27 @@ export function ApprovalChainPreview({ ...@@ -159,10 +160,27 @@ export function ApprovalChainPreview({
} }
> >
<div style={{ display: 'flex', padding: '20px 8px 8px' }}> <div style={{ display: 'flex', padding: '20px 8px 8px' }}>
{finalNodes.map((n, i) => ( {finalNodes.map((n, i) => {
<div key={i} style={{ flex: 1, display: 'flex', position: 'relative' }}> const prev = finalNodes[i - 1];
const hasLeft = i > 0;
const hasRight = i < finalNodes.length - 1;
return (
<div
key={i}
style={{
flex: 1,
display: 'flex',
alignItems: 'flex-start',
}}
>
<div style={{ flex: 1 }}>{hasLeft && <NodeLine status={prev.status} />}</div>
<div <div
style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', flex: 1 }} style={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
flex: 'none',
}}
> >
<NodeIcon status={n.status} index={i} /> <NodeIcon status={n.status} index={i} />
<div <div
...@@ -171,7 +189,11 @@ export function ApprovalChainPreview({ ...@@ -171,7 +189,11 @@ export function ApprovalChainPreview({
fontSize: 14, fontSize: 14,
fontWeight: 600, fontWeight: 600,
color: color:
n.status === 'active' ? '#2B5CE6' : n.status === 'done' ? '#16A34A' : '#6B7280', n.status === 'active'
? '#2B5CE6'
: n.status === 'done'
? '#16A34A'
: '#6B7280',
textAlign: 'center', textAlign: 'center',
}} }}
> >
...@@ -200,9 +222,10 @@ export function ApprovalChainPreview({ ...@@ -200,9 +222,10 @@ export function ApprovalChainPreview({
</div> </div>
)} )}
</div> </div>
{i < finalNodes.length - 1 && <NodeLine status={finalNodes[i].status} />} <div style={{ flex: 1 }}>{hasRight && <NodeLine status={n.status} />}</div>
</div> </div>
))} );
})}
</div> </div>
</UCard> </UCard>
); );
......
...@@ -130,7 +130,9 @@ export function FailDetailCard({ checkResult, fileSize, onReUpload }: FailDetail ...@@ -130,7 +130,9 @@ export function FailDetailCard({ checkResult, fileSize, onReUpload }: FailDetail
<div <div
style={{ style={{
width: '100%', width: '100%',
maxHeight: 360,
overflowX: 'auto', overflowX: 'auto',
overflowY: 'auto',
marginBottom: 14, marginBottom: 14,
}} }}
> >
...@@ -149,7 +151,7 @@ export function FailDetailCard({ checkResult, fileSize, onReUpload }: FailDetail ...@@ -149,7 +151,7 @@ export function FailDetailCard({ checkResult, fileSize, onReUpload }: FailDetail
))} ))}
</colgroup> </colgroup>
<thead> <thead>
<tr> <tr style={{ position: 'sticky', top: 0, zIndex: 1 }}>
{FAIL_COL_LABELS.map((c) => ( {FAIL_COL_LABELS.map((c) => (
<th <th
key={c.key} key={c.key}
...@@ -161,6 +163,7 @@ export function FailDetailCard({ checkResult, fileSize, onReUpload }: FailDetail ...@@ -161,6 +163,7 @@ export function FailDetailCard({ checkResult, fileSize, onReUpload }: FailDetail
padding: '10px 8px', padding: '10px 8px',
borderBottom: '1px solid #F3F4F6', borderBottom: '1px solid #F3F4F6',
whiteSpace: 'nowrap', whiteSpace: 'nowrap',
background: '#fff',
}} }}
> >
{c.label} {c.label}
...@@ -170,7 +173,7 @@ export function FailDetailCard({ checkResult, fileSize, onReUpload }: FailDetail ...@@ -170,7 +173,7 @@ export function FailDetailCard({ checkResult, fileSize, onReUpload }: FailDetail
</thead> </thead>
<tbody> <tbody>
{hasFailures ? ( {hasFailures ? (
failures.slice(0, 3).map((f, i) => ( failures.map((f, i) => (
<tr key={`${f.rowIndex ?? i}-${f.levelCode ?? ''}-${f.productCategory ?? ''}`}> <tr key={`${f.rowIndex ?? i}-${f.levelCode ?? ''}-${f.productCategory ?? ''}`}>
{/* 行号(蓝 #2563EB) */} {/* 行号(蓝 #2563EB) */}
<td <td
......
...@@ -105,8 +105,8 @@ export default function TemplateImport() { ...@@ -105,8 +105,8 @@ export default function TemplateImport() {
cancelText: '知道了', cancelText: '知道了',
// 非阻塞(不强制跳转):「知道了」留在当前页 // 非阻塞(不强制跳转):「知道了」留在当前页
onOk: () => { onOk: () => {
// 跳转门店审批页(对应路由:/store/approval // 跳转门店审批页,tab=mine 默认定位到「我发起的」页签
window.location.href = '/store/approval'; window.location.href = '/store/approval?tab=mine';
}, },
}); });
} catch (e) { } catch (e) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!