Browse Source

修改页面切换 滚动条滚动到最顶部

plg 6 months ago
parent
commit
e8ff15a411
2 changed files with 26 additions and 1 deletions
  1. 10 0
      src/router/index.ts
  2. 16 1
      src/views/Plan.vue

+ 10 - 0
src/router/index.ts

@@ -124,5 +124,15 @@ const router = createRouter({
   history: createWebHistory(import.meta.env.BASE_URL),
   routes
 })
+//页面滚动到最顶部
+router.beforeEach((to, from, next) => {
+  window.scrollTo(0, 0);
+  /** meta是定义路由时路由的属性 */
+  if (to.meta.title) {
+    (document as any).title = to.meta.title;
+  }
+  next();
+});
+
 
 export default router

+ 16 - 1
src/views/Plan.vue

@@ -192,8 +192,21 @@ const planNumGet = async () => {
                     //如果完成状态为1,则判断后边的到底有没有必做不显示但是其中有未完成的
                     //如果完成状态为1,则判断后边的到底有没有必做不显示但是其中有未完成的
                 }
+                //判断是显示开始测试还是继续测试
+                let isContinue = []
+                isContinue = planList.value[i].list.filter((item: any) => {
+                    return item.isCompleted != '0'
+                })
+                if (isContinue.length == 0) {
+                    planList.value[i].isCompleted = '0'
+                } else {
+                    planList.value[i].isCompleted = '2'
+                }
             }
         }
+        //判断是开始测试还好继续测试
+        console.log("planList.value")
+        console.log(planList.value)
         //数据格式改变抽出需要展示的量表、、放入数组
         //抽出需要展示的认知任务--放入数组
 
@@ -308,7 +321,9 @@ onUnmounted(() => {
                             <div></div>
                         </div>
                         <div class="start_button_out">
-                            <div class="start_button_self" @click="startPlan(item)">开始测试</div>
+                            <div class="start_button_self" @click="startPlan(item)"><span
+                                    v-if="item.isCompleted == '0'">开始测试</span><span
+                                    v-if="item.isCompleted == '2'">继续测试</span></div>
                         </div>
                     </div>
                     <!-- 测试记录列表 -->