add.vue
3.98 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<template>
<div class="layout" v-loading="loading">
<div class="tabs flex">
<template v-for="(i,index) in tabs">
<template>
<div
:key="index"
:class="['tab flex',{'active':step == index + 1}]"
>
<template v-if="index != 0">
<div class="line"></div>
</template>
<template v-if="step == 2 && index == 0">
<div class="icon finish">
<span class="el-icon-check"></span>
</div>
</template>
<template v-else>
<div class="icon">{{index + 1}}</div>
</template>
{{i}}
</div>
</template>
</template>
</div>
<div class="content">
<step-one
v-show="step == 1"
ref="stepOne"
/>
<step-two
v-show="step == 2"
ref="stepTwo"
/>
</div>
<GLFooter class="footer">
<el-button
@click="handleCancel"
size="medium"
>{{step == 1?'取消':'上一步'}}</el-button>
<el-button
type="primary"
@click="handleConfirm"
size="medium"
>{{step == 1?'下一步':'提交'}}</el-button>
</GLFooter>
</div>
</template>
<script type='text/ecmascript-6'>
import StepOne from './components/StepOne/index.vue'
import StepTwo from './components/StepTwo/index.vue'
export default {
components: { StepOne, StepTwo },
name: '',
data () {
return {
parsedData: [],
step: 1,
tabs: ['基本信息', '配置内容'],
loading:false
}
},
mounted () {
},
methods: {
handleCancel () {
const { step } = this
step == 1 ? this.$router.go(-1) : this.step = 1
},
handleConfirm () {
const { step, $refs: {
stepOne,
stepTwo
} } = this
if (step == 1) {
stepOne.formRef().validate(valid => {
if (valid) this.step = 2
})
} else {
stepTwo.formRef().validate(async valid => {
if (valid) {
this.loading = true
try {
const params = {
...stepOne.configForm,
...stepTwo.configForm,
status: 1
}, res = await this.$apis.questionnaire.addQuestionnaire(params)
console.log(res)
if (res) {
this.$message({
message: '创建成功',
type: 'success'
})
this.$router.go(-1)
}
else throw '创建失败'
} catch (error) {
this.loading = false
if (error) this.$message.error(error)
}
}
})
}
}
}
}
</script>
<style scoped lang='scss'>
.layout {
position: absolute;
width: 100%;
height: calc(100vh - 48px);
top: 0;
left: 0;
.tabs {
height: 64px;
justify-content: center;
-webkit-user-select: none;
.tab {
font-size: 16px;
color: #000000a6;
line-height: 24px;
.icon {
width: 32px;
height: 32px;
border-radius: 100%;
border: 1px solid #c6c6c6;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
margin-right: 8px;
font-size: 14px;
color: #c6c6c6;
}
.finish {
border-color: #5850ff !important;
border-width: 2px;
}
.line {
width: 160px;
height: 1px;
background: #e5e5e5;
margin: 0 8px;
}
}
.active {
font-weight: 500;
color: #000000d9;
.icon {
background: #5850ff;
border-color: #5850ff;
color: #fff;
}
}
.el-icon-check {
color: #5850ff;
font-size: 18px;
font-weight: 700;
}
}
.content {
height: calc(100% - 136px);
background-color: #fff;
margin: 0 24px;
border-radius: 0 4px 4px 4px;
}
.footer {
padding: 16px 0;
}
}
</style>