<template>
  <el-dialog
    :visible.sync="addShow"
    :show-close="false"
    :destroy-on-close="true"
    :close-on-click-modal="false"
    append-to-body
    custom-class="dialog-boxed"
    width="60%"
  >
    <div class="dialog-slot">
      <div class="closeClick">
        <div class="newplan">
          <div class="line"></div>
          <div class="span">企业详情</div>
        </div>
        <img src="@/assets/images/close.png" alt="" @click="Close" />
      </div>
      <div class="content">
        <div class="filtrate">
          <el-descriptions :column="2" border>
            <el-descriptions-item
                :label="item.label"
                v-for="(item, index) in listDes"
                :key="index"
              >
                {{ item.value}}
              </el-descriptions-item>
          </el-descriptions>
        </div>
      </div>
    </div>
  </el-dialog>
</template>
<script>
export default {
  dicts: [
    "economic_categories",
    "economic_subcategory",
    "special_governance",
    "enterprise_status",
    "standardization_level",
    "safety_level",
    "category",
    "major_hazard_level",
    "entpr_color",
    "is_point",
  ],
  data() {
    return {
      addShow: false,
      listDes: [
        {
          eng: "bizAddr",
          label: "生产经营地址",
          value: "",
        },
        {
          eng: "bossEmail",
          label: "主要负责人电子邮箱",
          value: "",
        },
        {
          eng: "bossMobtel",
          label: "主要负责人移动电话",
          value: "",
        },
        {
          eng: "bossTel",
          label: "主要负责人固定电话",
          value: "",
        },
        {
          eng: "businessScope",
          label: "经营范围",
          value: "",
        },
        {
          eng: "contactEmail",
          label: "电子邮箱",
          value: "",
        },
        {
          eng: "contactQq",
          label: "联系QQ号码",
          value: "",
        },
        {
          eng: "contactTel",
          label: "企业固定电话",
          value: "",
        },
        {
          eng: "cseNum",
          label: "注册安全工程师人员数量",
          value: "",
        },
        // {
        //   eng: "doublePreven",
        //   label: "是否开展双重预防机制",
        //   value: "",
        // },
        {
          eng: "ecoTypeLarge",
          label: "经济类型大类",
          value: "",
        },
        {
          eng: "ecoTypeSmall",
          label: "经济类型小类",
          value: "",
        },
        {
          eng: "employeeNum",
          label: "从业人员数量",
          value: "",
        },
        {
          eng: "entprcolor",
          label: "企业分色",
          value: "",
        },
        // {
        //   eng: "entprId",
        //   label: "企业ID",
        //   value: "",
        // },
        {
          eng: "entprName",
          label: "企业名称",
          value: "",
        },
        // {
        //   eng: "entprPlaneGragh",
        //   label: "企业平面图",
        //   value: "",
        // },
        {
          eng: "floorArea",
          label: "占地面积（㎡）",
          value: "",
        },
        {
          eng: "fullEmegNum",
          label: "专职应急管理人员数量",
          value: "",
        },
        {
          eng: "fullSafety",
          label: "是否有专职安全人员",
          value: "",
        },
        {
          eng: "fullSafetyNum",
          label: "专职安全生产管理人员数量",
          value: "",
        },
        {
          eng: "gridCode",
          label: "网格编码",
          value: "",
        },
        {
          eng: "gridEntprStatus",
          label: "网格对企业的关停和恢复",
          value: "",
        },
        {
          eng: "groupCompName",
          label: "集团公司名称",
          value: "",
        },
        {
          eng: "indusTypeClass",
          label: "行业类别门类",
          value: "",
        },
        // {
        //   eng: "indusTypeLagre",
        //   label: "行业类别大类",
        //   value: "",
        // },
        // {
        //   eng: "indusTypeMiddle",
        //   label: "行业类别中类",
        //   value: "",
        // },
        // {
        //   eng: "indusTypeSmall",
        //   label: "行业类别小类",
        //   value: "",
        // },
        // {
        //   eng: "industryRefer",
        //   label: "工贸涉及(专项治理类别)",
        //   value: "",
        // },
        {
          eng: "infoYear",
          label: "数据年份",
          value: "",
        },

        {
          eng: "isPoint",
          label: "是否重点",
          value: "",
        },

        {
          eng: "latitudeGps",
          label: "纬度（度） 84",
          value: "",
        },
        {
          eng: "legalPerson",
          label: "法定代表人",
          value: "",
        },
        {
          eng: "localSafetyAdmin",
          label: "属地安监机构",
          value: "",
        },
        {
          eng: "longitudeGps",
          label: "经度（度） 84",
          value: "",
        },
        {
          eng: "mainProduct",
          label: "主要产品",
          value: "",
        },
        {
          eng: "majorHazardInstallations",
          label: "是否存在重大危险源",
          value: "",
        },
        {
          eng: "majorHazardLevel",
          label: "重大危险源等级",
          value: "",
        },
        {
          eng: "operatingStatus",
          label: "经营状态",
          value: "",
        },
        {
          eng: "parentCompName",
          label: "母公司名称",
          value: "",
        },
        {
          eng: "partSafetyNum",
          label: "兼职安全生产管理人员数量",
          value: "",
        },
        {
          eng: "regAddr",
          label: "注册地址",
          value: "",
        },
        {
          eng: "regCapi",
          label: "注册资金（万元）",
          value: "",
        },
        {
          eng: "safetyDepart",
          label: "是否有专门安全机构",
          value: "",
        },
        {
          eng: "safetyDepartDuty",
          label: "安全管理机构职责",
          value: "",
        },
        {
          eng: "safetyDepartName",
          label: "安全管理机构名称",
          value: "",
        },
        {
          eng: "safetyDepartNum",
          label: "安全管理机构成员数量",
          value: "",
        },
        {
          eng: "safetyEmail",
          label: "安全负责人电子邮箱",
          value: "",
        },
        {
          eng: "safetyManager",
          label: "安全负责人",
          value: "",
        },
        {
          eng: "safetyMobtel",
          label: "安全负责人移动电话",
          value: "",
        },
        {
          eng: "safetySupervisionLevel",
          label: "安全监管等级",
          value: "",
        },
        {
          eng: "safetyTel",
          label: "安全负责人固定电话",
          value: "",
        },
        {
          eng: "setupDate",
          label: "成立日期",
          value: "",
        },
        {
          eng: "sourceData",
          label: "数据来源",
          value: "",
        },
        {
          eng: "specialGovernance",
          label: "专项治理类别",
          value: "",
        },
        {
          eng: "speclalOperationNum",
          label: "特种作业人员数量",
          value: "",
        },
        {
          eng: "standLevel",
          label: "标准化等级",
          value: "",
        },
        {
          eng: "stateOwed",
          label: "是否为国有企业",
          value: "",
        },
        // {
        //   eng: "supervisionLarge",
        //   label: "行业监管大类",
        //   value: "",
        // },
        // {
        //   eng: "supervisionSmall",
        //   label: "行业监管小类",
        //   value: "",
        // },
        {
          eng: "uscCode",
          label: "统一社会信用代码",
          value: "",
        },
      ],
      details:null
    }
  },
  methods:{
    async open(option) {
      this.addShow = true;
      this.look(option)
      // const { bizAddr,
      //         bossEmail,
      //         bossMobtel,
      //         bossTel,
      //         businessScope,
      //         contactEmail,
      //         contactQq,
      //         contactTel,
      //         cseNum,
      //         doublePreven,
      //         employeeNum,
      //         enterColorChart,
      //         entprName,
      //         entprPlaneGragh,
      //         floorArea,
      //         fullEmegNum,
      //         fullSafety,
      //         fullSafetyNum,
      //         gridCode,
      //         gridEntprStatus,
      //         groupCompName,
      //         indusTypeClass,
      //         industryRefer,
      //         infoYear,
      //         isPoint,
      //         latitudeGps,
      //         legalPerson,
      //         localSafetyAdmin,
      //         longitudeGps,
      //         mainProduct,
      //         majorHazardInstallations,
      //         majorHazardLevel,
      //         operatingStatus,
      //         parentCompName,
      //         partSafetyNum,
      //         regAddr,
      //         regCapi,
      //         safetyDepart,
      //         safetyDepartDuty,
      //         safetyDepartName,
      //         safetyDepartNum,
      //         safetyEmail,
      //         safetyManager,
      //         safetyMobtel,
      //         safetySupervisionLevel,
      //         safetyTel,
      //         setupDate,
      //         sourceData,
      //         specialGovernance,
      //         speclalOperationNum,
      //         standLevel,
      //         stateOwed,
      //         supervisionLarge,
      //         supervisionSmall,
      //         uscCode } = option
      // this.changeDescriptions(this.listDes,option)
    },
    Close(item) {
      this.addShow = false;
      this.details = null
    },
    changeDescriptions(arr,arr2){
      for (let key in arr2) {
        if (arr2.hasOwnProperty(key)) {
          arr.map((item)=>{
            if(key == item.eng){
              item.value = arr2[key] || '空'
              if(item.eng == 'isPoint'){
                item.value = arr2[key] == '1' ? '是':arr2[key] == '2' ? '否':''
              }
            }
          })
        }
      }
    },
    filterTable(a, b) {
      if (!b) return;
      return this.selectDictLabel(a, b);
    },
    look(e) {
      this.details = e;
      // console.log(e)
      for (let key in this.details) {
        this.listDes.forEach((value1, index1) => {
          if (key == value1.eng) {
            this.listDes[index1].value = this.details[key] == '无' ? '/' : this.details[key] == 'true' ? '是' : this.details[key];
            return;
          }
        });
      }
      this.listDes.forEach((value1, index1) => {
        //重大危险源等级
        if (value1.eng == "majorHazardLevel") {
          this.listDes[index1].value = this.filterTable(
            this.dict.type.major_hazard_level,
            value1.value
          );
        }
        //经济类型大类
        if (value1.eng == "ecoTypeLarge") {
          this.listDes[index1].value = this.filterTable(
            this.dict.type.economic_categories,
            value1.value
          );
        }
        //经济类型小类
        if (value1.eng == "ecoTypeSmall") {
          this.listDes[index1].value = this.filterTable(
            this.dict.type.economic_subcategory,
            value1.value
          );
        }
        //专项治理类别
        if (value1.eng == "specialGovernance") {
          this.listDes[index1].value = this.filterTable(
            this.dict.type.special_governance,
            value1.value
          );
        }
        //隶属关系
        //企业经营状态
        if (value1.eng == "operatingStatus") {
          this.listDes[index1].value = this.filterTable(
            this.dict.type.enterprise_status,
            value1.value
          );
        }
        //标准化等级
        if (value1.eng == "standLevel") {
          this.listDes[index1].value = this.filterTable(
            this.dict.type.standardization_level,
            value1.value
          );
        }
        //安全监管等级
        if (value1.eng == "safetySupervisionLevel") {
          this.listDes[index1].value = this.filterTable(
            this.dict.type.safety_level,
            value1.value
          );
        }
        //检查来源
        //文书类型
        // 检查方式
        // 企业分色
        if (value1.eng == "entprColor") {
          this.listDes[index1].value = this.filterTable(
            this.dict.type.entpr_color,
            value1.value
          );
        }
        // 行业类型
        if (value1.eng == "indusTypeClass") {
          this.listDes[index1].value = this.filterTable(
            this.dict.type.category,
            value1.value
          );
        }
        //是否重点
        if (value1.eng == "isPoint") {
          this.listDes[index1].value = this.filterTable(
            this.dict.type.is_point,
            value1.value
          );
        }
        if (value1.value == null ) {
          this.listDes[index1].value = '/'
        }
        if ( value1.value == 'false') {
          this.listDes[index1].value = '否'
        }
      });
    },
  },
}
</script>
<style lang="scss" scoped>
::v-deep .el-descriptions-row th {
  width: 20% !important;
  font-size: 14px;
  font-family: "Alibaba PuHuiTi";
  font-weight: 400;
}
::v-deep .el-descriptions-row td {
  width: 30% !important;
  font-size: 14px;
  font-family: "Alibaba PuHuiTi";
  font-weight: 400;
}
.dialog-slot {
  .closeClick {
    position: absolute;
    top: 0;
    right: 0;
    padding: 10px 20px;
    width: 100%;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: center;
    background: #f8f9fa;
    box-shadow: 0px 1px 0px 0px #dbe0e8;
    background-color: #e0eaf8;
    img {
      width: 18px;
      height: 18px;
      cursor: pointer;
    }
    .newplan {
      display: flex;
      align-items: center;
      .line {
        margin-right: 10px;
        width: 5px;
        height: 16px;
        background-color: #1e70de;
      }
      .span {
        font-size: 16px;
        font-family: "Alibaba PuHuiTi";
        font-weight: bold;
        color: #1e70de;
      }
    }
  }
  .content {
    // padding: 15px 10px;
    .filtrate {
      padding-bottom: 10px;
    }
  }
}
::v-deep .el-dialog__body {
  padding: 30px 15px;
}
</style>
