<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">
            <!-- 开户许可证 -->
            <div class="detail-item">
                <div class="item-label">开户许可证</div>
                <div class="item-value">
                    <el-image :src="form.url" :preview-src-list="[form.url]" class="license-image">
                    </el-image>
                </div>
            </div>

            <!-- 开户银行 -->
            <div class="detail-item">
                <div class="item-label">开户银行</div>
                <div class="item-value">{{ form.openingBank || '--' }}</div>
            </div>

            <!-- 开户账号 -->
            <div class="detail-item">
                <div class="item-label">开户账号</div>
                <div class="item-value">{{ form.openingAccount || '--' }}</div>
            </div>

            
        </div>
    </div>
</template>

<script>
export default {
    name: 'AccountOpeningCertificateDetail',
    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].lsFilePath,
            }
        },
        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;
    }
}

.detail-content {
    .detail-item {
        margin-bottom: 16px;

        .item-label {
            color: #424242;
            font-size: 18px;
            font-weight: 500;
            margin-bottom: 8px;
        }

        .item-value {
            color: #424242;
            font-size: 16px;
            line-height: 1.5;

            .license-image {
                width: 350px;
                height: 220px;
                display: block;
                margin: 0 auto;
                border-radius: 8px;
                box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
                object-fit: cover;
                cursor: pointer;
                transition: transform 0.3s ease;
                
                &:hover {
                    transform: scale(1.02);
                }
            }
        }
    }
}
</style>