devServiceProvideList.vue
3.18 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
<template>
<div class="dev-service-provide-container">
<el-steps :active="activeStep" finish-status="success" simple>
<el-step v-for="(title, index) in $t('devServiceProvide.stepTitles')" :key="index" :title="title" />
</el-steps>
<view-service-info v-if="activeStep === 0" ref="viewServiceInfo" :call-back-listener="callBackListener"
:call-back-function="callBackFunction" @openChooseServiceModel="openChooseServiceModel"
@openAddServiceModal="openAddServiceModal" />
<dev-service-provide-view v-if="activeStep === 1" ref="devServiceProvideView" :call-back-listener="callBackListener"
:call-back-function="callBackFunction" />
<service-provide-remark-view v-if="activeStep === 2" ref="serviceProvideRemarkView"
:call-back-listener="callBackListener" :call-back-function="callBackFunction" />
<div class="action-buttons">
<el-button @click="prevStep">{{ $t('devServiceProvide.prevStep') }}</el-button>
<el-button v-if="activeStep !== 2" type="primary" @click="nextStep">
{{ $t('devServiceProvide.nextStep') }}
</el-button>
<el-button v-if="activeStep === 2" type="primary" @click="finishStep">
{{ $t('devServiceProvide.finish') }}
</el-button>
</div>
<choose-service ref="chooseService" :emit-choose-service="callBackListener" :emit-load-data="callBackListener" />
</div>
</template>
<script>
import ViewServiceInfo from '@/components/dev/viewServiceInfo'
import DevServiceProvideView from '@/components/dev/devServiceProvideView'
import ServiceProvideRemarkView from '@/components/dev/serviceProvideRemarkView'
import ChooseService from '@/components/dev/chooseService'
import { saveServiceProvide } from '@/api/dev/devServiceProvideApi'
export default {
name: 'DevServiceProvideList',
components: {
ViewServiceInfo,
DevServiceProvideView,
ServiceProvideRemarkView,
ChooseService,
},
data() {
return {
activeStep: 0,
callBackListener: 'devServiceProvide',
callBackFunction: 'notify',
infos: []
}
},
created() {
this.$on('notify', this.notify)
},
methods: {
notify(info) {
this.infos[this.activeStep] = info
},
prevStep() {
if (this.activeStep > 0) {
this.activeStep--
}
},
nextStep() {
if (!this.infos[this.activeStep]) {
this.$message.error(this.$t('devServiceProvide.requiredInfo'))
return
}
if (this.activeStep < 2) {
this.activeStep++
}
},
finishStep() {
if (!this.infos[this.activeStep]) {
this.$message.error(this.$t('devServiceProvide.requiredInfo'))
return
}
saveServiceProvide({ data: this.infos })
.then(() => {
this.$message.success(this.$t('devServiceProvide.saveSuccess'))
this.$router.go(-1)
})
.catch(error => {
this.$message.error(error.message)
})
},
openChooseServiceModel() {
this.$refs.chooseService.open()
},
openAddServiceModal() {
this.$refs.addService.open()
}
}
}
</script>
<style scoped>
.dev-service-provide-container {
padding: 20px;
}
.action-buttons {
margin-top: 20px;
text-align: right;
}
</style>