<template>
    <div class="basic-info-detail">
        <div class="basic-info-title">
            <img src="@/assets/enterpriseLibrary/legalperson.png" alt="开户证明">
            <span>开户证明</span>
        </div>

        <div class="detail-content">
            <el-row>
                <el-col :span="8">
                    <!-- 开户许可证 -->
                    <FileOrImageDisplay label="开户许可证" :file="form.fileList[0]" :image-url="form.url" />
                </el-col>
            </el-row>
            <el-row :gutter="24">
                <el-col :span="8">
                    <!-- 开户银行 -->
                    <DetailItem label="开户银行" :value="form.openingBank" />
                </el-col>
                <el-col :span="8">
                    <!-- 开户账号 -->
                    <DetailItem label="开户账号" :value="form.openingAccount" />
                </el-col>
            </el-row>
        </div>
    </div>
</template>

<script>
import FileOrImageDisplay from '@/views/common/FileOrImageDisplay.vue';
import DetailItem from '@/views/common/DetailItem.vue';
export default {
    name: 'AccountOpeningCertificateDetail',
    components: {
        FileOrImageDisplay,
        DetailItem
    },
    props: {
        detailData: {
            type: Object,
            default: () => { }
        }
    },
    data() {
        return {
            form:{
                openingBank:'',
                openingAccount:'',
                url:null,
            }
        }
    },
    methods: {
        setDetailData() {
            const fileList = this.getFileList('account_opening_license')
            this.form = {
                openingBank: this.detailData.openingBank,
                openingAccount: this.detailData.openingAccount,
                url:fileList[0]?.fileType === '1'? fileList[0]?.lsFilePath : null,
                fileList:fileList,
            }
        },
        getFileList(businessType){
            return this.detailData.fileList.filter(item => item.businessType === businessType).map(item => {
                return {
                    name: item.fileName,
                    filePath: item.filePath,
                    lsFilePath:item.lsFilePath,
                    fileType:item.fileType
                };
            });
        }
        
    },
    watch: {
        detailData: {
            handler(newVal) {
                if (Object.keys(newVal).length > 0) {
                    this.setDetailData();
                }
            },
            // immediate: true, // 立即执行一次
            deep: true
        }
    },
}
</script>

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

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


</style>