<template>
  <div class="waitConfirm">
    <div class="conentBox">
      <div class="conent">
        <div class="header">处理方案</div>
        <div class="navBar">
          <div class="fl">
            <a
              :class="{ active: actives == 'info' }"
              href="javascript:;"
              @click="toInfo('info')"
              >事件信息</a
            >
          </div>
          <div class="fl">
            <a
              :class="{ active: actives == 'handlerInfo' }"
              href="javascript:;"
              @click="toInfo('handlerInfo')"
              >处理信息</a
            >
          </div>
          <div class="fl">
            <a
              :class="{ active: actives == 'progress' }"
              href="javascript:;"
              @click="toInfo('progress')"
              >处理进度</a
            >
          </div>
        </div>

        <div class="info">
          <div class="label headtop" id="info">事件信息</div>
          <div class="head">
            <p>
              <i class="iconfont icon-zuixinbaoxiu newPapir"></i>
              事件编号：{{ model.incident.incidentsign }}
              <span
                :class="{
                  fr: true,
                  btn: true,
                  daipingjia: model.incident.state.name == '待评价',
                  daijiedan:
                    model.incident.state.name == '待接单' &&
                    model.incident.handlerUser &&
                    !model.incident.candidateGroups,
                  daiqiangdan:
                    model.incident.state.name == '待接单' &&
                    !model.incident.handlerUser &&
                    model.incident.candidateGroups,
                  chulizhong: model.incident.state.name == '处理中',
                  yijiejue: model.incident.state.name == '已解决',
                  yiguanbi: model.incident.state.name == '已关闭'
                }"
                >{{
                  model.incident.state.name == "待接单"
                    ? model.incident.handlerUser &&
                      !model.incident.candidateGroups
                      ? "待接单"
                      : "待接单"
                    : model.incident.state.name
                }}</span
              >
            </p>
          </div>
          <p>
            <span class="fl">故障现象</span>
            <span class="fr">{{ model.incident.category.category }}</span>
          </p>
          <!-- <p>
            <span class="fl">事件主题</span>
            <span class="fr">{{model.incident.title}}</span>
          </p> -->
          <p>
            <span class="fl">故障描述</span>
            <span class="fr showwrap">{{ model.incident.description }}</span>
          </p>
          <div class="shows" id="shows">
            <p v-if="valConfig == 2">
              <span class="fl">报修科室</span>
              <span class="fr">{{
                model.incident.department ? model.incident.department.dept : ""
              }}</span>
            </p>
            <p v-if="valConfig == 1">
              <span class="fl">报修人</span>
              <span class="fr">{{ model.incident.requester.name }}</span>
            </p>
            <p v-if="valConfig == 2">
              <span class="fl">联系人</span>
              <span class="fr">{{ model.incident.contacts }}</span>
            </p>
            <p>
              <span class="fl">联系电话</span>
              <span
                class="fr"
                v-if="!model.incident.contactsInformation"
              ></span>
              <span class="fr" v-if="model.incident.contactsInformation"
                ><a :href="'tel:' + model.incident.contactsInformation"
                  ><i class="iconfont icon-shouji"></i
                  >{{ model.incident.contactsInformation }}</a
                ></span
              >
            </p>
            <p>
              <span class="fl">联系地址</span>
              <span class="fr">{{ model.incident.houseNumber || "" }}</span>
            </p>
            <p class="boeder_B">
              <span class="fl">事件来源</span>
              <span class="fr">{{ model.incident.source.name }}</span>
            </p>
            <!-- <p>
              <span class="fl">影响度</span>
              <span class="fr">{{model.incident.influence?model.incident.influence.name:''}}</span>
            </p>
            <p>
              <span class="fl">紧急度</span>
              <span class="fr">{{model.incident.emergency?model.incident.emergency.name:''}}</span>
            </p> -->
            <p>
              <span class="fl">受理人</span>
              <span class="fr">{{
                model.incident.acceptUser ? model.incident.acceptUser.name : ""
              }}</span>
            </p>
            <p>
              <span class="fl">处理人</span>
              <span class="fr">{{
                model.incident.handlerUser
                  ? model.incident.handlerUser.name
                  : ""
              }}</span>
            </p>
            <p>
              <span class="fl">优先级</span>
              <span class="fr">{{
                model.incident.priority ? model.incident.priority.name : ""
              }}</span>
            </p>
            <p>
              <span class="fl">逾期响应时间</span>
              <span class="fr">{{ model.incident.overdueResponseDate }}</span>
            </p>
            <p>
              <span class="fl">逾期解决时间</span>
              <span class="fr">{{ model.incident.overdueTime }}</span>
            </p>
          </div>
          <p class="info_hide">
            <span class="fl hide" @click="hides()" v-if="!item_hides"
              >展开详情 >></span
            >
            <span class="fl hide" @click="hides()" v-if="item_hides"
              >隐藏详情<<</span
            >
          </p>
          <ShowPicture :processInstanceId="processInstanceId" :wxIncidentId="wxIncidentId"></ShowPicture>

          <div class="label" id="handlerInfo">处理信息</div>
          <p>
            <span class="fl">处理人</span>
            <span class="fr">{{
              model.incident.acceptUser ? model.incident.acceptUser.name : ""
            }}</span>
          </p>
          <p>
            <span class="fl">联系电话</span>
            <span class="fr" v-if="!model.incident.contactsInformation"></span>
            <span class="fr" v-if="model.incident.contactsInformation"
              ><a :href="'tel:' + model.incident.contactsInformation"
                ><i class="iconfont icon-shouji"></i
                >{{ model.incident.contactsInformation }}</a
              ></span
            >
          </p>
          <p>
            <span class="fl">处理方式</span>
            <span class="fr showwrap">{{ model.incident.handleCategory }}</span>
          </p>
          <p>
            <span class="fl">关闭代码</span>
            <span class="fr">{{
              model.incident.closecode ? model.incident.closecode.name : ""
            }}</span>
          </p>
          <p>
            <span class="fl">处理方案</span>
            <span class="fr">{{ model.incident.handleDescription || "" }}</span>
          </p>
          <p>
            <span class="fl">升级对象</span>
            <span class="fr">{{
              model.incident.handlerUser ? model.incident.handlerUser.name : ""
            }}</span>
          </p>
          <!-- <p>
            <span class="fl">升级原因</span>
            <span class="fr">升级原因</span>
          </p> -->

          <div class="label" id="progress">处理进度</div>
          <div class="progress">
            <div class="progress_info" v-for="(item,index) in progressInfo" :key="index">
              <div class="progress_info_L">{{ item.logType ? item.logType.name : '' }}</div>
              <div class="progress_info_R">
                <div class="time">
                  <i
                    :class="{
                      iconfont: true,
                      'icon-icon_weizuo': item.endTime != '',
                      'icon-icon_zhengzaijinx': item.endTime == ''
                    }"
                  ></i>
                  <span class="text1">
                    {{ item.startTime | timeFormat("MM-dd HH:mm:ss") }}
                    <template v-if="item.appointorName">
                      ，{{ item.appointorName }}
                    </template>
                  </span>
                </div>
                <div :class="{ cont: true, blue: item.endTime != '' }">
                  <p class="text2" v-if="item.logType && item.logType.desc" v-html="item.logType.desc"></p>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import ShowPicture from './../custom/ShowPicture.vue'
