1717
1818<template >
1919 <a-spin :spinning =" loading" >
20+ <div v-if =" !isNormalUserOrProject" >
21+ <ownership-selection @fetch-owner =" fetchOwnerOptions" />
22+ </div >
2023 <a-form
2124 class =" form"
2225 layout =" vertical"
@@ -127,11 +130,14 @@ import { api } from '@/api'
127130import { mixinForm } from ' @/utils/mixin'
128131import ResourceIcon from ' @/components/view/ResourceIcon'
129132import TooltipLabel from ' @/components/widgets/TooltipLabel'
133+ import OwnershipSelection from ' @/views/compute/wizard/OwnershipSelection.vue'
134+ import store from ' @/store'
130135
131136export default {
132137 name: ' CreateVolume' ,
133138 mixins: [mixinForm],
134139 components: {
140+ OwnershipSelection,
135141 ResourceIcon,
136142 TooltipLabel
137143 },
@@ -143,6 +149,11 @@ export default {
143149 },
144150 data () {
145151 return {
152+ owner: {
153+ projectid: store .getters .project ? .id ,
154+ domainid: store .getters .project ? .id ? null : store .getters .userInfo .domainid ,
155+ account: store .getters .project ? .id ? null : store .getters .userInfo .account
156+ },
146157 snapshotZoneIds: [],
147158 zones: [],
148159 offerings: [],
@@ -155,6 +166,9 @@ export default {
155166 createVolumeFromVM () {
156167 return this .$route .path .startsWith (' /vm/' )
157168 },
169+ isNormalUserOrProject () {
170+ return [' User' ].includes (this .$store .getters .userInfo .roletype ) || store .getters .project ? .id
171+ },
158172 createVolumeFromSnapshot () {
159173 return this .$route .path .startsWith (' /snapshot' )
160174 }
@@ -195,6 +209,22 @@ export default {
195209 this .rules .diskofferingid = [{ required: true , message: this .$t (' message.error.select' ) }]
196210 }
197211 },
212+ fetchOwnerOptions (OwnerOptions ) {
213+ this .owner = {}
214+ if (OwnerOptions .selectedAccountType === this .$t (' label.account' )) {
215+ if (! OwnerOptions .selectedAccount ) {
216+ return
217+ }
218+ this .owner .account = OwnerOptions .selectedAccount
219+ this .owner .domainid = OwnerOptions .selectedDomain
220+ } else if (OwnerOptions .selectedAccountType === this .$t (' label.project' )) {
221+ if (! OwnerOptions .selectedProject ) {
222+ return
223+ }
224+ this .owner .projectid = OwnerOptions .selectedProject
225+ }
226+ this .fetchData ()
227+ },
198228 fetchData () {
199229 if (this .createVolumeFromSnapshot ) {
200230 this .fetchSnapshotZones ()
@@ -246,11 +276,17 @@ export default {
246276 this .loading = true
247277 var params = {
248278 zoneid: zoneId,
249- listall: true
279+ listall: true ,
280+ domainid: this .owner .domainid
250281 }
251282 if (this .createVolumeFromVM ) {
252283 params .virtualmachineid = this .resource .id
253284 }
285+ if (this .owner .projectid ) {
286+ params .projectid = this .owner .projectid
287+ } else {
288+ params .account = this .owner .account
289+ }
254290 api (' listDiskOfferings' , params).then (json => {
255291 this .offerings = json .listdiskofferingsresponse .diskoffering || []
256292 if (this .createVolumeFromVM ) {
@@ -279,6 +315,12 @@ export default {
279315 if (this .createVolumeFromSnapshot ) {
280316 values .snapshotid = this .resource .id
281317 }
318+ values .domainid = this .owner .domainid
319+ if (this .owner .projectid ) {
320+ values .projectid = this .owner .projectid
321+ } else {
322+ values .account = this .owner .account
323+ }
282324 this .loading = true
283325 api (' createVolume' , values).then (response => {
284326 this .$pollJob ({
0 commit comments