From 509f1d71c91242b11fd287cfcdeafe3d19b2d807 Mon Sep 17 00:00:00 2001
From: 马宇豪 <978517621@qq.com>
Date: 星期二, 04 三月 2025 11:11:46 +0800
Subject: [PATCH] 新增

---
 src/views/onlineEducation/count/index.vue |  223 +++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 158 insertions(+), 65 deletions(-)

diff --git a/src/views/onlineEducation/count/index.vue b/src/views/onlineEducation/count/index.vue
index cecd2dc..ba55738 100644
--- a/src/views/onlineEducation/count/index.vue
+++ b/src/views/onlineEducation/count/index.vue
@@ -7,16 +7,37 @@
         type="daterange"
         range-separator="至"
         start-placeholder="开始日期"
-        end-placeholder="结束日期">
+        end-placeholder="结束日期"
+        format="yyyy-MM-dd"
+      >
       </el-date-picker>
-      <el-select v-model="queryParams.object"  size="small" style="margin-left: 40px" placeholder="请选择科目">
-        <el-option
-          v-for="item in objectList"
-          :key="item.value"
-          :label="item.label"
-          :value="item.value">
-        </el-option>
-      </el-select>
+      <el-cascader
+        v-model="queryParams.subjectCode"
+        ref="classifyRef"
+        @change="changeTree"
+        :options="subjectList"
+        :props="{ checkStrictly: true }"
+        clearable
+        size="small"
+        style="margin-left: 30px;"
+      ></el-cascader>
+<!--      <el-select v-model="queryParams.subjectCode"  size="small" style="margin-left: 40px;" clearable placeholder="请选择资格类型">-->
+<!--        <el-option-->
+<!--          v-for="item in subjectList"-->
+<!--          :key="item.id"-->
+<!--          :label="item.name"-->
+<!--          :value="item.id">-->
+<!--        </el-option>-->
+<!--      </el-select>-->
+      <el-input size="small" style="margin-left: 30px;width: 200px" v-model="queryParams.trainOrgName" placeholder="请输入机构"></el-input>
+<!--      <el-select v-model="queryParams.trainOrgId"  size="small" style="margin-left: 40px;" clearable filterable placeholder="请选择所属机构">-->
+<!--        <el-option-->
+<!--          v-for="item in trainOrgList"-->
+<!--          :key="item.id"-->
+<!--          :label="item.name"-->
+<!--          :value="item.id">-->
+<!--        </el-option>-->
+<!--      </el-select>-->
       <el-button
         size="small"
         type="primary"
@@ -30,26 +51,33 @@
         @click="resetQuery()"
       >重置</el-button>
     </div>
-    <el-table v-loading="loading" :data="expertList">
-      <el-table-column label="平台" align="center" prop="name" />
-      <el-table-column label="机构" align="center" prop="organization" />
-      <el-table-column label="培训总人数" align="center" prop="pTotal" />
-      <el-table-column label="总时长" align="center" prop="tTotal" />
-      <el-table-column label="培训学时达标人数" align="center" prop="timeQualifyNum" />
-      <el-table-column label="考试合格人数" align="center" prop="examQualifyNum" />
-      <el-table-column label="考试合格率" align="center" prop="passRate" />
+    <el-table v-loading="loading" :data="expertList" show-summary :summary-method="getSummaries">
+      <el-table-column label="平台" align="center" prop="institutionName" />
+      <el-table-column label="培训总人数" align="center" prop="studentCount" />
+      <el-table-column label="培训学时达标人数" align="center" prop="finishCount" />
+      <el-table-column label="学时合格率" align="center" prop="classHourRate" />
+      <el-table-column label="自测考试总人数" align="center" prop="eaxmStudentCount" />
+      <el-table-column label="自测考试合格人数" align="center" prop="passCount" />
+      <el-table-column label="考试合格率" align="center" prop="passRate">
+        <template #default="scope">
+          <span>{{scope.row.passRate}}%</span>
+        </template>
+      </el-table-column>
     </el-table>
-    <pagination
-      v-show="total>0"
-      :total="total"
-      :page.sync="queryParams.pageIndex"
-      :limit.sync="queryParams.pageSize"
-      @pagination="getList"
-    />
+<!--    <pagination-->
+<!--      v-show="total>0"-->
+<!--      :total="total"-->
+<!--      :page.sync="queryParams.pageNum"-->
+<!--      :limit.sync="queryParams.pageSize"-->
+<!--      @pagination="getList"-->
+<!--    />-->
   </div>
 </template>
 
 <script>
