From bd7f920a53ba17016ee4f6324d155eef2bc4cece Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期一, 03 八月 2026 17:00:37 +0800
Subject: [PATCH] feat: 发货信息展示源单号

---
 src/views/safeProduction/safetyTrainingAssessment/index.vue |  935 +++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 823 insertions(+), 112 deletions(-)

diff --git a/src/views/safeProduction/safetyTrainingAssessment/index.vue b/src/views/safeProduction/safetyTrainingAssessment/index.vue
index 8fbfe9b..9daa354 100644
--- a/src/views/safeProduction/safetyTrainingAssessment/index.vue
+++ b/src/views/safeProduction/safetyTrainingAssessment/index.vue
@@ -2,23 +2,14 @@
   <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>
+        <span class="search_title">鍩硅鏃ユ湡锛�</span>
+        <el-date-picker v-model="searchForm.trainingDate"
+                        value-format="YYYY-MM-DD"
+                        format="YYYY-MM-DD"
+                        @change="handleQuery"
+                        type="date"
+                        placeholder="璇烽�夋嫨"
+                        clearable />
         <el-button type="primary"
                    @click="handleQuery"
                    style="margin-left: 10px">
@@ -28,12 +19,24 @@
       <div>
         <el-button type="primary"
                    @click="openForm('add')">鏂板鍩硅</el-button>
+        <el-button type="primary"
+                   @click="opendetail">鍩硅璁板綍</el-button>
         <el-button type="danger"
                    plain
                    @click="handleDelete">鍒犻櫎</el-button>
       </div>
     </div>
     <div class="table_list">
+      <el-tabs v-model="searchForm.state"
+               @tab-click="tabhandleQuery">
+        <el-tab-pane label="鏈紑濮�"
+                     :name="0"></el-tab-pane>
+        <el-tab-pane label="杩涜涓�"
+                     :name="1"></el-tab-pane>
+        <el-tab-pane label="宸茬粨鏉�"
+                     :name="2"></el-tab-pane>
+      </el-tabs>
+      <!-- state	鐘舵��(0锛氭湭寮�濮�1锛氳繘琛屼腑锛�2锛氬凡缁撴潫)	 -->
       <PIMTable rowKey="id"
                 :column="tableColumn"
                 :tableData="tableData"
@@ -43,7 +46,21 @@
                 :tableLoading="tableLoading"
                 @pagination="pagination"
                 :total="page.total"
-                :rowClassName="getRowClass"></PIMTable>
+                :rowClassName="getRowClass">
+        <template #courseCode="{ row }">
+          <el-button v-if="row.courseCode"
+                     type="primary"
+                     link
+                     class="course-code-link"
+                     @click.stop="openCourseDetail(row)">
+            {{ row.courseCode }}
+          </el-button>
+          <span v-else>-</span>
+        </template>
+        <template #signStatus="{ row }">
+          <span class="sign-summary-text">{{ formatSignSummary(row) }}</span>
+        </template>
+      </PIMTable>
     </div>
     <!-- 鏂板/缂栬緫鐭ヨ瘑寮圭獥 -->
     <el-dialog v-model="dialogVisible"
@@ -53,7 +70,8 @@
       <el-form ref="formRef"
                :model="form"
                :rules="rules"
-               label-width="120px">
+               label-position="top"
+               label-width="150px">
         <el-row :gutter="20">
           <el-col :span="12">
             <el-form-item label="鍩硅鏃ユ湡"
@@ -82,6 +100,7 @@
                           prop="openingTime">
               <el-time-picker v-model="form.openingTime"
                               placeholder="璇烽�夋嫨"
+                              style="width: 100%"
                               value-format="HH:mm:ss"
                               format="HH:mm:ss"
                               clearable />
@@ -92,6 +111,7 @@
                           prop="endTime">
               <el-time-picker v-model="form.endTime"
                               placeholder="璇烽�夋嫨"
+                              style="width: 100%"
                               value-format="HH:mm:ss"
                               format="HH:mm:ss"
                               clearable />
@@ -109,8 +129,19 @@
           <el-col :span="12">
             <el-form-item label="鍙傚姞瀵硅薄"
                           prop="participants">
-              <el-input v-model="form.participants"
-                        placeholder="璇疯緭鍏ュ弬鍔犲璞�" />
+              <el-select v-model="participantSelection"
+                         placeholder="璇烽�夋嫨鍙傚姞瀵硅薄"
+                         filterable
+                         multiple
+                         collapse-tags
+                         collapse-tags-tooltip
+                         clearable
+                         style="width: 100%">
+                <el-option v-for="item in userOptions"
+                           :key="item.userId"
+                           :label="getUserLabel(item)"
+                           :value="getUserLabel(item)" />
+              </el-select>
             </el-form-item>
           </el-col>
         </el-row>
@@ -125,19 +156,20 @@
           <el-col :span="12">
             <el-form-item label="鍩硅璁插笀"
                           prop="trainingLecturer">
-              <el-input v-model="form.trainingLecturer"
-                        placeholder="璇疯緭鍏ュ煿璁甯�" />
+              <el-select v-model="form.trainingLecturer"
+                         placeholder="璇烽�夋嫨鍩硅璁插笀"
+                         filterable
+                         clearable
+                         style="width: 100%">
+                <el-option v-for="item in userOptions"
+                           :key="item.userId"
+                           :label="getUserLabel(item)"
+                           :value="getUserLabel(item)" />
+              </el-select>
             </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">
@@ -173,77 +205,277 @@
       </el-form>
       <template #footer>
         <span class="dialog-footer">
