123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <!-- -->
- <template>
- <view>
- <resume v-if="showResumeList" resumeAnalysis @submit="handleResumeAnalysis"></resume>
- <view v-if="formLIst?.length">
- <uni-card v-for="item of formLIst" :key="item.id" :id="item.id">
- <uni-section :title="item.text" type="line">
- <template v-slot:right>
- <view style="color: #e64340;" @click="null">删除</view>
- </template>
- <avatarEdit v-if="item.path === 'avatarEdit'" ref="componentRef" :id="item.id" :data="item.data" />
- <baseInfoEdit v-if="item.path === 'baseInfoEdit'" ref="componentRef" :id="item.id" :data="item.data" />
- </uni-section>
- </uni-card>
- </view>
- <view v-else>
- <view v-if="loading">加载中...</view>
- <view v-else>加载失败</view>
- </view>
- </view>
- </template>
- <script setup>
- defineOptions({name: 'resumeAnalysis-index'})
- // import { saveResumeInfo, resumeParser2 } from '@/api/recruit/personal/resume'
- // import { resumeParser2 } from '@/api/recruit/personal/resume'
- // import { envObj, baseUrl } from '@/utils/config'
- import resume from '../resume/index.vue'
- import { ref, shallowRef } from 'vue'
- import baseInfoEdit from './components/baseInfoEdit.vue'
- import avatarEdit from './components/avatarEdit.vue'
- import { data } from './testData.js'
- const showResumeList = ref(true)
- const handleResumeAnalysis = (url) => {
- if (!url) {
- return uni.showToast({ icon: 'none', title: '请选择要解析的简历' })
- }
- showResumeList.value = false
- // handleAnalysis(url)
- }
- const exampleList = {
- avatar: { text: '头像', id: 'avatar', path: 'avatarEdit' },
- person: { text: '基础信息', id: 'person', path: 'baseInfoEdit' },
- advantage: { text: '个人优势', id: 'advantage', path: 'advantage' },
- eduList: { text: '教育经历', id: 'eduList', path: '' },
- workList: { text: '工作经历', id: 'workList', path: '' },
- trainList: { text: '培训经历', id: 'trainList', path: '' },
- }
- // const del = (item) => {
- // Confirm('系统提示', `是否确认删除${item.text}?`).then(async () => {
- // formLIst.value = formLIst.value.filter(e => e.id !== item.id)
- // })
- // }
- const resumeTxt = ref([]) // 查看文本信息
- const formLIst = shallowRef([])
- const transformToLIst = async (result) => {
- formLIst.value = []
- if (result && Object.keys(result)) {
- if (result.resume?.rawText) resumeTxt.value = result.resume.rawText.split('\n') || []
- if (result.person?.advantage) result.advantage = result.person.advantage
- if (result.person?.avatar) result.avatar = result.person.avatar
- // obj
- const dealObjKeys = ['avatar', 'person', 'advantage']
- dealObjKeys.forEach(key => {
- if (result[key]) {
- const obj = {...exampleList[key]}
- obj.data = result[key]
- formLIst.value.push(obj)
- }
- })
- // arr
- const dealArrKeys = ['eduList', 'workList', 'trainList']
- dealArrKeys.forEach(key => {
- if (result[key]?.length) {
- for (let index = 0; index < result[key].length; index++) {
- const obj = {...exampleList[key]}
- obj.id = obj.id + '_' + index
- obj.text = result[key].length > 1 ? obj.text + (index+1) : obj.text
- obj.data = result[key][index]
- formLIst.value.push(obj)
- }
- }
- })
- }
- console.log('formLIst:', formLIst.value)
- }
- const result = ref(JSON.parse(JSON.stringify(data)))
- const loading = ref(false)
- transformToLIst(result.value)
- // const handleAnalysis = async (url) => {
- // url = decodeURIComponent(url)
- // if (!url) return
- // showSelect.value = false
- // loading.value = true
- // // const baseUrl = envObj.previewUrl
- // // fileUrl.value = !url.includes('.pdf') ? `${baseUrl}/onlinePreview?url=${encodeURIComponent(Base64.encode(url))}` : url
- // try {
- // const data = await resumeParser2({ fileUrl: url })
- // result.value = data || {}
- // await transformToLIst(result.value)
- // } catch (error) {
- // console.log(error)
- // } finally {
- // loading.value = false
- // }
- // }
- </script>
- <style lang="scss" scoped>
- </style>
|