<template>
  <ExcelOperate v-if="loading" />

  <el-button class="page-back" type="primary" size="large" :icon="Back" circle @click="pageBack" />
</template>

<script lang="ts" setup>
import { onMounted, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { getOrderFileById } from '@/api/var'
import { useCommentExcel } from '@/stores/commentExcel'
import ExcelOperate from './components/ExcelOperate/ExcelOperate.vue'
import { Back } from '@element-plus/icons-vue'

const loading = ref(false)
const route = useRoute()
const router = useRouter()
const { setFileInfo } = useCommentExcel()

// 获取文件信息及客户信息
const queryFileInfo = async () => {
  const { data } = await getOrderFileById(route.query.fileId as string)
  setFileInfo(data.result)
  loading.value = true
}

const pageBack = () => {
  router.push('/order/list')
}

onMounted(() => {
  route.query?.fileId && queryFileInfo()
})
</script>
<style lang="scss" scoped>
.page-back {
  position: fixed;
  top: 0px;
  right: 30px;
  z-index: 1001;
}
</style>
