Modify the directory structure
Modify the directory structure
This commit is contained in:
parent
31fbef10e4
commit
4b05d84ea2
175 changed files with 48 additions and 46 deletions
5
src/components/steps/index.js
Normal file
5
src/components/steps/index.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
import Steps from './steps.vue';
|
||||
import Step from './step.vue';
|
||||
|
||||
Steps.Step = Step;
|
||||
export default Steps;
|
94
src/components/steps/step.vue
Normal file
94
src/components/steps/step.vue
Normal file
|
@ -0,0 +1,94 @@
|
|||
<template>
|
||||
<div :class="wrapClasses" :style="styles">
|
||||
<div :class="[`${prefixCls}-tail`]"><i></i></div>
|
||||
<div :class="[`${prefixCls}-head`]">
|
||||
<div :class="[`${prefixCls}-head-inner`]">
|
||||
<span v-if="!icon && status != 'finish' && status != 'error'">{{ stepNumber }}</span>
|
||||
<span v-else :class="iconClasses"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div :class="[`${prefixCls}-main`]">
|
||||
<div :class="[`${prefixCls}-title`]">{{ title }}</div>
|
||||
<div v-if="content" :class="[`${prefixCls}-content`]">{{ content }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { oneOf } from '../../utils/assist';
|
||||
|
||||
const prefixCls = 'ivu-steps';
|
||||
const iconPrefixCls = 'ivu-icon';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
status: {
|
||||
validator (value) {
|
||||
return oneOf(value, ['wait', 'process', 'finish', 'error']);
|
||||
}
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
content: {
|
||||
type: String
|
||||
},
|
||||
icon: {
|
||||
type: String
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
prefixCls: prefixCls,
|
||||
stepNumber: '',
|
||||
nextError: false,
|
||||
total: 1
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
wrapClasses () {
|
||||
return [
|
||||
`${prefixCls}-item`,
|
||||
`${prefixCls}-status-${this.status}`,
|
||||
{
|
||||
[`${prefixCls}-custom`]: !!this.icon,
|
||||
[`${prefixCls}-next-error`]: this.nextError
|
||||
}
|
||||
]
|
||||
},
|
||||
iconClasses () {
|
||||
let icon = '';
|
||||
|
||||
if (!!this.icon) {
|
||||
icon = this.icon;
|
||||
} else {
|
||||
if (this.status == 'finish') {
|
||||
icon = 'ios-checkmark-empty';
|
||||
} else if (this.status == 'error') {
|
||||
icon = 'ios-close-empty';
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
`${prefixCls}-icon`,
|
||||
`${iconPrefixCls}`,
|
||||
{
|
||||
[`${iconPrefixCls}-${icon}`]: icon != ''
|
||||
}
|
||||
]
|
||||
},
|
||||
styles () {
|
||||
return {
|
||||
width: `${1/this.total*100}%`
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
status () {
|
||||
if (this.status == 'error') {
|
||||
this.$parent.setNextError();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
107
src/components/steps/steps.vue
Normal file
107
src/components/steps/steps.vue
Normal file
|
@ -0,0 +1,107 @@
|
|||
<template>
|
||||
<div :class="classes">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { oneOf } from '../../utils/assist';
|
||||
|
||||
const prefixCls = 'ivu-steps';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
current: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
status: {
|
||||
validator (value) {
|
||||
return oneOf(value, ['wait', 'process', 'finish', 'error']);
|
||||
},
|
||||
default: 'process'
|
||||
},
|
||||
size: {
|
||||
validator (value) {
|
||||
return oneOf(value, ['small']);
|
||||
}
|
||||
},
|
||||
direction: {
|
||||
validator (value) {
|
||||
return oneOf(value, ['horizontal', 'vertical']);
|
||||
},
|
||||
default: 'horizontal'
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
classes () {
|
||||
return [
|
||||
`${prefixCls}`,
|
||||
`${prefixCls}-${this.direction}`,
|
||||
{
|
||||
[`${prefixCls}-${this.size}`]: !!this.size
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
ready () {
|
||||
this.updateChildProps(true);
|
||||
this.setNextError();
|
||||
this.updateCurrent(true);
|
||||
},
|
||||
methods: {
|
||||
updateChildProps (isInit) {
|
||||
const total = this.$children.length;
|
||||
this.$children.forEach((child, index) => {
|
||||
child.stepNumber = index + 1;
|
||||
|
||||
if (this.direction === 'horizontal') {
|
||||
child.total = total;
|
||||
}
|
||||
|
||||
// 如果已存在status,且在初始化时,则略过
|
||||
// todo 如果当前是error,在current改变时需要处理
|
||||
if (!(isInit && child.status)) {
|
||||
if (index == this.current) {
|
||||
if (this.status != 'error') {
|
||||
child.status = 'process';
|
||||
}
|
||||
} else if (index < this.current) {
|
||||
child.status = 'finish';
|
||||
} else {
|
||||
child.status = 'wait';
|
||||
}
|
||||
}
|
||||
|
||||
if (child.status != 'error' && index != 0) {
|
||||
this.$children[index - 1].nextError = false;
|
||||
}
|
||||
});
|
||||
},
|
||||
setNextError () {
|
||||
this.$children.forEach((child, index) => {
|
||||
if (child.status == 'error' && index != 0) {
|
||||
this.$children[index - 1].nextError = true;
|
||||
}
|
||||
});
|
||||
},
|
||||
updateCurrent (isInit) {
|
||||
if (isInit) {
|
||||
const current_status = this.$children[this.current].status;
|
||||
if (!current_status) {
|
||||
this.$children[this.current].status = this.status;
|
||||
}
|
||||
} else {
|
||||
this.$children[this.current].status = this.status;
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
current () {
|
||||
this.updateChildProps();
|
||||
},
|
||||
status () {
|
||||
this.updateCurrent();
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue