<template>
  <div class="container-main" ref="main">
    <div class="filtrate">
      <div class="one-line">
        <div class="select-input">
          <div class="select-span">行政区划:</div>
          <executive
            @quhua="quhua"
            @quhuadizhi="quhuadizhi"
            ref="executive"
          ></executive>
        </div>
        <div class="select-input">
          <div class="select-span">经济类型:</div>
          <el-select v-model="form.ecoTypeLarge" placeholder="请选择">
            <el-option
              v-for="item in dict.type.economic_categories"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </div>

        <div class="select-input">
          <div class="select-span">行业类型:</div>
          <el-select v-model="form.indusTypeClass" placeholder="请选择">
            <el-option
              v-for="item in dict.type.category"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </div>
        <!-- <div class="select-input">
          <div class="select-span">是否重点:</div>
          <el-select v-model="form.isPoint" placeholder="请选择">
            <el-option
              v-for="item in dict.type.is_point"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </div> -->
        <div class="select-input">
          <div class="select-span">企业分色:</div>
          <el-select v-model="form.entprColor" placeholder="请选择">
            <el-option
              v-for="item in dict.type.entpr_color"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </div>
      </div>
      <div class="two-line">
        <div class="two-line-left">
          <div class="select-input">
            <div class="select-span">重大危险源等级:</div>
            <el-select v-model="form.majorHazardLevel" placeholder="请选择">
              <el-option
                v-for="item in dict.type.major_hazard_level"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </div>

          <div class="input-input" style="margin-left: 10px">
            <div class="select-span">统一社会信用代码:</div>
            <el-input
              v-model="form.uscCode"
              placeholder="请输入统一社会信用代码"
            ></el-input>
          </div>
        </div>
        <div class="select-btn" @click="searchList">搜索</div>
        <div
          class="select-btn"
          @click="chongzhiList"
          style="background-color: #fdab5b"
        >
          重置
        </div>
      </div>
    </div>
    <div class="tables">
      <el-table
        v-loading="load1"
        :data="tableData"
        style="width: 100%"
        :height="497"
        :border="false"
        tooltip-effect="light"
        :row-class-name="tableRowClassName"
      >
        <el-table-column
          prop="entprName"
          label="企业名称"
          show-overflow-tooltip
          header-align="center"
        >
        </el-table-column>
        <el-table-column
          prop="majorHazardLevel"
          label="行政区划"
          width="180"
          header-align="center"
        >
          <template slot-scope="scope">
            <span>{{ componendDistrict(scope.row.subdistrict) || '/' }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="majorHazardLevel"
          label="重大危险源等级"
          width="180"
          header-align="center"
        >
          <template slot-scope="scope">
            <div>
              {{
                filterTable1(
                  dict.type.major_hazard_level,
                  scope.row.majorHazardLevel
                )
              }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          prop="indusTypeClass"
          label="行业类型"
          width="180"
          header-align="center"
        >
          <template slot-scope="scope">
            <div>
              {{
                scope.row.indusTypeClass != "null"
                  ? filterTable1(dict.type.category, scope.row.indusTypeClass)
                  : "/"
              }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          prop="entprColor"
          label="企业分色"
          header-align="center"
        >
          <template slot-scope="scope">
            <dict-tag
              :options="dict.type.entpr_color"
              :value="scope.row.entprColor ? scope.row.entprColor : '/'"
            >
            </dict-tag>
          </template>
        </el-table-column>

        <el-table-column
          prop="uscCode"
          label="统一社会信用代码"
          header-align="center"
        >
        </el-table-column>
        <!-- <el-table-column prop="isPoint" label="是否重点" header-align="center">
          <template slot-scope="scope">
            <div
              style="font-family: 'Alibaba PuHuiTi'"
              :class="scope.row.isPoint == '1' ? 'isStyle' : ''"
            >
              <span v-if="scope.row.isPoint == '1'">是</span>
              <span v-if="scope.row.isPoint == '0'">否</span>
            </div>
          </template>
        </el-table-column> -->
        <el-table-column label="操作" header-align="center">
          <template slot-scope="scope">
            <div class="tabs-btns">
              <div class="look" @click="look(scope.row)">
                <img src="@/assets/images/lookInfo.png" alt="" />
                <span>查看详情</span>
              </div>
            </div>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="pagination">
      <my-pagination
        :total="total"
        @pagesChange="pagesChange"
        ref="mypagination"
      ></my-pagination>
    </div>
    <!-- 查看 -->
    <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="50%"
    >
      <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="shutDownDetail" />
        </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>
  </div>
</template>
  
  <script>
import myPagination from "@/views/components/myPagination/index.vue";
import { businessList, listDist, xzTree } from "@/api/yingji/keyEnterprise";
// import { mapState } from "vuex";
import executive from "./echarts/executive";

export default {
  components: { myPagination, executive },
  name: "Order",
  data() {
    return {
      tableData: [],
      option: [],
      form: {},
      xzqh: "",
      searchBefore: {
        pageSize: 10,
        pageNum: 1,
      },
      xzList: [],
      load1: true,
      total: 0,
      main: {
        height: "",
      },
      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: "",
        },
      ],
      addShow: false,
      details: null,
      //==
      subdistrict: [],
    };
  },
  created() {
    this.getList();
  },
  dicts: [
    "economic_categories",
    "economic_subcategory",
    "special_governance",
    "enterprise_status",
    "standardization_level",
    "safety_level",
    "category",
    "major_hazard_level",
    "entpr_color",
    "is_point",
  ],

  methods: {
    // 匹配行政区划
    componendDistrict(district) {
      let name;
      this.option.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;
    },
    // 获取行政区划树
    quhuadizhi(district) {
      this.option = district;
    },
    filterTable1(datas, value) {
      if (!value) {
        return "/";
      }
      var actions = [];
      datas.forEach((value1, index1) => {
        actions.push(value1.raw);
      });
      let newarr = actions.filter((value2) => {
        return value2.dictValue == value;
      });
      if (newarr.length > 0) {
        return newarr[0].dictLabel;
      } else {
        return "/";
      }
    },
    shutDownDetail() {
      this.addShow = false;
    },
    look(e) {
      this.addShow = true;
      this.details = 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];
            return;
          }
        });
      }
      this.listDes.forEach((value1, index1) => {
        //重大危险源等级
        if (value1.eng == "majorHazardLevel") {
          this.listDes[index1].value = this.filterTable1(
            this.dict.type.major_hazard_level,
            value1.value
          );
        }
        //经济类型大类
        if (value1.eng == "ecoTypeLarge") {
          this.listDes[index1].value = this.filterTable1(
            this.dict.type.economic_categories,
            value1.value
          );
        }
        //经济类型小类
        if (value1.eng == "ecoTypeSmall") {
          this.listDes[index1].value = this.filterTable1(
            this.dict.type.economic_subcategory,
            value1.value
          );
        }
        //专项治理类别
        if (value1.eng == "specialGovernance") {
          this.listDes[index1].value = this.filterTable1(
            this.dict.type.special_governance,
            value1.value
          );
        }
        //隶属关系
        //企业经营状态
        if (value1.eng == "operatingStatus") {
          this.listDes[index1].value = this.filterTable1(
            this.dict.type.enterprise_status,
            value1.value
          );
        }
        //标准化等级
        if (value1.eng == "standLevel") {
          this.listDes[index1].value = this.filterTable1(
            this.dict.type.standardization_level,
            value1.value
          );
        }
        //安全监管等级
        if (value1.eng == "safetySupervisionLevel") {
          this.listDes[index1].value = this.filterTable1(
            this.dict.type.safety_level,
            value1.value
          );
        }
        //检查来源
        //文书类型
        // 检查方式
        // 企业分色
        if (value1.eng == "entprColor") {
          this.listDes[index1].value = this.filterTable1(
            this.dict.type.entpr_color,
            value1.value
          );
        }
        // 行业类型
        if (value1.eng == "indusTypeClass") {
          this.listDes[index1].value = this.filterTable1(
            this.dict.type.category,
            value1.value
          );
        }
        //是否重点
        if (value1.eng == "isPoint") {
          this.listDes[index1].value = this.filterTable1(
            this.dict.type.is_point,
            value1.value
          );
        }
        if (value1.value == null) {
          this.listDes[index1].value = "/";
        }
        if (value1.value == "false") {
          this.listDes[index1].value = "否";
        }
        if (value1.value == "true") {
          this.listDes[index1].value = "是";
        }
      });
    },
    quhua(e) {
      this.form.subdistrict = e;
    },
    searchList() {
      this.searchBefore = {
        pageSize: 10,
        pageNum: 1,
      };
      this.$refs.mypagination.defaultPages();
      this.searchBefore = { ...this.searchBefore, ...this.form };
      this.getList();
    },
    chongzhiList() {
      this.form = {
        subdistrict: "",
        frimType: "",
        indusTypeClass: "",
        // isPoint: "",
        majorHazardLevel: "",
        entprColor: "",
        uscCode: "",
      };
      this.searchBefore = {
        pageSize: 10,
        pageNum: 1,
      };
      this.$refs.executive.district = [];
      this.$refs.mypagination.defaultPages();
      this.getList();
    },
    // 页码，当前页切换事件
    pagesChange(pages) {
      this.searchBefore.pageNum = pages.pageNum;
      this.searchBefore.pageSize = pages.pageSize;
      this.getList();
    },
    getList() {
      this.load1 = true;
      businessList(this.searchBefore).then((res) => {
        this.tableData = res.data.list;
        this.total = res.data.total;
        this.load1 = false;
      });
    },
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex % 2 !== 0) {
        return "success-row";
      }
      return "";
    },
  },
  // mounted() {
  //   this.checkListTwo = this.checkList;
  //   // this.$nextTick(()=>{
  //   //   let dom = document.getElementsByClassName('tables');
  //   //   let height = dom[0].getBoundingClientRect();
  //   //   let windowHeight = window.innerHeight;
  //   //   let relativeHeight = windowHeight - height.top
  //   //   this.main.height = relativeHeight - 50
  //   // })
  // },
};
</script>
  <style lang="scss" scoped>
