PciList.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 WindowsMixin from '@/mixins/windows'
  11. import ListMixin from '@/mixins/list'
  12. import ColumnsMixin from '../mixins/columns'
  13. import SingleActionsMixin from '../mixins/singleActions'
  14. export default {
  15. name: 'PciList',
  16. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
  17. data () {
  18. return {
  19. list: this.$list.createList(this, {
  20. id: 'pciList',
  21. resource: 'isolated_device_models',
  22. getParams: this.getParam,
  23. filterOptions: {
  24. dev_type: {
  25. label: this.$t('compute.pci.dev_type'),
  26. filter: true,
  27. formatter: val => {
  28. return `dev_type.contains("${val}")`
  29. },
  30. },
  31. model: {
  32. label: this.$t('compute.pci.model'),
  33. filter: true,
  34. formatter: val => {
  35. return `model.contains("${val}")`
  36. },
  37. },
  38. vendor_id: {
  39. label: this.$t('compute.pci.vendor_id'),
  40. filter: true,
  41. formatter: val => {
  42. return `vendor_id.contains("${val}")`
  43. },
  44. },
  45. device_id: {
  46. label: this.$t('compute.pci.device_id'),
  47. filter: true,
  48. formatter: val => {
  49. return `device_id.contains("${val}")`
  50. },
  51. },
  52. },
  53. }),
  54. exportDataOptions: {
  55. items: [
  56. { label: 'ID', key: 'id' },
  57. { label: this.$t('compute.pci.dev_type'), key: 'dev_type' },
  58. { label: this.$t('compute.pci.model'), key: 'model' },
  59. { label: this.$t('compute.pci.vendor_id'), key: 'vendor_id' },
  60. { label: this.$t('compute.pci.device_id'), key: 'device_id' },
  61. ],
  62. },
  63. columns: [],
  64. groupActions: [
  65. {
  66. label: this.$t('common.create'),
  67. permission: 'isolated_device_models_create',
  68. action: () => {
  69. this.createDialog('PciCreateDialog', {
  70. refresh: this.refresh,
  71. })
  72. },
  73. meta: () => ({
  74. buttonType: 'primary',
  75. }),
  76. },
  77. {
  78. label: this.$t('table.action.delete'),
  79. permission: 'isolated_device_models_delete',
  80. action: () => {
  81. this.createDialog('DeleteResDialog', {
  82. vm: this,
  83. data: this.list.selectedItems,
  84. columns: this.columns,
  85. title: this.$t('table.action.delete'),
  86. name: this.$t('compute.pci.passthrough_device_type'),
  87. onManager: this.onManager,
  88. })
  89. },
  90. meta: () => {
  91. const ret = { validate: this.list.selected.length }
  92. if (this.list.selectedItems.some(item => !item.can_delete)) {
  93. ret.validate = false
  94. return ret
  95. }
  96. return ret
  97. },
  98. },
  99. ],
  100. }
  101. },
  102. created () {
  103. this.initSidePageTab('pci-detail')
  104. this.list.fetchData()
  105. },
  106. methods: {
  107. getParam () {
  108. const ret = {
  109. with_meta: true,
  110. details: true,
  111. }
  112. return ret
  113. },
  114. handleOpenSidepage (row, tab) {
  115. this.sidePageTriggerHandle(this, 'PciSidePage', {
  116. id: row.id,
  117. resource: 'isolated_device_models',
  118. getParams: this.getParam,
  119. }, {
  120. list: this.list,
  121. tab,
  122. })
  123. },
  124. },
  125. }
  126. </script>
  127. <style>
  128. </style>