<template>
	<view id="page">
		<indexPers />
		<view class="index-pc-cur Box" v-if="!!curPcList.length">
			<view class="index-title">
				排查中
			</view>
			<view class="Content MarginAuto BorderBox" style="padding-bottom: 2px;">
				<view class="List Width100 BorderBox">
					<view class="Unit FontBold BorderBox Width100 MarginT_30rpx BG_FFFFFF" v-for="item in list"
						:key='item.id' @click='handleClick(item)'>
						<!-- <image class="imgleft" :src="item.imgurl || '/static/logo.png'" mode="widthFix"></image> -->
						<view class="right">
							<view class="title">{{ item.name }}</view>
							<view class="type">
								<text>{{ item.enumname || '--' }}</text>
								<text>{{ item.deadlineStatus || '--' }}</text>
							</view>
						</view>
						<view class="trapezoidal" v-if="item.deadlineType == 1">
							超期
						</view>
						<view class="trapezoidal lin" v-if="item.deadlineType == 2">
							临期
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="Width100 Box BorderBox">
			<view class="index-title">
				待办任务
			</view>
			<view class="Content MarginAuto BorderBox">
				<no-data v-if="isEmpty" />
				<view v-else class="List Width100 BorderBox">
					<view class="Unit FontBold BorderBox Width100 MarginT_30rpx BG_FFFFFF" v-for="item in list"
						:key='item.id' @click='handleClick(item)'>
						<!-- <image class="imgleft" :src="item.imgurl || '/static/logo.png'" mode="widthFix"></image> -->
						<view class="right">
							<view class="title">{{ item.name }}</view>
							<view class="type">
								<text>{{ item.enumname || '--' }}</text>
								<text>{{ item.deadlineStatus || '--' }}</text>
							</view>
						</view>
						<template v-if="listStatus !== '60'">
							<view class="trapezoidal" v-if="item.deadlineType == 1">
								超期
							</view>
							<view class="trapezoidal lin" v-if="item.deadlineType == 2">
								临期
							</view>
						</template>
					</view>
				</view>
				<u-loadmore :status="loadmorestatus" v-show="!isEmpty" />
			</view>
		</view>
		<Tabbar name="首页" v-if="tabbarShow"></Tabbar>
	</view>
</template>

