<template>
  <ContentWrap>

    <el-form
      ref="formRef"
      :model="formData"
      :rules="formRules"
      label-width="100px"
      v-loading="formLoading"
    >

      <el-form-item label="企业名称"  prop="enterprisesName">
        <el-input v-model="formData.enterprisesName" placeholder="请输入企业名称"  readonly="true"/>
      </el-form-item>
      <el-form-item label="企业类型" prop="type">

        <el-select v-model="formData.type" placeholder="请选择企业类型" readonly="true" >
          <el-option
            v-for="dict in getStrDictOptions(DICT_TYPE.ENTERPRISES_TYPE)"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>

        <el-input v-model="formData.enterprisesName" placeholder="请输入企业名称"  readonly="true"/>
      </el-form-item>
      <el-form-item label="企业所属区域" prop="region">
        <el-select v-model="formData.region" placeholder="请选择企业所属区域">
          <el-option
            v-for="dict in getStrDictOptions(DICT_TYPE.ENTERPRISES_AREA)"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="企业地址" prop="address">
        <el-input v-model="formData.address" type="textarea" placeholder="请输入企业地址" readonly="true"/>
      </el-form-item>
      <el-form-item label="环保负责人姓名" prop="contactName">
        <el-input v-model="formData.contactName" placeholder="请输入环保负责人姓名" readonly="true" />
      </el-form-item>
      <el-form-item label="企业环保负责人联系电话" prop="environmentalContactPhone">
        <el-input v-model="formData.environmentalContactPhone" placeholder="请输入企业环保负责人联系电话" readonly="true" />
      </el-form-item>
      <el-form-item label="企业注册号" prop="registrationNumber">
        <el-input v-model="formData.registrationNumber" placeholder="请输入企业注册号" />
      </el-form-item>
      <el-form-item label="企业介绍" prop="introduction">
        <el-input v-model="formData.introduction" type="textarea" placeholder="请输入企业介绍" />
      </el-form-item>
      <el-form-item label="企业照片" prop="size">
        <InnerUploadImg
          :uploadList="uploadList"
          @handler-success="uploadSuccess"
          ref="uploadRef"
          @handler-remove="uploadRemove"
        />
      </el-form-item>

      <el-form-item label="企业成立时间" prop="establishmentDate">
        <el-date-picker
          v-model="formData.establishmentDate"
          type="date"
          value-format="x"
          placeholder="选择企业成立时间"
        />
      </el-form-item>
      <el-form-item label="企业经纬度" prop="gpsLocation">
        <el-input v-model="formData.gpsLocation" placeholder="请输入企业经纬度" />
      </el-form-item>
      <el-form-item label="管理部门" prop="managerDeptId">
        <el-select v-model="formData.managerDeptId" placeholder="请选择管理部门">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>

      <el-form-item label="资质整明" prop="managerDeptId">
        <el-select v-model="formData.managerDeptId" placeholder="请选择管理部门">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>

      <el-form-item label="执法记录" prop="managerDeptId">
        <el-select v-model="formData.managerDeptId" placeholder="请选择管理部门">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
    </el-form>

  </ContentWrap>
</template>s
<script setup lang="ts">
import { getStrDictOptions, DICT_TYPE } from '@/utils/dict'
import { EnterprisesApi, EnterprisesVO, } from '@/api/enterprises'
import { FileInfoApi } from '@/api/enterprises/fileinfo'
import { ElMessage,ElLoading } from 'element-plus'

/** 企业 表单 */


const formLoading = ref(false) // 表单的加载中：1）修改时的数据加载；2）提交的按钮禁用
const formData = ref({
  id: undefined,
  departmentId: undefined,
  userId: undefined,
  type: undefined,
  region: undefined,
  enterprisesName: undefined,
  address: undefined,
  contactName: undefined,
  environmentalContactPhone: undefined,
  registrationNumber: undefined,
  introduction: undefined,
  establishmentDate: undefined,
  gpsLocation: undefined,
  managerDeptId: undefined,
  ides:undefined
})
const formRules = reactive({
  type: [{ required: true, message: '企业类型不能为空', trigger: 'change' }],
  enterprisesName: [{ required: true, message: '企业名称不能为空', trigger: 'blur' }],
})
const formRef = ref() // 表单 Ref
const route=useRoute()

function getDetail(){
  EnterprisesApi.getEnterprises(route.query.id as any).then(res=>{
    formData.value=res
  })
}

  getDetail()

</script>
