| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <template>
- <page-list
- :list="list"
- :columns="columns"
- :group-actions="groupActions"
- :single-actions="singleActions" />
- </template>
- <script>
- import { getCopyWithContentTableColumn, getStatusTableColumn } from '@/utils/common/tableColumn'
- import { getFilter } from '@/utils/common/tableFilter'
- import { sizestr } from '@/utils/utils'
- import WindowsMixin from '@/mixins/windows'
- export default {
- name: 'BlockStorageCachedImages',
- mixins: [WindowsMixin],
- props: {
- data: Object,
- getParams: {
- type: [Object, Function],
- default: () => ({}),
- },
- },
- data () {
- return {
- list: this.$list.createList(this, {
- id: 'CachedImageListForBlockStorageSidePage',
- resource: 'cachedimages',
- ctx: [['storagecaches', this.data.storagecache_id]],
- getParams: this.getParams,
- idKey: 'cachedimage_id',
- filterOptions: {
- image: getFilter({ field: 'image', title: this.$t('storage.text_40') }),
- },
- }),
- columns: [
- getCopyWithContentTableColumn({
- field: 'image',
- }),
- {
- field: 'size',
- title: this.$t('storage.text_71'),
- minWidth: 80,
- formatter: ({ row }) => {
- return sizestr(row.size, 'B', 1024)
- },
- },
- getStatusTableColumn({ statusModule: 'imageCache' }),
- getCopyWithContentTableColumn({
- field: 'path',
- title: this.$t('storage.text_72'),
- minWidth: 200,
- }),
- getCopyWithContentTableColumn({
- field: 'reference',
- title: this.$t('storage.text_73'),
- minWidth: 80,
- }),
- ],
- groupActions: [
- {
- label: this.$t('storage.text_74'),
- permission: 'cachedimages_uncache_image',
- action: row => {
- this.createDialog('UncacheImageDialog', {
- data: this.list.selectedItems,
- columns: this.columns,
- title: this.$t('storage.text_74'),
- list: this.list,
- resItem: this.data,
- refresh: this.refresh,
- })
- },
- meta: () => {
- const isReference = this.list.selectedItems.every(row => !row.reference)
- return {
- validate: !!this.list.selectedItems.length && isReference,
- }
- },
- },
- ],
- singleActions: [
- {
- label: this.$t('storage.text_74'),
- permission: 'cachedimages_uncache_image',
- action: row => {
- this.createDialog('UncacheImageDialog', {
- data: [row],
- columns: this.columns,
- title: this.$t('storage.text_74'),
- list: this.list,
- resItem: this.data,
- refresh: this.refresh,
- })
- },
- meta: row => {
- const isValidate = !row.reference
- return {
- validate: isValidate,
- tooltip: !isValidate && this.$t('storage.text_75'),
- }
- },
- },
- ],
- }
- },
- created () {
- this.list.fetchData()
- },
- methods: {
- refresh () {
- this.list.refresh()
- },
- },
- }
- </script>
|