<template>
	<view>
		<scroll-list ref="list" :option="option" @load="load" @refresh="refresh" @loadSuccess="loadSuccess"
			@scrolltolower="scrolltolower">
			<view v-for="(item, index) in list" :key="index" @click="handleTest(item)">
				<view class="infoBody">
					<view>
						<view style="border-bottom: 1px #b8b8b8 solid;">
							<uni-row class="demo-uni-row">
								<uni-col :span="20">
									<view class="demo-uni-col dark"
										style="font-size: 36rpx;margin: -20rpx 0 0 0;font-weight: bold;letter-spacing:5rpx;">
										{{item.formData.title}}
									</view>
								</uni-col>
								<uni-col v-if="item.msgIsRead === '0'" :span="4">
									<view class="demo-uni-col light"
										style="color: rgb(55,186,189);margin-bottom: 10rpx;">
										新进度
									</view>
								</uni-col>
							</uni-row>
						</view>
						<uni-row class="demo-uni-row">
							<uni-col>
								<view class="demo-uni-col light" style="padding: 26rpx;color: #b1b1b1;">
									{{item.formData.reason ? item.formData.reason : ''}}
								</view>
							</uni-col>
						</uni-row>
						<uni-row class="demo-uni-row">
							<uni-col :span="5">
								<view class="demo-uni-col light" style="color: #727272;">
									申请人：
								</view>
							</uni-col>
							<uni-col :span="6">
								<view class="demo-uni-col light" style="color: #727272;">
									{{item.formData.apply_user_name}}
								</view>
							</uni-col>
							<uni-col :span="13">
								<view class="demo-uni-col light" style="color: #727272;">
									{{item.createTime}}
								</view>
							</uni-col>
						</uni-row>
					</view>
					<view></view>
				</view>
			</view>
		</scroll-list>
	</view>
</template>
<style lang="scss" scoped>
	// page {
	// 	background-color: #f3f3f3;
	// }

	.page-wrap {}

	.infoBody {
		background-color: #ffffff;
		padding: 40rpx;
		border-radius: 20rpx;
		margin: 20rpx;
		box-shadow: 0px 2px 10px #cccccc;
	}
</style>
<script>
	export default {
		data() {
			return {
				option: {
					page: 1,
					size: 5,
					auto: true
				},
				page: 1,
				list: [],
				scrollList: [],
				total: 0,
				file_approval_flow_run_key: '',
				biz_leave_flow_run_key: '',
				reserve_consuming_flow_run_key: '',
				personnel_hire_approval_flow_run_key: '',
				personnel_dimission_approval_flow_run_key: '',
				isClick: false
			}
		},
		onLoad() {
			this.file_approval_flow_run_key = uni.getStorageSync('file_approval_flow_run_key')
			this.biz_leave_flow_run_key = uni.getStorageSync('biz_leave_flow_run_key')
			this.reserve_consuming_flow_run_key = uni.getStorageSync('reserve_consuming_flow_run_key')
			this.reserve_return_flow_run_key = uni.getStorageSync('reserve_return_flow_run_key')
			this.reserve_register_flow_run_key = uni.getStorageSync('reserve_register_flow_run_key')
			this.personnel_hire_approval_flow_run_key = uni.getStorageSync('personnel_hire_approval_flow_run_key')
			this.personnel_dimission_approval_flow_run_key = uni.getStorageSync(
				'personnel_dimission_approval_flow_run_key')
		},
		onShow() {
			this.$refs.list.refresh()
		},
		methods: {
			handleTest(item) {
				console.log(this.isClick)
				if (this.isClick) {
					return
				}
				item.pageType = 1
				this.list = []
				uni.setStorageSync("approval", item)
				if (item.examplesId === this.file_approval_flow_run_key) {
					this.$goto('../ge/geNewsApproval')
				} else if (item.examplesId === this.biz_leave_flow_run_key) {
					this.$goto('../ge/geApproval')
				} else if (item.examplesId === this.reserve_register_flow_run_key) {
					this.$goto('../ge/geReserveApproval')
				} else if (item.examplesId === this.reserve_consuming_flow_run_key) {
					this.$goto('../ge/geReserveApproval')
				} else if (item.examplesId === this.reserve_return_flow_run_key) {
					this.$goto('../ge/geReserveApproval')
				} else if (item.examplesId === this.personnel_hire_approval_flow_run_key) {
					this.$goto('../ge/geEntry')
				} else if (item.examplesId === this.personnel_dimission_approval_flow_run_key) {
					this.$goto('../ge/geDimission')
				} else if (item.examplesId === uni.getStorageSync('interview_record_approval_flow_run_key')) {
					this.$goto('../ge/geInterview')
				} else if (item.examplesId === uni.getStorageSync('instant_notice_approval_flow_run_key')) {
					this.$goto('../ge/geNotice')
				} else if (item.examplesId === uni.getStorageSync('shift_official_approval_flow_run_key')) {
					this.$goto('../ge/geShiftOfficial')
				} else if (item.examplesId === uni.getStorageSync('use_seal_approval_flow_run_key')) {
					this.$goto('../ge/geUseSeal')
				} else if (item.examplesId === uni.getStorageSync('device_repairs_approval_flow_run_key')) {
					this.$goto('../ge/geDeviceRepairs')
				} else if (item.examplesId === uni.getStorageSync('device_scrap_approval_flow_run_key')) {
					this.$goto('../ge/geDeviceScrap')
				}else if (item.examplesId === uni.getStorageSync('purchase_approval_flow_run_key')) {
					this.$goto('../ge/gePurchase')
				}
			},
			async taskList(paging) {
				this.isClick = true
				// 发送请求
				const {
					data: res
				} = await this.$httpRequest({
					url: '/app/gtd?pageNum=' + paging.page + '&pageSize=' + paging.size,
					method: 'get',
					urlType: this.$getUrlType()
				});
				if (res.code === 200) {
					if (paging.page === 1) {
						this.scrollList = res.rows
						this.total = res.total
						this.$refs.list.loadSuccess({
							list: res.rows,
							total: this.total
						});
					} else if (paging.page > 1) {
						for (var i = 0; i < res.rows.length; i++) {
							this.scrollList.push(res.rows[i])
						}
						this.$refs.list.loadSuccess({
							list: this.scrollList,
							total: this.total
						});
					}

					this.isClick = false
				}

			},
			// 刷新
			refresh(paging) {
				this.taskList(paging)
				this.isClick = false
			},
			scrolltolower(e) {
				console.log(e)
			},
			load(paging) {
				this.taskList(paging)
			},
			loadSuccess(list) {
				this.list = list
				this.isClick = false
			}
		}
	}
</script>
