<template>
  <div class="ManagementHistory">
    <div class="title">最近处置历史</div>
    <div v-for="(item, index) in info.riskDisposalHistoryList" :key="index">
      <div class="info" v-if="item.handleType == 2">
        <div class="item-flex">
          <div class="label">处置意见</div>
          <div class="value">{{ $dict.getLabel('EP_handleType', item.handleType) }}</div>
        </div>
        <div class="item-flex">
          <div class="label">集中隔离地</div>
          <div class="value">{{ $dict.getLabel('EP_quarantineAddress', item.quarantineAddress) }}</div>
        </div>
        <div class="item-flex">
          <div class="label">隔离时间</div>
          <div class="value">{{item.quarantineBeginTime}}至{{item.quarantineEndTime}}</div>
        </div>
        <div class="item-flex">
          <div class="label">隔离策略</div>
          <div class="value">{{ $dict.getLabel('EP_quarantineStrategy', item.quarantineStrategy) }}</div>
        </div>
      </div>

      <div class="info" v-if="item.handleType == 3">
        <div class="item-flex">
          <div class="label">处置意见</div>
          <div class="value">{{ $dict.getLabel('EP_handleType', item.handleType) }}</div>
        </div>
        <div class="item-flex">
          <div class="label">居家状态</div>
          <div class="value">{{ $dict.getLabel('EP_homeStatus', item.homeStatus) }}</div>
        </div>
        <div class="item-flex">
          <div class="label">隔离时间</div>
          <div class="value">{{item.quarantineBeginTime}}至{{item.quarantineEndTime}}</div>
        </div>
        <div class="item-flex">
          <div class="label">隔离策略</div>
          <div class="value">{{ $dict.getLabel('EP_quarantineStrategy', item.quarantineStrategy) }}</div>
        </div>
        <div class="item-flex">
          <div class="label">管控方式</div>
          <div class="value">{{ $dict.getLabel('EP_controlMethod', item.controlMethod) }}</div>
        </div>
        <div class="item-flex">
          <div style="color:#999;">备注</div>
        </div>
        <p style="padding-bottom: 12px;">{{item.remarks}}</p>
        <div class="item-flex border-none" v-if="item.fileList && item.fileList.length" style="border-top:1px solid #ddd">
          <div style="color:#999;">图片</div>
        </div>
        <div class="img-list">
          <img :src="items.url" alt="" v-for="(items, indexs) in item.fileList" :key="indexs" @click="previewImage(item.fileList, items.url)">
        </div>
      </div>

      <div class="info" v-if="item.handleType == 6">
        <div class="item-flex">
          <div class="label">处置意见</div>
          <div class="value">{{ $dict.getLabel('EP_handleType', item.handleType) }}</div>
        </div>
        <div class="item-flex">
          <div class="label">移交对象</div>
          <div class="value">{{ $dict.getLabel('EP_handoverObject', item.handoverObject) }}</div>
        </div>
        <div class="item-flex">
          <div class="label">移交方式</div>
          <div class="value">{{ $dict.getLabel('EP_handoverMethod', item.handoverMethod) }}</div>
        </div>
        <div class="item-flex">
          <div class="label">交接人姓名</div>
          <div class="value">{{item.handoverPersonName}}</div>
        </div>
        <div class="item-flex">
          <div class="label">手机号</div>
          <div class="value" style="color:#4181FF;" @click="callPhone(item.handoverPersonPhone)">
            <img :src="$cdn + 'common/phone.png'" alt="" class="phone-icon" >
            {{item.handoverPersonPhone}}</div>
        </div>
        <div class="item-flex border-none" v-if="item.fileList && item.fileList.length">
          <div style="color:#999;">交接图片</div>
        </div>
        <div class="img-list">
          <img :src="items.url" alt="" v-for="(items, indexs) in item.fileList" :key="indexs" @click="previewImage(item.fileList, items.url)">
        </div>
      </div>
    </div>
    <AiEmpty v-if="!info.riskDisposalHistoryList.length"></AiEmpty>
    
    <div class="btn-height"></div>
    <div class="footer" v-if="form.handleType == 3">
      <div @click="submit('1')">放行居家隔离</div>
      <div @click="submit('0')">通知社区核实</div>
    </div>
    <div class="footer-btn" v-else @click="submit('')">提交</div>
  </div>
</template>

<script>
import { mapState } from 'vuex'

