林旭祥 hace 7 meses
padre
commit
6020ecee18
Se han modificado 2 ficheros con 104 adiciones y 20 borrados
  1. 21 0
      src/api/module/test.ts
  2. 83 20
      src/views/test/index.vue

+ 21 - 0
src/api/module/test.ts

@@ -0,0 +1,21 @@
+import req from '../request';
+
+export default {
+  //获取测试列表
+  getTaskList: (data: any) => {
+    return req({
+      url: '/task/common_list',
+      method: 'get',
+      data: data
+    });
+  },
+
+  //获取测试项目
+  getTaskProject: (data: any) => {
+    return req({
+      url: '/exam/ccconfig_grade_view',
+      method: 'get',
+      data: data
+    });
+  }
+};

+ 83 - 20
src/views/test/index.vue

@@ -8,26 +8,13 @@
           <el-input class="myInput" :prefix-icon="Search" v-model="keywords" placeholder="搜索" clearable />
         </div>
         <ul>
-          <li>初一春季体育测试</li>
-          <li>初一春季体育测试</li>
-          <li>初一春季体育测试</li>
-          <li>初一春季体育测试</li>
-          <li>初一春季体育测试</li>
-          <li>初一春季体育测试</li>
-          <li>初一春季体育测试</li>
-          <li>初一春季体育测试</li>
-          <li>初一春季体育测试</li>
-          <li>初一春季体育测试</li>
-          <li>初一春季体育测试</li>
-          <li>初一春季体育测试</li>
-          <li>初一春季体育测试</li>
-          <li>初一春季体育测试</li>
-          <li>初一春季体育测试</li>
-          <li>初一春季体育测试</li>
-          <li>初一春季体育测试</li>
+          <li v-for="(item, index) in newTaskList" :key="index" :class="{ 'current': currentTask.id == item.id }"
+            @click="clickTask(item)">{{ item.name
+            }}</li>
         </ul>
       </div>
-      <div class="menu" v-if="projectList.length" :class="projectList.length <= 10 ? 'menu1' : 'menu2'">
+      <div class="menu" v-if="projectList.length"
+        :class="{ 'menu1': projectList.length <= 10, 'menu2': projectList.length > 10, 'prohibit': !currentTask.id }">
         <swiper :slides-per-view="5" :modules="[Grid]" :grid="{
           fill: projectList.length <= 10 ? 'row' : 'column',
           rows: 2,
@@ -52,8 +39,13 @@
 import { Swiper, SwiperSlide } from 'swiper/vue';
 import { Grid } from 'swiper/modules';
 import { Search } from '@element-plus/icons-vue'
+import 'dayjs/locale/zh-cn'
+import dayjs from 'dayjs'
+import weekOfYear from 'dayjs/plugin/weekOfYear'
 import 'swiper/css';
 import 'swiper/css/grid';
+dayjs.locale('zh-cn')
+dayjs.extend(weekOfYear)
 
 const router = useRouter();
 const { proxy } = getCurrentInstance() as any;
@@ -63,17 +55,65 @@ const data = reactive<any>({
   projectList: [],
   timerManager: {},
   keywords: '',
+  taskList: [],
+  currentTask: {},
+  myProject: [],
 });
-const { projectList, timerManager, keywords } = toRefs(data);
+const { projectList, timerManager, keywords, taskList, currentTask, myProject } = toRefs(data);
+
+/**
+ * 点击课程
+*/
+const clickTask = (data: any) => {
+  currentTask.value = data
+  getProjectTaskList()
+};
+
+/**
+ * 获取测试项目
+*/
+const getProjectTaskList = () => {
+  let params = {
+    exam_type: currentTask.value.exam_type,
+    grade: currentTask.value.grade
+  };
+  proxy?.$http.test.getTaskProject(params).then((res: any) => {
+    myProject.value = res.data;
+    getExam();
+  });
+};
+
+/**
+ * 获取测试列表
+*/
+const getTaskList = () => {
+  let today = dayjs().format('YYYY-MM-DD')
+  let params = {
+    start_time: today
+  };
+  proxy?.$http.test.getTaskList(params).then((res: any) => {
+    taskList.value = res.data;
+  });
+};
 
 /**
  * 获取项目
 */
 const getExam = () => {
+  let examList: any = []
+  myProject.value.forEach((item: any) => {
+    item.exams.forEach((items: any) => {
+      examList.push(items[0]);
+    })
+  })
   proxy?.$http.train.projectList().then((res: any) => {
     projectList.value = proxy?.$utils.getProject(res.exams).filter((item: any) => {
       //只显示能开的
-      return item.area.length > 0;
+      if (currentTask.value.id) {
+        return item.area.length > 0 && examList.includes(item.key);
+      } else {
+        return item.area.length
+      }
     });
   });
 };
@@ -82,6 +122,10 @@ const getExam = () => {
  * 弹出选项窗口
 */
 const getOption = (data: any) => {
+  if (!currentTask.value.id) {
+    proxy?.$modal.msgWarning(`请先选择左侧测试!`);
+    return false;
+  }
   optionWindowRef.value.open(data);
 };
 
@@ -115,7 +159,18 @@ const getExit = () => {
   router.go(-1);
 };
 
+/**
+ * 新的测试列表
+*/
+const newTaskList: any = computed(() => {
+  let list = taskList.value.filter((item: any) => {
+    return item.name.indexOf(keywords.value) != -1
+  })
+  return list;
+});
+
 onBeforeMount(() => {
+  getTaskList();
   getInitExam();
 })
 
@@ -193,6 +248,10 @@ $waiPadding: 6.51rem;
       }
     }
 
+    .current {
+      background: rgba(255, 255, 255, 0.2);
+    }
+
     &::-webkit-scrollbar {
       width: 0px;
     }
@@ -359,6 +418,10 @@ $waiPadding: 6.51rem;
   }
 }
 
+.prohibit {
+  opacity: 0.5;
+}
+
 ::v-deep(.menu) {
   .swiper-horizontal {
     width: 100%;