File tree Expand file tree Collapse file tree 2 files changed +28
-20
lines changed
Expand file tree Collapse file tree 2 files changed +28
-20
lines changed Original file line number Diff line number Diff line change @@ -111,19 +111,29 @@ export default {
111111 label : 'label.disable.host' ,
112112 message : 'message.confirm.disable.host' ,
113113 dataView : true ,
114- show : ( record ) => { return record . resourcestate === 'Enabled' } ,
114+ show : ( record ) => record . resourcestate === 'Enabled' ,
115115 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+ }
117122 } ,
118123 {
119124 api : 'updateHost' ,
120125 icon : 'play-circle-outlined' ,
121126 label : 'label.enable.host' ,
122127 message : 'message.confirm.enable.host' ,
123128 dataView : true ,
124- show : ( record ) => { return record . resourcestate === 'Disabled' } ,
129+ show : ( record ) => record . resourcestate === 'Disabled' ,
125130 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+ }
127137 } ,
128138 {
129139 api : 'prepareHostForMaintenance' ,
Original file line number Diff line number Diff line change 1818<template >
1919 <div class =" form-layout" >
2020 <a-form
21- : ref =" formRef"
21+ ref =" formRef"
2222 :model =" form"
2323 :rules =" rules"
2424 @finish =" handleSubmit"
5454</template >
5555
5656<script >
57- import { ref , reactive , toRaw } from ' vue'
57+ import { reactive , toRaw } from ' vue'
5858import { api } from ' @/api'
5959
6060export default {
@@ -78,11 +78,8 @@ export default {
7878 this .resourcestate = this .resource .resourcestate
7979 this .allocationstate = this .resourcestate === ' Enabled' ? ' Disable' : ' Enable'
8080 },
81- beforeCreate () {
82- },
8381 methods: {
8482 initForm () {
85- this .formRef = ref ()
8683 this .form = reactive ({})
8784 this .rules = reactive ({})
8885 },
@@ -97,11 +94,9 @@ export default {
9794 })
9895 },
9996 handleSubmit (e ) {
100- e .preventDefault ()
101- this .formRef .value .validate ().then (() => {
97+ this .$refs .formRef .validate ().then (() => {
10298 const values = toRaw (this .form )
103-
104- var data = {
99+ const data = {
105100 allocationstate: this .allocationstate ,
106101 id: this .resource .id
107102 }
@@ -110,24 +105,27 @@ export default {
110105 }
111106 api (' updateHost' , data).then (_ => {
112107 this .$emit (' close-action' )
108+ this .$emit (' refresh-data' )
109+ }).catch (err => {
110+ this .$message .error (err .message || ' Failed to update host status' )
113111 })
112+ }).catch (() => {
113+ this .$message .error (' Validation failed. Please check the inputs.' )
114114 })
115115 }
116116 }
117117}
118-
119118 </script >
120119
121120<style scoped>
122121.reason {
123- padding-top : 20px
122+ padding-top : 20px ;
124123}
125124
126125.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 ;
132129 }
130+ }
133131 </style >
You can’t perform that action at this time.
0 commit comments