export default {
  data() {
    return {
      id: '',
      info: {},
      form: {},
    }
  },
  computed: { ...mapState(['user']) },
  onShow() {
    document.title = '居家隔离确认'
  },
  onLoad(option) {
    this.form = uni.getStorageSync('checkPointContent')
    this.$dict.load('EP_handleType', 'EP_quarantineAddress', 'EP_quarantineStrategy', 'EP_homeStatus', 'EP_controlMethod', 'EP_handoverObject', 'EP_handoverMethod').then(() => {
      this.id = option.id
      this.getDetail()
    })
  },
  methods: {
    submit(status) {
      if(this.form.handleType == 6) {
        this.form.quarantineBeginTime = null
        this.form.quarantineEndTime = null
      }
      this.form.homeQuarantineOperation = status
      this.$http.post(`/app/appepidemicpreventionregisterinfo/riskDisposal?homeQuarantineOperation=${this.form.homeQuarantineOperation}`, this.form).then((res) => {
        if (res.code == 0) {
          this.$u.toast('提交成功')
          uni.$emit('updateDetail')
          uni.$emit('updateList')
          uni.navigateBack({ delta: 2 })
        }
      })
    },
    getDetail() {
      this.$http.post(`/app/appepidemicpreventionregisterinfo/queryDetailById?id=${this.id}`).then((res) => {
        if (res.code == 0) {
          this.info = res.data
        }
      })
    },
    callPhone(phone) {
      uni.makePhoneCall({phoneNumber: phone})
    },
    previewImage(images, img) {
      uni.previewImage({
        urls: images.map(v => v.url),
        current: img
      })
    },
  },
}
</script>

<style lang="scss" scoped>
.ManagementHistory {
  .title{
    padding-left: 32px;
    line-height: 116px;
    background: #FFF;
    font-size: 38px;
    font-family: PingFangSC-Semibold, PingFang SC;
    font-weight: 600;
    color: #333;
  }
  .info{
    background-color: #fff;
    padding: 0 32px;
    margin-bottom: 24px;
    .item-flex{
      padding: 34px 0;
      border-bottom: 1px solid #ddd;
      display: flex;
      justify-content: space-between;
      line-height: 44px;
      font-size: 32px;
      font-family: PingFangSC-Regular, PingFang SC;
      .label{
        width: 206px;
        color: #999;
      }
      .value{
        width: calc(100% - 206px);
        word-break: break-all;
        color: #333;
        text-align: right;
        .phone-icon{
          width: 40px;
          height: 40px;
          vertical-align: middle;
          margin-right: 8px;
        }
      }
      .color-0{
        color: #42D784;
      }
      .color-1{
        color: #f46;
      }
      .color-2{
        color: #1365DD;
      }
    }
    .img-list{
      padding-bottom: 32px;
      img{
        width: 320px;
        height: 320px;
      }
    }
    .item-flex:nth-last-of-type(1){
      border-bottom: 0;
    }
    .error-list {
      .item {
        width: 100%;
        background: #f4f7fe;
        border-radius: 8px;
        padding: 24px 24px 18px 24px;
        box-sizing: border-box;
        margin-bottom: 16px;
        p {
          font-size: 28px;
          font-family: PingFangSC-Regular, PingFang SC;
          color: #343d65;
          line-height: 40px;
          word-break: break-all;
          margin-bottom: 12px;
        }
        div {
          font-size: 24px;
          font-family: PingFangSC-Regular, PingFang SC;
          color: #666;
          line-height: 34px;
          span {
            display: inline-block;
            margin-left: 32px;
          }
        }
      }
    }
    .text-p{
      line-height: 44px;
      color: #333;
      padding-bottom: 16px;
    }
  }
  .line-bg{
    width: 100%;
    height: 24px;
    background-color: #F3F6F9;
  }
  .btn-height{
    height: 160px;
    background-color: #F3F6F9;
  }
  .footer {
    width: 100%;
    height: 128px;
    background: #FFF;
    box-shadow: inset 0 0 0 0 #D4D4D4;
    padding: 24px 32px;
    box-sizing: border-box;
    display: flex;
    position: fixed;
    bottom: 0;
    div {
      flex: 1;
      height: 80px;
      line-height: 80px;
      background: #FFF;
      border-radius: 8px;
      font-family: PingFangSC-Regular;
      font-size: 32px;
      text-align: center;
      background-color: #1365DD;
      color: #fff;
    }
    div:nth-of-type(1) {
      margin-right: 32px;
    }
  }
  .border-none{
    border-bottom: 0!important;
  }
  .footer-btn{
    width: 100%;
    height: 112px;
    line-height: 112px;
    background: #1365DD;
    box-shadow: inset 0px 1px 0px 0px #EEEEEE;
    font-size: 32px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #FFF;
    text-align: center;
    position: fixed;
    bottom: 0;
    left: 0;
  }
}
</style>
