<template>
  <MDialog :visible.sync="show" title="文件列表" widthType="1">
    <MTable
      :loading="false"
      elevation="0"
      :headers="headers"
      :items="items"
      :total="total"
      :page-info="pageInfo"
      :show-select="false"
      :is-tools="false"
    >
      <template #actions="{ item }">
        <v-btn text color="primary" @click="handleRestore(item)">恢复备份</v-btn>
      </template>
    </MTable>
    <BackupDetailsConfirm ref="backupDetailsConfirmRefs" @success="$emit('success')"></BackupDetailsConfirm>
  </MDialog>
</template>

<script>
import MDialog from '@/components/Dialog'
import MTable from '@/components/List/table'
import BackupDetailsConfirm from './backupDetailsConfirm.vue'
// import {
//   pgBackupRestore
// } from '@/api/dataChart'
export default {
  name: 'backupDetails',
  components: {
    MDialog,
    MTable,
    BackupDetailsConfirm
  },
  data () {
    return {
      show: false,
      headers: [
        { text: 'collection文件', align: 'start', value: 'collection_file' },
        { text: 'collection文件大小', align: 'center', value: 'collection_size' },
        { text: 'embedding文件', align: 'start', value: 'embedding_file' },
        { text: 'embedding文件大小', align: 'center', value: 'embedding_size' },
        { text: '备份日期', align: 'start', value: 'backup_date' },
        { text: '操作', value: 'actions' }
      ],
      itemData: {},
      items: [],
      orders: [],
      pageInfo: {
        size: 10,
        current: 1
      },
      total: 0
    }
  },
  methods: {
    open (item) {
      this.itemData = item
      this.items = item.backups
      this.total = item.backups.length
      this.show = true
    },
    handleRestore (item) {
      this.$refs.backupDetailsConfirmRefs.open(item, this.itemData)
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
