fix: 修复

This commit is contained in:
2025-11-12 19:31:46 +08:00
parent 1468002fe2
commit 967317367c
17 changed files with 1002 additions and 560 deletions

View File

@@ -46,45 +46,103 @@
</template>
<script setup>
import { ref, onMounted } from 'vue';
import { ref, computed, watch } from 'vue';
import SkillWeightPopup from './SkillWeightPopup.vue';
import { getSkillNum, getSkillsHeatAnalysisList } from '@/apiRc/jobSkill.js';
// 技能列表(后续从接口获取)
const skillList = ref([
{
name: '项目管理(PMP)',
weight: '0.98',
tags: ['核心技能', '管理能力'],
currentLevel: 3
const props = defineProps({
// 来自职业推荐 tab 的数据
currentJobSkills: {
type: Array,
default: () => []
},
{
name: '团队领导力',
weight: '0.90',
tags: ['核心技能', '软技能'],
currentLevel: 2
recommendedJobs: {
type: Array,
default: () => []
},
{
name: '云安全架构',
weight: '0.85',
tags: ['技术技能', '网络安全'],
currentLevel: 4
// 来自职业路径 tab 的数据
pathData: {
type: Object,
default: () => ({
start: { title: '', skills: [] },
steps: [],
end: { title: '', skills: [] }
})
},
{
name: '财务预算规划',
weight: '0.60',
tags: ['软技能', '管理能力'],
currentLevel: 1
targetCareer: {
type: String,
default: ''
}
]);
});
// 技能数量
const skillCount = ref(0);
const isLoadingSkillCount = ref(false);
// 技能热度分析列表
const heatAnalysisList = ref([]);
const isLoadingHeatAnalysis = ref(false);
// 综合技能列表(基于前两个 tab 的数据)
const skillList = computed(() => {
const skillMap = new Map();
// 1. 收集当前职位技能(已有技能,权重较低)
props.currentJobSkills.forEach(skill => {
if (skill && skill.trim()) {
const existing = skillMap.get(skill) || { name: skill, weight: 0, tags: [], currentLevel: 0 };
existing.weight = Math.max(existing.weight, 0.3); // 已有技能权重较低
existing.tags.push('当前技能');
skillMap.set(skill, existing);
}
});
// 2. 收集推荐职位的技能(需要发展的技能,权重较高)
props.recommendedJobs.forEach(job => {
if (Array.isArray(job.skills)) {
job.skills.forEach(skill => {
if (skill && skill.trim()) {
const existing = skillMap.get(skill) || { name: skill, weight: 0, tags: [], currentLevel: 0 };
existing.weight = Math.max(existing.weight, 0.7); // 推荐职位技能权重较高
if (!existing.tags.includes('推荐技能')) {
existing.tags.push('推荐技能');
}
skillMap.set(skill, existing);
}
});
}
});
// 3. 收集职业路径中的技能(发展路径技能,权重最高)
const pathSkills = [];
if (props.pathData.start && Array.isArray(props.pathData.start.skills)) {
pathSkills.push(...props.pathData.start.skills);
}
if (Array.isArray(props.pathData.steps)) {
props.pathData.steps.forEach(step => {
if (Array.isArray(step.skills)) {
pathSkills.push(...step.skills);
}
});
}
if (props.pathData.end && Array.isArray(props.pathData.end.skills)) {
pathSkills.push(...props.pathData.end.skills);
}
pathSkills.forEach(skill => {
if (skill && skill.trim()) {
const existing = skillMap.get(skill) || { name: skill, weight: 0, tags: [], currentLevel: 0 };
existing.weight = Math.max(existing.weight, 0.9); // 路径技能权重最高
if (!existing.tags.includes('路径技能')) {
existing.tags.push('路径技能');
}
skillMap.set(skill, existing);
}
});
// 转换为数组并按权重排序
const result = Array.from(skillMap.values())
.map(item => ({
name: item.name,
weight: item.weight.toFixed(2),
tags: [...new Set(item.tags)], // 去重
currentLevel: item.currentLevel || Math.floor(item.weight * 5) + 1 // 根据权重计算等级
}))
.sort((a, b) => parseFloat(b.weight) - parseFloat(a.weight)); // 按权重降序
return result;
});
// 弹出层引用
const skillWeightPopup = ref(null);
@@ -94,52 +152,6 @@ const selectedSkillName = ref('');
const selectedSkillWeight = ref('');
const selectedSkillLevel = ref(0);
// 获取技能数量
async function fetchSkillNum(skillType = null) {
isLoadingSkillCount.value = true;
try {
const response = await getSkillNum({
skillType: skillType
});
skillCount.value = response?.data ?? 0;
} catch (error) {
console.error('获取技能数量失败:', error);
skillCount.value = 0;
} finally {
isLoadingSkillCount.value = false;
}
}
// 获取技能热度分析列表
async function fetchSkillsHeatAnalysis(startDate, endDate) {
isLoadingHeatAnalysis.value = true;
try {
const params = {};
if (startDate) {
params.startDate = startDate;
}
if (endDate) {
params.endDate = endDate;
}
const response = await getSkillsHeatAnalysisList(params);
heatAnalysisList.value = Array.isArray(response?.data) ? response.data : [];
} catch (error) {
console.error('获取技能热度分析失败:', error);
heatAnalysisList.value = [];
} finally {
isLoadingHeatAnalysis.value = false;
}
}
// 获取技能发展数据(从接口获取)
async function getSkillDevelopmentData() {
// TODO: 调用接口获取技能发展数据
// const response = await getSkillDevelopment();
// if (response && response.code === 200) {
// skillList.value = response.data || [];
// }
}
// 处理技能项点击
function handleSkillItemClick(skill) {
selectedSkillName.value = skill.name || '';
@@ -152,27 +164,6 @@ function handleSkillItemClick(skill) {
function handlePopupClose() {
// 可以在这里处理关闭后的逻辑
}
onMounted(() => {
getSkillDevelopmentData();
// 获取技能数量不传skillType获取全部
fetchSkillNum();
// 获取技能热度分析默认查询最近7天
const endDate = new Date();
const startDate = new Date();
startDate.setDate(startDate.getDate() - 7);
const formatDate = (date) => {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
};
fetchSkillsHeatAnalysis(formatDate(startDate), formatDate(endDate));
});
</script>
<style lang="scss" scoped>