|
@@ -77,15 +77,25 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</v-toolbar>
|
|
|
+ <CtDialog :visible="show" title="请选择要切换的公司账号" :footer="true" widthType="2" @close="show = false" @submit="handleToAnotherEnterpriseSubmit">
|
|
|
+ <v-radio-group v-model="radios">
|
|
|
+ <v-radio v-for="item in enterpriseList" :key="item.enterpriseId" color="primary" :label="item.enterpriseName" :value="item.enterpriseId"></v-radio>
|
|
|
+ </v-radio-group>
|
|
|
+ </CtDialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref } from 'vue'
|
|
|
+import {
|
|
|
+ getUserBindEnterpriseList,
|
|
|
+ getUserRegisterEnterpriseApply
|
|
|
+} from '@/api/personal/user'
|
|
|
+import { computed, ref } from 'vue'
|
|
|
import { getToken } from '@/utils/auth'
|
|
|
-import { useUserStore } from '@/store/user'
|
|
|
-import { useLocaleStore } from '@/store/locale'
|
|
|
-import { useI18n } from '@/hooks/web/useI18n'
|
|
|
+import { useUserStore } from '@/store/user'; const userStore = useUserStore()
|
|
|
+import { useLocaleStore } from '@/store/locale'; const localeStore = useLocaleStore()
|
|
|
+import { useRouter } from 'vue-router'; const router = useRouter()
|
|
|
+import { useI18n } from '@/hooks/web/useI18n'; const { t } = useI18n()
|
|
|
defineOptions({ name: 'personal-navbar' })
|
|
|
|
|
|
defineProps({
|
|
@@ -95,12 +105,6 @@ defineProps({
|
|
|
}
|
|
|
})
|
|
|
|
|
|
-const { t } = useI18n()
|
|
|
-const localeStore = useLocaleStore()
|
|
|
-const userStore = useUserStore()
|
|
|
-
|
|
|
-import { useRouter } from 'vue-router'
|
|
|
-const router = useRouter()
|
|
|
const handleLogoClick = () => { router.push({ path: '/recruit/enterprise'}) }
|
|
|
|
|
|
const handleToPersonalCenter = () => {
|
|
@@ -119,14 +123,20 @@ const handleLogout = async () => {
|
|
|
await userStore.userLogout(2)
|
|
|
router.push({ path: '/login' })
|
|
|
}
|
|
|
+const enterpriseList = ref([])
|
|
|
|
|
|
-const items = ref([
|
|
|
+const menuList = ref([
|
|
|
{ title: t('vipPackage.purchasePackage'), icon: 'mdi-gift-outline', change: () => router.push({ path: '/recruit/enterprise/purchasePackage' }) },
|
|
|
{ title: t('enterprise.personalInformationSettings'), icon: 'mdi-account-cog', change: () => router.push({ path: '/recruit/enterprise/informationSettings' }) },
|
|
|
+ { title: t('setting.switchToOtherCompany'), icon: 'mdi-home-switch', hidden: enterpriseList.value?.length < 2, change: () => handleSwitchToAnotherEnterprise },
|
|
|
+ { title: t('enterprise.registeringNewEnterprise'), icon: 'mdi-home-plus-outline', change: () => handleRegisteringNewEnterprise },
|
|
|
{ title: t('setting.switchToJobSeeker'), icon: 'mdi-swap-horizontal', change: handleLogout },
|
|
|
// { title: t('enterprise.account.myAccount'), icon: 'mdi-account', change: () => router.push({ path: '/recruit/enterprise/myAccount' }) },
|
|
|
{ title: t('setting.logOut'), icon: 'mdi-logout', change: handleLogout }
|
|
|
])
|
|
|
+const items = computed(() => {
|
|
|
+ return menuList.value.filter(item => !item.hidden)
|
|
|
+})
|
|
|
|
|
|
// 企业logo、用户基本信息
|
|
|
let baseInfo = ref(JSON.parse(localStorage.getItem('baseInfo')) || {})
|
|
@@ -142,6 +152,46 @@ const handleChangeLocale = (item) => {
|
|
|
localeStore.setCurrentLocale(item)
|
|
|
location.reload()
|
|
|
}
|
|
|
+
|
|
|
+// 企业相关操作
|
|
|
+const show = ref(false)
|
|
|
+const radios = ref(null)
|
|
|
+
|
|
|
+// 注册新企业
|
|
|
+const handleRegisteringNewEnterprise = async () => {
|
|
|
+ const data = await getUserRegisterEnterpriseApply()
|
|
|
+ const bool = data && Object.keys(data).length // 已经有数据说明已经申请过了
|
|
|
+ const path = bool ? '/recruit/enterprise/register/inReview' : '/recruit/enterprise/register'
|
|
|
+ router.push({ path })
|
|
|
+}
|
|
|
+
|
|
|
+// 切换其他企业
|
|
|
+const handleSwitchToAnotherEnterprise = async () => {
|
|
|
+ if (enterpriseList.value?.length) {
|
|
|
+ if (enterpriseList.value.length > 1) {
|
|
|
+ show.value = true
|
|
|
+ radios.value = enterpriseList.value[0].enterpriseId
|
|
|
+ } else {
|
|
|
+ // 只有一个企业不能切换 只能再注册新的一个
|
|
|
+ handleRegisteringNewEnterprise()
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+// 手动切换企业提交
|
|
|
+const handleToAnotherEnterpriseSubmit = async () => {
|
|
|
+ // 获取企业账号令牌以及企业用户个人信息
|
|
|
+ await userStore.changeRole(radios.value) // enterpriseId
|
|
|
+ router.push({ path: '/recruit/enterprise' })
|
|
|
+ localStorage.setItem('loginType', 'enterprise')
|
|
|
+ // handleSwitchToAnotherEnterprise(radios.value)
|
|
|
+}
|
|
|
+
|
|
|
+// 企业列表
|
|
|
+const getEnterpriseListData = async () => {
|
|
|
+ const data = await getUserBindEnterpriseList() // 申请通过才有数据,否则空数组
|
|
|
+ enterpriseList.value = data || []
|
|
|
+}
|
|
|
+getEnterpriseListData()
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|