Jelajahi Sumber

build: :bug: 训练报告体验用户调整

chaooo 2 tahun lalu
induk
melakukan
358f31be2e

+ 2 - 2
src/api/training/index.ts

@@ -18,10 +18,10 @@ export function getTrainingLists(params: TrainingParams): AxiosPromise<TrainingM
  * 训练报告
  * /board/v1/detail?game_record_id=82967
  */
-export function getTrainingResult(id: number): AxiosPromise<TrainingResult> {
+export function getTrainingResult(id: string, isFormal: string): AxiosPromise<TrainingResult> {
   return request({
     url: "/board/v1/detail",
     method: "get",
-    params: {game_record_id: id},
+    params: {game_record_id: id, is_formal: isFormal},
   });
 }

+ 3 - 1
src/api/training/types.ts

@@ -27,7 +27,9 @@ export interface TrainingItem {
   create_time: string;
   play_time: string;
   grade_name: string;
-  game_record_id: number;
+  game_record_id: string;
+  // 报告状态:1正常
+  report_status: number;
 }
 
 export interface TrainingManage {

+ 0 - 1
src/views/student/index.vue

@@ -221,7 +221,6 @@ watch(
     border-radius: 6px;
 
     &.disabled {
-      cursor: not-allowed;
       background: #bfbfbf;
     }
   }

+ 19 - 8
src/views/training/index.vue

@@ -15,7 +15,7 @@ defineOptions({
 
 const pageParams: TrainingParams = reactive({
   school_id: userStore.schoolId,
-  is_formal: 0, // 1正式,2非正式
+  is_formal: 1, // 1正式,2非正式
   grade_id: 0,
   page_no: 1,
   page_size: 10,
@@ -63,6 +63,9 @@ async function getTrainingData(schoolId: number) {
 function getTrainingSearch() {
   getTrainingData(userStore.schoolId);
 }
+function alertError() {
+  ElMessage.error("本次训练采集的数据不足,无法分析并生成有效报告!");
+}
 onMounted(() => {
   getGradeData(userStore.schoolId);
   getTrainingData(userStore.schoolId);
@@ -82,7 +85,6 @@ watch(
     <!-- 学生查找 -->
     <div class="training-search">
       <el-select v-model="pageParams.is_formal" placeholder="正式学生/体验用户" size="large">
-        <el-option key="0" :value="Number(0)" label="全部学生"></el-option>
         <el-option key="1" :value="Number(1)" label="正式学生"></el-option>
         <el-option key="2" :value="Number(2)" label="体验用户"></el-option>
       </el-select>
@@ -108,11 +110,21 @@ watch(
         <el-table-column prop="grade_name" label="所在班级" align="center" />
         <el-table-column label="操作" align="center" min-width="120">
           <template #default="scope">
-            <router-link
-              :to="'/training/result?id=' + scope.row.game_record_id + '&type=' + scope.row.device_id"
-              class="table-btn"
-              >报告详情</router-link
-            >
+            <template v-if="scope.row.report_status == 1">
+              <router-link
+                :to="
+                  '/training/result?id=' +
+                  scope.row.game_record_id +
+                  '&type=' +
+                  scope.row.device_id +
+                  '&formal=' +
+                  pageParams.is_formal
+                "
+                class="table-btn"
+                >报告详情</router-link
+              >
+            </template>
+            <button v-else class="table-btn disabled" @click="alertError()">训练效果分析</button>
           </template>
         </el-table-column>
         <!-- 无数据插槽 -->
@@ -208,7 +220,6 @@ watch(
     border-radius: 10px;
 
     &.disabled {
-      cursor: not-allowed;
       background: #bfbfbf;
     }
   }

+ 3 - 2
src/views/training/result.vue

@@ -26,8 +26,9 @@ const gameType = ref(Number(getUrlParam("type")));
 const games = ref<TrainingResult>();
 const chartStatus = ref(false);
 async function getTrainingData() {
-  const gameId = Number(getUrlParam("id")) || 0;
-  getTrainingResult(gameId)
+  const gameId = getUrlParam("id") || "0";
+  const isFormal = getUrlParam("formal");
+  getTrainingResult(gameId, isFormal)
     .then(({data}) => {
       games.value = data;
       if (gameType.value == 0) {