<template>
    <div class="home_wrapper">
        <div class="header_main">
            历史任务
            <div class="return_btn" @click="onClickLeft"></div>
        </div>
      <div class="jg"></div>
      <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="getList"
        >
          <van-cell center v-for="(item,index) in applicationList" :key="index" :to="{name:'caseDetail', query: {id:item.caseId,caseProgress:item.caseProgress}}">
            <template #title>
              <div class="first">
                <span>{{item.handlerSetDate}}</span>
                <span>{{item.caseSource}}</span>
              </div>
              <span>{{item.caseName}}</span>
            </template>
            <template #label>
              <div class="label">
                <p>执法人：{{item.handlerNameStr}}</p>
                <p>{{item.caseProgressName}}</p>
              </div>
            </template>
          </van-cell>
      </van-list>
    </div>
</template>

<script>
  import { listSurvey } from "@/api/lawEnforcement/index";
  import Cookies from "js-cookie";
  import request from '@/utils/request'
  export default {
    name: "caseAllocation",
    data() {
      return {
        applicationList:[],
        applicationListSecond:[],
        assetStatusOptions:[],
        auditStatus:[],
        loading: false,
        finished: false,
        show: false,
        showTab: false,
        fileList:[],
        listLength:'0',
        searchInput:'',
        // 查询参数
        queryParams: {
          // 分页
          pageNum: 1,
          pageSize: 10,
          // 查询排序
          orderByColumn: "id",
          isAsc: "desc",
          caseName: null,
          caseProgress: "2",
          title:"",
          isDistribute: "Y"   // 办理人员是否已分配 （查询历史任务传参 “Y” ）
        },
        uploadFiles1:[],
        projectId:'',
        projectIndex:'',
        showBtn:true,
      };
    },
    created() {
      this.getDicts("case_source").then(response => {
        this.caseSourceOptions = response.data;
      });
      this.getDicts("case_node").then(response => {
        this.caseProgressOptions = response.data;
      });
    },
    methods: {
      getList(){
        var _this = this;
        listSurvey(_this.queryParams).then(response => {
          _this.listLength = response.total;
          response.rows.map(res=>{
            res.caseSource = res.caseSource == '' ? '' : this.selectDictLabel(this.caseSourceOptions, res.caseSource);
            res.caseProgressName = res.caseProgress == '' ? '' : this.selectDictLabel(this.caseProgressOptions, res.caseProgress);
            _this.applicationList.push(res);
          })
          if(_this.applicationList.length >= response.total){
            _this.finished = true;
            return;
          }else{
            _this.loading = false;
            _this.queryParams.pageNum += 1 ;
          }

        });
      },
      tabClick(year){
        this.queryParams.year = year ;
        this.applicationList = [];
        this.getList();
      },
      tabShow(){
        this.showTab = !this.showTab;
      },
      /** 删除按钮操作 */
      handleDelete(row,index) {
        let assetStatus = row.assetStatus ? row.assetStatus : data[0].assetStatus;
        if (assetStatus === '2' || assetStatus === '3') {
          this.$notify({
            message: "不允许删除已出售或已报废的资产",
            type: "warning",
          });
          return;
        }
        let useType = row.useType;
        if(useType == 3) {
          this.$notify({
            message: "出租或出借的资产不允许删除",
            type: "warning",
          });
          return ;
        }
        const ids = row.id || this.ids;

        this.$dialog.alert(
          {
            message:'是否确认删除固定资产?',
            title:"警告",
            confirmButtonText: "确定",
            cancelButtonText: "取消",
          }
        )
          .then(function () {
            return delPermanent(ids);
          })
          .then(() => {
            this.applicationList.splice(index, 1);
            this.$notify({ type: 'success', message: '删除成功' });
          });
      },
      goAdd(){
        this.$router.push('/sunVillage_info/list_finance_add')
      },
      goDetail(id){
        this.$router.push({path:'/sunVillage_info/list_finance_detail',query: {id:id,type:'finance'}})
      },
      goRanking(id,time){
        this.$router.push({path:'/sunVillage_info/list_finance_ranking',query: {id:id,time:time}})
      },
      goEdit(id){
        this.$router.push({path:'/sunVillage_info/list_finance_edit',query: {id:id,type:'finance'}})
      },
      goRemove(id){
        // this.$dialog.alert({
        //   title: '提示',
        //   message: '确认删除？',
        //   showCancelButton:true,
        // })
        //   .then(() => {
        //     openRemove(id).then(response => {
        //       this.$notify({ type: 'success', message: '删除成功' });
        //       this.getList()
        //     });
        //   })
        //   .catch(() => {
        //     // on cancel
        //   });

      }
    },
  }
</script>

<style scoped lang="scss">
  .jg{
    height: 116px;
  }
.home_wrapper{
    background: #e9e9e9;
    min-height: 100vh;
    width: 100vw;
    padding: 0 0 0.2rem;
    .search_box{
      display: flex;
      justify-content: space-between;
      align-items: center;
      width: 92%;
      margin: 0PX auto;
      .search{
        background: #ffffff;
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 80%;
        margin: 10PX auto;
        border: 1px solid #1D6FE9;
        padding: 1PX 1PX 1PX 12PX ;
        border-radius: 50PX;
        input{
          flex: 1;
          background: transparent;
        }
      }
    }
    .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: #D60303;
      &:first-child{
        color: #1D6FE9;
      }
    }
  }
  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{
      color: #1D6FE9;
    }
    &:last-child{
      padding: 0 7PX;
      border: 1px solid #666666;
      color: #666666;
      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;
}
.van-row{
  height: 100%;
}
.van-col{
  height: 100%;
}
.delete-button {
  height: 100%;
}
</style>
