|
|
@@ -34,12 +34,16 @@ import { computed } from "vue";
|
|
|
import { useEnterpriseStore } from "@/store/modules/enterprise.store";
|
|
|
import { OfficeBuilding, ArrowDown, Check } from "@element-plus/icons-vue";
|
|
|
|
|
|
+const router = useRouter();
|
|
|
+const route = useRoute();
|
|
|
+
|
|
|
const enterpriseStore = useEnterpriseStore();
|
|
|
|
|
|
const currentEnterprise = computed(() => enterpriseStore.getCurrentEnterprise);
|
|
|
const hasEnterprise = computed(() => enterpriseStore.hasEnterprise);
|
|
|
const enterpriseList = computed(() => enterpriseStore.getEnterpriseList);
|
|
|
|
|
|
+
|
|
|
// 在组件挂载或依赖变化时处理
|
|
|
onMounted(() => {
|
|
|
if (!currentEnterprise.value && hasEnterprise.value && enterpriseList.value.length > 0) {
|
|
|
@@ -55,7 +59,26 @@ onMounted(() => {
|
|
|
// }, { immediate: true });
|
|
|
|
|
|
function handleSwitch(enterpriseId: string) {
|
|
|
- enterpriseStore.setCurrentEnterprise(enterpriseId);
|
|
|
+ const enterprise = enterpriseStore.findEnterpriseById(enterpriseId);
|
|
|
+ if (!enterprise) {
|
|
|
+ ElMessage.error('企业不存在~');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ ElMessageBox.confirm(
|
|
|
+ `切换企业 【${enterprise.name}】,是否继续?`,
|
|
|
+ '确认切换',
|
|
|
+ {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }
|
|
|
+ ).then(() => {
|
|
|
+ enterpriseStore.setCurrentEnterprise(enterpriseId);
|
|
|
+ router.go(0);
|
|
|
+ }).catch(() => {
|
|
|
+ // 用户取消切换
|
|
|
+ });
|
|
|
}
|
|
|
</script>
|
|
|
|