<template>
  <view class="page">
    <u-navbar class="u-navbar" title="人员库" placeholder @leftClick="leftClick" leftIconColor="#fff"  bgColor="#00337A"  :titleStyle="{ color: '#FFF', fontSize: '32rpx' }"/>
	<view style="width: 94%;height: 80rpx;margin: 20rpx auto;display: flex;align-items: center;">
		<!-- searchList -->
		<u-search shape="square" placeholder="搜索"  v-model="keyword" :showAction="false"></u-search>
		<view class="searchBtn" @click="searchList">搜索</view>
	</view>
	<!-- <view style="padding-left: 40rpx;">
		<text style="font-size: 24rpx;color: #5193FE;">已查询{{number}}条数据</text>
	</view> -->
	<!-- 列表 -->
	<view class="list-box">
		<view style="width: 100%;height: 70vh;display: flex;align-items: center;justify-content: center;" v-if="isLoading">
			<u-loading-icon :show="true" mode="circle" text="加载中" :vertical="true"></u-loading-icon>
		</view>
		<view v-if="!isLoading&&listData.length==0" style="width: 96%;height: 60vh;display: flex;flex-direction: column;justify-content: center;align-items: center;" >
			<image src="../../../../static/realName/noData.png" style="width: 100rpx;height: 120rpx;" mode=""></image>
			<view>暂无数据</view>
		</view>
		<u-list height="76vh" v-if="!isLoading&&listData.length>0">
			<u-list-item  v-for="(item, index) in listData" :key="index">
				<view class="list-item" @click="goEdit(item)">
					<view class="content-box">
						<view class="item-text" >
							<text class="label" style="font-weight: bold;">姓名：</text>
							<text class="info">{{item.name}}</text>
						<!-- 	<text class="info-right" style="color: green;" v-if="item.lightStatus==2">绿灯</text>
							<text class="info-right" style="color: yellow;" v-if="item.lightStatus==1">黄灯</text>
							<text class="info-right" style="color: red;" v-if="item.lightStatus==0">红灯</text> -->
						</view>
						<view class="item-text">
							<text class="label" style="font-weight: bold;">身份证：</text>
							<text class="info">{{item.idNumber}}</text>
						</view>
						<view class="item-text">
							<text class="label"style="font-weight: bold;">人脸采集：</text>
							<text class="info" style="color: #06E7A3;" v-if="item.facePhoto">已采集</text>
							<text class="info" style="color: red;" v-else>未采集</text>
						</view>
						<view class="item-text">
						 	<text class="label"style="font-weight: bold;">签名采集：</text>
							<text class="info" style="color: #06E7A3;" v-if="item.aotoPhoto">已采集</text>
							<text class="info" style="color: red;" v-else>未采集</text>						 
						</view>
					</view>
					<view style="width:94%;text-align: right;padding-right: 40rpx;color: #999;height: 80rpx;line-height: 80rpx;">
						重新采集
					</view>
					 
				</view>
			</u-list-item>
		</u-list>
	</view>
	
  </view>
</template>

<script>
import config from '@/config'
export default {
  data() {
    return {
		keyword:'',
		listData:[],
		number:0,
		isLoading:false
    }
  },
  onLoad() {
    console.log('?? ~ mounted ~ mounted-index:')  
  },
  onShow() {
  },
  methods: {
	//搜索
	searchList(value){
		this.loadList()
	},
	loadList(){
		if(this.keyword==""){
			uni.showToast({
				title: "请先输入人名",
				icon: 'none'
			})
		}else{
		let param={
			keyword:this.keyword
		}
		this.isLoading=true
		uni.request({
		  url: config.realAppUrl+'/BasePerson/selectBasePerson',
		  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.listData=res.data;
				this.number=res.data.length
				this.$forceUpdate()
				this.isLoading=false
				// console.log(this.listData)
			}else{
				uni.showToast({
					title: res.msg,
					icon: 'none'
				})
				this.isLoading=false
			}
		  },
		  fail: err => {
			console.log(err)
			this.isLoading=false
		  }
		})
		}
	},
	goEdit(item){
		console.log(item)
		uni.navigateTo({ 
			url: `/pages/realName/workbench/peopleLibrary/detail?idNumber=${item.idNumber}&workerType=${item.workerType}`
		})
	},
    // 返回
    leftClick() {
      console.log('返回')
      uni.navigateBack({
      	delta: 1 // 返回
      });
    }
  },

}
</script>

<style lang="scss">
.searchBtn{
	width: 120rpx;
	height:60rpx;
	line-height: 60rpx;
	text-align: center;
	border-radius: 10rpx;
	background-color: #00337A;
	color: #FFF;
	margin-left: 20rpx;
}
.page {
	width: 100vw;
	height: 100vh;
	background-color: #EFEFEF;
	box-sizing: border-box;
	// padding: 0 20px;
	.list-box{
		width: 90%;
		height: auto;
		// border: 1px solid #000;
		margin: 0rpx auto;
		
		.list-item{
			width: 100%;
			height: auto;
			background-color: #fff;
			border-radius: 20rpx;
			margin: 20rpx 0;
			
			.content-box{
				width: 100%;
				height: auto;
				padding: 10rpx 0;
				border-bottom: 1rpx solid #eee;
				
				.item-text{
					width: 95%;
					margin-left: 20rpx;
					margin-top: 15rpx;
					// display: flex;
					align-items: center;
					position: relative;
					.label{
						color: #999;
						font-weight: 500;
					}
					.info-right{
						position: absolute;
						top: 0rpx;
						right: 40rpx;
					}
					.info{
						color: #000;
					
					}
				}
			}
		}
	}
}
</style>
