<template>
  <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>
</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([])
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>
