<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="value"
              v-for="(key, value) in elDesLabels"
              :key="key"
              :span="
                key == 'majorProduct' ||
                key == 'businessScope' ||
                key == 'subdistrict' ||
                key == 'rigisterAddress'
                  ? 2
                  : 1
              "
            >
              {{ infoData[key] || "/" }}
            </el-descriptions-item>
          </el-descriptions>
        </div>
      </div>
    </div>
  </el-dialog>
</template>
<script>
import dictzh from "@/utils/dictzh.js";
import { xzTree } from "@/api/yingji/keyEnterprise.js";

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,
      infoData: {},
      areaData: [],
      dictzh: dictzh,
      elDesLabels: {
        企业名称: "enterpriseName",
        统一社会信用代码: "uuitNo",
        法定代表人: "legalPerson",
        法人证件号: "frzjh",
        是否规上企业: "aboveDesignated",
        企业规模: "aboveDesignatedTwo",
        企业类型: "zjEconKind",
        生产经营地址: "businessAddress",
        行业监管大类: "supervisionLarge",
        "所在乡镇（街道）": "subdistrict",
        注册地址: "rigisterAddress",
        主营业务及产品: "majorProduct",
        经营范围: "businessScope",
        登记状态: "corpStatus",
        // 行政区划: "county",
        办公地址: "enterpriseAddress",
        企业规模: "enterpristScale",
        固定资产: "fixedAssets",
        占地面积: "floorSpace",
        上一年经营收入: "lastYearOperatingIncome",
        企业上一年投入生产: "lastYeatOnStream",
        法人移动电话: "legalPersonCellphone",
        法人职务: "legalPersonPost",
        法人固定电话: "legalPersonTel",
        法人类型: "legalPersonType",
        机构编码: "orgCode",
        其他名称: "otherName",
        登记时间: "registerTime",
        登记机关: "registrationOrg",
        注册资金: "rigisterFund",
        是否上报风险报告: "riskReport",
        安全生产投入占比: "safetyProductionInvestment",
        申请人: "sqr",
        申请人联系方式: "sqrlxfs",
        成立时间: "startTime",
        有效期起: "termStart",
        有效期止: "termEnd",
        创建时间: "createTime",
        修改时间: "updateTime",
        备注: "remark",
        // 工艺流程内容: "htmlText",
        // :"updateBy",
        // :"updateId",
        // :"updater",
        // :"userId",
        // :"village",
        // :"supervisionSmall",
        // :"reportHistoryId",
        // :"indusTypeClass",
        // :"indusTypeLagre",
        // :"indusTypeMiddle",
        // :"indusTypeSmall",
        // :"isDelete",
        // :"jhptUpdateTime",
        // :"lastPageNumber",
        // :"creater",
        // :"deptId",
        // :"districtCode",
        // :"province",
        // :"createBy",
        // :"createId",
        // :"businessScope",
        // :"city",
      },
    };
  },
  created() {
    this.$nextTick(() => {
      this.xzList();
    });
  },
  methods: {
    supervisionLarge(value) {
      // console.log(value.split(","));
      let array = value.split(",");
      array.map((item, ind) => {
        array[ind] = dictzh[item];
      });
      // console.log(array.join(","));
      return array.join(",");
    },
    async open(option) {
      this.addShow = true;
      this.look(option);
    },
    Close(item) {
      this.addShow = false;
    },
    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) {
      localStorage.setItem("enterInfo", JSON.stringify(e));
      let infoObj = JSON.parse(localStorage.getItem("enterInfo"));
      // 查看弹窗
      this.addShow = true;
      infoObj["aboveDesignated"] =
        infoObj.aboveDesignated == 1 ? "规上" : "规下";
      infoObj["riskReport"] = infoObj.riskReport == 1 ? "是" : "否";
      infoObj["aboveDesignatedTwo"] =
        infoObj.aboveDesignatedTwo == 1
          ? "大型"
          : infoObj.aboveDesignatedTwo == 2
          ? "中型"
          : infoObj.aboveDesignatedTwo == 3
          ? "小型"
          : infoObj.aboveDesignatedTwo == 4
          ? "微型"
          : "";
      infoObj["supervisionLarge"] = this.supervisionLarge(
        infoObj.supervisionLarge
      );
      infoObj["subdistrict"] =
        this.componendDistrict(infoObj.subdistrict) || "/";
      this.infoData = infoObj;
    },
    // 行政区域树状
    xzList() {
        let treeData =  JSON.parse(localStorage.getItem("TREE_DATA"))
        treeData.forEach((value, index) => {
          this.areaData.push({
            value: value.subdistrict,
            label: value.institutionName,
            children: [],
          });
          if (value.children.length > 0) {
            value.children.forEach((value1, index1) => {
              this.areaData[index].children.push({
                value: value1.subdistrict,
                label: value1.institutionName,
              });
            });
          }
        });
    },
    // 匹配行政区划
    componendDistrict(district) {
      let name;
      this.areaData.map((item) => {
        if (item.value == district) {
          name = item.label;
        } else {
          item.children.map((itemTwo) => {
            if (itemTwo.value == district) {
              name = item.label + "-" + itemTwo.label;
            }
          });
        }
      });
      return name;
    },
  },
};
</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>
