<template>
  <div class="list">
    <u-navbar back-icon-color="#000" :title="title" title-color="#000" title-width="300" title-size="32" 
      :title-bold="true" :background="backgroundNavbar" :is-fixed="true" height="44"></u-navbar>
    <div class="header-content-bg">
      <img src="https://cdn.sinoecare.com/i/2024/07/12/6690a1303d423.png" alt="">
    </div>
    <div class="list-content">
      <div class="item" v-for="(item, i) in datas" :key="i" @click.native="goDetail(item, 1)">
        <div class="card-top">
          <div class="titles">{{ item.content }}</div>
          <div class="source-type">{{ $dict.getLabel('residentEventSource', item.eventSource) }}</div>
          <div class="info">
            <span>事件类型</span>
            <span class="value">{{ item.groupName }}</span>
          </div>
          <div class="info">
            <span>所属网格</span>
            <span class="value">{{ item.girdName }}</span>
          </div>
        </div>
        <div class="card-bottom">
          <div class="status" v-if="item.eventStatus"
            :class="item.eventStatus == 0 ? 'status0' : item.eventStatus == 1 ? 'status1' : item.eventStatus == 2 ? 'status2' : 'status3'">
            <span class="icon"></span>
            <span>{{ $dict.getLabel('clapEventStatus', item.eventStatus) }}</span>
          </div>
          <div class="level-type">中风险纠纷</div>
        </div>
      </div>
      <AiEmpty v-if="!datas.length"/>
    </div>
    <div class="pad-b120" v-if="datas.length"></div>
  </div>
</template>

<script>
import {mapState} from 'vuex'

export default {
  customNavigation: true,
  data() {
    return {
      datas: [],
      current: 1,
      pages: 0,
      searchType: '',
      title: '',
      girdId: '',
      backgroundNavbar: {
        background: 'url(https://cdn.sinoecare.com/i/2024/07/12/6690a1309c7d3.png) no-repeat',
        backgroundSize: 'cover',
      },
    }
  },
  computed: {
    ...mapState(['user']),
    listType() {
      return this.$dict.getDict('clapEventStatusAll')
    }
  },
  onLoad(options) {
    
    console.log(options)
    this.searchType = options.searchType
    this.title = ['', '', '累计上报', '今日上报', '今日办结', '办理中'][options.searchType]
    this.girdId = options.girdId
  },
  onShow() {
    this.current = 1
    this.getList()
  },
  created() {
    this.$dict.load('clapEventStatus', 'clapEventStatusAll', 'clapEventStatusHistory', 'residentEventSource').then(() => {
      this.getList()
    })
  },
  methods: {
    getListInit() {
      this.current = 1
      this.getList()
    },
    nextPage() {
      this.current++
      this.getList()
    },
    getList() {
      let {current, girdId, searchType} = this
      this.$instance.post(`/app/apppatrolreportinfov2/listByStatus`, null, {
        params: {
          size: 10,
          current, 
          girdId,
          searchType
        },
      }).then((res) => {
        if (res.code == 0) {
          this.datas = this.current > 1 ? [...this.datas, ...res.data.records] : res.data.records
          this.pages = res.data.pages
          this.$forceUpdate()
        }
      })
    },
    goDetail(item) {
      uni.navigateTo({url: `./Detail?id=${item.id}&isShowBtn=0`})
    },
  },
  onReachBottom() {
    this.nextPage()
  }
}
</script>

<style scoped lang="scss">
uni-page-body {
  height: 100%;
  background: #F4F5FA;
}
.list {
  height: 100%;
  width: 100vw;

  .header-content-bg {
    width: 100%;
    position: fixed;
    z-index: -1;
    img {
      width: 100%;
      height: 592px;
    }
  }
  .list-content {
    margin: 16px 0 0 32px;
  }

  .item {
    width: calc(100% - 32px);
    background: #FFF;
    box-shadow: 0 0 4px 0 #00000005;
    border-radius: 16px;
    margin-bottom: 32px;
    .card-top {
      width: 100%;
      padding: 32px 32px 24px 32px;
      box-sizing: border-box;
      position: relative;
      .titles {
        width: calc(100% - 132px);
        word-break: break-all;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        line-height: 44px;
        font-family: PingFangSC-Medium;
        font-weight: 500;
        font-size: 32px;
        color: #333;
        margin-bottom: 24px;  
      }
      .source-type {
        padding: 0 10px;
        line-height: 44px;
        background-color: #EBF3FE;
        border-radius: 6px;
        font-family: PingFangSC-Regular;
        font-size: 24px;
        color: #3D88F5;
        position: absolute;
        top: 32px;
        right: 32px;
      }

      .info {
        line-height: 40px;
        font-family: PingFangSC-Regular;
        font-weight: 400;
        font-size: 28px;
        color: #999;
        margin-bottom: 8px;

        .value {
          display: inline-block;
          margin-left: 24px;
          color: #333;
        }
      }
    }

    .card-bottom {
      display: flex;
      justify-content: space-between;
      padding: 32px;
      border-top: 1px solid #ddd;
      font-family: PingFangSC-Regular;
      font-weight: 400;
      font-size: 28px;
    }

    .status {
      .icon {
        display: inline-block;
        width: 16px;
        height: 16px;
        vertical-align: middle;
        margin-right: 16px;
        border-radius: 50%;
      }
    }

    .status0 {
      color: #ff883c;

      .icon {
        background: #ff883c;
      }
    }

    .status1 {
      color: #1aaaff;

      .icon {
        background: #1aaaff;
      }
    }

    .status2 {
      color: #42d784;

      .icon {
        background: #42d784;
      }
    }

    .status3 {
      color: #ff4466;

      .icon {
        background: #ff4466;
      }
    }

    .level-type0 {
      color: #52C75B;
    }
    .level-type1 {
      color: #FF883C;
    }
    .level-type2 {
      color: #FF3C3C;
    }
    
  }
}
</style>
