<template>
  <ContentWrap>
    <el-descriptions class="margin-top" :column="2" border>
      <el-descriptions-item label="企业LOGO">
        <el-image v-if="info.logoUrl" style="width: 100px; height: 100px" :src="info.logoUrl" fit="contain" hide-on-click-modal :preview-src-list="[info.logoUrl]"/>
      </el-descriptions-item>
      <el-descriptions-item label="企业全称">{{ formatName(info.name) }}</el-descriptions-item>
      <el-descriptions-item label="企业别名">{{ formatName(info.anotherName) }}</el-descriptions-item>
      <el-descriptions-item label="企业官网">
        <el-link :href="info.website" target="_blank" type="primary">{{ info.website }}</el-link>
      </el-descriptions-item>
      <el-descriptions-item label="开业时间">{{ formatDate(info.openTime, 'YYYY-MM-DD') }}</el-descriptions-item>
      <el-descriptions-item label="联系人">{{ info.contact }}</el-descriptions-item>
      <el-descriptions-item label="联系电话">{{ info.phone }}</el-descriptions-item>
      <el-descriptions-item label="是否筹备">{{ info.prepare && info.prepare ? '是' : '否' }}</el-descriptions-item>
      <el-descriptions-item label="企业规模">
        <dict-tag :type="DICT_TYPE.MENDUNER_SCALE" :value="info.scale" />
      </el-descriptions-item>
      <el-descriptions-item label="所在行业">{{ info.industryName }}</el-descriptions-item>
      <el-descriptions-item label="融资阶段">
        <dict-tag :type="DICT_TYPE.MENDUNER_FINANCING_STATUS" :value="info.financingStatus" />
      </el-descriptions-item>
      <el-descriptions-item label="企业标签">
        <el-tag type="primary" v-for="k in info.tagList" :key="k" class="m-r-5px">{{ k }}</el-tag>
      </el-descriptions-item>
      <el-descriptions-item label="会员">
        {{ info.vipExpireDate ? info.vipExpireDate > Date.now() ? packageList.find(e => e.id === Number(info.vipFlag))?.text : '会员已过期' : '非会员' }}
      </el-descriptions-item>
      <el-descriptions-item label="会员到期时间">{{ formatDate(info.vipExpireDate, 'YYYY-MM-DD') }}</el-descriptions-item>
    </el-descriptions>
  </ContentWrap>
</template>

<script setup>
defineOptions({ name: 'EnterpriseDetailsInfo'})
import { EnterpriseApi } from '@/api/menduner/system/enterprise/message'
import { formatDate } from '@/utils/formatTime'
import { DICT_TYPE } from '@/utils/dict'
import { formatName } from '@/utils'

const props = defineProps({
  id: String
})

const info = ref({})
const getInfo = async () => {
  const data = await EnterpriseApi.getEnterpriseInfo(props.id)
  info.value = data
}
getInfo()

// 套餐列表
const packageList = ref([])
const getPackList = async () => {
	const data = await EnterpriseApi.getEnterprisePackageList()
	packageList.value = data
}
getPackList()
</script>
