<template>
	<a-modal
      v-model:open="open"
      title="企业详情"
      centered
      width="90%"
  >
      <div class="enterprise-detail">
        <div class="__cus-title_1">资质类型</div>
        <a-checkbox-group v-model:value="formData.zzTypeArr" name="checkboxgroup" :disabled="true">
          <a-row :gutter="[0, 10]">
            <template v-for="item in zzTypeOptions">
              <a-col :span="4">
                <a-checkbox :value="item.value">{{item.label}}</a-checkbox>
              </a-col>
            </template>
          </a-row>
        </a-checkbox-group>
        <div class="__cus-title_1">基本信息</div>
        <a-form ref="formRef" :model="formData" layout="inline">
          <a-row :gutter="[0, 16]">
            <a-col :span="8">
              <a-form-item label="统一社会信用代码：" name="companyCode">
                <a-input v-model:value="formData.companyCode" :disabled="true"/>
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="企业注册名称(全)：" name="companyName">
                <a-input v-model:value="formData.companyName" :disabled="true"/>
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="法定代表人：" name="companyLegal">
                <a-input v-model:value="formData.companyLegal" :disabled="true"/>
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="法定代表人联系电话：" name="companyLegalPhone">
                <a-input v-model:value="formData.companyLegalPhone" :disabled="true"/>
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="联系人：" name="companyLinkMan">
                <a-input v-model:value="formData.companyLinkMan" :disabled="true"/>
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="联系人电话：" name="companyLinkPhone">
                <a-input v-model:value="formData.companyLinkPhone" :disabled="true"/>
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="企业类型：" name="companyType">
                <a-select v-model:value="formData.companyType" :disabled="true" :options="companyTypeOptions"/>
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="注册资本：" name="companyRegisteredCapital">
                <a-input v-model:value="formData.companyRegisteredCapital" :disabled="true"/>
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="成立日期：" name="companyRegisterDate">
                <a-date-picker v-model:value="formData.companyRegisterDate" :disabled="true" value-format="YYYY-MM-DD HH:mm:ss" show-time style="width: 100%"/>
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="企业地址：" name="companyAddress">
                <a-input v-model:value="formData.companyAddress" :disabled="true"/>
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="营业期限：" name="companyDeadline">
                <a-input v-model:value="formData.companyDeadline" :disabled="true"/>
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="登记机关：" name="companyRegistration">
                <a-input v-model:value="formData.companyRegistration" :disabled="true"/>
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="申报企业编号：" name="companyApplyCode">
                <a-input v-model:value="formData.companyApplyCode" :disabled="true"/>
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="监管场所：" name="companySupervisionPlaceType">
                <a-select v-model:value="formData.companySupervisionPlaceType" :disabled="true" :options="companySupervisionPlaceTypeOptions"/>
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="主管海关：" name="companyMainHgType">
                <a-select v-model:value="formData.companyMainHgType" :disabled="true" :options="companyMainHgTypeOptions"/>
              </a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item label="经营范围：" name="companyJyFw">
                <a-textarea v-model:value="formData.companyJyFw" :disabled="true" :rows="10" />
              </a-form-item>
            </a-col>
          </a-row>
        </a-form>
      </div>
      <template #footer></template>
	</a-modal>
</template>

<script setup name="enterpriseDetail">
	import tool from '@/utils/tool'
	import { cloneDeep } from 'lodash-es'
  import qyRecordApi from "@/api/yqyc/qyRecordApi";
	// 抽屉状态
	const open = ref(false)
	const emit = defineEmits({ successful: null })
	const formRef = ref()
	// 表单数据
	const formData = ref({})
  const zzTypeOptions = ref([])
  const companyTypeOptions = ref([])
  const companySupervisionPlaceTypeOptions = ref([])
  const companyMainHgTypeOptions = ref([])
  const zzTypes = ref([])

	// 打开抽屉
	const onOpen = (record, view = false) => {
		open.value = true
		if (record) {
      qyRecordApi.qyRecordGetInfoByCondition({companyCode: record.companyCode}).then(res => {
        formData.value = Object.assign({
          zzTypeArr: res.zzType.split(',')
        }, res)
      })
		}
    zzTypeOptions.value = tool.dictList('applyzztype')
    companyTypeOptions.value = tool.dictList('qylx')
    companySupervisionPlaceTypeOptions.value = tool.dictList('jtcs')
    companyMainHgTypeOptions.value = tool.dictList('zhhg')
	}
	// 关闭抽屉
	const onClose = () => {
		formRef.value.resetFields()
		formData.value = {}
		open.value = false
	}
	// 抛出函数
	defineExpose({
		onOpen
	})
</script>