.isStyle {
  color: #f71052;
}
::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;
      // .select-input {
      //   // margin-right: 10px;
      //   margin-top: 20px;
      //   display: flex;
      //   align-items: center;
      //   .select-span {
      //     font-size: 13px;
      //     font-family: "Alibaba PuHuiTi";
      //     font-weight: 400;
      //     color: #525966;
      //     // line-height: 40px;
      //     margin-right: 10px;
      //   }
      //   ::v-deep .el-select,
      //   .el-cascader {
      //     background-color: transparent;
      //     width: 180px;
      //     .el-input__inner {
      //       height: 33px;
      //     }
      //     // border-radius: 2px;
      //     .el-input
      //       .el-input__suffix
      //       .el-input__suffix-inner
      //       .el-icon-arrow-up::before {
      //       content: "";
      //       background: url(../../assets/images/down2.png) center center
      //         no-repeat;
      //       background-size: cover;
      //       position: absolute;
      //       width: 10px;
      //       height: 7px;
      //       top: 50%;
      //       left: 50%;
      //       transform: translate(-50%, -50%);
      //     }
      //   }
      // }
      // .select-input {
      //   width: 45%;
      //   ::v-deep .el-input {
      //     .el-input__inner {
      //       height: 33px;
      //     }
      //   }
      // }
      // .select-btn {
      //   width: 80px;
      //   height: 33px;
      //   background: #2378ec;
      //   border-radius: 2px;
      //   display: flex;
      //   align-items: center;
      //   justify-content: center;
      //   font-size: 15px;
      //   font-family: Alibaba PuHuiTi;
      //   font-weight: 500;
      //   color: #ffffff;
      //   cursor: pointer;
      //   margin-right: 10px;
      // }
      // .select-btn1 {
      //   background: #28b384;
      // }
    }
  }
}
.container-main {
  // height: calc(100vh - 84px);
  height: 100%;
  overflow: hidden;
  padding: 0 20px;
  background-color: #fff;
  .filtrate {
    // display: flex;
    // align-items: center;
    // justify-content: space-between;
    // flex-wrap: wrap;
    padding-bottom: 10px;
    .one-line,
    .two-line {
      display: flex;
      align-items: center;
      justify-content: space-between;
      .two-line-left {
        display: flex;
        align-items: center;
        // justify-content: space-between;
        padding-right: 50px;
        width: 88%;
        .input-input {
          margin: 10px 0 0 0;
          width: 355px;
          display: flex;
          align-items: center;
          .select-span {
            font-size: 14px;
            font-family: "Alibaba PuHuiTi";
            font-weight: 400;
            color: #525966;
            line-height: 40px;
            margin-right: 10px;
          }
          ::v-deep .el-input {
            flex: 1;
            .el-input__inner {
              height: 33px;
            }
          }
        }
      }
      .select-btn {
        padding: 12px 20px;
        margin: 10px 0 0 0;
        height: 33px;
        background: #2378ec;
        border-radius: 2px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 15px;
        font-family: Alibaba PuHuiTi;
        font-weight: 500;
        color: #ffffff;
        cursor: pointer;
      }
    }
    // .two-line {
    //   display: flex;
    //   align-items: center;
    //   justify-content: space-between;
    // }
    .select-input {
      // margin-right: 10px;
      margin-top: 10px;
      display: flex;
      align-items: center;
      .select-span {
        font-size: 14px;
        font-family: "Alibaba PuHuiTi";
        font-weight: 400;
        color: #525966;
        line-height: 40px;
        margin-right: 10px;
      }
      ::v-deep .el-select {
        background-color: transparent;
        width: 210px;
        .el-input__inner {
          height: 33px;
        }
        .el-input .el-input__suffix .el-input__suffix-inner .el-icon-arrow-up {
          display: flex;
          align-items: center;
          justify-content: center;
        }
        // border-radius: 2px;
        .el-input
          .el-input__suffix
          .el-input__suffix-inner
          .el-icon-arrow-up::before {
          content: "";
          background: url(../../assets/images/down2.png) center center no-repeat;
          background-size: cover;
          position: absolute;
          width: 10px;
          height: 7px;
          // top: 50%;
          // left: 50%;
          // transform: translate(-50%, -50%);
          transform: rotate(180deg);
        }
      }
    }
  }
  .tables {
    background-color: #eaf2fd;
    .tabs-btns {
      display: flex;
      align-items: center;
      justify-content: center;
      .look {
        display: flex;
        align-items: center;
        cursor: pointer;
        img {
          width: 20px;
          margin-right: 5px;
        }
        span {
          font-size: 15px;
          font-family: Alibaba PuHuiTi;
          font-weight: 400;
          color: #045ffd;
        }
      }
    }
    ::v-deep .el-table {
      .success-row {
        background-color: rgba(234, 242, 253, 0.25);
      }
      td {
        height: 45px;
        text-align: center;
        font-size: 14px;
        font-family: "Alibaba PuHuiTi";
        font-weight: 400;
        color: #525966;
      }
      th {
        height: 42px;
        background-color: #eaf2fd;
        font-size: 15px;
        font-family: "Alibaba PuHuiTi";
        font-weight: bold;
        color: #525966;
        .el-checkbox {
          display: none;
        }
      }
      // .el-table__body-wrapper {
      //   height: 450px !important;
      //   overflow-y: auto;
      // }
    }
    ::v-deep .el-table::before {
      height: 0;
    }
  }
  .pagination {
    margin-top: 10px;
  }
}
</style>
  