-          <el-button @click="dialogVisible = false">鍙栨秷</el-button>
           <el-button type="primary"
                      @click="submitForm">纭畾</el-button>
+          <el-button @click="dialogVisible = false">鍙栨秷</el-button>
+        </span>
+      </template>
+    </el-dialog>
+    <!-- 璇剧▼璇︽儏寮圭獥 -->
+    <el-dialog v-model="courseDetailVisible"
+               title="璇剧▼璇︽儏"
+               width="860px"
+               :close-on-click-modal="false">
+      <div v-loading="courseDetailLoading"
+           class="course-detail">
+        <el-descriptions border
+                         :column="2"
+                         class="course-detail-descriptions">
+          <el-descriptions-item label="璇剧▼缂栧彿">
+            {{ formatDetailValue(courseDetail.courseCode) }}
+          </el-descriptions-item>
+          <el-descriptions-item label="鐘舵��">
+            <el-tag :type="getTrainingStateTagType(courseDetail.state)">
+              {{ getTrainingStateLabel(courseDetail.state) }}
+            </el-tag>
+          </el-descriptions-item>
+          <el-descriptions-item label="鍩硅鏃ユ湡">
+            {{ formatDetailValue(courseDetail.trainingDate) }}
+          </el-descriptions-item>
+          <el-descriptions-item label="鍩硅鏃堕棿">
+            {{ formatTrainingTimeRange(courseDetail) }}
+          </el-descriptions-item>
+          <el-descriptions-item label="鍩硅鐩爣">
+            {{ formatDetailValue(courseDetail.trainingObjectives) }}
+          </el-descriptions-item>
+          <el-descriptions-item label="鍩硅鍐呭">
+            {{ formatDetailValue(courseDetail.trainingContent) }}
+          </el-descriptions-item>
+          <el-descriptions-item label="鍙傚姞瀵硅薄">
+            {{ formatDetailValue(courseDetail.participants) }}
+          </el-descriptions-item>
+          <el-descriptions-item label="鍩硅璁插笀">
+            {{ formatDetailValue(courseDetail.trainingLecturer) }}
+          </el-descriptions-item>
+          <el-descriptions-item label="鍩硅鏂瑰紡">
+            {{ formatDetailValue(getTrainingModeLabel(courseDetail.trainingMode)) }}
+          </el-descriptions-item>
+          <el-descriptions-item label="鍩硅鍦扮偣">
+            {{ formatDetailValue(courseDetail.placeTraining) }}
+          </el-descriptions-item>
+          <el-descriptions-item label="璇炬椂">
+            {{ formatDetailValue(courseDetail.classHour) }}
+          </el-descriptions-item>
+          <el-descriptions-item label="绛惧埌鎯呭喌">
+            {{ formatSignSummary(courseDetail) }}
+          </el-descriptions-item>
+          <el-descriptions-item label="闄勪欢鍒楄〃">
+            <el-button type="primary"
+                       link
+                       :disabled="!courseDetail.id"
+                       @click="openFileDialog(courseDetail)">
+              鏌ョ湅闄勪欢
+            </el-button>
+          </el-descriptions-item>
+        </el-descriptions>
+        <div class="classtitle course-sign-title">绛惧埌鎯呭喌</div>
+        <div class="course-sign-summary">
+          <el-tag type="success">宸茬鍒� {{ getSignedCount(courseDetail) }}</el-tag>
+          <el-tag type="info">鏈鍒� {{ getUnsignedCount(courseDetail) }}</el-tag>
+        </div>
+        <el-table :data="courseSignRows"
+                  border
+                  fit
+                  stripe
+                  empty-text="鏆傛棤鍙傚姞瀵硅薄"
+                  class="course-sign-table">
+          <el-table-column prop="name"
+                           label="濮撳悕"
+                           min-width="140" />
+          <el-table-column prop="phonenumber"
+                           label="鐢佃瘽鍙风爜"
+                           min-width="140" />
+          <el-table-column label="绛惧埌鐘舵��"
+                           width="120">
+            <template #default="scope">
+              <el-tag :type="scope.row.signed ? 'success' : 'info'">
+                {{ scope.row.signed ? "宸茬鍒�" : "鏈鍒�" }}
+              </el-tag>
+            </template>
+          </el-table-column>
+        </el-table>
+      </div>
+      <template #footer>
+        <span class="dialog-footer">
+          <el-button @click="courseDetailVisible = false">鍏抽棴</el-button>
         </span>
       </template>
     </el-dialog>
     <!-- 鏌ョ湅鐭ヨ瘑璇︽儏寮圭獥 -->
     <el-dialog v-model="viewDialogVisible"
-               title="鍩硅璇︽儏"
+               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) }} -->
+        <div class="classtitle">璇剧▼璇︽儏</div>
+        <el-descriptions size="mini"
+                         border
+                         :column="3">
+          <el-descriptions-item label="璇剧▼缂栧彿:">{{ currentKnowledge.courseCode }}</el-descriptions-item>
+          <el-descriptions-item label="鍩硅鍐呭:">{{ currentKnowledge.trainingContent }}</el-descriptions-item>
+          <el-descriptions-item label="鐘舵��:">
+            <el-tag :type="currentKnowledge.status === 0 ? 'success' : (currentKnowledge.status === 1 ? 'success' : 'info')">
+              {{ currentKnowledge.status === 0 ? '鏈紑濮�' : (currentKnowledge.status === 1 ? '杩涜涓�' : '宸茬粨鏉�') }}
             </el-tag>
           </el-descriptions-item>