<script>
	import tabFun from '@/libs/function/tabbar.js'
	import NoData from "../../components/no-data.vue";
	import Tabbar from "../../components/tabbar.vue";
	import indexPers from './index-pers.vue';
	export default {
		// 组件
		components: {
			NoData,
			Tabbar,
			indexPers
		},
		data() {
			return {
				$: this.$,
				// 公用的js
				bgUrl1: '', // 登录信息背景图
				list: [],
				curPcList: [],
				isEmpty: false,
				isMore: true,
				page: 1,
				loadmorestatus: 'loading',
				tabbarShow: true
			}
		},
		// 页面加载
		onLoad(e) {
			// this.getData()
			// this.getList()
		},
		onShow(e) {
			uni.hideTabBar() //隐藏官方的tabBar
			this.isMore = true
			this.list = []
			this.page = 1
			this.getList()
			this.getCurPcList()
			// tabFun.tabbar()
			// this.tabbarShow = false
			// this.$nextTick(() => {
			// 	this.tabbarShow = true
			// })
		},
		// 计算属性
		computed: {
			listStatus() {
				const myRoles = this.$.getData('userInfo').role || []
				if (myRoles.includes('领导')) {
					return '60'
				}
				if (myRoles.includes('排查人员') && myRoles.includes('治理人员')) {
					return "10"
				}
				if (myRoles.includes('治理人员')) {
					return "20"
				}
				if (myRoles.includes('排查人员')) {
					return "10"
				}
				return "10"
			}
		},
		// 方法
		methods: {
			getCurPcList() {

			},
			getList() {
				let datas = {
					nuserid: this.$.getData('token'),
					status: this.listStatus
				}
				this.loadmorestatus = 'loading'
				this.$request.globalRequest(
						`/hiddenDanger/highDanger/getHigDangerDealt?pageNum=${this.page}&pageSize=${10}&approve=${'1'}`,
						datas, 'POST')
					.then(res => {
						this.loadmorestatus = 'loadmore'
						if (res.code === 200) {
							if (res.result.total === 0) {
								this.isEmpty = true;
								return false
							}
							this.list.push(...res.result.list)
							if (this.list.length >= res.result.total) {
								this.isMore = false
								this.loadmorestatus = 'nomore'
							}
						} else {
							this.$.toast(res.message)
						}
					}).catch((err) => {
						this.loadmorestatus = 'nomore'
					})
			},
			handleClick(row) {
				if (this.listStatus === '60') {
					this.$.open("/pages/investigation/complete" + "?id=" + row.businessId + '&sectionId=' + row
						.sectionCode +
						'&operator=' + row.operator + '&deptId=' + row.handleDept + '&taskName=' + row.name +
						'&pcType' + row.pcType + '&sectionName=' + row.sectionName + '&sectionCode=' + row
						.sectionCode + '&sectionType=' + (row.ifCross || '1') + '&pageName=' + '审批' +
						'&approveStatus=' +
						row.status + '&isSP=1');
				}
				if (this.listStatus === '20') {
					this.$.open(`/pages/governance/governance-form?id=${row.businessId}`)
				}
				if (this.listStatus === '10') {
					if (row.pcType == 2) {
						this.$.open("/pages/investigation/task" + "?id=" + row.businessId + '&sectionId=' + row
							.sectionCode +
							'&operator=' + row.operator + '&deptId=' + row.handleDept + '&taskName=' + row.name +
							'&pcType' + row.pcType + '&sectionName=' + row.sectionName + '&sectionCode=' + row
							.sectionCode + '&sectionType=' + (row.ifCross || '1'));
					} else {
						this.$.open('/pages/map/index?businessId=' + row.businessId + '&sectionId=' + row.sectionCode +
							'&operator=' + row.operator + '&deptId=' + row.handleDept + '&taskName=' + row.name +
							'&pcType' + row.pcType + '&sectionName=' + row.sectionName + '&sectionCode=' + row
							.sectionCode + '&enumname=' + row.enumname + '&deadlineStatus=' + row.deadlineStatus +
							'&sectionType=' + (row.ifCross || '1') +
							'&deadlineType=' + row.deadlineType)
					}
				}
			},
		},
		onReady() {
			// this.$tabFun.tabbar()
		},
		mounted() {

		},
		// 页面卸载
		onUnload() {

		},
		// 页面上拉触底事件的处理函数
		onReachBottom() {
			if (this.isMore) {
				this.page++
				this.getList()
			}
		}
	}
</script>

