<template>
  <div class="Detail">
    <AiTopFixed>
      <u-tabs :list="tabList" :is-scroll="false" :current="currentTabs" height="96" bg-color="#3975C6" inactive-color="#A1C1E8" :bar-style="barStyle"
        :active-item-style="activeStyle" active-color="#ffffff "  @change="change">
      </u-tabs>
    </AiTopFixed>
    <div class="user-info" v-if="currentTabs == 1">
      <div class="user-list">
        <div class="item">
          <h2 class="name">{{info.name}}的返乡登记信息</h2>
          <p><img src="./components/img/org-icon.png" alt=""><span class="start-name">{{info.startAreaName}}</span></p>
          <p><img src="./components/img/blue-icon.png" alt=""><span class="start-name">{{info.arriveAreaName}}</span></p>
          <p><img src="./components/img/time-icon.png" alt="">{{info.arriveTime}}</p>
          <p><img src="./components/img/point-icon.png" alt="">{{info.gatewayName}}</p>
        </div>
      </div>
      <div class="info">
        <div class="title">基本信息</div>
        <div class="item-flex">
          <div class="label">姓名</div>
          <div class="value">{{info.name}}</div>
        </div>
        <div class="item-flex">
          <div class="label">身份证号</div>
          <div class="value">
            <span>{{info.idNumberText}}</span>
          </div>
        </div>
        <div class="item-flex">
          <div class="label">联系方式</div>
          <div class="value" style="color:#4181FF;" @click="callPhone(info.phone)">
            <img :src="$cdn + 'common/phone.png'" alt="" class="phone-icon">
            {{info.phone}}
          </div>
        </div>
        <!-- <div class="item-flex">
          <div class="label">人员类别</div>
          <div class="value">{{$dict.getLabel('EP_registerPersonType', info.type)}}</div>
        </div>
        <div class="item-flex">
          <div class="label">高危行业</div>
          <div class="value">{{$dict.getLabel('EP_highRiskIndustries', info.highRiskIndustries)}}</div>
        </div> -->
      </div>
      <div class="line-bg"></div>
      <div class="info">
        <div class="title">行程信息</div>
        <div class="item-flex">
          <div class="label">出行方式</div>
          <div class="value">
            <span v-for="(item, index) in info.travelTypeList" :key="index"><span v-if="index>0">;</span>{{$dict.getLabel('EP_travelType',item)}}</span>
          </div>
        </div>
        <div class="item-flex border-none" v-if="info.trainNo">
          <div style="color:#999;">车次/车牌/航班</div>
        </div>
        <p class="line-text" v-if="info.trainNo">{{info.trainNo}}</p>
        <div class="item-flex">
          <div class="label">出发时间</div>
          <div class="value" v-if="info.startTime">{{info.startTime.substring(0, 16)}}</div>
        </div>
        <div class="item-flex">
          <div class="label">出发地</div>
          <div class="value" :class="`address-color`+info.riskLevel">{{info.startAreaName}}</div>
        </div>
        <div class="item-flex">
          <div class="label">出发地详址</div>
          <div class="value">{{info.startAddress}}</div>
        </div>
        <div class="item-flex">
          <div class="label">行程描述</div>
          <div class="value">{{info.description}}</div>
        </div>
        <div class="item-flex">
          <div class="label">抵平时间</div>
          <div class="value" v-if="info.arriveTime">{{info.arriveTime.substring(0, 16)}}</div>
        </div>
        <div class="item-flex">
          <div class="label">目的地</div>
          <div class="value">{{info.arriveAreaName}}</div>
        </div>
        <div class="item-flex">
          <div class="label">目的地详址</div>
          <div class="value">{{info.arriveAddress}}</div>
        </div>
      </div>
      <div class="line-bg"></div>
      <div class="info">
        <div class="title">健康状况</div>
        <div class="item-flex">
          <div class="label">是否有风险旅居史</div>
          <div class="value" v-if="info.fromHighRiskArea != 1">否</div>
          <div class="value" style="color:#f46;" v-else>{{info.highRiskAreaName}}</div>
        </div>
        <div class="item-flex">
          <div class="label" style="width:360px;">7天内是否接触新冠确诊或疑似患者</div>
          <div class="value" :style="info.contactPatients == 1 ? 'color:#f46;' : ''">{{$dict.getLabel('epidemicTouchInFourteen', info.contactPatients)}}</div>
        </div>
        <div class="item-flex">
          <div class="label">当前健康状况</div>
          <div class="value">
            <span v-if="info.abnormalHealth != 1">没有异常</span>
            <span v-else style="color:#FF4466;">{{$dict.getLabel('EP_abnormalType', info.abnormalType)}}</span>
          </div>
        </div>
      </div>
      <div class="line-bg" v-if="info.companionList && info.companionList.length"></div>
      <div class="info" v-if="info.companionList && info.companionList.length">
        <div class="title">同行情况<span>共{{info.companionCount}}人同行</span></div>
        <div class="table-content">
          <div class="item table-header">
            <div>姓名</div>
            <div>手机号码</div>
          </div>
          <div class="item" v-for="(item, index) in info.companionList" :key="index">
            <div>{{item.name}}</div>
            <div>{{item.phone}}</div>
          </div>
        </div>
      </div>
    </div>
    <div class="controll-info" v-else>
      <div class="info">
        <div class="title">基本信息<span class="title-right-text" @click="toNucleAcidDetail">点击查看核酸采样记录</span></div>
        <div class="item-flex">
          <div class="label">管理区域</div>
          <div class="value">{{controllInfo.areaName}}</div>
        </div>
        <div class="item-flex">
          <div class="label">管理对象</div>
          <div class="value">{{controllInfo.name}}</div>
        </div>
        <div class="item-flex">
          <div class="label">身份证号</div>
          <div class="value">{{controllInfo.idNumberText}}</div>
        </div>
        <div class="item-flex">
          <div class="label">手机号码</div>
          <div class="value" style="color:#4181FF;" @click="callPhone(controllInfo.phone)">
            <img :src="$cdn + 'common/phone.png'" alt="" class="phone-icon" >
            {{controllInfo.phone}}</div>
        </div>
        <div class="item-flex">
          <div class="label">处置意见</div>
          <div class="value" :class="'type-'+controllInfo.lastRiskDisposal.handleType">{{$dict.getLabel('EP_handleType', controllInfo.lastRiskDisposal.handleType)}}</div>
        </div>
        <div class="item-flex">
          <div class="label">居家状态</div>
          <div class="value">{{$dict.getLabel('EP_homeStatus2', controllInfo.homeStatus)}}</div>
        </div>
        <div class="item-flex">
          <div class="label">隔离时间</div>
          <div class="value" v-if="info.quarantineBeginTime">{{controllInfo.quarantineBeginTime.substring(0, 10)}} 至 {{controllInfo.quarantineEndTime.substring(0, 10)}}</div>
        </div>
        <div class="item-flex">
          <div class="label">隔离策略</div>
          <div class="value">{{$dict.getLabel('EP_quarantineStrategy', controllInfo.quarantineStrategy)}}</div>
        </div>
        <div class="item-flex" v-if="info.status != 0">
          <div class="label">管控人</div>
          <div class="value">{{controllInfo.controllerUserName}}</div>
        </div>
        <div class="item-flex" v-if="controllInfo.status != 0">
          <div class="label">联系方式</div>
          <div class="value" @click="callPhone(controllInfo.controllerUserPhone)">{{controllInfo.controllerUserPhone}}</div>
        </div>
      </div>
      <div class="line-bg"></div>
      <div class="info" v-if="controllInfo.status != 0">
        <div  v-if="controllInfo.controllerContent">
          <div class="item-flex border-none">
            <div class="label">管控内容</div>
          </div>
          <p style="padding-bottom: 24px;">{{controllInfo.controllerContent}}</p>
        </div>
        <div v-if="controllInfo.fileList && controllInfo.fileList.length">
          <div class="item-flex border-none" >
            <div class="label">图片</div>
          </div>
          <div class="img-list" v-for="(item, index) in controllInfo.fileList" :key="index">
            <img :src="item.accessUrl" alt="" @click="previewImage(controllInfo.fileList, item.accessUrl)">
          </div>
        </div>
      </div>

      <div class="info" v-if="controllInfo.status == 2 && controllInfo.proveFileList.length">
        <div class="item-flex border-none" >
          <div class="label">核酸证明</div>
        </div>
        <div class="img-list" v-for="(item, index) in controllInfo.proveFileList" :key="index">
          <img :src="item.accessUrl" alt="" @click="previewImage(controllInfo.proveFileList, item.accessUrl)">
        </div>
      </div>

      <div class="info" v-if="controllInfo.lastRiskDisposal && controllInfo.lastRiskDisposal.remarks">
        <div class="item-flex border-none">
          <div style="color:#999;">备注</div>
        </div>
        <p style="padding-bottom: 12px;">{{controllInfo.lastRiskDisposal.remarks}}</p>
      </div>

      <div class="line-bg" style="padding-bottom: 56px;"></div>
      <div class="footer">
        <div class="confirm" @click="cancelRelieve">撤销解除</div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex'

