From 1da082138ce384d17b93169cfe108386603e72d0 Mon Sep 17 00:00:00 2001
From: zhouwx <1175765986@qq.com>
Date: 星期三, 23 七月 2025 08:49:10 +0800
Subject: [PATCH] 修改

---
 src/views/work/onlineEducation/offlineEducation/index.vue |   66 +++++++++++++++++++++++++++++++-
 1 files changed, 63 insertions(+), 3 deletions(-)

diff --git a/src/views/work/onlineEducation/offlineEducation/index.vue b/src/views/work/onlineEducation/offlineEducation/index.vue
index 89abc80..2a9bd04 100644
--- a/src/views/work/onlineEducation/offlineEducation/index.vue
+++ b/src/views/work/onlineEducation/offlineEducation/index.vue
@@ -62,7 +62,7 @@
       <el-table-column label="课程名称" prop="courseName" align="center"/>
       <el-table-column label="培训等级" prop="level" align="center">
         <template #default="scope">
-          <span>{{scope.row.sex == 1 ? '公司级':scope.row.sex == 2 ? '部门级' : '车间级'}}</span>
+          <span>{{scope.row.level == 1 ? '公司级':scope.row.level == 2 ? '部门级' : '车间级'}}</span>
         </template>
       </el-table-column>
       <el-table-column label="要求课时(分)" prop="period" align="center"/>
@@ -71,6 +71,20 @@
       <el-table-column label="是否合格" prop="passed" align="center">
         <template #default="scope">
           <span>{{scope.row.passed == 0 ? '不合格':'合格'}}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="培训记录" prop="passed" align="center" width="130">
+        <template #default="scope">
+          <div v-for="item in scope.row.files" style="display: flex;flex-direction: column">
+            <el-link type="primary" @click="openFile(item.filePath)">{{item.fileName}}</el-link>
+          </div>
+
+        </template>
+      </el-table-column>
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120">
+        <template #default="scope">
+          <el-button link type="primary"  @click="openDialog('edit',scope.row)" >编辑</el-button>
+          <el-button link type="danger"  @click="handleDelete(scope.row)" >删除</el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -95,7 +109,8 @@
 import {delUser, getUser} from "@/api/onlineEducation/user";
 import Cookies from "js-cookie";
 import {delStudent, getStudent} from "@/api/onlineEducation/student";
-import {getRecord} from "@/api/onlineEducation/examRecord";
+import {delRecord, getRecord} from "@/api/onlineEducation/examRecord";
+import {renderAsync} from "docx-preview";
 
 
 const { proxy } = getCurrentInstance();
@@ -103,6 +118,7 @@
 const dialogRef = ref();
 const data = reactive({
   queryParams: {
+    companyId: null,
     companyName: '',
     courseName: '',
     pageNum: 1,
@@ -121,8 +137,10 @@
   console.log("userInfo",userInfo)
   if(userInfo.userType === 0){
     data.isAdmin = true;
+    // data.queryParams.companyId = null
   }else {
     data.isAdmin = false;
+    // data.queryParams.companyId = userInfo.companyId
   }
   await getList()
 })
@@ -167,7 +185,7 @@
         type: 'warning',
       })
       .then( async() => {
-        const res = await delStudent(val.id)
+        const res = await delRecord(val.id)
         if(res.code == 200){
           ElMessage.success('数据删除成功')
           await getList()
@@ -176,5 +194,47 @@
         }
       })
 }
+const openFile = async(path)=>{
+  const ext = path.split('.').pop().toLowerCase();
+  if (ext === 'doc' || ext === 'xls' || ext === 'xlsx') {
+    ElMessageBox.confirm(`暂不支持线上预览.${ext}文件,是否下载查看?`, '提示', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning' }).then(() => {
+      window.open(`${import.meta.env.VITE_APP_BASE_API}/${path}`, '_blank');
+    }).catch(() => {
+      console.log('取消预览')
+    });
+    return
+  }else if(ext === 'pdf' || ext === 'jpg'||  ext === 'jpeg' || ext === 'png' ){
+    window.open(`${import.meta.env.VITE_APP_BASE_API}/${path}`, '_blank');
+  }else{
+    try {
+      // 1. 获取文件
+      const response = await fetch(import.meta.env.VITE_APP_BASE_API + '/' + path);
+      const arrayBuffer = await response.arrayBuffer();
+      // 2. 创建新窗口
+      const win = window.open('', '_blank');
+      win.document.write(`
+      <!DOCTYPE html>
+      <html>
+        <head>
+          <title>预览</title>
+          <style>
+            body { margin: 20px; font-family: Arial; }
+            .docx-container { width: 100%; height: 100%; }
+          </style>
+        </head>
+        <body>
+          <div id="container" class="docx-container"></div>
+        </body>
+      </html>
+    `);
+      // 3. 渲染 DOCX
+      await renderAsync(arrayBuffer, win.document.getElementById('container'));
+
+    } catch (error) {
+      console.error('预览失败:', error);
+      alert(`预览失败: ${error.message}`);
+    }
+  }
+}
 
 </script>

--
Gitblit v1.9.2