feat: 管理中心路由调整、选择公司逻辑调整

This commit is contained in:
renxiaodong
2025-06-23 05:58:04 -04:00
parent 7b79443980
commit 82dfa3faeb
11 changed files with 134 additions and 86 deletions

View File

@ -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 {
// 多个企业时候需要弹窗让用户选择企业

View File

@ -4,7 +4,7 @@
<template #info="{ record }">
<div class="pt-3px pb-3px">
<a-avatar :image-url="record.head_image" :size="32" />
{{ record.name }}
{{ record.name || '-' }}
<icon-edit size="13" class="ml-8px" @click="openEditInfoModal" />
</div>
</template>
@ -170,15 +170,17 @@ async function handleFileChange(event: Event) {
const file = target.files?.[0];
if (file) {
const fileExtension = getFileExtension(file.name);
const res = await fetchImageUploadFile({
const { data } = await fetchImageUploadFile({
suffix: fileExtension,
});
const { upload_url, file_name, file_url } = data;
const blob = new Blob([file], { type: file.type });
await axios.put(res.upload_url, blob, {
await axios.put(upload_url, blob, {
headers: { 'Content-Type': file.type },
});
userInfoForm.head_image = res.file_name;
userInfoForm.file_url = res.file_url;
userInfoForm.head_image = file_name;
userInfoForm.file_url = file_url;
}
}
function openEditImageModal() {
@ -191,8 +193,6 @@ function openEditMobileModal() {
async function handleSubmitUserInfo() {
await updateMyInfo(userInfoForm);
store.setUserName(userInfoForm.name);
store.setUserHeadImage(userInfoForm.file_url);
AMessage.success('修改成功!');
}
@ -235,7 +235,6 @@ async function handleUpdateMobile() {
const res = await formRef.value.validate();
if (res === true || res === undefined) {
await updateMobile(form);
store.setUserMobile(form.mobile);
AMessage.success('修改成功!');
}
}