Commit 5770bb5b by 李伟康

refactor(ApprovalChainPreview): 重构审批链预览组件布局,优化连接线渲染

提取统一的连接线颜色工具函数,使用flex布局替代绝对定位优化代码结构,调整节点内部排版
1 parent fcc0d0da
Pipeline #362 for 5770bb5b failed in 0 seconds
...@@ -80,18 +80,17 @@ function NodeIcon({ status, index }: NodeIconProps) { ...@@ -80,18 +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={{
position: 'absolute', flex: 1,
top: 15,
left: '70%',
width: '60%',
height: 2, height: 2,
background: bg, background: lineColor(status),
zIndex: 0, alignSelf: 'flex-start',
marginTop: 15,
}} }}
/> />
); );
...@@ -161,25 +160,26 @@ export function ApprovalChainPreview({ ...@@ -161,25 +160,26 @@ 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) => {
const prev = finalNodes[i - 1];
const hasLeft = i > 0;
const hasRight = i < finalNodes.length - 1;
return (
<div <div
key={i} key={i}
style={{ style={{
flex: 1, flex: 1,
display: 'flex', display: 'flex',
flexDirection: 'column', alignItems: 'flex-start',
alignItems: 'center',
position: 'relative',
}} }}
> >
{i < finalNodes.length - 1 && <NodeLine status={n.status} />} <div style={{ flex: 1 }}>{hasLeft && <NodeLine status={prev.status} />}</div>
<div <div
style={{ style={{
position: 'relative',
zIndex: 1,
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
alignItems: 'center', alignItems: 'center',
flex: 'none',
}} }}
> >
<NodeIcon status={n.status} index={i} /> <NodeIcon status={n.status} index={i} />
...@@ -189,7 +189,11 @@ export function ApprovalChainPreview({ ...@@ -189,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',
}} }}
> >
...@@ -218,8 +222,10 @@ export function ApprovalChainPreview({ ...@@ -218,8 +222,10 @@ export function ApprovalChainPreview({
</div> </div>
)} )}
</div> </div>
<div style={{ flex: 1 }}>{hasRight && <NodeLine status={n.status} />}</div>
</div> </div>
))} );
})}
</div> </div>
</UCard> </UCard>
); );
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!