<template>
    <div class="app-container detail" style="background-color: rgb(238, 241, 245);">
      <!-- 巡检计划信息 -->
      <div style="padding-top: 10px;background: #fff;height: 100%;">
        <el-row>
          <el-col :span="24" style="padding-left: 15px;">
            <div style="height: 45px;" @click="$router.go(-1)">
              <el-button size="medium" type="text" style="font-size: 18px; color: rgb(7, 63, 112);float: left;">返回
              </el-button>
              <div style="float: left;margin-top: 8px;margin-left: 5px;"><img src="../../../assets/logo/fanhui.png" style="width: 25px;" alt=""></div>
            </div>
          </el-col>
        </el-row>
        <el-divider></el-divider>

        <el-row style="width: 100%;">
          <el-col :span="24">
            <div style="color: #31EAEA;height: 25px;">
              <ul><li>详细信息</li></ul>
            </div>
          </el-col>
        </el-row>

        <el-row style="width: 100%;padding: 10px;padding-left: 40px;">
          <el-col :span="12">
            <el-col :span="12">
              <el-form ref="form" v-model="form" :rules="rules" label-width="100px" style="width: 100%;margin-left: 25px;margin-bottom: 25px;">
                <el-form-item label="隐患名称:" prop="troubleName">
                  <font>{{form.troubleName}}</font>
                </el-form-item>
                <el-form-item label="隐患类型:" prop="troubleType">
                  <font v-if="form.troubleType == 1">设备老化</font>
                  <font v-if="form.troubleType == 2">质保过期</font>
                </el-form-item>
                <el-form-item label="隐患等级:" prop="troubleLevel">
                  <font v-if="form.troubleLevel == 1">Ⅰ级</font>
                  <font v-if="form.troubleLevel == 2">Ⅱ级</font>
                  <font v-if="form.troubleLevel == 3">Ⅲ级</font>
                </el-form-item>
                <el-form-item label="隐患描述:" prop="remarks">
                  <div style="height: 90px;width: 200%; border: 1px solid rgb(187, 183, 183);margin-top: 10px;overflow-y: auto;padding: 5px;border-radius: 5px;">
                    <font>{{form.remarks}}</font>
                  </div>
                </el-form-item>
              </el-form>
            </el-col>
            <el-col :span="12">
              <el-form ref="form" v-model="form" :rules="rules" label-width="100px" style="width: 100%;">
                <el-form-item label="上报人:" prop="reportManName">
                  <font>{{form.reportManName}}</font>
                </el-form-item>
                <el-form-item label="上报时间:" prop="createTime">
                  <font>{{form.createTime}}</font>
                </el-form-item>
                <el-form-item label="处理状态:" prop="dealStatus">
                  <font v-if="form.orderId == null || form.orderId == ''">未生成工单</font>
                  <font v-if="(form.dealStatus == null || form.dealStatus == '') &&
                              form.orderId != null && form.orderId != ''">暂未处理</font>
                  <font v-if="form.dealStatus == 1">不需处理</font>
                  <font v-if="form.dealStatus == 2">已处理完成</font>
                  <font v-if="form.dealStatus == 3">未处理完成</font>
                </el-form-item>
              </el-form>
            </el-col>
          </el-col>
          <el-col :span="12" >
            <el-form ref="form" v-model="form" :rules="rules" label-width="100px" >
              <el-form-item label="照片:" prop="pictureUrl">
                <el-image :src="form.pictureUrl" :preview-src-list="[form.pictureUrl]" style="width: 300px;height: 300px;"></el-image>
              </el-form-item>
            </el-form>
          </el-col>
        </el-row>

        <!-- 接单信息 -->
        <el-row v-if="form.orderId != null && form.orderId != ''">
          <el-divider></el-divider>
          <el-col :span="24">
            <div style="color: #31EAEA;width: 100%;height: 40px;">
              <ul><li>接单信息</li></ul>
            </div>
          </el-col>
          <el-col :span="5" style="margin-left: 50px;">
            <el-form ref="form" v-model="form" :rules="rules" label-width="100px" style="height: 30px;width: 100%;">
              <el-form-item label="下发人员:" prop="appointInspectorName">
                <font>{{form.appointInspectorName}}</font>
              </el-form-item>
            </el-form>
          </el-col>
          <el-col :span="6">
            <el-form ref="form" v-model="form" :rules="rules" label-width="100px" style="height: 30px;width: 100%;">
              <el-form-item label="下发时间:" prop="allotTime">
                <font>{{form.allotTime}}</font>
              </el-form-item>
            </el-form>
          </el-col>
          <el-col :span="6">
            <el-form ref="form" v-model="form" :rules="rules" label-width="100px" style="height: 30px;width: 100%;">
              <el-form-item label="工单编号:" prop="orderId">
                <template slot-scope="scope">
                  <el-button type="text" @click="showDetail(form.orderId)">{{form.orderId}}</el-button>
                </template>
              </el-form-item>
            </el-form>
          </el-col>
        </el-row>
        <el-divider></el-divider>
        <!-- 处置信息 -->
        <div style="width: 100%;font-weight: 600;" v-if="form.feedbackList != null">
          <div style="color: #31EAEA;width: 100%;height: 40px;">
            <ul><li>处置信息</li></ul>
          </div>
          <div class="block" style="width: 95%;margin-left: 2%;">
            <el-timeline ref="timeline">
              <el-timeline-item v-for="(activity, index) in form.feedbackList"  v-show='index>1?false:true' :key="index" :timestamp="activity.feedbackTime">
                <el-card>

                  <el-row>
                    <el-col :span="6">
                      <p>处置人：
                        <span>{{form.appointInspectorName}}</span>
                      </p>

                      <p>处置时间：
                        <span>{{activity.feedbackTime}}</span>
                      </p>


                      <div style="width: 600px;">
                        <p>处置内容：
                          <span>{{activity.contents}}</span>
                        </p>
                      </div>
                    </el-col>
                    <el-col :span="6">
                      <p>是否有隐患：
                        <span v-if="activity.isHiddenDanger == 1">是</span>
                        <span v-if="activity.isHiddenDanger == 2">否</span>
                      </p>

                      <p v-if="activity.isHiddenDanger == 1">处理状态：
                        <span v-if="activity.dealStatus == 1">不需要处理</span>
                        <span v-if="activity.dealStatus == 2">已处理完成</span>
                        <span v-if="activity.dealStatus == 3">未处理完成</span>
                      </p>
                    </el-col>
                    <el-col :span="12">
                      <div class="feedbackTime-div">
                        <div class="feedbackTime">
                          <el-image :src="activity.pictureUrl1" :preview-src-list="[activity.pictureUrl1]" v-if="activity.pictureUrl1 != null && activity.pictureUrl1 != ''" style="width: 90px;"></el-image>
                        </div>
                        <div class="feedbackTime">
                          <el-image :src="activity.pictureUrl2" :preview-src-list="[activity.pictureUrl2]"  v-if="activity.pictureUrl2 != null && activity.pictureUrl2 != ''" style="width: 90px;"></el-image>
                        </div>
                        <div class="feedbackTime">
                          <el-image :src="activity.pictureUrl3" :preview-src-list="[activity.pictureUrl3]"  v-if="activity.pictureUrl3 != null && activity.pictureUrl3 != ''" style="width: 90px;"></el-image>
                        </div>
                      </div>
                    </el-col>
                  </el-row>

                </el-card>
              </el-timeline-item>
            </el-timeline>
          </div>
          <div style="width: 95%;position: relative;" @click="changeDisplay(scope)">
            <i class="el-icon-arrow-down" v-if="isDisplay==false" style="margin-left: 100px;color: #909399;font-size: 14px;">
              <span style="text-decoration:underline">显示全部</span>
            </i>
            <i class="el-icon-arrow-up" v-else style="color: #909399;font-size: 14px;margin-left: 100px;">
              <span style="text-decoration:underline">收起</span>
            </i>
          </div>
        </div>
      </div>
    </div>
  </template>

  <script>

  import { getHiddenTrouble } from "@/api/riskManagement/hiddenTrouble";

