2022-04-08 14:09:56 +08:00
|
|
|
<template>
|
2022-04-11 12:29:50 +08:00
|
|
|
<div class="backups-table">
|
2022-04-08 14:09:56 +08:00
|
|
|
<el-table :data="isConfigurations ? tableData : tableData2" border>
|
|
|
|
|
<el-table-column
|
|
|
|
|
class="table-column__head"
|
|
|
|
|
v-for="(item, index) in customTableTitle"
|
|
|
|
|
:key="`col-${index}`"
|
2022-05-26 09:00:29 +08:00
|
|
|
:width="`${item.width}`"
|
2022-05-30 09:18:13 +08:00
|
|
|
:min-width="`${item.minWidth}`"
|
2022-04-08 14:09:56 +08:00
|
|
|
:label="item.label"
|
|
|
|
|
:prop="item.prop"
|
|
|
|
|
:resizable="true"
|
|
|
|
|
>
|
|
|
|
|
<template slot="header">
|
|
|
|
|
<span class="data-column__span">{{ item.label }}</span>
|
|
|
|
|
<div class="col-resize-area"></div>
|
|
|
|
|
</template>
|
|
|
|
|
<template slot-scope="scope" :column="item">
|
2022-04-12 14:34:55 +08:00
|
|
|
<span v-if="item.prop === 'schedule'">
|
|
|
|
|
{{ tableData[0].schedule && changeType(tableData[0].schedule.type)? changeType(tableData[0].schedule.type):''}}
|
2022-04-08 14:09:56 +08:00
|
|
|
</span>
|
|
|
|
|
<span v-if="item.prop === 'retention'">
|
|
|
|
|
{{ tableData[0].retention }}
|
|
|
|
|
</span>
|
|
|
|
|
<span v-if="item.prop === 'state'">
|
2022-04-11 12:29:50 +08:00
|
|
|
<el-switch class="switch" v-model="tableData[0].state" disabled> </el-switch>
|
2022-04-08 14:09:56 +08:00
|
|
|
</span>
|
|
|
|
|
<span v-if="item.prop === 'time'">
|
2022-04-11 12:29:50 +08:00
|
|
|
{{ scope.row.time ? changeDate(scope.row.time ) : "" }}
|
2022-04-08 14:09:56 +08:00
|
|
|
</span>
|
|
|
|
|
<span v-if="item.prop === 'size'">
|
2022-04-08 19:07:25 +08:00
|
|
|
{{ scope.row.size ? getNum(scope.row.size) : "" }}
|
2022-04-08 14:09:56 +08:00
|
|
|
</span>
|
|
|
|
|
<span v-if="item.prop === 'fileName'"> {{ scope.row.fileName }} </span>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
2022-04-11 17:24:10 +08:00
|
|
|
<el-table-column :resizable="false" fixed="right"
|
2022-04-11 12:29:50 +08:00
|
|
|
width="165px"
|
|
|
|
|
>
|
2022-04-08 14:09:56 +08:00
|
|
|
<div
|
|
|
|
|
slot-scope="scope"
|
|
|
|
|
class="table-operation-items"
|
|
|
|
|
v-if="isConfigurations"
|
|
|
|
|
>
|
2022-07-01 09:39:20 +08:00
|
|
|
<button class="table-operation-button" @click="backupNow(scope.row)" :title="$t('config.backup')">
|
2022-05-26 09:00:29 +08:00
|
|
|
<i class="nz-icon-beifen nz-icon"></i>
|
2022-04-08 14:09:56 +08:00
|
|
|
</button>
|
2022-07-01 09:39:20 +08:00
|
|
|
<button class="table-operation-edit" @click="edit(scope.row)" :title="$t('backup.edit')">
|
2022-04-11 12:29:50 +08:00
|
|
|
<i class="nz-icon-gear nz-icon"></i>
|
|
|
|
|
</button>
|
2022-04-08 14:09:56 +08:00
|
|
|
</div>
|
2022-04-11 12:29:50 +08:00
|
|
|
|
2022-04-08 14:09:56 +08:00
|
|
|
<div slot-scope="scope" v-else class="table-operation-items">
|
2022-07-01 09:39:20 +08:00
|
|
|
<button class="table-operation-button" @click="Restore(scope.row)" v-if="scope.row" :title="$t('backup.RestoreNow')">
|
2022-05-26 09:00:29 +08:00
|
|
|
<i class="nz-icon-shujubeifenhuifu nz-icon"></i>
|
2022-04-08 14:09:56 +08:00
|
|
|
</button>
|
2022-10-14 15:43:11 +08:00
|
|
|
<div v-if="scope.row" @click="tableOperation(scope.row)">
|
|
|
|
|
<delete-button
|
|
|
|
|
ref="deleteButton"
|
|
|
|
|
:forceDeleteShow="false"
|
|
|
|
|
id="backup-delete"
|
|
|
|
|
:from="'backup'"
|
|
|
|
|
:type="'btn'"
|
|
|
|
|
:api="'/sys/backup'"
|
|
|
|
|
:single="true"
|
|
|
|
|
:delete-objs="singleDelete"
|
|
|
|
|
@before="delFlag=true"
|
|
|
|
|
></delete-button>
|
|
|
|
|
</div>
|
|
|
|
|
<!-- <button class="table-operation-edit" @click="del(scope.row)" v-if="scope.row" :title="$t('overall.delete')">
|
2022-04-11 12:29:50 +08:00
|
|
|
<i class="nz-icon nz-icon-delete" style="font-size='12px'"></i>
|
2022-10-14 15:43:11 +08:00
|
|
|
</button> -->
|
2022-04-08 14:09:56 +08:00
|
|
|
</div>
|
|
|
|
|
</el-table-column>
|
2022-06-20 17:22:52 +08:00
|
|
|
<template slot="empty">
|
|
|
|
|
<div v-if="!loading" class="table-no-data">
|
|
|
|
|
<svg class="icon" aria-hidden="true">
|
|
|
|
|
<use xlink:href="#nz-icon-no-data-list"></use>
|
|
|
|
|
</svg>
|
|
|
|
|
<div class="table-no-data__title">No results found</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else> </div>
|
|
|
|
|
</template>
|
2022-04-08 14:09:56 +08:00
|
|
|
</el-table>
|
2022-04-11 12:29:50 +08:00
|
|
|
</div>
|
2022-04-08 14:09:56 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2022-04-11 17:24:10 +08:00
|
|
|
import { post, put } from '@/http'
|
2022-04-08 15:05:10 +08:00
|
|
|
import lodash from 'lodash'
|
|
|
|
|
import bus from '@/libs/bus'
|
2022-10-14 15:43:11 +08:00
|
|
|
import deleteButton from '@/components/common/deleteButton'
|
2022-04-08 14:09:56 +08:00
|
|
|
|
|
|
|
|
export default {
|
2022-04-08 15:05:10 +08:00
|
|
|
name: 'backupsTable',
|
2022-04-08 14:09:56 +08:00
|
|
|
mixins: [],
|
2022-10-14 15:43:11 +08:00
|
|
|
components: { deleteButton },
|
2022-04-08 14:09:56 +08:00
|
|
|
props: {
|
|
|
|
|
loading: Boolean,
|
|
|
|
|
customTableTitle: Array,
|
|
|
|
|
isConfigurations: Boolean,
|
2022-04-11 16:01:36 +08:00
|
|
|
tableData: Array,
|
2022-04-11 17:24:10 +08:00
|
|
|
tableData2: Array
|
2022-04-08 14:09:56 +08:00
|
|
|
},
|
2022-04-08 15:05:10 +08:00
|
|
|
data () {
|
2022-04-08 14:09:56 +08:00
|
|
|
return {
|
2022-10-14 15:43:11 +08:00
|
|
|
singleDelete: []
|
2022-04-11 16:01:36 +08:00
|
|
|
// tableData: [
|
|
|
|
|
// {
|
|
|
|
|
// retention: '',
|
|
|
|
|
// state: '',
|
|
|
|
|
// schedule: {
|
|
|
|
|
// repeat: '',
|
|
|
|
|
// stime: '',
|
|
|
|
|
// type: '',
|
|
|
|
|
// nums: []
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// ],
|
|
|
|
|
// tableData2: [
|
|
|
|
|
// {
|
|
|
|
|
// fileName: '',
|
|
|
|
|
// time: '',
|
|
|
|
|
// size: ''
|
|
|
|
|
// }
|
|
|
|
|
// ]
|
2022-04-08 15:05:10 +08:00
|
|
|
}
|
2022-04-08 14:09:56 +08:00
|
|
|
},
|
|
|
|
|
computed: {},
|
|
|
|
|
|
|
|
|
|
methods: {
|
2022-04-12 15:03:33 +08:00
|
|
|
changeType (item) {
|
|
|
|
|
if (item == 1) {
|
2022-04-12 14:34:55 +08:00
|
|
|
return this.$t('backup.only')
|
2022-04-12 15:03:33 +08:00
|
|
|
} else if (item == 2) {
|
2022-04-12 14:34:55 +08:00
|
|
|
return this.$t('backup.Daily')
|
2022-04-12 15:03:33 +08:00
|
|
|
} else if (item == 3) {
|
2022-04-12 14:34:55 +08:00
|
|
|
return this.$t('backup.Weekly')
|
2022-04-12 15:03:33 +08:00
|
|
|
} else {
|
2022-04-12 14:34:55 +08:00
|
|
|
return this.$t('backup.Monthly')
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-04-11 17:24:10 +08:00
|
|
|
Restore (row) {
|
2022-05-31 09:34:32 +08:00
|
|
|
let ts = true
|
|
|
|
|
if (ts) {
|
|
|
|
|
ts = false
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
ts = true
|
|
|
|
|
put('/sys/backup/restore', { filename: row.fileName }).then(res => {
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
this.$emit('getTableData', 'recent')
|
|
|
|
|
this.$message.success(this.$t('backup.Restore'))
|
|
|
|
|
} else {
|
|
|
|
|
this.$message.error(res.msg)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}, 400)
|
|
|
|
|
}
|
2022-04-11 17:24:10 +08:00
|
|
|
},
|
2022-10-14 15:43:11 +08:00
|
|
|
// del (row) {
|
|
|
|
|
// this.$delete('/sys/backup?filename=' + row.fileName).then(res => {
|
|
|
|
|
// if (res.code == 200) {
|
|
|
|
|
// this.$emit('getTableData', 'recent')
|
|
|
|
|
// } else {
|
|
|
|
|
// this.$message.error(res.msg)
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
// },
|
2022-04-11 17:24:10 +08:00
|
|
|
changeDate (item) {
|
2022-06-10 10:48:48 +08:00
|
|
|
const time = this.utcTimeToTimezoneStr(item)
|
2022-06-15 14:12:08 +08:00
|
|
|
const time1 = this.timeFormate(time)
|
2022-04-11 17:24:10 +08:00
|
|
|
return time1
|
|
|
|
|
},
|
|
|
|
|
getNum (item) {
|
|
|
|
|
return bus.getNumStr(item)
|
|
|
|
|
},
|
2022-04-08 15:05:10 +08:00
|
|
|
backupNow (item) {
|
|
|
|
|
post('/sys/backup').then((res) => {
|
2022-05-30 18:37:01 +08:00
|
|
|
if (res.code == 200) {
|
|
|
|
|
this.$message.success(this.$t('backup.backupNow'))
|
2022-06-10 10:48:48 +08:00
|
|
|
bus.$emit('backupNow')
|
2022-05-30 18:37:01 +08:00
|
|
|
} else {
|
|
|
|
|
this.$message.error(res.msg)
|
|
|
|
|
}
|
2022-04-08 15:05:10 +08:00
|
|
|
})
|
2022-04-08 14:09:56 +08:00
|
|
|
},
|
2022-04-11 12:29:50 +08:00
|
|
|
edit () {
|
2022-04-11 17:24:10 +08:00
|
|
|
this.$emit('edit', this.tableData[0])
|
2022-10-14 15:43:11 +08:00
|
|
|
},
|
|
|
|
|
tableOperation (row) {
|
|
|
|
|
this.$set(row, 'name', row.fileName)
|
|
|
|
|
if (this.singleDelete.length === 0) {
|
|
|
|
|
this.singleDelete.push(row)
|
|
|
|
|
} else {
|
|
|
|
|
this.singleDelete = []
|
|
|
|
|
this.singleDelete.push(row)
|
|
|
|
|
}
|
2022-04-08 15:05:10 +08:00
|
|
|
}
|
2022-04-08 14:09:56 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
watch: {
|
2022-04-08 15:05:10 +08:00
|
|
|
}
|
|
|
|
|
}
|
2022-04-08 14:09:56 +08:00
|
|
|
</script>
|
|
|
|
|
<style lang='' scoped>
|
2022-04-08 15:05:10 +08:00
|
|
|
</style>
|