CachedImages.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :group-actions="groupActions"
  6. :single-actions="singleActions" />
  7. </template>
  8. <script>
  9. import { getCopyWithContentTableColumn, getStatusTableColumn } from '@/utils/common/tableColumn'
  10. import { getFilter } from '@/utils/common/tableFilter'
  11. import { sizestr } from '@/utils/utils'
  12. import WindowsMixin from '@/mixins/windows'
  13. export default {
  14. name: 'BlockStorageCachedImages',
  15. mixins: [WindowsMixin],
  16. props: {
  17. data: Object,
  18. getParams: {
  19. type: [Object, Function],
  20. default: () => ({}),
  21. },
  22. },
  23. data () {
  24. return {
  25. list: this.$list.createList(this, {
  26. id: 'CachedImageListForBlockStorageSidePage',
  27. resource: 'cachedimages',
  28. ctx: [['storagecaches', this.data.storagecache_id]],
  29. getParams: this.getParams,
  30. idKey: 'cachedimage_id',
  31. filterOptions: {
  32. image: getFilter({ field: 'image', title: this.$t('storage.text_40') }),
  33. },
  34. }),
  35. columns: [
  36. getCopyWithContentTableColumn({
  37. field: 'image',
  38. }),
  39. {
  40. field: 'size',
  41. title: this.$t('storage.text_71'),
  42. minWidth: 80,
  43. formatter: ({ row }) => {
  44. return sizestr(row.size, 'B', 1024)
  45. },
  46. },
  47. getStatusTableColumn({ statusModule: 'imageCache' }),
  48. getCopyWithContentTableColumn({
  49. field: 'path',
  50. title: this.$t('storage.text_72'),
  51. minWidth: 200,
  52. }),
  53. getCopyWithContentTableColumn({
  54. field: 'reference',
  55. title: this.$t('storage.text_73'),
  56. minWidth: 80,
  57. }),
  58. ],
  59. groupActions: [
  60. {
  61. label: this.$t('storage.text_74'),
  62. permission: 'cachedimages_uncache_image',
  63. action: row => {
  64. this.createDialog('UncacheImageDialog', {
  65. data: this.list.selectedItems,
  66. columns: this.columns,
  67. title: this.$t('storage.text_74'),
  68. list: this.list,
  69. resItem: this.data,
  70. refresh: this.refresh,
  71. })
  72. },
  73. meta: () => {
  74. const isReference = this.list.selectedItems.every(row => !row.reference)
  75. return {
  76. validate: !!this.list.selectedItems.length && isReference,
  77. }
  78. },
  79. },
  80. ],
  81. singleActions: [
  82. {
  83. label: this.$t('storage.text_74'),
  84. permission: 'cachedimages_uncache_image',
  85. action: row => {
  86. this.createDialog('UncacheImageDialog', {
  87. data: [row],
  88. columns: this.columns,
  89. title: this.$t('storage.text_74'),
  90. list: this.list,
  91. resItem: this.data,
  92. refresh: this.refresh,
  93. })
  94. },
  95. meta: row => {
  96. const isValidate = !row.reference
  97. return {
  98. validate: isValidate,
  99. tooltip: !isValidate && this.$t('storage.text_75'),
  100. }
  101. },
  102. },
  103. ],
  104. }
  105. },
  106. created () {
  107. this.list.fetchData()
  108. },
  109. methods: {
  110. refresh () {
  111. this.list.refresh()
  112. },
  113. },
  114. }
  115. </script>