Steps: add status prop, close #3722 (#3724)

pull/3831/head
cinwell.li 2017-03-28 15:09:22 +08:00 committed by baiyaaaaa
parent 01d747358b
commit 1a481f5c55
3 changed files with 15 additions and 9 deletions

View File

@ -128,6 +128,7 @@ Vertical step bars.
| title | step title | string | — | — | | title | step title | string | — | — |
| description | step description | string | — | — | | description | step description | string | — | — |
| icon | step icon | icons provided by Element Icon. Can be overwritten by a named slot if you want to use custom icons | string | — | | icon | step icon | icons provided by Element Icon. Can be overwritten by a named slot if you want to use custom icons | string | — |
| status | current status. It will be automatically set by Steps if not configured. | wait/process/finish/error/success | - |
### Step Slot ### Step Slot
| Name | Description | | Name | Description |

View File

@ -122,6 +122,7 @@
| title | 标题 | string | — | — | | title | 标题 | string | — | — |
| description | 描述性文字 | string | — | — | | description | 描述性文字 | string | — | — |
| icon | 图标 | Element Icon 提供的图标,如果要使用自定义图标可以通过 slot 方式写入 | string | — | | icon | 图标 | Element Icon 提供的图标,如果要使用自定义图标可以通过 slot 方式写入 | string | — |
| status | 设置当前步骤的状态,不设置则根据 steps 确定状态 | wait/process/finish/error/success | - |
### Step Slot ### Step Slot
| name | 说明 | | name | 说明 |

View File

@ -52,10 +52,7 @@ export default {
title: String, title: String,
icon: String, icon: String,
description: String, description: String,
status: { status: String
type: String,
default: 'wait'
}
}, },
data() { data() {
@ -65,7 +62,7 @@ export default {
lineStyle: {}, lineStyle: {},
mainOffset: 0, mainOffset: 0,
isLast: false, isLast: false,
currentStatus: this.status internalStatus: ''
}; };
}, },
@ -73,19 +70,25 @@ export default {
this.$parent.steps.push(this); this.$parent.steps.push(this);
}, },
computed: {
currentStatus() {
return this.status || this.internalStatus;
}
},
methods: { methods: {
updateStatus(val) { updateStatus(val) {
const prevChild = this.$parent.$children[this.index - 1]; const prevChild = this.$parent.$children[this.index - 1];
if (val > this.index) { if (val > this.index) {
this.currentStatus = this.$parent.finishStatus; this.internalStatus = this.$parent.finishStatus;
} else if (val === this.index) { } else if (val === this.index) {
this.currentStatus = this.$parent.processStatus; this.internalStatus = this.$parent.processStatus;
} else { } else {
this.currentStatus = 'wait'; this.internalStatus = 'wait';
} }
if (prevChild) prevChild.calcProgress(this.currentStatus); if (prevChild) prevChild.calcProgress(this.internalStatus);
}, },
calcProgress(status) { calcProgress(status) {
@ -100,6 +103,7 @@ export default {
style.transitionDelay = (-150 * this.index) + 'ms'; style.transitionDelay = (-150 * this.index) + 'ms';
} }
style.borderWidth = step ? '1px' : 0;
this.$parent.direction === 'vertical' this.$parent.direction === 'vertical'
? style.height = step + '%' ? style.height = step + '%'
: style.width = step + '%'; : style.width = step + '%';