简历编辑功能bug修复
This commit is contained in:
@@ -97,8 +97,8 @@
|
||||
"sdkConfigs" : {
|
||||
"maps" : {
|
||||
"amap" : {
|
||||
"key" : "9cfc9370bd8a941951da1cea0308e9e3",
|
||||
"securityJsCode" : "7b16386c7f744c3ca05595965f2b037f",
|
||||
"key" : "b79ea14cb17704ab1a1a32c12d72f634",
|
||||
"securityJsCode" : "04795ef5b20919d34cadc2e33e01d609",
|
||||
"serviceHost" : ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
const storedData = uni.getStorageSync('editWorkExperienceData');
|
||||
if (storedData) {
|
||||
editData.value = storedData;
|
||||
console.log('编辑数据:', editData.value);
|
||||
|
||||
// 回显数据到表单
|
||||
if (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 {
|
||||
// 添加模式:调用新增接口
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
<dict-Label dictType="area" :value="Number(userInfo.area)"></dict-Label>
|
||||
</view>
|
||||
<view class="mys-list">
|
||||
<view class="cards button-click" v-for="(title, index) in userInfo.jobTitle" :key="index">
|
||||
<view class="cards button-click" v-for="(title, index) in (userInfo.jobTitle || [])" :key="index">
|
||||
{{ title }}
|
||||
</view>
|
||||
</view>
|
||||
@@ -236,9 +236,9 @@ const handleEditOrAdd = () => {
|
||||
|
||||
// 编辑单个经历
|
||||
const handleEditItem = (item) => {
|
||||
// 跳转到编辑页面,传递编辑标识和数据
|
||||
const itemData = encodeURIComponent(JSON.stringify(item));
|
||||
navTo(`/packageA/pages/addWorkExperience/addWorkExperience?type=edit&data=${itemData}`);
|
||||
// 使用本地存储传递数据,避免URL长度限制导致小程序框架报错
|
||||
uni.setStorageSync('editWorkExperienceData', item);
|
||||
navTo('/packageA/pages/addWorkExperience/addWorkExperience?type=edit');
|
||||
};
|
||||
|
||||
// 删除单个经历(带确认弹窗)
|
||||
|
||||
Reference in New Issue
Block a user