whyczyk
2021-09-07 69f949b70f1cd2c80a9738afe602905b18e72e0b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<template>
    <div class="mw-step-wrapper">
        <div 
            class="mw-step-item"
            v-for="item in list" :key="item.key"
            :class="[item.class, {'step-active': step>=item.step}]"
            @click="changeStep(item)">
            <div class="mw-step-text">{{item.label}}</div>
        </div>
    </div>
</template>
 
<script>
export default {
    name: "mwStep",
    props: {
        step: {
            type: Number,
            default: 0
        }
    },
    model: {
        prop: 'step',
        event: 'changeStep'
    },
    data() {
        return {
            list: [
                {
                    key: 'step0',
                    class: 'step-start',
                    step: 0,
                    label: "1.新建试验",
                },
                {
                    key: 'step1',
                    class: 'step-middle',
                    step: 1,
                    label: "2.试验基础数据录入",
                },
                {
                    key: 'step2',
                    class: 'step-end',
                    step: 2,
                    label: "3.试验步骤确认",
                },
            ],
        }
    },
    methods: {
        changeStep(item) {
            let max = this.list.length-1;
            let min = 0;
            if(item.step<this.step) {
                let step = item.step;
                if(this.step>max) {
                    step = max;
                }else if(this.step<min) {
                    step = min;
                }
                this.$emit('changeStep', step);
            }else {
                
            }
        },
    },
    computed: {
        
    },
}
</script>
 
<style scoped>
.mw-step-wrapper {
    display: flex;
    flex-direction: row;
}
.mw-step-item {
    flex: 1;
    height: 40px;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    cursor: not-allowed;
}
.mw-step-item.step-active {
    cursor: pointer;
}
.mw-step-text {
    line-height: 40px;
    text-align: center;
    color: #CCCCCC;
}
.step-active .mw-step-text {
    color: #FFFFFF;
}
.mw-step-item.step-start {
    background-image: url("./images/start.svg");
}
.mw-step-item.step-middle {
    margin-left: -6px;
    background-image: url("./images/middle-default.svg");
}
.mw-step-item.step-middle.step-active {
    background-image: url("./images/middle-active.svg");
}
.mw-step-item.step-end {
    margin-left: -6px;
    background-image: url("./images/end.svg");
}
.mw-step-item.step-end.step-active {
    background-image: url("./images/end-active.svg");
}
</style>