<template>
  <div class="layout-content" :class="{ preview: previewMode }">
    <div class="layout-body">
      <div class="layout-page">
        <RouterView v-if="!loading" />
        <div v-else class="loading" v-loading="loading" />
      </div>
    </div>
    <UploadList />
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted, watch } from 'vue';
import { getAllDictDataFun, getUserPermissionsFun } from '@/utils/common';
import UploadList from '@/components/common/uploadList/index.vue';
import { useRoute } from 'vue-router';

const route = useRoute();
const previewMode = ref<any>(false);

const loading = ref(true);

watch(
  () => route.path,
  () => {
    previewMode.value = route.path.indexOf('/approvalPreview') > -1;
  },
  { deep: true, immediate: true }
);

onMounted(async () => {
  await getAllDictDataFun();
  getUserPermissionsFun();
  loading.value = false;
});
</script>

<style lang="scss" scoped>
.layout-content {
  width: 100%;
  height: calc(100vh - 104px);
  display: flex;
  &.preview {
    height: 100%;
    .layout-body {
      .layout-page {
        padding: 0;
        .gl-page-content,
        .gl-page-content-full {
          min-width: 0;
        }
      }
    }
  }
  .layout-body {
    flex: 1;
    width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    .layout-page {
      flex: 1;
      width: 100%;
      height: 100%;
      overflow-y: auto;
      background-color: var(--el-bg-color-page);
      padding: 16px;
    }
  }
}
.loading {
  width: 100%;
  height: 100%;
}
</style>
