Browse Source

附件简历上传

Xiao_123 7 tháng trước cách đây
mục cha
commit
7c10a8db48

+ 1 - 1
src/components/Upload/file.vue

@@ -43,7 +43,7 @@ const handleUploadFile = async (e) => {
   formData.append('file', file)
   const { data } = await uploadFile(formData)
   if (!data) return
-  emits('success', data, arr[0])
+  emits('success', data, arr[0], file.name)
 }
 
 defineExpose({

+ 68 - 10
src/views/recruit/components/message/index.vue

@@ -123,7 +123,24 @@
     </div>
   </div>
 
-  <File ref="uploadFile" @success="handleUploadResume"></File>
+  <!-- 附件上传 -->
+  <CtDialog
+    :visible="showUploadDialog"
+    :widthType="2"
+    :footer="true"
+    title="附件简历上传"
+    titleClass="text-h6"
+    @close="showUploadDialog = false"
+    @submit="handleSubmitAttachment"
+  >
+    <CtForm ref="CtFormRef" :items="formItems">
+      <template #uploadFile="{ item }">
+        <TextInput v-model="item.value" :item="item" @click="openFileInput"></TextInput>
+        <File ref="uploadFile" @success="handleUploadResume"></File>
+      </template>
+    </CtForm>
+    <div class="color-666" style="font-size: 13px;">* 仅支持.doc, .docx, .pdf文件</div>
+  </CtDialog>
 
   <CtDialog :visible="showInvite" :widthType="2" titleClass="text-h6" title="邀请面试" @close="showInvite = false" @submit="handleSubmit">
     <InvitePage v-if="showInvite" ref="inviteRef" :item-data="itemData" :position="positionList"></InvitePage>
@@ -192,10 +209,31 @@ const itemData = ref({})
 const inviteRef = ref()
 
 // 发送简历
-const uploadFile = ref()
 const showResume = ref(false)
 const resumeList = ref([])
 const selectResume = ref(null)
+// 上传附件简历
+const CtFormRef = ref()
+const formItems = ref({
+  options: [
+    {
+      type: 'text',
+      key: 'title',
+      value: '',
+      label: '附件简历名称 *',
+      rules: [v => !!v || '请输入附件简历名称']
+    },
+    {
+      slotName: 'uploadFile',
+      key: 'url',
+      value: '',
+      truthValue: '',
+      label: '点击上传附件简历 *',
+      outline: true,
+      rules: [v => !!v || '请上传您的附件简历']
+    }
+  ]
+})
 
 // 求职者面试列表
 const interview = ref([])
@@ -328,16 +366,29 @@ const handleUpdate = (val) => {
   send(val.value, channelItem.value)
 }
 
+// 选择文件
+const uploadFile = ref()
+const openFileInput = () => {
+  uploadFile.value.trigger()
+}
+
+// 上传附件
+const handleUploadResume = async (url, title, filename) => {
+  const obj = formItems.value.options.find(e => e.key === 'url')
+  obj.value = filename
+  obj.truthValue = url
+}
+
 // 获取简历
+const showUploadDialog = ref(false)
 async function handleSendResume (item) {
   try {
     item.loading = true
-    // showResume.value = true
     // 获取简历列表
     const result = await getPersonResumeCv()
     if (result.length === 0) {
-      Snackbar.error(t('resume.resumeYetSubmit'))
-      uploadFile.value.trigger()
+      Snackbar.warning(t('resume.resumeYetSubmit'))
+      showUploadDialog.value = true
       return
     }
     resumeList.value = result
@@ -360,14 +411,21 @@ async function handleSendResume (item) {
  */
 
 // 没有上传过简历的弹窗上传并发送给对方
-const handleUploadResume = async (url, title) => {
-  if (!url || !title) return
-  await savePersonResumeCv({ title, url })
+const handleSubmitAttachment = async () => {
+  const { valid } = await CtFormRef.value.formRef.validate()
+  if (!valid) return
+  const obj = {}
+  formItems.value.options.forEach(e => {
+    obj[e.key] = e.truthValue || e.value
+  })
+  if (!obj.title || !obj.url) return
+  await savePersonResumeCv(obj)
+  showUploadDialog.value = false
   const text = {
     remark: '发送简历',
     query: {
-      src: url,
-      title
+      src: obj.url,
+      title: obj.title
     },
     type: 1
   }

+ 78 - 12
src/views/recruit/personal/PersonalCenter/resume/attachment/index.vue

@@ -1,11 +1,8 @@
 <template>
-  <div class="resume-box">
+  <div class="resume-box" style="position: relative; height: 100%;">
     <div class="resume-header">
       <div class="resume-title">附件简历</div>
-      <v-btn variant="text" color="primary" prepend-icon="mdi-plus-box" @click="openFileInput">
-        上传
-        <File ref="uploadFile" @success="handleUploadResume"></File>
-      </v-btn>
+      <v-btn variant="text" color="primary" prepend-icon="mdi-plus-box" @click="handleAdd">上传</v-btn>
     </div>
     <p class="font-size-14 color-999">最多只能上传5份附件简历</p>
     <div v-if="attachmentList.length" class="mt-5">
@@ -24,8 +21,26 @@
         </div>
       </div>
     </div>
-    <div v-else class="resumeNoDataText">请上传您的附件简历</div>
+    <div v-else class="resumeNoDataText tips">请上传您的附件简历</div>
   </div>
+
+  <CtDialog
+    :visible="showUploadDialog"
+    :widthType="2"
+    :footer="true"
+    title="附件简历上传"
+    titleClass="text-h6"
+    @close="showUploadDialog = false"
+    @submit="handleSubmit"
+  >
+    <CtForm ref="CtFormRef" :items="formItems">
+      <template #uploadFile="{ item }">
+        <TextInput v-model="item.value" :item="item" @click="openFileInput"></TextInput>
+        <File ref="uploadFile" @success="handleUploadResume"></File>
+      </template>
+    </CtForm>
+    <div class="color-666" style="font-size: 13px;">* 仅支持.doc, .docx, .pdf文件</div>
+  </CtDialog>
 </template>
 
 <script setup>
@@ -34,12 +49,34 @@ import { ref } from 'vue'
 import Snackbar from '@/plugins/snackbar'
 import Confirm from '@/plugins/confirm'
 import { useI18n } from '@/hooks/web/useI18n'
-import { getPersonResumeCv, savePersonResumeCv, deletePersonResumeCv } from '@/api/recruit/personal/resume'
+import { getPersonResumeCv, deletePersonResumeCv, savePersonResumeCv } from '@/api/recruit/personal/resume'
 import { getBlob, saveAs } from '@/utils'
 import { previewFile } from '@/utils'
 
 const { t } = useI18n()
 
+const CtFormRef = ref()
+const formItems = ref({
+  options: [
+    {
+      type: 'text',
+      key: 'title',
+      value: '',
+      label: '附件简历名称 *',
+      rules: [v => !!v || '请输入附件简历名称']
+    },
+    {
+      slotName: 'uploadFile',
+      key: 'url',
+      value: '',
+      truthValue: '',
+      label: '点击上传附件简历 *',
+      outline: true,
+      rules: [v => !!v || '请上传您的附件简历']
+    }
+  ]
+})
+
 // 获取附件
 const attachmentList = ref([])
 const getList = async () => {
@@ -51,16 +88,39 @@ getList()
 // 选择文件
 const uploadFile = ref()
 const openFileInput = () => {
-  if (attachmentList.value.length >= 5) return Snackbar.warning(t('resume.uploadFiveCopies'))
   uploadFile.value.trigger()
 }
 
 // 上传附件
-const handleUploadResume = async (url, title) => {
-  if (!url || !title) return
-  Snackbar.success(t('common.uploadSucMsg'))
-  await savePersonResumeCv({ title, url })
+const handleUploadResume = async (url, title, filename) => {
+  const obj = formItems.value.options.find(e => e.key === 'url')
+  obj.value = filename
+  obj.truthValue = url
+}
+
+const showUploadDialog = ref(false)
+const handleAdd = () => {
+  if (attachmentList.value.length >= 5) return Snackbar.warning(t('resume.uploadFiveCopies'))
+  formItems.value.options.forEach(e => {
+    e.value = ''
+    e.truthValue = ''
+  })
+  showUploadDialog.value = true
+}
+
+// 上传附件
+const handleSubmit = async () => {
+  const { valid } = await CtFormRef.value.formRef.validate()
+  if (!valid) return
+  const obj = {}
+  formItems.value.options.forEach(e => {
+    obj[e.key] = e.truthValue || e.value
+  })
+  if (!obj.title || !obj.url) return
+  await savePersonResumeCv(obj)
   getList()
+  showUploadDialog.value = false
+  Snackbar.success(t('common.uploadSucMsg'))
 }
 
 // 删除
@@ -98,4 +158,10 @@ const handleDownload = (k) => {
     color: var(--color-999);
   }
 }
+.tips {
+  position: absolute;
+  top: 50%;
+  left: 50%;
+  transform: translate(-50%, -50%);
+}
 </style>

+ 68 - 27
src/views/recruit/personal/position/components/details.vue

@@ -99,7 +99,23 @@
     </div>
 
     <!-- 简历上传 -->
-    <File ref="uploadFile" @success="handleUploadResume"></File>
+    <CtDialog
+      :visible="showUploadDialog"
+      :widthType="2"
+      :footer="true"
+      title="附件简历上传"
+      titleClass="text-h6"
+      @close="showUploadDialog = false"
+      @submit="handleUploadSubmit"
+    >
+      <CtForm ref="CtFormRef" :items="formItems">
+        <template #uploadFile="{ item }">
+          <TextInput v-model="item.value" :item="item" @click="openFileInput"></TextInput>
+          <File ref="uploadFile" @success="handleUploadResume"></File>
+        </template>
+      </CtForm>
+      <div class="color-666" style="font-size: 13px;">* 仅支持.doc, .docx, .pdf文件</div>
+    </CtDialog>
 
     <!-- 选择简历 -->
     <selectResumeDialog v-model="showResume" :list="resumeList" @submit="handleSubmit" @close="handleClose"></selectResumeDialog>
@@ -112,7 +128,6 @@
     >
       <div>
         <div class="mb-3">微信分享:保存图片分享给好友</div>
-        <!-- <div class="mb-3">方式一:保存图片分享给好友</div> -->
         <div class="d-flex align-center flex-column">
           <v-img :src="previewSrc" width="200" height="250"></v-img>
           <div class="mt-5">
@@ -121,13 +136,6 @@
           </div>
         </div>
       </div>
-      <!-- <div class="mt-10">
-        <div class="mb-3">方式二:复制以下链接分享给好友</div>
-        <div class="pa-4" style="background-color: #f0f0f0; border-radius: 8px;">{{ shareUrlTxt }}</div>
-        <div class="text-center">
-          <v-btn class="mt-5 ml-3" color="primary" variant="outlined" v-clipboard="() => shareUrlTxt" @click="copyText">点击复制分享链接</v-btn>
-        </div>
-      </div> -->
       <template #footer>
         <v-divider></v-divider>
         <div>
@@ -178,6 +186,29 @@ const loading = ref(false)
 const showLogin = ref(false)
 const previewSrc = ref('')
 const showPreview = ref(false)
+// 附件简历上传
+const CtFormRef = ref()
+const showUploadDialog = ref(false)
+const formItems = ref({
+  options: [
+    {
+      type: 'text',
+      key: 'title',
+      value: '',
+      label: '附件简历名称 *',
+      rules: [v => !!v || '请输入附件简历名称']
+    },
+    {
+      slotName: 'uploadFile',
+      key: 'url',
+      value: '',
+      truthValue: '',
+      label: '点击上传附件简历 *',
+      outline: true,
+      rules: [v => !!v || '请上传您的附件简历']
+    }
+  ]
+})
 
 const share = ref()
 // 生成图片
@@ -281,15 +312,6 @@ const handleShare = async () => {
   shareDialog.value = true
 }
 
-// 复制分享链接
-// const accessUrl = import.meta.env.VITE_ACCESS_BASE_URL
-// const shareUrlTxt = computed(() => {
-//   return accessUrl + shareUrl.value
-// })
-// const copyText = () => {
-//   Snackbar.success('复制成功')
-// }
-
 // 收藏&取消收藏职位
 const handleCollection = async () => {
   const api = isCollection.value ? getPersonJobUnfavorite : getPersonJobFavorite
@@ -297,18 +319,37 @@ const handleCollection = async () => {
   await getCollectionStatus()
 }
 
-// 投递简历时,若当前用户没有简历列表则弹窗上传简历以及投递
+// 选择文件
 const uploadFile = ref()
-const handleUploadResume = async (url, title) => {
-  if (!url || !title) return
-  // 简历上传
-  await savePersonResumeCv({ title, url })
-  // 简历投递
-  await jobCvRelSend({ jobId: id, title, url, type: info.value.hire ? 1 : 0 })
+const openFileInput = () => {
+  uploadFile.value.trigger()
+}
+
+// 上传附件
+const handleUploadResume = async (url, title, filename) => {
+  const obj = formItems.value.options.find(e => e.key === 'url')
+  obj.value = filename
+  obj.truthValue = url
+}
+
+// 上传附件
+const handleUploadSubmit = async () => {
+  const { valid } = await CtFormRef.value.formRef.validate()
+  if (!valid) return
+  const obj = {}
+  formItems.value.options.forEach(e => {
+    obj[e.key] = e.truthValue || e.value
+  })
+  if (!obj.title || !obj.url) return
+  loading.value = true
+  await savePersonResumeCv(obj)
+  await jobCvRelSend({ jobId: id, title: obj.title, url: obj.url, type: info.value.hire ? 1 : 0 })
+  showUploadDialog.value = false
   setTimeout(() => {
     Snackbar.success(t('resume.deliverySuccess'))
     deliveryCheck()
-  }, 3000)
+    loading.value = false
+  }, 1000)
 }
 
 const showResume = ref(false)
@@ -323,7 +364,7 @@ const handleDelivery = async () => {
   // 没有上传过简历的先去上传
   if (!result.length) {
     Snackbar.warning('您还未上传过简历,请先上传简历')
-    uploadFile.value.trigger()
+    showUploadDialog.value = true
     return
   }
   showResume.value = true

+ 11 - 20
src/views/recruit/personal/shareJob/form/upload.vue

@@ -1,7 +1,7 @@
 <template>
   <div style="width: 100%;">
-    <div class="color-666 mb-3" style="font-size: 13px;">* 仅支持.doc, .docx, .pdf文件</div>
     <CtForm ref="formPageRef" :items="items"></CtForm>
+    <div class="color-666 mb-3" style="font-size: 13px;">* 仅支持.doc, .docx, .pdf文件</div>
   </div>
 </template>
 
@@ -41,31 +41,22 @@ const handleUpload = async (e) => {
 
 const items = ref({
   options: [
-    // {
-    //   type: 'text',
-    //   key: 'name',
-    //   value: '',
-    //   clearable: true,
-    //   label: '姓名 *',
-    //   rules: [v => !!v || '请填写姓名']
-    // },
-    // {
-    //   type: 'phoneNumber',
-    //   key: 'phone',
-    //   value: '',
-    //   clearable: true,
-    //   label: '手机号码 *',
-    //   rules: [v => !!v || '请填写手机号码']
-    // },
+    {
+      type: 'text',
+      key: 'title',
+      value: null,
+      label: '附件简历名称 *',
+      rules: [v => !!v || '请填写附件简历名称']
+    },
     {
       type: 'upload',
       key: 'url',
       value: null,
       data: '',
-      label: '简历 *',
+      label: '附件简历 *',
       accept: '.doc, .docx, .pdf',
-      placeholder: '请上传简历',
-      rules: [v => !!v || '请上传简历'],
+      placeholder: '请上传附件简历',
+      rules: [v => !!v || '请上传附件简历'],
       change: handleUpload
     }
   ]

+ 4 - 4
src/views/recruit/personal/shareJob/sendResume/select.vue

@@ -16,11 +16,11 @@
     titleClass="text-h6"
     submitText="立即投递"
     @close="openUploadDialog = false"
-    title="选择简历"
+    title="附件简历上传"
     @submit="uploadFileSubmit"
   >
   <uploadForm ref="uploadFormRef"></uploadForm>
-  <div class="color-666" style="font-size: 13px;">提示:立即投递会将已上传的简历进行投递</div>
+  <div class="color-warning" style="font-size: 13px;">提示:立即投递会将已上传的简历进行投递</div>
   </CtDialog>
 </template>
 
@@ -73,8 +73,8 @@ const openUploadDialog = ref(false)
 // 上传附件-提交
 const uploadFileSubmit = async () => {
   const obj = await uploadFormRef.value.getQuery()
-  if (!obj?.url || !obj?.fileName) return Snackbar.warning(t('resume.selectResumeToSubmit'))
-  const query = { title: obj.fileName, url: obj.url }
+  if (!obj?.url || !obj?.title) return Snackbar.warning(t('resume.selectResumeToSubmit'))
+  const query = { title: obj.title, url: obj.url }
   await savePersonResumeCv(query)
   handleSubmit(query, '上传的文件提交_直接投递')
 }