Explorar el Código

导入解析简历尝试不得超过5次

lifanagju_citu hace 4 meses
padre
commit
20f0fd9280

+ 68 - 3
src/plugins/dialogExtend/components/infoForm.vue

@@ -22,9 +22,28 @@
         </div>
         <div style="font-size: 14px; color: var(--color-999);">只支持JPG、JPEG、PNG类型的图片,大小不超过20M</div>
       </template>
+      <template #analysis>
+        <div style="text-align: right; width: 100%;">
+          <v-btn variant="text" color="primary" :loading="analyzeLoading" @click="handleImportAttachment">导入简历解析</v-btn>
+        </div>
+      </template>
     </CtForm>
   </div>
   <ImgCropper :visible="isShowCopper" :image="selectPic" :cropBoxResizable="true" @submit="handleHideCopper" :aspectRatio="1 / 1" @close="isShowCopper = false"></ImgCropper>
+  
+  <!-- 选择本地简历 -->
+  <CtDialog
+    :visible="openUploadDialog"
+    :widthType="2"
+    titleClass="text-h6"
+    @close="openUploadDialog = false"
+    title="附件简历上传"
+    @submit="uploadFileSubmit"
+  >
+  <uploadForm ref="uploadFormRef"></uploadForm>
+  <div class="color-warning" style="font-size: 14px;">提示:上传成功后将自动解析,导入解析简历尝试不得超过5次,请确认好简历后上传!</div>
+  </CtDialog>
+  <Loading :visible="analyzeLoading"></Loading>
 </template>
 
 <script setup>
@@ -32,11 +51,18 @@ import { getDict } from '@/hooks/web/useDictionaries'
 defineOptions({name: 'dialogExtend-InfoForm'})
 import { reactive, ref } from 'vue'
 import { checkEmail } from '@/utils/validate'
-import { enterpriseSearchByName } from '@/api/recruit/personal/resume'
+import {
+  resumeParser2,
+  getPersonResumeCv,
+  enterpriseSearchByName,
+  savePersonResumeCv
+} from '@/api/recruit/personal/resume'
 import { getUserAvatar } from '@/utils/avatar'
 import { uploadFile } from '@/api/common'
 import Snackbar from '@/plugins/snackbar'
 import { useI18n } from '@/hooks/web/useI18n'; const { t } = useI18n()
