<template>
  <view class="rzbox">
	<box-list :datainfo="list" type="rzbox"></box-list>
	<view class="tzfbox">
		<view class="abtns" @click="getAddFn">添加</view>
	</view>
	<loading></loading>
  </view>
</template>

<script>
import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
import {getDictionaryFn} from "@/api/mine/register.js";
import boxList from "@/work/components/box/list.vue"
  export default {
	components:{boxList},
	data(){
		return{
			list:[{tit:1},{tit:1},],
			pageSize: 10,
			pageNum: 1,
			reachflag: true,
			wtdt:'',
		}
	},
	onShow() {
		
	},
	onUnload() {
		uni.$off('refreshtRzlist')
	},
    onLoad: function() {
		uni.$on('refreshtRzlist',(res)=>{
			this.getrefreshData()
		})
		// this.init();
		// this.getDataFn()
    },
	// 上拉触底加载更多触发事件
	onReachBottom() {
		if (this.reachflag) {
			this.pageNum++
			// this.getDataFn()
		}
	},
	methods:{
		checkPermi,checkRole,
		init(){
			//工单类型
			getDictionaryFn('work_order_type').then(res => {
				if (res.code == 200) {
					this.gdList = res.data.map(v => {
						return {
							dictLabel: v.dictLabel,
							dictValue: v.dictValue
						}
					})
				}
			})
		},
		getrefreshData(){
			this.pageNum=1;
			this.list=[];
			this.reachflag=true;
			this.getDataFn()
		},
		getDetail(e){
			// this.$tab.navigateTo(`/work/pages/detail?id=${e}`) 
		},
		getAddFn(){
			this.$tab.navigateTo(`/work/pages/rz/add`) 
		},
		getDataFn(){
			var params={
				pageSize:this.pageSize,
				pageNum: this.pageNum,
			}
			getworkInfoList(params).then(res=>{
				if(res.code==200){
					if (res.rows.length < this.pageSize) {
						this.reachflag = false
						this.wtdt = '到底了~';
					} else {
						var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum -	1)
						if (num < res.total) {
							this.reachflag = true
							this.wtdt = ''
						} else {
							this.reachflag = false
							this.wtdt = '到底了~';
						}
					}
					if (this.pageNum == 1) {
						this.list = res.rows;
					} else {
						this.list = this.list.concat(res.rows)
					}
				}else{
					this.$toast(res.msg)
				}
			})
				
		},
		
		
		
	}
  }
</script>
<style lang="scss" scoped>
.rzbox{padding: 24rpx 48rpx 186rpx;
	.tzfbox{padding: 24rpx 24rpx 74rpx;position: fixed;left: 0;right: 0;bottom: 0;z-index: 2;background: #ffffff;}
}
</style>
