2025-06-23 05:58:04 -04:00
|
|
|
import { fetchEnterpriseInfo } from '@/api/all/login';
|
|
|
|
|
|
2025-06-20 16:16:17 +08:00
|
|
|
interface EnterpriseInfo {
|
|
|
|
|
id: number;
|
|
|
|
|
name: string;
|
|
|
|
|
update_name_quota: number;
|
|
|
|
|
used_update_name_count: number;
|
|
|
|
|
sub_account_quota: number;
|
|
|
|
|
used_sub_account_count: number;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-20 16:58:03 +08:00
|
|
|
interface EnterpriseState {
|
|
|
|
|
enterpriseInfo: EnterpriseInfo | null;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-20 16:16:17 +08:00
|
|
|
export const useEnterpriseStore = defineStore('enterprise', {
|
2025-06-20 16:58:03 +08:00
|
|
|
state: (): EnterpriseState => ({
|
2025-06-23 05:58:04 -04:00
|
|
|
enterpriseInfo: null,
|
2025-06-20 16:16:17 +08:00
|
|
|
}),
|
|
|
|
|
actions: {
|
|
|
|
|
setEnterpriseInfo(enterpriseInfo: EnterpriseInfo) {
|
2025-06-23 05:58:04 -04:00
|
|
|
console.log('setEnterpriseInfo', enterpriseInfo);
|
2025-06-20 16:16:17 +08:00
|
|
|
this.enterpriseInfo = enterpriseInfo;
|
|
|
|
|
},
|
|
|
|
|
setEnterpriseName(name: string) {
|
2025-06-20 16:58:03 +08:00
|
|
|
if (this.enterpriseInfo) {
|
|
|
|
|
this.enterpriseInfo.name = name;
|
|
|
|
|
}
|
2025-06-20 16:16:17 +08:00
|
|
|
},
|
|
|
|
|
incUsedUpdateNameCount() {
|
2025-06-20 16:58:03 +08:00
|
|
|
if (this.enterpriseInfo) {
|
|
|
|
|
this.enterpriseInfo.used_update_name_count++;
|
|
|
|
|
}
|
2025-06-20 16:16:17 +08:00
|
|
|
},
|
|
|
|
|
incUsedSubAccountCount() {
|
2025-06-20 16:58:03 +08:00
|
|
|
if (this.enterpriseInfo) {
|
|
|
|
|
this.enterpriseInfo.used_sub_account_count++;
|
|
|
|
|
}
|
2025-06-20 16:16:17 +08:00
|
|
|
},
|
2025-06-20 16:58:03 +08:00
|
|
|
getEnterpriseInfo(): EnterpriseInfo | null {
|
2025-06-20 16:16:17 +08:00
|
|
|
return this.enterpriseInfo;
|
|
|
|
|
},
|
2025-06-23 05:58:04 -04:00
|
|
|
async updateEnterpriseInfo() {
|
|
|
|
|
const res = await fetchEnterpriseInfo(this.enterpriseInfo!.id);
|
|
|
|
|
const { code, data } = res;
|
|
|
|
|
if (code === 200) {
|
|
|
|
|
this.setEnterpriseInfo(data);
|
|
|
|
|
}
|
|
|
|
|
},
|
2025-06-20 16:16:17 +08:00
|
|
|
},
|
|
|
|
|
});
|