8585 <template #label >
8686 <tooltip-label :title =" $t('label.directdownload')" :tooltip =" apiParams.directdownload.description" />
8787 </template >
88- <a-switch v-model:checked =" form.directdownload" />
88+ <a-switch v-model:checked =" form.directdownload" @change = " handleDirectDownloadChange " />
8989 </a-form-item >
9090
9191 <a-form-item ref =" checksum" name =" checksum" >
110110 }"
111111 :loading =" zoneLoading"
112112 :placeholder =" apiParams.zoneid.description" >
113- <a-select-option :value =" opt.id" v-for =" opt in zones " :key =" opt.id" :label =" opt.name || opt.description" >
113+ <a-select-option :value =" opt.id" v-for =" opt in zoneList " :key =" opt.id" :label =" opt.name || opt.description" >
114114 <span >
115115 <resource-icon v-if =" opt.icon" :image =" opt.icon.base64image" size =" 1x" style =" margin-right : 5px " />
116116 <global-outlined v-else style =" margin-right : 5px " />
@@ -371,17 +371,18 @@ export default {
371371 },
372372 created () {
373373 this .initForm ()
374- this .zones = []
375- if (this .$store .getters .userInfo .roletype === ' Admin' && this .currentForm === ' Create' ) {
376- this .zones = [
377- {
378- id: ' -1' ,
379- name: this .$t (' label.all.zone' )
380- }
381- ]
382- }
374+ this .initZones ()
383375 this .fetchData ()
384376 },
377+ computed: {
378+ zoneList () {
379+ let filteredZones = this .zones
380+ if (! this .form .directdownload ) {
381+ filteredZones = this .zones .filter (zone => zone .type !== ' Edge' )
382+ }
383+ return filteredZones
384+ }
385+ },
385386 methods: {
386387 initForm () {
387388 this .formRef = ref ()
@@ -400,6 +401,17 @@ export default {
400401 ostypeid: [{ required: true , message: this .$t (' message.error.select' ) }]
401402 })
402403 },
404+ initZones () {
405+ this .zones = []
406+ if (this .$store .getters .userInfo .roletype === ' Admin' && this .currentForm === ' Create' ) {
407+ this .zones = [
408+ {
409+ id: ' -1' ,
410+ name: this .$t (' label.all.zone' )
411+ }
412+ ]
413+ }
414+ },
403415 fetchData () {
404416 this .fetchZoneData ()
405417 this .fetchOsType ()
@@ -422,11 +434,10 @@ export default {
422434 const listZones = json .listzonesresponse .zone
423435 if (listZones) {
424436 this .zones = this .zones .concat (listZones)
425- this .zones = this .zones .filter (zone => zone .type !== ' Edge' )
426437 }
427438 }).finally (() => {
428439 this .zoneLoading = false
429- this .form .zoneid = ( this .zones [ 0 ]. id ? this . zones [0 ].id : ' ' )
440+ this .form .zoneid = this .zoneList ? . [0 ]? .id || ' '
430441 })
431442 },
432443 fetchOsType () {
@@ -477,6 +488,12 @@ export default {
477488 this .fileList = newFileList
478489 this .form .file = undefined
479490 },
491+ handleDirectDownloadChange () {
492+ if (this .form .zoneid && this .zoneList .find (entry => entry .id === this .form .zoneid )) {
493+ return
494+ }
495+ this .form .zoneid = this .zoneList ? .[0 ]? .id || ' '
496+ },
480497 beforeUpload (file ) {
481498 this .fileList = [file]
482499 this .form .file = file
@@ -542,7 +559,7 @@ export default {
542559 }
543560 switch (key) {
544561 case ' zoneid' :
545- var zone = this .zones .filter (zone => zone .id === input)
562+ var zone = this .zoneList .filter (zone => zone .id === input)
546563 params[key] = zone[0 ].id
547564 break
548565 case ' ostypeid' :
0 commit comments