<template>
|
<div class="all">
|
<div class="backup-content">
|
<div class="backup-center" ref="left">
|
<div
|
class="menu-item"
|
@click="openRight(i)"
|
v-for="(item, i) in tabList"
|
:class="activePage == i ? 'menu-item-active' : ''"
|
:key="i"
|
>
|
<div class="con">
|
<span class="icon iconfont">{{ item.icon }}</span>
|
<span class="menu-text">{{ item.name }}</span>
|
</div>
|
</div>
|
</div>
|
<div class="backup-right">
|
<div class="auto" v-if="activePage == 0">
|
<div class="bar">
|
<div class="name">自动备份</div>
|
<el-switch
|
v-model="isBackUp"
|
active-color="rgba(61, 104, 225, 1)"
|
@change="switchChange"
|
>
|
</el-switch>
|
</div>
|
<div class="bar">
|
<div class="name">备份目录</div>
|
<el-input
|
v-model="dir"
|
:placeholder="'请输入备份目录'"
|
size="small"
|
></el-input>
|
</div>
|
<div class="bar">
|
<div class="name">备份间隔 / 天</div>
|
<el-input
|
v-model.number="interval"
|
:placeholder="'请输入天数'"
|
size="small"
|
></el-input>
|
<!-- :controls="false" -->
|
</div>
|
<div class="bar">
|
<div class="name">备份数据保存时间 / 天</div>
|
<el-input
|
v-model.number="lifeSpan"
|
placeholder="请输入天数"
|
size="small"
|
></el-input>
|
</div>
|
<div class="bar">
|
<div class="name">立即备份</div>
|
<el-button type="primary" size="small" @click="backUpNow"
|
>立即备份</el-button
|
>
|
</div>
|
|
<el-button class="save-btn" type="primary" @click="saveBakConfig"
|
>保存</el-button
|
>
|
</div>
|
<div class="recover" v-if="activePage == 1">
|
<div class="title">显示备份的文件范围:{{ 5 }}</div>
|
|
<div class="table-body">
|
<div class="table-head">
|
<span class="line1">自动备份时间</span>
|
<span class="line1">备份文件名称</span>
|
<span class="line2">恢复备份</span>
|
</div>
|
|
<div class="bar" v-for="(item, i) in fileList" :key="i">
|
<span class="time">{{ item }}</span>
|
<span class="time">{{ item }}</span>
|
<span class="operation iconfont" @click="recoverFile(item)"
|
>
|
</span>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import {
|
getBakConfig,
|
setBakConfig,
|
backupRN,
|
getBackupList,
|
recoverBackup,
|
} from "@/api/system";
|
export default {
|
created() {
|
this.getBakConfig();
|
this.getBakFileList();
|
},
|
data() {
|
return {
|
tabList: [
|
{ name: "自动备份设置", icon: "\ue6f2" },
|
{ name: "从备份中恢复", icon: "\ue6db" },
|
],
|
warnSpn: "\ue71c",
|
fileList: [],
|
activePage: 0,
|
interval: null,
|
lifeSpan: null,
|
dir: "",
|
isBackUp: false,
|
};
|
},
|
methods: {
|
getBakFileList() {
|
getBackupList().then((res) => {
|
this.fileList = res.data;
|
});
|
},
|
getBakConfig() {
|
getBakConfig().then((res) => {
|
this.isBackUp = res.data.enable;
|
this.lifeSpan = res.data.saveDays;
|
this.interval = res.data.period;
|
this.dir = res.data.dir;
|
});
|
},
|
openRight(i) {
|
this.activePage = i;
|
},
|
handleChange() {},
|
backUpNow() {
|
const h = this.$createElement;
|
const icon = this.$msgbox({
|
title: "",
|
message: h(
|
"div",
|
{
|
style:
|
"display: flex; flex-direction: column; justify-content: center; align-items: center;",
|
},
|
[
|
h("span", { class: "icon iconfont warn-icon" }, `${this.warnSpn}`),
|
h("span", { class: "warn-title" }, "立即备份"),
|
h(
|
"span",
|
{ class: "warn-dec" },
|
"确认立即备份所有应用的配置数据?"
|
),
|
]
|
),
|
showCancelButton: true,
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
}).then(() => {
|
backupRN({
|
enable: this.isBackUp,
|
dir: this.dir,
|
period: this.interval,
|
saveDays: this.lifeSpan,
|
})
|
.then((res) => {
|
if (res.code == 200) {
|
this.$notify.success(res.msg);
|
} else {
|
this.$notify.error(res.msg);
|
}
|
})
|
.catch((err) => {
|
this.$notify.error(err.msg);
|
});
|
});
|
},
|
recoverFile(bakDir) {
|
recoverBackup({ bakDir }).then((res) => {
|
debugger;
|
res.data;
|
});
|
},
|
saveBakConfig() {
|
setBakConfig({
|
enable: this.isBackUp,
|
dir: this.dir,
|
period: this.interval,
|
saveDays: this.lifeSpan,
|
})
|
.then((res) => {
|
if (res.code == 200) {
|
this.$notify.success(res.msg);
|
this.getBakConfig();
|
} else {
|
this.$notify.error(res.msg);
|
}
|
})
|
.catch((err) => {
|
this.$notify.error(err.msg);
|
});
|
},
|
switchChange(val) {
|
this.saveBakConfig();
|
},
|
},
|
};
|
</script>
|
<style lang="scss">
|
.all {
|
width: 100%;
|
background-color: #fbfaff;
|
}
|
.backup-content {
|
height: 100%;
|
display: flex;
|
flex-direction: row;
|
flex: 1;
|
flex-basis: auto;
|
box-sizing: border-box;
|
border-top: 4px solid rgb(242, 242, 247);
|
border-left: 4px solid rgb(242, 242, 247);
|
|
.backup-center {
|
height: 100%;
|
width: 300px;
|
overflow: auto;
|
box-sizing: border-box;
|
flex-shrink: 0;
|
padding: 9px 10px 0 10px;
|
border-right: 4px solid rgb(242, 242, 247);
|
.menu-item {
|
background-color: #f8f8f8;
|
height: 56px;
|
margin-bottom: 4px;
|
border-radius: 8px;
|
line-height: 56px;
|
box-sizing: border-box;
|
font-size: 14px;
|
cursor: pointer;
|
padding: 0 15px;
|
display: flex;
|
justify-content: space-between;
|
.con {
|
.iconfont {
|
font-size: 20px;
|
line-height: 32px;
|
width: 32px;
|
height: 26px;
|
margin-right: 10px;
|
color: #333;
|
}
|
.menu-text {
|
font-size: 16px;
|
font-weight: 700;
|
}
|
}
|
}
|
.menu-item-active {
|
background-color: var(--colorCard) !important;
|
.iconfont {
|
color: #fff !important;
|
}
|
.menu-text {
|
color: #fff;
|
}
|
}
|
.menu-item:hover {
|
background-color: #f2f2f7;
|
}
|
}
|
.backup-right {
|
flex: 1;
|
flex-basis: auto;
|
padding: 10px;
|
overflow: auto;
|
box-sizing: border-box;
|
position: relative;
|
.el-form-item.is-required:not(.is-no-asterisk)
|
> .el-form-item__label:before,
|
.el-form-item.is-required:not(.is-no-asterisk)
|
.el-form-item__label-wrap
|
> .el-form-item__label:before {
|
display: none;
|
}
|
.el-select {
|
width: 100%;
|
}
|
.el-form-item {
|
margin-bottom: 10px;
|
height: 50px;
|
background: #f8f8f8;
|
padding: 4px 20px;
|
-webkit-box-sizing: border-box;
|
box-sizing: border-box;
|
border-radius: 10px;
|
.el-form-item__label {
|
text-align: left;
|
line-height: 42px;
|
}
|
}
|
.el-form-item__content {
|
line-height: 40px;
|
position: relative;
|
font-size: 14px;
|
}
|
.ip-input-container {
|
max-width: none !important;
|
}
|
.auto {
|
.bar {
|
display: flex;
|
align-items: center;
|
padding: 0 25px;
|
justify-content: space-between;
|
margin-bottom: 10px;
|
border-radius: 8px;
|
margin-bottom: 10px;
|
height: 48px;
|
background-color: #f2f2f7;
|
.el-button--small,
|
.el-button--small.is-round {
|
padding: 9px 19px;
|
background: var(--colorCard) !important;
|
border-radius: 25px;
|
border-color: var(--colorCard) !important;
|
}
|
.name {
|
font-size: 14px;
|
text-align: left;
|
font-weight: 600;
|
min-width: 170px;
|
}
|
.el-input {
|
width: 100%;
|
.el-input {
|
height: auto;
|
}
|
.el-input__inner {
|
border: none;
|
border-radius: 8px;
|
text-align: left;
|
background: #fbfaff;
|
border-radius: 20px;
|
}
|
}
|
}
|
}
|
.recover {
|
.title {
|
font-size: 14px;
|
color: #333333;
|
text-align: left;
|
margin-bottom: 10px;
|
line-height: 18px;
|
font-weight: bold;
|
}
|
.table-body {
|
box-sizing: border-box;
|
padding: 10px 20px;
|
padding-bottom: 5px;
|
background: #f2f2f7;
|
border-radius: 8px;
|
.table-head {
|
height: 30px;
|
line-height: 30px;
|
display: flex;
|
box-sizing: border-box;
|
font-size: 15px;
|
padding: 0 10px;
|
margin-bottom: 5px;
|
font-size: 14px;
|
color: #666666;
|
.line1 {
|
flex: 3;
|
text-align: left;
|
}
|
.line2 {
|
flex: 1;
|
text-align: left;
|
min-width: 60px;
|
}
|
}
|
.bar {
|
height: 32px;
|
background-color: #ffffff;
|
display: flex;
|
box-sizing: border-box;
|
padding: 0 10px;
|
align-items: center;
|
border-radius: 20px;
|
color: #333333;
|
font-size: 12px;
|
margin-bottom: 8px;
|
font-weight: bold;
|
.time {
|
width: 42.857%;
|
text-align: left;
|
}
|
.operation {
|
color: var(--colorCard);
|
cursor: pointer;
|
width: 14.2857%;
|
min-width: 60px;
|
text-align: left;
|
font-size: 20px;
|
}
|
}
|
}
|
}
|
.save-btn {
|
width: 251px;
|
height: 40px;
|
margin-top: 100px;
|
background: var(--colorCard) !important;
|
border: 1px solid var(--colorCard) !important;
|
border-radius: 25px;
|
}
|
}
|
}
|
</style>
|