<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;color: #616161;">
										{{item.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 :span="12">
								<view class="demo-uni-col light" style="padding: 26rpx;color: #b1b1b1;">
								</view>
							</uni-col>
						</uni-row>
						<uni-row class="demo-uni-row">
							<uni-col :span="12">
								<view class="demo-uni-col light" style="color: #b1b1b1;">
									{{"申请人："+item.formData.apply_user_name}}
								</view>
							</uni-col>
							<uni-col :span="12">
								<view class="demo-uni-col light" style="color: #b1b1b1;">
									{{item.createTime}}
								</view>
							</uni-col>
						</uni-row>
					</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,
				actions: [],
				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: ''
			}
		},
		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) {
				item.pageType = 4
				uni.setStorageSync("approval", item)
				this.readL(item.taskId)
				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')
				}else if (item.examplesId === uni.getStorageSync('contract_approval_flow_run_key')) {
					this.$goto('../ge/geContract')
				}

				this.list = []
			},
			async readL(id) {
				// 发送请求
				const {
					data: res
				} = await this.$httpRequest({
					url: '/app/rt?taskId=' + id,
					method: 'get',
					urlType: this.$getUrlType()
				});
				if (res.code === 200) {

				}
			},
			async taskList(paging) {
				// 发送请求
				const {
					data: res
				} = await this.$httpRequest({
					url: '/app/ccRecord?pageNum=' + paging.page + '&pageSize=' + paging.size,
					method: 'get',
					urlType: this.$getUrlType()
				});
				if (res.code === 200) {
					for (var i = 0; i < res.rows.length; i++) {
						res.rows[i].formData = JSON.parse(res.rows[i].formData)
					}
					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
						});
					}
				}
			},
			refresh(paging) {
				this.taskList(paging)
			},
			scrolltolower(e) {},
			load(paging) {
				this.taskList(paging)
			},
			loadSuccess(list) {
				this.list = list
			}
		}
	}
</script>
