import { createNamespace } from '../utils'; import { BORDER } from '../utils/constant'; import { ChildrenMixin } from '../mixins/relation'; import Icon from '../icon'; const [createComponent, bem] = createNamespace('step'); export default createComponent({ mixins: [ChildrenMixin('vanSteps')], computed: { status() { if (this.index < this.parent.active) { return 'finish'; } if (this.index === +this.parent.active) { return 'process'; } }, active() { return this.status === 'process'; }, lineStyle() { const { activeColor, inactiveColor, alignCenter, direction } = this.parent return { background: this.status === 'finish' ? activeColor : inactiveColor, top: (alignCenter && direction === 'vertical') && '50%' } }, circleContainerStyle() { return { top: (this.parent.alignCenter && this.parent.direction === 'vertical') && '50%' }; }, titleStyle() { if (this.active) { return { color: this.parent.activeColor }; } if (!this.status) { return { color: this.parent.inactiveColor }; } }, }, methods: { genCircle() { const { activeIcon, iconPrefix, activeColor, finishIcon, inactiveIcon, } = this.parent; if (this.active) { return ( this.slots('active-icon') || ( ) ); } const finishIconSlot = this.slots('finish-icon'); if (this.status === 'finish' && (finishIcon || finishIconSlot)) { return ( finishIconSlot || ( ) ); } const inactiveIconSlot = this.slots('inactive-icon'); if (inactiveIcon || inactiveIconSlot) { return ( inactiveIconSlot || ( ) ); } return ; }, onClickStep() { this.parent.$emit('click-step', this.index); }, }, render() { const { status, active } = this; const { direction } = this.parent; return (
{this.slots()}
{this.genCircle()}
); }, });