67
67
v-model:value =" form[field.key]"
68
68
v-focus =" index === 0"
69
69
/>
70
+ <a-radio-group
71
+ v-else-if =" field.radioGroup"
72
+ v-model:value =" form[field.key]"
73
+ buttonStyle =" solid" >
74
+ <span
75
+ style =" margin-right : 5px ;"
76
+ v-for =" (radioItem, idx) in field.radioOption"
77
+ :key =" idx" >
78
+ <a-radio-button
79
+ :value =" radioItem.value"
80
+ v-if =" isDisplayItem(radioItem.condition)" >
81
+ {{ $t(radioItem.label) }}
82
+ </a-radio-button >
83
+ </span >
84
+ <a-alert style =" margin-top : 5px " type =" warning" v-if =" field.alert && isDisplayItem(field.alert.display)" >
85
+ <template #message >
86
+ <span v-html =" $t(field.alert.message)" />
87
+ </template >
88
+ </a-alert >
89
+ </a-radio-group >
70
90
<a-input
71
91
v-else
72
92
v-model:value =" form[field.key]"
@@ -118,6 +138,11 @@ export default {
118
138
created () {
119
139
this .initForm ()
120
140
},
141
+ computed: {
142
+ hypervisor () {
143
+ return this .prefillContent ? .hypervisor || null
144
+ }
145
+ },
121
146
mounted () {
122
147
this .fillValue ()
123
148
},
@@ -152,13 +177,13 @@ export default {
152
177
if (! fieldExists) {
153
178
return
154
179
}
155
- if (field .key === ' agentUserName' && ! this .getPrefilled (field . key )) {
180
+ if (field .key === ' agentUserName' && ! this .getPrefilled (field)) {
156
181
this .form [field .key ] = ' Oracle'
157
182
} else {
158
183
if (field .switch ) {
159
184
this .form [field .key ] = this .isChecked (field)
160
185
} else {
161
- this .form [field .key ] = this .getPrefilled (field . key )
186
+ this .form [field .key ] = this .getPrefilled (field)
162
187
}
163
188
}
164
189
})
@@ -179,8 +204,11 @@ export default {
179
204
})
180
205
}
181
206
},
182
- getPrefilled (key ) {
183
- return this .prefillContent ? .[key] || null
207
+ getPrefilled (field ) {
208
+ if (field .key === ' authmethod' && this .hypervisor !== ' KVM' ) {
209
+ return field .value || field .defaultValue || ' password'
210
+ }
211
+ return this .prefillContent ? .[field .key ] || field .value || field .defaultValue || null
184
212
},
185
213
handleSubmit () {
186
214
this .formRef .value .validate ().then (() => {
@@ -236,6 +264,27 @@ export default {
236
264
return false
237
265
}
238
266
return true
267
+ },
268
+ isDisplayItem (conditions ) {
269
+ if (! conditions || Object .keys (conditions).length === 0 ) {
270
+ return true
271
+ }
272
+ let isShow = true
273
+ Object .keys (conditions).forEach (key => {
274
+ if (! isShow) return false
275
+
276
+ const condition = conditions[key]
277
+ const fieldVal = this .form [key]
278
+ ? this .form [key]
279
+ : (this .prefillContent ? .[key] || null )
280
+ if (Array .isArray (condition) && ! condition .includes (fieldVal)) {
281
+ isShow = false
282
+ } else if (! Array .isArray (condition) && fieldVal !== condition) {
283
+ isShow = false
284
+ }
285
+ })
286
+
287
+ return isShow
239
288
}
240
289
}
241
290
}
0 commit comments