Policies.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <page-list
  3. id="role-sidepage-role-policies-list"
  4. :list="list"
  5. :columns="tableColumns"
  6. :group-actions="groupActions"
  7. :single-actions="singleActions"
  8. default-search-key="policy_id" />
  9. </template>
  10. <script>
  11. import ListMixin from '@/mixins/list'
  12. import WindowsMixin from '@/mixins/windows'
  13. import {
  14. getCopyWithContentTableColumn,
  15. getNameDescriptionTableColumn,
  16. getTimeRangeColumn,
  17. } from '@/utils/common/tableColumn'
  18. export default {
  19. name: 'PoliciesListForRoleSidepage',
  20. mixins: [WindowsMixin, ListMixin],
  21. props: {
  22. id: String,
  23. resId: {
  24. type: String,
  25. required: true,
  26. },
  27. columns: Array,
  28. data: Object,
  29. singleRefreshRole: Function,
  30. },
  31. data () {
  32. return {
  33. list: this.$list.createList(this, {
  34. id: this.id,
  35. resource: 'rolepolicies',
  36. apiVersion: 'v1',
  37. getParams: this.getParam,
  38. filterOptions: {
  39. policy_id: {
  40. label: this.$t('system.text_101'),
  41. },
  42. },
  43. }),
  44. tableColumns: [
  45. getNameDescriptionTableColumn({
  46. resource: 'policies',
  47. hideField: true,
  48. showDesc: false,
  49. edit: false,
  50. slotCallback: row => {
  51. return (
  52. <side-page-trigger onTrigger={ () => this.handleOpenSidepage(row) }>{ row.policy }</side-page-trigger>
  53. )
  54. },
  55. }),
  56. {
  57. field: 'description',
  58. title: this.$t('table.title.desc'),
  59. minWidth: 200,
  60. },
  61. getCopyWithContentTableColumn({
  62. field: 'ips',
  63. title: this.$t('system.text_328'),
  64. }),
  65. getCopyWithContentTableColumn({
  66. field: 'project',
  67. title: this.$t('res.project'),
  68. }),
  69. getTimeRangeColumn({
  70. start_field: 'valid_since',
  71. end_field: 'valid_until',
  72. title: this.$t('iam.role_policy_valid_time_range'),
  73. format: 'YYYY-MM-DD hh:mm',
  74. }),
  75. ],
  76. groupActions: [
  77. {
  78. label: this.$t('role.action.add_policies'),
  79. permission: 'roles_perform_set_policies',
  80. action: () => {
  81. this.createDialog('RoleSetPoliciesDialog', {
  82. data: [this.data],
  83. setPoliciesAction: 'update',
  84. columns: this.columns,
  85. success: () => {
  86. this.refresh()
  87. this.singleRefreshRole(this.resId)
  88. },
  89. })
  90. },
  91. meta: () => {
  92. return {
  93. buttonType: 'primary',
  94. }
  95. },
  96. },
  97. {
  98. label: this.$t('common.remove'),
  99. permission: 'rolepolicies_delete',
  100. action: () => {
  101. this.createDialog('DeleteResDialog', {
  102. vm: this,
  103. data: this.list.selectedItems,
  104. columns: this.tableColumns,
  105. title: this.$t('common.remove'),
  106. name: this.$t('res.policy'),
  107. onManager: this.onManager,
  108. })
  109. },
  110. meta: () => this.$getDeleteResult(this.list.selectedItems),
  111. },
  112. ],
  113. singleActions: [
  114. {
  115. label: this.$t('common.remove'),
  116. permission: 'rolepolicies_delete',
  117. action: (obj) => {
  118. this.createDialog('DeleteResDialog', {
  119. vm: this,
  120. data: [obj],
  121. columns: this.tableColumns,
  122. title: this.$t('common.remove'),
  123. name: this.$t('res.policy'),
  124. onManager: this.onManager,
  125. })
  126. },
  127. meta: (obj) => this.$getDeleteResult(obj),
  128. },
  129. ],
  130. }
  131. },
  132. created () {
  133. this.list.fetchData()
  134. },
  135. methods: {
  136. getParam () {
  137. return {
  138. filter: `role_id.in("${this.resId}")`,
  139. }
  140. },
  141. handleOpenSidepage (row, tab) {
  142. this.sidePageTriggerHandle(this, 'PolicySidePage', {
  143. id: row.policy_id,
  144. resource: 'policies',
  145. apiVersion: 'v1',
  146. getParams: this.getParam,
  147. })
  148. },
  149. },
  150. }
  151. </script>