فهرست منبع

feat: 初始化巡检

zhangwenya 9 ماه پیش
والد
کامیت
5c3844d6aa
1فایلهای تغییر یافته به همراه31 افزوده شده و 1 حذف شده
  1. 31 1
      src/views/hl/check/index.vue

+ 31 - 1
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/>已检测指标</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 },
@@ -103,6 +104,9 @@ const colors = [
 ]
 
 onMounted(async ()=>{
+  if(localStorage.getItem("listData")){
+    return restoreCache()
+  }
   const res = await getCheckList();
   checkList.value = res.data
   listData.value = res.data[0].classList
@@ -136,6 +140,7 @@ function getRandomInt(min, max) {
 
 function handleNowCheck(sub){
   if(!cLoading.value){
+    removeCache()
     cLoading.value = true
     cIndex.value = null;
     checkTime.value = new Date()
@@ -143,10 +148,12 @@ function handleNowCheck(sub){
   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 +164,29 @@ 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")
+}
+
+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";