From c2dcff2da9764f50dbd645032ac34c67442b67bc Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期四, 29 一月 2026 17:45:47 +0800
Subject: [PATCH] 安全培训考核部分功能

---
 src/views/productionManagement/productionProcess/index.vue  |   48 +-
 src/api/safeProduction/safetyTrainingAssessment.js          |   70 +++
 src/views/safeProduction/safetyTrainingAssessment/index.vue |  939 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1,036 insertions(+), 21 deletions(-)

diff --git a/src/api/safeProduction/safetyTrainingAssessment.js b/src/api/safeProduction/safetyTrainingAssessment.js
new file mode 100644
index 0000000..a02ff2e
--- /dev/null
+++ b/src/api/safeProduction/safetyTrainingAssessment.js
@@ -0,0 +1,70 @@
+
+import request from "@/utils/request";
+
+// 鍒嗛〉鏌ヨ
+export function safeTrainingListPage(query) {
+  return request({
+    url: "/safeTraining/page",
+    method: "get",
+    params: query,
+  });
+}
+
+
+export function safeTrainingAdd(query) {
+    return request({
+        url: '/safeTraining',
+        method: 'post',
+        data: query
+    })
+}
+
+export function safeTrainingUpdate(query) {
+    return request({
+        url: '/safeTraining',
+        method: 'put',
+        data: query
+    })
+}
+
+export function safeTrainingDel(ids) {
+    return request({
+        url: '/safeTraining/' + ids,
+        method: 'delete',
+        data: ids
+    })
+}
+// 瀵煎嚭
+export function safeTrainingExport(query) {
+    return request({
+        url: '/safeTraining/export',
+        method: 'post',
+        data: query,
+        responseType: 'blob'
+    })
+}
+
+// 鏌ヨ闄勪欢鍒楄〃
+export function safeTrainingFileListPage(query) {
+  return request({
+    url: "/safeTrainingFile/listPage",
+    method: "get",
+    params: query,
+  });
+}
+// 娣诲姞闄勪欢
+export function safeTrainingFileAdd(query) {
+    return request({
+        url: '/safeTrainingFile/add',
+        method: 'post',
+        data: query
+    })
+}
+// 鍒犻櫎闄勪欢
+export function safeTrainingFileDel(ids) {
+    return request({
+        url: '/safeTrainingFile/del',
+        method: 'delete',
+        data: ids
+    })
+}
\ No newline at end of file
diff --git a/src/views/productionManagement/productionProcess/index.vue b/src/views/productionManagement/productionProcess/index.vue
index 7ab8c9a..67430cb 100644
--- a/src/views/productionManagement/productionProcess/index.vue
+++ b/src/views/productionManagement/productionProcess/index.vue
@@ -30,7 +30,9 @@
            class="mb10">
         <el-button type="primary"
                    @click="showNewModal">鏂板宸ュ簭</el-button>
-        <el-button type="info" plain @click="handleImport">瀵煎叆</el-button>
+        <el-button type="info"
+                   plain
+                   @click="handleImport">瀵煎叆</el-button>
         <el-button type="danger"
                    @click="handleDelete"
                    :disabled="selectedRows.length === 0"
@@ -53,19 +55,17 @@
                   v-model:visible="isShowEditModal"
                   :record="record"
                   @completed="getList" />
-    <ImportDialog
-      ref="importDialogRef"
-      v-model="importDialogVisible"
-      title="瀵煎叆宸ュ簭"
-      :action="importAction"
-      :headers="importHeaders"
-      :auto-upload="false"
-      :on-success="handleImportSuccess"
-      :on-error="handleImportError"
-      @confirm="handleImportConfirm"
-      @download-template="handleDownloadTemplate"
-      @close="handleImportClose"
-    />
+    <ImportDialog ref="importDialogRef"
+                  v-model="importDialogVisible"
+                  title="瀵煎叆宸ュ簭"
+                  :action="importAction"
+                  :headers="importHeaders"
+                  :auto-upload="false"
+                  :on-success="handleImportSuccess"
+                  :on-error="handleImportError"
+                  @confirm="handleImportConfirm"
+                  @download-template="handleDownloadTemplate"
+                  @close="handleImportClose" />
   </div>
 </template>
 
@@ -74,7 +74,12 @@
   import NewProcess from "@/views/productionManagement/productionProcess/New.vue";
   import EditProcess from "@/views/productionManagement/productionProcess/Edit.vue";
   import ImportDialog from "@/components/Dialog/ImportDialog.vue";
