var app = getApp();
var that;
Page({
  data: {
    isData: false,
    list: [],
    jxName: '哈哈',
    selectIndex: 0,
    selectpfList: [
      // 选择时间选项
      { value: 0, label: '全部' },
      { value: 2, label: '月度' },
      { value: 3, label: '季度' },
      { value: 4, label: '半年度' },
      { value: 5, label: '年度' },
      { value: 1, label: '天' },
      { value: 6, label: '自定义' }
    ],
    page:1,
  },
  onLoad() {
    that = this;
    dd.setNavigationBar({ title: "全部考核" });
  },
  onShow(){
    if(this.data.page==1){
      this.getList();
    }
  },
  getList(is) {
    if (!is) { this.setData({ page: 1 })};
    let data = {
      cycle_type: this.data.selectpfList[this.data.selectIndex].value,
      is_manage_scope: 1,
      page: this.data.page,
      page_size: 20,
    }
    app.$get('api/per/package/list', data).then((res) => {
      var list = res.data.data.list;
      if (this.data.page !== 1) {
        list = this.data.list.concat(list);
      }
      this.setData({
        list: list,
        isData: list.length == res.data.data.total
      })
    })
  },
  activeItem(e) {
    this.setData({ selectIndex: e.detail.value, })
    this.getList();
  },
  //上啦加载
  onScrollToLower() {
    if (!that.data.isData) {
      this.setData({
        page: ++this.data.page
      })
      this.getList(true);
    }
  },
  openDetail(e) {
    var item = e.target.dataset.item;
    dd.navigateTo({
      url: '../workList/workList?id='+item.id+'&tel='+item.name
    })
  },
});
