<template>
  <div class="container-box">
    <div class="control-btn" v-if="hasPermisson()">
      <div class="btn" :class="{ 'btn-active': activeName === 'default' }" @click="activeName = 'default'">默认数据</div>
      <div class="btn" :class="{ 'btn-active': activeName === 'show' }" @click="activeName = 'show'">展示数据</div>
    </div>
    <Default class="content-box" v-if="activeName === 'default'" />
    <Show class="content-box" v-else />
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue';
import Default from './components/default/Default.vue';
import Show from './components/show/Show.vue';
import { useUserStore } from '@/store/modules/user';

const userStore = useUserStore();
// const userInfo: object = userStore.getUserInfo || {};

const activeName = ref('default');

const hasPermisson = () => {
  return userStore.checkPermission("question_mock_edit_admin");
};

onMounted(() => {
  hasPermisson();
})

</script>

<style scoped lang="scss">
.container-box {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 90px);
  padding: 21px;
  background-color: rgba(255, 255, 255, 1);
  border-radius: 10px;
}

.control-btn {
  display: flex;
  margin-bottom: 20px;

  .btn {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 188px;
    height: 38px;
    font-size: 14px;
    font-weight: 400;
    color: rgba(0, 0, 0, 0.88);
    border: 1px solid #D9D9D9;
    background: rgba(0, 0, 0, 0.02);
    cursor: pointer;
  }

  :first-child {
    border-radius: 8px 0px 0px 8px;
  }

  :last-child {
    border-radius: 0px 8px 8px 0px;
  }

  .btn-active {
    font-weight: 500;
    color: #1890FF;
    border: 1px solid #1890FF;
    background-color: rgba(24, 144, 255, 0.15);
  }
}

.content-box {
  flex: 1;
}
</style>