export default {
    name: "HiddenTroubleDetail",
    components: {
    },
    data() {
      return {
        troubleId: '',
        isDisplay:false,
        showAndHide : false,
        form: {  },
        rules: {  },
      };
    },
    created() {
      // 如果是跳转来的，则接受初始化参数
      this.troubleId = this.$route.query.troubleId;
      this.getDetail();
    },
    methods: {
      /** 获取隐患信息详情 */
      getDetail (){
        getHiddenTrouble(this.troubleId).then(response =>{
          this.form = response.data;
          console.log("this.form",this.form)
        });
      },
      /** 详细信息跳转 */
      showDetail(orderId) {
        this.$router.push({
           path: '/workOrder/detail',
           query:{
             orderId : orderId
           }
        })
      },
      // 点击按钮显示隐藏
      changeDisplay(e) {
        this.isDisplay = !this.isDisplay
        let $timeline = this.$refs.timeline;
        if (!this.showAndHide) {
          for (let i = 0; i < $timeline.$children.length; i++) {
            if (i > 1) {
              $timeline.$children[i].$el.style.display = "block";
            }
          }
          this.showAndHide = true;
        } else {
          for (let i = 0; i < $timeline.$children.length; i++) {
            if (i > 1) {
              $timeline.$children[i].$el.style.display = "none";
            }
          }
          this.showAndHide = false;
        }
      },
    }
  }
  </script>
  <style>
    .el-tree-node__content{
      width: 150px;
    }
    .el-divider--horizontal {
      display: block;
      height: 1px;
      width: 100%;
      margin: 20px 0;
    }
    .feedbackTime-div{
      float: left;margin-left: 150px;margin-top: 10px;
    }
    .feedbackTime{
      height: 120px;
      width: 120px;
      float: left;
      margin-left: 15px;
      margin-top: 5px;
      margin-bottom: 15px;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .el-card__body {
      padding: 5px 20px 20px 20px;
    }
    .detail .el-form{
        width: 20%;
    }
    .detail .el-form-item{
        margin-bottom: 0px;
    }
    .el-tree{
      margin-top: 5px;
    }
    .avatar-uploader{
        width: 25%;
        float: left;
    }
    .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
  li{
    font-size: 15px;
    font-weight: 900;
  }
  </style>
