List.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :group-actions="groupActions"
  6. :single-actions="singleActions"
  7. :export-data-options="exportDataOptions" />
  8. </template>
  9. <script>
  10. import ColumnsMixin from '../mixins/columns'
  11. import SingleActionsMixin from '../mixins/singleActions'
  12. import { getNameFilter, getDescriptionFilter } from '@/utils/common/tableFilter'
  13. import WindowsMixin from '@/mixins/windows'
  14. import ListMixin from '@/mixins/list'
  15. export default {
  16. name: 'ZoneList',
  17. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
  18. props: {
  19. id: String,
  20. getParams: {
  21. type: [Object, Function],
  22. default: () => ({}),
  23. },
  24. disableCreate: Boolean,
  25. hiddenActions: {
  26. type: Array,
  27. default: () => ([]),
  28. },
  29. },
  30. data () {
  31. return {
  32. list: this.$list.createList(this, {
  33. id: this.id,
  34. resource: 'zones',
  35. getParams: this.getParams,
  36. filterOptions: {
  37. name: getNameFilter(),
  38. description: getDescriptionFilter(),
  39. },
  40. }),
  41. exportDataOptions: {
  42. items: [
  43. { label: 'ID', key: 'id' },
  44. { label: this.$t('cloudenv.text_95'), key: 'name' },
  45. { label: this.$t('cloudenv.text_424'), key: 'hosts' },
  46. { label: this.$t('cloudenv.text_476'), key: 'hosts_enabled' },
  47. { label: this.$t('cloudenv.text_477'), key: 'baremetals' },
  48. { label: this.$t('cloudenv.text_478'), key: 'baremetals_enabled' },
  49. { label: this.$t('cloudenv.text_229'), key: 'wires' },
  50. ],
  51. getParams: {
  52. cloud_env: 'private_or_onpremise',
  53. with_meta: true,
  54. show_emulated: true,
  55. },
  56. },
  57. groupActions: [
  58. {
  59. label: this.$t('cloudenv.text_104'),
  60. permission: 'zones_create',
  61. action: () => {
  62. this.createDialog('CreateZoneDialog', {
  63. title: this.$t('cloudenv.text_479'),
  64. onManager: this.onManager,
  65. })
  66. },
  67. meta: () => {
  68. return {
  69. buttonType: 'primary',
  70. validate: !this.disableCreate,
  71. }
  72. },
  73. hidden: () => this.hiddenActions.includes('create'),
  74. },
  75. {
  76. label: this.$t('cloudenv.text_108'),
  77. permission: 'zones_delete',
  78. action: () => {
  79. this.createDialog('DeleteResDialog', {
  80. vm: this,
  81. data: this.list.selectedItems,
  82. columns: this.columns,
  83. name: this.$t('cloudenv.text_11'),
  84. title: this.$t('cloudenv.text_108'),
  85. onManager: this.onManager,
  86. })
  87. },
  88. meta: () => this.$getDeleteResult(this.list.selectedItems),
  89. },
  90. ],
  91. }
  92. },
  93. created () {
  94. this.initSidePageTab('zone-detail')
  95. this.list.fetchData()
  96. },
  97. methods: {
  98. handleOpenSidepage (row) {
  99. this.sidePageTriggerHandle(this, 'ZoneSidePage', {
  100. id: row.id,
  101. resource: 'zones',
  102. getParams: this.getParams,
  103. }, {
  104. list: this.list,
  105. hiddenActions: this.hiddenActions,
  106. })
  107. },
  108. },
  109. }
  110. </script>