<template>
    <div>
        <div class="basic-info-title">
            <img src="@/assets/enterpriseLibrary/basic-info.png" alt="文件上传">
            <span>文件上传</span>
        </div>
        <div class="detail-content">
            <el-row :gutter="24">
                <el-col :span="8">
                    <FileOrImageDisplay label="文件上传" :file="form.fileList[0]" :image-url="form.url" />
                </el-col>
            </el-row>
        </div>
    </div>
</template>

<script>

import FileOrImageDisplay from '@/views/common/FileOrImageDisplay.vue';
export default {
    name: 'FileInfoTechnical',
    components: {
        FileOrImageDisplay
    },
    props: {
        detailData: {
            type: Object,
            default: () => { }
        }
    },
    data() {
        return {
            form: {
                fileList: [],
                url: ''
            },
        }
    },
    watch: {
        detailData: {
            handler(newVal) {
                if (Object.keys(newVal).length > 0) {
                    this.setDetailData(newVal)
                }
            },
            immediate: true
        }
    },
    created() {
    },
    methods: {
        setDetailData() {
            const fileList = this.getFileList();
            this.form = {
                fileList: fileList,
                url: fileList[0].filePath
            }
        },
        getFileList() {
            return this.detailData.resourceFileVoList.map(item => {
                return {
                    name: item.fileName,
                    filePath: item.filePath,
                    lsFilePath: item.lsFilePath,
                    fileType: item.fileType,
                    id: item.sourceId + ''
                };
            });
        }
    },

}
</script>

<style scoped lang="scss">
.basic-info-title {
    display: flex;
    align-items: center;
    margin: 10px 0;

    span {
        margin: 0 5px;
        font-size: 20px;
    }
}

.form-item {
    width: 100%;
}
</style>