<template>
	<view class="blacklog-container">
		<uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="我的待办" @clickLeft="back"></uni-nav-bar>
		<view class="list-container">
			<view v-for="(item, index) in list" :key="index">
				<CardTime :time="item.createTime" />
				<KdCard :title="item.processInstance.name" :item="item" @handleDetail="handleDetail(item)" />
			</view>
		</view>
		<view v-show="list.length === 0" class="no_data">
			<u-empty mode="data" textSize="30"></u-empty>
		</view>
	</view>
</template>

<script>
	import {
		getTodoTaskPage
	} from '@/api/wt/index.js'
	import KdCard from '../components/KdCard/index.vue'
	import CardTime from '../components/CardTime.vue'
	let [page, size, isEnd] = [1, 10, true]

	export default {
		components: {
			KdCard,
			CardTime
		},
		data() {
			return {
				list: [],
				params: {
					handleStatus: 0,
					keywords: '',
					handleType: ''
				}
			}
		},
		//加载更多
		onReachBottom: function() {
			console.log('asdsad')
			if (isEnd) {
				return
			}

			// 显示加载图标
			uni.showLoading({
				title: '数据加载中'
			})
			this.getMoreLists()
		},
		onShow() {
			page = 1
			this.list = []
			this.getList()
		},

		methods: {
			scrolltolower() {},

			handleDetail(item) {
				console.log(item)
				let url = ''
				uni.navigateTo({
					url
				})
			},
			/* 
			 handleType 	办理类型(0 审批 1 验收)  
			 devOpsType	运维管理类型(0 计划 1 工单)
			 planType.code	计划类型(1:巡点检;2:保养;3:维修;4:盘点;5:出入库) 
			*/
			async getList() {
				let paging = {
					page,
					size
				}
				let par = Object.assign(paging, this.params)
				this.list = await getTodoTaskPage(par)
				this.list.forEach(item => {
					item.startUserNickname = item.processInstance.startUserNickname
				})
				console.log(this.list)


			},
			getMoreLists: function() {
				//获取更多数据
				page++
				this.getList()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.blacklog-container {
		height: 100vh;
		display: flex;
		flex-direction: column;
	}

	.list-container {
		flex: 1;
		padding: 24rpx;
		background: $page-bg;
		// position: absolute;
		// top: 88rpx;
		// bottom: 0;
		// left: 0;
		// right: 0;

		/deep/.u-list {
			height: 100% !important;
		}
	}

	.no_data {
		position: fixed;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
		color: #999;
		font-size: 50rpx;
	}
</style>