+import moment from 'moment'
+import { getCount, getSubject } from '@/api/onlineEducation/count'
+
 export default {
   name: "count",
   components: {},
@@ -61,56 +89,95 @@
       showSearch: true,
       addForm: false,
       total: 0,
-      objectList: [
-        {
-          value: '1',
-          label: '测试数据1'
-        },
-        {
-          value: '2',
-          label: '测试数据2'
-        },
-      ],
       expertList: [],
-      queryParams: {},
-      time: []
+      subjectList: [],
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        startTime: '',
+        endTime: '',
+        subjectCode: null,
+        trainOrgName: ''
+      },
+      time: [],
+      trainOrgList: []
     };
   },
   created() {
+    this.setDate()
+    this.getSubjectList()
     this.getList()
   },
   methods: {
+    setDate(){
+      const end = new Date();
+      const start = new Date();
+      start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
+      console.log('11',start,end)
+      const s = moment(start).format('YYYY-MM-DD')
+      const e = moment(end).format('YYYY-MM-DD')
+      this.time = [s,e]
+    },
+    changeTree(val) {
+      console.log("label====",this.$refs.classifyRef.getCheckedNodes()[0].value)
+      this.queryParams.subjectCode = this.$refs.classifyRef.getCheckedNodes()[0].value
+      // 我这里只是打印了一下label的值哦,需要赋值的话自己去赋值哦
+      if (this.$refs.classifyRef) {
+        this.$refs.classifyRef.dropDownVisible = false
+      }
+    },
     getList(){
+      // debugger
+      if(this.time && this.time.length >0){
+        this.queryParams.startTime = moment(this.time[0]).format('YYYY-MM-DD')
+        this.queryParams.endTime = moment(this.time[1]).format('YYYY-MM-DD')
+      }
+      console.log('1111',this.queryParams)
       this.loading = true;
-      this.expertList = [
-        {
-          id: 1,
-          name: '测试数据1',
-          organization: '测试机构1',
-          pTotal: 40,
-          tTotal: 80,
-          timeQualifyNum: 38,
-          examQualifyNum: 35,
-          passRate: '87.5%'
-        },
-        {
-          id: 2,
-          name: '测试数据2',
-          organization: '测试机构3',
-          pTotal: 30,
-          tTotal: 50,
-          timeQualifyNum: 30,
-          examQualifyNum: 30,
-          passRate: '100%'
-
+      getCount(this.queryParams).then(res => {
+        if (res.code == 200) {
+          this.expertList = res.data.map(item => {
+            return {
+              ...item,
+              classHourRate: item.finishCount != 0 && item.studentCount != 0 ? (item.finishCount / item.studentCount).toFixed(2) *100 + '%': '0%'
+            }
+          })
+          this.loading = false;
         }
-      ]
-      this.total = 2;
+      })
       this.loading = false;
-
     },
     handleChange(){
 
+    },
+    getSubjectList() {
+      getSubject().then(res => {
+        if (res.code == 200) {
+         console.log('res',res)
+          this.subjectList = this.recursion(res.data)
+        }
+      })
+    },
+   recursion(data){
+      let tmp = []
+      for (let i = 0; i < data.length; i++) {
+        let item = data[i]
+        // children为空
+        if (item.children&& item.children.length==0) {
+          tmp.push({
+            value: item.code,
+            label: item.name
+          })
+          // 有children
+        } else {
+          tmp.push({
+            value: item.code,
+            label: item.name,
+            children: this.recursion(item.children)
+          })
+        }
+      }
+      return tmp;
     },
     handleQuery(){
       this.getList()
@@ -118,17 +185,43 @@
     },
     resetQuery(){
       this.queryParams = {
-        pageIndex: 1,
+        pageNum: 1,
         pageSize: 10,
-        object: '',
         startTime: '',
-        endTime: ''
+        endTime: '',
+        subjectCode: null,
+        trainOrgName: ''
       }
       this.time = []
       this.getList()
     },
-    handleAdd(){
-
+    getSummaries(param) {
+      const { columns, data } = param
+      const sums = [];
+      columns.forEach((column, index) => {
+        if (index === 0) {
+          sums[index] = '总计';
+          return
+        }
+        if (index === columns.length - 1) {
+          sums[index] = '--';
+          return
+        }
+        const values = data.map(item => Number(item[column.property]))
+        if (!values.every(value => isNaN(value))) {
+          sums[index] = values.reduce((prev, curr) => {
+            const value = Number(curr);
+            if (!isNaN(value)) {
+              return prev + curr;
+            } else {
+              return prev;
+            }
+          }, 0)
+        } else {
+          sums[index] = '--';
+        }
+      })
+      return sums;
     }
   }
 };

--
Gitblit v1.9.2