<template>
	<view class="index">

		<view class="tab">
			<!-- //表格 -->
			<view class="exele">

				<view class="box">
					<table @change="change">
						<tr class="tr_one">
							<!-- <th style="width: 130upx; text-align: center;">编号</th> -->
							<th style="width: 90upx; text-align: center;">姓名</th>
							<!-- <th style="width: 120upx; text-align: center;">与户主关系</th> -->
							<th style="width: 260upx; text-align: center;">身份证号</th>
							<th style="width: 60upx; text-align: center;">历史状态</th>
							<th style="width: 170upx; text-align: center;">变更人</th>
							<th style="width: 164upx; text-align: center;">变更时间</th>
							<!-- <th style="width: 100upx;">联系方式</th> -->
							<!-- <th style="width: 70upx; text-align: center;">操作</th> -->
							<!-- <th style="width: 60upx;">查看</th> -->
						</tr>
						<scroll-view scroll-y class="scroll-view" upper-threshold="40" lower-threshold="40" @scrolltolower="bot_btn">
							<tr v-for="(item,index) in list" :key="index" :class=" [index%2  ==0 ? 'two_tr two_trtwo':'two_tr']" @click="chakn(item)">
								<!-- <td style="width: 130upx; text-align: center;" >{{ item.code == null ? '暂无信息' :  item.code}}</td> -->
								<td style="width: 90upx; text-align: center;" >{{ item.userName == null ? '暂无信息' :  item.userName}}</td>
								
								<!-- <td style="width:120upx; text-align: center;" >{{ item.yhzgx == null ? '暂无信息' :  item.yhzgx}}</td> -->
								<!-- <td style="width: 40upx; text-align: center;">{{item.gender == null? '暂无信息' : item.gender }}</td> -->
								<td style="width: 260upx; text-align: center;">{{item.idCard == null? '暂无信息' : item.idCard }}</td>
								<!-- 状态 -->
								<td style="width: 60upx; text-align: center;" >{{ item.status == null ? '暂无信息' :  statusFn(item.status)}}</td>
								<!-- <td style="width: 170upx; text-align: center;" >{{ item.phoneNum == null? '暂无信息' :  item.phoneNum}}</td> -->
								 <td style="width:170upx; text-align: center;" >{{ item.changUser == null ? '暂无信息' :  item.changUser}}</td>
								<!-- <td style="width: 100upx;" :class="[item.phone == '' ? 'tdse' : '' ]" >{{ item.phone == ''? '未完善' : item.phone}}</td> -->
								<!-- <td style="width: 100upx; text-align: center;" :class="[item.addtime == null ? 'tdse' : item.addtime == ''? 'tdse' : ''  ]">{{ item.addtime ==null ? '未完善' :  item.addtime==''? '未完善' : item.addtime}}</td> -->
								<!-- <td style="width: 50upx;" class="coiu" @click.stop="dele(item.id)">删除</td> -->
								<!-- <td style="width: 70upx;text-align: center; color: #32B16C;" @click.stop="goDetail(item.id)">查看</td> -->
								<td style="width: 164upx;text-align: center; color: #32B16C;" >{{ item.changUserTime == null ? '暂无信息' :  item.changUserTime}}</td>
							</tr>
							<div class="shax" v-if="list.length>0">
								{{wtdt}}
							</div>
							<div class="zanwu " v-else><span>暂无数据</span></div>
						</scroll-view>
						
					</table>
				</view>

			</view>
		</view>
		<!-- 弹窗 -->
		<!-- <div class='xinse'>
			<div class="xinsea btn1" @click="addVacFrom">新增家庭成员</div>
			<div class="xinsea btn2" @click='getSynFn'>与户主户籍同步</div>
			<div class="xinsea btn" @click='getSureFn'>一键确认信息无误</div>
		</div> -->
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				upimg:require("@/static/image/up.png"),
				activeTab: 0, //tab切换
				//列表数据
				list: [],
				show: false,
				actions: [{
					name: '102',
				}],
				params: { //上拉刷新
					pageNum: 1,
					pageSize: 40,
				},
				
				keyword: '',
				haveMore: true,
				wtdt: '上拉加载更多',
				terd: '',
				stuList: {}, //学生人数
				shoue: false,
				listShow: true, //判断是否有数据 true 有
				areaList: {}, //班级数据
				xuan: ['请选择', '请选择', '请选择'],
				columns: [

				],
				cites: [],
				tehu: '请选择班级',
				companyId: '',
				arrbq: [],
				startDate:'选择开始时间',
				endDate:'选择结束时间',
				showtime:false, 
				minDate:0 ,
				maxDate: 0,
				currentDate: 0,
				shwtie:0,
				baseurl:'',
				tabstalist:[]
			};
		},
		onShow() {
			let type = uni.getStorageSync('token')
			if (!type) {
				uni.redirectTo({
					url: '/pages/load/roles'
				})
			}
		},
		onLoad(e) {
			this.id=e.id;
			// this.params.pageNum = 1
			// this.params.code=e.code;
			this.list = []
			// 修改 获取列表的
			// 获取统计
			this.getStatelist()
			this.$nextTick(function(){
				this.lists(this.params)
			})
			
			
		},
		created() {

		},
		//下拉刷新
		onPullDownRefresh() {

			
			wx.showNavigationBarLoading()
			this.params.pageNum = 1
			this.shwtie = 0
			this.params = { //上拉刷新
					pageSize: 40,
					pageNum: 1,
					code:this.code
				}, //查询

			this.keyword = ''
			this.list = []

		},
		methods: {
			statusFn(sta){
				return this.selectDictLabel(sta)
			},
			selectDictLabel(value) {
				var actions = [];
				var datas=this.tabstalist
				Object.keys(datas).some((key) => {
					if (datas[key].dictValue == (value)) {
						actions.push(datas[key].dictLabel);
						return true;
					}
				})
				return actions.join('');
			},
			// 字典值
			getStatelist(){
				// 旧字典值
				this.$http.get("system/dict/data/type/person_type").then(res => {
					if (res.code == 200) {
						this.tabstalist = res.data
						// 列表
					} else {
						uni.showToast({
							title: res.msg,
							duration: 1000,
							icon: 'none'
						});
				
					}
				})
			},
			goDetail(id) {
				uni.navigateTo({
					url: '/add/pages/addvacfrom/addpeople?id=' + id
				})
				// uni.navigateTo({
				// 	url: '/pages/resident/residentdetail?id=' + id
				// })
			},
			
			// 一键确认
			getSureFn(){
				var that=this;
				var newArr=this.list;
				var newAdd=[];
				var newstr='';
				if(newArr.length>0){
					for(var i=0;i<newArr.length;i++){
						newAdd[newAdd.length]=newArr[i].id;	
					}
					newstr=newAdd.join(',')
					this.$nextTick(function(){
						that.$http.get('boman-web-core/core/ryrl/confirmInfo/'+newstr,{}).then(res => {
							// console.log(res)
							if (res.code == 200) {
								uni.navigateTo({
									url: '/add/pages/addvacfrom/submit'
								})
							} else {
								uni.showToast({
									title: res.msg,
									icon: "none"
								})
							}
						})
					})
				}else{
					uni.showToast({
						title:'暂无需要确认的信息',
						icon: "none"
					})
				}
			},
			// 一键同步
			getSynFn(){
				var that=this;
				var code=this.code
				if(this.code){
					var url='boman-web-core/core/czrk/synchronization/'+code
					that.$http.get(url,{}).then(res => {
						// console.log(res)
						if (res.code == 200) {
							if(res.msg=='无家庭成员'){
								uni.showToast({
									title: res.msg,
									icon: "none"
								})
							}else{
								uni.navigateTo({
									url: '/add/pages/addvacfrom/submit'
								})
							}
							
						} else {
							uni.showToast({
								title: res.msg,
								icon: "none"
							})
						}
					})
				}else{
					uni.showToast({
						title:'暂无需要同步的信息',
						icon: "none"
					})
				}	
			},
			addVacFrom () {
				uni.navigateTo({
					url: '/add/pages/addvacfrom/addpeople?code='+this.code
				})
			},
			
			//查询列表
			lists(params) {
				this.$http.post('boman-web-core/core/czrk/changeCzrkHistory',{id: this.id}).then(res => {
					//停止下拉加载
					uni.hideNavigationBarLoading()
					uni.stopPullDownRefresh()
					if (res.code == 200) {
						if (res.data.length < params.pageSize) {
							// this.listShow = false
							this.wtdt='到底了~'
							this.haveMore = false
						} else {
							this.wtdt='上拉加载更多'
							// this.listShow = true
							this.haveMore = true
						}
						if(params.pageSize==1){
							this.list = res.data
						}else{
							this.list = this.list.concat(res.data) 
						}
					} else {
						uni.showToast({
							title: res.msg,
							duration: 1000,
							icon: 'none'
						});
				
				
					}
				})
			},
			//刷新
			bot_btn() {
				if (this.haveMore) {
					this.params.pageNum++
					this.lists(this.params)
				}
			},
			formatter(type, value){
				 if (type === 'year') {
				        return `${value}年`;
				      } else if (type === 'month') {
				        return `${value}月`;
				      }
				      return value;
			},
		}
	}
