<template>
  <div class="wrapper">
    <span class="dot-left"></span>
    <div class="top display-default">
      <div class="left text ddd" :title="data.troubleName">
        {{ data.troubleName }}
      </div>
      <div class="right text">
        <img src="../../assets/images/closeBtn.png" alt="" @click="close" />
      </div>
    </div>
    <!-- 设备信息 -->
    <div class="content  scrollStyle">
      <div class="eq-content display-default">
        <div class="text-wrapper">
          <div class="eq-text">
            隐患类型：<span>{{ data.troubleType }}</span>
          </div>
          <div class="eq-text">
            隐患等级：<span>{{ data.troubleLevel }}</span>
          </div>
          <div class="eq-text">
            处理状态：<span>{{
              data.dealStatus ? data.dealStatus : "暂未处理"
            }}</span>
          </div>
          <div class="eq-text">
            上报人员：<span>{{ data.reportManName }}</span>
          </div>
        </div>
        <div class="pic">
          <img v-bind:src="data.pictureUrl" alt="" />
        </div>
      </div>
      <!-- 维修人员 -->
      <div class="maintain-content">
        <el-col :span="11">
          <div>
            <span>上报日期：</span>
            <span>{{ moment(data.createTime).format("YYYY-MM-DD") }}</span>
          </div>
        </el-col>

        <el-col :span="13">
          <div>
            <span>最后巡检日期：</span>
            <span>{{
              data.updateTime
                ? moment(data.updateTime).format("YYYY-MM-DD")
                : "-"
            }}</span>
          </div>
        </el-col>

        <div>
          <span>隐患所在地址：</span>
          <span>{{ data.address }}</span>
        </div>
        <div>
          <span>备注信息：</span>
          <span>{{ data.remarks ? data.remarks : "-" }} </span>
        </div>
      </div>
    </div>

    <!-- 隐患关联设备状态 -->
    <div class="warn-wrapper" v-if="true">
      <div class="warn-content">
        <div>
          关联设备：<span>{{ data.deviceName ? data.deviceName : "-" }}</span>
        </div>
        <div>
          设备类型：<span>{{
            data.deviceType ? this.deviceType[data.deviceType] : "-"
          }}</span>
        </div>
        <div v-if="!orderId">
          工单编号：<span>{{ data.orderId }}</span>
        </div>
      </div>
      <div class="btn">
        <span @mousedown.stop="deviceMore">
          <el-button class="elbtn" type="primary">隐患详情</el-button>
        </span>
        <span v-if="orderId" @mousedown.stop="createWork">
          <el-button class="elbtn" type="primary">生成工单</el-button>
        </span>
        <span v-else @mousedown.stop="checkWork">
          <el-button class="elbtn" type="primary">查看工单</el-button>
        </span>
      </div>
    </div>
  </div>
</template>

<script>
import moment from "moment";
//line移入时的的infowindow
export default {
  props: {
    obj: { typs: Object },
    title: "",
    data: {},
    map: null,
  },
  data() {
    return {
      deviceType: {
        0: "管道",
        1: "调压箱",
        2: "阀门井",
        3: "流量计",
        4: "智能燃气表",
      },
    };
  },
  computed: {
    orderId() {
      // 如果已经生成过工单，就不能再次生成了
      console.log("orderId", this.data.orderId);
      // return this.data.orderId ? false : true;
      return this.data.orderId ? false : true;
    },
  },
  methods: {
    moment,
    createWork() {
      // 控制外层弹框
      // console.log(this.data.view.$refs.CreateWork);
      this.data.class.view.$refs.CreateWorkTrouble.form.troubleId =
        this.data.troubleId;
      this.data.class.view.$refs.CreateWorkTrouble.form.troubleName =
        this.data.troubleName;
      this.data.class.view.$refs.CreateWorkTrouble.form.troubleType =
        this.data.troubleType;
      this.data.class.view.$refs.CreateWorkTrouble.form.troubleLevel =
        this.data.troubleLevel;
      this.data.class.view.$refs.CreateWorkTrouble.open = true;
      this.data.class.view.$refs.CreateWorkTrouble.gaoMap =
        this.data.class.view.gaoMap;
      // 改变外层回调
      // this.data.view.CreateWorkCallBack = this.CreateWorkCallBack;
      this.data.class.view.troubleObjChange({ troubleId: this.data.troubleId });
    },
    // CreateWorkCallBack(e) {
    //   // console.log("生成工单后传过来的参数", e);
    //   // console.log("markerCallBack");
    //   const marker = this.data.view.gaoMap.markers.filter((item) => {
    //     return item.getExtData().alarmId == this.data.alarmId;
    //   })[0];
    //   console.log("marer.getExtData()", marker.getExtData());
    //   let options = marker.getExtData();
    //   // 暂时传值，到时候回重新刷新
    //   options.orderId = e;
    //   marker.setExtData(options);
    // },
    close() {
      this.map.clearInfoWindow();
      this.data.class.view.domAllShow();
    },
    deviceMore() {
      this.data.class.view.$router.push({
        path: "/riskManagement/hiddenTroubleDetail",
        query: {
          troubleId: this.data.troubleId,
          // dcviceType: this.deviceType[this.data.deviceType],
        },
      });
    },
    // 查看工单
    checkWork() {
      this.data.class.view.$router.push({
        path: "/workOrder/detail",
        query: {
          orderId: this.data.orderId,
        },
      });
    },
  },
  beforeDestroy() {
    // this.data.view.createWorkOpen = false;
  },
};
</script>

