<template>
  <div class="home_wrapper">
    <!--  头部开始  -->
    <van-nav-bar
      title="草稿箱"
      fixed
      placeholder
      left-arrow
      @click-left="onClickLeft"
    />
    <!--  头部结束  -->

    <!--  内容开始  -->
    <div class="main">

      <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="getList"
      >
  <!--            @load="onLoad"-->
        <div class="main_content_right_list" v-for="(item,index) in supplyDemandListYes" :key="index" @click="$router.push({name:'agriculturalTrusteeshipSocializationProjectEdit',query:{id:item.id}})">
          <div class="main_content_right_list_center">
            <img v-if="item.supplyMasterMap" :src="item.supplyMasterMap" style="width: 18vw;height: 18vw;">
            <img v-else src="../../../../static/images/agriculturalTrusteeship/zwtp.png" style="width: 18vw;height: 18vw;">
            <div class="main_content_right_list_content">
              <p class="tt">{{item.supplyDemandName}}</p>
              <p class="name">{{item.createTime.substr(0,10)}}</p>
            </div>
          </div>
        </div>
      </van-list>

    </div>
    <!--  内容结束  -->
  </div>
</template>
<script>
  import Cookies from "js-cookie";
  import agr from "@/components/common/agr_footer";
  import dialogClose from "@/components/agriculturalTrusteeship/dialog";
  import {supplyDemandList} from "@/api/agriculturalTrusteeship";

  export default {
    name: "agriculturalTrusteeshipIndex",
    components: {
      agr,
      dialogClose
    },
    data() {
      return {
        activeKey: 0,
        active: 0,
        loading: false,
        finished: false,
        showDialog:false,
        supplyDemandList:[],
        supplyDemandListYes:[],
        query:{
          entityId:Cookies.get('ACCESS-SESSION-ID'),
          productType:''
        },
      };
    },
    created() {

    },
    methods: {
      getList(){
        supplyDemandList(this.query).then(response => {
          response.rows.map(res=>{
            if (res.supplyMasterMap){
              let supplyMasterMap = res.supplyMasterMap.split( "," )
              res.supplyMasterMap = '/api'+supplyMasterMap[0]
            }
            if(res.publishStatus == 2){
              this.supplyDemandListYes.push(res);
            }
            this.supplyDemandList.push(res);
          })
          if(this.supplyDemandList.length >= response.total){
            this.finished = true;
            return;
          }else{
            this.loading = false;
            this.query.pageNum += 1 ;
          }
        });
      },
      openDialog(val){
        this.showDialog = val
      },
    },
  }
</script>
<style scoped lang="scss">
.home_wrapper{

}
  /*头部*/
  .header{
    display: flex;
    align-items: end;
    justify-content: space-between;
    padding: 2vh 4% 0vh;
    p{
      &:nth-child(1){
        color: #334281;
        font-size: .45rem;
      }
      &:nth-child(2){
        color: #7A7A7A;
        margin-top: .5vh;
      }
    }
  }

  /*内容*/
  .main{
    width: 94%;
    margin: 0 auto;
    .main_content_right_list{
      margin-top: 2vh;
      padding: 1.5vh 3%;
      background: #ffffff;
      border-radius: 10PX;
      /*box-shadow: 0px 3PX 6PX 0px rgba(0,0,0,0.16);*/
      /deep/ .van-cell{
        padding: 0;
        margin-top: 8PX;
      }
      .main_content_right_list_header{
        display: flex;
        margin-bottom: 1vh;
        align-items: center;
        p{
          padding: 3PX 10PX;
          border-radius: 8PX;
          &:nth-child(1){background: #2B7EEC;color: #ffffff;}
          &:nth-child(2){background: #E2E9FD;color: #497CE8;margin-left: 10PX;}
          &:nth-child(3){color: #334281;margin-left: auto;padding:0 0 0 15PX;background: url("../../../../static/images/agriculturalTrusteeship/socialization/socialization_icon_clock.png") no-repeat left center}
        }
      }
      .main_content_right_list_center{
        display: flex;
        img{
          border-radius: 15PX;
          margin-right: 4%;
        }
        .main_content_right_list_content{
          display: flex;
          flex-direction:column;
          justify-content: space-between;
          .tt{
            color: #333333;
            font-size: .35rem;
          }
          .tab{
            display: flex;
            justify-content: space-between;
            p{
              &:nth-child(1){
                flex: 1;
                color: #FF5E00;
                span{
                  font-size: .4rem;
                }
              }
              &:nth-child(2){
                span{
                  display: inline-block;
                  text-align: center;
                  padding: 2PX 5PX;
                  &:nth-child(1){
                    color: #497CE8;
                    background: #E2E9FD;
                    border-top-left-radius: 10PX;
                  }
                  &:nth-child(2){
                    color: #ffffff;
                    background-image: linear-gradient(to right , #5D87FA , #5FD5F5);
                    border-bottom-right-radius: 10PX;
                  }
                }
              }
            }
          }
          .name{
            color: #334281;
            /*margin-left: auto;*/
            padding:0 0 0 15PX;
            background: url("../../../../static/images/agriculturalTrusteeship/socialization/socialization_icon_clock.png") no-repeat left center
          }
        }
      }
    }
  }

</style>
