<template>
  <div>
    <div class="detailItem">
      <div class="imgparent">
        <van-nav-bar
          title="待审批"
          left-text="返回"
          left-arrow
          @click-left="onClickLeft"
        />
      </div>
      <div class="approva_header">
        <van-notice-bar
          color="#1989fa"
          background="#fff"
          left-icon="volume-o"
        >
          技术是开发它的人的共同灵魂。
        </van-notice-bar>
      </div>
      <div>
        <van-list
          v-model="loading"
          :finished="finished"
          :finished-text="finishedText"
          @load="onLoad"
          :immediate-check="false"
        >
          <div
            class="approba_nave"
            v-for="(item,index) in allHouseDetail"
            :key="index"
            @click="xiangq(item.id)"
          >
            <p>
              <span class="soei"><i>{{item.leavefrom_user_name}}</i>的请假申请</span>
              <span>{{item.leavefrom_start_time}}</span>
            </p>
            <p>请假类型:{{item.leavefrom_leave_type}}</p>
            <p>开始时间：{{item.leavefrom_start_time}}</p>
            <p>结束时间：{{item.leavefrom_end_time}}</p>
          </div>
        </van-list>
      </div>

    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      message: "",
      uploader: [{ url: "https://img01.yzcdn.cn/vant/leaf.jpg" }],
      allHouseDetail: [],
      loading: false,
      finished: false,
      qurmond: {
        table: "leavefrom",
        pageNo: 1,
        pageSize: 4,
        orderBy: "create_time desc",
        fixedData: {
          condition: {
            status: 1
          }
        },
      },
       page: 1, // 当前页码
       page_size: 100, // 每页多少条
        total: 0, // 总条数
        error: false, // 错误提示
        refreshing: false ,// 下拉刷新
        finishedText:''
    };
  },
  props: ["detailitem"],

  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
    onConfirm(value) {
      this.value = value;
      this.showPicker = false;
    },
    xiangq(index) {
      this.$router.push("/details?id=" + index);
    },
    async appList() {
      const res = await this.$http.post(
        "/boman-web-core/p/cs/queryList",
        this.qurmond
      );
      console.log(res);
      if (res.data.code !== 200) {
        this.$msg.fail(res.data.msg);
        return false;
      }
      // this.allHouseDetail = res.data.data.rows;
       if (this.qurmond.pageNo == 1) {
      this.loading = false
      this.allHouseDetail = res.data.data.rows;
      this.total = res.total;
    } else {
      this.loading = false
      this.allHouseDetail = this.allHouseDetail.concat(res.data.data.rows)
      this.total = res.data.total;
    }
    if(res.data.data.rows.length < this.qurmond.pageSize){
      this.finished = true;
      this.finishedText = '没有更多啦';
    }
    if (res.data.data.rows.length == 0) {
      this.finished = true;
      this.finishedText = '暂无数据';
      console.log(34)
    } else if (res.data.data.rows.length < this.qurmond.pageSize) {
      console.log(12)
      this.finished = true;
      this.finishedText = '没有更多啦';
    }
    console.log(this.allHouseDetail)
    },
    onLoad() {
      // 异步更新数据
      // setTimeout 仅做示例，真实场景中一般为 ajax 请求
      this.qurmond.pageNo++; 
      this.appList();
    }
  },
  created() {
    this.appList();
  }
};
</script>

<style lang="less">
.formtr {
  .stru {
    .van-field__control {
      text-align: right;
    }
  }

  .van-cell:not(:last-child)::after {
    border-bottom: 0;
  }
  .van-field__control--custom {
    justify-content: flex-end;
  }
  .van-cell {
    font-weight: 500;
    color: #343434;
    padding: 5.6vw 4.267vw;
  }
}
</style>


<style scoped lang="less">
.detailItem {
  background-color: #fff;
  //   height: 100vh;
  p {
    font-size: 3.333vw;
    padding: 0.833vw 0;
  }
  .imgparent {
    position: relative;
    .bottom {
      padding: 0 2.778vw;
      margin-bottom: 1.389vw;
      position: absolute;
      bottom: 0.556vw;
      background: linear-gradient(0deg, rgba(0, 0, 0, 0.85), transparent);
      justify-content: space-between;
      color: white;
      display: flex;
      left: 0;
      right: 0;
    }
  }
  .approba_nave {
    border-bottom: 0.267vw solid #dadada;
    margin: 16px 16px;
    padding: 16px 0;
    p {
      font-size: 2.667vw;
      font-family: PingFang SC;
      font-weight: 400;
      color: #666666;
    }
    p:nth-child(1) {
      display: flex;
      justify-content: space-between;
      margin-bottom: 2.133vw;
      i {
        font-style: normal;
        font-weight: 700;
      }
      .soei {
        font-size: 3.733vw;
        font-family: PingFang SC;
        font-weight: 400;
        color: #343434;
      }
      span:nth-child(2) {
        color: #aaa;
        font-weight: 500;
      }
    }
  }
}
.approva_header {
  box-shadow: 0vw 0.8vw 0.533vw 0vw rgba(218, 218, 218, 0.35);
}
</style>