<template>
	<view>
		<view class="tag-view text-center" style="padding: 10rpx;">
			<uni-tag :text="'您还有' + total + '个任务待审'" />
		</view>
		<u-list v-if="todoList.length > 0">
			<u-list-item v-for="(item, index) in todoList" :key="index">
				<view @click="goToDetail(item)">
					<uni-card>
						<view style="text-align: right;">
							<span style="font-size: 26rpx;color: #999999;">{{item.createTime}}</span>
						</view>
						<uni-title type="h3" :title="item.title ? item.title:'暂无标题'"></uni-title>
						<view>流程名称：{{item.procDefName}}</view>
						<view>当前节点：{{item.taskName}}</view>
						<view>流程发起人：{{item.startUserName}}</view>
					</uni-card>
				</view>
			</u-list-item>
		</u-list>
		<u-empty v-else></u-empty>
	</view>
</template>

<script>
	import {
		todoList
	} from "@/api/flowable/todo";
	export default {
		data() {
			return {
				todoList: [],
				total: 0,
			};
		},
		created() {
			this.getTodoList();
		},
		onLoad: function(options) {
			uni.startPullDownRefresh();
		},
		onPullDownRefresh() {
			this.getTodoList();
		},
		methods: {
			getTodoList() {
				todoList({
					pageNum: 1,
					pageSize: 999,
					name: null
				}).then(response => {
					this.total = response.data.total;
					this.todoList = response.data.records;
					uni.stopPullDownRefresh();
				});
			},
			goToDetail(item) {
				// 跳转到详情页，并传递项目ID
				console.log(item)
				uni.navigateTo({
					url: `/pages/message/apply/detail?procDefName=${item.procDefName}&taskName=${item.taskName}&startUserName=${item.startUserName}&taskId=${item.taskId}`
				});
			}
		}
	}
</script>

<style lang="scss">

</style>