-  import { listPage, del, importData, downloadTemplate } from "@/api/productionManagement/productionProcess.js";
+  import {
+    listPage,
+    del,
+    importData,
+    downloadTemplate,
+  } from "@/api/productionManagement/productionProcess.js";
   import { getToken } from "@/utils/auth";
 
   const data = reactive({
@@ -93,7 +98,7 @@
       label: "宸ュ簭鍚嶇О",
       prop: "name",
     },
-   
+
     {
       label: "宸ヨ祫瀹氶",
       prop: "salaryQuota",
@@ -102,7 +107,7 @@
       label: "澶囨敞",
       prop: "remark",
     },
-     {
+    {
       label: "鏇存柊鏃堕棿",
       prop: "updateTime",
     },
@@ -137,9 +142,10 @@
     total: 0,
   });
   const { proxy } = getCurrentInstance();
-  
+
   // 瀵煎叆鐩稿叧閰嶇疆
-  const importAction = import.meta.env.VITE_APP_BASE_API + "/productProcess/importData";
+  const importAction =
+    import.meta.env.VITE_APP_BASE_API + "/productProcess/importData";
   const importHeaders = { Authorization: "Bearer " + getToken() };
 
   // 鏌ヨ鍒楄〃
@@ -235,7 +241,7 @@
   };
 
   // 瀵煎叆鎴愬姛
