ResourceManage.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <div>
  3. <page-list
  4. :list="list"
  5. :columns="columns" />
  6. </div>
  7. </template>
  8. <script>
  9. import { mapGetters } from 'vuex'
  10. import WindowsMixin from '@/mixins/windows'
  11. import ListMixin from '@/mixins/list'
  12. import { getNameFilter } from '@/utils/common/tableFilter'
  13. export default {
  14. name: 'WafResourcesForWafInstancesSidePage',
  15. components: {
  16. },
  17. mixins: [WindowsMixin, ListMixin],
  18. props: {
  19. id: String,
  20. data: Object,
  21. getParams: {
  22. type: Object,
  23. },
  24. },
  25. data () {
  26. return {
  27. list: this.$list.createList(this, {
  28. // idKey: 'id',
  29. resource: this.fetchResource,
  30. getParams: { details: true },
  31. filterOptions: {
  32. name: getNameFilter(),
  33. type: {
  34. label: this.$t('network.waf.resource_type'),
  35. dropdown: true,
  36. multiple: true,
  37. distinctField: {
  38. type: 'field',
  39. key: 'type',
  40. },
  41. },
  42. },
  43. }),
  44. columns: [
  45. {
  46. field: 'name',
  47. title: this.$t('network.waf.resource_name'),
  48. resizable: true,
  49. slots: {
  50. default: ({ row }) => {
  51. return [<list-body-cell-wrap copy row={row} field={'name'} />]
  52. },
  53. },
  54. },
  55. {
  56. field: 'type',
  57. title: this.$t('network.waf.resource_type'),
  58. resizable: true,
  59. formatter: ({ row }) => {
  60. const { type = '-' } = row
  61. return this.$te(`network_waf_resource_type.${type}`) ? this.$t(`network_waf_resource_type.${type}`) : type
  62. },
  63. },
  64. {
  65. field: 'port',
  66. title: this.$t('network.text_165'),
  67. resizable: true,
  68. formatter: ({ row }) => {
  69. return row.port || '-'
  70. },
  71. },
  72. ],
  73. }
  74. },
  75. computed: {
  76. ...mapGetters(['isAdminMode', 'scope', 'isDomainMode', 'userInfo', 'l3PermissionEnable']),
  77. },
  78. created () {
  79. this.initSidePageTab('waf-resource-list')
  80. this.list.fetchData()
  81. },
  82. methods: {
  83. async fetchResource (params) {
  84. try {
  85. const managerArgs = {
  86. id: this.data.id,
  87. spec: 'cloud-resources',
  88. params: {
  89. details: true,
  90. ...params,
  91. },
  92. }
  93. const res = await new this.$Manager('waf_instances', 'v2').getSpecific(managerArgs)
  94. return res
  95. } catch (error) {
  96. throw error
  97. }
  98. },
  99. },
  100. }
  101. </script>
  102. <style lang="less" scoped>
  103. .tag-list {
  104. min-height: 65px;
  105. border: 1px solid #ddd;
  106. padding: 8px;
  107. }
  108. .tag {
  109. max-width: 100%;
  110. line-height: 20px;
  111. margin-right: 10px;
  112. padding: 0 6px 0 4px;
  113. font-size: 12px;
  114. border-style: solid;
  115. border-width: 1px;
  116. }
  117. </style>