<template>
	<view :class="{'gray':store.isgray==1}">
		<tasklistCom @jump="jump" :taskArr="taskArr" :currentIndex="2"></tasklistCom>
	</view>
</template>

<script setup>
	import {
		beforeJump
	} from '@/utils/index.js';
	import tasklistCom from '../../component/tasklistCom.vue';
	import {
		ref
	} from 'vue';
	import {
		onLoad,
		onReachBottom
	} from '@dcloudio/uni-app';
	import {
		useStore
	} from '@/store';
	import {
		myApplyProcessListApi
	} from '@/api/api.js';
	import { toast } from '@/utils/index.js';
	const store = useStore()
	const taskArr = ref([])
	let processName = ''
	onLoad((options) => {
		processName = options.title
		getmyApply()
	})
	let pageNo = 1
	let pageSize = 10
	let loading = false
	const getmyApply = () => {
		loading = true
		uni.showLoading({
			title:'加载中...'
		})
		myApplyProcessListApi({
			pageNo,
			pageSize,
			_t: new Date().getTime(),
			processName
		}).then((res) => {
			if (res.success) {
				if(!res.result.records.length)return toast('没有更多了~')
				let arr = res.result.records
				arr.map((item) => {
					item['processApplyUserName'] = item['startUserName']
					item['processDefinitionName'] = item['prcocessDefinitionName']
					item['taskBeginTime'] = item['startTime']
				})
				taskArr.value = [...taskArr.value, ...arr]
				loading = false
			}
		}).catch((err) => {
			console.log(err);
		})

	}
	const jump = (url) => {
		beforeJump(url, () => {
			uni.navigateTo({
				url
			})
		})
	}
	onReachBottom(() => {
		if (loading) return
		pageNo++
		getmyApply()
	})
</script>

<style lang="scss" scoped>

</style>