-  const handleImportSuccess = (response) => {
+  const handleImportSuccess = response => {
     if (response.code === 200) {
       proxy.$modal.msgSuccess("瀵煎叆鎴愬姛");
       importDialogVisible.value = false;
@@ -249,7 +255,7 @@
   };
 
   // 瀵煎叆澶辫触
-  const handleImportError = (error) => {
+  const handleImportError = error => {
     proxy.$modal.msgError("瀵煎叆澶辫触锛�" + (error.message || "鏈煡閿欒"));
   };
 
diff --git a/src/views/safeProduction/safetyTrainingAssessment/index.vue b/src/views/safeProduction/safetyTrainingAssessment/index.vue
new file mode 100644
index 0000000..8fbfe9b
--- /dev/null
+++ b/src/views/safeProduction/safetyTrainingAssessment/index.vue
@@ -0,0 +1,939 @@
+<template>
+  <div class="app-container">
+    <div class="search_form">
+      <div>
+        <span class="search_title">鍩硅鍚嶇О锛�</span>
+        <el-input v-model="searchForm.name"
+                  style="width: 240px"
+                  placeholder="璇疯緭鍏ュ煿璁悕绉版悳绱�"
+                  @change="handleQuery"
+                  clearable
+                  :prefix-icon="Search" />
+        <span class="search_title ml10">鍩硅绫诲瀷锛�</span>
+        <el-select v-model="searchForm.type"
+                   clearable
+                   @change="handleQuery"
+                   style="width: 240px">
+          <el-option v-for="item in knowledgeTypeOptions"
+                     :key="item.value"
+                     :label="item.label"
+                     :value="item.value" />
+        </el-select>
+        <el-button type="primary"
+                   @click="handleQuery"
+                   style="margin-left: 10px">
+          鎼滅储
+        </el-button>
+      </div>
+      <div>
+        <el-button type="primary"
+                   @click="openForm('add')">鏂板鍩硅</el-button>
+        <el-button type="danger"
+                   plain
+                   @click="handleDelete">鍒犻櫎</el-button>
+      </div>
+    </div>
+    <div class="table_list">
+      <PIMTable rowKey="id"
+                :column="tableColumn"
+                :tableData="tableData"
+                :page="page"
+                :isSelection="true"
+                @selection-change="handleSelectionChange"
+                :tableLoading="tableLoading"
+                @pagination="pagination"
+                :total="page.total"
+                :rowClassName="getRowClass"></PIMTable>
+    </div>
+    <!-- 鏂板/缂栬緫鐭ヨ瘑寮圭獥 -->
+    <el-dialog v-model="dialogVisible"
+               :title="dialogTitle"
+               width="800px"
+               :close-on-click-modal="false">
+      <el-form ref="formRef"
+               :model="form"
+               :rules="rules"
+               label-width="120px">
+        <el-row :gutter="20">
+          <el-col :span="12">
+            <el-form-item label="鍩硅鏃ユ湡"
+                          prop="trainingDate">
+              <el-date-picker style="width: 100%"
+                              v-model="form.trainingDate"
+                              value-format="YYYY-MM-DD"
+                              format="YYYY-MM-DD"
+                              type="date"
+                              placeholder="璇烽�夋嫨"
+                              clearable />
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="璇剧▼缂栧彿"
+                          prop="courseCode">
+              <el-input v-model="form.courseCode"
+                        disabled
+                        placeholder="鑷姩鐢熸垚" />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="20">
+          <el-col :span="12">
+            <el-form-item label="寮�濮嬫椂闂�"
+                          prop="openingTime">
+              <el-time-picker v-model="form.openingTime"
+                              placeholder="璇烽�夋嫨"
+                              value-format="HH:mm:ss"
+                              format="HH:mm:ss"
+                              clearable />
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="缁撴潫鏃堕棿"
+                          prop="endTime">
+              <el-time-picker v-model="form.endTime"
+                              placeholder="璇烽�夋嫨"
+                              value-format="HH:mm:ss"
+                              format="HH:mm:ss"
+                              clearable />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="20">
+          <el-col :span="12">
+            <el-form-item label="鍩硅鐩爣"
+                          prop="trainingObjectives">
+              <el-input v-model="form.trainingObjectives"
+                        placeholder="璇疯緭鍏ュ煿璁洰鏍�" />
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="鍙傚姞瀵硅薄"
+                          prop="participants">
+              <el-input v-model="form.participants"
+                        placeholder="璇疯緭鍏ュ弬鍔犲璞�" />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="20">
+          <el-col :span="12">
+            <el-form-item label="鍩硅鍐呭"
+                          prop="trainingContent">
+              <el-input v-model="form.trainingContent"
+                        placeholder="璇疯緭鍏ュ煿璁唴瀹�" />
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="鍩硅璁插笀"
+                          prop="trainingLecturer">
+              <el-input v-model="form.trainingLecturer"
+                        placeholder="璇疯緭鍏ュ煿璁甯�" />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="20">
+          <el-col :span="12">
+            <el-form-item label="璇剧▼瀛﹀垎"
+                          prop="projectCredits">
+              <el-input v-model="form.projectCredits"
+                        placeholder="璇疯緭鍏ヨ绋嬪鍒�" />
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="鍩硅鏂瑰紡"
+                          prop="trainingMode">
+              <el-select v-model="form.trainingMode"
+                         placeholder="璇烽�夋嫨鍩硅鏂瑰紡"
+                         clearable>
+                <el-option v-for="item in trainingModeOptions"
+                           :key="item.value"
+                           :label="item.label"
+                           :value="item.value" />
+              </el-select>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="20">
+          <el-col :span="12">
+            <el-form-item label="鍩硅鍦扮偣"
+                          prop="placeTraining">
+              <el-input v-model="form.placeTraining"
+                        placeholder="璇疯緭鍏ュ煿璁湴鐐�" />
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="璇炬椂"
+                          prop="classHour">
+              <el-input v-model="form.classHour"
+                        type="number"
+                        min="0"
+                        placeholder="璇疯緭鍏ヨ鏃�" />
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+      <template #footer>
+        <span class="dialog-footer">
+          <el-button @click="dialogVisible = false">鍙栨秷</el-button>
+          <el-button type="primary"
+                     @click="submitForm">纭畾</el-button>
+        </span>
+      </template>
+    </el-dialog>
+    <!-- 鏌ョ湅鐭ヨ瘑璇︽儏寮圭獥 -->
+    <el-dialog v-model="viewDialogVisible"
+               title="鍩硅璇︽儏"
+               width="900px"
+               :close-on-click-modal="false">
+      <div class="knowledge-detail">
+        <el-descriptions :column="2"
+                         border>
+          <el-descriptions-item label="鍩硅鍚嶇О"
+                                :span="2">
+            <span class="detail-title">{{ currentKnowledge.name }}</span>
+          </el-descriptions-item>
+          <el-descriptions-item label="鍩硅缂栫爜">
+            {{ currentKnowledge.code }}
+          </el-descriptions-item>
+          <el-descriptions-item label="鍩硅绫诲瀷">
+            <el-tag type="info">
+              <!-- {{ getTypeLabel(currentKnowledge.type) }} -->
+            </el-tag>
+          </el-descriptions-item>
+          <el-descriptions-item label="鎵�鍦ㄤ綅缃�">
+            {{ currentKnowledge.location }}
+          </el-descriptions-item>
+          <el-descriptions-item label="绠℃帶鎺柦">
+            {{ currentKnowledge.controlMeasures }}
+          </el-descriptions-item>
+          <el-descriptions-item label="搴撳瓨鏁伴噺">
+            {{ currentKnowledge.stockQty }}
+          </el-descriptions-item>
+          <el-descriptions-item label="绠℃帶璐d换浜�">
+            {{ currentKnowledge.principalUserId }}
+          </el-descriptions-item>
+          <el-descriptions-item label="璐d换浜鸿仈绯荤數璇�">
+            {{ currentKnowledge.principalMobile }}
+          </el-descriptions-item>
+          <el-descriptions-item label="椋庨櫓绛夌骇">
+            <el-tag :type="getTypeTagType(currentKnowledge.riskLevel)">
+              {{ currentKnowledge.riskLevel }}
+            </el-tag>
+          </el-descriptions-item>
+          <el-descriptions-item label="瑙勬牸 / 椋庨櫓鎻忚堪">
+            {{ currentKnowledge.specInfo }}
+          </el-descriptions-item>
+        </el-descriptions>
+      </div>
+      <template #footer>
+        <span class="dialog-footer">
+          <el-button @click="viewDialogVisible = false">鍏抽棴</el-button>
+        </span>
+      </template>
+    </el-dialog>
+    <!-- 闄勪欢鍒楄〃寮圭獥 -->
+    <FileListDialog ref="fileListRef"
+                    v-model="fileListDialogVisible"
+                    :show-upload-button="true"
+                    :show-delete-button="true"
+                    :upload-method="handleUpload"
+                    :delete-method="handleFileDelete"
+                    title="闄勪欢鍒楄〃" />
+  </div>
+</template>
+
+<script setup>
+  import { Search } from "@element-plus/icons-vue";
+  import FileListDialog from "@/components/Dialog/FileListDialog.vue";
+  import {
+    onMounted,
+    ref,
+    reactive,
+    toRefs,
+    getCurrentInstance,
+    computed,
+  } from "vue";
+  import request from "@/utils/request";
+  import { getToken } from "@/utils/auth";
+  import { ElMessage, ElMessageBox } from "element-plus";
+  import PIMTable from "@/components/PIMTable/PIMTable.vue";
+  import { userListNoPage } from "@/api/system/user.js";
+  import {
+    safeTrainingListPage,
+    safeTrainingAdd,
+    safeTrainingExport,
+    safeTrainingDel,
+    safeTrainingFileListPage,
+    safeTrainingFileAdd,
+    safeTrainingFileDel,
+  } from "@/api/safeProduction/safetyTrainingAssessment.js";
+
+  // 琛ㄥ崟楠岃瘉瑙勫垯
+  const rules = {
+    trainingDate: [
+      { required: true, message: "璇烽�夋嫨鍩硅鏃ユ湡", trigger: "change" },
+    ],
+    openingTime: [
+      { required: true, message: "璇烽�夋嫨寮�濮嬫椂闂�", trigger: "change" },
+    ],
+    endTime: [{ required: true, message: "璇烽�夋嫨缁撴潫鏃堕棿", trigger: "change" }],
+    trainingContent: [
+      { required: true, message: "璇疯緭鍏ュ煿璁唴瀹�", trigger: "blur" },
+    ],
+    trainingLecturer: [
+      { required: true, message: "璇疯緭鍏ュ煿璁甯�", trigger: "blur" },
+    ],
+    classHour: [{ required: true, message: "璇疯緭鍏ヨ鏃�", trigger: "blur" }],
+  };
+
+  // 鍝嶅簲寮忔暟鎹�
+  const data = reactive({
+    searchForm: {
+      name: "",
+      type: "",
+    },
+    tableLoading: false,
+    page: {
+      current: 1,
+      size: 20,
+      total: 0,
+    },
+    tableData: [],
+    selectedIds: [],
+    form: {
+      courseCode: "", // 璇剧▼缂栧彿
+      trainingDate: "", // 鍩硅鏃ユ湡
+      openingTime: "", // 寮�濮嬫椂闂�
+      endTime: "", // 缁撴潫鏃堕棿
+      trainingObjectives: "", // 鍩硅鐩爣
+      participants: "", // 鍙傚姞瀵硅薄
+      trainingContent: "", // 鍩硅鍐呭
+      trainingLecturer: "", // 鍩硅璁插笀
+      projectCredits: "", // 椤圭洰瀛﹀垎
+      trainingMode: "", // 鍩硅鏂瑰紡
+      placeTraining: "", // 鍩硅鍦扮偣
+      classHour: "", // 璇炬椂
+    },
+    dialogVisible: false,
+    dialogTitle: "",
+    dialogType: "add",
+    viewDialogVisible: false,
+    currentKnowledge: {},
+  });
+
+  const {
+    searchForm,
+    tableLoading,
+    page,
+    tableData,
+    selectedIds,
+    form,
+    dialogVisible,
+    dialogTitle,
+    dialogType,
+    viewDialogVisible,
+    currentKnowledge,
+  } = toRefs(data);
+  const { proxy } = getCurrentInstance();
+  const { safe_training_methods } = proxy.useDict("safe_training_methods");
+  const trainingModeOptions = computed(() => safe_training_methods?.value || []);
+  const getTrainingModeLabel = val => {
+    const item = trainingModeOptions.value.find(
+      i => String(i.value) === String(val)
+    );
+    return item ? item.label : val;
+  };
+  // 琛ㄥ崟寮曠敤
+  const formRef = ref();
+  const riskLevelOptions = ref([
+    { value: "浣庨闄�", label: "浣庨闄�" },
+    { value: "涓�鑸闄�", label: "涓�鑸闄�" },
+    { value: "杈冨ぇ椋庨櫓", label: "杈冨ぇ椋庨櫓" },
+    { value: "閲嶅ぇ椋庨櫓", label: "閲嶅ぇ椋庨櫓" },
+  ]);
+
+  // 琛ㄦ牸鍒楅厤缃�
+  const tableColumn = ref([
+    {
+      label: "璇剧▼缂栧彿",
+      prop: "courseCode",
+      showOverflowTooltip: true,
+    },
+    {
+      label: "鍩硅鏃ユ湡",
+      prop: "trainingDate",
+      showOverflowTooltip: true,
+    },
+    {
+      label: "寮�濮嬫椂闂�",
+      prop: "openingTime",
+      showOverflowTooltip: true,
+    },
+    {
+      label: "缁撴潫鏃堕棿",
+      prop: "endTime",
+      showOverflowTooltip: true,
+    },
+    {
+      label: "鍩硅鐩爣",
+      prop: "trainingObjectives",
+      showOverflowTooltip: true,
+    },
+    {
+      label: "鍙傚姞瀵硅薄",
+      prop: "participants",
+      showOverflowTooltip: true,
+    },
+    {
+      label: "鍩硅鍐呭",
+      prop: "trainingContent",
+      showOverflowTooltip: true,
+    },
+    {
+      label: "鍩硅璁插笀",
+      prop: "trainingLecturer",
+      showOverflowTooltip: true,
+    },
+    {
+      label: "椤圭洰瀛﹀垎",
+      prop: "projectCredits",
+      showOverflowTooltip: true,
+    },
+    {
+      label: "鍩硅鏂瑰紡",
+      prop: "trainingMode",
+      showOverflowTooltip: true,
+      formatData: params => {
+        return getTrainingModeLabel(params);
+      },
+    },
+    {
+      label: "鍩硅鍦扮偣",
+      prop: "placeTraining",
+      showOverflowTooltip: true,
+    },
+    {
+      label: "璇炬椂",
+      prop: "classHour",
+      showOverflowTooltip: true,
+    },
+    {
+      dataType: "action",
+      label: "鎿嶄綔",
+      align: "center",
+      fixed: "right",
+      width: 200,
+      operation: [
+        {
+          name: "缂栬緫",
+          type: "text",
+          clickFun: row => {
+            openForm("edit", row);
+          },
+        },
+        {
+          name: "瀵煎嚭",
+          type: "danger",
+          clickFun: row => {
+            exportKnowledge(row);
+          },
+        },
+        {
+          name: "闄勪欢",
+          type: "danger",
+          clickFun: row => {
+            downLoadFile(row);
+          },
+        },
+        // {
+        //   name: "鏌ョ湅",
+        //   type: "text",
+        //   clickFun: row => {
+        //     viewKnowledge(row);
+        //   },
+        // },
+      ],
+    },
+  ]);
+  const userList = ref([]);
+  // 鐢熷懡鍛ㄦ湡
+  onMounted(() => {
+    getList();
+    startAutoRefresh();
+    userListNoPage().then(res => {
+      userList.value = res.data;
+    });
+  });
+
+  // 澶勭悊鐢ㄦ埛閫夋嫨鍙樺寲
+  const handleUserChange = userId => {
+    const selectedUser = userList.value.find(user => user.userId === userId);
+    if (selectedUser) {
+      form.value.principalUser = selectedUser.nickName;
+      form.value.principalMobile = selectedUser.phonenumber;
+    }
+  };
+  /**
+   * 涓嬭浇鏂囦欢
+   *
+   * @param row 涓嬭浇鏂囦欢鐨勭浉鍏充俊鎭璞�
+   */
+  const fileListRef = ref(null);
+  const fileListDialogVisible = ref(false);
+  const currentFileRow = ref(null);
+  const downLoadFile = row => {
+    currentFileRow.value = row;
+    safeTrainingFileListPage({ safeTrainingId: row.id }).then(res => {
+      if (fileListRef.value) {
+        fileListRef.value.open(res.data.records);
+      }
+    });
+  };
+  // 涓婁紶闄勪欢
+  const handleUpload = async () => {
+    if (!currentFileRow.value) {
+      proxy.$modal.msgWarning("璇峰厛閫夋嫨鏁版嵁");
+      return null;
+    }
+
+    return new Promise(resolve => {
+      // 鍒涘缓涓�涓殣钘忕殑鏂囦欢杈撳叆鍏冪礌
+      const input = document.createElement("input");
+      input.type = "file";
+      input.style.display = "none";
+      input.onchange = async e => {
+        const file = e.target.files[0];
+        if (!file) {
+          resolve(null);
+          return;
+        }
+
+        try {
+          // 浣跨敤 FormData 涓婁紶鏂囦欢
+          const formData = new FormData();
+          formData.append("file", file);
+
+          const uploadRes = await request({
+            url: "/file/upload",
+            method: "post",
+            data: formData,
+            headers: {
+              "Content-Type": "multipart/form-data",
+              Authorization: `Bearer ${getToken()}`,
+            },
+          });
+
+          if (uploadRes.code === 200) {
+            // 淇濆瓨闄勪欢淇℃伅
+            const fileData = {
+              safeTrainingId: currentFileRow.value.id,
+              name: uploadRes.data.originalName || file.name,
+              url: uploadRes.data.tempPath || uploadRes.data.url,
+            };
+
+            const saveRes = await safeTrainingFileAdd(fileData);
+            if (saveRes.code === 200) {
+              proxy.$modal.msgSuccess("鏂囦欢涓婁紶鎴愬姛");
+              // 閲嶆柊鍔犺浇鏂囦欢鍒楄〃
+              const listRes = await safeTrainingFileListPage({
+                safeTrainingId: currentFileRow.value.id,
+              });
+              if (listRes.code === 200 && fileListRef.value) {
+                const fileList = (listRes.data?.records || []).map(item => ({
+                  name: item.name,
+                  url: item.url,
+                  id: item.id,
+                  ...item,
+                }));
+                fileListRef.value.setList(fileList);
+              }
+              // 杩斿洖鏂版枃浠朵俊鎭�
+              resolve({
+                name: fileData.name,
+                url: fileData.url,
+                id: saveRes.data?.id,
+              });
+            } else {
+              proxy.$modal.msgError(saveRes.msg || "鏂囦欢淇濆瓨澶辫触");
+              resolve(null);
+            }
+          } else {
+            proxy.$modal.msgError(uploadRes.msg || "鏂囦欢涓婁紶澶辫触");
+            resolve(null);
+          }
+        } catch (error) {
+          proxy.$modal.msgError("鏂囦欢涓婁紶澶辫触");
+          resolve(null);
+        } finally {
+          document.body.removeChild(input);
+        }
+      };
+
+      document.body.appendChild(input);
+      input.click();
+    });
+  };
+  // 鍒犻櫎闄勪欢
+  const handleFileDelete = async row => {
+    try {
+      const res = await safeTrainingFileDel([row.id]);
+      if (res.code === 200) {
+        proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+        // 閲嶆柊鍔犺浇鏂囦欢鍒楄〃
+        if (currentFileRow.value && fileListRef.value) {
+          const listRes = await safeTrainingFileListPage({
+            safeTrainingId: currentFileRow.value.id,
+          });
+          if (listRes.code === 200) {
+            const fileList = (listRes.data?.records || []).map(item => ({
+              name: item.name,
+              url: item.url,
+              id: item.id,
+              ...item,
+            }));
+            fileListRef.value.setList(fileList);
+          }
+        }
+        return true; // 杩斿洖 true 琛ㄧず鍒犻櫎鎴愬姛锛岀粍浠朵細鏇存柊鍒楄〃
+      } else {
+        proxy.$modal.msgError(res.msg || "鍒犻櫎澶辫触");
+        return false;
+      }
+    } catch (error) {
+      proxy.$modal.msgError("鍒犻櫎澶辫触");
+      return false;
+    }
+  };
+
+  // 寮�濮嬭嚜鍔ㄥ埛鏂�
+  const startAutoRefresh = () => {
+    setInterval(() => {
+      getList();
+    }, 600000); // 10鍒嗛挓鍒锋柊涓�娆� (10 * 60 * 1000 = 600000ms)
+  };
+
+  // 鏌ヨ鏁版嵁
+  const handleQuery = () => {
+    page.value.current = 1;
+    getList();
+  };
+  const exportKnowledge = row => {
+    safeTrainingExport(row)
+      .then(res => {
+        // 鍒涘缓Blob瀵硅薄
+        const blob = new Blob([res], {
+          type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+        });
+        // 鍒涘缓涓嬭浇閾炬帴
+        const url = window.URL.createObjectURL(blob);
+        const link = document.createElement("a");
+        link.href = url;
+        link.download = `鍩硅璁板綍_${row.courseCode}.xlsx`;
+
+        // 妯℃嫙鐐瑰嚮涓嬭浇
+        document.body.appendChild(link);
+        link.click();
+
+        // 娓呯悊涓存椂瀵硅薄
+        setTimeout(() => {
+          document.body.removeChild(link);
+          window.URL.revokeObjectURL(url);
+        }, 100);
+
+        ElMessage.success("瀵煎嚭鎴愬姛");
+      })
+      .catch(err => {
+        console.error("瀵煎嚭澶辫触:", err);
+        ElMessage.error("瀵煎嚭澶辫触锛岃閲嶈瘯");
+      });
+  };
+  const getList = () => {
+    tableLoading.value = true;
+    safeTrainingListPage({ ...page.value, ...searchForm.value })
+      .then(res => {
+        tableLoading.value = false;
+        tableData.value = res.data.records;
+        page.value.total = res.data.total;
+      })
+      .catch(err => {
+        tableLoading.value = false;
+      });
+  };
+
+  // 鍒嗛〉澶勭悊
+  const pagination = obj => {
+    page.value.current = obj.page;
+    page.value.size = obj.limit;
+    handleQuery();
+  };
+
+  // 閫夋嫨鍙樺寲澶勭悊
+  const handleSelectionChange = selection => {
+    selectedIds.value = selection.map(item => item.id);
+  };
+
+  // 鎵撳紑琛ㄥ崟
+  const openForm = (type, row = null) => {
+    dialogType.value = type;
+    if (type === "add") {
+      dialogTitle.value = "鏂板鍩硅";
+      // 閲嶇疆琛ㄥ崟
+      Object.assign(form.value, {
+        courseCode: "", // 璇剧▼缂栧彿
+        trainingDate: "", // 鍩硅鏃ユ湡
+        openingTime: "", // 寮�濮嬫椂闂�
+        endTime: "", // 缁撴潫鏃堕棿
+        trainingObjectives: "", // 鍩硅鐩爣
+        participants: "", // 鍙傚姞瀵硅薄
+        trainingContent: "", // 鍩硅鍐呭
+        trainingLecturer: "", // 鍩硅璁插笀
+        projectCredits: "", // 椤圭洰瀛﹀垎
+        trainingMode: "", // 鍩硅鏂瑰紡
+        placeTraining: "", // 鍩硅鍦扮偣
+        classHour: "", // 璇炬椂
+      });
+    } else if (type === "edit" && row) {
+      dialogTitle.value = "缂栬緫鍩硅";
+      Object.assign(form.value, {
+        id: row.id,
+        courseCode: row.courseCode, // 璇剧▼缂栧彿
+        trainingDate: row.trainingDate, // 鍩硅鏃ユ湡
+        openingTime: row.openingTime, // 寮�濮嬫椂闂�
+        endTime: row.endTime, // 缁撴潫鏃堕棿
+        trainingObjectives: row.trainingObjectives, // 鍩硅鐩爣
+        participants: row.participants, // 鍙傚姞瀵硅薄
+        trainingContent: row.trainingContent, // 鍩硅鍐呭
+        trainingLecturer: row.trainingLecturer, // 鍩硅璁插笀
+        projectCredits: row.projectCredits, // 椤圭洰瀛﹀垎
+        trainingMode: row.trainingMode, // 鍩硅鏂瑰紡
+        placeTraining: row.placeTraining, // 鍩硅鍦扮偣
+        classHour: row.classHour, // 璇炬椂
+      });
+    }
+    dialogVisible.value = true;
+  };
+
+  // 鏌ョ湅鍩硅璇︽儏
+  const viewKnowledge = row => {
+    currentKnowledge.value = { ...row };
+    viewDialogVisible.value = true;
+  };
+
+  // 鑾峰彇绫诲瀷鏍囩绫诲瀷
+  const getTypeTagType = type => {
+    const typeMap = {
+      杈冨ぇ椋庨櫓: "warning",
+      浣庨闄�: "info",
+      涓�鑸闄�: "info",
+      閲嶅ぇ椋庨櫓: "danger",
+    };
+    return typeMap[type] || "info";
+  };
+
+  // 鑾峰彇鏁堢巼鏍囩绫诲瀷
+  const getEfficiencyTagType = efficiency => {
+    const typeMap = {
+      high: "success",
+      medium: "warning",
+      low: "info",
+    };
+    return typeMap[efficiency] || "info";
+  };
+
+  // 鑾峰彇鏁堢巼鏍囩鏂囨湰
+  const getEfficiencyLabel = efficiency => {
+    const efficiencyMap = {
+      high: "鏄捐憲鎻愬崌",
+      medium: "涓�鑸彁鍗�",
+      low: "杞诲井鎻愬崌",
+    };
+    return efficiencyMap[efficiency] || efficiency;
+  };
+
+  // 鑾峰彇鏁堢巼鎻愬崌鐧惧垎姣�
+  const getEfficiencyScore = efficiency => {
+    const scoreMap = {
+      high: 40,
+      medium: 25,
+      low: 15,
+    };
+    return scoreMap[efficiency] || 0;
+  };
+
+  // 鑾峰彇骞冲潎鑺傜渷鏃堕棿
+  const getTimeSaved = efficiency => {
+    const timeMap = {
+      high: "2-3澶�",
+      medium: "1-2澶�",
+      low: "0.5-1澶�",
+    };
+    return timeMap[efficiency] || "鏈煡";
+  };
+
+  /**
+   * 鑾峰彇琛岀被鍚嶏紝鐢ㄤ簬鍒ゆ柇椋庨櫓绛夌骇鏄惁涓洪噸澶ч闄�
+   * @param row 琛屾暟鎹�
+   * @returns 绫诲悕
+   */
+  const getRowClass = ({ row }) => {
+    if (row.riskLevel === "閲嶅ぇ椋庨櫓") {
+      return "danger-row";
+    }
+    return "";
+  };
+
+  // 鎻愪氦鍩硅琛ㄥ崟
+  const submitForm = async () => {
+    try {
+      await formRef.value.validate();
+      if (dialogType.value === "add") {
+        // 鏂板鍩硅鍙拌处
+        safeTrainingAdd({ ...form.value })
+          .then(res => {
+            if (res.code == 200) {
+              ElMessage.success("娣诲姞鎴愬姛");
+              dialogVisible.value = false;
+              getList();
+            }
+          })
+          .catch(err => {
+            ElMessage.error(err.msg);
+          });
+      } else {
+        // 鏇存柊鍩硅鍙拌处
+        safeTrainingAdd({ ...form.value })
+          .then(res => {
+            if (res.code == 200) {
+              ElMessage.success("鏇存柊鎴愬姛");
+              dialogVisible.value = false;
+              getList();
+            }
+          })
+          .catch(err => {
+            ElMessage.error(err.msg);
+          });
+      }
+    } catch (error) {
+      console.error("琛ㄥ崟楠岃瘉澶辫触:", error);
+    }
+  };
+
+  // 鍒犻櫎鍩硅
+  const handleDelete = () => {
+    if (selectedIds.value.length === 0) {
+      ElMessage.warning("璇烽�夋嫨瑕佸垹闄ょ殑鍩硅");
+      return;
+    }
+
+    ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎", {
+      confirmButtonText: "纭",
+      cancelButtonText: "鍙栨秷",
+      type: "warning",
+    })
+      .then(() => {
+        // console.log(selectedIds.value);
+        safeTrainingDel(selectedIds.value).then(res => {
+          if (res.code == 200) {
+            ElMessage.success("鍒犻櫎鎴愬姛");
+            selectedIds.value = [];
+            getList();
+          }
+        });
+      })
+      .catch(() => {
+        // 鐢ㄦ埛鍙栨秷
+      });
+  };
+
+  const getKnowledgeTypeTagType = val => {
+    const item = knowledgeTypeOptions.value.find(
+      i => String(i.value) === String(val)
+    );
+    return item?.elTagType || "info";
+  };
+  const handleExport = () => {
+    proxy.download(
+      "/knowledgeBase/export",
+      { ...searchForm.value },
+      "鐭ヨ瘑搴�.xlsx"
+    );
+  };
+</script>
+
+<style scoped>
+  .auto-refresh-info {
+    margin-bottom: 15px;
+  }
+
+  .auto-refresh-info .el-alert {
+    border-radius: 8px;
+  }
+
+  .dialog-footer {
+    text-align: right;
+  }
+
+  .knowledge-detail {
+    padding: 20px 0;
+  }
+
+  .detail-title {
+    font-size: 18px;
+    font-weight: bold;
+    color: #303133;
+  }
+
+  .detail-section {
+    margin-top: 24px;
+  }
+
+  .detail-section h4 {
+    margin: 0 0 12px 0;
+    font-size: 16px;
+    font-weight: 600;
+    color: #303133;
+    border-left: 4px solid #409eff;
+    padding-left: 12px;
+  }
+
+  .detail-content {
+    background: #f8f9fa;
+    padding: 16px;
+    border-radius: 6px;
+    line-height: 1.6;
+    color: #606266;
+    white-space: pre-wrap;
+  }
+
+  .key-points {
+    display: flex;
+    flex-wrap: wrap;
+    gap: 8px;
+  }
+
+  .usage-stats {
+    margin-top: 16px;
+  }
+
+  .stat-item {
+    text-align: center;
+    padding: 20px;
+    background: #f8f9fa;
+    border-radius: 8px;
+  }
+
+  .stat-number {
+    font-size: 24px;
+    font-weight: bold;
+    color: #409eff;
+    margin-bottom: 8px;
+  }
+
+  .stat-label {
+    font-size: 14px;
+    color: #909399;
+  }
+
+  :deep(.danger-row td) {
+    color: #e95a66 !important;
+  }
+</style>

--
Gitblit v1.9.3