<template>
  <div class="container-main" ref="main">
    <div class="filtrate">
      <div class="one-line">
        <div class="select-input">
          <div class="select-span">行政区划:</div>
          <el-cascader
            v-model="subdistrict"
            placeholder="请选择"
            :options="xzList"
            :props="props"
            :disabled="isNoneDivision"
          >
          </el-cascader>
        </div>
        <div class="select-input">
          <div class="select-span">经济类型:</div>
          <el-select v-model="form.economicsType" placeholder="请选择">
            <el-option
              v-for="item in options.economic_categories"
              :key="item.dictValue"
              :label="item.dictLabel"
              :value="item.dictValue"
            >
            </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 options.category"
              :key="item.dictValue"
              :label="item.dictLabel"
              :value="item.dictValue"
            >
            </el-option>
          </el-select>
        </div>
        <div class="select-input">
          <div class="select-span">是否重点:</div>
          <el-select v-model="form.isPoint" placeholder="请选择">
            <el-option label="是" value="1"></el-option>
            <el-option label="否" value="0"></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 options.major_hazard_level"
                :key="item.dictValue"
                :label="item.dictLabel"
                :value="item.dictValue"
              >
              </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 options.entpr_color"
                :key="item.dictValue"
                :label="item.dictLabel"
                :value="item.dictValue"
              >
              </el-option>
            </el-select>
          </div>
          <div class="input-input">
            <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"
        :row-class-name="tableRowClassName"
      >
        <el-table-column
          prop="entprName"
          label="企业名称"
          header-align="center"
        >
        </el-table-column>
        <el-table-column
          prop="majorHazardLevel"
          label="重大危险源等级"
          width="180"
          header-align="center"
        >
          <template slot-scope="scope">
            <div>
              {{
                filterTable(
                  options.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"
                  ? scope.row.indusTypeClass
                  : ""
              }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          prop="entprColor"
          label="企业分色"
          header-align="center"
        >
          <template slot-scope="scope">
            <div>
              {{
                scope.row.enterColorChart != "null"
                  ? scope.row.enterColorChart
                  : ""
              }}
            </div>
          </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"></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 == "null"
                    ? ""
                    : item.value == "false"
                    ? "暂无"
                    : 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";

export default {
  components: { myPagination },
  name: "Order",
  data() {
    return {
      tableData: [],
      form: {
        subdistrict: [],
        frimType: "",
        indusTypeClass: "",
        isPoint: "",
        majorHazardLevel: "",
        entprColor: "",
        uscCode: "",
      },
      props: {
        checkStrictly: true,
        value: "value",
        label: "label",
        children: "children",
      },
      xzqh: "",
      searchBefore: {
        pageSize: 10,
        pageNum: 1,
      },
      xzList: [],
      options: {},
      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: "enterColorChart",
          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,
      //==
      isNoneDivision: false,
      newQHList: [],
      subdistrict: [],
      isPointOption:[
        {
          dictValue:1,
          dictLabel:'是'
        },
        {
          dictValue:0,
          dictLabel:'否'
        },
      ]
    };
  },
  created() {
    this.getList();
    this.getDict();
  },
  computed: {
    ...mapState({
      //根据存储的dept.parentId判断是哪个等级
      dept: (state) => state.user.dept,
    }),
  },
  methods: {
    filterTable(a, b) {
      let arr = [];
      if (!b) return;
      if (a == this.options.major_hazard_level) {
        arr = a.filter((value) => {
          return "0" + value.dictValue == b;
        });
      }
      arr = a.filter((value) => {
        return value.dictValue == b;
      });
      return arr[0].dictLabel;
    },
    shutDownDetail() {
      this.addShow = false;
    },
    look(e) {
      this.addShow = true;
      console.log(e);
      this.details = e;
      for (let key in this.details) {
        this.listDes.forEach((value1, index1) => {
          // if(key == value1.eng ){
          //   this.listDes[index1].value =this.filterTable(this.isPointOption, this.details[key]) ;
          //   return;
          // }
          if (key == value1.eng) {
            this.listDes[index1].value = this.details[key];
            
            return;
          }
        });
      }
      for (let key1 in this.listDes) {
        
      }
      console.log(this.filterTable(this.isPointOption, this.listDes[30].value) );
    },
    getDict() {
      xzTree().then((res1) => {
        console.log(res1);
        if (this.dept.parentId == 0) {
          res1.data.forEach((value, index) => {
            this.xzList.push({
              value: value.county,
              label: value.institutionName,
              children: [],
            });
            if (value.children.length > 0) {
              value.children.forEach((value1, index1) => {
                this.xzList[index].children.push({
                  value: value1.subdistrict,
                  label: value1.institutionName,
                });
              });
            }
          });
        }
      });
      listDist({
        list: "economic_categories,category,major_hazard_level,entpr_color",
      }).then((res) => {
        this.options = res.data;
      });
    },

    searchList() {
      if (this.subdistrict) {
        this.form.subdistrict = this.subdistrict[0];
      }
      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.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: 455px;
          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;
        }
        // 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%);
        }
      }
    }
  }
  .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>
  