2022-04-08 14:09:56 +08:00
|
|
|
<template>
|
|
|
|
|
<el-table :data="isConfigurations ? tableData : tableData2" border>
|
|
|
|
|
<el-table-column
|
|
|
|
|
class="table-column__head"
|
|
|
|
|
v-for="(item, index) in customTableTitle"
|
|
|
|
|
:key="`col-${index}`"
|
|
|
|
|
: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">
|
|
|
|
|
<span v-if="item.prop === 'repeat'">
|
|
|
|
|
{{ tableData[0].schedule && tableData[0].schedule.repeat }}
|
|
|
|
|
</span>
|
|
|
|
|
<span v-if="item.prop === 'retention'">
|
|
|
|
|
{{ tableData[0].retention }}
|
|
|
|
|
</span>
|
|
|
|
|
<span v-if="item.prop === 'last'">
|
2022-04-08 15:05:10 +08:00
|
|
|
{{ tableData[0].schedule && utcTimeToTimezoneStr(tableData[0].schedule.stime) }}
|
2022-04-08 14:09:56 +08:00
|
|
|
</span>
|
|
|
|
|
<span v-if="item.prop === 'state'">
|
|
|
|
|
<el-switch class="switch" v-model="switchStatus"> </el-switch>
|
|
|
|
|
</span>
|
|
|
|
|
<span v-if="item.prop === 'time'">
|
|
|
|
|
{{ scope.row.time ? scope.row.time : "-" }}
|
|
|
|
|
</span>
|
|
|
|
|
<span v-if="item.prop === 'size'">
|
|
|
|
|
{{ scope.row.size ? scope.row.size : "" }}
|
|
|
|
|
</span>
|
|
|
|
|
<span v-if="item.prop === 'fileName'"> {{ scope.row.fileName }} </span>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column :resizable="false" fixed="right">
|
|
|
|
|
<div
|
|
|
|
|
slot-scope="scope"
|
|
|
|
|
class="table-operation-items"
|
|
|
|
|
v-if="isConfigurations"
|
|
|
|
|
>
|
|
|
|
|
<button class="table-operation-button" @click="backupNow(scope.row)">
|
|
|
|
|
backup now
|
|
|
|
|
</button>
|
|
|
|
|
<el-dropdown size="medium" trigger="click" @command="tableOperation">
|
|
|
|
|
<div class="table-operation-item table-operation-item--more">
|
|
|
|
|
<i class="nz-icon nz-icon-more3"></i>
|
|
|
|
|
</div>
|
|
|
|
|
<el-dropdown-menu
|
|
|
|
|
slot="dropdown"
|
|
|
|
|
class="right-box-select-top right-public-box-dropdown-top"
|
|
|
|
|
>
|
|
|
|
|
<el-dropdown-item command="edit"
|
|
|
|
|
><i class="nz-icon nz-icon-edit"></i
|
|
|
|
|
><span class="operation-dropdown-text">{{
|
|
|
|
|
$t("overall.edit")
|
|
|
|
|
}}</span></el-dropdown-item
|
|
|
|
|
>
|
|
|
|
|
<el-dropdown-item @click="tableOperation('del', scope.row)"
|
|
|
|
|
><i class="nz-icon nz-icon-delete"></i
|
|
|
|
|
><span class="operation-dropdown-text">{{
|
|
|
|
|
$t("overall.delete")
|
|
|
|
|
}}</span></el-dropdown-item
|
|
|
|
|
>
|
|
|
|
|
</el-dropdown-menu>
|
|
|
|
|
</el-dropdown>
|
|
|
|
|
</div>
|
|
|
|
|
<div slot-scope="scope" v-else class="table-operation-items">
|
|
|
|
|
<button class="table-operation-button" @click="Restore(scope.row)">
|
|
|
|
|
Restore
|
|
|
|
|
</button>
|
|
|
|
|
<button class="table-operation-del" @click="del(scope.row)">
|
|
|
|
|
<i class="nz-icon nz-icon-delete"></i>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2022-04-08 15:05:10 +08:00
|
|
|
import { get, post } from '@/http'
|
|
|
|
|
import lodash from 'lodash'
|
|
|
|
|
import bus from '@/libs/bus'
|
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: [],
|
|
|
|
|
|
|
|
|
|
props: {
|
|
|
|
|
loading: Boolean,
|
|
|
|
|
customTableTitle: Array,
|
|
|
|
|
isConfigurations: Boolean,
|
2022-04-08 15:05:10 +08:00
|
|
|
isState: Boolean
|
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 {
|
|
|
|
|
switchStatus: true,
|
|
|
|
|
tableData: [
|
|
|
|
|
{
|
2022-04-08 15:05:10 +08:00
|
|
|
retention: '',
|
|
|
|
|
state: '',
|
2022-04-08 14:09:56 +08:00
|
|
|
schedule: {
|
2022-04-08 15:05:10 +08:00
|
|
|
repeat: '',
|
|
|
|
|
stime: '',
|
|
|
|
|
type: '',
|
|
|
|
|
nums: []
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-04-08 14:09:56 +08:00
|
|
|
],
|
|
|
|
|
tableData2: [
|
|
|
|
|
{
|
2022-04-08 15:05:10 +08:00
|
|
|
fileName: '',
|
|
|
|
|
time: '',
|
|
|
|
|
size: ''
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
2022-04-08 14:09:56 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
components: {},
|
|
|
|
|
|
|
|
|
|
computed: {},
|
|
|
|
|
|
2022-04-08 15:05:10 +08:00
|
|
|
created () {},
|
2022-04-08 14:09:56 +08:00
|
|
|
|
2022-04-08 15:05:10 +08:00
|
|
|
mounted () {
|
|
|
|
|
this.getTableData()
|
2022-04-08 14:09:56 +08:00
|
|
|
this.monitoring()
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
methods: {
|
2022-04-08 15:05:10 +08:00
|
|
|
monitoring () {
|
|
|
|
|
this.$on('getData', (res) => {
|
|
|
|
|
console.log('getdata')
|
|
|
|
|
this.getTableData()
|
2022-04-08 16:07:06 +08:00
|
|
|
this.$forceUpdate();
|
|
|
|
|
// window.location.reload()
|
2022-04-08 15:05:10 +08:00
|
|
|
})
|
2022-04-08 14:09:56 +08:00
|
|
|
},
|
2022-04-08 15:05:10 +08:00
|
|
|
async getTableData () {
|
|
|
|
|
await get('/sys/backup').then((res) => {
|
2022-04-08 14:09:56 +08:00
|
|
|
if (res.code === 200) {
|
|
|
|
|
if (res.data) {
|
2022-04-08 15:05:10 +08:00
|
|
|
this.tableData[0].retention = res.data.retention
|
|
|
|
|
this.tableData[0].state = res.data.state
|
|
|
|
|
this.switchStatus = res.data.state === 1
|
|
|
|
|
for (const i in res.data.schedule) {
|
|
|
|
|
this.tableData[0].schedule[i] = res.data.schedule[i]
|
2022-04-08 14:09:56 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-04-08 15:05:10 +08:00
|
|
|
})
|
|
|
|
|
await post('/sys/backup/list').then((res) => {
|
2022-04-08 14:09:56 +08:00
|
|
|
if (res.code === 200) {
|
|
|
|
|
if (res.data) {
|
2022-04-08 15:05:10 +08:00
|
|
|
for (const i in res.data) {
|
|
|
|
|
this.tableData2[i].fileName = res.data[i].fileName
|
|
|
|
|
this.tableData2[i].size = bus.getNumStr(res.data[i].size)
|
|
|
|
|
this.tableData2[i].time = res.data[i].time
|
2022-04-08 14:09:56 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-04-08 15:05:10 +08:00
|
|
|
})
|
2022-04-08 14:09:56 +08:00
|
|
|
},
|
2022-04-08 15:05:10 +08:00
|
|
|
backupNow (item) {
|
|
|
|
|
post('/sys/backup').then((res) => {
|
|
|
|
|
console.log(res)
|
|
|
|
|
})
|
2022-04-08 14:09:56 +08:00
|
|
|
},
|
2022-04-08 15:05:10 +08:00
|
|
|
tableOperation (command) {
|
2022-04-08 14:09:56 +08:00
|
|
|
if (command) {
|
2022-04-08 15:05:10 +08:00
|
|
|
if (command === 'edit') {
|
|
|
|
|
this.$emit('edit', this.tableData[0])
|
|
|
|
|
} else if (command === 'del') {
|
2022-04-08 14:09:56 +08:00
|
|
|
}
|
|
|
|
|
}
|
2022-04-08 15:05:10 +08:00
|
|
|
}
|
2022-04-08 14:09:56 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
|
isState: {
|
|
|
|
|
deep: true,
|
2022-04-08 15:05:10 +08:00
|
|
|
handler (n) {
|
|
|
|
|
this.switchStatus = n
|
|
|
|
|
this.tableData[0].state = n === true ? 1 : 0
|
|
|
|
|
}
|
2022-04-08 14:09:56 +08:00
|
|
|
},
|
2022-04-08 15:05:10 +08:00
|
|
|
switchStatus: {
|
|
|
|
|
deep: true,
|
|
|
|
|
handler (n) {
|
|
|
|
|
this.tableData[0].state = n === true ? 1 : 0
|
|
|
|
|
}
|
2022-04-08 14:09:56 +08:00
|
|
|
}
|
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>
|