From 4f6cdee3d3a9967b6955aacc354bf557430c0643 Mon Sep 17 00:00:00 2001
From: zhouwx <1175765986@qq.com>
Date: 星期一, 05 八月 2024 17:05:16 +0800
Subject: [PATCH] 批改

---
 src/views/onlineEducation/count/index.vue |  159 ++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 108 insertions(+), 51 deletions(-)

diff --git a/src/views/onlineEducation/count/index.vue b/src/views/onlineEducation/count/index.vue
index 3146e79..4efa22c 100644
--- a/src/views/onlineEducation/count/index.vue
+++ b/src/views/onlineEducation/count/index.vue
@@ -1,21 +1,25 @@
 <template>
   <div class="app-container">
-    <div style="margin-bottom: 10px">
-      <el-form style="display: flex">
-        <el-form-item label="企业:">
+    <div>
+      <el-form style="display: flex;flex-wrap: wrap">
+        <el-form-item label="企业:" v-if="state.isAdmin">
           <el-select
-              v-model="state.queryParams.companyId"
-              style="width: 100%"
-              v-loadMore="loadMore"
-              class="m-2"
-              placeholder="请选择所属企业"
-              popper-class="more_select_dropdown"
+              v-model="state.queryParams.companyName"
+              filterable
+              remote
+              @change="selectValue"
+              reserve-keyword
+              placeholder="请输入企业名称"
+              remote-show-suffix
+              :remote-method="getCompanyList"
+              :loading="loadingCompany"
+              style="width: 240px"
           >
             <el-option
                 v-for="item in state.companyList"
                 :key="item.id"
                 :label="item.name"
-                :value="item.id"
+                :value="item.name"
             />
           </el-select>
         </el-form-item>
@@ -27,14 +31,14 @@
               range-separator="至"
               start-placeholder="开始日期"
               end-placeholder="结束日期"
-              value-format="YYYY-MM-DD 00:00:00"
+              format="YYYY-MM-DD"
           />
         </el-form-item>
         <el-form-item  style="margin-left: 50px">
           <el-radio-group v-model="state.queryParams.type">
             <el-radio :label="1">线上教育</el-radio>
             <el-radio :label="2">线下教育</el-radio>
-            <el-radio :label="null">全部</el-radio>
+<!--            <el-radio :label="null">全部</el-radio>-->
           </el-radio-group>
         </el-form-item>
         <el-form-item>
@@ -47,15 +51,31 @@
     <!-- 表格数据 -->
     <el-table v-loading="loading" :data="state.dataList" :border="true" row-key="id">
       <el-table-column label="序号" type="index" align="center" width="80" />
-      <el-table-column label="企业名称" prop="sort" align="center" />
-      <el-table-column label="企业编号" prop="sort" align="center" width="80" />
-      <el-table-column label="总批次/人数" prop="sort" align="center" width="80" />
-      <el-table-column label="三级" prop="sort" align="center" width="80" />
-      <el-table-column label="二级" prop="sort" align="center" width="80" />
-      <el-table-column label="一级" prop="sort" align="center" width="80" />
-      <el-table-column label="考试人次" prop="sort" align="center" width="80" />
-      <el-table-column label="合格人次" prop="sort" align="center" width="80" />
-      <el-table-column label="考试合格率" prop="sort" align="center" width="80" />
+      <el-table-column label="企业名称" prop="companyName" align="center" />
+      <el-table-column label="企业编号" prop="companyCode" align="center" />
+      <el-table-column label="总批次/人数" prop="sort" align="center"  >
+        <template #default="scope">
+          <span>{{scope.row.phaseStudentCount && scope.row.phaseCount ? scope.row.phaseCount + '/' +scope.row.phaseStudentCount:''}}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="三级" prop="sort" align="center" >
+        <template #default="scope">
+          <span>{{scope.row.level3StudentCount && scope.row.level3PhaseCount ? scope.row.level3PhaseCount+ '/' +scope.row.level3StudentCount:''}}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="二级" prop="sort" align="center" >
+        <template #default="scope">
+          <span>{{scope.row.level2StudentCount && scope.row.level2PhaseCount ? scope.row.level2PhaseCount+ '/' +scope.row.level2StudentCount:''}}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="一级" prop="sort" align="center"  >
+        <template #default="scope">
+          <span>{{scope.row.level1StudentCount && scope.row.level1PhaseCount ? scope.row.level1PhaseCount+ '/' +scope.row.level1StudentCount:''}}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="考试人次" prop="paperStudentCount" align="center"  />
+      <el-table-column label="合格人次" prop="passStudentCount" align="center"  />
+      <el-table-column label="合格率" prop="passRate" align="center"  />
     </el-table>
     <pagination
         v-show="state.total > 0"
@@ -71,10 +91,12 @@
 <script setup>
 import {getCurrentInstance, onMounted, reactive, ref, toRefs} from "vue";
 import {ElMessage, ElMessageBox} from "element-plus";
