<template>
  <div>
    <!-- <el-tabs>
      <el-tab-pane v-for="item of tableData" :key="item.id" :label="item.title">
        <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 props = defineProps({
  userId: String
})

const loading = ref(false)
const tableData = ref([
  {
    id: "1854433786213732353", 
    title: "沈和威-13229740092", 
    url: "https://minio.menduner.com/test/person/1/attachment/7cde29dc69c1403649be55d4c2bfd3d8304c088dc79ab25afe9c4bf55d3b382f.docx", 
    createTime: 1730966443004, 
    updateTime: 1730966443004
  }, 
  {
    id: "1854351450755395585", 
    title: "沈和威", 
    url: "https://minio.menduner.com/test/957f8916b9f8e624d9dbe26dd35b31ee44961514e464d413c71419277cbaa38a.pdf", 
    createTime: 1730946812702, 
    updateTime: 1730946812702
  }, 
  {
    id: "1833835593730252802", 
    title: "沈和威2", 
    url: "http://menduner.citupro.com:6868/admin-api/infra/file/24/get/7f3b59ce754d452ced40091a63d6db2e08ea8a22a26b7e81f03f133c947aff52.docx", 
    createTime: 1726055451223, 
    updateTime: 1726055451223
  }
])
const total = ref(0)
const queryParams = reactive({
  pageNo: 1,
  pageSize: 5,
  userId: props.userId
})

const getList = async () => {
  loading.value = true
  try {
    const data = await PersonInfoApi.getPersonAttachmentList(queryParams)
    tableData.value = data.list
    total.value = data.total
  } finally {
    loading.value = false
  }
}
// getList()
</script>
