QuotaList.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns" />
  5. </template>
  6. <script>
  7. import WindowsMixin from '@/mixins/windows'
  8. import ListMixin from '@/mixins/list'
  9. import {
  10. // getNameDescriptionTableColumn,
  11. getCopyWithContentTableColumn,
  12. } from '@/utils/common/tableColumn'
  13. export default {
  14. name: 'CloudaccountQuotaList',
  15. mixins: [WindowsMixin, ListMixin],
  16. props: {
  17. getParams: {
  18. type: [Function, Object],
  19. },
  20. data: {
  21. type: Object,
  22. },
  23. },
  24. data () {
  25. return {
  26. list: this.$list.createList(this, {
  27. resource: 'cloudproviderquotas',
  28. getParams: {
  29. cloudprovider_id: this.data.id,
  30. },
  31. filterOptions: {
  32. name: {
  33. label: this.$t('cloudenv.text_95'),
  34. filter: true,
  35. formatter: val => {
  36. return `name.contains("${val}")`
  37. },
  38. },
  39. quota_type: {
  40. label: this.$t('cloudenv.text_360'),
  41. filter: true,
  42. formatter: val => {
  43. return `quota_type.contains("${val}")`
  44. },
  45. },
  46. cloudregion: {
  47. label: this.$t('cloudenv.text_10'),
  48. // filter: true,
  49. // formatter: val => {
  50. // return `cloudregion.contains("${val}")`
  51. // },
  52. },
  53. },
  54. }),
  55. columns: [
  56. {
  57. field: 'name',
  58. title: this.$t('cloudenv.text_95'),
  59. minWidth: 150,
  60. slots: {
  61. default: ({ row }, h) => {
  62. const { name } = row
  63. const text = this.$t('cloudproviderquotaNames')[name] || name
  64. return [
  65. <list-body-cell-wrap hideField copy field={'name'} row={row} message={text}>
  66. {text}
  67. </list-body-cell-wrap>,
  68. ]
  69. },
  70. },
  71. },
  72. getCopyWithContentTableColumn({
  73. field: 'quota_type',
  74. title: this.$t('cloudenv.text_360'),
  75. }),
  76. getCopyWithContentTableColumn({
  77. field: 'cloudregion',
  78. title: this.$t('cloudenv.text_10'),
  79. }),
  80. {
  81. field: 'used_count',
  82. title: this.$t('cloudenv.text_361'),
  83. minWidth: 330,
  84. sortable: true,
  85. slots: {
  86. default: ({ row }) => {
  87. const { used_count: uc, max_count: mc } = row
  88. const percent = uc / mc * 100
  89. const format = (percent, successPercent) => {
  90. return Math.round(percent) + '%'
  91. }
  92. let strokeColor = '#52c41a'
  93. if (Math.round(percent) > 60) {
  94. strokeColor = '#faad14'
  95. }
  96. if (Math.round(percent) > 80) {
  97. strokeColor = '#f5222d'
  98. }
  99. return [
  100. <a-row>
  101. <a-col span={14}>
  102. <a-progress status={'active'} strokeColor={strokeColor} format={format} size="small" percent={percent} />
  103. </a-col>
  104. <a-col span={10}>
  105. <span style={{ fontSize: '12px', paddingLeft: '20px' }}>{uc}({this.$t('common.total', [mc])})</span>
  106. </a-col>
  107. </a-row>,
  108. ]
  109. },
  110. },
  111. },
  112. ],
  113. }
  114. },
  115. created () {
  116. this.list.fetchData()
  117. },
  118. }
  119. </script>