<template>
  <div class="Detail" v-if="showPage">
    <div class="header-top">
      <div class="avatars" v-if="data.openId">
        <!-- {{ data.name.substring(data.name.length, data.name.length - 2) }} -->
        <AiOpenData v-if="data.openId" type="userName" :openid="data.openId" style="display: inline-block; font-size:12px;"/>
      </div>

      <div class="right">
        <div class="names"><AiOpenData v-if="data.openId" type="userName" :openid="data.openId" style="display: inline-block;" />的上报</div>

        <div class="times">{{ data.createTime }}</div>
      </div>
    </div>

    <div class="header-middle">
      <div class="titles">{{ data.content }}</div>

      <span class="status status1" :class="data.eventStatus == 0 ? 'status1' : 'status2'" v-if="data.eventStatus"> {{ $dict.getLabel('clapEventStatus', data.eventStatus) }}</span>

      <div class="card">
        <span class="card-left">事件类型</span>
        <span class="card-right">{{ data.groupName }}</span>
      </div>

      <div class="card">
        <span class="card-left">所属网格</span>
        <span class="card-right">{{ data.girdName }}</span>
      </div>

      <div class="card">
        <span class="card-left">上报地址</span>
        <span class="card-right">
          <span>{{ data.address }}</span>
        </span>
      </div>

      <div class="cards">
        <span class="card-left" style="color: #999">照片</span>
      </div>

      <img :src="item.url" alt="" v-for="(item, i) in data.files" :key="i" @click="previewImage(data.files, item.url)" />
    </div>

    <div class="header-bottom">
      <div class="line"></div>

      <div class="plan">
        <div class="nav">
          <span>办理进度</span>
          <span> ({{ $dict.getLabel('clapEventStatus', data.eventStatus) }})</span>
        </div>

        <div class="cards" v-for="(item, index) in data.processList" :key="index">
          <div class="cardss">
            <div class="cardss-left">
              <span>
                <AiOpenData v-if="item.openId" type="userName" :openid="item.openId" style="display: inline-block; font-size:12px;"/>
              </span>

              <img src="./components/1.png" class="avatarIcon" alt="" />
            </div>

            <div class="cardss-right">
              <div class="cardsss-right-left">
                <div class="cardssss-right-left-top">
                  <!-- <span>{{ item.systemExplain }}</span> -->
                  <div v-html="transTxt(item.systemExplain)"/>
                  <div style="color: #2ea222; font-size: 16px; margin-top: 5px">
                    {{ $dict.getLabel('clapDoStatus', item.doStatus) }}
                  </div>
                </div>
              </div>

              <div class="cardees-right-right">{{ item.doTime }}</div>
            </div>

            <div class="lines"></div>
          </div>

          <div class="cardes-msg-top" v-if="item.doExplain">{{ item.doExplain }}</div>

          <div class="imgs">
            <img :src="e.url" alt="" v-for="(e, index) in item.files" :key="index" @click="previewImage(item.files, e.url)" />
          </div>
        </div>
      </div>
    </div>

    <div class="fixedBtn">
      <div class="status00" v-if="data.eventStatus == 0">
        <div class="columns border-r" @click="toContent(4)">
          <span class="hint">转交事件</span>
        </div>

        <div class="doIt" @click="doItShow = true">事件处理</div>
      </div>
    </div>

    <u-modal v-model="doItShow" :mask-close-able="true" z-index="99" content="确定受理该事件?" :show-cancel-button="true" @confirm="toContent(2)"></u-modal>
  </div>
</template>

<script>
import { mapState } from 'vuex'

export default {
  name: 'Detail',
  components: {},
  props: {},
  data() {
    return {
      data: {},
      id: '',
      doItShow: false,
      showPage: false,
    }
  },
  computed: {
    ...mapState(['user']),
  },
  watch: {},
  onLoad(o) {
    this.$dict.load('realityStatus', 'clapDoStatus').then(() => {
      this.id = o.id
      this.getDetail()
    })

    uni.$on('updateDeatil', () => {
      this.getDetail()
    })
  },
  onShow() {
    document.title = '矛盾调解'
  },
  methods: {
    transTxt(str){
      return str.replace(/\$(.+)\$/g,'<AiOpenData type="userName" openid="$1"/>')
    },
    getDetail() {
      this.$http.post(`/app/appclapeventinfo/queryDetailById?id=${this.id}`).then((res) => {
        if (res?.data) {
          this.data = res.data
          console.log(this.data);
          this.showPage = true
        }
      })
    },

    callPhone(phone) {
      uni.makePhoneCall({ phoneNumber: phone })
    },

    toContent(status) {
      uni.navigateTo({ url: `./Content?status=${status}&groupId=${this.data.groupId}&groupName=${this.data.groupName}&id=${this.id}` })
    },
    previewImage(images, img) {
      uni.previewImage({
        urls: images.map((v) => v.url),
        current: img,
      })
    },
  },
}
</script>

