File tree 2 files changed +28
-20
lines changed
2 files changed +28
-20
lines changed Original file line number Diff line number Diff line change @@ -111,19 +111,29 @@ export default {
111
111
label : 'label.disable.host' ,
112
112
message : 'message.confirm.disable.host' ,
113
113
dataView : true ,
114
- show : ( record ) => { return record . resourcestate === 'Enabled' } ,
114
+ show : ( record ) => record . resourcestate === 'Enabled' ,
115
115
popup : true ,
116
- component : shallowRef ( defineAsyncComponent ( ( ) => import ( '@/views/infra/HostEnableDisable' ) ) )
116
+ component : shallowRef ( defineAsyncComponent ( ( ) => import ( '@/views/infra/HostEnableDisable' ) ) ) ,
117
+ events : {
118
+ 'refresh-data' : ( ) => {
119
+ store . dispatch ( 'refreshCurrentPage' )
120
+ }
121
+ }
117
122
} ,
118
123
{
119
124
api : 'updateHost' ,
120
125
icon : 'play-circle-outlined' ,
121
126
label : 'label.enable.host' ,
122
127
message : 'message.confirm.enable.host' ,
123
128
dataView : true ,
124
- show : ( record ) => { return record . resourcestate === 'Disabled' } ,
129
+ show : ( record ) => record . resourcestate === 'Disabled' ,
125
130
popup : true ,
126
- component : shallowRef ( defineAsyncComponent ( ( ) => import ( '@/views/infra/HostEnableDisable' ) ) )
131
+ component : shallowRef ( defineAsyncComponent ( ( ) => import ( '@/views/infra/HostEnableDisable' ) ) ) ,
132
+ events : {
133
+ 'refresh-data' : ( ) => {
134
+ store . dispatch ( 'refreshCurrentPage' )
135
+ }
136
+ }
127
137
} ,
128
138
{
129
139
api : 'prepareHostForMaintenance' ,
Original file line number Diff line number Diff line change 18
18
<template >
19
19
<div class =" form-layout" >
20
20
<a-form
21
- : ref =" formRef"
21
+ ref =" formRef"
22
22
:model =" form"
23
23
:rules =" rules"
24
24
@finish =" handleSubmit"
54
54
</template >
55
55
56
56
<script >
57
- import { ref , reactive , toRaw } from ' vue'
57
+ import { reactive , toRaw } from ' vue'
58
58
import { api } from ' @/api'
59
59
60
60
export default {
@@ -78,11 +78,8 @@ export default {
78
78
this .resourcestate = this .resource .resourcestate
79
79
this .allocationstate = this .resourcestate === ' Enabled' ? ' Disable' : ' Enable'
80
80
},
81
- beforeCreate () {
82
- },
83
81
methods: {
84
82
initForm () {
85
- this .formRef = ref ()
86
83
this .form = reactive ({})
87
84
this .rules = reactive ({})
88
85
},
@@ -97,11 +94,9 @@ export default {
97
94
})
98
95
},
99
96
handleSubmit (e ) {
100
- e .preventDefault ()
101
- this .formRef .value .validate ().then (() => {
97
+ this .$refs .formRef .validate ().then (() => {
102
98
const values = toRaw (this .form )
103
-
104
- var data = {
99
+ const data = {
105
100
allocationstate: this .allocationstate ,
106
101
id: this .resource .id
107
102
}
@@ -110,24 +105,27 @@ export default {
110
105
}
111
106
api (' updateHost' , data).then (_ => {
112
107
this .$emit (' close-action' )
108
+ this .$emit (' refresh-data' )
109
+ }).catch (err => {
110
+ this .$message .error (err .message || ' Failed to update host status' )
113
111
})
112
+ }).catch (() => {
113
+ this .$message .error (' Validation failed. Please check the inputs.' )
114
114
})
115
115
}
116
116
}
117
117
}
118
-
119
118
</script >
120
119
121
120
<style scoped>
122
121
.reason {
123
- padding-top : 20px
122
+ padding-top : 20px ;
124
123
}
125
124
126
125
.form-layout {
127
- width : 30vw ;
128
-
129
- @media (min-width : 500px ) {
130
- width : 450px ;
131
- }
126
+ width : 30vw ;
127
+ @media (min-width : 500px ) {
128
+ width : 450px ;
132
129
}
130
+ }
133
131
</style >
You can’t perform that action at this time.
0 commit comments