فهرست منبع

快速填写简易人才信息

lifanagju_citu 10 ماه پیش
والد
کامیت
ca12ebae87

+ 111 - 0
src/views/recruit/enterprise/systemManagement/groupAccount/components/simplePageForm.vue

@@ -0,0 +1,111 @@
+<template>
+  <div style="width: 100%;">
+    <CtForm ref="formPageRef" :items="items"></CtForm>
+  </div>
+</template>
+
+<script setup>
+import { getDict } from '@/hooks/web/useDictionaries'
+defineOptions({name: 'inviteConfirm-simplePageForm'})
+import { reactive, ref, defineExpose } from 'vue'
+
+const formPageRef = ref()
+let query = reactive({})
+
+const items = ref({
+  options: [
+    {
+      type: 'text',
+      key: 'name',
+      value: '',
+      default: null,
+      label: '姓名 *',
+      outlined: true,
+      rules: [v => !!v || '请输入姓名']
+    },
+    {
+      type: 'text',
+      key: 'phone',
+      value: '',
+      clearable: true,
+      label: '联系手机号 *',
+      rules: [v => !!v || '请填写联系手机号']
+    },
+    {
+      type: 'autocomplete',
+      key: 'jobStatus',
+      value: '',
+      default: null,
+      label: '求职状态 *',
+      outlined: true,
+      itemText: 'label',
+      itemValue: 'value',
+      dictTypeName: 'menduner_job_status',
+      rules: [v => !!v || '请选择求职状态'],
+      items: []
+    },
+    {
+      type: 'autocomplete',
+      key: 'expType',
+      value: '',
+      default: null,
+      label: '工作经验 *',
+      outlined: true,
+      itemText: 'label',
+      itemValue: 'value',
+      dictTypeName: 'menduner_exp_type',
+      rules: [v => !!v || '请选择工作经验'],
+      items: []
+    },
+    {
+      type: 'autocomplete',
+      key: 'eduType',
+      value: '',
+      default: null,
+      label: '最高学历 *',
+      outlined: true,
+      itemText: 'label',
+      itemValue: 'value',
+      dictTypeName: 'menduner_education_type',
+      rules: [v => !!v || '请选择最高学历'],
+      items: []
+    },
+  ]
+})
+
+// 获取字典内容
+const getDictData = async (dictTypeName) => {
+  const item = items.value.options.find(e => e.dictTypeName === dictTypeName)
+  if (item) {
+    const { data } = await getDict(dictTypeName)
+    item.items = data
+  }
+}
+
+items.value.options.forEach((e) => {
+  if (e.dictTypeName) getDictData(e.dictTypeName) // 查字典set options
+  // formItems回显
+  // const infoExist = baseInfo.value && Object.keys(baseInfo.value).length
+  // if (infoExist && baseInfo.value[e.key]) e.value = baseInfo.value[e.key]
+  // // 日期相关
+  // if (e.type === 'datepicker') e.value = timesTampChange(e.value).slice(0, 10)
+  // // 所在城市回显
+  // if (infoExist && e.nameKey) e[e.nameKey] = baseInfo.value[e.nameKey]
+})
+
+const getQuery = async () => {
+  const { valid } = await formPageRef.value.formRef.validate()
+  if (!valid) return false
+  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>

+ 94 - 7
src/views/recruit/enterprise/systemManagement/groupAccount/inviteConfirm.vue

@@ -2,14 +2,12 @@
   <div style="background-color: #f0f0f0;">
     <div class="inviteView text-center" :style="{'width': isMobile ? '100%' : '750px'}">
       <div class="invite-title">
-        <!-- 门墩儿直聘用户史迪奇,邀请你加入【门墩儿科技有限公司】的招聘团 -->
-        <!-- 【门墩儿直聘邀请】 -->
         <div style="color: var(--v-primary-base);" class="mb-3">【门墩儿直聘企业邀请】</div>
         <div style="font-size: 24px">
           <span class="color-333">{{ enterpriseInfo.name }}</span>
           <span class="color-333"> 邀请您加入 </span>
           <span class="color-333">{{ enterpriseInfo.enterpriseName }}</span>
-          <!-- <span>的招聘团</span> -->
+          <span>的招聘团</span>
         </div>
       </div>
       <div class="mt-10 d-flex flex-column align-center">
@@ -27,16 +25,35 @@
       </div>
     </div>
   </div>
+  <!-- 快速填写简易人才信息 -->
+  <CtDialog
+    :visible="showSimpleInput"
+    :widthType="2"
+    titleClass="text-h6"
+    title="补充基本信息"
+    @close="showSimpleInput = false"
+    @submit="simpleInfoSubmit"
+  >
+    <simplePageForm ref="formRef"></simplePageForm>
+  </CtDialog>
 </template>
 
 <script setup>
 defineOptions({ name: 'inviteConfirm'})
 import { ref, onMounted } from 'vue'
 import phoneFrom from '@/components/VerificationCode'
-import { useUserStore } from '@/store/user'; const userStore = useUserStore()
+import simplePageForm from './components/simplePageForm.vue'
 import { useRoute } from 'vue-router'; const route = useRoute()
 import { enterpriseInviteRecordConsent, getEnterpriseInfoByCode } from '@/api/recruit/enterprise/enterpriseInvite.js'
 import Snackbar from '@/plugins/snackbar'
+import { getToken, setToken, setRefreshToken } from '@/utils/auth'
+import {
+  smsLogin,
+  getBaseInfo,
+  logout
+} from '@/api/common'
+import { savePersonSimpleInfo } from '@/api/recruit/personal/shareJob'
+
 
 const joinSuccess = ref(false)
 const code = route.query?.code || ''
@@ -50,24 +67,94 @@ onMounted(() => {
 const phoneRef = ref()
 const loginLoading = ref(false)
 
+// 登录
 const handleLogin = async () => {
-  localStorage.removeItem('currentRole')
   const { valid } = await phoneRef.value.phoneForm.validate()
   if (!valid) return
   loginLoading.value = true
   try {
     const params = { ...phoneRef.value.loginData } // 只能验证码登录
-    await userStore.handleSmsLogin(params)
+    const res = await smsLogin(params)
+    setToken(res.accessToken)
+    setRefreshToken(res.refreshToken)
+    localStorage.setItem('loginType', 'personal') // 不存在时刷新会出现重定向,值没有影响
+    getUserBaseInfos(res.userId)
+  } catch (error) {
+    Snackbar.error('加入失败! ' + error)
+  } finally {
+    loginLoading.value = false
+  }
+}
+
+// 查询人才信息
+const showSimpleInput = ref(false)
+const getUserBaseInfos = async (userId) => {
+  loginLoading.value = true
+  try {
+    const data = await getBaseInfo({ userId })
+    console.log('data', data)
+    if (!data) {
+      showSimpleInput.value = true; Snackbar.warning('请先完善个人基本信息')
+      return 
+    }
+    const keyArr = ['name', 'phone', 'jobStatus', 'expType', 'eduType'] // 必填人才信息
+    const simpleInfoReady = Object.keys(data).length && keyArr.every(e => data[e] && data[e] !== 0) // 校验必填人才信息
+    if (!simpleInfoReady) {
+      showSimpleInput.value = true; Snackbar.warning('请先完善个人基本信息')
+      return
+    }
+    join()
+  } catch (error) {
+    logoutFun()
+    Snackbar.error('获取用户信息失败! ' + error)
+  } finally {
+    loginLoading.value = false
+  }
+}
+
+// 调用加入接口
+const join = async () => {
+  loginLoading.value = true
+  try {
     await enterpriseInviteRecordConsent(code)
     joinSuccess.value = true
     Snackbar.success('加入成功')
   } catch (error) {
-    Snackbar.error('加入失败')
+    Snackbar.error('加入失败' + error)
   } finally {
+    logoutFun()
     loginLoading.value = false
   }
 }
 
+const logoutFun = async () => {
+  if (!getToken()) {
+    localStorage.clear()
+    return
+  }
+  try {
+    await logout()
+    localStorage.clear()
+  } catch (error) {
+    console.log('登出失败!', error)
+  }
+}
+logoutFun() // 清除之前的token
+
+// 提交简易人才信息
+const formRef = ref()
+const simpleInfoSubmit = async () => {
+  try {
+    const obj = await formRef.value.getQuery()
+    if (!obj) return
+    await savePersonSimpleInfo(obj)
+    join()
+    showSimpleInput.value = false
+  } catch (error) {
+    console.error('error', error)
+  }
+}
+
 const enterpriseInfo = ref({})
 // 根据邀请码获取企业信息
 const getEnterpriseInfo = async () => {

+ 1 - 1
src/views/recruit/personal/shareJob/form/simpleInfo.vue

@@ -95,7 +95,7 @@ items.value.options.forEach((e) => {
 
 const getQuery = async () => {
   const { valid } = await formPageRef.value.formRef.validate()
-  if (!valid) return
+  if (!valid) return false
   const obj = {}
   items.value.options.forEach(e => {
     if (Object.prototype.hasOwnProperty.call(e, 'data')) return obj[e.key] = e.data

+ 1 - 0
src/views/recruit/personal/shareJob/sendResume/simple.vue

@@ -55,6 +55,7 @@ const formRef = ref()
 const simpleInfoSubmit = async () => {
   try {
     const obj = await formRef.value.getQuery()
+    if (!obj) return
     await savePersonSimpleInfo(obj)
     localStorage.setItem('baseInfo', JSON.stringify(obj))
     openDialog.value = false