2016-09-09 14:29:19 +08:00
|
|
|
<template>
|
2016-09-23 15:22:37 +08:00
|
|
|
<div :class="wrapClasses" :style="styles">
|
2016-10-28 17:24:52 +08:00
|
|
|
<div :class="[prefixCls + '-tail']"><i></i></div>
|
|
|
|
<div :class="[prefixCls + '-head']">
|
|
|
|
<div :class="[prefixCls + '-head-inner']">
|
2017-03-01 23:24:23 +08:00
|
|
|
<span v-if="!icon && currentStatus != 'finish' && currentStatus != 'error'">{{ stepNumber }}</span>
|
2016-09-09 14:29:19 +08:00
|
|
|
<span v-else :class="iconClasses"></span>
|
|
|
|
</div>
|
|
|
|
</div>
|
2016-10-28 17:24:52 +08:00
|
|
|
<div :class="[prefixCls + '-main']">
|
|
|
|
<div :class="[prefixCls + '-title']">{{ title }}</div>
|
|
|
|
<div v-if="content" :class="[prefixCls + '-content']">{{ content }}</div>
|
2016-09-09 14:29:19 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import { oneOf } from '../../utils/assist';
|
|
|
|
|
|
|
|
const prefixCls = 'ivu-steps';
|
|
|
|
const iconPrefixCls = 'ivu-icon';
|
|
|
|
|
|
|
|
export default {
|
2017-03-02 17:40:19 +08:00
|
|
|
name: 'Step',
|
2016-09-09 14:29:19 +08:00
|
|
|
props: {
|
2017-03-01 23:24:23 +08:00
|
|
|
status: {
|
|
|
|
validator (value) {
|
|
|
|
return oneOf(value, ['wait', 'process', 'finish', 'error']);
|
|
|
|
}
|
|
|
|
},
|
2016-09-09 14:29:19 +08:00
|
|
|
title: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
content: {
|
|
|
|
type: String
|
|
|
|
},
|
|
|
|
icon: {
|
|
|
|
type: String
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
prefixCls: prefixCls,
|
|
|
|
stepNumber: '',
|
2016-09-23 15:22:37 +08:00
|
|
|
nextError: false,
|
2017-03-01 21:10:43 +08:00
|
|
|
total: 1,
|
2017-03-01 23:24:23 +08:00
|
|
|
currentStatus: ''
|
2016-12-25 22:49:42 +08:00
|
|
|
};
|
2016-09-09 14:29:19 +08:00
|
|
|
},
|
2017-03-01 23:24:23 +08:00
|
|
|
created () {
|
|
|
|
this.currentStatus = this.status;
|
|
|
|
},
|
2016-09-09 14:29:19 +08:00
|
|
|
computed: {
|
|
|
|
wrapClasses () {
|
|
|
|
return [
|
|
|
|
`${prefixCls}-item`,
|
2017-03-01 23:24:23 +08:00
|
|
|
`${prefixCls}-status-${this.currentStatus}`,
|
2016-09-09 14:29:19 +08:00
|
|
|
{
|
|
|
|
[`${prefixCls}-custom`]: !!this.icon,
|
|
|
|
[`${prefixCls}-next-error`]: this.nextError
|
|
|
|
}
|
2016-12-25 22:49:42 +08:00
|
|
|
];
|
2016-09-09 14:29:19 +08:00
|
|
|
},
|
|
|
|
iconClasses () {
|
|
|
|
let icon = '';
|
|
|
|
|
2016-12-25 22:49:42 +08:00
|
|
|
if (this.icon) {
|
2016-09-09 14:29:19 +08:00
|
|
|
icon = this.icon;
|
|
|
|
} else {
|
2017-03-01 23:24:23 +08:00
|
|
|
if (this.currentStatus == 'finish') {
|
2016-09-09 14:29:19 +08:00
|
|
|
icon = 'ios-checkmark-empty';
|
2017-03-01 23:24:23 +08:00
|
|
|
} else if (this.currentStatus == 'error') {
|
2016-09-09 14:29:19 +08:00
|
|
|
icon = 'ios-close-empty';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return [
|
|
|
|
`${prefixCls}-icon`,
|
|
|
|
`${iconPrefixCls}`,
|
|
|
|
{
|
|
|
|
[`${iconPrefixCls}-${icon}`]: icon != ''
|
|
|
|
}
|
2016-12-25 22:49:42 +08:00
|
|
|
];
|
2016-09-23 15:22:37 +08:00
|
|
|
},
|
|
|
|
styles () {
|
|
|
|
return {
|
|
|
|
width: `${1/this.total*100}%`
|
2016-12-25 22:49:42 +08:00
|
|
|
};
|
2016-09-09 14:29:19 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
2017-03-01 23:24:23 +08:00
|
|
|
status (val) {
|
|
|
|
this.currentStatus = val;
|
|
|
|
if (this.currentStatus == 'error') {
|
2016-09-09 14:29:19 +08:00
|
|
|
this.$parent.setNextError();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-12-25 22:49:42 +08:00
|
|
|
};
|
2016-10-28 17:24:52 +08:00
|
|
|
</script>
|