export default {
  data() {
    return {
      id: '',
      controllInfo: {},
      tabList: [
        {
          name: '排查管理',
        },
        {
          name: '人员详情',
        },
      ],
      barStyle: {
        'width': '24px',
        'height': '2px',
        'border-radius': '0',
        'bottom': '5px'
      },
      activeStyle: {
        'font-weight' : '400',
      },
      currentTabs: 0,
      info: {}
    }
  },
  computed: { ...mapState(['user']) },
  onShow() {
    document.title = '管理信息'
  },
  onLoad(option) {
    this.$dict.load('EP_homeStatus2', 'EP_quarantineStrategy', 'EP_handleType').then(() => {
      this.id = option.id
      this.getDetail()
    })
    uni.$on('updateDetail', () => {
      this.getDetail()
    })
  },
  methods: {
    change(index) {
      this.currentTabs = index
    },
    getDetail() {
      this.$http.post(`/app/appepidemicpreventioncommunitymanagement/queryDetailById?id=${this.id}`).then((res) => {
        if (res.code == 0) {
          this.controllInfo = res.data
          this.controllInfo.idNumberText = res.data.idNumber.replace(/(.{6}).*(.{4})/,"$1********$2")
          this.info = res.data.registerInfo
          this.info.travelTypeList = this.info.travelType.split(',')
          this.info.idNumberText = res.data.idNumber.replace(/(.{6}).*(.{4})/,"$1********$2")
        }
      })
    },
    changeStatus() {
      this.controllInfo.status = 2
      this.$http.post(`/app/appepidemicpreventioncommunitymanagement/troubleshooting`, this.controllInfo).then((res) => {
        if (res.code == 0) {
          this.$u.toast('提交成功')
          uni.$emit('updateList')
          this.getDetail()
        }
      })
    },
    callPhone(phone) {
      uni.makePhoneCall({phoneNumber: phone})
    },
    previewImage(images, img) {
      uni.previewImage({
        urls: images.map(v => v.url),
        current: img
      })
    },
    toEdit() {
      uni.navigateTo({url: `./Add?id=${this.id}`})
    },
    toNucleAcidDetail() {
      uni.navigateTo({url: `../AppNucleicAcidSampling/Detail?id=${this.id}&isHideBtn=1`})
    },
    cancelRelieve() {
      this.$confirm(`是否撤销对${this.info.name}的风险解除`).then(() => {
        this.$http.post(`/app/appepidemicpreventioncommunitymanagement/cancel?id=${this.id}`, ).then((res) => {
          if (res.code == 0) {
            this.$u.toast('撤销成功')
            uni.$emit('updateList')
            setTimeout(() => {
              uni.navigateBack()
            }, 600)
          }
        })
      })
    }
  },
}
</script>

