Browse Source

refactor(employeeProfile): 优化职业资格证书展示逻辑

调整证书数据的渲染方式,改用label作为循环key避免潜在问题,新增无数据提示,同时重构计算逻辑直接从qualificationData获取时间数据
huoyi 1 month ago
parent
commit
c1b5e150f7
1 changed files with 8 additions and 7 deletions
  1. 8 7
      src/views/portraitManagement/employeeProfile/index.vue

+ 8 - 7
src/views/portraitManagement/employeeProfile/index.vue

@@ -135,9 +135,10 @@
135 135
           </Card>
136 136
           <Card title="职业资格证书获取时间">
137 137
             <div class="cert-info">
138
-              <div class="cert-item" v-for="level in displayQualificationLevels" :key="level.field">
139
-                <span class="cert-name">{{ level.label }}:{{ qualificationData?.[level.field] || '-' }}</span>
138
+              <div class="cert-item" v-for="level in displayQualificationLevels" :key="level.label">
139
+                <span class="cert-name">{{ level.label }}:{{ level.time }}</span>
140 140
               </div>
141
+              <span v-if="displayQualificationLevels.length === 0" class="no-data">暂无证书数据</span>
141 142
             </div>
142 143
           </Card>
143 144
         </div>
@@ -312,11 +313,11 @@ const qualificationLevelMap = [
312 313
 ]
313 314
 
314 315
 const displayQualificationLevels = computed(() => {
315
-  const currentLevel = portrait.value?.qualificationLevelText
316
-  if (!currentLevel) return []
317
-  const currentIndex = qualificationLevelMap.findIndex(l => l.label === currentLevel)
318
-  if (currentIndex === -1) return []
319
-  return qualificationLevelMap.slice(currentIndex)
316
+  if (!qualificationData.value) return []
317
+  return qualificationLevelMap.map(item => ({
318
+    label: item.label,
319
+    time: qualificationData.value[item.field]
320
+  })).filter(item => item.time)
320 321
 })
321 322
 
322 323