 <template>
 	<view class="page">
 		<u-navbar title="工作台" placeholder bgColor="#00337A" @leftClick="leftClick" leftIconColor="#fff"
 			:titleStyle="{ color: '#FFF', fontSize: '32rpx' }">
 			<view class="u-nav-slot" slot="left">
 				<u-icon name="grid" size="24" color="#FFF" v-if="type.indexOf('4')>-1"></u-icon>
 			</view>
 		</u-navbar>
 		<view style="width: 100%;height: 84vh;">
 			<scroll-view scroll-y="true">
 				<view class="view-box">
 					<view class="view-item" v-for="(item,index) in menuList" :key="index" @click="goModule(item.name)">
 						<view>
 							<image class="img1" :src="`/static/realName/${item.css}.png`"
 								style="width: 70rpx;height: 70rpx;" alt="">
 						</view>
 						<view style="font-size: 26rpx;">{{item.name}}</view>
 					</view>

 					<view class="view-item" @click="goOutPerson">
 						<view>
 							<image class="img1" src="@/static/realName/out_person.png"
 								style="width: 80rpx;height: 80rpx;" alt="">
 						</view>
 						<view style="font-size: 28rpx;">人员暂退</view>
 					</view>

 				</view>
 			</scroll-view>
 		</view>


 		<!-- 弹窗 -->
 		<u-popup :show="showPopup" mode="center" @close="closePopup">
 			<view style="width:500rpx;height: auto%;position: relative;background-color: #fff;">
 				<view
 					style="width: 100%;height: 70rpx;margin: 0 auto;display: flex;justify-content: space-between;align-items: center;background-color: #fff;">
 					<view style="width: 50%;height: 70rpx;line-height: 70rpx;font-weight: bold;margin-left: 40rpx;">
 						选择工程</view>
 					<u-icon style="width: 10%;" name="close" color="#000" size="24" @click="closePopup"></u-icon>
 				</view>
 				<scroll-view style="width: 100%;height: 50vh;background-color: #fff;" scroll-y="true">
 					<view v-for="(item,index) in proList" :key="index" style="padding: 20rpx;" v-if="item.isActive==1"
 						@click="chosenPro(item)">{{item.abbreviation}}</view>
 				</scroll-view>
 			</view>
 		</u-popup>

 		<!-- 弹窗 -->
 		<u-popup :show="showAccessPopup" mode="center" @close="closeAccessPopup">
 			<view style="width:600rpx;height: auto%;position: relative;background-color: #fff;">
 				<view
 					style="width: 100%;height: 70rpx;margin: 0 auto;display: flex;justify-content: space-between;align-items: center;background-color: #fff;">
 					<view style="width: 10%;height: 70rpx;"></view>
 					<view
 						style="width: 50%;height: 70rpx;line-height: 70rpx;font-weight: bold;margin-left: 40rpx;text-align: center;font-size: 30rpx;">
 						个人信息查询</view>
 					<u-icon style="width: 10%;" name="close" color="#000" size="22" @click="closeAccessPopup"></u-icon>
 				</view>
 				<scroll-view style="width: 100%;height: 32vh;background-color: #fff;" scroll-y="true">
 					<view class="card-item" v-if="accessData.isFace==1">
 						<view class="label">人脸照片</view>
 						<view class="btn">已采集</view>
 					</view>
 					<view class="card-item-red" v-else>
 						<view class="label">人脸照片</view>
 						<view class="btn">未采集</view>
 					</view>

 					<view class="card-item" v-if="accessData.isSign==1">
 						<view class="label">电子签名</view>
 						<view class="btn">已采集</view>
 					</view>
 					<view class="card-item-red" v-else>
 						<view class="label">电子签名</view>
 						<view class="btn">未采集</view>
 					</view>

 					<view class="card-item" v-if="accessData.isContract==1">
 						<view class="label">合同见证/电子合同</view>
 						<view class="btn">已上传</view>
 					</view>
 					<view class="card-item-red" v-else>
 						<view class="label">合同见证/电子合同</view>
 						<view class="btn">未上传</view>
 					</view>

 					<view class="card-item" v-if="accessData.isWages==1">
 						<view class="label">工资卡见证</view>
 						<view class="btn">已上传</view>
 					</view>
 					<view class="card-item-red" v-else>
 						<view class="label">工资卡见证</view>
 						<view class="btn">未上传</view>
 					</view>

 					<view class="card-item" v-if="accessData.isWorkScene==1">
 						<view class="label">班组作业点</view>
 						<view class="btn">已配置</view>
 					</view>
 					<view class="card-item-red" v-else>
 						<view class="label">班组作业点</view>
 						<view class="btn">未配置</view>
 					</view>

 				</scroll-view>
 			</view>
 		</u-popup>




 		<m-tabbar fixed fill :current="1" :tabbar="tabbar"></m-tabbar>
 	</view>
 </template>

 <script>
 	import TabbarConfig from '../util/tabbar.js'
 	import config from '@/config'

 	export default {
 		data() {
 			return {
 				tabbar: TabbarConfig,
 				type: uni.getStorageSync('realNameUser').type,
 				subId: uni.getStorageSync('realNameUser').subId,
 				idNumber: uni.getStorageSync('realNameUser').idNumber,
 				teamId: uni.getStorageSync('realNameUser').teamId,
 				showPopup: false,
 				showAccessPopup: false,
 				accessData: {},
 				proList: [],
 				menuList: [],
 				permissionList: uni.getStorageSync('realNamePermissions')
 				// userName: uni.getStorageSync('userName'),
 				// className: uni.getStorageSync('className'),
 				// facePath: config.fileUrl + uni.getStorageSync('facePath'),
 				// token: uni.getStorageSync('access_token')
 			}
 		},
 		onLoad() {
 			this.getPermission()
 			if (this.type.indexOf("4") > -1) { //监督端
 				this.getPro()
 			}
 		},
 		onShow() {
 			if (this.type.indexOf("4") > -1) { //监督端
 				let hasChosenPro = uni.getStorageSync('hasChosenPro')
 				if (!hasChosenPro) {
 					this.showPopup = true
 				}
 			}
 			if (this.type.indexOf("3") > -1) { //施工端
 				let hasViewAccess = uni.getStorageSync('hasViewAccess')
 				if (!hasViewAccess) {
 					this.getAccessData()
 					this.showAccessPopup = true
 				}
 			}
 		},
 		methods: {
 			getPermission() {
 				this.permissionList.forEach((item, index) => {
 					// console.log(item)
 					if (item.type == 3) {
 						this.menuList.push(item)
 					}
 				})
 				console.log(this.menuList)
 			},
 			goModule(name) {
 				if (name == '合同见证') {
 					uni.navigateTo({
 						url: `/pages/realName/workbench/contractWitness/index`
 					})
 				} else if (name == '电子合同') {
 					uni.navigateTo({
 						url: `/pages/realName/workbench/electronicContract/contractTip`
 					})
 				} else if (name == '电子合同签署') {
 					uni.navigateTo({ //电子合同签署
 						url: `/pages/realName/workbench/electronicContractSign/index`
 					})
 				} else if (name == '电子合同审核') {
 					uni.navigateTo({
 						url: `/pages/realName/workbench/electronicContractExam/index`
 					})
 				} else if (name == '人员库') {
 					uni.navigateTo({
 						url: `/pages/realName/workbench/peopleLibrary/index`
 					})
 				} else if (name == '欠薪维权申诉') {
 					uni.navigateTo({ //欠薪维权申诉
 						url: `/pages/realName/workbench/safeguarding/index`
 					})
 				} else if (name == '工资卡见证') {
 					uni.navigateTo({
 						url: `/pages/realName/workbench/wageWitness/index`
 					})
 				} else if (name == '工资查看') {
 					uni.navigateTo({
 						url: `/pages/realName/workbench/wageRecord/index`
 					})
 				} else if (name == '出场申请') {
 					uni.navigateTo({
 						url: `/pages/realName/workbench/appearApply/index`
 					})
 				} else if (name == '出场审核') {
 					uni.navigateTo({
 						url: `/pages/realName/workbench/appearExam/index`
 					})
 				} else if (name == '人员转场') {
 					uni.navigateTo({
 						url: `/pages/realName/workbench/cutToPlace/index`
 					})
 				} else if (name == '我的组织') {
 					uni.navigateTo({ //我的组织
 						url: `/pages/realName/workbench/myOrg/index`
 					})
 				} else if (name == '作业计划管理') {
 					uni.navigateTo({ //作业计划管理 日计划管理
 						url: `/pages/realName/workbench/dailyPlanManagement/index`
 					})
 				} else if (name == '人员信息录入') {
 					uni.navigateTo({ //人员信息录入
 						url: `/pages/realName/workbench/personEnter/index`
 					})
 				}

 			},

 			goOutPerson() {
 				uni.navigateTo({ //人员暂退
 					url: `/pages/realName/workbench/outPerson/index`
 				})
 			},
 			//监督端
 			//作业计划与实名制监控情况
 			goPlan() {
 				uni.navigateTo({ //作业计划
 					url: `/pages/realName/workbench/workPlan/index`
 				})
 			},
 			//人员资质库更新
 			goUpdateFace() {
 				uni.showToast({
 					title: "人员资质库更新中...",
 					icon: 'none',
 					duration: 2000
 				})
 			},
 			//人员资质检查
 			goQualifications() {
 				uni.navigateTo({ //人员资质检查
 					url: `/pages/realName/workbench/qualifications/index`
 				})
 			},

 			goMyOrg() {
 				uni.navigateTo({ //人员资质检查
 					url: `/pages/realName/workbench/myOrg/index`
 				})
 			},

 			// 施工端
 			goDayPlan() { //准入信息查询
 				uni.navigateTo({
 					url: `/pages/realName/workbench/dayPlan/index`
 				})
 			},
 			goExam() { //安全教育培训
 				uni.navigateTo({
 					url: `/pages/realName/workbench/exam/index`
 				})
 			},
 			// 施工端-个人信息
 			getAccessData() {
 				let param = {
 					idNumber: this.idNumber,
 					teamId: this.teamId
 				}
 				// console.log(param)
 				uni.request({
 					url: config.realAppUrl + '/BasePerson/selectPersonAccess',
 					method: 'post',
 					data: param,
 					header: {
 						'Content-Type': 'application/json',
 						Authorization: uni.getStorageSync('realNameToken')
 					},
 					success: res => {
 						// console.log(res)
 						res = res.data;
 						if (res.code == 200) {
 							this.accessData = res.data;
 						}
 					},
 					fail: err => {
 						console.log(err)
 					}
 				})
 			},

 			//监督端获取工程列表
 			getPro() {
 				let param = {
 					id: -1,
 					subId: this.subId
 				}
 				console.log(param)
 				uni.request({
 					url: config.realAppUrl + '/offLine/getPro',
 					method: 'post',
 					data: param,
 					header: {
 						'Content-Type': 'application/x-www-form-urlencoded',
 						Authorization: uni.getStorageSync('realNameToken')
 					},
 					success: res => {
 						console.log(res)
 						res = res.data;
 						if (res.code == 200) {
 							this.proList = res.data;
 						}
 					},
 					fail: err => {
 						console.log(err)
 					}
 				})
 			},
 			//展示工程选择弹窗
 			leftClick() {
 				if (this.type.indexOf("4") > -1) {
 					this.showPopup = true;
 				}
 			},
 			//选择工程
 			chosenPro(item) {
 				let obj = uni.getStorageSync('realNameUser')
 				obj.proId = item.id
 				uni.setStorageSync('realNameUser', obj)
 				uni.setStorageSync('hasChosenPro', "1")
 				this.showPopup = false;
 			},
 			closePopup() {
 				this.showPopup = false;
 			},
 			closeAccessPopup() {
 				uni.setStorageSync('hasViewAccess', "1")
 				this.showAccessPopup = false;
 			},
 		}
 	}
 </script>

 <style lang="scss">
 	.page {
 		width: 100%;
 		height: 100vh;

 		// box-sizing: border-box;
 		// padding: 15vh 8vw;
 		.view-box {
 			width: 100%;
 			height: auto;
 			display: flex;
 			flex-wrap: wrap;
 			flex-direction: row;
 			margin-bottom: 100rpx;
 		}

 		.view-item {
 			width: 33%;
 			height: 200rpx;
 			display: flex;
 			flex-direction: column;
 			align-items: center;
 			justify-content: center;
 		}

 		// .view-item{
 		// 	width: 94%;
 		// 	margin: 0rpx auto;
 		// 	padding:20rpx;
 		// 	// display: flex;
 		// 	border-bottom: 1rpx solid #EFEFEF;
 		// 	font-size: 26rpx;
 		// 	.label{
 		// 		width: 300rpx;
 		// 		color: #666;
 		// 		margin-bottom: 20rpx;
 		// 	}
 		// }
 		.card-item {
 			width: 90%;
 			margin: 20rpx auto;
 			padding: 16rpx;
 			display: flex;
 			justify-content: space-between;
 			align-items: center;
 			font-size: 26rpx;
 			background: #E2F0CD;
 			border-radius: 10rpx;

 			.label {
 				width: 300rpx;
 				color: #74B01A;
 				font-weight: 600;
 				// margin-bottom: 20rpx;
 			}

 			.btn {
 				width: 140rpx;
 				height: 40rpx;
 				line-height: 40rpx;
 				color: #FFF;
 				background: #6FB504;
 				text-align: center;
 				border-radius: 10rpx;
 			}
 		}

 		.card-item-red {
 			width: 90%;
 			margin: 20rpx auto;
 			padding: 16rpx;
 			display: flex;
 			justify-content: space-between;
 			align-items: center;
 			font-size: 26rpx;
 			background: #FFEBEC;
 			border-radius: 10rpx;

 			.label {
 				width: 300rpx;
 				color: #DA3E26;
 				font-weight: 600;
 				// margin-bottom: 20rpx;
 			}

 			.btn {
 				width: 140rpx;
 				height: 40rpx;
 				line-height: 40rpx;
 				color: #FFF;
 				background: #FF2F2F;
 				text-align: center;
 				border-radius: 10rpx;
 			}
 		}
 	}
 </style>