<template>
|
<div class="clear" v-loading="loading" :element-loading-text="loadingText">
|
<div class="head">
|
<span class="t">请选择要清理的数据范围</span>
|
<el-date-picker
|
style="width: 100%"
|
v-model="dataRange"
|
value-format="yyyy-MM-dd"
|
type="daterange"
|
align="right"
|
size="small"
|
range-separator="至"
|
start-placeholder="开始日期"
|
end-placeholder="结束日期"
|
:picker-options="pickerOptions"
|
></el-date-picker>
|
</div>
|
|
<div class="desc">
|
<div class="disk-img">
|
<span class="icon iconfont">{{"\ue8b1"}}</span>
|
|
</div>
|
<div class="cap">
|
<div class="cap-text">
|
<span>磁盘可用: {{ percent }}%</span>
|
</div>
|
<div class="cap-bar">
|
<div class="inner-bar" :style="`width: ${100-percent}%;`"></div>
|
</div>
|
</div>
|
|
<el-button type="primary" @click="deleteData">数据清理</el-button>
|
|
<div class="warm">
|
<i class="iconfont icontishi-zhuyi"></i>
|
<span class="text">请注意,按以上日期范围删除的数据不可恢复,立即生效,请谨慎操作!</span>
|
</div>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import { deleteData } from "@/api/system";
|
export default {
|
data() {
|
return {
|
pickerOptions: {
|
disabledDate(time) {
|
var day = new Date();
|
day.setTime(day.getTime() - 24 * 60 * 60 * 1000);
|
return time.getTime() > day;
|
},
|
},
|
loading: false,
|
loadingText: '',
|
dataRange: []
|
};
|
},
|
props:["free","full"],
|
computed: {
|
percent(){
|
return Math.round(this.free/this.full *100)
|
}
|
},
|
methods: {
|
deleteData() {
|
if (this.dataRange.length==0) {
|
this.$message.warning("请先选择日期")
|
return
|
}
|
const [showStartTime, showEndTime] = this.dataRange
|
this.$confirm(`${showStartTime} 至 ${showEndTime} 产生的全部数据将被删除,此操作立即生效,不可恢复,是否删除?`, "提示",{
|
type:"warning",
|
cancelButtonClass: "comfirm-class-cancle",
|
confirmButtonClass: "comfirm-class-sure",
|
}
|
)
|
.then(() => {
|
this.loading = true
|
this.loadingText = "正在删除数据,请稍候!"
|
deleteData({
|
startTime: showStartTime,
|
endTime: showEndTime,
|
})
|
.then((resp) => {
|
if (resp.success) {
|
this.loading = false
|
this.$message.success(`清理成功,已清理 ${resp.data} 条数据`);
|
this.$emit("refreshPercent")
|
}
|
})
|
.catch((err) => {
|
this.$message.error("删除失败,"+err.msg);
|
this.loading = false
|
});
|
})
|
.catch(() => { });
|
},
|
},
|
};
|
</script>
|
<style lang="scss">
|
.all {
|
width: 100%;
|
}
|
.clear {
|
margin: 0 auto;
|
padding: 20px;
|
.head {
|
height: 50px;
|
background-color: rgba(248, 248, 248, 1);
|
border-radius: 10px;
|
display: flex;
|
align-items: center;
|
justify-content: space-around;
|
box-sizing: border-box;
|
padding: 0 20px;
|
width: 560px;
|
margin: 0 auto;
|
.t {
|
font-size: 14px;
|
min-width: 175px;
|
text-align: left;
|
}
|
|
.el-range-editor--small.el-input__inner {
|
border: none;
|
}
|
.el-range-editor--small .el-range-separator {
|
line-height: 26px;
|
}
|
}
|
.desc {
|
margin-top: 50px;
|
.disk-img {
|
height: 100px;
|
width: 100px;
|
margin: 0 auto;
|
margin-bottom: 10px;
|
// background-color: aquamarine;
|
.iconfont{
|
font-size: 82px;
|
color: #3a8120;
|
}
|
}
|
.cap {
|
height: 50px;
|
margin: 0 auto;
|
width: 160px;
|
margin-bottom: 20px;
|
.cap-bar {
|
height: 10px;
|
background: rgb(239, 240, 236);
|
//
|
margin: 0 auto;
|
border-radius: 2px;
|
|
.inner-bar {
|
background: #3a8120;
|
height: 100%;
|
border-radius: 2px;
|
}
|
}
|
.cap-text {
|
text-align: right;
|
height: 25px;
|
text-align: right;
|
line-height: 25px;
|
font-size: 12px;
|
}
|
}
|
.el-button--primary {
|
width: 200px;
|
font-size: 15px;
|
}
|
.warm {
|
line-height: 30px;
|
height: 30px;
|
margin-top: 10px;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
.iconfont {
|
font-size: 16px;
|
|
color: #e99038;
|
margin-right: 5px;
|
}
|
.text {
|
color: rgb(175, 175, 175);
|
font-size: 14px;
|
}
|
}
|
}
|
}
|
</style>
|