<template>
    <div class="home_wrapper">
        <div class="header_main">
            关联案件
            <div class="return_btn" @click="onClickLeft"></div>
        </div>
      <div class="jg"></div>

      <div class="search_box" v-if="list.length>0">
        <p><span>{{list[0].name}}</span>关联案件</p>
      </div>

      <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="getList"
        >
        <van-swipe-cell v-for="(item,index) in list" :key="index">
          <van-cell center :to="{name:'caseDetail', query: {id:item.id,caseProgress:item.caseProgress}}">
            <template #title>
              <span>{{item.caseName}}</span>
            </template>
            <template #label>
              <div class="label">
                <p>{{item.caseSource}}</p>
                <p>{{item.caseProgressText}}</p>
              </div>
            </template>
          </van-cell>
        </van-swipe-cell>
      </van-list>
    </div>
</template>

<script>
  import { listCase } from "@/api/lawEnforcement/index";
  export default {
    name: "caseAllocation",
    data() {
      return {
        loading: false,
        finished: false,
        caseQueryParams:{
          // 分页
          pageNum: 1,
          pageSize: 10,
          // 查询排序
          orderByColumn: "id",
          isAsc: "desc",
          bodyId: null,  //个体户ID
          type: "1"
        },
        list:[]
      };
    },
    created() {
      console.log(this.$route.query.id)
      this.getDicts("case_node").then(response => {
        this.caseProgressOptions = response.data;
      });
      this.getDicts("case_source").then(response => {
        this.caseSourceOptions = response.data;
      });
      this.caseQueryParams.bodyId = this.$route.query.id;
    },
    methods: {
      getList(){
        var _this = this;
        listCase(_this.caseQueryParams).then(response => {
          response.rows.map(res=>{
            res.caseProgressText = res.caseProgress == '' ? '' : this.selectDictLabel(this.caseProgressOptions, res.caseProgress);
            res.caseSource = res.caseSource == '' ? '' : this.selectDictLabel(this.caseSourceOptions, res.caseSource);
            _this.list.push(res);
          })
          if(_this.list.length >= response.total){
            _this.finished = true;
            return;
          }else{
            _this.loading = false;
            _this.queryParams.pageNum += 1 ;
          }
        });
      },

    },
  }
</script>

<style scoped lang="scss">
.jg{
  height: 116px;
}
.home_wrapper{
    background: #e9e9e9;
    min-height: 100vh;
    width: 100vw;
    padding: 0 2% 0.2rem;

    .search_box{
      display: flex;
      justify-content: center;
      align-items: center;
      width: 92%;
      margin: 10PX auto;
      font-size: 0.4rem;
      span{
        color: #1D6FE9;
      }
    }
    .header_main{
        height: 116px;
        background: url('../../../../static/images/lawEnforcement/new/list_head.png') no-repeat;
        background-size: 100% 100%;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        font-size: 36px;
        line-height: 116px;
        text-align: center;
        color: #fff;
        z-index: 999;
        .return_btn{
            width: 24px;
            height: 43.2px;
            background: url('../../../assets/images/sunVillage_info/list_icon_5.png') center center no-repeat;
            background-size: 20px 36px;
            position: absolute;
            left: 38px;
            top: 36px;
        }
        .add_btn{
            width: 56.4px;
            height: 40.8px;
            background: url('../../../assets/images/sunVillage_info/list_icon_9.png') center center no-repeat;
            background-size: 47px 34px;
            position: absolute;
            right: 38px;
            top: 36px;
        }
    }

}
/deep/.van-cell__title{
  .first{
    display: flex;
    justify-content: space-between;
    span{
      color: #FE1313;
      &:last-child{
        color: #B4B0B0;
      }
    }
  }
  span{
    font-family: Arial;
    font-size: 0.35rem;
    font-weight: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    word-break: break-all;
    overflow: hidden;
  }
}
/deep/.van-cell__label .label {
  display: flex;
  justify-content: space-between;
  p{
    display: inline-block;
    font-size: 0.35rem;
    &:first-child{
      background: rgba(29,111,233,0.2);
      padding: 0 8PX;
      border-radius: 3PX;
      color: #1D6FE9;
    }
    &:last-child{
      padding: 0 7PX;
      border: 1px solid #1CB8B1;
      color: #1CB8B1;
      border-radius: 1rem;
    }
  }
}
/deep/.van-cell__value{
  flex: 0.3;
  color: #1D6FE9;
  font-weight: bold;
}
/deep/.van-cell{
  /*margin-bottom: 0.2rem;*/
  /*overflow: hidden;*/
}
/deep/.van-cell:first-child{
  /*margin-top: 0.2rem;*/
}
/deep/van-ellipsis{
  font-weight: bold;
}
/deep/ .van-swipe-cell{
  margin-bottom: 0.3rem;
  border-radius: 0.2rem;
  overflow: hidden;
  box-shadow: 0px 3px 6px 0px rgba(0,0,0,0.16);
  &:first-child{
    margin-top: 0.3rem;
  }
}
/deep/ .van-swipe-cell__right{
  right: -1PX;
}
.van-row{
  height: 100%;
}
.van-col{
  height: 100%;
}
.delete-button {
  height: 100%;
}
</style>