<style lang="scss" scoped>
.wrapper {
  width: 406px;
  max-height: 500px;
  // background: #fff;
  background: rgba(7, 29, 51, 0.9);

  border-radius: 4px;
  box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
  // overflow: hidden;
  .top {
    width: 100%;
    height: 51px;
    // background-color: #e6a23c;
    background-image: url(../../assets/images/yellowTopBg.png);
    background-size: 100% 100%;
    background-position: center;
    color: #fff;
    &:before {
      content: "";
      position: absolute;
      left: -20px;
      top: 5px;
      z-index: -1;
      width: 33px;
      height: 33px;
      background-image: url(../../assets/images/yellowLeftTriangle.png);
    }
    .text {
      font-weight: 600;
      font-size: 16px;
      color: #ffffff;
      line-height: 51px;
    }
    .left {
      padding-left: 22px;
    }
    .right {
      padding-right: 22px;
      img {
        cursor: pointer;
      }
    }
  }
  .content {
    position: relative;
    max-height: 300px;
    overflow: hidden;
    overflow-y: auto;
    padding-bottom: 2px;
    border-bottom: 1px solid #eeeeee;
    .eq-content {
      // min-height: 156px;
      box-sizing: border-box;
      padding: 13px 22px 0px 22px;
      // border-bottom: 1px solid #e2e2e2;
      .text-wrapper {
        padding-top: 1px;
        & > div {
          margin-bottom: 6px;
        }
        .eq-text {
          font-size: 14px;
          font-weight: 400;
          color: #fff;
          opacity: 1;
          & > span {
            vertical-align: top;
            display: inline-block;
            // white-space: nowrap;
            // text-overflow: ellipsis;
            // overflow: hidden;
            word-break: break-all;
            max-width: 100px;
          }
        }
      }
      .pic {
        width: 180px;
        height: 103px;
        // background-color: black;
        img {
          width: 100%;
          height: 100%;
          // cursor: pointer;
        }
      }
    }
  }

  .maintain-content {
    width: 100%;
    max-height: 119px;
    padding-left: 22px;
    color: #fff;
    // padding-right: 22px;
    // padding-bottom: 10px;
    // padding-top: 16px;
    box-sizing: border-box;
    // border-bottom: 1px solid #e2e2e2;
    & > div {
      margin-bottom: 8px;
      font-size: 14px;
      font-weight: 400;
      span {
        vertical-align: top;
        display: inline-block;
        word-break: break-all;
        max-width: 280px;
      }
    }
  }
  .warn-wrapper {
    .warn-content {
      box-sizing: border-box;
      padding: 10px 0 2px 22px;
      border-bottom: 1px solid #e2e2e2;
      color: #fe5966;
      & > div {
        font-size: 14px;
        font-weight: 400;
        margin-bottom: 8px;
      }
    }
    .btn {
      padding: 16px 0;
      text-align: center;
      span {
        display: inline-block;
        padding: 0 10px;
        .elbtn {
          background-color: #053b6a;
          box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
          width: 95px;
          height: 33px;
          // border: none;
        }
      }
    }
  }
}

.wrapperEditorPage {
}
.display-default {
  display: flex;
  justify-content: space-between;
}
</style>