<style scoped lang="scss">
uni-page-body {
  height: 100%;
}
.Detail {
  height: 100%;
  background: #fff;

  .header-top {
    display: flex;
    margin: 26px 0 14px 0;
    padding: 0 32px;
    .avatars {
      width: 80px;
      height: 80px;
      line-height: 80px;
      background: #4e8eee;
      border-radius: 50%;
      color: #fff;
      text-align: center;
      font-size: 28px;
      font-weight: 500;
      margin-right: 16px;
    }
    .right {
      .names {
        font-size: 32px;
        font-weight: 500;
      }
      .times {
        margin-top: 10px;
        font-size: 28px;
        color: #999999;
      }
    }
  }

  .header-middle {
    padding: 0 32px 10px 32px;
    .titles {
      margin: 32px 0;
      line-height: 1.4;
      word-break: break-all;
      font-size: 40px;
      font-weight: 600;
    }
    .status {
      display: inline-block;
      margin-bottom: 14px;
      padding: 4px 8px;
      font-size: 26px;
      color: #ffffff;
      border-radius: 8px;
    }

    .status1 {
      background: #1aaaff;
    }

    .status2 {
      background: #42d784;
    }

    .card {
      display: flex;
      justify-content: space-between;
      padding: 34px 0;
      border-bottom: 1px solid #ddd;
      .card-left {
        width: 46%;
        font-size: 32px;
        color: #999999;
      }
      .card-right {
        font-size: 32px;
        .u-icon {
          margin-left: 8px;
        }
      }
    }

    .cards {
      padding: 34px 0;
    }

    img {
      width: 220px;
      height: 220px;
      margin-right: 8px;
    }
    img:nth-child(3n) {
      margin-right: 0;
    }
  }

  .header-bottom {
    padding-bottom: 80px;
    .line {
      height: 16px;
      background: #f3f6f9;
    }

    .plan {
      padding: 0 32px;
      .nav {
        padding: 26px 0;
      }

      .cards {
        position: relative;
        padding-bottom: 80px;
        .cardss {
          display: flex;
          justify-content: space-between;

          .cardss-left {
            position: relative;
            width: 80px;
            height: 80px;
            text-align: center;
            line-height: 80px;
            color: #fff;
            background: #197df0;
            border: 1px solid #dddddd;
            border-radius: 50%;
            font-size: 28px;
            z-index: 9;

            .avatarIcon {
              position: absolute;
              bottom: 0;
              right: 0;
              width: 38px;
              height: 38px;
            }
          }
          .cardss-right {
            width: calc(100% - 184px);
            display: flex;
            justify-content: space-between;
            .cardsss-right-left {
              .cardssss-right-left-top {
                width: 300px;
                overflow: hidden;
                text-overflow: ellipsis;
                font-size: 32px;
              }
              .cardssss-right-left-bottom {
                margin-top: 10px;
                font-size: 28px;
                color: #666666;
              }
            }
            .cardees-right-right {
              font-size: 28px;
              color: #999999;
            }
          }
          .lines {
            position: absolute;
            top: 0;
            left: 40px;
            width: 4px;
            height: 100%;
            background: #eeeeee;
          }
        }
        .cardes-msg-top {
          font-size: 28px;
          color: #343d65;
          margin-top: 10px;
          margin-left: 110px;
        }

        .imgs {
          margin-top: 10px;
          margin-left: 110px;
          img {
            width: 136px;
            height: 136px;
            border-radius: 4px;
            margin-right: 12px;
          }
          img:nth-child(4n) {
            margin-right: 0;
          }
        }
      }
      .cards:last-child {
        .lines {
          width: 0;
          height: 0;
        }
      }
    }
  }

  .fixedBtn {
    background: #fff;
    position: fixed;
    bottom: 0;
    width: 100%;
    box-sizing: border-box;
    z-index: 999;
    .status00 {
      display: flex;

      .columns {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 40%;
        padding: 16px 0;
        border-top: 1px solid #ddd;
        img {
          width: 44px;
          height: 42px;
        }
        .hint {
          margin-top: 10px;
          font-size: 36px;
          color: #666666;
        }
      }
      .border-r {
        border-right: 1px solid #ddd;
      }
      .doIt {
        width: 60%;
        background: #3975c6;
        text-align: center;
        line-height: 112px;
        font-size: 36px;
        font-weight: 500;
        color: #fff;
      }
    }

    .endDoIt {
      background: #3975c6;
      text-align: center;
      padding: 34px 0;

      font-size: 32px;
      font-weight: 500;
      color: #ffffff;
    }
  }
}
</style>
