<template>
  <div class="card-edit">
    <a-divider orientation="left">企业基础信息</a-divider>
    <a-descriptions bordered>
      <a-descriptions-item label="统一社会信用代码">{{ companyInfo.companyCode }}</a-descriptions-item>
      <a-descriptions-item label="企业名称">{{ companyInfo.companyName }}</a-descriptions-item>
      <a-descriptions-item label="所属驿站">{{ companyInfo.SiteName }}</a-descriptions-item>
      <a-descriptions-item :span="2" label="企业办公地址">{{ companyInfo.companyAddress }}</a-descriptions-item>
      <a-descriptions-item label="企业联系人">{{ companyInfo.userName }}</a-descriptions-item>
      <a-descriptions-item label="企业联系电话">{{ companyInfo.userMobile }}</a-descriptions-item>
      <a-descriptions-item label="企业状态">{{ companyInfo.recordStatus == 0 ? '停业' : '在营' }}</a-descriptions-item>
      <a-descriptions-item label="是否缺工">{{ companyInfo.isShortage == 0 ? '否' : '是' }}</a-descriptions-item>
      <a-descriptions-item label="企业所在经度">{{ companyInfo.longitude }}</a-descriptions-item>
      <a-descriptions-item label="企业所在纬度">{{ companyInfo.latitude }}</a-descriptions-item>
      <a-descriptions-item label="企业成立日期">
        {{ companyInfo.establishmentTime ? dayjs(companyInfo.establishmentTime).format('YYYY-MM-DD') : '' }}
      </a-descriptions-item>
      <a-descriptions-item label="注册资本">{{ companyInfo.registeredCapital }}万元</a-descriptions-item>
      <a-descriptions-item label="注册地行政区划">{{ companyInfo.signInPoliticalAreaName }}</a-descriptions-item>
      <a-descriptions-item label="所属行业">{{ companyInfo.industryName }}</a-descriptions-item>
      <a-descriptions-item label="所属产业分类">{{ companyInfo.estateCategoryName }}</a-descriptions-item>
      <a-descriptions-item label="企业标签">{{ companyInfo.tagName }}</a-descriptions-item>
      <a-descriptions-item :span="3" label="官网网址">{{ companyInfo.website }}</a-descriptions-item>
      <a-descriptions-item :span="3" label="企业福利">{{ companyInfo.bonus }}</a-descriptions-item>
      <a-descriptions-item label="最后更新人">{{ companyInfo.modifyUserName }}</a-descriptions-item>
      <a-descriptions-item label="最后更新时间">
        {{ companyInfo.modifyTime ? dayjs(companyInfo.modifyTime).format('YYYY-MM-DD') : '' }}
      </a-descriptions-item>
    </a-descriptions>

    <a-divider orientation="left">其他信息</a-divider>
    <a-descriptions bordered>
      <a-descriptions-item label="法定代表人(负责人)">{{ companyInfo.frName }}</a-descriptions-item>
      <a-descriptions-item label="营业执照有效期">
        {{ companyInfo.validDate ? dayjs(companyInfo.validDate).format('YYYY-MM-DD') : '' }}
      </a-descriptions-item>
      <a-descriptions-item label="企业邮箱">{{ companyInfo.companyEmail }}</a-descriptions-item>
      <a-descriptions-item label="经济类型">{{ companyInfo.companyTypeName }}</a-descriptions-item>
      <a-descriptions-item label="所属县区">{{ companyInfo.regionName }}</a-descriptions-item>
      <a-descriptions-item label="所属街道">{{ companyInfo.streetName }}</a-descriptions-item>
      <a-descriptions-item label="企业规模">{{ companyInfo.companyModel }}</a-descriptions-item>
      <a-descriptions-item label="用工情况(人)">{{ companyInfo.workSituation }}</a-descriptions-item>
      <a-descriptions-item label="参保人数(人)">{{ companyInfo.insuredCount }}</a-descriptions-item>
      <a-descriptions-item :span="3" label="标签">
        <a-button style="margin: 0px 5px 5px 0px;color: black;border: 1px solid rgb(217, 217, 217);" v-for="item in companyInfo.listLabel">
          {{ item.labelName }}
        </a-button>
      </a-descriptions-item>
      <a-descriptions-item :span="3" label="经营范围">{{ companyInfo.businScope }}</a-descriptions-item>
      <a-descriptions-item :span="3" label="企业简介">{{ companyInfo.companyDesc }}</a-descriptions-item>
    </a-descriptions>
    <a-divider orientation="left">附件照片</a-divider>
    <b-upload-file :fileRefId="companyInfo.companyID" :readonly="true" :multiple="true" style="width: 100%;"
                   :setFileList="setFileList" :accept="'.pdf,.png,.jpg'"></b-upload-file>
  </div>
</template>

<script setup lang="ts">

import {getCompanyById} from "@/api/companyService/company";
import {onMounted, reactive, ref} from "vue";
import BUploadFile from "@/components/file/uploadFile.vue";
import dayjs from "dayjs";

// 企业信息
const companyInfo = reactive({
  companyID: "",
  companyCode: "",
  companyName: "",
  SiteName: "",
  companyAddress: "",
  userName: "",
  userMobile: "",
  recordStatus: null,
  isShortage: null,
  longitude: "",
  latitude: "",
  frName: "",
  validDate: "",
  companyEmail: "",
  companyType: "",
  companyTypeName: "",
  regionName: "",
  streetName: "",
  companyModel: "",
  workSituation: "",
  insuredCount: "",
  businScope: "",
  companyDesc: "",
  establishmentTime: "",
  registeredCapital: "",
  signInPoliticalAreaName: "",
  industryName: "",
  estateCategoryName: "",
  tagName: "",
  website: "",
  listLabel: null,
  bonus: "",
  modifyUserName: "",
  modifyTime: ""
})
// 文件数据
const fileList = ref();

// 数据加载
function loadData(id: any) {
  getCompanyById(id, "").then(result => {
    Object.keys(companyInfo).forEach(key => {
      companyInfo[key] = result[key]
    })
  })
}

// 设置文件列表
function setFileList(files) {
  fileList.value = files;
};

onMounted(() => {
  const id = history.state.params?.id;
  loadData(id);
})
</script>

<script lang="ts">
// 设置页面名称进行组件缓存
export default {
  name: "CompanyDetail"
}
</script>

<style scoped>

</style>
