@@ -265,33 +265,32 @@ export default {
265265 this .values = {}
266266 this .ipAddresses = {}
267267 for (const item of this .items ) {
268- var network = this .validNetworks [item .id ]? .[0 ] || null
268+ let network = null
269+ if (item .vlanid && item .vlanid !== - 1 ) {
270+ const matched = this .validNetworks [item .id ].filter (x => Number (x .vlan ) === item .vlanid )
271+ if (matched .length > 0 ) {
272+ network = matched[0 ]
273+ }
274+ }
275+ if (! network) {
276+ network = this .validNetworks [item .id ]? .[0 ] || null
277+ }
269278 this .values [item .id ] = network ? network .id : ' '
270279 this .ipAddresses [item .id ] = (! network || network .type === ' L2' ) ? null : ' auto'
271280 this .setIpAddressEnabled (item, network)
272281 }
273282 this .sendValuesTimed ()
274283 },
275- setNetworkState (nic , networkId ) {
284+ handleNetworkChange (nic , networkId ) {
276285 if (this .hypervisor === ' KVM' ) {
277286 this .setIpAddressEnabled (nic, _ .find (this .networks , (option ) => option .id === networkId))
278287 } else {
279288 this .setIpAddressEnabled (nic, _ .find (this .validNetworks [nic .id ], (option ) => option .id === networkId))
280289 }
281- },
282- handleNetworkChange (nic , networkId ) {
283- this .setNetworkState (nic, networkId)
284290 this .sendValuesTimed ()
285291 },
286292 getDefaultNetwork (record ) {
287- if (record .vlanid && record .vlanid !== - 1 ) {
288- const matched = this .validNetworks [record .id ].filter (x => Number (x .vlan ) === record .vlanid )
289- if (matched .length > 0 ) {
290- this .setNetworkState (record, matched[0 ].id )
291- return matched[0 ].id
292- }
293- }
294- return this .validNetworks [record .id ][0 ].id
293+ return this .values [record .id ] || this .validNetworks [record .id ]? .[0 ]? .id
295294 },
296295 sendValuesTimed () {
297296 clearTimeout (this .sendValuesTimer )
0 commit comments