<script setup>
import LTitle from "@/components/LTitle.vue";

const props = defineProps({
    data: {
        type: Object,
        required: true,
    },
});
const { data } = props;
const entCollapse = ref([]);
</script>

<template>
    <div class="">
        <template v-if="!data || data.datalist?.length === 0">
            <!-- 显示“暂无关联企业信息”的提示 -->
            <div class="card py-10 text-center text-gray-500">
                暂无关联企业信息
            </div>
        </template>
        <template v-else>
            <van-collapse v-model="entCollapse" custom-class="space-y-5"
                custom-style="background: transparent; !important">
                <van-collapse-item v-for="(item, index) in data.datalist" :key="index" :name="index" class="card mb-4">
                    <template #title>
                        <div class="w-full space-y-3">
                            <div class="text-lg text-gray-800 font-bold">
                                {{ item.orgName }}
                            </div>
                            <div class="text-sm text-gray-700">
                                查询人：{{ item.pName }}
                            </div>
                            <div class="flex items-center gap-3">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    与企业关联关系:
                                </span>
                                <span v-for="(relation, idx) in item.relationship" :key="idx"
                                    class="flex-shrink-0 rounded-full bg-blue-100 px-3 py-1 text-xs text-blue-800">
                                    {{
                                        relation === "lp"
                                            ? "法人"
                                            : relation === "sh"
                                                ? "股东"
                                                : "高管"
                                    }}
                                </span>
                            </div>
                        </div>
                    </template>
                    <LTitle title="关联企业信息" type="blue-green" />
                    <!-- 基本信息 -->
                    <div class="pt-4 space-y-3">
                        <div class="flex justify-between">
                            <span class="flex-shrink-0 text-gray-700 font-medium">
                                企业状态：
                            </span>
                            <span class="text-gray-600">
                                {{ item.basicInfo.regStatus }}
                            </span>
                        </div>
                        <div class="flex justify-between">
                            <span class="flex-shrink-0 text-gray-700 font-medium">
                                注册资本：
                            </span>
                            <span class="text-gray-600">
                                {{ item.basicInfo.regCapital }}
                                {{ item.basicInfo.regCapitalCurrency }}
                            </span>
                        </div>
                        <div class="flex justify-between">
                            <span class="flex-shrink-0 text-gray-700 font-medium">
                                法人：
                            </span>
                            <span class="text-gray-600">
                                {{ item.basicInfo.legalPersonName }}
                            </span>
                        </div>
                        <div class="flex justify-between">
                            <span class="flex-shrink-0 text-gray-700 font-medium">
                                统一社会信用代码：
                            </span>
                            <span class="text-gray-600">
                                {{ item.basicInfo.creditCode }}
                            </span>
                        </div>
                        <div class="flex justify-between">
                            <span class="flex-shrink-0 text-gray-700 font-medium">
                                成立日期：
                            </span>
                            <span class="text-gray-600">
                                {{ item.basicInfo.estiblishTime }}
                            </span>
                        </div>
                        <div class="flex justify-between">
                            <span class="flex-shrink-0 text-gray-700 font-medium">
                                经营范围：
                            </span>
                            <span class="text-gray-600">
                                <LExpandCollapse :max-length="50">
                                    {{ item.basicInfo.opscope }}
                                </LExpandCollapse>
                            </span>
                        </div>
                        <div class="flex justify-between">
                            <span class="flex-shrink-0 text-gray-700 font-medium">
                                地址：
                            </span>
                            <span class="text-gray-600">
                                {{ item.basicInfo.province }}
                                {{ item.basicInfo.city }}
                                {{ item.basicInfo.district }}
                            </span>
                        </div>
                        <div class="flex justify-between">
                            <span class="flex-shrink-0 text-gray-700 font-medium">
                                行业：
                            </span>
                            <span class="text-gray-600">
                                {{ item.basicInfo.industry }}
                            </span>
                        </div>
                        <div class="flex justify-between">
                            <span class="flex-shrink-0 text-gray-700 font-medium">
                                行业代码：
                            </span>
                            <span class="text-gray-600">
                                {{ item.basicInfo.nic_code }}
                            </span>
                        </div>
                        <div class="flex justify-between">
                            <span class="flex-shrink-0 text-gray-700 font-medium">
                                公司类型：
                            </span>
                            <span class="text-gray-600">
                                {{ item.basicInfo.companyOrgType }}
                            </span>
                        </div>
                        <div class="flex justify-between">
                            <span class="flex-shrink-0 text-gray-700 font-medium">
                                注册机关：
                            </span>
                            <span class="text-gray-600">
                                {{ item.basicInfo.regorg }}
                            </span>
                        </div>

                        <div class="flex justify-between">
                            <span class="flex-shrink-0 text-gray-700 font-medium">
                                行业名称：
                            </span>
                            <span class="text-gray-600">
                                {{ item.basicInfo.nic_name }}
                            </span>
                        </div>
                        <div class="flex justify-between">
                            <span class="flex-shrink-0 text-gray-700 font-medium">
                                注册资本币种：
                            </span>
                            <span class="text-gray-600">
                                {{ item.basicInfo.reccapcur }}
                            </span>
                        </div>
                        <div class="flex justify-between">
                            <span class="flex-shrink-0 text-gray-700 font-medium">
                                审核日期：
                            </span>
                            <span class="text-gray-600">
                                {{ item.basicInfo.apprdate }}
                            </span>
                        </div>
                    </div>

                    <!-- 高管信息 -->
                    <div v-if="item.basicInfo.staffList?.result?.length > 0" class="pt-4 space-y-3">
                        <LTitle title="高管信息" type="blue-green" />
                        <div v-for="(staff, idx) in item.basicInfo.staffList
                            .result" :key="idx" class="space-y-3">
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    姓名：
                                </span>
                                <span class="text-gray-600">
                                    {{ staff.name }}
                                </span>
                            </div>
                            <div v-for="(type, typeIdx) in staff.typeJoin" :key="typeIdx" class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    职位：
                                </span>
                                <span class="text-gray-600">
                                    {{ type }}
                                </span>
                            </div>
                        </div>
                    </div>

                    <!-- 股东信息 -->
                    <div v-if="item.stockHolderItem" class="pt-4 space-y-3">
                        <LTitle title="股东信息" type="blue-green" />
                        <div class="flex justify-between">
                            <span class="flex-shrink-0 text-gray-700 font-medium">
                                股东类型：
                            </span>
                            <span class="text-gray-600">
                                {{ item.stockHolderItem.orgHolderType }}
                            </span>
                        </div>
                        <div class="flex justify-between">
                            <span class="flex-shrink-0 text-gray-700 font-medium">
                                占比：
                            </span>
                            <span class="text-gray-600">
                                {{ item.stockHolderItem.investRate }}
                            </span>
                        </div>
                        <div class="flex justify-between">
                            <span class="flex-shrink-0 text-gray-700 font-medium">
                                股东名称：
                            </span>
                            <span class="text-gray-600">
                                {{ item.stockHolderItem.orgHolderName }}
                            </span>
                        </div>
                    </div>
                    <!-- 被执行人信息 -->
                    <div v-if="item.executedPerson?.length > 0" class="pt-4">
                        <LTitle title="被执行人信息" type="blue-green" />
                        <div v-for="(person, pidx) in item.executedPerson" :key="pidx"
                            class="border-b border-gray-400 border-b-dashed pb-4 pt-4 space-y-3">
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    案号：
                                </span>
                                <span class="text-gray-600">
                                    {{ person.caseCode }}
                                </span>
                            </div>
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    身份证号：
                                </span>
                                <span class="text-gray-600">
                                    {{ person.partyCardNum }}
                                </span>
                            </div>
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    被执行人：
                                </span>
                                <span class="text-gray-600">
                                    {{ person.pname }}
                                </span>
                            </div>
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    立案日期：
                                </span>
                                <span class="text-gray-600">
                                    {{ person.caseCreateTime }}
                                </span>
                            </div>
                            <div v-if="person.execCourtName" class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    执行法院：
                                </span>
                                <span class="text-gray-600">
                                    {{ person.execCourtName }}
                                </span>
                            </div>
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    执行标的：
                                </span>
                                <span class="text-gray-600">
                                    {{ person.execMoney }} 元
                                </span>
                            </div>
                        </div>
                    </div>

                    <div v-if="item.dishonestExecutedPerson?.length > 0" class="pt-4">
                        <LTitle title="失信被执行人信息" type="blue-green" />
                        <div v-for="(person, didx) in item.dishonestExecutedPerson" :key="didx"
                            class="border-b border-gray-400 border-b-dashed pb-4 pt-4 space-y-3">
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    失信人姓名：
                                </span>
                                <span class="text-gray-600">
                                    {{ person.iname }}
                                </span>
                            </div>
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    失信行为：
                                </span>
                                <span class="text-gray-600">
                                    {{ person.disrupttypename }}
                                </span>
                            </div>
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    案号：
                                </span>
                                <span class="text-gray-600">
                                    {{ person.casecode }}
                                </span>
                            </div>
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    身份证号：
                                </span>
                                <span class="text-gray-600">
                                    {{ person.cardnum }}
                                </span>
                            </div>
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    未履行部分：
                                </span>
                                <span class="text-gray-600">
                                    {{ person.unperformPart || '无' }}
                                </span>
                            </div>
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    已履行部分：
                                </span>
                                <span class="text-gray-600">
                                    {{ person.performedPart || '无' }}
                                </span>
                            </div>
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    履行情况：
                                </span>
                                <span class="text-gray-600">
                                    {{ person.performance }}
                                </span>
                            </div>
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    立案时间：
                                </span>
                                <span class="text-gray-600">
                                    {{ person.regdate }}
                                </span>
                            </div>
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    生效法律文书确定义务：
                                </span>
                                <span class="text-gray-600">
                                    {{ person.duty }}
                                </span>
                            </div>
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    执行依据文号：
                                </span>
                                <span class="text-gray-600">
                                    {{ person.gistid }}
                                </span>
                            </div>
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    执行法院：
                                </span>
                                <span class="text-gray-600">
                                    {{ person.courtname }}
                                </span>
                            </div>
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    发布时间：
                                </span>
                                <span class="text-gray-600">
                                    {{ person.publishdate }}
                                </span>
                            </div>
                        </div>
                    </div>

                    <div v-if="item.adminPenalty?.length > 0" class="pt-4">
                        <LTitle title="行政处罚信息" type="blue-green" />
                        <div v-for="(penalty, aidx) in item.adminPenalty" :key="aidx"
                            class="border-b border-gray-400 border-b-dashed pb-4 pt-4 space-y-3">
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    处罚单位：
                                </span>
                                <span class="text-gray-600">
                                    {{ penalty.departmentName }}
                                </span>
                            </div>
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    处罚原因：
                                </span>
                                <span class="text-gray-600">
                                    {{ penalty.reason || "无" }}
                                </span>
                            </div>
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    处罚决定书文号：
                                </span>
                                <span class="text-gray-600">
                                    {{ penalty.punishNumber }}
                                </span>
                            </div>
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    处罚类别：
                                </span>
                                <span class="text-gray-600">
                                    {{ penalty.type }}
                                </span>
                            </div>
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    处罚结果：
                                </span>
                                <span class="text-gray-600">
                                    {{ penalty.content || "无" }}
                                </span>
                            </div>
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    处罚日期：
                                </span>
                                <span class="text-gray-600">
                                    {{ penalty.decisionDate }}
                                </span>
                            </div>
                            <div class="flex justify-between">
                                <span class="flex-shrink-0 text-gray-700 font-medium">
                                    法人姓名：
                                </span>
                                <span class="text-gray-600">s
                                    {{ penalty.legalPersonName }}
                                </span>
                            </div>
                        </div>
                    </div>
                </van-collapse-item>
            </van-collapse>
        </template>
    </div>
</template>

<style scoped lang="scss">
:deep(.wd-collapse-item__header) {
    padding: 0;
}

:deep(.wd-collapse-item__body) {
    padding: 0;
    @apply text-sm;
}
</style>
