|
|
@@ -46,6 +46,11 @@ export const useEnterpriseStore = defineStore("enterprise", {
|
|
|
if (state.currentEnterprise) {
|
|
|
return state.currentEnterprise;
|
|
|
}
|
|
|
+ // 从sessionStorage获取当前选中的企业
|
|
|
+ const currentEnterpriseJson = sessionStorage.getItem(CURRENT_ENTERPRISE_KEY);
|
|
|
+ if (currentEnterpriseJson) {
|
|
|
+ return JSON.parse(currentEnterpriseJson);
|
|
|
+ }
|
|
|
// 如果没有选中的企业,返回列表中的第一个企业
|
|
|
if (state.enterpriseList && state.enterpriseList.length > 0) {
|
|
|
return state.enterpriseList[0];
|
|
|
@@ -99,8 +104,11 @@ export const useEnterpriseStore = defineStore("enterprise", {
|
|
|
// if (this.currentEnterprise) {
|
|
|
// sessionStorage.setItem(CURRENT_ENTERPRISE_KEY, JSON.stringify(this.currentEnterprise));
|
|
|
// }
|
|
|
- this.currentEnterprise =
|
|
|
+ this.currentEnterprise =
|
|
|
this.enterpriseList.find((e: EnterpriseItem) => e.enterprise_id === enterpriseId) || null;
|
|
|
+ if (this.currentEnterprise) {
|
|
|
+ sessionStorage.setItem(CURRENT_ENTERPRISE_KEY, JSON.stringify(this.currentEnterprise));
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
clearEnterprise() {
|