<template>
  <view class="page">
    <u-navbar class="u-navbar" :title="pageTitle" placeholder @leftClick="leftClick" leftIconColor="#fff"  bgColor="#00337A"  :titleStyle="{ color: '#FFF', fontSize: '32rpx' }"/>
	<scroll-view class="scroll-view" scroll-x="true">
		<view class="scroll-view-item" :class="hIndex == 1 ? 'active' : ''" @click="hIndex = 1">
			身份证
			<view class="activeLine" v-if="hIndex == 1"></view>
		</view>
		<view class="scroll-view-item" :class="hIndex == 2 ? 'active' : ''" @click="hIndex = 2">
			关键信息
			<view class="activeLine" v-if="hIndex == 2"></view>
		</view>
		<view class="scroll-view-item" :class="hIndex == 3 ? 'active' : ''" @click="hIndex = 3">
			安全培训
			<view class="activeLine" v-if="hIndex == 3"></view>
		</view>
		<view class="scroll-view-item" :class="hIndex == 4 ? 'active' : ''" @click="hIndex = 4" v-if="indexMax==7">
			分包班组
			<view class="activeLine" v-if="hIndex == 4"></view>
		</view>
		<view class="scroll-view-item" :class="hIndex == 5 ? 'active' : ''" @click="hIndex = 5" v-if="indexMax==7">
			合同
			<view class="activeLine" v-if="hIndex == 5"></view>
		</view>
		<view class="scroll-view-item" :class="hIndex == 6 ? 'active' : ''" @click="hIndex = 6" v-if="indexMax==7">
			工资卡
			<view class="activeLine" v-if="hIndex == 6"></view>
		</view>
		<view class="scroll-view-item" :class="hIndex == indexMax ? 'active' : ''" @click="hIndex = indexMax">
			其他
			<view class="activeLine" v-if="hIndex == indexMax"></view>
		</view>
		 
	</scroll-view>
	 <scroll-view class="content" scroll-y="true">
		 
		<view v-show="hIndex == 1">
			<u--form class="addForm" :model="entryIdNumberBean" ref="vForm">
				<view style="width: 100%;height: 80rpx;display: flex;justify-content: space-between;align-items: center;">
					<view style="margin-left: 20rpx;">身份证人像面信息</view>
					<view style="margin-right: 20rpx;color: #00337A;padding: 20rpx;border: 1rpx solid #00337A;border-radius: 20rpx;"  @click="distinguishFornt">身份证识别</view>
				</view>
				<view class="form-input-box">
					<view style="width:20%;height: 100%;">
						<text>姓名</text>
					</view>
					<u-form-item prop='name' style="width:75%;height: 100%;" >
						<u--input v-model="entryIdNumberBean.name" type="text" placeholder="请输入" maxlength="20"  border="surround" clearable></u--input>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:20%;height: 100%;">
						<text>身份证号</text>
					</view>
					<u-form-item prop='idNumber' style="width:75%;height: 100%;" >
						<u--input v-model="entryIdNumberBean.idNumber" type="text" placeholder="请输入" maxlength="18"  border="surround" clearable @input="getBorth"></u--input>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:20%;height: 100%;">
						<text>性别</text>
					</view>
					<u-form-item prop='sex' style="width:75%;height: 100%;" >
						<u--input
							v-model="entryIdNumberBean.sex" readonly type="text" placeholder="自动计算带入" maxlength="15"  border="surround" clearable></u--input>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:20%;height: 100%;">
						<text>出生日期</text>
					</view>
					<u-form-item prop='birthday' style="width:75%;height: 100%;" >
						<u--input v-model="entryIdNumberBean.birthday" readonly type="text" placeholder="自动计算带入" maxlength="20"  border="surround" clearable></u--input>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:20%;height: 100%;">
						<text>民族</text>
					</view>
					<u-form-item prop='ethnic' style="width:75%;height: 100%;" >
						<u--input v-model="entryIdNumberBean.ethnic" type="text" placeholder="请输入" maxlength="15"  border="surround" clearable></u--input>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:20%;height: 100%;">
						<text>住址</text>
					</view>
					<u-form-item prop='address' style="width:75%;height: 100%;" >
						<u--input v-model="entryIdNumberBean.address" type="text" placeholder="请输入" maxlength="40"  border="surround" clearable></u--input>
					</u-form-item>
				</view>
				<view style="width: 100%;height: 80rpx;display: flex;justify-content: space-between;align-items: center;">
					<view style="margin-left: 20rpx;">身份证国徽面信息</view>
					<view style="margin-right: 20rpx;color: #00337A;padding: 20rpx;border: 1rpx solid #00337A;border-radius: 20rpx;"  @click="distinguishBack">身份证识别</view>
				</view>
				<view class="form-input-box">
					<view style="width:20%;height: 100%;">
						<text>生效日期</text>
					</view>
					<u-form-item prop='signDate' style="width:75%;height: 100%;" >
						<uni-datetime-picker type="date" :clear-icon="false" format="yyyy-MM-dd" v-model="entryIdNumberBean.signDate"/>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:20%;height: 100%;">
						<text>失效日期</text>
					</view>
					<u-form-item prop='expiryDate' style="width:75%;height: 100%;" >
						<uni-datetime-picker type="date" :clear-icon="false" format="yyyy-MM-dd" v-model="entryIdNumberBean.expiryDate"/>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:20%;height: 100%;">
						<text>签发机关</text>
					</view>
					<u-form-item prop='issuance' style="width:75%;height: 100%;" >
						<u--input v-model="entryIdNumberBean.issuance" type="text" placeholder="请输入" maxlength="40"  border="surround" clearable></u--input>
					</u-form-item>
				</view>
				
				<view class="submit-box">
					<u-button type="primary" shape="surround" @click="next"
					style="background:#5193FE"
					>下一步</u-button>
				</view>
			</u--form>
		</view>
		
		<view v-show="hIndex == 2">
			<view class="tip-view">
				<text style="font-size: 24rpx;color: red;">此页面全部为必填项</text>
			</view>
			<u--form class="addForm" :model="entryCruxBean" ref="iForm">
				<view class="form-input-box">
					<view style="width:20%;height: 100%;">
						<text>入场工程</text>
					</view>
					<u-form-item prop='proId' style="width:75%;height: 100%;" >
						<uni-data-select v-model="entryCruxBean.proId" :localdata="proList" @change="changePro"></uni-data-select>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:20%;height: 100%;">
						<text>工种</text>
					</view>
					<u-form-item prop='postId' style="width:75%;height: 100%;" >
						<uni-data-select v-model="entryCruxBean.postId" :localdata="postList" @change="changePost"></uni-data-select>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:20%;height: 100%;">
						<text>手机号码</text>
					</view>
					<u-form-item prop='phone' style="width:75%;height: 100%;" >
						<u--input v-model="entryCruxBean.phone" type="number" placeholder="请输入" maxlength="11"  border="surround" clearable></u--input>
					</u-form-item>
				</view>
				<view class="tip-view">
					<text style="font-size: 24rpx;color: red;">特征信息采集</text>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;margin-top: 20rpx;">
						<text>人脸照片采集</text>
					</view>
					<view class="img-box">
						<view class="img-item" v-if="faceImgUrl!=''">
							<image class="img" :src="faceImgUrl" mode=""></image>
						</view>
						<view style="margin-left: 40rpx;" class="signBtn" @click="openPhotograph">人脸照片采集</view>
					</view>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;margin-top: 20rpx;">
						<view>电子签名采集</view>
					</view>
					<view class="img-box">
						<view class="img-item" v-if="signImgUrl!=''">
							<image class="img" :src="signImgUrl" mode=""></image>
						</view>
						<view style="margin-left: 40rpx;" class="signBtn" @click="openSignView">采集电子签名</view>
					</view>
				</view>
				<view style="display: flex;flex-direction: column;padding: 20rpx;">
					<text style="font-size: 24rpx;color: red;">提醒事项：</text>
					<text style="font-size: 24rpx;color: red;">
						1.入场工程后，即为入场即可考勤打卡；
					</text>
					<text style="font-size: 24rpx;color: red;">
						2.手机号会自动创建施工人员级别APP账号，默认密码：YNsbd@123456)
					</text>
					<text style="font-size: 24rpx;color: red;">
						3.人脸照片采集用于考勤打卡（APP打卡，考勤机打卡）
					</text>
					<text style="font-size: 24rpx;color: red;">
						4.电子签名用于电子合同签订使用。
					</text>
				</view>
				<view class="submit-box">
					<u-button type="primary" shape="surround" @click="up" class="submit-btn"
					style="background:#ccc;border:0;" 
					>上一步</u-button>
					<u-button type="primary" shape="surround" @click="next" class="submit-btn"
					style="background:#5193FE"
					>下一步</u-button>
				</view>
			</u--form>
		</view>
		
		<view v-show="hIndex == 3">
			<view class="tip-view">
				<text style="font-size: 24rpx;color: #5193FE;">培训结果</text>
				<text style="font-size: 24rpx;color: red;">非必填</text>
			</view>
			<u--form class="addForm" :model="entryTrainBean" ref="tForm">
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>安规培训</text>
					</view>
					<u-form-item prop='safetyTraining' style="width:70%;height: 100%;" >
						<u-radio-group v-model="entryTrainBean.safetyTraining" placement="row" style="border: 1rpx solid #ccc;padding: 20rpx;border-radius: 10rpx;">
							<u-radio label="未完成" name="0" style="margin-right: 40rpx;"></u-radio>
							<u-radio label="完成" name="1"></u-radio>
						</u-radio-group>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>保命教育实操</text>
					</view>
					<u-form-item prop='practical' style="width:70%;height: 100%;" >
						<u-radio-group v-model="entryTrainBean.practical" placement="row" style="border: 1rpx solid #ccc;padding: 20rpx;border-radius: 10rpx;">
							<u-radio label="未完成" name="0" style="margin-right: 40rpx;"></u-radio>
							<u-radio label="完成" name="1"></u-radio>
						</u-radio-group>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>保命教育理论</text>
					</view>
					<u-form-item prop='theory' style="width:70%;height: 100%;" >
						<u-radio-group v-model="entryTrainBean.theory" placement="row" style="border: 1rpx solid #ccc;padding: 20rpx;border-radius: 10rpx;">
							<u-radio label="未完成" name="0" style="margin-right: 40rpx;"></u-radio>
							<u-radio label="完成" name="1"></u-radio>
						</u-radio-group>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>准军事化培训</text>
					</view>
					<u-form-item prop='militarize' style="width:70%;height: 100%;" >
						<u-radio-group v-model="entryTrainBean.militarize" placement="row" style="border: 1rpx solid #ccc;padding: 20rpx;border-radius: 10rpx;">
							<u-radio label="未完成" name="0" style="margin-right: 40rpx;"></u-radio>
							<u-radio label="完成" name="1"></u-radio>
						</u-radio-group>
					</u-form-item>
				</view>
				<view class="tip-view">
					<text style="font-size: 24rpx;color: #5193FE;">培训成绩结果</text>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>安规培训</text>
					</view>
					<u-form-item prop='safetyScore' style="width:70%;height: 100%;" >
						<u--input v-model="entryTrainBean.safetyScore" type="number" placeholder="90分以上及格" maxlength="3"  border="surround" clearable @input="matchScore1"></u--input>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>保命教育实操</text>
					</view>
					<u-form-item prop='practicalScore' style="width:70%;height: 100%;" >
						<u--input v-model="entryTrainBean.practicalScore" type="number" placeholder="80分以上及格" maxlength="3"  border="surround" clearable @input="matchScore2"></u--input>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>保命教育理论</text>
					</view>
					<u-form-item prop='theoryScore' style="width:70%;height: 100%;" >
						<u--input v-model="entryTrainBean.theoryScore" type="number" placeholder="80分以上及格" maxlength="3"  border="surround" clearable @input="matchScore3"></u--input>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>准军事化培训</text>
					</view>
					<u-form-item prop='militarizeScore' style="width:70%;height: 100%;" >
						<u--input v-model="entryTrainBean.militarizeScore" type="number" placeholder="80分以上及格" maxlength="3"  border="surround" clearable @input="matchScore4"></u--input>
					</u-form-item>
				</view>
				<view style="display: flex;flex-direction: column;padding: 20rpx;">
					<text style="font-size: 24rpx;color: red;">提醒事项：</text>
					<text style="font-size: 24rpx;color: red;">
						1.未完成安全培训考试为【红灯】人员；
					</text>
					<text style="font-size: 24rpx;color: red;">
						2.工资册生成时需要处理红灯打卡是否有效，（红灯打卡为待生效打卡）
					</text>
					<text style="font-size: 24rpx;color: red;">
						3.红灯人员只可打卡7天，作业计划无法选择红灯人员。
					</text>
				</view>
				<view class="submit-box">
					<u-button type="primary" shape="surround" @click="up" class="submit-btn"
					style="background:#ccc;border:0;" 
					>上一步</u-button>
					<u-button type="primary" shape="surround" @click="next" class="submit-btn"
					style="background:#5193FE"
					>下一步</u-button>
				</view>
			</u--form>
		</view>
		
		<view v-show="hIndex == 4" v-if="indexMax==7">
			<view style="color: #c0c0c0;font-size: 24rpx;margin-left: 20rpx;">
				关键信息已选择工程（只可选择工程下绑定得分包商
			</view>
			<view class="tip-view">
				<view>
					<text style="font-size: 24rpx;color: #000;">{{entryCruxBean.proName}}</text>
				</view>
				<text style="font-size: 24rpx;color: red;">非必填</text>
			</view>
			<u--form class="addForm" :model="entrySubTeamBean" ref="iForm">
				<view class="form-input-box">
					<view style="width:20%;height: 100%;">
						<text>所属分包</text>
					</view>
					<u-form-item prop='subId' style="width:75%;height: 100%;" >
						<uni-data-select v-model="entrySubTeamBean.subId" :localdata="subList" @change="changeSub" ></uni-data-select>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:20%;height: 100%;">
						<text>所属班组</text>
					</view>
					<u-form-item prop='teamId' style="width:75%;height: 100%;" >
						<uni-data-select v-model="entrySubTeamBean.teamId" :localdata="teamList" @change="changeTeam"></uni-data-select>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:20%;height: 100%;">
						<text>是否为班组固定人员</text>
					</view>
					<u-form-item prop='isRegularPerson' style="width:75%;height: 100%;" >
						<u-radio-group v-model="entrySubTeamBean.isRegularPerson" placement="row" style="border: 1rpx solid #ccc;padding: 16rpx;border-radius: 10rpx;">
							<u-radio label="否" name="0" style="margin-right: 40rpx;"></u-radio>
							<u-radio label="是" name="1"></u-radio>
						</u-radio-group>
					</u-form-item>
				</view>
			  
				 
				<view style="display: flex;flex-direction: column;padding: 20rpx;">
					<text style="font-size: 24rpx;color: red;">提醒事项：</text>
					<text style="font-size: 24rpx;color: red;">
						1.未完成分包班组绑定为【黄灯人员】；
					</text>
					<text style="font-size: 24rpx;color: red;">
						2.生成工资册之前必须绑定分包班组信息；
					</text>
					<text style="font-size: 24rpx;color: red;">
						3.班组固定人员不可使用【强制转场】
					</text>
				</view>
				<view class="submit-box">
					<u-button type="primary" shape="surround" @click="up" class="submit-btn"
					style="background:#ccc;border:0;" 
					>上一步</u-button>
					<u-button type="primary" shape="surround" @click="next" class="submit-btn"
					style="background:#5193FE"
					>下一步</u-button>
				</view>
			</u--form>
		</view>
		
		<view v-show="hIndex == 5" v-if="indexMax==7">
			<view class="tip-view">
				<view>
					<text style="font-size: 24rpx;color: #5193FE;">纸质合同见证上传</text>
					<text style="font-size: 24rpx;color: red;">(电子合同在【电子合同】完成及审核)</text>
				</view>
				<text style="font-size: 24rpx;color: red;">非必填</text>
			</view>
			<u--form class="addForm" :model="entryContractBean" ref="cForm">
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>合同类型</text>
					</view>
					<u-form-item prop='contractType' style="width:70%;height: 100%;" >
						<u--input v-model="entryContractBean.contractType" type="text" readonly  border="surround"></u--input>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>合同编号</text>
					</view>
					<u-form-item prop='contractCode' style="width:70%;height: 100%;" >
						<u--input v-model="entryContractBean.contractCode" type="text" placeholder="请输入" maxlength="40"  border="surround" clearable></u--input>
					</u-form-item>
				</view>
				<view style="width: 100%;height: auto;">
					<view style="width:25%;height: 100%;margin: 20rpx;">
						<text>合同期限类型</text>
					</view>
					<u-form-item prop='laborContractType' style="width:96%;height: 100%;margin: 0 auto;" >
						<u-radio-group v-model="entryContractBean.laborContractType" placement="row" style="border: 1rpx solid #ccc;padding:20rpx 10rpx;border-radius: 10rpx;">
							<u-radio label="以完成一定工作为期限的合同" name="以完成一定工作为期限的合同" style="margin-right: 20rpx;transform:scale(0.8);"></u-radio>
							<u-radio label="固定期限合同" name="固定期限合同" style="transform:scale(0.8);"></u-radio>
						</u-radio-group>
					</u-form-item>
				</view>
				
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>合同签订日期</text>
					</view>
					<u-form-item prop='contractValidDate' style="width:70%;height: 100%;" >
						<uni-datetime-picker type="date" :clear-icon="false" format="yyyy-MM-dd" v-model="entryContractBean.contractValidDate"/>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>合同终止日期</text>
					</view>
					<u-form-item prop='contractInvalidDate' style="width:70%;height: 100%;" >
						<uni-datetime-picker type="date" :clear-icon="false" format="yyyy-MM-dd" v-model="entryContractBean.contractInvalidDate"/>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>工资核定方式</text>
					</view>
					<u-form-item prop='wageApprovedWay' style="width:70%;height: 100%;" >
						<u--input v-model="entryContractBean.wageApprovedWay" type="text" readonly  border="surround"></u--input>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>工资核定标准</text>
					</view>
					<u-form-item prop='wageCriterion' style="width:70%;height: 100%;" >
						<u--input v-model="entryContractBean.wageCriterion" type="number" placeholder="请输入" maxlength="3"  border="surround" clearable @input="matchWageCriterion"></u--input>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>人员角色</text>
					</view>
					<u-form-item prop='role' style="width:70%;height: 100%;" >
						<uni-data-select v-model="entryContractBean.role" :localdata="roleList"></uni-data-select>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>是否参加城乡居民医疗保险</text>
					</view>
					<u-form-item prop='miurInsurance' style="width:70%;height: 100%;" >
						<u-radio-group v-model="entryContractBean.miurInsurance" placement="row" style="border: 1rpx solid #ccc;padding: 16rpx;border-radius: 10rpx;">
							<u-radio label="否" name="否" style="margin-right: 40rpx;"></u-radio>
							<u-radio label="是" name="是"></u-radio>
						</u-radio-group>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>是否参加城乡居民养老保险</text>
					</view>
					<u-form-item prop='endowmentInsurance' style="width:70%;height: 100%;" >
						<u-radio-group v-model="entryContractBean.endowmentInsurance" placement="row" style="border: 1rpx solid #ccc;padding: 16rpx;border-radius: 10rpx;">
							<u-radio label="否" name="否" style="margin-right: 40rpx;"></u-radio>
							<u-radio label="是" name="是"></u-radio>
						</u-radio-group>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>是否在职</text>
					</view>
					<u-form-item prop='whetherOnJob' style="width:70%;height: 100%;" >
						<u-radio-group v-model="entryContractBean.whetherOnJob" placement="row" style="border: 1rpx solid #ccc;padding: 16rpx;border-radius: 10rpx;">
							<u-radio label="否" name="否" style="margin-right: 40rpx;"></u-radio>
							<u-radio label="是" name="是"></u-radio>
						</u-radio-group>
					</u-form-item>
				</view>
				
				
				
				<view class="tip-view">
					<text style="font-size: 24rpx;color: #5193FE;">合同见证照片上传</text>
				</view>
				<view class="form-input-box" style="display: block;">
					<view style="width:25%;height: 100%;margin-top: 20rpx;">
						<text>合同上传</text>
					</view>
					<view class="img-box">
						<view class="img-item upload-btn" @click="uploadContractImg()">
							<image class="img" src="@/static/realName/tianjia-img.png" mode=""></image>
						</view>
						<view class="img-item" v-if="contractImgUrl!=''">
							<image class="img" :src="contractImgUrl" mode=""></image>
						</view>
					</view>
				</view>
		 
				<view style="display: flex;flex-direction: column;padding: 20rpx;">
					<text style="font-size: 24rpx;color: red;">提醒事项：</text>
					<text style="font-size: 24rpx;color: red;">
						1.未完成合同上传为【黄灯】人员；
					</text>
					<text style="font-size: 24rpx;color: red;">
						2.工资册生成之前必须上传合同信息，工资册根据合同核定标准生成
					</text>
				</view>
				<view class="submit-box">
					<u-button type="primary" shape="surround" @click="up" class="submit-btn"
					style="background:#ccc;border:0;" 
					>上一步</u-button>
					<u-button type="primary" shape="surround" @click="next" class="submit-btn"
					style="background:#5193FE"
					>下一步</u-button>
				</view>
			</u--form>
		</view>
		
		<view v-show="hIndex == 6" v-if="indexMax==7">
			<view class="tip-view">
				<text style="font-size: 24rpx;color: #5193FE;">工资卡见证</text>
				<text style="font-size: 24rpx;color: red;">非必填</text>
			</view>
			<u--form class="addForm" :model="entryBankBean" ref="cForm">
				<view class="form-input-box" style="display: block;">
					<view style="width:25%;height: 100%;">
						<text>见证照片</text>
					</view>
					<view class="img-box">
						<view class="img-item upload-btn" @click="uploadBankImg()">
							<image class="img" src="@/static/realName/tianjia-img.png" mode=""></image>
						</view>
						<view class="img-item" v-if="bankImgUrl!=''">
							<image class="img" :src="bankImgUrl" mode=""></image>
						</view>
					</view>
				</view>
				 
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>银行名称</text>
					</view>
					<u-form-item prop='bankName' style="width:70%;height: 100%;" >
						<u--input v-model="entryBankBean.bankName" type="text" placeholder="请输入" maxlength="30"  border="surround" clearable></u--input>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>银行卡号</text>
					</view>
					<u-form-item prop='bankCard' style="width:70%;height: 100%;" >
						<u--input v-model="entryBankBean.bankCard" type="number" placeholder="请输入" maxlength="20"  border="surround" clearable></u--input>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>银行支行名称</text>
					</view>
					<u-form-item prop='rollBankName' style="width:70%;height: 100%;" >
						<u--input v-model="entryBankBean.rollBankName" type="text" placeholder="请输入" maxlength="30"  border="surround" clearable></u--input>
					</u-form-item>
				</view>
				<view style="display: flex;flex-direction: column;padding: 20rpx;">
					<text style="font-size: 24rpx;color: red;">提醒事项：</text>
					<text style="font-size: 24rpx;color: red;">
						1.未完成工资卡上传为【黄灯】人员；
					</text>
					<text style="font-size: 24rpx;color: red;">
						2.工资册生成之前必须上传工资卡。
					</text>
				</view>
				<view class="submit-box">
					<u-button type="primary" shape="surround" @click="up" class="submit-btn"
					style="background:#ccc;border:0;" 
					>上一步</u-button>
					<u-button type="primary" shape="surround" @click="next" class="submit-btn"
					style="background:#5193FE"
					>下一步</u-button>
				</view>
			</u--form>
		</view>

		<view v-show="hIndex == indexMax">
			<view class="tip-view">
				<view>
					<text style="font-size: 24rpx;color: #5193FE;">社保信息</text>
					<text style="font-size: 24rpx;color: red;">(分包自有人员)</text>
				</view>
				
				<text style="font-size: 24rpx;color: red;">非必填</text>
			</view>
			<u--form class="addForm" :model="entryOtherBean" ref="oForm">
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>社保证明</text>
					</view>
					<u-form-item prop='socialSecurityPath' style="width:70%;height: 100%;" >
						
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>社保号</text>
					</view>
					<u-form-item prop='socialSecurityNumber' style="width:70%;height: 100%;" >
						<u--input v-model="entryOtherBean.socialSecurityNumber" type="text" placeholder="请输入社保号" maxlength="30"  border="surround" clearable></u--input>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>社保单位</text>
					</view>
					<u-form-item prop='socialSecurityUnit' style="width:70%;height: 100%;" >
						<u--input v-model="entryOtherBean.socialSecurityUnit" type="text" placeholder="请输入社保单位" maxlength="30"  border="surround" clearable></u--input>
					</u-form-item>
				</view>
				<view class="tip-view">
					<text style="font-size: 24rpx;color: #5193FE;">其他信息</text>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>人员类型</text>
					</view>
					<u-form-item prop='personType' style="width:70%;height: 100%;" >
						<u--input v-model="entryOtherBean.personType" type="text" placeholder="请输入人员类型" maxlength="30"  border="surround" clearable></u--input>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>工人技能</text>
					</view>
					<u-form-item prop='workerSkill' style="width:70%;height: 100%;" >
						<u--input v-model="entryOtherBean.workerSkill" type="text" placeholder="请输入工人技能" maxlength="30"  border="surround" clearable></u--input>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>重要人员</text>
					</view>
					<u-form-item prop='importantPerson' style="width:70%;height: 100%;" >
						<u--input v-model="entryOtherBean.importantPerson" type="text" placeholder="请输入重要人员" maxlength="30"  border="surround" clearable></u--input>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>紧急联系人</text>
					</view>
					<u-form-item prop='urgentPerson' style="width:70%;height: 100%;" >
						<u--input v-model="entryOtherBean.urgentPerson" type="text" placeholder="请输入紧急联系人" maxlength="30"  border="surround" clearable></u--input>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:28%;height: 100%;">
						<text>紧急联系人电话</text>
					</view>
					<u-form-item prop='urgentPersonPhone' style="width:67%;height: 100%;" >
						<u--input v-model="entryOtherBean.urgentPersonPhone" type="number" placeholder="请输入紧急联系人电话" maxlength="11"  border="surround" clearable></u--input>
					</u-form-item>
				</view>
			 
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>文化程度</text>
					</view>
					<u-form-item prop='cultrue' style="width:70%;height: 100%;" >
						<u--input v-model="entryOtherBean.cultrue" type="text" placeholder="请输入文化程度" maxlength="30"  border="surround" clearable></u--input>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>政治面貌</text>
					</view>
					<u-form-item prop='politicalOutlook' style="width:70%;height: 100%;" >
						<u--input v-model="entryOtherBean.politicalOutlook" type="text" placeholder="请输入政治面貌" maxlength="30"  border="surround" clearable></u--input>
					</u-form-item>
				</view>
				<view class="form-input-box">
					<view style="width:25%;height: 100%;">
						<text>家庭电话</text>
					</view>
					<u-form-item prop='addressPhone' style="width:70%;height: 100%;" >
						<u--input v-model="entryOtherBean.addressPhone" type="text" placeholder="请输入家庭电话" maxlength="30"  border="surround" clearable></u--input>
					</u-form-item>
				</view>
			 
				<view class="submit-box">
					<u-button type="primary" shape="surround" @click="up" class="submit-btn"
					style="background:#ccc;border:0;" 
					>上一步</u-button>
					<u-button type="primary" shape="surround" @click="next" class="submit-btn"
					style="background:#5193FE"
					>下一步</u-button>
				</view>
			</u--form>
		</view>
		
	</scroll-view>
	<!-- 签名弹窗 -->
	<u-popup :show="signPopup" mode="center" @close="closeSign">
		<view style="width:650rpx;height: 100%;position: relative;background-color: #fff;">
		<!-- 	<view class="popup-header">
				<view style="width: 5%;height: 80rpx;"></view>
				<view style="width: 85%;height: 80rpx;line-height: 80rpx;font-weight: bold;">收样信息修改</view>
				<u-icon style="width: 10%;" name="close" color="#000" size="32" @click="closeSign"></u-icon>
			</view> -->
			<view class="popup-content">
				<SignView v-on:signConfirm="signConfirm" style="width: 100%;height: 100%;" />
			</view>
			<!-- <view class="popup-submit-box">
				<u-button shape="square" class="submit-edit-1" @click="closeSign">取 消</u-button>
				<u-button type="primary" shape="square" class="submit-edit-2" @click="signConfirm">确 认</u-button>
			</view> -->
		</view>
	</u-popup>
	
	
  </view>
