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

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

<template>
    <view class="">
        <template v-if="data && data.datalist.length === 0">
            <!-- 显示“暂无关联企业信息”的提示 -->
            <view class="card py-10 text-center text-gray-500">
                暂无关联企业信息
            </view>
        </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 }">
                        <view class="w-full space-y-3">
                            <view class="text-lg text-gray-800 font-bold">
                                {{ item.orgName }}
                            </view>
                            <view class="text-sm text-gray-700">
                                查询人：{{ item.pName }}
                            </view>
                            <!-- 关联关系 -->
                            <view 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>
                            </view>
                            <view class="text-center text-blue-500">
                                {{ expanded ? "收起" : "点击查看更多" }}
                            </view>
                        </view>
                    </template>
                    <LTitle title="关联企业信息" type="blue-green" />
                    <!-- 基本信息 -->
                    <view class="pt-4 space-y-3">
                        <view class="flex justify-between">
                            <text
                                class="flex-shrink-0 text-gray-700 font-medium"
                            >
                                企业状态：
                            </text>
                            <text class="text-gray-600">
                                {{ item.basicInfo.regStatus }}
                            </text>
                        </view>
                        <view 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>
                        </view>
                        <view class="flex justify-between">
                            <text
                                class="flex-shrink-0 text-gray-700 font-medium"
                            >
                                法人：
                            </text>
                            <text class="text-gray-600">
                                {{ item.basicInfo.legalPersonName }}
                            </text>
                        </view>
                        <view class="flex justify-between">
                            <text
                                class="flex-shrink-0 text-gray-700 font-medium"
                            >
                                统一社会信用代码：
                            </text>
                            <text class="text-gray-600">
                                {{ item.basicInfo.creditCode }}
                            </text>
                        </view>
                        <view class="flex justify-between">
                            <text
                                class="flex-shrink-0 text-gray-700 font-medium"
                            >
                                成立日期：
                            </text>
                            <text class="text-gray-600">
                                {{ item.basicInfo.estiblishTime }}
                            </text>
                        </view>
                        <view 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>
                        </view>
                        <view 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>
                        </view>
                        <view class="flex justify-between">
                            <text
                                class="flex-shrink-0 text-gray-700 font-medium"
                            >
                                行业：
                            </text>
                            <text class="text-gray-600">
                                {{ item.basicInfo.industry }}
                            </text>
                        </view>
                        <view 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>
                        </view>
                        <view class="flex justify-between">
                            <text
                                class="flex-shrink-0 text-gray-700 font-medium"
                            >
                                公司类型：
                            </text>
                            <text class="text-gray-600">
                                {{ item.basicInfo.companyOrgType }}
                            </text>
                        </view>
                        <view class="flex justify-between">
                            <text
                                class="flex-shrink-0 text-gray-700 font-medium"
                            >
                                注册机关：
                            </text>
                            <text class="text-gray-600">
                                {{ item.basicInfo.regorg }}
                            </text>
                        </view>

                        <view 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>
                        </view>
                        <view class="flex justify-between">
                            <text
                                class="flex-shrink-0 text-gray-700 font-medium"
                            >
                                注册资本币种：
                            </text>
                            <text class="text-gray-600">
                                {{ item.basicInfo.reccapcur }}
                            </text>
                        </view>
                        <view class="flex justify-between">
                            <text
                                class="flex-shrink-0 text-gray-700 font-medium"
                            >
                                审核日期：
                            </text>
                            <text class="text-gray-600">
                                {{ item.basicInfo.apprdate }}
                            </text>
                        </view>
                    </view>

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

                    <!-- 股东信息 -->
                    <view v-if="item.stockHolderItem" class="pt-4 space-y-3">
                        <LTitle title="股东信息" type="blue-green" />
                        <view class="flex justify-between">
                            <text
                                class="flex-shrink-0 text-gray-700 font-medium"
                            >
                                股东类型：
                            </text>
                            <text class="text-gray-600">
                                {{ item.stockHolderItem.orgHolderType }}
                            </text>
                        </view>
                        <view class="flex justify-between">
                            <text
                                class="flex-shrink-0 text-gray-700 font-medium"
                            >
                                占比：
                            </text>
                            <text class="text-gray-600">
                                {{ item.stockHolderItem.investRate }}
                            </text>
                        </view>
                        <view class="flex justify-between">
                            <text
                                class="flex-shrink-0 text-gray-700 font-medium"
                            >
                                股东名称：
                            </text>
                            <text class="text-gray-600">
                                {{ item.stockHolderItem.orgHolderName }}
                            </text>
                        </view>
                    </view>
                    <!-- 被执行人信息 -->
                    <!-- <view v-if="item.executedPerson?.length > 0" class="pt-4">
        <LTitle title="被执行人信息" type="blue-green" />
        <view 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">
          <view class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              案号：
            </text>
            <text class="text-gray-600">
              {{ person.caseCode }}
            </text>
          </view>
          <view class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              身份证号：
            </text>
            <text class="text-gray-600">
              {{ person.partyCardNum }}
            </text>
          </view>
          <view class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              被执行人：
            </text>
            <text class="text-gray-600">
              {{ person.pname }}
            </text>
          </view>
          <view class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              立案日期：
            </text>
            <text class="text-gray-600">
              {{ person.caseCreateTime }}
            </text>
          </view>
          <view 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>
          </view>
          <view class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              执行标的：
            </text>
            <text class="text-gray-600">
              {{ person.execMoney }} 元
            </text>
          </view>
        </view>
      </view>

      <view v-if="item.dishonestExecutedPerson?.length > 0"  class="pt-4">
        <LTitle title="失信被执行人信息" type="blue-green" />
        <view 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">
          <view class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              失信人姓名：
            </text>
            <text class="text-gray-600">
              {{ person.iname }}
            </text>
          </view>
          <view class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              失信行为：
            </text>
            <text class="text-gray-600">
              {{ person.disrupttypename }}
            </text>
          </view>
          <view class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              案号：
            </text>
            <text class="text-gray-600">
              {{ person.casecode }}
            </text>
          </view>
          <view class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              身份证号：
            </text>
            <text class="text-gray-600">
              {{ person.cardnum }}
            </text>
          </view>
          <view class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              未履行部分：
            </text>
            <text class="text-gray-600">
              {{ person.unperformPart || '无' }}
            </text>
          </view>
          <view class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              已履行部分：
            </text>
            <text class="text-gray-600">
              {{ person.performedPart || '无' }}
            </text>
          </view>
          <view class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              履行情况：
            </text>
            <text class="text-gray-600">
              {{ person.performance }}
            </text>
          </view>
          <view class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              立案时间：
            </text>
            <text class="text-gray-600">
              {{ person.regdate }}
            </text>
          </view>
          <view class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              生效法律文书确定义务：
            </text>
            <text class="text-gray-600">
              {{ person.duty }}
            </text>
          </view>
          <view class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              执行依据文号：
            </text>
            <text class="text-gray-600">
              {{ person.gistid }}
            </text>
          </view>
          <view class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              执行法院：
            </text>
            <text class="text-gray-600">
              {{ person.courtname }}
            </text>
          </view>
          <view class="flex justify-between">
            <text class="flex-shrink-0 text-gray-700 font-medium">
              发布时间：
            </text>
            <text class="text-gray-600">
              {{ person.publishdate }}
            </text>
          </view>
        </view>
      </view> -->

                    <view v-if="item.adminPenalty?.length > 0" class="pt-4">
                        <LTitle title="行政处罚信息" type="blue-green" />
                        <view
                            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"
                        >
                            <view class="flex justify-between">
                                <text
                                    class="flex-shrink-0 text-gray-700 font-medium"
                                >
                                    处罚单位：
                                </text>
                                <text class="text-gray-600">
                                    {{ penalty.departmentName }}
                                </text>
                            </view>
                            <view class="flex justify-between">
                                <text
                                    class="flex-shrink-0 text-gray-700 font-medium"
                                >
                                    处罚原因：
                                </text>
                                <text class="text-gray-600">
                                    {{ penalty.reason || "无" }}
                                </text>
                            </view>
                            <view class="flex justify-between">
                                <text
                                    class="flex-shrink-0 text-gray-700 font-medium"
                                >
                                    处罚决定书文号：
                                </text>
                                <text class="text-gray-600">
                                    {{ penalty.punishNumber }}
                                </text>
                            </view>
                            <view class="flex justify-between">
                                <text
                                    class="flex-shrink-0 text-gray-700 font-medium"
                                >
                                    处罚类别：
                                </text>
                                <text class="text-gray-600">
                                    {{ penalty.type }}
                                </text>
                            </view>
                            <view class="flex justify-between">
                                <text
                                    class="flex-shrink-0 text-gray-700 font-medium"
                                >
                                    处罚结果：
                                </text>
                                <text class="text-gray-600">
                                    {{ penalty.content || "无" }}
                                </text>
                            </view>
                            <view class="flex justify-between">
                                <text
                                    class="flex-shrink-0 text-gray-700 font-medium"
                                >
                                    处罚日期：
                                </text>
                                <text class="text-gray-600">
                                    {{ penalty.decisionDate }}
                                </text>
                            </view>
                            <view class="flex justify-between">
                                <text
                                    class="flex-shrink-0 text-gray-700 font-medium"
                                >
                                    法人姓名：
                                </text>
                                <text class="text-gray-600">
                                    {{ penalty.legalPersonName }}
                                </text>
                            </view>
                        </view>
                    </view>
                </wd-collapse-item>
            </wd-collapse>
        </template>
    </view>
</template>

<style scoped lang="scss">
:deep(.wd-collapse-item__header) {
    padding: 0;
}
:deep(.wd-collapse-item__body) {
    padding: 0;
    @apply text-sm;
}
</style>
