feat: 全局获取userinfo、数据持久化、store处理
This commit is contained in:
@ -275,9 +275,9 @@ const getProfileInfo = async () => {
|
||||
let enterprises = data['enterprises'];
|
||||
mobileNumber.value = data['mobile'];
|
||||
accounts.value = enterprises;
|
||||
|
||||
enterpriseStore.setEnterpriseInfo(data);
|
||||
userStore.setUserInfo(data);
|
||||
|
||||
if (enterprises.length > 0) {
|
||||
if (enterprises.length === 1) {
|
||||
await enterpriseStore.updateEnterpriseInfo();
|
||||
|
||||
@ -105,6 +105,8 @@ const okText = computed(() => {
|
||||
});
|
||||
const customerServiceVisible = ref(false);
|
||||
const canAddAccount = computed(() => {
|
||||
if (!enterpriseInfo) return false;
|
||||
|
||||
return enterpriseInfo.sub_account_quota > enterpriseInfo.used_sub_account_count;
|
||||
});
|
||||
|
||||
@ -124,9 +126,11 @@ function handlePageSizeChange(pageSize: number) {
|
||||
|
||||
async function getSubAccount() {
|
||||
const res = await fetchSubAccountPage(params);
|
||||
const { data, total } = res.data;
|
||||
pagination.total = total;
|
||||
data.value = data;
|
||||
const { data, total, code } = res.data;
|
||||
if (code === 200) {
|
||||
pagination.total = total;
|
||||
data.value = data;
|
||||
}
|
||||
}
|
||||
async function handleAddAccount() {
|
||||
if (canAddAccount.value) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<Container title="企业信息" class="container mt-24px">
|
||||
<a-table :columns="columns" :data="data" :pagination="false" class="mt-16px">
|
||||
<a-table :columns="columns" :data="dataSource" :pagination="false" class="mt-16px">
|
||||
<template #info="{ record }">
|
||||
{{ record.name }}
|
||||
</template>
|
||||
@ -11,7 +11,7 @@
|
||||
<Modal v-model:visible="infoVisible" width="480px" title="修改企业名称" :okText="okText" @ok="handleOk">
|
||||
<p class="tips">
|
||||
企业名称只能修改2次,请谨慎操作。<span
|
||||
>(剩余{{ enterpriseInfo.update_name_quota - enterpriseInfo.used_update_name_count }}次)
|
||||
>(剩余{{ enterpriseInfo!.update_name_quota - enterpriseInfo!.used_update_name_count }}次)
|
||||
</span>
|
||||
</p>
|
||||
<a-form
|
||||
@ -54,12 +54,15 @@ const columns = [
|
||||
slotName: 'action',
|
||||
},
|
||||
];
|
||||
const data = ref([enterpriseInfo]);
|
||||
|
||||
const infoVisible = ref(false);
|
||||
const customerServiceVisible = ref(false);
|
||||
|
||||
const dataSource = computed(() => {
|
||||
return enterpriseInfo ? [enterpriseInfo] : [];
|
||||
});
|
||||
const canUpdate = computed(() => {
|
||||
if (!enterpriseInfo) return false;
|
||||
return enterpriseInfo.update_name_quota > enterpriseInfo.used_update_name_count;
|
||||
});
|
||||
|
||||
@ -72,7 +75,7 @@ const okText = computed(() => {
|
||||
|
||||
function handleUpdate() {
|
||||
if (!canUpdate.value) {
|
||||
form.name = enterpriseInfo.name;
|
||||
form.name = enterpriseInfo!.name;
|
||||
}
|
||||
infoVisible.value = true;
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<Container title="个人信息" class="container mt-24px">
|
||||
<a-table :columns="columns" :data="data" :pagination="false" class="mt-16px">
|
||||
<a-table :columns="columns" :data="dataSource" :pagination="false" class="mt-16px">
|
||||
<template #info="{ record }">
|
||||
<div class="pt-3px pb-3px">
|
||||
<a-avatar :image-url="record.head_image" :size="32" />
|
||||
@ -85,7 +85,7 @@ import axios from 'axios';
|
||||
import { useUserStore } from '@/stores';
|
||||
|
||||
const store = useUserStore();
|
||||
const userInfo = store.getUserInfo();
|
||||
const userInfo = store.userInfo;
|
||||
|
||||
const columns = [
|
||||
{
|
||||
@ -97,7 +97,7 @@ const columns = [
|
||||
slotName: 'mobile',
|
||||
},
|
||||
];
|
||||
const data = reactive([userInfo]);
|
||||
|
||||
const infoVisible = ref(false);
|
||||
const imageVisible = ref(false);
|
||||
const mobileVisible = ref(false);
|
||||
@ -108,6 +108,10 @@ const formRef = ref();
|
||||
const isSendCaptcha = ref(false);
|
||||
const uploadInputRef = ref();
|
||||
|
||||
const dataSource = computed(() => {
|
||||
return userInfo ? [userInfo] : [];
|
||||
});
|
||||
|
||||
// 表单校验规则
|
||||
const formRules = {
|
||||
mobile: [
|
||||
|
||||
Reference in New Issue
Block a user