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

@@ -13,7 +13,7 @@
<input
class="input-field"
:value="currentPosition"
placeholder="前端开发工程师"
placeholder="市场专员"
placeholder-style="color: #999999"
disabled
/>
@@ -115,11 +115,21 @@
</template>
<script setup>
import { ref, onMounted } from 'vue';
import { ref, computed, onMounted } from 'vue';
import { getJobPathPage, getJobPathDetail, getJobPathNum } from '@/apiRc/jobPath.js';
// 当前职位(从接口获取,只读)
const currentPosition = ref('前端开发工程师');
// 接收父组件传递的当前职位名称
const props = defineProps({
currentJobName: {
type: String,
default: ''
}
});
const emit = defineEmits(['path-data-updated']);
// 当前职位(从父组件获取,统一使用)
const currentPosition = computed(() => props.currentJobName || '市场专员');
// 目标职业选项列表
const targetCareerOptions = ref([]);
@@ -170,7 +180,9 @@ async function fetchTargetCareerOptions(keyword = '') {
pageNo: 1,
pageSize: 100
});
const list = response?.data?.list || [];
const list = response?.data?.list || response?.list || [];
targetCareerOptions.value = list.map(item => ({
label: item.endJob || item.startJob || '未知职位',
value: item.id,
@@ -184,7 +196,6 @@ async function fetchTargetCareerOptions(keyword = '') {
selectedJobPathId.value = null;
}
} catch (error) {
console.error('获取职业路径列表失败:', error);
targetCareerOptions.value = [];
selectedTargetIndex.value = -1;
selectedJobPathId.value = null;
@@ -200,17 +211,29 @@ async function fetchPathCount() {
const response = await getJobPathNum();
totalPathCount.value = response?.data ?? 0;
} catch (error) {
console.error('获取职业路径数量失败:', error);
totalPathCount.value = 0;
}
}
async function loadPathDetail(jobPathId) {
try {
const response = await getJobPathDetail({
jobPathId
if (!jobPathId || jobPathId === null || jobPathId === undefined || jobPathId === '') {
uni.showToast({
title: '职业路径ID无效',
icon: 'none'
});
resetPathData();
return;
}
try {
const requestParams = {
jobPathId: jobPathId
};
const response = await getJobPathDetail(requestParams);
const details = Array.isArray(response?.data) ? response.data : [];
if (details.length === 0) {
resetPathData();
uni.showToast({
@@ -234,12 +257,22 @@ async function loadPathDetail(jobPathId) {
steps,
end
};
// 通知父组件路径数据已更新
emit('path-data-updated', {
pathData: pathData.value,
targetCareer: targetCareerOptions.value[selectedTargetIndex.value]?.label || ''
});
} catch (error) {
console.error('获取职业路径详情失败:', error);
uni.showToast({
title: '获取路径详情失败',
icon: 'none'
});
resetPathData();
emit('path-data-updated', {
pathData: { ...emptyPathData },
targetCareer: ''
});
}
}
@@ -298,7 +331,6 @@ async function handleQuery() {
selectedJobPathId.value = jobPathId;
await loadPathDetail(jobPathId);
} catch (error) {
console.error('查询职业路径失败:', error);
uni.showToast({
title: '查询失败,请重试',
icon: 'none'