简历编辑功能bug修复
This commit is contained in:
@@ -42,9 +42,8 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, inject, watch, ref, onMounted, computed } from 'vue';
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import SelectJobs from '@/components/selectJobs/selectJobs.vue';
|
||||
import { reactive, inject, ref } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import useUserStore from '@/stores/useUserStore';
|
||||
|
||||
const { $api, navTo, navBack, config } = inject('globalFunction');
|
||||
@@ -76,6 +75,7 @@
|
||||
|
||||
// 表单数据
|
||||
const formData = reactive({
|
||||
id: '', // 工作经历ID(编辑时使用)
|
||||
companyName: '',
|
||||
position: '',
|
||||
userId: '', // 将在确认时动态获取
|
||||
@@ -93,15 +93,17 @@
|
||||
pageType.value = options.type;
|
||||
}
|
||||
|
||||
// 如果是编辑模式,解析传递的数据
|
||||
if (options.type === 'edit' && options.data) {
|
||||
// 如果是编辑模式,从本地存储获取数据(避免URL长度限制)
|
||||
if (options.type === 'edit') {
|
||||
try {
|
||||
editData.value = JSON.parse(decodeURIComponent(options.data));
|
||||
console.log('编辑数据:', editData.value);
|
||||
|
||||
// 回显数据到表单
|
||||
if (editData.value) {
|
||||
const storedData = uni.getStorageSync('editWorkExperienceData');
|
||||
if (storedData) {
|
||||
editData.value = storedData;
|
||||
console.log('编辑数据:', editData.value);
|
||||
|
||||
// 回显数据到表单
|
||||
formData.companyName = editData.value.companyName || '';
|
||||
formData.id = editData.value.id || '';
|
||||
formData.position = editData.value.position || '';
|
||||
formData.startDate = editData.value.startDate || '';
|
||||
formData.endDate = editData.value.endDate || '至今';
|
||||
@@ -110,6 +112,9 @@
|
||||
// 同步日期选择器的显示
|
||||
startDate.value = editData.value.startDate || '';
|
||||
endDate.value = editData.value.endDate || '至今';
|
||||
|
||||
// 使用完后清除存储
|
||||
uni.removeStorageSync('editWorkExperienceData');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('解析编辑数据失败:', error);
|
||||
@@ -196,13 +201,16 @@
|
||||
};
|
||||
|
||||
console.log('请求参数:', params);
|
||||
if (pageType.value === 'edit') {
|
||||
params.id = formData.id;
|
||||
}
|
||||
console.log('页面类型:', pageType.value);
|
||||
|
||||
let resData;
|
||||
// 根据页面类型调用不同的接口
|
||||
if (pageType.value === 'edit' && editData.value?.id) {
|
||||
if (pageType.value === 'edit' && formData.id) {
|
||||
// 编辑模式:调用更新接口
|
||||
resData = await $api.createRequest(`/app/userworkexperiences/edit`, {...params, id: editData.value.id}, 'put');
|
||||
resData = await $api.createRequest(`/app/userworkexperiences/edit`, params, 'put');
|
||||
console.log('编辑接口响应:', resData);
|
||||
} else {
|
||||
// 添加模式:调用新增接口
|
||||
|
||||
Reference in New Issue
Block a user