AccessGroupRule.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :single-actions="singleActions"
  6. :group-actions="groupActions" />
  7. </template>
  8. <script>
  9. import ListMixin from '@/mixins/list'
  10. import { getStatusTableColumn } from '@/utils/common/tableColumn'
  11. import WindowsMixin from '@/mixins/windows'
  12. import { getRwAccessTypeColumn, getUserAccessTypeColumn } from '../mixins/columns'
  13. export default {
  14. name: 'AccessGroupRuleList',
  15. mixins: [WindowsMixin, ListMixin],
  16. props: {
  17. id: {
  18. type: String,
  19. required: true,
  20. },
  21. },
  22. data () {
  23. const validate = this.id !== 'default'
  24. return {
  25. list: this.$list.createList(this, {
  26. resource: 'access_group_rules',
  27. getParams: {
  28. order: 'desc',
  29. order_by: 'priority',
  30. access_group_id: this.id,
  31. },
  32. filterOptions: {
  33. },
  34. }),
  35. columns: [
  36. {
  37. field: 'source',
  38. title: this.$t('storage.access.group.rule.source'),
  39. minWidth: 30,
  40. showOverflow: 'ellipsis',
  41. },
  42. getRwAccessTypeColumn(),
  43. getStatusTableColumn({ statusModule: 'accessGroupRule', vm: this }),
  44. getUserAccessTypeColumn(),
  45. {
  46. field: 'priority',
  47. title: this.$t('storage.access.group.rule.priority'),
  48. },
  49. {
  50. field: 'description',
  51. title: this.$t('compute.text_312'),
  52. slots: {
  53. default: ({ row }, h) => {
  54. const ret = []
  55. ret.push(h('list-body-cell-wrap', {
  56. props: {
  57. edit: true,
  58. copy: true,
  59. field: 'description',
  60. row,
  61. onManager: this.onManager,
  62. formRules: [],
  63. },
  64. }))
  65. return ret
  66. },
  67. },
  68. },
  69. ],
  70. singleActions: [
  71. {
  72. label: this.$t('common.action.delete'),
  73. permission: 'access_group_rules_delete',
  74. action: obj => {
  75. this.createDialog('DeleteResDialog', {
  76. vm: this,
  77. data: [obj],
  78. columns: this.columns,
  79. title: this.$t('storage.text_36'),
  80. name: this.$t('dictionary.access_group_rule'),
  81. onManager: this.onManager,
  82. refresh: this.refresh,
  83. })
  84. },
  85. meta: (obj) => {
  86. const ret = {
  87. validate,
  88. }
  89. if (!validate) {
  90. ret.tooltip = this.$t('storage.default.access.group.can.not.delete.rules')
  91. }
  92. return ret
  93. },
  94. },
  95. ],
  96. groupActions: [
  97. {
  98. label: this.$t('common.action.create'),
  99. permission: 'access_group_rules_create',
  100. action: () => {
  101. this.createDialog('AccessGroupRuleEditDialog', {
  102. title: this.$t('common.action.create'),
  103. data: [{}],
  104. onManager: this.onManager,
  105. refresh: this.refresh,
  106. access_group_id: this.id,
  107. })
  108. },
  109. meta: () => {
  110. const ret = {
  111. buttonType: 'primary',
  112. validate,
  113. }
  114. if (!validate) {
  115. ret.tooltip = this.$t('storage.default.access.group.can.not.add.rules')
  116. }
  117. return ret
  118. },
  119. },
  120. {
  121. label: this.$t('common.action.delete'),
  122. permission: 'access_group_rules_delete',
  123. action: () => {
  124. this.createDialog('DeleteResDialog', {
  125. vm: this,
  126. data: this.list.selectedItems,
  127. columns: this.columns,
  128. title: this.$t('common.action.delete'),
  129. name: this.$t('dictionary.access_group_rule'),
  130. onManager: this.onManager,
  131. })
  132. },
  133. meta: () => {
  134. const ret = {
  135. validate,
  136. }
  137. if (!validate) {
  138. ret.tooltip = this.$t('storage.default.access.group.can.not.delete.rules')
  139. }
  140. return ret
  141. },
  142. },
  143. ],
  144. }
  145. },
  146. created () {
  147. this.list.fetchData()
  148. },
  149. }
  150. </script>