Bläddra i källkod

feat: 选择租户添加二次确认弹窗

qindao 1 år sedan
förälder
incheckning
254148de4a
1 ändrade filer med 26 tillägg och 25 borttagningar
  1. 26 25
      src/layout/components/Header/SwitchTenant.vue

+ 26 - 25
src/layout/components/Header/SwitchTenant.vue

@@ -1,9 +1,9 @@
 <!-- 切换租户 -->
 <template>
-  <div class="switchTenantLable-wrapper" v-if="options.length > 0 && currentRouteName !== 'SystemTenant'">
+  <div class="switchTenantLable-wrapper" v-if="options.length > 0 ">
     <div class="switchTenantLable">选择租户</div>
     <el-tree-select
-      v-model="currentTenant"
+      :model-value="currentTenant"
       :data="options"
       check-strictly
       show-all-levels
@@ -15,6 +15,7 @@
 </template>
 <script lang="ts" setup>
 import { ref, computed, onMounted, watch } from 'vue';
+import { ElMessageBox, ElMessage } from 'element-plus';
 import { useUserStore } from '@/store/modules/user';
 import { queryListTenant } from '@/api/tenant';
 import { useTargetTenantIdSetting } from '@/utils/useTargetTenantIdSetting';
@@ -23,6 +24,7 @@ import { useRoute } from 'vue-router';
 import useMiniMap from '@/views/map-config/mini-map/use-mini-map.ts'
 import router from '@/router';
 
+
 const miniMap = useMiniMap();
 const  {isInConfigEditor}  = miniMap;
 
@@ -47,32 +49,31 @@ onMounted(() => {
   });
 });
 const route = useRoute();
+/* 选择租户添加二次确认弹窗 */
 const handleChange = (targetTenantId: string) => {
-  setValue(targetTenantId);
-  currentTenant.value = Number(targetTenantId);
-  window.location.reload();
-  /**
-   * 如果处于小地图编辑状态,切换租户时候,返回布局列表
-   */
-  if (isInConfigEditor(route.name)) {
-    router.back();
-  }
-  sessionStorage.removeItem('selectCompanyId'); //切换租户的时候,下拉公司列表清空
+  ElMessageBox.confirm('是否切换租户?', '提示', {
+    confirmButtonText: '确定',
+    cancelButtonText: '取消',
+    type: 'warning',
+  }).then(() => {
+    setValue(targetTenantId);
+    currentTenant.value = Number(targetTenantId);
+    window.location.reload();
+    /**
+    * 如果处于小地图编辑状态,切换租户时候,返回布局列表
+    */
+    if (isInConfigEditor(route.name)) {
+      router.back();
+    }
+    sessionStorage.removeItem('selectCompanyId'); //切换租户的时候,下拉公司列表清空
+  }).catch(() => {
+    ElMessage({
+      type: 'info',
+      message: '取消删除',
+    });
+  });
 };
 
-/* 当页面切换至租户管理时,隐藏选择租户下拉选项 */
-const currentRouteName = ref();
-watch(
-  () => route.name,
-  (value) => {
-    if (value) {
-      currentRouteName.value = value
-    }
-  },
-  {
-    immediate: true
-  }
-)
 </script>
 <style scoped>
 .switchTenantLable {