AddUser.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{ $t('cloudenv.cloudgroup_single_action1') }}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="$t('dictionary.cloudgroup')" :count="params.data.length" :action="$t('cloudenv.cloudgroup_single_action1')" />
  6. <dialog-table class="mb-2" :data="params.data" :columns="params.columns.slice(0, 3)" />
  7. <a-form
  8. :form="form.fc"
  9. v-bind="formItemLayout">
  10. <a-form-item :label="$t('cloudenv.coludgroup_text001')">
  11. <list-select
  12. v-decorator="decorators.clouduser_id"
  13. :listProps="clouduserSelectProps"
  14. :formatter="row => `${row.name} / ${row.cloudaccount || ''}`"
  15. :multiple="false"
  16. :dialog-params="{ mask: false, width: 900, title: $t('rules.clouduser') }" />
  17. </a-form-item>
  18. </a-form>
  19. </div>
  20. <div slot="footer">
  21. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t('dialog.ok') }}</a-button>
  22. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  23. </div>
  24. </base-dialog>
  25. </template>
  26. <script>
  27. import DialogMixin from '@/mixins/dialog'
  28. import WindowsMixin from '@/mixins/windows'
  29. import ListSelect from '@/sections/ListSelect'
  30. import { getNameFilter } from '@/utils/common/tableFilter'
  31. import { getStatusTableColumn } from '@/utils/common/tableColumn'
  32. export default {
  33. name: 'CloudgroupAddUserDialog',
  34. components: {
  35. ListSelect,
  36. },
  37. mixins: [DialogMixin, WindowsMixin],
  38. data () {
  39. return {
  40. loading: false,
  41. form: {
  42. fc: this.$form.createForm(this),
  43. fi: {
  44. generate_name: '',
  45. },
  46. },
  47. decorators: {
  48. clouduser_id: [
  49. 'clouduser_id',
  50. {
  51. validateFirst: true,
  52. rules: [
  53. { required: true, message: this.$t('common.select') },
  54. ],
  55. },
  56. ],
  57. },
  58. clouduserSelectProps: {
  59. list: this.$list.createList(this, {
  60. resource: 'cloudusers',
  61. apiVersion: 'v1',
  62. getParams: () => {
  63. return {
  64. scope: this.$store.getters.scope,
  65. manager_id: this.params.data[0].manager_id,
  66. cloudaccount_id: this.params.data[0].cloudaccount_id,
  67. }
  68. },
  69. filterOptions: {
  70. name: getNameFilter(),
  71. },
  72. }),
  73. columns: [
  74. {
  75. field: 'name',
  76. title: this.$t('table.title.name'),
  77. showOverflow: 'title',
  78. },
  79. getStatusTableColumn({ statusModule: 'clouduser' }),
  80. {
  81. field: 'cloudaccount',
  82. title: this.$t('dictionary.cloudaccount'),
  83. showOverflow: 'title',
  84. },
  85. ],
  86. },
  87. formItemLayout: {
  88. wrapperCol: {
  89. span: 21,
  90. },
  91. labelCol: {
  92. span: 3,
  93. },
  94. },
  95. }
  96. },
  97. methods: {
  98. async handleConfirm () {
  99. this.loading = true
  100. try {
  101. const values = await this.form.fc.validateFields()
  102. await this.params.onManager('performAction', {
  103. steadyStatus: ['available'],
  104. id: this.params.data[0].id,
  105. managerArgs: {
  106. action: 'add-user',
  107. data: {
  108. ...values,
  109. provider: this.params.data[0].provider,
  110. },
  111. },
  112. })
  113. this.cancelDialog()
  114. } finally {
  115. this.loading = false
  116. }
  117. },
  118. },
  119. }
  120. </script>