<template>
|
<div class="clear" v-loading="loading" :element-loading-text="loadingText">
|
<div class="clear-list">
|
<div class="cap">
|
<div class="cap-bar">
|
<!-- <div class="inner-bar" :style="`width: ${100-percent}%;`"></div> -->
|
<el-progress v-if="percent>25" type="circle" :percentage="100-percent" stroke-width="10"></el-progress>
|
<el-progress v-if="percent<=25&&percent>0" type="circle" :percentage="100-percent" status="warning" stroke-width="10"></el-progress>
|
<el-progress v-if="percent == 0" type="circle" :percentage="100-percent" status="exception" stroke-width="10"></el-progress>
|
</div>
|
<div class="cap-text">
|
<span>磁盘可用: {{ percent }}%</span>
|
</div>
|
</div>
|
|
<el-button type="primary" @click="deleteData">数据清理</el-button>
|
</div>
|
|
|
<div class="clear-list">
|
<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="warm">
|
<i class="iconfont icontishi-zhuyi"></i>
|
<span class="text">请注意,按以上日期范围删除的数据不可恢复,立即生效,请谨慎操作!</span>
|
</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%;
|
background-color: #FBFAFF;
|
}
|
.container {
|
background-color: #FBFAFF;
|
}
|
|
.clear {
|
padding: 10px;
|
border-top:2px solid #E1E0E6 ;
|
border-left:2px solid #E1E0E6 ;
|
|
.clear-list {
|
background: #F2F2F7;
|
border-radius: 8px;
|
height: 114px;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
padding: 0 45px;
|
|
&:first-child {
|
border-bottom: 1px solid #E1E0E6;
|
}
|
|
.cap {
|
display: flex;
|
align-items: center;
|
|
.cap-bar {
|
width: 70px;
|
height: 70px;
|
div {
|
width: 100%;
|
height: 100%;
|
.el-progress-circle {
|
width: 100% !important;
|
height: 100% !important;
|
}
|
&::after {
|
position: relative;
|
top: -68%;
|
content: '\e6e8';
|
width: 25px;
|
height: 25px;
|
display: inline-block;
|
margin: auto;
|
font-family: "iconfont" !important;
|
font-size: 25px;
|
font-style: normal;
|
-webkit-font-smoothing: antialiased;
|
-moz-osx-font-smoothing: grayscale;
|
|
}
|
}
|
svg {
|
width: 70px;
|
height: 70px;
|
}
|
.el-progress__text {
|
display: none !important;
|
}
|
}
|
}
|
|
}
|
}
|
|
|
</style>
|