</template>

<script>
import { pathToBase64, base64ToPath } from 'image-tools';
import SignView from '../../components/signView.vue';
import config from '@/config'
export default {
  components: { SignView },
  data() {
    return {
		pageTitle:'修改人员',
		idNumber:'',
		sysUser:uni.getStorageSync('realNameUser'),
		hIndex:1,
		indexMax:4,
		errorType: 'message',
		entryIdNumberBean:{
			"name": "",
			"idNumber": "",
			"sex": "",
			"birthday": "",
			"ethnic": "",//民族
			"address": "",//住址
			"signDate": "",//生效日期
			"expiryDate": "",//失效日期
			"issuance": "",//签发机关
			"frontPath": "",//正面身份证照片
			"backPath": "",//反面身份证照片
			"workerType": "0",//用工类型:0-临时1-固有2-分包
			"light": "",//灯
			"userId": uni.getStorageSync('realNameUser').userId,//上传人
			"isOwnPerson": ""//是否自有人员
		},
		entryCruxBean:{
			"proId": "",//工程
			"proName": "",
			"postId": "",//工种
			"postName": "",
			"phone": "",//手机号
			"facePath": "",//人脸照片
			// "faceFeature": "1111",//人脸特征
			// "faceFeatureByte": [0],//人脸特征
			"autoPath": "",//签名
			"isFurloughPerson": "",//是否暂退
			"einStatus": "",//出入场状态
			"einTime": ""//入场时间
		},
		faceImgUrl:'',
		signImgUrl:'',
		signPopup:false,
		entryTrainBean:{//安全培训
			"safetyTraining": "",//安规培训
			"practical": "",//保命教育实操
			"theory": "",//保命教育理论
			"militarize": "",//准军事化培训
			"safetyScore": "",//安规培训分数
			"practicalScore": "",//保命教育实操分数
			"theoryScore": "",//保命教育理论分数
			"militarizeScore": "",//准军事化培训分数
			"isPass": ""//是否合格
		},
		entrySubTeamBean:{
			"subId": "",//分包编号
			"subName": "",//分包名称
			"teamId": "",//班组编号
			"teamName": "",//班组名称
			"isRegularPerson": ""//是否固定
		},
		entryContractBean:{
			"contractPath": "",//合同见证照片
			"contractId": "",//合同上传编号
			"contractCode": "",//合同编号
			"laborContractType": "",//合同期限类型
			"contractValidDate": "",//合同签订日期
			"contractInvalidDate": "",//合同终止日期
			"wageApprovedWay": "天",//工资核定方式
			"wageCriterion": "",//工资核定标准
			"role": "",//人员角色
			"contractType": "纸质合同",//合同类型
			"miurInsurance": "",//是否参加城乡居民医疗保险
			"endowmentInsurance": "",//是否参加城乡居民养老保险
			"whetherOnJob": ""//是否在职
		},
		contractImgUrl:'',
		bankImgUrl:'',
		entryBankBean:{
			"bankName": "",//银行名称
			"bankCard": "",//银行卡号
			"rollBankName": "",//银行支行名称
			"bankPhoto": ""//见证照片
		},
		entryOtherBean:{
			"socialSecurityNumber": "",//社保号
			"socialSecurityUnit": "",//社保单位
			"socialSecurityPath": "",//社保文件
			"personType": "",//人员类型
			"workerSkill": "",//工人技能
			"importantPerson": "",//重要人员
			"urgentPerson": "",//紧急联系人
			"urgentPersonPhone": "",//紧急联系人电话
			"cultrue": "",//文化程度
			"politicalOutlook": "",//政治面貌
			"addressPhone": ""//家庭电话
		},
		proList:[],
		postList:[],
		subList:[],
		teamList:[],
		roleList:[
			{value:'管理人员',text:'管理人员'},
			{value:'务工人员',text:'务工人员'},
			{value:'劳资专管员',text:'劳资专管员'}
		]
    }
  },
  onLoad(option) {
	this.distinguish()
	this.getproList()
	this.getpostList()
 
  },
  onShow() {
  },
  methods: {
	//人脸识别采集
	distinguish(){
		console.log('人脸识别采集')
		uni.chooseImage({
			count: 1,
			sizeType: ['compressed'],
			sourceType: ['camera'],
			success: res => {
				console.log('?? ~ res-拍照:', res)
				this.imgToBase64(res.tempFilePaths[0]).then(base64 => {
					// console.log(base64)
					uni.uploadFile({
						url: config.realFileUrl+`file/getFaceRecognition`, //服务器地址
						fileType:"image",//ZFB必填,不然报错
						filePath: res.tempFilePaths[0],//这个就是我们上面拍照返回或者先中照片返回的数组
						formData: {
							file:base64,
							photoType:'face',
						},
						success: (uploadFileRes) => {
							console.log(uploadFileRes)
							if(uploadFileRes.statusCode==200){
								uploadFileRes=JSON.parse(uploadFileRes.data)
								console.log(uploadFileRes)
								if(uploadFileRes.code==200){
									if(uploadFileRes.data.face){
										this.faceData=JSON.parse(uploadFileRes.data.personData)
										console.log(this.faceData)
										if(this.faceData){
											uni.$u.toast('人脸识别成功！');
											this.idNumber = this.faceData.idNumber;
											if(this.faceData.workerType=='0'){
												this.indexMax=4;
												this.pageTitle="修改临时人员"
											}else if(this.faceData.workerType=='1'){
												this.indexMax=7
												this.pageTitle="修改固定人员"
											}else if(this.faceData.workerType=='2'){
												this.indexMax=7
												this.pageTitle="修改分包管理人员"
											}
											this.getPersonById()
										}else{
											uni.$u.toast('识别失败');
										}
									}else{
										uni.$u.toast(uploadFileRes.msg);
									}
								}else{
									uni.$u.toast(uploadFileRes.msg);
								}
							}else{
								uni.$u.toast('识别失败');
							}
						},
						fail: err => {
							uni.$u.toast('识别失败');
							console.log(err)
						}
					});
				})
			},
			fail: err => { 
				uni.navigateBack({
					delta: 1 // 返回
				});
				console.log('?? ~ err:', err)
			}
		})
	},
	//获取工程
	getproList(){
		let param={
			id:-1,
			subId:this.sysUser.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.map(item=>{
					let obj={value:item.id,text:item.name}
					return obj
				});
			}
		  },
		  fail: err => {
			console.log(err)
		  }
		})
		// uni.request({
		//   url: config.realExamUrl+'/select/getProByTeamId',
		//   method: 'get',
		//   data: {},
		//   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.map(item=>{
		// 			let obj={value:item.id,text:item.name}
		// 			return obj
		// 		});
		// 	}
		//   },
		//   fail: err => {
		// 	console.log(err)
		//   }
		// })
	},
	changePro(e){
		this.proList.forEach(item=>{
			if(item.value==e){
				this.entryCruxBean.proName=item.text;
			}
		})
		
		console.log(this.entryCruxBean.proName)
		this.getSubList()
	},
	//获取工种
	getpostList(){
		uni.request({
		  url: config.realAppUrl + '/offLine/getWorkType',
		  method: 'post',
		  data: {},
		  header: {
			'Content-Type': 'application/x-www-form-urlencoded',
			Authorization: uni.getStorageSync('realNameToken')
		  },
		  success: res => {
			res = res.data;
			if(res.code==200){
				res.data.forEach(item=>{
					if(item.code=='postType'){
						let obj={value:item.id,text:item.type}
						this.postList.push(obj)
					}
				});
			}
		  },
		  fail: err => {
			console.log(err)
		  }
		})
	},
	changePost(e){
		this.postList.forEach(item=>{
			console.log(item)
			if(item.value==e){ 
				this.entryCruxBean.postName=item.text;
			}
		})
		console.log(this.entryCruxBean.postName)
	},
	//获取分包商
	getSubList(){
		let param={
			proId:this.entryCruxBean.proId
		}
		uni.request({
		  url: config.realExamUrl+'/select/getSubByProId',
		  method: 'get',
		  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.subList=res.data.map(item=>{
					let obj={value:item.id,text:item.name}
					return obj
				});
			}
		  },
		  fail: err => {
			console.log(err)
		  }
		})
	},
	changeSub(e){
		this.subList.forEach(item=>{
			if(item.value==e){
				this.entrySubTeamBean.subName=item.text;
			}
		})
		console.log(this.entrySubTeamBean.subName)
		this.getTeamList()
	},
	//获取班组
	getTeamList(){
		let param={
			subId:this.entrySubTeamBean.subId
		}
		uni.request({
		  url: config.realExamUrl+'/select/getTeamBySubId',
		  method: 'get',
		  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.teamList=res.data.map(item=>{
					let obj={value:item.id,text:item.name}
					return obj
				});
			}
		  },
		  fail: err => {
			console.log(err)
		  }
		})
 
		 
	},
	changeTeam(e){
		this.teamList.forEach(item=>{
			if(item.value==e){
				this.entrySubTeamBean.teamName=item.text;
			}
		})
		console.log(this.entrySubTeamBean.teamName)
	},
	//获取人员信息
	getPersonById(){
		uni.request({
		  url: config.realAppUrl+'/entry/'+this.idNumber,
		  method: 'get',
		  data: {},
		  header: {
			'Content-Type': 'application/x-www-form-urlencoded',
			Authorization: uni.getStorageSync('realNameToken')
		  },
		  success: res => {
			console.log(res)
			res = res.data;
			if(res.code==200){
				 console.log(res.data)
				 if(res.data.entryIdNumberBean){ this.entryIdNumberBean=res.data.entryIdNumberBean;}
				 if(res.data.entryCruxBean){ 
					 this.entryCruxBean=res.data.entryCruxBean;
					 this.faceImgUrl=config.realBaseUrl+this.entryCruxBean.facePath;
					 this.signImgUrl=config.realBaseUrl+this.entryCruxBean.autoPath;
				 }
				 if(res.data.entryTrainBean){ this.entryTrainBean=res.data.entryTrainBean;}
				 if(res.data.entrySubTeamBean){
					 this.getSubList()
					 this.getTeamList()
					 this.entrySubTeamBean=res.data.entrySubTeamBean;
				 }
				 if(res.data.entryContractBean){ 
					 this.entryContractBean=res.data.entryContractBean;
					 this.contractImgUrl=config.realBaseUrl+this.entryContractBean.contractPath;
				 }
				 if(res.data.entryBankBean){ 
					 this.entryBankBean=res.data.entryBankBean;
					 this.bankImgUrl=config.realBaseUrl+this.entryBankBean.bankPhoto;
				 }
				 if(res.data.entryOtherBean){ this.entryOtherBean=res.data.entryOtherBean;} 
			}
		  },
		  fail: err => {
			console.log(err)
		  }
		})
	},
	
	//正面面识别采集
	distinguishFornt(){
		console.log('正面识别')
		uni.chooseImage({
			count: 1,
			sizeType: ['compressed'],
			sourceType: ['camera'],
			success: res => {
				console.log('?? ~ res-拍照:', res)
				this.imgToBase64(res.tempFilePaths[0]).then(base64 => {
					let param={
						type:'1',
						recognitionFrontData:base64.split(',')[1]
					}
					console.log(param)
					uni.request({
					  url: config.realIdCardUrl+'/recognition',
					  method: 'post',
					  data: param,
					  header: {
						'Content-Type': 'application/Json',
						Authorization: uni.getStorageSync('realNameToken')
					  },
					  success: res => {
						console.log(res)
						res = JSON.parse(res.data); 
						this.entryIdNumberBean.name=res.data.name;
						this.entryIdNumberBean.idNumber=res.data.idNumber;
						this.getBorth(this.entryIdNumberBean.idNumber)
						this.entryIdNumberBean.sex=res.data.gender;
						this.entryIdNumberBean.ethnic=res.data.ethnicity;
						this.entryIdNumberBean.address=res.data.address;
					  },
					  fail: err => {
						console.log(err)
					  }
					})
	 
				})
			},
			fail: err => { 
			  console.log('?? ~ err:', err)
			}
		})
	},
	//背面识别采集
	distinguishBack(){
		console.log('背面识别')
		uni.chooseImage({
			count: 1,
			sizeType: ['compressed'],
			sourceType: ['camera'],
			success: res => {
				console.log('?? ~ res-拍照:', res)
				this.imgToBase64(res.tempFilePaths[0]).then(base64 => {
					let param={
						type:'1',
						recognitionBackData:base64.split(',')[1]
					}
					console.log(param)
					uni.request({
					  url: config.realIdCardUrl+'/recognition',
					  method: 'post',
					  data: param,
					  header: {
						'Content-Type': 'application/Json',
						Authorization: uni.getStorageSync('realNameToken')
					  },
					  success: res => {
						console.log(res)
						res = JSON.parse(res.data); 
						this.entryIdNumberBean.issuance=res.data.issuingAuthority;
						this.entryIdNumberBean.signDate=res.data.validTime.split("-")[0];
						this.entryIdNumberBean.expiryDate=res.data.validTime.split("-")[1];
					  },
					  fail: err => {
						console.log(err)
					  }
					})
	 
				})
			},
			fail: err => { 
			  console.log('?? ~ err:', err)
			}
		})
	},
	
	//上传合同照片
	uploadContractImg(){
		uni.chooseImage({
				count: 1,
				sizeType: ['compressed'],
				sourceType: ['camera'],
				success: res => {
				  console.log('?? ~ res-拍照:', res)
				  uni.uploadFile({
						url: config.realFileUrl+`file/upload`, //服务器地址
						fileType:"image",//ZFB必填,不然报错
						filePath: res.tempFilePaths[0],//这个就是我们上面拍照返回或者先中照片返回的数组
						name: "imgFile",
						formData: {
							photoType:'Contract',
						},
						success: (uploadFileRes) => {
							console.log(uploadFileRes)
							if(uploadFileRes.statusCode==200){
								this.entryContractBean.contractPath=JSON.parse(uploadFileRes.data).data.url;
							}else{
								uni.$u.toast('上传失败');
							}
						},
						fail: err => {
							uni.$u.toast('上传失败');
							console.log(err)
						}
				  });
				  this.imgToBase64(res.tempFilePaths[0]).then(base64 => {
						this.contractImgUrl=base64
					})
				},
				fail: err => { 
				  console.log('?? ~ err:', err)
				}
		})
	},
	//上传银行卡照片
	uploadBankImg(){
		uni.chooseImage({
				count: 1,
				sizeType: ['compressed'],
				sourceType: ['camera'],
				success: res => {
				  console.log('?? ~ res-拍照:', res)
				  uni.uploadFile({
						url: config.realFileUrl+`file/upload`, //服务器地址
						fileType:"image",//ZFB必填,不然报错
						filePath: res.tempFilePaths[0],//这个就是我们上面拍照返回或者先中照片返回的数组
						name: "imgFile",
						formData: {
							photoType:'salary',
						},
						success: (uploadFileRes) => {
							console.log(uploadFileRes);
							if(uploadFileRes.statusCode==200){  
								this.entryBankBean.bankPhoto=JSON.parse(uploadFileRes.data).data.url;
							}else{
								uni.$u.toast('上传失败');
							}
							
						},
						fail: err => {
							uni.$u.toast('上传失败');
							console.log(err)
						}
				  });
				  this.imgToBase64(res.tempFilePaths[0]).then(base64 => {
					this.bankImgUrl=base64  
				  })
				},
				fail: err => { 
				  console.log('?? ~ err:', err)
				}
		})
	},
	// 人脸照片拍照录入
	openPhotograph() {
		if(!this.verifyidNumber(this.entryIdNumberBean.idNumber)){
			uni.$u.toast('人脸采集前请先填写身份证号！');
		}else{
			uni.chooseImage({
				count: 1,
				sizeType: ['compressed'],
				sourceType: ['camera'],
				success: res => {
					console.log('?? ~ res-拍照:', res)
					this.imgToBase64(res.tempFilePaths[0]).then(base64 => {
						uni.uploadFile({
							url: config.realFileUrl+`file/uploadFaceRecognition`, //服务器地址
							fileType:"image",//ZFB必填,不然报错
							filePath: res.tempFilePaths[0],//这个就是我们上面拍照返回或者先中照片返回的数组
							formData: {
								file:base64,
								optMode:'replace',
								photoType:'face',
								uniqueKey:this.entryIdNumberBean.idNumber, 
							},
							success: (uploadFileRes) => {
								console.log(uploadFileRes)
								if(uploadFileRes.statusCode==200){
									uploadFileRes=JSON.parse(uploadFileRes.data)
									if(uploadFileRes.code==200){
										this.faceImgUrl=base64;
										this.entryCruxBean.facePath=uploadFileRes.data.url;
									}else{
										uni.$u.toast(uploadFileRes.msg);
									}
								}else{
									uni.$u.toast('上传失败');
								}
							},
							fail: err => {
								uni.$u.toast('上传失败');
								console.log(err)
							}
						});
					})
				},
				fail: err => { 
				  console.log('?? ~ err:', err)
				}
			})
		}
	},
	imgToBase64(data) {
	  return new Promise((resolve, reject) => {
		pathToBase64(data)
		  .then(base64 => {
			resolve(base64)
		  })
		  .catch(error => {
			console.error(error)
			reject(error)
		  })
	  })
	},
	//aoto 签名photoType
	openSignView(){
		this.signPopup=true;
		this.entryCruxBean.autoPath='';
		this.signImgUrl=""
	},
	closeSign(){this.signPopup=false;},
	signConfirm(url,localPath){
		console.log(url)
		this.entryCruxBean.autoPath=url;
		this.imgToBase64(localPath).then(base64 => {
			this.signImgUrl=base64
		})
		this.signPopup=false;
	},
	matchScore1(e){
		if(Number(e)>100){
			this.entryTrainBean.safetyScore=100;
		}else if(Number(e)<0){
			this.entryTrainBean.safetyScore=0;
		}
	},
	matchScore2(e){
		if(Number(e)>100){
			this.entryTrainBean.practicalScore=100;
		}else if(Number(e)<0){
			this.entryTrainBean.practicalScore=0;
		}
	},
	matchScore3(e){
		if(Number(e)>100){
			this.entryTrainBean.theoryScore=100;
		}else if(Number(e)<0){
			this.entryTrainBean.theoryScore=0;
		}
	},
	matchScore4(e){
		if(Number(e)>100){
			this.entryTrainBean.militarizeScore=100;
		}else if(Number(e)<0){
			this.entryTrainBean.militarizeScore=0;
		}
	},
	matchWageCriterion(e){
		if(Number(e)>600){
			this.entryContractBean.wageCriterion=600;
		}else if(Number(e)<60||e<''){
			this.entryContractBean.wageCriterion=60;
		}
	},
	//身份证校验
	verifyidNumber(idNumber) {
	  // 校验长度
	  if (idNumber.length !== 18) {
	    return false;
	  }
	  // 校验前17位是否为数字
	  if (!/^\d{17}$/.test(idNumber.substr(0, 17))) {
	    return false;
	  }
	  
	  // 校验最后一位
	  var weightFactor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
	  var checkCodeList = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
	  var checkSum = 0;
	  for (var i = 0; i < 17; i++) {
	    checkSum += parseInt(idNumber.charAt(i)) * weightFactor[i];
	  }
	  var checkCodeIndex = checkSum % 11;
	  if (idNumber.charAt(17).toUpperCase() !== checkCodeList[checkCodeIndex]) {
	    return false;
	  }
	  
	  return true;
	},
	getBorth(e){
		if(e.length==18){
			if (parseInt(this.entryIdNumberBean.idNumber.substr(16, 1)) % 2 == 1) {
				this.entryIdNumberBean.sex = "男";
			} else {
				this.entryIdNumberBean.sex = "女";
			}
			this.entryIdNumberBean.birthday=this.entryIdNumberBean.idNumber.substring(6, 14)
		}
	},
	next(){
		var pattern = /^1[3-9]\d{9}$/;
		if(this.hIndex==1){
			if(this.entryIdNumberBean.name==''){
				uni.$u.toast('请填写姓名');
			}else if(this.entryIdNumberBean.idNumber==''){
				uni.$u.toast('请填写身份证号');
			}else if(!this.verifyidNumber(this.entryIdNumberBean.idNumber)){
				uni.$u.toast('请填写正确身份证号');
			}else if(this.entryIdNumberBean.ethnic==''){
				uni.$u.toast('请填写名族');
			}else if(this.entryIdNumberBean.address==''){
				uni.$u.toast('请填写住址');
			}else if(this.entryIdNumberBean.signDate==''){
				uni.$u.toast('请选择生效日期');
			}else if(this.entryIdNumberBean.expiryDate==''){
				uni.$u.toast('请选择失效日期');
			}else if(this.entryIdNumberBean.issuance==''){
				uni.$u.toast('请填写签发机关');
			}else{
				this.hIndex=2;
			}
		}else if(this.hIndex==2){
			
			if(this.entryCruxBean.proId==''){
				uni.$u.toast('请选择工程');
			}else if(this.entryCruxBean.postId==''){
				uni.$u.toast('请选择工种');
			}else if(this.entryCruxBean.phone==''){
				uni.$u.toast('请填写手机号码');
			}else if(!pattern.test(this.entryCruxBean.phone)){
				uni.$u.toast('请填写正确手机号码');
			}else{
				this.hIndex=3;
			}
		}else if(this.hIndex==this.indexMax){
			 this.updateEntryPerson()
		}else{
			this.hIndex=this.hIndex+1
		}
		
		
		
	},
	up(){
		if(this.hIndex!=1){
			this.hIndex=this.hIndex-1
		}
	},
	updateEntryPerson(){
		console.log('add')
		let param={
			entryIdNumberBean:this.entryIdNumberBean,
			entryCruxBean:this.entryCruxBean,
			entryTrainBean:this.entryTrainBean,
			entrySubTeamBean:this.entrySubTeamBean,
			entryContractBean:this.entryContractBean,
			entryBankBean:this.entryBankBean,
			entryOtherBean:this.entryOtherBean
		}
		console.log(param)
		uni.request({
		  url: config.realAppUrl+'/entry/updateEntryPerson',
		  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){
				uni.showToast({
					title: res.data,
					icon: 'none'
				})
				setTimeout(()=>{
					uni.navigateBack({
						delta: 1 // 返回到已存在的页面
					});
				},1000)
			}else{
				uni.showToast({
					title: res.msg,
					icon: 'none'
				})
			}
		  },
		  fail: err => {
			console.log(err)
		  }
		})
		
		
	},
	
    // 返回
    leftClick() {
      console.log('返回')
      uni.navigateBack({
      	delta: 1 // 返回
      });
    }
  },

}
</script>

