feat: 管理中心路由调整、选择公司逻辑调整
This commit is contained in:
@ -101,14 +101,14 @@
|
||||
v-for="(account, index) in accounts"
|
||||
:key="index"
|
||||
class="account-item"
|
||||
:class="{ selected: selectedAccount === index }"
|
||||
@click="selectAccount(index)"
|
||||
:class="{ selected: selectedAccountIndex === index }"
|
||||
@click="selectAccount(account, index)"
|
||||
>
|
||||
<a-list-item-meta>
|
||||
<template #title>
|
||||
<div style="display: flex; align-items: center; gap: 12px">
|
||||
<a-checkbox :model-value="selectedAccount === index" />
|
||||
<a-typography-text>{{ account.name }}</a-typography-text>
|
||||
<a-checkbox :model-value="selectedAccountIndex === index" />
|
||||
<a-typography-text>{{ account.name || '-' }}</a-typography-text>
|
||||
</div>
|
||||
</template>
|
||||
</a-list-item-meta>
|
||||
@ -124,11 +124,13 @@ import PuzzleVerification from './components/PuzzleVerification.vue';
|
||||
import { fetchLoginCaptCha, fetchAuthorizationsCaptcha, fetchProfileInfo } from '@/api/all/login';
|
||||
import { ref, reactive, onUnmounted, computed } from 'vue';
|
||||
import { useUserStore } from '@/stores';
|
||||
import { useEnterpriseStore } from '@/stores/modules/enterprise';
|
||||
import { handleUserLogin } from '@/utils/user';
|
||||
import router from '@/router';
|
||||
|
||||
const formRef = ref();
|
||||
const userStore = useUserStore();
|
||||
const enterpriseStore = useEnterpriseStore();
|
||||
const countdown = ref(0);
|
||||
let timer = ref();
|
||||
const isLogin = ref(true);
|
||||
@ -138,7 +140,7 @@ const hasGetCode = ref(false);
|
||||
const submitting = ref(false);
|
||||
const hasCheck = ref(false);
|
||||
const mobileNumber = ref('');
|
||||
const selectedAccount = ref(0);
|
||||
const selectedAccountIndex = ref(0);
|
||||
|
||||
const accounts = ref([]);
|
||||
|
||||
@ -199,8 +201,9 @@ const disabledSubmitBtn = computed(() => {
|
||||
return !isFormValid.value;
|
||||
});
|
||||
|
||||
const selectAccount = (index: any) => {
|
||||
selectedAccount.value = index;
|
||||
const selectAccount = (account: any, index: any) => {
|
||||
enterpriseStore.setEnterpriseInfo(account);
|
||||
selectedAccountIndex.value = index;
|
||||
};
|
||||
|
||||
const validateField = (field: string) => {
|
||||
@ -211,8 +214,10 @@ const clearError = (field: string) => {
|
||||
formRef.value.clearValidate(field);
|
||||
};
|
||||
|
||||
const handleOk = () => {
|
||||
const handleOk = async () => {
|
||||
visible.value = false;
|
||||
|
||||
await enterpriseStore.updateEnterpriseInfo();
|
||||
handleUserLogin();
|
||||
};
|
||||
|
||||
@ -259,15 +264,14 @@ const handleVerificationSubmit = async () => {
|
||||
const getProfileInfo = async () => {
|
||||
const { code, data } = await fetchProfileInfo();
|
||||
if (code === 200) {
|
||||
enterpriseStore.setEnterpriseInfo(data);
|
||||
userStore.setUserInfo(data);
|
||||
let enterprises = data['enterprises'];
|
||||
mobileNumber.value = data['mobile'];
|
||||
accounts.value = enterprises;
|
||||
if (enterprises.length > 0) {
|
||||
if (enterprises.length == 1) {
|
||||
|
||||
// let enterprise = enterprises[0];
|
||||
// userStore.setCompanyInfo(enterprise);
|
||||
if (enterprises.length === 1) {
|
||||
await enterpriseStore.updateEnterpriseInfo();
|
||||
handleUserLogin();
|
||||
} else {
|
||||
// 多个企业时候需要弹窗让用户选择企业
|
||||
|
||||
Reference in New Issue
Block a user