jinxia.mo 3 недель назад
Родитель
Сommit
b3de45165d
1 измененных файлов с 49 добавлено и 3 удалено
  1. 49 3
      back-ui/src/views/dz/cards/components/CardTable.vue

+ 49 - 3
back-ui/src/views/dz/cards/components/CardTable.vue

@@ -68,9 +68,16 @@
         </el-table-column>
         <el-table-column label="定向" prop="directedStudy" align="center" width="140">
           <template #default="scope">
-            <div v-if="getFirstDirectedStudy(scope.row)" class="cursor-pointer text-blue-500 hover:text-blue-700" @click="handleShowDirectedStudy(scope.row)">
+            <div v-if="getFirstDirectedStudyInfo(scope.row)" class="cursor-pointer text-blue-500 hover:text-blue-700" @click="handleShowDirectedStudy(scope.row)">
               <el-tooltip :content="getFirstDirectedStudy(scope.row)" placement="top" :disabled="!getFirstDirectedStudy(scope.row)">
-                <div class="truncate">{{ getFirstDirectedStudy(scope.row) }}</div>
+                <div class="directed-study-cell">
+                  <div v-if="getFirstDirectedStudyInfo(scope.row).universityName" class="directed-study-line">
+                    {{ getFirstDirectedStudyInfo(scope.row).universityName }}
+                  </div>
+                  <div v-if="getFirstDirectedStudyInfo(scope.row).majorName" class="directed-study-line">
+                    {{ getFirstDirectedStudyInfo(scope.row).majorName }}
+                  </div>
+                </div>
               </el-tooltip>
             </div>
             <span v-else>-</span>
@@ -191,7 +198,7 @@ const getAssignExamType = (row) => {
   return row && row.assignExamType ? row.assignExamType : null;
 };
 
-// 解析directedStudy JSON并获取第一个的显示文本
+// 解析directedStudy JSON并获取第一个的显示文本(用于tooltip)
 const getFirstDirectedStudy = (row) => {
   if (!row || !row.directedStudy) {
     return null;
@@ -218,6 +225,33 @@ const getFirstDirectedStudy = (row) => {
   return null;
 };
 
+// 解析directedStudy JSON并获取第一个的信息对象
+const getFirstDirectedStudyInfo = (row) => {
+  if (!row || !row.directedStudy) {
+    return null;
+  }
+  try {
+    const directedStudy = typeof row.directedStudy === 'string' 
+      ? JSON.parse(row.directedStudy) 
+      : row.directedStudy;
+    
+    if (Array.isArray(directedStudy) && directedStudy.length > 0) {
+      const first = directedStudy[0];
+      const universityName = first?.universityName || '';
+      const majorName = first?.majorName || '';
+      if (universityName || majorName) {
+        return {
+          universityName: universityName,
+          majorName: majorName
+        };
+      }
+    }
+  } catch (e) {
+    console.error('解析directedStudy失败:', e);
+  }
+  return null;
+};
+
 // 获取完整的directedStudy列表
 const getDirectedStudyList = (row) => {
   if (!row || !row.directedStudy) {
@@ -271,4 +305,16 @@ const handleShowDirectedStudy = (row) => {
   top: 0 !important;
   left: 0 !important;
 }
+
+.directed-study-cell {
+  text-align: center;
+  line-height: 1.5;
+}
+
+.directed-study-line {
+  overflow: hidden;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+  font-size: 12px;
+}
 </style>