add.vue
2.28 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
<template>
<div>
<div class="g-card">
<el-steps :active="active" align-center finish-status="success">
<el-step title="活码设置"></el-step>
<el-step title="生成活码"></el-step>
</el-steps>
</div>
<div class="g-card">
<div>
<div v-if="active === 0">
<BaseInfo ref="baseInfo" :groupCodeId="groupCodeId" @next="next"></BaseInfo>
</div>
<div v-if="active === 1">
<GroupCode :groupCodeId="groupCodeId" :data="baseInfo"></GroupCode>
</div>
</div>
<div class="ac">
<template v-if="active === 0">
<el-button @click="$router.back()">取消</el-button>
<el-button type="primary" v-loading="loading" :disabled="loading" @click="handleGroupCode">下一步</el-button>
</template>
<template v-else>
<!-- <el-button @click="prev"> 上一步 </el-button> -->
<el-button type="primary" @click="finished">完成</el-button>
</template>
</div>
</div>
</div>
</template>
<script>
import BaseInfo from './baseInfo'
import GroupCode from './groupCode'
export default {
components: {
BaseInfo,
GroupCode,
},
data() {
return {
loading: false,
// 当前群活码ID
groupCodeId: null,
// 当前激活的步骤
active: 0,
baseInfo: {},
}
},
created() {
if (this.$route.query.groupCodeId) this.groupCodeId = this.$route.query.groupCodeId
},
methods: {
// 下一步
next(groupCodeId, info) {
this.loading = false
if (groupCodeId || info) {
if (groupCodeId) this.groupCodeId = groupCodeId
this.baseInfo = info
this.active += 1
if (this.active > 3) this.active = 1
}
},
// 上一步
prev() {
this.active -= 1
if (this.active < 0) this.active = 0
},
// 完成
finished() {
this.next()
this.$router.back()
},
// 新增或更新群活码
handleGroupCode() {
if (!this.$refs.baseInfo.handleValidateFn()) return
this.loading = true
this.$refs.baseInfo.submit()
},
// 管理实际群活码
handleRealCode() {
this.next()
},
},
}
</script>
<style scoped lang="scss">
.page-content {
padding-top: 50px;
padding-bottom: 20px;
}
</style>