+import moment from "moment";
 
 import {delClassification, getClassification} from "@/api/onlineEducation/courseClass";
 import {getCompany} from "@/api/onlineEducation/company";
 import {getCompanyCount} from "@/api/onlineEducation/count";
+import Cookies from "js-cookie";
 const { proxy } = getCurrentInstance();
 const loading = ref(false);
 const areaRef = ref();
@@ -94,11 +116,19 @@
   companyList: [],
   pageNum: 1,
   pageSize: 10,
+  isAdmin: false
 });
 
 //页面加载
 onMounted(() => {
-  getCompanyList();
+  setDate();
+  const userInfo = JSON.parse(Cookies.get('userInfo'))
+  console.log("userInfo",userInfo)
+  state.isAdmin = userInfo.userType === 0;
+  // if(state.isAdmin){
+  //   getCompanyList();
+  // }
+
   getList();
 
 });
@@ -106,67 +136,94 @@
   loading.value = true;
   const res = await getCompanyCount(state.queryParams);
   if(res.code === 200){
-    state.dataList = res.data
+    state.dataList = res.data.list.map(item => {
+      return {
+        ...item,
+        passRate: item.passStudentCount!=null && item.paperStudentCount!=null ? (item.passStudentCount / item.paperStudentCount).toFixed(2) *100 + '%': ''
+
+      }
+    })
+    state.total = res.data.total
   }else{
     ElMessage.warning(res.message)
   }
   loading.value = false;
 }
+const selectValue = (val) => {
+  state.companyList.forEach(item => {
+    if(item.name === val){
+      state.queryParams.companyId = item.id
+    }
+  })
+}
 
 const finshed = ref(false)
-const getCompanyList = async (type)=>{
-  if (type === 'open' && state.pageNum !== 1) {
-  } else {
+const loadingCompany = ref(false)
+const getCompanyList = async (val)=>{
+  if(val != ""){
+    loadingCompany.value = true;
     const queryParams = {
-      pageNum: state.pageNum,
-      pageSize: state.pageSize,
+      name: val
     }
     const res = await getCompany(queryParams)
     if (res.code == 200) {
-      if (res.data.pageNum === state.pageNum) {
-        finshed.value = false;
-        if (state.pageNum == 1) {
-          state.companyList = res.data.list
-        } else {
-          state.companyList = state.companyList.concat(res.data.list)
-        }
-      } else {
-        finshed.value = true;
-      }
+      loadingCompany.value = false;
+      state.companyList = res.data.list
 
     } else {
       ElMessage.warning(res.message)
     }
-    console.log("state.companyList",state.companyList)
   }
 }
 //触底函数
-const loadMore = () => {
-  console.log(' 触底了');
-  // 防抖处理
-  setTimeout(() => {
-    if (finshed.value) return //值为true,则代表没有数据了
-    state.pageNum += 1
-    getCompanyList('')
-  }, 500)
+// const loadMore = () => {
+//   console.log(' 触底了');
+//   // 防抖处理
+//   setTimeout(() => {
+//     if (finshed.value) return //值为true,则代表没有数据了
+//     state.pageNum += 1
+//     // getCompanyList('')
+//   }, 500)
+// }
+const setDate = () => {
+  let isDate = new Date()
+  let sTime = `${isDate.getFullYear()}-${isDate.getMonth() + 1}-${isDate.getDate()-7}`
+  let eTime = `${isDate.getFullYear()}-${isDate.getMonth() + 1}-${isDate.getDate()}`
+  sTime = `${sTime}`
+  eTime = `${eTime}`
+  searchTime.value = [sTime,eTime];
+  state.queryParams.startTime = searchTime.value[0]+' 00:00:00'
+  state.queryParams.endTime = searchTime.value[1]+' 00:00:00'
 }
 const changeTime=(value)=>{
+  console.log('11',searchTime.value)
   if(!value){
     state.queryParams.endTime = ""
     state.queryParams.startTime = ""
   }
+  searchTime.value[0]=moment(searchTime.value[0]).format('YYYY-MM-DD')
+  searchTime.value[1]=moment(searchTime.value[1]).format('YYYY-MM-DD')
 }
 const searchClick = () => {
   if(searchTime.value && searchTime.value.length>0){
-    state.queryParams.startTime = searchTime.value[0]
-    state.queryParams.endTime = searchTime.value[1]
+    state.queryParams.startTime = searchTime.value[0] + ' 00:00:00'
+    state.queryParams.endTime = searchTime.value[1] + ' 00:00:00'
   }
   getList();
 }
+
 /** 重置新增的表单以及其他数据  */
 function reset() {
-  data.queryParams.name = '';
-  data.queryParams.pageNum = 1;
+  state.queryParams = {
+    companyId: '',
+    type: null,
+    endTime: '',
+    startTime: '',
+    pageNum: 1,
+    pageSize: 10,
+  }
+  searchTime.value = [];
+  state.companyList = [];
   getList();
 }
 

--
Gitblit v1.9.2