-          <el-descriptions-item label="鎵�鍦ㄤ綅缃�">
-            {{ currentKnowledge.location }}
+          <el-descriptions-item label="鍩硅璁插笀:">
+            {{ currentKnowledge.trainingLecturer }}
           </el-descriptions-item>
-          <el-descriptions-item label="绠℃帶鎺柦">
-            {{ currentKnowledge.controlMeasures }}
+          <el-descriptions-item label="鍩硅寮�濮嬫椂闂�:">
+            {{ currentKnowledge.trainingDate + ' ' + currentKnowledge.openingTime }}
           </el-descriptions-item>
-          <el-descriptions-item label="搴撳瓨鏁伴噺">
-            {{ currentKnowledge.stockQty }}
+          <el-descriptions-item label="鍩硅缁撴潫鏃堕棿:">
+            {{ currentKnowledge.trainingDate + ' ' + currentKnowledge.endTime }}
           </el-descriptions-item>
-          <el-descriptions-item label="绠℃帶璐d换浜�">
-            {{ currentKnowledge.principalUserId }}
+          <el-descriptions-item label="鍩硅鐩爣:">
+            {{ currentKnowledge.trainingObjectives }}
           </el-descriptions-item>
-          <el-descriptions-item label="璐d换浜鸿仈绯荤數璇�">
-            {{ currentKnowledge.principalMobile }}
+          <el-descriptions-item label="鍙傚姞瀵硅薄:">
+            {{ currentKnowledge.participants }}
           </el-descriptions-item>
-          <el-descriptions-item label="椋庨櫓绛夌骇">
-            <el-tag :type="getTypeTagType(currentKnowledge.riskLevel)">
-              {{ currentKnowledge.riskLevel }}
+          <el-descriptions-item label="鍩硅鏂瑰紡:">
+            <el-tag type="primary">
+              {{ getTrainingModeLabel(currentKnowledge.trainingMode) }}
             </el-tag>
           </el-descriptions-item>
-          <el-descriptions-item label="瑙勬牸 / 椋庨櫓鎻忚堪">
-            {{ currentKnowledge.specInfo }}
+          <el-descriptions-item label="鍩硅鍦扮偣:">
+            {{ currentKnowledge.placeTraining }}
+          </el-descriptions-item>
+          <el-descriptions-item label="璇炬椂:">
+            {{ currentKnowledge.classHour }}
+          </el-descriptions-item>
+          <el-descriptions-item label="鎶ュ悕浜烘暟:">
+            {{ currentKnowledge.nums }}
+          </el-descriptions-item>
+          <el-descriptions-item label="闄勪欢鍒楄〃:">
+            <el-button type="primary"
+                       size="small"
+                       @click="openFileDialog(endform)">闄勪欢鍒楄〃</el-button>
           </el-descriptions-item>
         </el-descriptions>
+        <!-- <el-divider style="margin: 20px 0;" /> -->
+        <div class="classtitle"
+             style="margin-top: 40px;margin-bottom: 30px;">璇剧▼璇勪环</div>
+        <el-form ref="formRef"
+                 :model="form"
+                 :rules="rules"
+                 label-position="top"
+                 label-width="150px">
+          <el-row :gutter="20">
+            <el-col :span="12">
+              <el-form-item label="璇勪环浜�:"
+                            prop="courseCode">
+                <el-input v-model="endform.assessmentUserName"
+                          disabled
+                          placeholder="璇烽�夋嫨璇勪环浜�" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="12">
+              <el-form-item label="璇勪环鏃堕棿:"
+                            prop="trainingDate">
+                <el-date-picker style="width: 100%"
+                                disabled
+                                v-model="endform.assessmentDate"
+                                value-format="YYYY-MM-DD"
+                                format="YYYY-MM-DD"
+                                type="date"
+                                placeholder="璇烽�夋嫨"
+                                clearable />
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row :gutter="20">
+            <el-col :span="12">
+              <el-form-item label="鑰冩牳鏂瑰紡:"
+                            prop="assessmentMethod">
+                <el-input v-model="endform.assessmentMethod"
+                          placeholder="璇烽�夋嫨鑰冩牳鏂瑰紡" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="12">
+              <el-form-item label="鏈璇剧▼缁煎悎璇勪环:"
+                            prop="comprehensiveAssessment">
+                <el-input v-model="endform.comprehensiveAssessment"
+                          placeholder="璇疯緭鍏ユ湰娆¤绋嬬患鍚堣瘎浠�" />
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-form-item label="鍩硅鎽樿:"
+                        prop="trainingAbstract">
+            <el-input v-model="endform.trainingAbstract"
+                      type="textarea"
+                      :rows="2"
+                      placeholder="璇疯緭鍏ュ煿璁憳瑕�" />
+          </el-form-item>
+          <!-- <el-row :gutter="30">
+            <el-col :span="24">
+              <el-form-item label="闄勪欢鏉愭枡锛�"
+                            prop="remark">
+                <el-upload v-model:file-list="fileList"
+                           :action="upload.url"
+                           multiple
+                           ref="fileUpload"
+                           auto-upload
+                           :headers="upload.headers"
+                           :before-upload="handleBeforeUpload"
+                           :on-error="handleUploadError"
+                           :on-success="handleUploadSuccess"
+                           :on-remove="handleRemove">
+                  <el-button type="primary"
+                             v-if="operationType !== 'view'">涓婁紶</el-button>
+                  <template #tip
+                            v-if="operationType !== 'view'">
+                    <div class="el-upload__tip">
+                      鏂囦欢鏍煎紡鏀寔
+                      doc锛宒ocx锛寈ls锛寈lsx锛宲pt锛宲ptx锛宲df锛宼xt锛寈ml锛宩pg锛宩peg锛宲ng锛実if锛宐mp锛宺ar锛寊ip锛�7z
+                    </div>
+                  </template>
+                </el-upload>
+              </el-form-item>
+            </el-col>
+          </el-row> -->
+        </el-form>
+        <div class="classtitle"
+             style="margin-top: 40px;">鑰冩牳鍒楄〃</div>
+        <el-table style="margin-top: 20px;"
+                  :data="endform.safeTrainingDetailsDtoList"
+                  border
+                  fit
+                  stripe
+                  highlight-current-row>
+          <el-table-column prop="nickName"
+                           label="濮撳悕" />
+          <el-table-column prop="phonenumber"
+                           label="鐢佃瘽鍙风爜" />
+          <el-table-column prop="examinationResults"
+                           label="鑰冩牳缁撴灉">
+            <template #default="scope">
+              <el-select v-model="scope.row.examinationResults"
+                         placeholder="璇烽�夋嫨鑰冩牳缁撴灉">
+                <el-option label="鍚堟牸"
+                           value="鍚堟牸" />
+                <el-option label="涓嶅悎鏍�"
+                           value="涓嶅悎鏍�" />
+              </el-select>
+            </template>
+          </el-table-column>
+        </el-table>
       </div>
       <template #footer>
         <span class="dialog-footer">
