@@ -84,64 +84,64 @@ import CheckBoxInputPair from '@/components/CheckBoxInputPair'
8484export default {
8585 name: ' MultiDiskSelection' ,
8686 components: {
87- CheckBoxInputPair
87+ CheckBoxInputPair,
8888 },
8989 props: {
9090 items: {
9191 type: Array ,
92- default : () => []
92+ default : () => [],
9393 },
9494 zoneId: {
9595 type: String ,
96- default : () => ' '
96+ default : () => ' ' ,
9797 },
9898 domainid: {
9999 type: String ,
100- default: ' '
100+ default: ' ' ,
101101 },
102102 account: {
103103 type: String ,
104- default: ' '
104+ default: ' ' ,
105105 },
106106 projectid: {
107107 type: String ,
108- default: ' '
108+ default: ' ' ,
109109 },
110110 selectionEnabled: {
111111 type: Boolean ,
112- default: true
112+ default: true ,
113113 },
114114 filterUnimplementedNetworks: {
115115 type: Boolean ,
116- default: false
116+ default: false ,
117117 },
118118 filterMatchKey: {
119119 type: String ,
120- default: null
120+ default: null ,
121121 },
122122 hypervisor: {
123123 type: String ,
124- default: null
125- }
124+ default: null ,
125+ },
126126 },
127- data () {
127+ data () {
128128 return {
129129 columns: [
130130 {
131131 key: ' name' ,
132132 dataIndex: ' name' ,
133- title: this .$t (' label.nic' )
133+ title: this .$t (' label.nic' ),
134134 },
135135 {
136136 key: ' network' ,
137137 dataIndex: ' network' ,
138- title: this .$t (' label.network' )
138+ title: this .$t (' label.network' ),
139139 },
140140 {
141141 key: ' ipaddress' ,
142142 dataIndex: ' ipaddress' ,
143- title: this .$t (' label.ipaddress' )
144- }
143+ title: this .$t (' label.ipaddress' ),
144+ },
145145 ],
146146 loading: false ,
147147 selectedRowKeys: [],
@@ -153,79 +153,78 @@ export default {
153153 ipAddresses: {},
154154 indexNum: 1 ,
155155 sendValuesTimer: null ,
156- accountNetworkUpdateTimer: null
156+ accountNetworkUpdateTimer: null ,
157157 }
158158 },
159159 computed: {
160- tableSource () {
160+ tableSource () {
161161 return this .items .map ((item ) => {
162162 var nic = { ... item, disabled: this .validNetworks [item .id ] && this .validNetworks [item .id ].length === 0 }
163163 nic .name = item .displaytext || item .name
164164 return nic
165165 })
166166 },
167- rowSelection () {
167+ rowSelection () {
168168 if (this .selectionEnabled === true ) {
169169 return {
170170 type: ' checkbox' ,
171171 selectedRowKeys: this .selectedRowKeys ,
172172 getCheckboxProps : (record ) => ({
173173 props: {
174- disabled: record .disabled
175- }
174+ disabled: record .disabled ,
175+ },
176176 }),
177177 onChange : (rows ) => {
178178 this .selectedRowKeys = rows
179179 this .sendValues ()
180- }
180+ },
181181 }
182182 }
183183 return null
184- }
184+ },
185185 },
186186 watch: {
187187 items: {
188188 deep: true ,
189- handler () {
189+ handler () {
190190 this .selectedRowKeys = []
191191 this .fetchNetworks ()
192- }
192+ },
193193 },
194- zoneId () {
194+ zoneId () {
195195 this .fetchNetworks ()
196196 },
197- account () {
197+ account () {
198198 clearTimeout (this .accountNetworkUpdateTimer )
199199 this .accountNetworkUpdateTimer = setTimeout (() => {
200200 if (this .account ) {
201201 this .fetchNetworks ()
202202 }
203203 }, 750 )
204204 },
205- projectid () {
205+ projectid () {
206206 this .fetchNetworks ()
207- }
207+ },
208208 },
209- created () {
209+ created () {
210210 this .fetchNetworks ()
211211 },
212212 methods: {
213- fetchNetworks () {
213+ fetchNetworks () {
214214 this .networks = []
215215 if (! this .zoneId || this .zoneId .length === 0 ) {
216216 return
217217 }
218218 this .loading = true
219219 var params = {
220220 zoneid: this .zoneId ,
221- listall: true
222- }
223- if (this .domainid && this .account ) {
224- params .domainid = this .domainid
225- params .account = this .account
221+ listall: true ,
226222 }
227223 if (this .projectid ) {
228224 params .projectid = this .projectid
225+ } else if (this .domainid && this .account ) {
226+ params .domainid = this .domainid
227+ params .account = this .account
229228 }
230229 getAPI (' listNetworks' , params)
231230 .then ((response ) => {
@@ -239,14 +238,14 @@ export default {
239238 this .loading = false
240239 })
241240 },
242- orderNetworks () {
241+ orderNetworks () {
243242 this .loading = true
244243 this .validNetworks = {}
245244 for (const item of this .items ) {
246245 this .validNetworks [item .id ] = this .networks
247246 if (this .filterUnimplementedNetworks ) {
248247 this .validNetworks [item .id ] = this .validNetworks [item .id ].filter (
249- (x ) => x .state === ' Implemented' || (x .state === ' Setup' && [' Shared' , ' L2' ].includes (x .type ))
248+ (x ) => x .state === ' Implemented' || (x .state === ' Setup' && [' Shared' , ' L2' ].includes (x .type )),
250249 )
251250 }
252251 if (this .filterMatchKey ) {
@@ -263,17 +262,17 @@ export default {
263262 this .setDefaultValues ()
264263 this .loading = false
265264 },
266- setIpAddressEnabled (nic , network ) {
265+ setIpAddressEnabled (nic , network ) {
267266 this .ipAddressesEnabled [nic .id ] = network && network .type !== ' L2'
268267 this .ipAddresses [nic .id ] = ! network || network .type === ' L2' ? null : ' auto'
269268 this .values [nic .id ] = network ? network .id : null
270269 this .indexNum = (this .indexNum % 2 ) + 1
271270 },
272- setIpAddress (nicId , autoAssign , ipAddress ) {
271+ setIpAddress (nicId , autoAssign , ipAddress ) {
273272 this .ipAddresses [nicId] = autoAssign ? ' auto' : ipAddress
274273 this .sendValuesTimed ()
275274 },
276- setDefaultValues () {
275+ setDefaultValues () {
277276 this .values = {}
278277 this .ipAddresses = {}
279278 for (const item of this .items ) {
@@ -293,30 +292,30 @@ export default {
293292 }
294293 this .sendValuesTimed ()
295294 },
296- handleNetworkChange (nic , networkId ) {
295+ handleNetworkChange (nic , networkId ) {
297296 if (this .hypervisor === ' KVM' ) {
298297 this .setIpAddressEnabled (
299298 nic,
300- _ .find (this .networks , (option ) => option .id === networkId)
299+ _ .find (this .networks , (option ) => option .id === networkId),
301300 )
302301 } else {
303302 this .setIpAddressEnabled (
304303 nic,
305- _ .find (this .validNetworks [nic .id ], (option ) => option .id === networkId)
304+ _ .find (this .validNetworks [nic .id ], (option ) => option .id === networkId),
306305 )
307306 }
308307 this .sendValuesTimed ()
309308 },
310- getDefaultNetwork (record ) {
309+ getDefaultNetwork (record ) {
311310 return this .values [record .id ] || this .validNetworks [record .id ]? .[0 ]? .id
312311 },
313- sendValuesTimed () {
312+ sendValuesTimed () {
314313 clearTimeout (this .sendValuesTimer )
315314 this .sendValuesTimer = setTimeout (() => {
316315 this .sendValues (this .selectedScope )
317316 }, 500 )
318317 },
319- sendValues () {
318+ sendValues () {
320319 const data = {}
321320 if (this .selectionEnabled ) {
322321 this .selectedRowKeys .map ((x ) => {
@@ -336,8 +335,8 @@ export default {
336335 }
337336 }
338337 this .$emit (' select-multi-network' , data)
339- }
340- }
338+ },
339+ },
341340}
342341< / script>
343342
0 commit comments