<style>
</style>
<style lang="scss" scoped>
	page {
		background: #F0F2F7;
	}

	.index-title {
		background: linear-gradient(180deg, #FFFFFF 0%, rgba(255, 255, 255, 0) 100%);
		border-radius: 24rpx 24rpx 0px 0px;
		padding: 0 20px;
		height: 44px;
		line-height: 44px;
		font-weight: bold;
		font-size: 18px;
		font-family: Source Han Sans CN, Source Han Sans CN;
	}

	.header {
		background: url("../../static/home_bg.png") no-repeat;
		background-size: cover;
		height: 500rpx;
		color: #FFFFFF;
		padding: calc(var(--status-bar-height) + 40rpx) 20rpx 20rpx;

		.title {
			font-family: 'Tensentype-MeiHeiJ-Bold';
			// font-weight: bold;
			font-size: 24px;
			line-height: 28px;
			letter-spacing: 2px;
			text-shadow: 0px 4px 0px rgba(255, 255, 255, 0.16);
			text-align: left;
			font-style: normal;
			text-transform: none;
		}

		.desc {
			font-family: 'SOURCEHANSANSCN-REGULAR';
			margin-top: 20rpx;
			// font-family: Source Han Sans CN, Source Han Sans CN;
		}

		.total {
			margin-top: 40rpx;

			.number {
				font-size: 20px;
				font-weight: bold;
				color: #363F4D;
			}

			.name {
				font-size: 16px;
				color: #363F4D;
				font-weight: bold;
			}

			.left {
				width: 40%;
				height: 100%;
				padding: 20rpx 20rpx 70rpx;
				border-radius: 10rpx;
				background: linear-gradient(180deg, #F0D9B4 0%, #F6F6F6 100%);
				overflow: hidden;

				.info {
					padding-left: 20rpx;
					padding-top: 20rpx;
					flex: 1;

					.number {
						font-size: 20px;
					}

					.name {
						font-size: 18px;
					}
				}

				.bottom {
					bottom: 0;
					border-radius: 0 0 10rpx 10px;
					width: calc(36% + 40rpx);
					left: 0;
					font-size: 16px;
					text-align: center;
					height: 80rpx;
					line-height: 80rpx;
					color: #363F4D;
				}
			}

			.right {
				flex: 1;
				padding: 0 20rpx;
				margin-left: 20rpx;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;

				.current_mouth {
					margin-bottom: 20rpx;
				}

				.current_mouth,
				.finish {
					flex: 1;
					border-radius: 10rpx;
					padding: 20rpx;
					width: 100%;
				}
			}

		}
	}

	.img {
		width: 40rpx;
		height: 40rpx;
		margin-left: 30rpx;
	}

	.trapezoidal {
		position: relative;
		display: inline-block;
		min-width: 2em;
		text-align: center;
		padding: 3rpx 20rpx 3rpx 18rpx;
	}

	.trapezoidal::before,
	.trapezoidal::after {
		content: '';
		position: absolute;
		top: 0;
		left: 0%;
		width: 100%;
		height: 100%;
		border-radius: 0rpx 0 0 0;
		background: #FF1111;
		z-index: -1;
		transform-origin: bottom;
		transform: skew(18deg);
		border: 0rpx solid #333;
		box-sizing: border-box;
	}

	.trapezoidal::after {
		left: auto;
		right: 0;
		transform: skew(-0deg);
		border-radius: 0 0rpx 0 0;
		background-color: #FF1111;
		border-left: 0 none;
	}

	.lin::before,
	.lin::after {
		background-color: #E68A0B;
	}

	.list_title {
		font-size: 20px;
		// background: linear-gradient(180deg, #FFFFFF 0%, rgba(255, 255, 255, 0) 100%);
		background: #f8fafb;
		// border-radius: 24px 24px 0px 0px;
		padding: 20rpx 30rpx;
		font-family: Source Han Sans CN, Source Han Sans CN;
		// position: fixed;
		/* top: 418px; */
		top: calc(var(--status-bar-height) + 792rpx);
		z-index: 99;
		width: 100%;
		// padding-bottom: 30rpx;
	}

	.Box {
		.Content {
			width: calc(100% - 48rpx);
			padding-bottom: 100rpx;
		}

		.Unit {
			padding: 24rpx 12rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			position: relative;
			box-shadow: 1px 1px 3px #ccc;
			margin-top: 0;
			margin-bottom: 30rpx;

			.trapezoidal {
				position: absolute;
				top: 0px;
				right: 0px;
				color: #ffffff;
				font-size: 22rpx;
				font-weight: normal;
				z-index: 1;
			}

			image {
				width: 200rpx;
			}

			.right {
				flex: 1;
				padding-left: 30rpx;

				.title {
					font-size: 16px;
				}

				.type {
					font-size: 14px;
					color: #666;
					font-weight: normal;

					text {
						margin-right: 20rpx;
					}
				}
			}
		}
	}
</style>