+          <el-button type="primary"
+                     @click="submitForm2">鎻愪氦</el-button>
           <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="闄勪欢鍒楄〃" />
+    <!--  todo 闄勪欢棰勮鐩稿叧 -->
+    <FileList v-if="fileDialogVisible"  v-model:visible="fileDialogVisible" record-type="safe_training" :record-id="recordId"  />
   </div>
 </template>
 
 <script setup>
   import { Search } from "@element-plus/icons-vue";
-  import FileListDialog from "@/components/Dialog/FileListDialog.vue";
   import {
     onMounted,
     ref,
@@ -265,7 +497,14 @@
     safeTrainingFileListPage,
     safeTrainingFileAdd,
     safeTrainingFileDel,
+    safeTrainingSign,
+    safeTrainingGet,
+    safeTrainingSave,
   } from "@/api/safeProduction/safetyTrainingAssessment.js";
+  import useUserStore from "@/store/modules/user";
+  import dayjs from "dayjs";
+  const userStore = useUserStore();
+  const FileList = defineAsyncComponent(() => import("@/components/Dialog/FileList.vue"));
 
   // 琛ㄥ崟楠岃瘉瑙勫垯
   const rules = {
@@ -280,16 +519,21 @@
       { required: true, message: "璇疯緭鍏ュ煿璁唴瀹�", trigger: "blur" },
     ],
     trainingLecturer: [
-      { required: true, message: "璇疯緭鍏ュ煿璁甯�", trigger: "blur" },
+      { required: true, message: "璇烽�夋嫨鍩硅璁插笀", trigger: "change" },
     ],
     classHour: [{ required: true, message: "璇疯緭鍏ヨ鏃�", trigger: "blur" }],
   };
