<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 my-4 text-center text-gray-500">
                暂无关联企业信息
            </div>
        </template>
        <template v-else>
            <wd-collapse v-model="entCollapse" custom-class="space-y-5"
                custom-style="background: transparent; !important">
                <wd-collapse-item v-for="(item, index) in data.datalist" :key="index" :name="index" class="card">
                    <template #title="{ expanded }">
                        <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">
                                <text class="flex-shrink-0 text-gray-700 font-medium">
                                    与企业关联关系:
                                </text>
                                <text 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"
                                                ? "股东"
                                                : "高管"
                                    }}
                                </text>
                            </div>
                            <div class="text-center text-blue-500">
                                {{ expanded ? "收起" : "点击查看更多" }}
                            </div>
                        </div>
                    </template>
                    <LTitle title="关联企业信息" type="blue-green" />
                    <!-- 基本信息 -->
                    <div class="pt-4 space-y-3">
                        <div class="flex justify-between">
                            <text class="flex-shrink-0 text-gray-700 font-medium">
                                企业状态：
                            </text>
                            <text class="text-gray-600">
                                {{ item.basicInfo.regStatus }}
                            </text>
                        </div>
                        <div class="flex justify-between">
                            <text class="flex-shrink-0 text-gray-700 font-medium">
                                注册资本：
                            </text>
                            <text class="text-gray-600">
                                {{ item.basicInfo.regCapital }}
                                {{ item.basicInfo.regCapitalCurrency }}
                            </text>
                        </div>
                        <div class="flex justify-between">
                            <text class="flex-shrink-0 text-gray-700 font-medium">
                                法人：
                            </text>
                            <text class="text-gray-600">
                                {{ item.basicInfo.legalPersonName }}
                            </text>
                        </div>
                        <div class="flex justify-between">
                            <text class="flex-shrink-0 text-gray-700 font-medium">
                                统一社会信用代码：
                            </text>
                            <text class="text-gray-600">
                                {{ item.basicInfo.creditCode }}
                            </text>
                        </div>
                        <div class="flex justify-between">
                            <text class="flex-shrink-0 text-gray-700 font-medium">
                                成立日期：
                            </text>
                            <text class="text-gray-600">
                                {{ item.basicInfo.estiblishTime }}
                            </text>
                        </div>
                        <div class="flex justify-between">
                            <text class="flex-shrink-0 text-gray-700 font-medium">
                                经营范围：
                            </text>
                            <text class="text-gray-600">
                                <LExpandCollapse :max-length="50">
                                    {{ item.basicInfo.opscope }}
                                </LExpandCollapse>
                            </text>
                        </div>
                        <div class="flex justify-between">
                            <text class="flex-shrink-0 text-gray-700 font-medium">
                                地址：
                            </text>
                            <text class="text-gray-600">
                                {{ item.basicInfo.province }}
                                {{ item.basicInfo.city }}
                                {{ item.basicInfo.district }}
                            </text>
                        </div>
                        <div class="flex justify-between">
                            <text class="flex-shrink-0 text-gray-700 font-medium">
                                行业：
                            </text>
                            <text class="text-gray-600">
                                {{ item.basicInfo.industry }}
                            </text>
                        </div>
                        <div class="flex justify-between">
                            <text class="flex-shrink-0 text-gray-700 font-medium">
                                行业代码：
                            </text>
                            <text class="text-gray-600">
                                {{ item.basicInfo.nic_code }}
                            </text>
                        </div>
                        <div class="flex justify-between">
                            <text class="flex-shrink-0 text-gray-700 font-medium">
                                公司类型：
                            </text>
                            <text class="text-gray-600">
                                {{ item.basicInfo.companyOrgType }}
                            </text>
                        </div>
                        <div class="flex justify-between">
                            <text class="flex-shrink-0 text-gray-700 font-medium">
                                注册机关：
                            </text>
                            <text class="text-gray-600">
                                {{ item.basicInfo.regorg }}
                            </text>
                        </div>

                        <div class="flex justify-between">
                            <text class="flex-shrink-0 text-gray-700 font-medium">
                                行业名称：
                            </text>
                            <text class="text-gray-600">
                                {{ item.basicInfo.nic_name }}
                            </text>
                        </div>
                        <div class="flex justify-between">
                            <text class="flex-shrink-0 text-gray-700 font-medium">
                                注册资本币种：
                            </text>
                            <text class="text-gray-600">
                                {{ item.basicInfo.reccapcur }}
                            </text>
                        </div>
                        <div class="flex justify-between">
                            <text class="flex-shrink-0 text-gray-700 font-medium">
                                审核日期：
                            </text>
                            <text class="text-gray-600">
                                {{ item.basicInfo.apprdate }}
                            </text>
                        </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">
                                <text class="flex-shrink-0 text-gray-700 font-medium">
                                    姓名：
                                </text>
                                <text class="text-gray-600">
                                    {{ staff.name }}
                                </text>
                            </div>
                            <div v-for="(type, typeIdx) in staff.typeJoin" :key="typeIdx" class="flex justify-between">
                                <text class="flex-shrink-0 text-gray-700 font-medium">
                                    职位：
                                </text>
                                <text class="text-gray-600">
                                    {{ type }}
                                </text>
                            </div>
                        </div>
                    </div>

                    <!-- 股东信息 -->
                    <div v-if="item.stockHolderItem" class="pt-4 space-y-3">
                        <LTitle title="股东信息" type="blue-green" />
                        <div class="flex justify-between">
                            <text class="flex-shrink-0 text-gray-700 font-medium">
                                股东类型：
                            </text>
                            <text class="text-gray-600">
                                {{ item.stockHolderItem.orgHolderType }}
                            </text>
                        </div>
                        <div class="flex justify-between">
                            <text class="flex-shrink-0 text-gray-700 font-medium">
                                占比：
                            </text>
                            <text class="text-gray-600">
                                {{ item.stockHolderItem.investRate }}
                            </text>
                        </div>
                        <div class="flex justify-between">
                            <text class="flex-shrink-0 text-gray-700 font-medium">
                                股东名称：
                            </text>
                            <text class="text-gray-600">
                                {{ item.stockHolderItem.orgHolderName }}
                            </text>
                        </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">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              案号：
            </text>
            <text class="text-gray-600">
              {{ person.caseCode }}
            </text>
          </div>
          <div class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              身份证号：
            </text>
            <text class="text-gray-600">
              {{ person.partyCardNum }}
            </text>
          </div>
          <div class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              被执行人：
            </text>
            <text class="text-gray-600">
              {{ person.pname }}
            </text>
          </div>
          <div class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              立案日期：
            </text>
            <text class="text-gray-600">
              {{ person.caseCreateTime }}
            </text>
          </div>
          <div v-if="person.execCourtName" class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              执行法院：
            </text>
            <text class="text-gray-600">
              {{ person.execCourtName }}
            </text>
          </div>
          <div class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              执行标的：
            </text>
            <text class="text-gray-600">
              {{ person.execMoney }} 元
            </text>
          </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">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              失信人姓名：
            </text>
            <text class="text-gray-600">
              {{ person.iname }}
            </text>
          </div>
          <div class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              失信行为：
            </text>
            <text class="text-gray-600">
              {{ person.disrupttypename }}
            </text>
          </div>
          <div class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              案号：
            </text>
            <text class="text-gray-600">
              {{ person.casecode }}
            </text>
          </div>
          <div class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              身份证号：
            </text>
            <text class="text-gray-600">
              {{ person.cardnum }}
            </text>
          </div>
          <div class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              未履行部分：
            </text>
            <text class="text-gray-600">
              {{ person.unperformPart || '无' }}
            </text>
          </div>
          <div class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              已履行部分：
            </text>
            <text class="text-gray-600">
              {{ person.performedPart || '无' }}
            </text>
          </div>
          <div class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              履行情况：
            </text>
            <text class="text-gray-600">
              {{ person.performance }}
            </text>
          </div>
          <div class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              立案时间：
            </text>
            <text class="text-gray-600">
              {{ person.regdate }}
            </text>
          </div>
          <div class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              生效法律文书确定义务：
            </text>
            <text class="text-gray-600">
              {{ person.duty }}
            </text>
          </div>
          <div class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              执行依据文号：
            </text>
            <text class="text-gray-600">
              {{ person.gistid }}
            </text>
          </div>
          <div class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              执行法院：
            </text>
            <text class="text-gray-600">
              {{ person.courtname }}
            </text>
          </div>
          <div class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              发布时间：
            </text>
            <text class="text-gray-600">
              {{ person.publishdate }}
            </text>
          </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">
                                <text class="flex-shrink-0 text-gray-700 font-medium">
                                    处罚单位：
                                </text>
                                <text class="text-gray-600">
                                    {{ penalty.departmentName }}
                                </text>
                            </div>
                            <div class="flex justify-between">
                                <text class="flex-shrink-0 text-gray-700 font-medium">
                                    处罚原因：
                                </text>
                                <text class="text-gray-600">
                                    {{ penalty.reason || "无" }}
                                </text>
                            </div>
                            <div class="flex justify-between">
                                <text class="flex-shrink-0 text-gray-700 font-medium">
                                    处罚决定书文号：
                                </text>
                                <text class="text-gray-600">
                                    {{ penalty.punishNumber }}
                                </text>
                            </div>
                            <div class="flex justify-between">
                                <text class="flex-shrink-0 text-gray-700 font-medium">
                                    处罚类别：
                                </text>
                                <text class="text-gray-600">
                                    {{ penalty.type }}
                                </text>
                            </div>
                            <div class="flex justify-between">
                                <text class="flex-shrink-0 text-gray-700 font-medium">
                                    处罚结果：
                                </text>
                                <text class="text-gray-600">
                                    {{ penalty.content || "无" }}
                                </text>
                            </div>
                            <div class="flex justify-between">
                                <text class="flex-shrink-0 text-gray-700 font-medium">
                                    处罚日期：
                                </text>
                                <text class="text-gray-600">
                                    {{ penalty.decisionDate }}
                                </text>
                            </div>
                            <div class="flex justify-between">
                                <text class="flex-shrink-0 text-gray-700 font-medium">
                                    法人姓名：
                                </text>
                                <text class="text-gray-600">
                                    {{ penalty.legalPersonName }}
                                </text>
                            </div>
                        </div>
                    </div>
                </wd-collapse-item>
            </wd-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>
