heyujie
2022-02-09 211cd7469ebc7df813ffd320c90f64fd1c2f1aee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
<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 class="useable">磁盘可用: {{ percent }}%</span>
          </div>
       </div>
 
    <el-button type="primary" @click="deleteData">数据清理</el-button>
    </div>
 
 
    <div class="clear-list">
      <span class="t">请选择要清理的数据范围</span>
      <el-date-picker popper-class="clean-time-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 {
  created(){
  const end = new Date();
  const start = new Date();
  start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  var year=end.getFullYear();
  var month=end.getMonth()+1;
  var day=end.getDate();
  month=month<10?"0"+month:month;
  day=day<10?"0"+day:day;
  const endTime = year+"-"+month+"-"+day
 
  var year2=start.getFullYear();
  var month2=start.getMonth()+1;
  var day2=start.getDate();
  month2=month2<10?"0"+month2:month2;
  day2=day2<10?"0"+day2:day2;
  const startTime = year2+"-"+month2+"-"+day2
  this.dataRange = [startTime,endTime]
  },
  data() {
    return {
      pickerOptions: {
        disabledDate(time) {
          var day = new Date();
          day.setTime(day.getTime() - 24 * 60 * 60 * 1000);
          return time.getTime() > day;
        },
         shortcuts: [{
            text: '最近一周',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近一个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近三个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit('pick', [start, end]);
            }
          }]
      },
      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
      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" }, '\ue71c'),
            h("span", { class: "warn-title" }, "提示 "),
            h("span", { class: "warn-dec" }, `${showStartTime} 至 ${showEndTime} 产生的全部数据将被删除,此操作立即生效,不可恢复,是否删除?`),
          ]
        ),
        showCancelButton: true,
        confirmButtonText: "确定",
        cancelButtonText: "取消",
      })
 
        .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 {
  position: relative;
  padding: 10px;
  border-top: 4px solid #f2f2f7;
  border-left: 4px solid #f2f2f7;
 
  .clear-list {
  background: #F2F2F7;
  border-radius: 8px;
  height: 114px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 45px;
  color: #333333;
  font-weight: bold;
  font-size: 16px;
  
  &: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: -77%;
        background-image: url(/images/vindicate/内存.png);
        width: 38px;
        height: 35px;
        background-size:cover;
        display: inline-block;
        margin: auto;
        content: '';
      }
    }
    svg {
      width: 70px;
      height: 70px;
    }
    .el-progress__text {
      display: none !important;
    }
    }
 
    .cap-text {
      color: #333333;
      font-weight: bold;
      font-size: 16px;
      .useable {
      margin-left:20px ;
      }
    }
     }
   .el-button.el-button--primary {
      width: 150px !important;
      height: 30px !important;
      line-height: 7px !important;
      font-size: 14px !important;
      color: #fff !important;
      background: var(--colorCard) !important;
      border-radius: 25px !important;
      border: none !important;
    }
    
    .el-date-editor.el-range-editor {
      height: 48px;
      width: 361px !important;
      border-radius: 8px;
      .el-input__icon.el-range__icon.el-icon-date {
      margin:0 15px ;
      &::before {
      line-height: 40px;
      font-size: 20px;
      color: #333;
      }
      }
      .el-range-separator{
        line-height: 41px;
      }
      input {
        width: 127px;
        height: 32px;
        font-size: 12px;
        background: #F2F2F7;
        border-radius: 20px;
      }
    }
   
  .t {
    height: 22px;
    width: 242px;
  }
}
 
.warm {
  position: absolute;
  bottom: 60px;
  left: 50%;
  width: 420px;
  transform:translateX(-50%) ;
  .icontishi-zhuyi {
    margin-right:10px ;
    color: red;
  }
}
}
 
 
</style>
 
<style scoped lang="scss">
.warn-icon {
    color: var(--colorCard);
    font-size: 40px;
    margin-top: 11px;
  }
  .warn-title {
    font-weight: bold;
    font-size: 16px;
    margin: 6px;
    line-height: 22px;
  }
  .warn-dec {
    font-weight: bold;
    font-size: 14px;
    color: #828282;
    line-height: 20px;
  }
   .el-message-box__headerbtn {
    top: 12px;
  }
  .el-message-box__headerbtn .el-message-box__close {
    color: #333333;
    font-weight: bold;
  }
  .el-message-box__btns {
    display: flex;
    justify-content: center;
  margin: 20px;
    .el-button:focus,
    .el-button:hover {
      background-color: none;
      border: none;
    }
    button {
      width: 175px;
      height: 40px;
      border-radius: 25px;
      span {
        font-size: 16px;
        font-weight: 700;
      }
      &:hover {
        border: 1px solid var(--colorCard) !important;
      }
    }
    button:first-child {
      background-color: #e0e0e0;
      span {
        color: #333333;
      }
    }
    button:last-child {
      background-color: var(--colorCard) !important;
      border: 1px solid var(--colorCard) !important;
      span { 
         color: #fff;
      }
    }
   } 
</style>
 
<style lang="scss">
.clean-time-picker {
    top: 208px !important;
    left: 343px !important;
    width: 624px !important;
 
    .el-picker-panel__sidebar {
      background: #EEF5FF;
      button {
        margin: 10px 0;
      }
    }
 
    tbody {
        tr:first-child {
          background: #EEF5FF;
        }
      }
   }
</style>