DeleteRes.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{ params.title }}</div>
  4. <div slot="body">
  5. <a-alert :message="$t('iam.operation_object.alter_tips')" class="mb-2" />
  6. <dialog-selected-tips :name="$t('common_578')" :count="params.data.length" :action="this.params.title" />
  7. <dialog-table v-if="params.columns && params.columns.length" :data="params.data" :columns="params.columns.slice(0, 3)" />
  8. </div>
  9. <div slot="footer">
  10. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t("dialog.ok") }}</a-button>
  11. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  12. </div>
  13. </base-dialog>
  14. </template>
  15. <script>
  16. import * as R from 'ramda'
  17. import DialogMixin from '@/mixins/dialog'
  18. import WindowsMixin from '@/mixins/windows'
  19. export default {
  20. name: 'ProjectDeleteResDialog',
  21. mixins: [DialogMixin, WindowsMixin],
  22. data () {
  23. return {
  24. loading: false,
  25. }
  26. },
  27. methods: {
  28. async handleConfirm () {
  29. this.loading = true
  30. const userRoles = []
  31. const groupRoles = []
  32. this.params.data.forEach((item) => {
  33. const roles = item.roles
  34. roles.forEach((role) => {
  35. if (item.groupId && item.groupName) {
  36. const ret = {
  37. group: item.groupId,
  38. role: role.id,
  39. }
  40. groupRoles.push(ret)
  41. } else {
  42. const ret = {
  43. user: item.id,
  44. role: role.id,
  45. }
  46. userRoles.push(ret)
  47. }
  48. })
  49. })
  50. try {
  51. if (this.params.ok) {
  52. await this.params.ok()
  53. } else {
  54. const response = await new this.$Manager('projects', 'v1').performAction({
  55. id: this.params.projectId,
  56. action: 'leave',
  57. data: { user_roles: userRoles, group_roles: groupRoles },
  58. })
  59. if (this.params.success && R.is(Function, this.params.success)) {
  60. this.params.success(response)
  61. }
  62. }
  63. this.cancelDialog()
  64. this.$message.success(this.$t('system.text_455'))
  65. } finally {
  66. this.loading = false
  67. }
  68. },
  69. },
  70. }
  71. </script>