<template>
  <div>
    <el-tabs>
      <el-tab-pane v-for="item of tableData" :key="item.id" :label="item.title">
        <ContentWrap>
          <IFrame v-if="!loading" :src="item.url" />
        </ContentWrap>
        <!-- <vue-office-docx :src="item.url" /> -->
      </el-tab-pane>
    </el-tabs>
    <!-- <el-table v-loading="loading" :data="tableData" :stripe="true">
      <el-table-column label="附件名称" align="center" prop="title" />
      <el-table-column label="操作" align="center">
        <template #default="scope">
          <el-link type="primary" download :href="scope.row.url" :underline="false" target="_blank">下载</el-link>
        </template>
      </el-table-column>
    </el-table> -->
  </div>
</template>

<script setup>
defineOptions({ name: 'PersonAttachment' })
import { PersonInfoApi } from '@/api/menduner/system/person'

const loading = ref(false)
const tableData = ref([])
const tableDataTest = [
  {
    id: "1854433786213732353", 
    title: "沈和威-2024-12-02", 
    url: "https://kkfileview.menduner.com//onlinePreview?url=aHR0cHM6Ly9taW5pby5tZW5kdW5lci5jb20vZGV2LzdjZGUyOWRjNjljMTQwMzY0OWJlNTVkNGMyYmZkM2Q4MzA0YzA4OGRjNzlhYjI1YWZlOWM0YmY1NWQzYjM4MmYuZG9jeA%3D%3D", 
    createTime: 1730966443004, 
    updateTime: 1730966443004
  }, 
  {
    id: "1833835593730252802", 
    title: "沈和威-2024-11-15", 
    url: "https://kkfileview.menduner.com//onlinePreview?url=aHR0cHM6Ly9taW5pby5tZW5kdW5lci5jb20vZGV2LzdmM2I1OWNlNzU0ZDQ1MmNlZDQwMDkxYTYzZDZkYjJlMDhlYThhMjJhMjZiN2U4MWYwM2YxMzNjOTQ3YWZmNTIuZG9jeA%3D%3D", 
    createTime: 1726055451223, 
    updateTime: 1726055451223
  }
]
const total = ref(0)
const queryParams = reactive({
  pageNo: 1,
  pageSize: 5,
})

const getList = async () => {
  loading.value = true
  try {
    // const data = await PersonInfoApi.getPersonAttachmentList(queryParams)
    // tableData.value = data.list
    // total.value = data.total
    tableData.value = tableDataTest.map(e => {
      // if (e.url.startsWith('http://')) {
      //   e.url = e.url.replace('http://', 'https://');
      // }
      return e 
    })
  } finally {
    loading.value = false
  }
}

const { currentRoute } = useRouter() // 路由
const route = useRoute()
const { id, userId } = route.query
if (id) getList()
else {
  const data = localStorage.getItem('resumeParserData') ? JSON.parse(localStorage.getItem('resumeParserData')) : null
  if (data) {
    tableData.value = [{
      id: data.id, 
      url: data.url, 
      title: data.filename, 
    }]
  }
}
</script>
