Skip to content

Commit 1c78438

Browse files
authored
Merge pull request #927 from WeBankFinTech/feat-step-click
feat(Step): 增加 clickStep 事件
2 parents 1a0a681 + a179e22 commit 1c78438

File tree

3 files changed

+36
-11
lines changed

3 files changed

+36
-11
lines changed

components/steps/step.tsx

+9-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ export default defineComponent({
4040
CheckOutlined,
4141
},
4242
props: stepProps,
43-
setup(props, { slots }) {
43+
emits: ['clickStep'],
44+
setup(props, { slots, emit }) {
4445
const vm = getCurrentInstance();
4546
if (
4647
!vm
@@ -108,6 +109,9 @@ export default defineComponent({
108109
const classList = computed(() =>
109110
[prefixCls, `is-${status.value}`].filter(Boolean).join(' '),
110111
);
112+
const onClickStep = () => {
113+
emit('clickStep', index.value);
114+
};
111115
const renderSymbol = () => {
112116
let content;
113117
if (slots.icon) {
@@ -134,7 +138,7 @@ export default defineComponent({
134138
}
135139
return (
136140
<div class={`${prefixCls}-symbol`}>
137-
<div class={`${prefixCls}-symbol-wrapper`}>{content}</div>
141+
<div class={`${prefixCls}-symbol-wrapper`} onClick={onClickStep}>{content}</div>
138142
{parent.props.vertical && (
139143
<div class={`${prefixCls}-tail`}></div>
140144
)}
@@ -155,7 +159,9 @@ export default defineComponent({
155159
{renderSymbol()}
156160
<div class={`${prefixCls}-content`}>
157161
<div class={`${prefixCls}-title`}>
158-
{slots.title?.() || `${props.title}`}
162+
<span class={`${prefixCls}-text`} onClick={onClickStep}>
163+
{slots.title?.() || `${props.title}`}
164+
</span>
159165
{!parent.props.vertical && (
160166
<div class={`${prefixCls}-tail`}></div>
161167
)}

docs/.vitepress/components/steps/common.vue

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
<template>
22
<FSteps :current="current">
3-
<FStep title="待开始" description="All through the day, I me mine" />
3+
<FStep title="待开始" description="All through the day, I me mine" @clickStep="handleClickStep" />
44
<FStep
55
title="进行中"
66
description="When I find myself in times of trouble Mother Mary comes to me"
7+
@clickStep="handleClickStep"
78
/>
8-
<FStep title="待处理">
9+
<FStep title="待处理" @clickStep="handleClickStep">
910
<template #icon>
1011
<ProductOutlined />
1112
</template>
1213
</FStep>
1314
<FStep
1415
title="已完成"
1516
description="Something in the way she moves Attracts me like no other lover"
17+
@clickStep="handleClickStep"
1618
/>
1719
</FSteps>
1820

@@ -41,10 +43,15 @@ export default {
4143
current.value = current.value + 1;
4244
};
4345
46+
const handleClickStep = (step) => {
47+
console.log('[steps.common] handleClickStep, step:', step);
48+
};
49+
4450
return {
4551
current,
4652
pre,
4753
next,
54+
handleClickStep,
4855
};
4956
},
5057
};

docs/.vitepress/components/steps/index.md

+18-6
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,27 @@ app.use(FSteps);
1414

1515
### 基础用法
1616

17-
--COMMON
17+
:::demo
18+
common.vue
19+
:::
1820

1921
### 垂直方向
2022

21-
--VERTICAL
23+
:::demo
24+
vertical.vue
25+
:::
2226

2327
### 图标
2428

25-
--ICON
29+
:::demo
30+
icon.vue
31+
:::
2632

2733
### 错误状态
2834

29-
--ERROR
30-
31-
--CODE
35+
:::demo
36+
error.vue
37+
:::
3238

3339
## Steps Props
3440

@@ -54,3 +60,9 @@ app.use(FSteps);
5460
| icon | 步骤图标的类型,可选 | slot | - |
5561
| status | 指定状态。当不配置该属性时,会使用 `Steps``status` 来自动指定状态。可选:`wait` `process` `finish` `error` | string | - |
5662
| title | 标题 | string / slot | - |
63+
64+
## Step Events
65+
66+
| 事件名称 | 说明 | 回调参数 |
67+
| --------- | -------------- | -------------------- |
68+
| clickStep | 点击步骤时触发 | (step: number)=>void |

0 commit comments

Comments
 (0)