<template>
	<view style="height: 100vh;" class=" ccc u-p-l-30 u-p-r-30 u-p-t-28 u-relative">
		<c-search @serbtn="serbtn()" />
		<view class="m-w u-m-t-34 ">
			<view class="m-w">
				<scroll-view class="m-w u-m-t-35 addscheight" :scroll-y="true">
						<block v-for="(item,index) in list" :key="index">
							<label @click="reove(item)" class="u-flex u-p-b-32 u-m-b-32 "
								style="border-bottom: 1px solid #E6E6E6;">
								<u-checkbox class="che" @click="reove(item)" :disabled="false" v-model="item.boll">
									{{item.name}}
								</u-checkbox>
							</label>
						</block>
				</scroll-view>
				<view @click="sumit" class="submit">确定</view>
			</view>
		</view>
	</view>
</template>

<script>
	import cSearch from '@/components/c-search/index.vue'
	import {
		syslist2
	} from '@/api/index.js'
	export default {
		components: {
			cSearch
		},
		data() {
			return {
				list: [],
				querform: {
					keyword: "",
					page: 1,
					size: 50,
				}
			}
		},
		onLoad() {
			this.init()
		},
		methods: {
			init() {
				syslist2(this.querform)
					.then(({
						data
					}) => {
						this.list = []
						data.list.forEach(Element => {
							this.list.push({
								boll: false,
								id: Element.id,
								name: Element.name
							})
						})
					})
			},
			reove(row) {
					row.boll = !row.boll
			},
			sumit() {
				let arr = [];
				this.list.forEach(Element => {
					if (Element.boll) {
						arr.push(
						{
							execUserId: Element.id,
							execUserName: Element.name
						}
						)
					}
				})
				this.$store.state.user.people = arr;
				uni.navigateBack(1)
			},
			serbtn({
				text
			}) {
				if (text == 10000000000) {
					this.querform.keyword = ""
				} else {
					this.querform.keyword = text
				}
				this.$nextTick(() => {
					this.init()
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.title-back {
		width: 10rpx;
		height: 38rpx;
		background: #4A8BFF;
	}

	.addscheight {
		height: calc(100vh - 315rpx);
	}
	.che {
		width: 100%;
	}
	
	.submit {
		width: 690rpx;
		height: 90rpx;
		background: #4A8BFF;
		border-radius: 4rpx;
		font-size: 28rpx;
		line-height: 90rpx;
		text-align: center;
		font-family: Microsoft YaHei-3970(82674968);
		font-weight: bold;
		color: #FFFFFF;
		margin-top: 50rpx;
	}
</style>
