فهرست منبع

Merge remote-tracking branch 'origin/master'

wukai 9 ماه پیش
والد
کامیت
d3b3b48422
1فایلهای تغییر یافته به همراه45 افزوده شده و 6 حذف شده
  1. 45 6
      src/views/hl/check/index.vue

+ 45 - 6
src/views/hl/check/index.vue

@@ -44,7 +44,7 @@
         </div>
         <div class="sub-col">
           <el-icon :size="46" color="#409EFF"><Compass /></el-icon>
-          <div class="s-c-text">{{cIndex!=null?Math.ceil((314/checkList.length)*(cIndex+1)):0}}/314<br/>已检测指标{{cIndex}}</div>
+          <div class="s-c-text">{{cIndex!=null?Math.ceil((totalErrorCount/checkList.length)*(cIndex+1)):0}}/{{totalErrorCount}}<br/>已检测指标</div>
         </div>
         <div class="sub-col">
           <el-icon :size="46" color="#409EFF"><Warning /></el-icon>
@@ -93,6 +93,7 @@ const cIndex=ref(null)
 const listData = ref([])
 const checkTime = ref(null)
 const totalError=ref(0)
+const totalErrorCount = ref(0)
 
 const colors = [
   { color: '#bbdefb', percentage: 20 },
@@ -102,12 +103,18 @@ const colors = [
   { color: '#1e88e5', percentage: 100 },
 ]
 
-onMounted(async ()=>{
+onMounted( ()=>{
+  if(localStorage.getItem("listData")){
+    return restoreCache()
+  }
+  getListData()
+})
+
+async function getListData(){
   const res = await getCheckList();
   checkList.value = res.data
   listData.value = res.data[0].classList
-})
-
+}
 
 function convertTime(milliseconds) {
   // 将毫秒转换为秒
@@ -136,17 +143,25 @@ function getRandomInt(min, max) {
 
 function handleNowCheck(sub){
   if(!cLoading.value){
-    cLoading.value = true
+    if(localStorage.getItem("listData")){
+      removeCache()
+      getListData()
+    }
+    cLoading.value = true;
     cIndex.value = null;
-    checkTime.value = new Date()
+    totalError.value = 0;
+    totalErrorCount.value=0;
+    checkTime.value = new Date();
   }
   let index = checkList.value.length-sub
   currentProgress.value = Number(Number(index / checkList.value.length * 100).toFixed(2))
   if(index > checkList.value.length-1) {
+    saveCache()
     return cLoading.value = false
   }
   setTimeout(async ()=>{
     const res = await getCheckModel(checkList.value[index].modelId)
+    totalErrorCount.value= 413
     console.log(res)
     listData.value[index].checkProess = 'done'
     let e = Math.ceil(Math.random()*100)
@@ -157,6 +172,30 @@ function handleNowCheck(sub){
   }, getRandomInt(500, 500))
 }
 
+function saveCache(){
+  localStorage.setItem("listData", JSON.stringify(listData.value))
+  localStorage.setItem("errorInfo",JSON.stringify({totalErrorCount:totalErrorCount.value,totalError:totalError.value,checkTime:checkTime.value}))
+  localStorage.setItem("checkList",JSON.stringify(checkList.value))
+}
+
+function removeCache(){
+  localStorage.removeItem("listData")
+  localStorage.removeItem("errorInfo")
+  localStorage.removeItem("checkList")
+}
+
+function restoreCache(){
+  listData.value = JSON.parse(localStorage.getItem("listData"))
+  checkList.value = JSON.parse(localStorage.getItem("checkList"))
+  const errorInfo = JSON.parse(localStorage.getItem("errorInfo"))
+  cIndex.value = checkList.value.length-1
+  totalErrorCount.value = errorInfo.totalErrorCount
+  totalError.value = errorInfo.totalError
+  checkTime.value = errorInfo.checkTime
+  currentProgress.value = 100
+}
+
+
 </script>
 <style scoped lang="scss">
 @import "./css/style.scss";