-
+  const upload = reactive({
+    // 涓婁紶鐨勫湴鍧�
+    url: import.meta.env.VITE_APP_BASE_API + "/file/upload",
+    // 璁剧疆涓婁紶鐨勮姹傚ご閮�
+    headers: { Authorization: "Bearer " + getToken() },
+  });
   // 鍝嶅簲寮忔暟鎹�
   const data = reactive({
     searchForm: {
-      name: "",
-      type: "",
+      trainingDate: "",
+      state: 0,
     },
     tableLoading: false,
     page: {
@@ -308,7 +552,6 @@
       participants: "", // 鍙傚姞瀵硅薄
       trainingContent: "", // 鍩硅鍐呭
       trainingLecturer: "", // 鍩硅璁插笀
-      projectCredits: "", // 椤圭洰瀛﹀垎
       trainingMode: "", // 鍩硅鏂瑰紡
       placeTraining: "", // 鍩硅鍦扮偣
       classHour: "", // 璇炬椂
@@ -342,6 +585,67 @@
     );
     return item ? item.label : val;
   };
+  const courseDetailVisible = ref(false);
+  const courseDetailLoading = ref(false);
+  const courseDetail = ref({});
+  const formatDetailValue = val =>
+    val === null || val === undefined || val === "" ? "-" : val;
+  const getTrainingStateLabel = val => {
+    const state = Number(val);
+    if (state === 0) return "鏈紑濮�";
+    if (state === 1) return "杩涜涓�";
+    if (state === 2) return "宸茬粨鏉�";
+    return "-";
+  };
+  const getTrainingStateTagType = val => {
+    const state = Number(val);
+    if (state === 0) return "info";
+    if (state === 1) return "success";
+    if (state === 2) return "warning";
+    return "info";
+  };
+  const formatTrainingTimeRange = row => {
+    const start = row?.openingTime || "";
+    const end = row?.endTime || "";
+    if (!start && !end) return "-";
+    return `${start || "-"} - ${end || "-"}`;
+  };
+  const normalizeCourseDetail = (data, row = {}) => ({
+    ...row,
+    ...data,
+    nums: data?.nums ?? row?.nums,
+    safeTrainingDetailsDtoList:
+      data?.safeTrainingDetailsDtoList ?? row?.safeTrainingDetailsDtoList,
+  });
+  const openCourseDetail = row => {
+    if (!row?.id) {
+      return;
+    }
+    courseDetail.value = normalizeCourseDetail(row);
+    courseDetailVisible.value = true;
+    courseDetailLoading.value = true;
+    safeTrainingGet({ id: row.id })
+      .then(res => {
+        if (res.code === 200) {
+          courseDetail.value = normalizeCourseDetail(res.data || {}, row);
+        } else {
+          proxy.$modal.msgError(res.msg || "鏌ヨ璇剧▼璇︽儏澶辫触");
+        }
+      })
+      .catch(err => {
+        proxy.$modal.msgError(err?.msg || "鏌ヨ璇剧▼璇︽儏澶辫触");
+      })
+      .finally(() => {
+        courseDetailLoading.value = false;
+      });
+  };
+  // 鍒囨崲tab鏌ヨ
+  const tabhandleQuery = val => {
+    searchForm.value.state = val.paneName;
+    console.log(searchForm.value.state, "searchForm.value.state");
+
+    handleQuery();
+  };
   // 琛ㄥ崟寮曠敤
   const formRef = ref();
   const riskLevelOptions = ref([
@@ -351,56 +655,96 @@
     { value: "閲嶅ぇ椋庨櫓", label: "閲嶅ぇ椋庨櫓" },
   ]);
 
+  const fileList = ref([]);
+  const getTrainingState = row => {
+    if (row?.state === null || row?.state === undefined || row?.state === "") {
+      return undefined;
+    }
+    return Number(row.state);
+  };
+  const isNotStartedTraining = row => getTrainingState(row) === 0;
+  const isInProgressTraining = row => getTrainingState(row) === 1;
+  const isEndedTraining = row => getTrainingState(row) === 2;
+  const hasKnownTrainingState = row => [0, 1, 2].includes(getTrainingState(row));
+  const signedTrainingIds = ref(new Set());
+  const signingTrainingIds = ref(new Set());
+  const isSignedValue = val => val === true || val === 1 || val === "1";
+  const isCurrentUserSigned = row =>
+    isSignedValue(row?.signed) ||
+    isSignedValue(row?.currentUserSigned) ||
+    signedTrainingIds.value.has(row?.id);
+  const isSigningTraining = row => signingTrainingIds.value.has(row?.id);
+  const setSigningTraining = (id, signing) => {
+    const next = new Set(signingTrainingIds.value);
+    if (signing) {
+      next.add(id);
+    } else {
+      next.delete(id);
+    }
+    signingTrainingIds.value = next;
+  };
+  const markTrainingSigned = id => {
+    const next = new Set(signedTrainingIds.value);
+    next.add(id);
+    signedTrainingIds.value = next;
+  };
+
   // 琛ㄦ牸鍒楅厤缃�
   const tableColumn = ref([
     {
       label: "璇剧▼缂栧彿",
       prop: "courseCode",
-      showOverflowTooltip: true,
+      width: 150,
+      dataType: "slot",
+      slot: "courseCode",
     },
     {
       label: "鍩硅鏃ユ湡",
       prop: "trainingDate",
+      width: 120,
+
       showOverflowTooltip: true,
     },
     {
       label: "寮�濮嬫椂闂�",
       prop: "openingTime",
+      width: 120,
       showOverflowTooltip: true,
     },
     {
       label: "缁撴潫鏃堕棿",
       prop: "endTime",
+      width: 120,
       showOverflowTooltip: true,
     },
     {
       label: "鍩硅鐩爣",
       prop: "trainingObjectives",
+      width: 200,
       showOverflowTooltip: true,
     },
     {
       label: "鍙傚姞瀵硅薄",
       prop: "participants",
+      width: 200,
       showOverflowTooltip: true,
     },
     {
       label: "鍩硅鍐呭",
       prop: "trainingContent",
+      width: 200,
       showOverflowTooltip: true,
     },
     {
       label: "鍩硅璁插笀",
       prop: "trainingLecturer",
-      showOverflowTooltip: true,
-    },
-    {
-      label: "椤圭洰瀛﹀垎",
-      prop: "projectCredits",
+      width: 200,
       showOverflowTooltip: true,
     },
     {
       label: "鍩硅鏂瑰紡",
       prop: "trainingMode",
+      width: 120,
       showOverflowTooltip: true,
       formatData: params => {
         return getTrainingModeLabel(params);
@@ -409,39 +753,80 @@
     {
       label: "鍩硅鍦扮偣",
       prop: "placeTraining",
+      width: 200,
       showOverflowTooltip: true,
     },
     {
       label: "璇炬椂",
       prop: "classHour",
+      width: 120,
       showOverflowTooltip: true,
+    },
+    {
+      label: "绛惧埌鎯呭喌",
+      prop: "nums",
+      width: 170,
+      dataType: "slot",
+      slot: "signStatus",
     },
     {
       dataType: "action",
       label: "鎿嶄綔",
       align: "center",
       fixed: "right",
-      width: 200,
+      width: 220,
       operation: [
+        {
+          name: "绛惧埌",
+          type: "text",
+          show: row => isInProgressTraining(row) && !isCurrentUserSigned(row),
+          disabled: isSigningTraining,
+          loading: isSigningTraining,
+          clickFun: row => {
+            signIn(row);
+          },
+        },
+        {
+          name: "宸茬鍒�",
+          type: "text",
+          show: row => isInProgressTraining(row) && isCurrentUserSigned(row),
+          disabled: true,
+          color: "#909399",
+          clickFun: () => {},
+        },
         {
           name: "缂栬緫",
           type: "text",
+          show: isNotStartedTraining,
           clickFun: row => {
             openForm("edit", row);
           },
         },
         {
           name: "瀵煎嚭",
-          type: "danger",
+          type: "text",
+          show: isEndedTraining,
           clickFun: row => {
             exportKnowledge(row);
           },
+          color: "#C49000",
         },
         {
           name: "闄勪欢",
-          type: "danger",
+          type: "text",
+          show: hasKnownTrainingState,
           clickFun: row => {
-            downLoadFile(row);
+            openFileDialog(row);
+          },
+          color: "#007AFF",
+        },
+
+        {
+          name: "缁撴灉鏄庣粏",
+          type: "text",
+          show: isEndedTraining,
+          clickFun: row => {
+            viewResultDetail(row);
           },
         },
         // {
@@ -455,14 +840,236 @@
     },
   ]);
   const userList = ref([]);
+  const userOptions = computed(() => userList.value || []);
+  const getUserLabel = user => user?.nickName || user?.userName || "";
+  const parseUserNames = val => {
+    if (Array.isArray(val)) {
+      return val.filter(Boolean);
+    }
+    return String(val || "")
+      .split(/[,锛�;锛沒/)
+      .map(item => item.trim())
+      .filter(Boolean);
+  };
+  const getSignedDetailList = row =>
+    Array.isArray(row?.safeTrainingDetailsDtoList)
+      ? row.safeTrainingDetailsDtoList
+      : [];
+  const findUserByName = name =>
+    userList.value.find(user =>
+      [user?.nickName, user?.userName, getUserLabel(user)]
+        .filter(Boolean)
+        .includes(name)
+    );
+  const isSignedDetailMatched = (detail, name) =>
+    [detail?.nickName, detail?.userName].filter(Boolean).includes(name);
+  const getParticipantSignRows = row => {
+    const participantNames = parseUserNames(row?.participants);
+    const signedDetails = getSignedDetailList(row);
+    const usedSignedIndexes = new Set();
+    const rows = participantNames.map(name => {
+      const signedIndex = signedDetails.findIndex(
+        (detail, index) =>
+          !usedSignedIndexes.has(index) && isSignedDetailMatched(detail, name)
+      );
+      const signedDetail = signedIndex >= 0 ? signedDetails[signedIndex] : null;
+      const user = findUserByName(name);
+      if (signedIndex >= 0) {
+        usedSignedIndexes.add(signedIndex);
+      }
+      return {
+        name,
+        phonenumber: signedDetail?.phonenumber || user?.phonenumber || "-",
+        signed: !!signedDetail,
+      };
+    });
+    signedDetails.forEach((detail, index) => {
+      if (usedSignedIndexes.has(index)) {
+        return;
+      }
+      const name =
+        detail?.nickName ||
+        detail?.userName ||
+        (detail?.userId ? `鐢ㄦ埛${detail.userId}` : "");
+      if (!name) {
+        return;
+      }
+      rows.push({
+        name,
+        phonenumber: detail?.phonenumber || "-",
+        signed: true,
+      });
+    });
+    return rows;
+  };
+  const getSignedCount = row => {
+    if (Array.isArray(row?.safeTrainingDetailsDtoList)) {
+      return getParticipantSignRows(row).filter(item => item.signed).length;
+    }
+    return Number(row?.nums || 0);
+  };
+  const getUnsignedCount = row => {
+    const participantCount = parseUserNames(row?.participants).length;
+    if (!participantCount) {
+      return 0;
+    }
+    return Math.max(participantCount - getSignedCount(row), 0);
+  };
+  const formatSignSummary = row =>
+    `宸茬鍒� ${getSignedCount(row)} / 鏈鍒� ${getUnsignedCount(row)}`;
+  const courseSignRows = computed(() => getParticipantSignRows(courseDetail.value));
+  const participantSelection = computed({
+    get: () => parseUserNames(form.value.participants),
+    set: val => {
+      form.value.participants = (val || []).join(",");
+    },
+  });
   // 鐢熷懡鍛ㄦ湡
   onMounted(() => {
+    getCurrentFactoryName();
     getList();
     startAutoRefresh();
     userListNoPage().then(res => {
-      userList.value = res.data;
+      userList.value = Array.isArray(res.data) ? res.data : [];
     });
   });
+  const endform = ref({
+    assessmentUserId: "", //璇勪环浜�
+    assessmentUserName: "", //璇勪环浜哄鍚�
+    assessmentMethod: "", //鑰冩牳鏂瑰紡
+    assessmentDate: "", //璇勪环鏃堕棿
+    comprehensiveAssessment: "", //缁煎悎璇勪环
+    trainingAbstract: "", //鍩硅鎽樿
+    safeTrainingFileList: [], //鍩硅闄勪欢
+    safeTrainingDetailsDtoList: [], //鑰冩牳缁撴灉璇︽儏
+  });
+  const operationType = ref("edit");
+  const viewResultDetail = row => {
+    // fileList.value = [];
+    operationType.value = "edit";
+    safeTrainingGet({ id: row.id }).then(res => {
+      if (res.code === 200) {
+        console.log(res.data, "res.data");
+        currentKnowledge.value = JSON.parse(JSON.stringify(res.data));
+        currentKnowledge.value.nums = row.nums;
+        viewDialogVisible.value = true;
+        endform.value = { ...res.data };
+        endform.value.assessmentUserName = endform.value.assessmentUserName
+          ? endform.value.assessmentUserName
+          : currentUserName.value;
+        endform.value.assessmentUserId = endform.value.assessmentUserId
+          ? endform.value.assessmentUserId
+          : currentUserId.value;
+        endform.value.assessmentDate = dayjs().format("YYYY-MM-DD");
+      } else {
+        proxy.$modal.msgError(res.msg || "鏌ヨ璇︽儏澶辫触");
+      }
+    });
+  };
+
+  // 涓婁紶鍓嶆牎妫�
+  function handleBeforeUpload(file) {
+    proxy.$modal.loading("姝e湪涓婁紶鏂囦欢锛岃绋嶅��...");
+    return true;
+  }
+  // 涓婁紶澶辫触
+  function handleUploadError(err) {
+    proxy.$modal.msgError("涓婁紶鏂囦欢澶辫触");
+    proxy.$modal.closeLoading();
+  }
+  // 涓婁紶鎴愬姛鍥炶皟
+  function handleUploadSuccess(res, file, uploadFiles) {
+    proxy.$modal.closeLoading();
+    if (res.code === 200) {
+      // 纭繚 tempFileIds 瀛樺湪涓斾负鏁扮粍
+      if (!endform.value.safeTrainingFileList) {
+        endform.value.safeTrainingFileList = [];
+      }
+      endform.value.safeTrainingFileList.push({
+        id: res.data.tempId,
+        fileName: res.data.originalName,
+        url: res.data.tempPath,
+        safeTrainingId: currentKnowledge.value.id,
+      });
+      proxy.$modal.msgSuccess("涓婁紶鎴愬姛");
+    } else {
+      proxy.$modal.msgError(res.msg);
+      proxy.$refs.fileUpload.handleRemove(file);
+    }
+  }
+  // 绉婚櫎鏂囦欢
+  function handleRemove(file) {
+    if (operationType.value === "edit") {
+      let index = endform.value.safeTrainingFileList.findIndex(
+        item => item.fileName === file.name
+      );
+      if (index !== -1) {
+        endform.value.safeTrainingFileList.splice(index, 1);
+      }
+    }
+  }
+  const submitForm2 = () => {
+    endform.value.safeTrainingDetailsDtoList.forEach((item, index) => {
+      if (!item.examinationResults) {
+        proxy.$modal.msgError(`璇烽�夋嫨${item.nickName}鐨勮�冩牳缁撴灉`);
+        return;
+      }
+    });
+    console.log(endform.value, "endform.value");
+    proxy.$modal.loading("姝e湪鎻愪氦锛岃绋嶅��...");
+    safeTrainingSave(endform.value).then(res => {
+      proxy.$modal.closeLoading();
+      if (res.code === 200) {
+        proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+        getList();
+        viewDialogVisible.value = false;
+      } else {
+        proxy.$modal.msgError(res.msg || "鎻愪氦澶辫触");
+      }
+    });
+  };
+  const opendetail = row => {
+    proxy.$router.push({
+      path: "/safeProduction/safetyTrainingAssessmentDetail",
+    });
+  };
+
+  const signIn = row => {
+    if (isCurrentUserSigned(row)) {
+      proxy.$modal.msgWarning("宸茬鍒帮紝璇峰嬁閲嶅绛惧埌");
+      return;
+    }
+    ElMessageBox.confirm("纭绛惧埌鍚楋紵", "鎻愮ず", {
+      confirmButtonText: "纭畾",
+      cancelButtonText: "鍙栨秷",
+      type: "warning",
+    }).then(() => {
+      setSigningTraining(row.id, true);
+      safeTrainingSign({
+        safeTrainingId: row.id,
+        userId: currentUserId.value,
+      }).then(res => {
+        if (res.code === 200) {
+          markTrainingSigned(row.id);
+          row.signed = true;
+          row.currentUserSigned = true;
+          proxy.$modal.msgSuccess("绛惧埌鎴愬姛");
+          getList();
+        } else {
+          if (res.msg?.includes("宸茬鍒�")) {
+            markTrainingSigned(row.id);
+            row.signed = true;
+            row.currentUserSigned = true;
+          }
+          proxy.$modal.msgError(res.msg || "绛惧埌澶辫触");
+        }
+      }).catch(err => {
+        proxy.$modal.msgError(err?.msg || "绛惧埌澶辫触");
+      }).finally(() => {
+        setSigningTraining(row.id, false);
+      });
+    });
+  };
 
   // 澶勭悊鐢ㄦ埛閫夋嫨鍙樺寲
   const handleUserChange = userId => {
@@ -472,22 +1079,17 @@
       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 recordId =ref(0)
+  const fileDialogVisible = ref(false)
+
+  // 鎵撳紑闄勪欢寮规
+  const openFileDialog = async (row) => {
+    recordId.value = row.id
+    fileDialogVisible.value = true
+  }
+  
   // 涓婁紶闄勪欢
   const handleUpload = async () => {
     if (!currentFileRow.value) {
@@ -536,6 +1138,8 @@
               // 閲嶆柊鍔犺浇鏂囦欢鍒楄〃
               const listRes = await safeTrainingFileListPage({
                 safeTrainingId: currentFileRow.value.id,
+                current: filePagination.value.current,
+                size: filePagination.value.size,
               });
               if (listRes.code === 200 && fileListRef.value) {
                 const fileList = (listRes.data?.records || []).map(item => ({
@@ -545,6 +1149,7 @@
                   ...item,
                 }));
                 fileListRef.value.setList(fileList);
+                filePagination.value.total = listRes.data?.total || 0;
               }
               // 杩斿洖鏂版枃浠朵俊鎭�
               resolve({
@@ -572,6 +1177,31 @@
       input.click();
     });
   };
+  const filePagination = ref({
+    current: 1,
+    size: 10,
+    total: 0,
+  });
+  const paginationSearch = async (page, size) => {
+    filePagination.value.current = page;
+    filePagination.value.size = size;
+    const listRes = await safeTrainingFileListPage({
+      safeTrainingId: currentFileRow.value.id,
+      current: filePagination.value.current,
+      size: filePagination.value.size,
+    });
+    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);
+      filePagination.value.total = listRes.data?.total || 0;
+    }
+  };
   // 鍒犻櫎闄勪欢
   const handleFileDelete = async row => {
     try {
@@ -582,6 +1212,8 @@
         if (currentFileRow.value && fileListRef.value) {
           const listRes = await safeTrainingFileListPage({
             safeTrainingId: currentFileRow.value.id,
+            current: filePagination.value.current,
+            size: filePagination.value.size,
           });
           if (listRes.code === 200) {
             const fileList = (listRes.data?.records || []).map(item => ({
@@ -591,6 +1223,7 @@
               ...item,
             }));
             fileListRef.value.setList(fileList);
+            filePagination.value.total = listRes.data?.total || 0;
           }
         }
         return true; // 杩斿洖 true 琛ㄧず鍒犻櫎鎴愬姛锛岀粍浠朵細鏇存柊鍒楄〃
@@ -627,7 +1260,7 @@
         const url = window.URL.createObjectURL(blob);
         const link = document.createElement("a");
         link.href = url;
-        link.download = `鍩硅璁板綍_${row.courseCode}.xlsx`;
+        link.download = `鍩硅璁板綍_${row.courseCode}.docx`;
 
         // 妯℃嫙鐐瑰嚮涓嬭浇
         document.body.appendChild(link);
@@ -651,8 +1284,13 @@
     safeTrainingListPage({ ...page.value, ...searchForm.value })
       .then(res => {
         tableLoading.value = false;
-        tableData.value = res.data.records;
-        page.value.total = res.data.total;
+        const records = res.data?.records || [];
+        tableData.value = records.map(item => ({
+          ...item,
+          currentUserSigned:
+            isSignedValue(item.signed) || signedTrainingIds.value.has(item.id),
+        }));
+        page.value.total = res.data?.total || 0;
       })
       .catch(err => {
         tableLoading.value = false;
@@ -663,12 +1301,19 @@
   const pagination = obj => {
     page.value.current = obj.page;
     page.value.size = obj.limit;
-    handleQuery();
+    getList();
   };
 
   // 閫夋嫨鍙樺寲澶勭悊
   const handleSelectionChange = selection => {
     selectedIds.value = selection.map(item => item.id);
+  };
+  const currentUserId = ref("");
+  const currentUserName = ref("");
+  const getCurrentFactoryName = async () => {
+    let res = await userStore.getInfo();
+    currentUserId.value = res.user.userId;
+    currentUserName.value = res.user.nickName;
   };
 
   // 鎵撳紑琛ㄥ崟
@@ -686,7 +1331,6 @@
         participants: "", // 鍙傚姞瀵硅薄
         trainingContent: "", // 鍩硅鍐呭
         trainingLecturer: "", // 鍩硅璁插笀
-        projectCredits: "", // 椤圭洰瀛﹀垎
         trainingMode: "", // 鍩硅鏂瑰紡
         placeTraining: "", // 鍩硅鍦扮偣
         classHour: "", // 璇炬椂
@@ -703,19 +1347,12 @@
         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;
   };
 
   // 鑾峰彇绫诲瀷鏍囩绫诲瀷
@@ -860,6 +1497,38 @@
 </script>
 
 <style scoped>
+  .search_form {
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+    flex-wrap: wrap;
+    gap: 14px 18px;
+    min-height: 44px;
+    margin-bottom: 18px;
+    padding-bottom: 10px;
+  }
+
+  .search_form > div {
+    display: flex;
+    align-items: center;
+    flex-wrap: wrap;
+    gap: 10px;
+  }
+
+  .search_title {
+    margin-right: 4px;
+    font-weight: 600;
+    white-space: nowrap;
+  }
+
+  .table_list {
+    padding-top: 4px;
+  }
+
+  :deep(.el-tabs__header) {
+    margin-bottom: 16px;
+  }
+
   .auto-refresh-info {
     margin-bottom: 15px;
   }
@@ -936,4 +1605,46 @@
   :deep(.danger-row td) {
     color: #e95a66 !important;
   }
+
+  .course-code-link {
+    padding: 0;
+    font-weight: 600;
+  }
+
+  .sign-summary-text {
+    color: #303133;
+    font-weight: 600;
+  }
+
+  .course-detail {
+    min-height: 220px;
+    padding: 4px 0;
+  }
+
+  .course-detail-descriptions {
+    width: 100%;
+  }
+
+  .course-sign-title {
+    margin-top: 22px;
+  }
+
+  .course-sign-summary {
+    display: flex;
+    gap: 10px;
+    margin-bottom: 12px;
+  }
+
+  .course-sign-table {
+    width: 100%;
+  }
+
+  .classtitle {
+    font-size: 16px;
+    font-weight: 600;
+    color: #303133;
+    border-left: 4px solid #409eff;
+    padding-left: 12px;
+    margin-bottom: 12px;
+  }
 </style>

--
Gitblit v1.9.3