UncacheImage.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{this.params.title}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :count="params.data.length" :action="this.params.title" :name="$t('dictionary.image')" />
  6. <dialog-table :data="params.data" :columns="params.columns.slice(0, 3)" />
  7. <a-checkbox v-model="force_checked">{{$t('compute.force_delete.extra')}}</a-checkbox>
  8. </div>
  9. <div slot="footer">
  10. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t("dialog.ok") }}</a-button>
  11. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  12. </div>
  13. </base-dialog>
  14. </template>
  15. <script>
  16. import DialogMixin from '@/mixins/dialog'
  17. import WindowsMixin from '@/mixins/windows'
  18. export default {
  19. name: 'UncacheImageDialog',
  20. mixins: [DialogMixin, WindowsMixin],
  21. data () {
  22. return {
  23. loading: false,
  24. force_checked: false,
  25. }
  26. },
  27. methods: {
  28. async handleConfirm () {
  29. this.loading = true
  30. try {
  31. const manager = new this.$Manager('cachedimages')
  32. await manager.batchPerformAction({
  33. action: 'uncache-image',
  34. ids: this.params.data.map(item => item.cachedimage_id),
  35. data: {
  36. storagecache_id: this.params.resItem.storagecache_id,
  37. is_force: this.force_checked,
  38. },
  39. })
  40. this.cancelDialog()
  41. this.params.refresh()
  42. this.loading = false
  43. } catch (error) {
  44. this.loading = false
  45. throw error
  46. }
  47. },
  48. },
  49. }
  50. </script>