+import uploadForm from './upload.vue'
+// import { analyzeTestData } from './analyzeTestData.js'
 
 const props = defineProps({
   option: {
@@ -79,6 +105,9 @@ const items = ref({
       value: '',
       flexStyle: 'align-center'
     },
+    {
+      slotName: 'analysis',
+    },
     {
       type: 'text',
       key: 'name',
@@ -254,6 +283,7 @@ const openFileInput = () => {
 // 上传头像
 const accept = ['jpg', 'png', 'jpeg']
 const handleUploadFile = async (e) => {
+  console.log('handleUploadFile:', e)
   const file = e.target.files[0]
   if (!file) return
 
@@ -352,6 +382,40 @@ const getQuery = async () => {
   return query
 }
 
+// 填充
+const handleAnalyzeFill = (data) => {
+  const person = data?.person || null
+  if (!person && !Object.keys(person).length) return Snackbar.warning('无可用内容!')
+  if (person.enterpriseName) getEnterpriseData(person.enterpriseName)
+  items.value.options.forEach((e) => {
+    if (person[e.key]) e.value = person[e.key]
+  })
+}
+
+const analyzeLoading = ref(false)
+const uploadFormRef = ref()
+const openUploadDialog = ref(false)
+// 上传附件-提交
+const uploadFileSubmit = async () => {
+  const obj = await uploadFormRef.value.getQuery()
+  if (!obj?.url || !obj?.title) return Snackbar.warning(t('resume.selectResumeToSubmit'))
+  const query = { title: obj.title, url: obj.url }
+  analyzeLoading.value = true
+  await savePersonResumeCv(query)
+  openUploadDialog.value = false
+  const data = await resumeParser2({ fileUrl: obj.url })
+  // const data = JSON.parse(JSON.stringify(analyzeTestData))
+  console.log('resumeParser2:', data)
+  handleAnalyzeFill(data)
+  analyzeLoading.value = false
+}
+
+const handleImportAttachment = async () => {
+  const data = await getPersonResumeCv() // 获取附件
+  if (data?.length >= 5) return Snackbar.warning('导入解析简历尝试不得超过5次!')
+  openUploadDialog.value = true
+}
+
 defineExpose({
   getQuery
 })
@@ -362,8 +426,9 @@ defineExpose({
   width: 80px;
   position: relative;
   cursor: pointer;
-  margin: 32px;
-  margin-right: 40px;
+  // margin: 32px;
+  // margin-right: 40px;
+  margin: 0 40px 0 32px;
   .img {
     width: 100%;
     height: 100%;

+ 85 - 0
src/plugins/dialogExtend/components/upload.vue

@@ -0,0 +1,85 @@
+<template>
+  <div style="width: 100%;">
+    <CtForm ref="formPageRef" :items="items"></CtForm>
+    <div class="color-666 mb-3" style="font-size: 13px;">* 仅支持.doc, .docx, .pdf文件且大小不能超过20MB</div>
+  </div>
+</template>
+
+<script setup>
+defineOptions({name: 'shareJob-form-upload'})
+import { reactive, ref } from 'vue'
+import { useI18n } from '@/hooks/web/useI18n'
+import { uploadFile } from '@/api/common'
+import Snackbar from '@/plugins/snackbar'
+
+const { t }  = useI18n()
+const formPageRef = ref()
+let query = reactive({})
+
+// 上传简历
+const typeList = ['pdf', 'doc', 'docx']
+const handleUpload = async (e) => {
+  const file = e
+  const size = file.size
+  if (size / (1024*1024) > 20) {
+    Snackbar.warning(t('common.fileSizeExceed'))
+    return
+  }
+  const arr = file.name.split('.')
+  if (typeList.indexOf(arr[arr.length - 1]) < 0) {
+    Snackbar.warning(t('common.fileFormatIncorrect'))
+    return
+  }
+  const formData = new FormData()
+  formData.append('file', file)
+  formData.append('path', 'attachment')
+  const { data } = await uploadFile(formData)
+  if (!data) return
+  const urlItem = items.value.options.find(e => e.key === 'url')
+  if (urlItem) urlItem.data = data
+  query.fileName = file.name
+  // const titleItem = items.value.options.find(e => e.key === 'title')
+  // if (titleItem && !titleItem.value) titleItem.value = query.fileName
+}
+
+const items = ref({
+  options: [
+    {
+      type: 'text',
+      key: 'title',
+      value: null,
+      label: '附件简历名称 *',
+      rules: [v => !!v || '请填写附件简历名称']
+    },
+    {
+      type: 'upload',
+      key: 'url',
+      value: null,
+      data: '',
+      label: '附件简历 *',
+      placeholder: '请上传附件简历',
+      accept: '.doc, .docx, .pdf',
+      prependInnerIcon: 'mdi-file-document-outline',
+      rules: [v => !!v || '请上传附件简历'],
+      change: handleUpload
+    }
+  ]
+})
+
+
+const getQuery = async () => {
+  const { valid } = await formPageRef.value.formRef.validate()
+  if (!valid) return
+  const obj = {}
+  items.value.options.forEach(e => {
+    if (Object.prototype.hasOwnProperty.call(e, 'data')) return obj[e.key] = e.data
+    obj[e.key] = e.value
+  })
+  query = Object.assign(query, obj)
+  return query
+}
+
+defineExpose({
+  getQuery
+})
+</script>

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 11 - 0
src/views/recruit/personal/PersonalCenter/resume/analysis/analyzeTestData.js


Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio