ソースを参照

添加查询接口调用

lm 1 ヶ月 前
コミット
408a0c172d

+ 8 - 0
src/api/step4Component.ts

@@ -25,4 +25,12 @@ export const finishReviewAccountApi = (evaluationId:any) => {
         url: `${teacherPrefix}/api/v1/account/finishAccount/${evaluationId}`,
         method: 'get',
     })
+}
+
+// 评价账号页面查询年级班级下拉数据
+export const getGradeAndClassListApi = (evaluationId:any) => {
+    return request({
+        url: `${teacherPrefix}/api/v1/account/queryGradeAndClassData/${evaluationId}`,
+        method: 'get',
+    })
 }

+ 0 - 1
src/utils/makeQRCode.ts

@@ -14,7 +14,6 @@ export const makeQRCode = async (linkUrl) => {
         light: '#ffffff' // 背景颜色
       }
     });
-    console.log('二维码生成成功');
   } catch (err) {
     console.error('生成失败:', err);
   }

+ 89 - 15
src/views/reviewManagement/stepComponent/step4Component/GenerateReviewCode.vue

@@ -3,7 +3,7 @@
         <div class=" page_search">
             <div class="search_content">
                 <div class="content_left">
-                    <FormSearchGroup :searchList="searchList"></FormSearchGroup>
+                    <FormSearchGroup :searchList="searchList" @searchChange="HandleSelectSearchChange"></FormSearchGroup>
                 </div>
                 <div class="content_right">
                     <el-button class="button_refresh">导出PDF</el-button>
@@ -53,7 +53,8 @@ import { searchList } from './formSearchGroup';
 import { generateCodeTableColumns } from './table';
 
 import {
-    generateReviewCodeListApi,finishReviewAccountApi,getReviewAccountListApi
+    generateReviewCodeListApi,finishReviewAccountApi,getReviewAccountListApi,
+    getGradeAndClassListApi,
 } from '@/api/step4Component'
 import { onMounted } from 'vue';
 
@@ -102,20 +103,15 @@ const GetReviewCode = async ()=>{
     // 获取评价码信息
     let params = {
         evaluationId: route.query.id,
-        
-        evaluationGradeId:'',
-        evaluationClassId:'',
-        gender:'',
-
-
+        evaluationGradeId: searchParams.value.evaluationGradeId == 'all' ? '' : JSON.parse(searchParams.value.evaluationGradeId || '{}')?.id,
+        evaluationClassId:searchParams.value.evaluationClassId == 'all' ? '' : searchParams.value.evaluationClassId ,
+        gender:searchParams.value.gender == 'all' ? '' : searchParams.value.gender,
         pageNum: currentPage.value,
         pageSize: pageSize.value
     }
     let res = await getReviewAccountListApi(params)
     if(res?.code == 200){
         const {codeDataList} = res.data
-         
-        
         tableData.value = await Promise.all(codeDataList.records.map(async item=>{
             return {
                 ...item,
@@ -123,7 +119,6 @@ const GetReviewCode = async ()=>{
             }
         }))
 
-        console.log('表行数据---',tableData.value)
         totalNum.value = codeDataList.total
     }
 }
@@ -138,11 +133,89 @@ const HandlePaginationChange = async (params)=>{
 
 //3. 查询参数变更
 const searchParams = ref({
-    evaluationGradeId:'',  //年级
-    evaluationClassId:'',   //班级
-    gender:2,          //性别
+    evaluationGradeId:'all',  //年级
+    evaluationClassId:'all',   //班级
+    gender:'all',          //性别
 })
 
+// 获取 评价账号 年级/班级 筛选下拉
+const GetGradeAndClassListOption = async ()=>{
+    let res = await getGradeAndClassListApi(route.query.id)
+    if(res?.code == 200){
+        ElMessage.success(res?.msg)
+        let gradeOptions = res.data?.map(item=>{
+            return {
+                label:item.gradeName,
+                value:JSON.stringify({
+                    id:item.id,
+                    classData:item.classData
+                })
+            }
+        }) || []
+        // 初始赋值,班级只展示 [全部] 项
+        let classOptions = [
+            {
+                label:'全部班级',
+                value:'all'
+            }
+        ]
+        searchList.value = searchList.value.map(item=>{
+            if(item.key == 'evaluationGradeId'){
+                item.options = [
+                    {
+                        label:'全部年级',
+                        value:'all'
+                    },
+                    ...gradeOptions
+                ]
+            }else if(item.key == 'evaluationClassId'){
+                item.options = classOptions
+            }
+            return item
+        })
+    }
+}
+
+// 搜索项下拉列表变更
+const HandleSelectSearchChange = async (params,key)=>{
+    console.log('查询搜素项参数__',params)
+    searchParams.value = {...searchParams.value,...params}
+    searchList.value = searchList.value.map(item=>{
+        switch(item.key){
+            case 'evaluationClassId':{
+                // 当前触发的是年级下拉变更
+                if(key == 'evaluationGradeId'){
+                    // 重置班级的默认值
+                    searchParams.value.evaluationClassId = 'all'
+                    if(params.evaluationGradeId == 'all'){
+                        // 班级下拉置空,只剩全部
+                        item.options = [{label:'全部班级', value:'all' }]
+                    }else{
+                        // 班级下拉 动态变更
+                        let classOptions = (JSON.parse(params.evaluationGradeId || '{}')?.classData || [])?.map(item=>{
+                            return {
+                                label:item.name,
+                                value:item.id
+                            }
+                        })
+                        item.options = [{label:'全部班级', value:'all'},
+                                        ...classOptions]
+                    }
+                }
+                break
+            }
+        }
+        return {
+            ...item,
+            defaultValue:searchParams.value[item.key]
+        }
+    })
+
+    // 调用查询接口
+    await GetReviewCode()
+
+}
+
 
 
 // 3. 完成评价账号
@@ -172,7 +245,8 @@ watch(()=>evaluationManageData.isGenerateAccountByGender,(newVal)=>{
 onMounted(async ()=>{
     let generateFlag = await GenerateReviewCode()
     if(generateFlag){  // 这一步成功 才执行下一步
-       await GetReviewCode()
+        await GetGradeAndClassListOption()
+        await GetReviewCode()
     }else{
         // 评价码生成失败 返回配置页
         router.push(`reviewAccount?id=${route.query.id}`)

+ 4 - 4
src/views/reviewManagement/stepComponent/step4Component/formSearchGroup.ts

@@ -30,19 +30,19 @@ export const searchList = ref([
         key:'gender',
         type:'select',
         placeholder:'请选择',
-        defaultValue:2,
+        defaultValue:'all',
         options:[
             {
                 label:'全部性别',
-                value:2
+                value:'all'
             },
             {
                 label:'男',
-                value:0
+                value:'0'
             },
             {
                 label:'女',
-                value:1
+                value:'1'
             },
         ] 
     },