<template>
	<view class="list-body">
		<uni-nav-bar @clickLeft="goBack()" class="nav-bar" height="110rpx" leftWidth="200rpx" leftText="人员选择"
			leftIcon="left" border backgroundColor="#2cade8" color="#fff" fixed statusBar shadow></uni-nav-bar>
		<view class="apply-info">
			<checkbox-group @change="checkboxChange">
				<label class="uni-list-cell uni-list-cell-pd" v-for="row in userRange" :key="row.value">
					<view>
						<checkbox :value="row.value" :checked="row.checked" />
					</view>
					<view>
						<view class="name">姓名：{{row.name}}</view>
						<view class="tel">手机号：{{row.phone}}</view>
						<view class="tel">身份证号：{{row.id_number}}</view>
					</view>
				</label>
			</checkbox-group>
			<view class="row" v-for="(row,index) in userRange" :key="index" @tap="select(row)">
				<view class="center">
					<view class="name-tel">
						<view class="name">姓名：{{row.name}}</view>
						<view class="tel">手机号：{{row.phone}}</view>
						<view class="tel">身份证号：{{row.id_number}}</view>
					</view>
				</view>
				<view class="right">
					<view class="icon bianji" @tap.stop="edit(row)">
					</view>
				</view>
			</view>
			<button type="primary" class="select">选择人员</button>
			<view style="position: fixed;width: 100vw;height: 100vh;background-color: rgba(0,0,0,.3);top: 0;left: 0;z-index: 101;">
				<view style="width: 80vw;position: absolute;top: 50%;margin: auto;background-color: #ffffff;left: 10vw;transform: translateY(-50%);">
					<view>选择来访人员</view>
					<form @submit="formSubmit">
						<view class="uni-form-item uni-column">
							<view class="title">访客</view>
							<uni-data-select :localdata="userRange">
							</uni-data-select>
						</view>
						<view class="uni-form-item uni-column">
							<view class="title">是否主访客</view>
							<view>
								<switch name="switch" />
							</view>
						</view>
						<view class="uni-btn-v">
							<button class="mini-btn" type="primary" size="mini" form-type="submit">确定</button>
						</view>
					</form>
				</view>
			</view>
		</view>
		<button type="primary" class="add" @click="add">新增人员</button>
	</view>
</template>

<script>
	export default {
		name: "userList",
		data() {
			return {
				formData: {
					name: '',
				},
				userRange: [{
					id: "1553943890468409344",
					name: "一一",
					phone: "1",
					photo: null,
					id_number: "",
					employee: null,
					visit: null,
				}, {
					id: "1547149802700148736",
					name: "test3",
					phone: "13112340003",
					photo: "/media/2022/07/13/微信图片_20220713172755.jpg",
					id_number: "371324198302029824",
					employee: "1547406632219185152",
					visit: "1547754231795159040"
				}],
			}
		},

		onShow() {
			// this.getUserRange();
		},
		methods: {
			//获取用户
			getUserRange() {
				let that = this;
				this.$u.api.vmVisitor({
					page: 0
				}).then(res => {
					that.userRange = [];
					res.forEach(item => {
						let obj = {};
						obj = item;
						obj.checked = false;
						that.userRange.push(obj)
					})

				})
			},
			select(row) {},
			goBack() {
				uni.navigateBack({
					delta: 1
				})
			},

			add() {
				uni.navigateTo({
					url: '/pages/workSpace/newWork/addUser'
				})
			},
			edit(row) {},
		}
	}
</script>

<style>
	>>>.uni-navbar__header,
	>>>.uni-status-bar {
		background-image: linear-gradient(90deg, #164cc3 0%, #2c6fd9 100%), linear-gradient(#e60012, #e60012) !important;
	}

	.list-body {
		background-color: #f3fbff;
		padding-bottom: 113px;
	}

	.apply-info {
		min-height: 70vh;
		width: 710upx;
		margin: 0 auto;
		background-color: #FFFFFF;
		border-radius: 5px;
		padding: 12px 16px;
		box-sizing: border-box;
		margin-top: 12px;
	}

	.row {
		padding: 10upx;
		margin-bottom: 20upx;
		border-bottom: 1upx solid #eeeeee;
	}

	.uni-list-cell {
		display: flex;
		padding: 10upx;
		margin-bottom: 20upx;
		border-bottom: 1upx solid #eeeeee;
	}

	.add {
		width: 50px;
		height: 50px;
		border-radius: 25px;
		line-height: 50px;
		box-shadow: 0 0 6px 2px rgba(0, 0, 0, .3);
		z-index: 100;
		position: fixed;
		bottom: 100px;
		right: 20px;
	}

	.select {
		margin: auto;
		box-shadow: 0upx 5upx 10upx rgba(0, 0, 0, 0.4);
		width: 400rpx;
		height: 80rpx;
		line-height: 80rpx;
		font-size: 30rpx;
	}

	.save-btn {
		height: 80rpx;
		color: #fff;
		font-size: 30upx;
		justify-content: center;
		align-items: center;
	}
</style>
