<template>
  <el-dialog v-model="dialogVisible" title="个人信息" width="500px" draggable>
    <div class="flex">
      <span>用户名：{{username}}</span>
      <span style="margin-left: 80px" v-if="username !== 'admin'">调解中心：{{currentTenant}}</span>
    </div>
    <div class="flex">
      <span>手机号：{{userStore.userInfo.phone}}</span>
    </div>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="dialogVisible = false">取消</el-button>
        <el-button type="primary" @click="dialogVisible = false">确认</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script setup>
  import { useUserStore } from '@/stores/modules/user';
  import { computed } from 'vue';

  import { ref } from 'vue';
  const userStore = useUserStore();
  const currentTenant = ref();

  const dialogVisible = ref(false);
  const openDialog = () => {
    dialogVisible.value = true;
  };
  console.log('userStore', userStore.userInfo)
  const username = computed(() => userStore.userInfo?.username);
  if (userStore.userInfo?.tenants && userStore.userInfo?.tenants.length > 0) {
      if (userStore.userInfo?.tenants.length < 2) {
        currentTenant.value = userStore.userInfo?.tenants[0].name;
      } else {
        currentTenant.value = userStore.tenant.name;
      }
    }
  defineExpose({ openDialog });
</script>