<style lang="scss">

/deep/ .uni-stat__select {
			width:420rpx !important;
			.uni-select__input-text {
					width: 420rpx !important;
				}
		}
.scroll-view {
	white-space: nowrap;
	width: 100%;
}
 
.scroll-view-item {
	display: inline-block;
	width: 160rpx;
	height: 100rpx;
	line-height: 100rpx;
	text-align: center;
	
	.activeLine{
		background:  #00337A;
		border-radius: 10upx;
		width: 160rpx;
		height: 6upx;
	}
}
.active {
	color: #333;
	font-weight: bolder;
	font-size: 32rpx;
}
.page {
	width: 100vw;
	height: 100vh;
	background-color: #FFF;
	box-sizing: border-box;
	.header{
		width: 100vw;
		height: 120rpx;
		// display: flex; 
		.header-item{
			width: 200rpx;
			padding: 0 20rpx;
			height: 120rpx;
			color: #666;
			line-height: 1200rpx;
			// white-space: nowrap;
			
			.activeLine{
				background:  #00337A;
				border-radius: 10upx;
				width: 200rpx;
				height: 6upx;
			}
		}
		.active {
			// background: #fff;
			color: #333;
			font-weight: bolder;
			font-size: 32rpx;
		}
	}

	.content{
		width: 100%;
		height: 86vh;
		margin-top: 20rpx;
		padding-bottom: 80rpx;
		background: #FFF;
		.addForm{
			width: 100%;
			height: auto;
			
			.form-input-box{
				padding: 0 20rpx;
				display: flex;
				align-items: center;
				border-bottom: 1rpx solid #eee;
			}
		}
		
		.submit-box{
			width: 94%;
			height: auto;
			margin: 0 auto;
			margin-top: 60rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.submit-btn{
				width: 45%;
			}
		}
		.tip-view{
			width: 96%;
			margin: 0 auto;
			display: flex;
			justify-content: space-between;
			border-bottom: 1rpx solid #eee;
			padding: 20rpx;
		}
		
	}
	.img-box{
		width: 70%;
		height: auto;
		margin: 0rpx auto;
		padding:20rpx;
		display: flex;
		align-items: center;
		border-bottom: 1rpx solid #EFEFEF;
		.img-item {
			float: left;
			width: 200upx;
			height: 200upx;
			border: 1px solid #ddd;
			margin: 0 22rpx 20upx 0upx;
			position: relative;
			box-sizing: border-box;
			background: #eee;
			.img {
				display: block;
				width: 100%;
				height: 100%;
			}
			.remove-btn {
				position: absolute;
				top: -18upx;
				right: -18upx;
				width: 44upx;
				height: 44upx;
				z-index: 2;
			}
		}
		.upload-btn {
				display: flex;
				justify-content: center;
				align-items: center;
			.img {
				width: 60upx;
				height: 60upx;
				margin: unset;
			}
		}
	}
	.signBtn{
		background-color:#00337A;
		color: #FFF;
		height: 36rpx;
		line-height: 36rpx;
		padding:10rpx 20rpx;
		border-radius: 10rpx;
	}
	.popup-header{
		width: 100%;
		height: 80rpx;
		margin: 0 auto;
		display: flex;
		justify-content: space-between;
		align-items: center;
		background-color: #fff;
	}
	.popup-content{
		width: 100%;
		height: 32vh;
		background-color: #fff;
	}
	.popup-submit-box {
		width: 100%;
		height: 100rpx;
		position: absolute;
		bottom: 0;
		display: flex;
		padding-bottom: 20rpx;
		justify-content: space-between;
		align-items: center;
		background-color: #FFF;
		.submit-edit-1{
			width:45%;
			margin: 0 auto;
			height: 65rpx;
			font-size: 26rpx;
			background: #F5F5F5;
		}
		.submit-edit-2{
			width: 45%;
			margin: 0 auto;
			height: 65rpx;
			font-size: 26rpx;
			background: #0052D9;
		}
	}
}
</style>
