<template>
  <el-row :gutter="20">
    <el-col :span="24">
      <el-form-item label="上传附件">
        <TableUpload v-model="mergedFiles" is-detail />
      </el-form-item>
    </el-col>
  </el-row>
</template>
<script setup lang="ts">
import { fillFileListMetaInfo, type FileItem } from '@/components/UploadFile'

const props = defineProps({
  dataForm: {
    type: Object,
    default: () => ({})
  }
})

const mergedFiles = ref<FileItem[]>([])

watch(
  () => props.dataForm,
  (form) => {
    const elderFiles = form.elderFiles ? JSON.parse(form.elderFiles) : []
    const custodianFiles = form.custodianFiles ? JSON.parse(form.custodianFiles) : []
    const otherFiles = form.otherFiles ? JSON.parse(form.otherFiles) : []
    mergedFiles.value = [...elderFiles, ...custodianFiles, ...otherFiles]
    fillFileListMetaInfo(mergedFiles.value)
  },
  { immediate: true, deep: true }
)
</script>
