index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <!-- -->
  2. <template>
  3. <view>
  4. <resume v-if="showResumeList" resumeAnalysis @submit="handleResumeAnalysis"></resume>
  5. <view v-if="formLIst?.length">
  6. <uni-card v-for="item of formLIst" :key="item.id" :id="item.id">
  7. <uni-section :title="item.text" type="line">
  8. <template v-slot:right>
  9. <view style="color: #e64340;" @click="null">删除</view>
  10. </template>
  11. <avatarEdit v-if="item.path === 'avatarEdit'" ref="componentRef" :id="item.id" :data="item.data" />
  12. <baseInfoEdit v-if="item.path === 'baseInfoEdit'" ref="componentRef" :id="item.id" :data="item.data" />
  13. </uni-section>
  14. </uni-card>
  15. </view>
  16. <view v-else>
  17. <view v-if="loading">加载中...</view>
  18. <view v-else>加载失败</view>
  19. </view>
  20. </view>
  21. </template>
  22. <script setup>
  23. defineOptions({name: 'resumeAnalysis-index'})
  24. // import { saveResumeInfo, resumeParser2 } from '@/api/recruit/personal/resume'
  25. // import { resumeParser2 } from '@/api/recruit/personal/resume'
  26. // import { envObj, baseUrl } from '@/utils/config'
  27. import resume from '../resume/index.vue'
  28. import { ref, shallowRef } from 'vue'
  29. import baseInfoEdit from './components/baseInfoEdit.vue'
  30. import avatarEdit from './components/avatarEdit.vue'
  31. import { data } from './testData.js'
  32. const showResumeList = ref(true)
  33. const handleResumeAnalysis = (url) => {
  34. if (!url) {
  35. return uni.showToast({ icon: 'none', title: '请选择要解析的简历' })
  36. }
  37. showResumeList.value = false
  38. // handleAnalysis(url)
  39. }
  40. const exampleList = {
  41. avatar: { text: '头像', id: 'avatar', path: 'avatarEdit' },
  42. person: { text: '基础信息', id: 'person', path: 'baseInfoEdit' },
  43. advantage: { text: '个人优势', id: 'advantage', path: 'advantage' },
  44. eduList: { text: '教育经历', id: 'eduList', path: '' },
  45. workList: { text: '工作经历', id: 'workList', path: '' },
  46. trainList: { text: '培训经历', id: 'trainList', path: '' },
  47. }
  48. // const del = (item) => {
  49. // Confirm('系统提示', `是否确认删除${item.text}?`).then(async () => {
  50. // formLIst.value = formLIst.value.filter(e => e.id !== item.id)
  51. // })
  52. // }
  53. const resumeTxt = ref([]) // 查看文本信息
  54. const formLIst = shallowRef([])
  55. const transformToLIst = async (result) => {
  56. formLIst.value = []
  57. if (result && Object.keys(result)) {
  58. if (result.resume?.rawText) resumeTxt.value = result.resume.rawText.split('\n') || []
  59. if (result.person?.advantage) result.advantage = result.person.advantage
  60. if (result.person?.avatar) result.avatar = result.person.avatar
  61. // obj
  62. const dealObjKeys = ['avatar', 'person', 'advantage']
  63. dealObjKeys.forEach(key => {
  64. if (result[key]) {
  65. const obj = {...exampleList[key]}
  66. obj.data = result[key]
  67. formLIst.value.push(obj)
  68. }
  69. })
  70. // arr
  71. const dealArrKeys = ['eduList', 'workList', 'trainList']
  72. dealArrKeys.forEach(key => {
  73. if (result[key]?.length) {
  74. for (let index = 0; index < result[key].length; index++) {
  75. const obj = {...exampleList[key]}
  76. obj.id = obj.id + '_' + index
  77. obj.text = result[key].length > 1 ? obj.text + (index+1) : obj.text
  78. obj.data = result[key][index]
  79. formLIst.value.push(obj)
  80. }
  81. }
  82. })
  83. }
  84. console.log('formLIst:', formLIst.value)
  85. }
  86. const result = ref(JSON.parse(JSON.stringify(data)))
  87. const loading = ref(false)
  88. transformToLIst(result.value)
  89. // const handleAnalysis = async (url) => {
  90. // url = decodeURIComponent(url)
  91. // if (!url) return
  92. // showSelect.value = false
  93. // loading.value = true
  94. // // const baseUrl = envObj.previewUrl
  95. // // fileUrl.value = !url.includes('.pdf') ? `${baseUrl}/onlinePreview?url=${encodeURIComponent(Base64.encode(url))}` : url
  96. // try {
  97. // const data = await resumeParser2({ fileUrl: url })
  98. // result.value = data || {}
  99. // await transformToLIst(result.value)
  100. // } catch (error) {
  101. // console.log(error)
  102. // } finally {
  103. // loading.value = false
  104. // }
  105. // }
  106. </script>
  107. <style lang="scss" scoped>
  108. </style>