<style lang="scss" scoped>
.Detail {
  ::v-deep .AiTopFixed {
    .placeholder {
      .content {
        padding: 0 !important;
      }
    }
    .fixed {
      margin: 0 !important;
      .content {
        padding: 0 !important;
      }
    }
  }
  .user-info {
    .user-list{
    margin-bottom: 24px;
    .item{
      padding: 32px 32px 24px;
      background-color: #fff;
      .name{
        font-size: 36px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #333;
        line-height: 50px;
        margin-bottom: 8px;
        .status{
          float: right;
          font-size: 28px;
          font-family: PingFangSC-Regular, PingFang SC;
          color: #FF4466;
          line-height: 40px;
        }
      }
      p{
        font-size: 28px;
        font-family: PingFangSC-Regular, PingFang SC;
        color: #333;
        line-height: 40px;
        margin-bottom: 8px;
        img{
          width: 32px;
          height: 32px;
          margin-right: 18px;
          vertical-align: top;
        }
      }
      .color-999{
        margin-bottom: 24px;
        color: #999;
      }
      .start-name{
        display: inline-block;
        width: calc(100% - 50px);
      }
    }
    }
    .info{
      background-color: #fff;
      padding: 0 32px;
      .title{
        line-height: 116px;
        background: #FFF;
        font-size: 38px;
        font-family: PingFangSC-Semibold, PingFang SC;
        font-weight: 600;
        color: #333;
        overflow: hidden;
        span {
          float: right;
          font-family: PingFangSC-Regular;
          font-size: 32px;
          color: #999;
          font-weight: 400;
        }
      }
      .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;
        }

        .address-color2 {
          color: #f46;
        }
        .address-color1 {
          color: #ff6200;
        }
      }
      .img-list{
        padding-bottom: 32px;
        img{
          width: 320px;
          height: 320px;
          margin-right: 8px;
        }
      }
      .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;
      }
    }
    .table-content {
      padding: 32px 0 48px 0;
      .item {
        width: 100%;
        display: flex;
        border-bottom: 1px solid #ccc;
        border-right: 1px solid #ccc;
        box-sizing: border-box;
        div {
          flex: 1;
          padding: 16px 48px;
          line-height: 40px;
          font-family: PingFangSC-Regular;
          font-size: 28px;
          color: #333;
          border-left: 1px solid #ccc;
          box-sizing: border-box;
        }
      }
      .table-header {
        background: #F7F7F7;
        border: 1px solid #ccc;
        border-left: none;
      }
    }
    .line-bg{
      width: 100%;
      height: 24px;
      background-color: #F3F6F9;
    }
    .line-text {
      line-height: 80px;
      border-bottom: 1px solid #ddd;
      font-family: PingFangSC-Regular;
      font-size: 32px;
      color: #333;
    }
  }
  .controll-info {
    .info{
      background-color: #fff;
      padding: 0 32px;
      .title{
        line-height: 116px;
        background: #FFF;
        font-size: 38px;
        font-family: PingFangSC-Semibold, PingFang SC;
        font-weight: 600;
        color: #333;
        overflow: hidden;
        .title-right-text {
          color: #1365DD;
          font-size: 28px;
          float: right;
          font-weight: 400;
        }
      }
      .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,
        .type-1,
        .type-5{
          color: #42D784;
        }
        .color-1,
        .type-2,
        .type-3{
          color: #f46;
        }
        .color-2{
          color: #1365DD;
        }
        .type-4{
          color: #FFA938;
        }
      }
      .img-list{
        padding-bottom: 32px;
        img{
          width: 320px;
          height: 320px;
        }
      }
      .item-flex:nth-last-of-type(1){
        border-bottom: 0;
      }
      .error-list {
        padding-bottom: 48px;
        .item {
          width: 100%;
          background: #f4f7fe;
          border-radius: 8px;
          padding: 24px 24px 18px 24px;
          box-sizing: border-box;
          margin-bottom: 16px;
          color: #343d65;
          font-size: 28px;
          font-family: PingFangSC-Regular, PingFang SC;
          line-height: 40px;
          div {
            display: flex;
            justify-content: space-between;
            margin-bottom: 16px;
          }
        }
      }
      .text-p{
        line-height: 44px;
        color: #333;
        padding-bottom: 16px;
      }
    }
    .line-bg{
      width: 100%;
      height: 24px;
      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;
    }
    .cancel {
      color: #333;
      line-height: 76px;
      border: 1px solid #CCCCCC;
      box-sizing: border-box;
      margin-right: 32px;
    }
    .confirm {
      background-color: #1365DD;
      color: #fff;
    }
  }
  .border-none{
    border-bottom: 0!important;
  }
}
</style>