export default {
  data() {
    return {
      loginUser: JSON.parse(localStorage.getItem("loginUser")),
      valConfig: JSON.parse(localStorage.getItem("valConfig")) - 0, //报修主体
      selected: 1,
      id: "",
      options: [
        {
          label: "接单",
          value: 1
        },
        {
          label: "关单信息",
          value: 2
        }
      ],
      resignComment: "", //重新指派原因
      item_hides: false,
      item_hides1: false,
      actives: "info",
      processInstanceId: "",
      wxIncidentId: "",
      progressInfo: [], //处理进度
      model: {} //提交数据
    };
  },
  methods: {
    //   获取事件数据
    getParamsData() {
      var that = this;
      that.$http
        .get(
          "/service/form/renderForm/receiveform/" +
            that.processInstanceId +
            "/" +
            that.loginUser.id,
          {}
        )
        .then(function(res) {
          console.log(res.data);
          that.wxIncidentId = res.data.model.incident.wxIncidentId;
          that.model = res.data.model;
        });
    },
    // 获取处理进度
    getProgressInfo() {
      var that = this;
      that.$http
        .post(
          "/service/simple/data/fetchDataList/incidentLog",
          {
              "idx": 0,
              "sum": 9999,
              "incidentLog": {
                  "incidentId": this.id
              }
          }
        )
        .then(function(res) {
          console.log(res.data);
          that.progressInfo = res.data.list || [];
          //维修记录startcaca
          if (that.model.incident.handlerLogs) {
            //添加日志
            that.model.incident.handlerLogs.forEach(v => {
              that.progressInfo.push({
                startTime: v.opTime,
                endTime: 1,
                desc: (v.repairType && v.expectedDate) ? `${v.repairType.name} ${formatDate(new Date(v.expectedDate), "MM月dd日前完成")}<br>${v.opValue}` : v.opValue,
                appointorName: v.userName,
                logType: {name: "事件处理"}
              });
            });
          }
          //处理数据
          that.progressInfo.forEach(v => {
            if (!v.endTime) {
              v.endTime = 1;
            }
            v.startTime = new Date(v.startTime).getTime();
          });
          var kaishi = that.progressInfo.shift();
          var jiedan = that.progressInfo.shift();
          that.progressInfo.sort(function(o, c) {
            return c.startTime - o.startTime;
          });
          that.progressInfo.length && (that.progressInfo[0].endTime = "");
          that.progressInfo.push(jiedan);
          that.progressInfo.push(kaishi);
          console.log(that.progressInfo);
          //维修记录end
        });
    },
    //隐藏显示详情
    hides() {
      this.item_hides = !this.item_hides;
      $("#shows").slideToggle();
    },
    //隐藏显示详情
    hides1() {
      this.item_hides1 = !this.item_hides1;
      $("#shows1").slideToggle();
    },
    // 快速定位
    toInfo(id) {
      this.actives = id;
      $("body,html").animate(
        {
          scrollTop:
            $("#" + id).offset().top -
            $(".header")[0].offsetHeight -
            $(".navBar")[0].offsetHeight
        },
        260
      );
    }
  },
  created() {
    this.processInstanceId = this.$route.params.data
      ? this.$route.params.data.processInstanceId
      : JSON.parse(localStorage.getItem("modelData")).incident
          .processInstanceId;
    this.id = this.$route.params.data
      ? this.$route.params.data.id
      : JSON.parse(localStorage.getItem("modelData")).incident.id;
    this.getParamsData();
    this.getHandlerInfo();
  },
  components:{
    ShowPicture,
  }
};
</script>
<style lang="less" scoped>
i.iconfont {
  &.blue {
    color: #005395;
    // &::after {
    //   content: "";
    //   width: 0.01rem;
    //   height: 0.4rem;
    //   background: #005395;
    //   position: relative;
    //   display: block;
    //   left: 0.14rem;
    // }
  }
  &.blue1 {
    color: #005395;
  }
}
.waitConfirm {
  .header {
    width: 100%;
    height: 0.88rem;
    line-height: 0.88rem;
    text-align: center;
    color: #fff;
    font-size: 0.37rem;
    background: linear-gradient(#2e2f32, #414246);
    position: fixed;
    top: 0;
    z-index: 6;
  }
  .navBar {
    width: 100%;
    height: 0.96rem;
    line-height: 0.96rem;
    background-color: #fafafa;
    font-size: 0.28rem;
    position: fixed;
    top: 0.88rem;
    div {
      width: 33.33%;
      text-align: center;
      a {
        display: inline-block;
        height: 0.9rem;
        width: 1.7rem;
        padding: 0 0.1rem;
        &.active {
          color: #005395;
          border-bottom: 0.06rem solid #005395;
        }
      }
    }
  }

  .headtop {
    margin-top: 1.84rem;
  }
  .label {
    background-color: #eeeeee;
    height: 0.6rem;
    line-height: 0.58rem;
    padding-left: 0.2rem;
    font-size: 0.24rem;
    color: #666666;
    span {
      font-size: 0.2rem;
      display: inline-block;
      margin-left: 0.08rem;
      color: #999999;
    }
    &.formLabel {
      background-color: #fff;
    }
  }
  .conentBox {
    width: 100%;
    .conent {
      font-size: 0.32rem;
      font-weight: 400;
      line-height: 0.45rem;
      // border-bottom: 0.16rem solid #e5e5e5;

      .shows {
        display: none;
      }

      .shows1 {
        display: none;
      }
      .boeder_B {
        border-bottom: 0.01rem solid #ccc;
      }
      .center {
        color: #333333;
        border-bottom: 0.01rem solid #e6e6e6;
        padding: 0.24rem 0.48rem;
        p {
          .grayFont {
            color: #666;
          }
        }
      }
      .bottom {
        overflow: hidden;
        line-height: 0.86rem;
        border-bottom: 0.01rem solid #e6e6e6;
        font-size: 0.24rem;
        color: #999;
        padding: 0 0.24rem 0 0.48rem;
      }
      .info {
        color: #999;
        font-size: 0.28rem;
        overflow: hidden;
        .head {
          border-bottom: 0.01rem solid #e6e6e6;
          p {
            padding: 0.24rem 0.3rem;
            i {
              color: #00559d;
            }
          }
        }
        p {
          line-height: 0.4rem;
          padding: 0.1rem 0.24rem;
          overflow: hidden;
          .overflowEllipsis2 {
            margin-left: 1.96rem;
          }
        }
        .info_hide {
          padding: 0.2rem 0.24rem;
          border-bottom: 0.01rem solid #e6e6e6;
          .hide {
            color: #00559d;
          }
        }
        .progress {
          padding: 0.2rem 0.2rem;
          overflow: hidden;
          margin-bottom: 0.7rem;
          .progress_info {
            overflow: hidden;
            margin-bottom: 0.1rem;
            &:nth-last-child(1) {
              .cont {
                border: none !important;
              }
            }
            .progress_info_L {
              float: left;
              color: #333;
              max-width: 18%;
            }
            .progress_info_R {
              float: right;
              margin-left: 0.09rem;
              width: 80%;
              font-size: 0.25rem;
              .time {
                i {
                  margin-left: -0.15rem;
                  &.icon-icon_weizuo {
                    color: #005495;
                  }
                  &.icon-icon_zhengzaijinx {
                    color: #48a843;
                    font-size: 0.37rem;
                  }
                }
                span {
                  margin-left: 0.15rem;
                }
              }
              .cont {
                border-left: 1px solid #999;
                padding-left: 0.4rem;
                min-height: 0.4rem;
                &.blue {
                  border-left: 1px solid #005395;
                }
              }

              .text1 {
                font-size: 0.15rem;
              }
              .text2 {
                color: #666;
              }
              p {
                padding: 0;
              }
            }
          }
        }
      }
      .txtLabel {
        width: 100%;
        overflow: hidden;
        padding: 0.32rem 0.24rem 0.32rem 0.32rem;
        .txt {
          width: 30%;
          color: #666;
        }
        .cube-textarea-wrapper {
          width: 62%;
        }
      }
      .sub {
        background: #ececec;
        .cube-btn {
          background-color: #005395 !important;
          width: 90%;
          margin: 0.2rem auto;
          border-radius: 8px;
        }
      }
    }
  }
  .showwrap {
    width: 75%;
    text-align: right;
  }
}
</style>
