LeaveProject.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{ $t('system.text_197', [$t('dictionary.group')]) }}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :count="params.data.length" :action="$t('system.text_196', [$t('dictionary.group')])" :name="$t('dictionary.project')" />
  6. <dialog-table v-if="params.columns && params.columns.length" :data="params.data" :columns="params.columns.slice(0, 3)" />
  7. </div>
  8. <div slot="footer">
  9. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t("dialog.ok") }}</a-button>
  10. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  11. </div>
  12. </base-dialog>
  13. </template>
  14. <script>
  15. import DialogMixin from '@/mixins/dialog'
  16. import WindowsMixin from '@/mixins/windows'
  17. export default {
  18. name: 'GroupLeaveProjectDialog',
  19. mixins: [DialogMixin, WindowsMixin],
  20. data () {
  21. return {
  22. loading: false,
  23. }
  24. },
  25. destroyed () {
  26. this.manager = null
  27. },
  28. created () {
  29. this.manager = new this.$Manager('groups', 'v1')
  30. },
  31. methods: {
  32. async handleConfirm () {
  33. this.loading = true
  34. try {
  35. const pids = []
  36. this.params.data.forEach(p => {
  37. p.roles.forEach(r => {
  38. pids.push({
  39. project: p.id,
  40. role: r.id,
  41. })
  42. })
  43. })
  44. const values = {
  45. project_roles: pids,
  46. }
  47. await this.manager.performAction({
  48. id: this.params.resId,
  49. action: 'leave',
  50. data: values,
  51. })
  52. this.loading = false
  53. this.params.success()
  54. this.cancelDialog()
  55. } catch (error) {
  56. this.loading = false
  57. throw error
  58. }
  59. },
  60. },
  61. }
  62. </script>