<template>
  <el-table v-loading="loading" :data="tableData" :stripe="true" class="m-t-20px">
    <el-table-column label="企业全称" align="center" prop="name">
      <template #default="scope">{{ formatName(scope.row.name) }}</template>
    </el-table-column>
    <el-table-column label="企业别称" align="center" prop="anotherName">
      <template #default="scope">{{ formatName(scope.row.anotherName) }}</template>
    </el-table-column>
    <el-table-column label="联系人" align="center" prop="contact" />
    <el-table-column label="联系电话" align="center" prop="phone" />
    <el-table-column label="所在行业" align="center" prop="industryName" />
    <el-table-column label="融资阶段" align="center" prop="financingStatus">
      <template #default="scope">
        <dict-tag :type="DICT_TYPE.MENDUNER_FINANCING_STATUS" :value="scope.row.financingStatus" />
      </template>
    </el-table-column>
    <el-table-column label="人员规模" align="center" prop="scale">
      <template #default="scope">
        <dict-tag :type="DICT_TYPE.MENDUNER_SCALE" :value="scope.row.scale" />
      </template>
    </el-table-column>
    <el-table-column
      label="创建时间"
      align="center"
      prop="createTime"
      :formatter="dateFormatter"
      width="180px"
    />
  </el-table>

  <Pagination
    :total="total"
    v-model:page="queryParams.pageNo"
    v-model:limit="queryParams.pageSize"
    @pagination="getList"
  />
</template>

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

const props = defineProps({
  id: String
})

const loading = ref(false)
const tableData = ref([])
const total = ref(0)
const queryParams = reactive({
  pageNo: 1,
  pageSize: 10,
  parentId: props.id
})

const getList = async () => {
  loading.value = true
  try {
    const data = await EnterpriseApi.getSubordinateEnterprisesPage(queryParams)
    tableData.value = data.list
    total.value = data.total
  } finally {
    loading.value = false
  }
}
getList()
</script>
