<!--
 * @Descripttion: 
 * @version: 
 * @Author: JC9527
 * @Date: 2023-09-28 11:25:48
 * @LastEditors: JC9527
 * @LastEditTime: 2023-10-11 11:06:21
-->
<template>
  <el-dialog
    :visible.sync="dialogVisible"
    :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="closeDialog" />
      </div>
      <div v-loading="loading">
        <el-descriptions :column="2" border>
          <el-descriptions-item
            :label="value"
            v-for="(key, value) in ObjectIndex"
            :key="key"
          >
            {{
              key == "district"
                ? componendDistrict(resData[key])
                : key == "status"
                ? fStatus(resData[key])
                : key == "checkStatus"
                ? fcheckStatus(resData[key])
                : key == "checkAgeing"
                ? fcheckAgeing(resData[key])
                : resData[key]
            }}
          </el-descriptions-item>
        </el-descriptions>
      </div>
    </div>
  </el-dialog>
</template>
<script>
export default {
  data() {
    return {
      dialogVisible: false,
      mydistrict: "",
      id: "",
      idTwo: "",
      readonly: false,
      loading: true,
      objInd1: {
        企业名称: "enterpriseName",
        统一信用代码: "enterpriseId",
        行政区划: "district",
        计划年份: "plannedYear",
        计划月份: "plannedMonth",
        执法地区: "lawAreas",
        执法级别: "lawLevel",
        执法层级: "lawHierarchy",
        状态: "status",
        检查状态: "checkStatus",
        检查失效: "checkAgeing",
        发布时间: "createTime",
        备注: "remark",
      },
      ObjectIndex: {},
      district: [],
      resData: {},
    };
  },
  methods: {
    openDialog(row) {
      this.dialogVisible = true;
      this.loading = false;
      row["createTime"] = this.$moment(row.createTime).format("yyyy-MM-DD");
      this.ObjectIndex = this.objInd1;
      this.resData = row;
      // console.log(row);
    },
    closeDialog() {
      this.dialogVisible = false;
    },
    fStatus(e) {
      return e == 1 ? "正式" : e == 0 ? "草稿" : "";
    },
    fcheckStatus(e) {
      return e == 1 ? "已检查" : "未检查";
    },
    fcheckAgeing(e) {
      switch (e) {
        case 1:
          return "当月";
        case 2:
          return "提前";
        case 3:
          return "滞后";
        default:
          return "/";
      }
    },
    // 匹配行政区划
    componendDistrict(district) {
      let fullName;
      let treeData = JSON.parse(localStorage.getItem("TREE_DATA"));
      treeData.map((item) => {
        if (item.districtCode == district) {
          fullName = item.district;
        } else {
          item.children.map((itemTwo) => {
            if (itemTwo.countyCode == district) {
              fullName = item.district + "-" + itemTwo.county;
            }
          });
        }
      });
      return fullName;
    },
  },
};
</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;
      }
    }
  }
  .form-input {
    display: inline-block;
    width: 50%;
  }
  ::v-deep .el-input {
    .el-input__inner {
      font-size: 15px;
      font-family: "Alibaba PuHuiTi";
      font-weight: 400;
      color: #525966;
    }
  }
  .form-textarea {
    ::v-deep .el-textarea {
      height: 180px;
      .el-textarea__inner {
        height: 100%;
        font-size: 15px;
        font-family: "Alibaba PuHuiTi";
        font-weight: 400;
        color: #525966;
      }
    }
  }
  .btns {
    text-align: right;
    ::v-deep .el-button {
      border-radius: 4px;
    }
  }
}
::v-deep .el-dialog__body {
  padding: 30px 15px;
}
</style>