</script>

<style lang="scss" scoped>
	.address{
		display: flex;align-items: center;
		.adds{
			display: flex;align-items: center;justify-content: center;padding:20rpx 12rpx;width: 180rpx;box-sizing: border-box;
			.addsa{font-size: 26rpx;color: #333333;
			}
			.addsimg{width: 14rpx;height: 10rpx;margin-left: 16rpx;transition: all 0.3s;}
		}
	}
	
	
	.coie{
		width: 100%;
		box-sizing: border-box;
		padding:  0 33upx;
		.coie_nav{
			border-top: 1upx solid #E5E5E5;
			display: flex;
			flex-wrap: wrap;
			padding-bottom: 28upx;
			p{
				width: 33.33%;
				text-align: center;
				display: flex;
				flex-direction: column;
				margin-top: 53upx;
				span{
					font-size: 28upx;
				}
				i{
					font-size: 28upx;
					color: #333;
					margin-top: 28upx;
				}
			}
		}
	}
	.ieju{
		height: 17upx;
		width: 100%;
		background-color: #eee;
		margin-bottom: 33upx;
	}
	//暂无数据
	.zanwu {
		text-align: center;
		padding-top: 20upx;

		span {
			font-size: 24upx;
		}
	}

	.scroll-view {
		max-height: calc(100vh - 150upx);
	}
	.shax {
		// height: 83upx;
		font-size: 25upx;
		color: #666;
		text-align: center;
	}

	.index {
		// padding-top: 33upx;
		max-height: 100vh;

		.sous {
			padding: 24upx 33upx;
			// display: flex;
            
			.input {
				height: 90upx;
				border: 1upx solid #E5E5E5;
				flex: 1;
				margin-right: 28upx;
				padding-left: 10upx;
				box-sizing: border-box;
			}

			button {
				// width: 125upx;
				height: 90upx;
				background-color: #1678FF;
				text-size: 28upx;
				color: #fff;
				text-align: center;
				line-height: 90upx;
			}
		}

		//tab
		.tab {
			padding-top:33upx;
			.tabs {
				display: flex;
				padding: 0 20upx;
				box-sizing: border-box;
				height: 111upx;
				justify-content: space-between;
				box-shadow: 0px 7px 7px 0px rgba(229, 229, 229, 0.5);

				.one_tab {
					color: #1678FF !important;
					// width: 140upx;
					// text-align: center;

					// .twotabs {
					// 	font-size: 31upx;
					// 	color: #666666;
					// 	;
					// 	font-weight: 500;
					// }

					// .twosrtabs {
					// 	color: #1678FF;
					// }

					// .twotabstwo {
					// 	font-size: 24upx;
					// 	color: #AAAAAA;
					// }
				}

				.one_tabqie {
					border-bottom: 8upx solid #1678FF;

				}
			}
		}

		//表格
		.exele {
			.box {
				.tr_one {
					display: flex;
					padding: 0 10upx;
					box-sizing: border-box;
					justify-content: space-between;

					th {
						// flex: 1;

						font-size: 24upx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #333333;
						line-height: 14upx;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
						line-height: 83upx;
						height: 83upx;
					}
				}

				.two_tr {
					display: flex;
					padding: 0 10upx;
					box-sizing: border-box;
					justify-content: space-between;

					td {
						// flex: 1;

						font-size: 24upx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #333333;
						line-height: 83upx;
						height: 83upx;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;

					}

					.tdse {
						color: #E60012 !important;
					}
					.apply_span_xl{
						color: #32B16C !important;
					}
					.apply_span_xltwo{
						color: #ffa200 !important;
					}
					.apply_span_xlfive{
						color: #4c4b4b !important;
					}
					.apply_span_xlthreo{
						color: #f00404 !important;
					}
					.apply_span_xlforu{
						color: #aaaaaa !important;
					}
					// .apply_span_xla{
					// 	color: #1678FF;
					// 	text-decoration: underline ;
					// }

					.coiu {
						color: #EC1717;
					}
				}

				.two_trtwo {
					background-color: #F6F9FC;
				}
			}

		}
	}

	.banj {
		height: 86upx;
		width: 100%;
		// text-align: center;
		line-height: 86upx;
		// background-color: #F6F9FC;
		color: #AAAAAA;
		margin-top: 20upx;
		display: flex;
		justify-content: space-around;
	}
	.apply_box{
		.apply_item_input{
			padding: 0 33upx;
			// border-top: 1upx solid #F4F4F4;
			display: flex;
			height: 68upx;
			align-items: center;
			.apply_span_x{
				font-size: 28upx;
				color: #363535;
				span{
					color: #F22346;
				}
			}
			.input_r{
				font-size: 28upx;
				height: 100%;
				flex: 1;
				text-align: right;
			}
			.input_rtwo{
				line-height:68upx;
			}
			.input_rtwoss{
				color: #1678FF;
			}
			.input_rtwosss{
				color: #FF0000;
			}
		}
		.apply_title_jt{
			height: 130upx;
			border-top: 1upx solid #F4F4F4;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0 32upx;
			span{
				font-size: 36upx;
				color: #333;
				font-weight: bold;
			}
			.apply_title_btn{
				width: 160upx;
				height: 60upx;
				font-size: 24upx;
				color: #fff;
				display: flex;
				justify-content: center;
				align-items: center;
				background: #FF568C;
				border-radius: 8upx;
				.img{
					width: 30upx;
					height: 30upx;
					margin-right: 10upx;
				}
			}
		}
		.apply_title_jts{
			border:none;
		}
		.apply_title_jt_item{
			border-bottom: 9upx solid #F4F4F4;
			.apply_item_input_qx{
				color: #FF5185;
				height: 100%;
				display: flex;
				justify-content: center;
				align-items: center;
				height: 112upx;
				font-size: 30upx;
			}
		}
		.apply_item_sfz{
			padding: 42upx 20upx;
			border-bottom: 9upx solid #F4F4F4;
			.apply_item_sfz_title{
				font-weight: bold;
				font-size: 34upx;
				margin-bottom: 40upx;
				margin-left: 2upx;
			}
			.apply_item_phones{
				display: flex;
				justify-content: space-between;
				.apply_item_phone{
					width: 340upx;
					height: 218upx;
					.img{
						width: 100%;
						height: 100%;
						border-radius: 20upx;
					}
				}
			}
		}
		.apply_item_zdxx{
			padding: 0 26upx;
			font-size: 34upx;
			font-weight: bold;
			color: #333;
			height: 112upx;
			line-height: 112upx;
			border: 1upx solid #F4F4F4;
		}
		.qt_div{
			height: 112upx;
			border-top: 1upx solid #F4F4F4;
			padding: 0 32upx;
			border-bottom: 9upx solid #F9F9F9;
			.input_l{
				height: 100%;
				font-size: 30upx;
			}
		}
	}
	.tabld{
		display: flex;
		// height: 90upx;
		box-shadow: 0px 7px 5px 0px rgba(218, 218, 218, 0.35);
		view {
			font-size:26upx ;
			font-family: PingFang SC;
			font-weight: 500;
			color: #191919;
			text-align: center;
			flex: 1;
			// line-height: 70upx;
			display: flex;
			flex-direction: column;
			padding: 18rpx 0 20rpx;
		}
		.one_tabhu{
			color: #009FE8;
			position: relative;
		::after{width: 28rpx;height: 6rpx;background: #009FE8;position: absolute;left: 50%;margin-left: -14rpx;bottom: 0;content: "";}
		}
	}
	.nbhe{
		display: flex;
		margin-bottom: 44upx;
		p{
			font-size: 25upx;
			flex: 1;
			padding: 0 77upx;
			display: flex;
			align-items: center;
		}
		p:nth-child(2){
			justify-content: flex-end;
		}
		img{
			width: 31upx;
			height: 29upx;
			margin-right: 11upx;
		}
	}
	.xinse{
		position: fixed;
		width: 100%;
		bottom: 0;
		left: 0;
		padding: 0 20rpx;
		padding: 20rpx 34rpx;background: #ffffff;
		// box-shadow: 0 14rpx 40rpx 12rpx rgba(218, 218, 218, 1);
		.xinsea{
			font-size: 33upx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
			height: 90upx;
			text-align: center;
			line-height: 90upx;
			border-radius: 6rpx;
		}
		.btn{
			background-color: #009FE8;
			
		}
		.btn1{
			background-color: #00B034;
			margin-bottom: 20rpx;
		}
		.btn2{background-color: #ff9329;margin-bottom: 20rpx;}
	}
</style>

