ChangeOwner.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{ $t('cloudenv.clouduser_list_a2') }}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="$t('dictionary.clouduser')" :count="params.data.length" :action="$t('cloudenv.clouduser_list_a2')" />
  6. <dialog-table class="mb-2" :data="params.data" :columns="columns" />
  7. <a-form
  8. :form="form.fc"
  9. v-bind="formItemLayout">
  10. <a-form-item :label="$t('cloudenv.clouduser_list_t4')">
  11. <template v-if="userLoading">
  12. <a-spin />
  13. </template>
  14. <template v-else>
  15. <user-select
  16. v-decorator="decorators.user_id"
  17. :project.sync="form.fi.project"
  18. :cloudaccount-id="params.cloudaccount.id"
  19. :default-domain-id="userInfo.projectDomainId"
  20. :default-user-id="userInfo.id"
  21. :default-project-id="userInfo.projectId"
  22. :cloudprovider-id="params.data[0].cloudprovider_id" />
  23. </template>
  24. </a-form-item>
  25. </a-form>
  26. </div>
  27. <div slot="footer">
  28. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t('dialog.ok') }}</a-button>
  29. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  30. </div>
  31. </base-dialog>
  32. </template>
  33. <script>
  34. import { mapGetters } from 'vuex'
  35. import UserSelect from '../components/UserSelect'
  36. import DialogMixin from '@/mixins/dialog'
  37. import WindowsMixin from '@/mixins/windows'
  38. export default {
  39. name: 'ClouduserChangeOwnerDialog',
  40. components: {
  41. UserSelect,
  42. },
  43. mixins: [DialogMixin, WindowsMixin],
  44. data () {
  45. return {
  46. loading: false,
  47. userLoading: false,
  48. form: {
  49. fc: this.$form.createForm(this),
  50. fi: {
  51. project: {},
  52. },
  53. },
  54. decorators: {
  55. user_id: [
  56. 'user_id',
  57. {
  58. rules: [
  59. { required: false, message: this.$t('common.select') },
  60. ],
  61. },
  62. ],
  63. },
  64. formItemLayout: {
  65. wrapperCol: {
  66. span: 20,
  67. },
  68. labelCol: {
  69. span: 4,
  70. },
  71. },
  72. }
  73. },
  74. computed: {
  75. ...mapGetters(['userInfo']),
  76. columns () {
  77. const columns = this.params.columns.filter(item => {
  78. return ['name', 'status', 'owner_name'].indexOf(item.field) !== -1
  79. })
  80. return columns
  81. },
  82. },
  83. destroyed () {
  84. this.um = null
  85. },
  86. created () {
  87. this.um = new this.$Manager('users', 'v1')
  88. },
  89. methods: {
  90. async handleConfirm () {
  91. this.loading = true
  92. try {
  93. const values = await this.form.fc.validateFields()
  94. values.project_id = this.form.fi.project.id
  95. await this.params.onManager('performAction', {
  96. id: this.params.data[0].id,
  97. steadyStatus: 'available',
  98. managerArgs: {
  99. action: 'change-owner',
  100. data: values,
  101. },
  102. })
  103. this.cancelDialog()
  104. } finally {
  105. this.loading = false
  106. }
  107. },
  108. },
  109. }
  110. </script>