| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- import { ref, onMounted, onUnmounted } from 'vue';
- import StepLayout from '../../components/step-layout/step-layout.vue';
- import { getStudent } from '../../api/student';
- import { delStudentEducation } from '../../api/studentEducation';
- import { delStudentExperience } from '../../api/studentExperience';
- import { delStudentProject } from '../../api/studentProject';
- export default {
- components: {
- StepLayout
- },
- setup() {
- const educationList = ref([]);
- const workList = ref([]);
- const projectList = ref([]);
- const isEditMode = ref(false);
- const loadData = async () => {
- const userInfo = uni.getStorageSync('userInfo');
- const studentId = userInfo ? userInfo.studentId : null;
- if (!studentId) return;
- try {
- const res = await getStudent(studentId);
- if (res.code === 200 && res.data) {
- educationList.value = res.data.educationList || [];
- workList.value = res.data.experienceList || [];
- projectList.value = res.data.projectList || [];
- }
- } catch (err) {
- console.error('加载经历失败', err);
- }
- };
- onMounted(() => {
- const options = getCurrentPages()[getCurrentPages().length - 1].options;
- if (options && options.editMode === '1') {
- isEditMode.value = true;
- }
- loadData();
- uni.$on('refresh_experience', () => {
- loadData();
- });
- });
- onUnmounted(() => {
- uni.$off('refresh_experience');
- });
- const showModal = ref(false);
- const modalContent = ref('');
- let currentDeleteType = '';
- let currentDeleteId = null;
- const openModal = (type, content, id) => {
- currentDeleteType = type;
- modalContent.value = content;
- currentDeleteId = id;
- showModal.value = true;
- };
- const closeModal = () => {
- showModal.value = false;
- };
- const confirmDelete = async () => {
- uni.showLoading({ title: '删除中...' });
- try {
- if (currentDeleteType === 'education') {
- await delStudentEducation(currentDeleteId);
- } else if (currentDeleteType === 'work') {
- await delStudentExperience(currentDeleteId);
- } else if (currentDeleteType === 'project') {
- await delStudentProject(currentDeleteId);
- }
- uni.showToast({ title: '删除成功', icon: 'success' });
- loadData();
- } catch (err) {
- uni.showToast({ title: '删除失败', icon: 'none' });
- } finally {
- closeModal();
- uni.hideLoading();
- }
- };
- const addEducation = () => { uni.navigateTo({ url: '/pages/experience/add-education' }); };
- const editEducation = (i) => {
- uni.setStorageSync('edit_data_education', educationList.value[i]);
- uni.navigateTo({ url: '/pages/experience/add-education?index=' + i });
- };
- const deleteEducation = (i) => { openModal('education', '确定要删除这段教育经历吗?', educationList.value[i].id); };
- const addWork = () => { uni.navigateTo({ url: '/pages/experience/add-work' }); };
- const editWork = (i) => {
- uni.setStorageSync('edit_data_work', workList.value[i]);
- uni.navigateTo({ url: '/pages/experience/add-work?index=' + i });
- };
- const deleteWork = (i) => { openModal('work', '确定要删除这段工作经历吗?', workList.value[i].id); };
- const addProject = () => { uni.navigateTo({ url: '/pages/experience/add-project' }); };
- const editProject = (i) => {
- uni.setStorageSync('edit_data_project', projectList.value[i]);
- uni.navigateTo({ url: '/pages/experience/add-project?index=' + i });
- };
- const deleteProject = (i) => { openModal('project', '确定要删除这段项目经历吗?', projectList.value[i].id); };
- const goNext = () => {
- const url = isEditMode.value ? '/pages/intention/intention?editMode=1' : '/pages/intention/intention';
- uni.navigateTo({ url });
- };
-
- const goSkip = () => {
- const url = isEditMode.value ? '/pages/intention/intention?editMode=1' : '/pages/intention/intention';
- uni.navigateTo({ url });
- };
- return {
- educationList,
- workList,
- projectList,
- showModal, modalContent, closeModal, confirmDelete,
- addEducation, editEducation, deleteEducation,
- addWork, editWork, deleteWork,
- addProject, editProject, deleteProject,
- goNext, goSkip,
- isEditMode
- };
- }
- }
|