<template>
	<!-- @rightClick 只有存在右边部分的情况下才使用,
	 右边默认为空,可以使用slot="right" 自定义右边内容
	 @ok 是单选或多选最终返回的结果
	 types 类型 radio或checkbox
	 titleKeys 标题对应的字段名称key,默认是name
	 listData 是数据
	 showArrow 是否显示右边箭头
	 backValue 设置返回的数据是idArr [id,id,...] 或 objArr [obj,obj,...]
	 defValue 设置已选择的数据,格式和backValue 一致
	 checkIconPositon 选择图标显示左边还是右边 left or right
	 -->
	<uni-check-list 
	:listData="list" 
	checkIconPositon="right" 
	:showArrow="false" 
	:defValue="value" 
	:types="type" 
	:status="status"
	:noDataText="noDataText"
	backValue="objArr"
	@ok="chooseOk">
	</uni-check-list>
</template>

<script>
	import {findUserList} from '@/api/user.js'
	export default {
		data() {
			return {
				list: [],
				value: [],
				noDataText: '暂无抄送人数据',
				type: '',  // 单选或多选
				status: 'loading'
			}
		},
		onLoad(opts) {
			this.value = opts.item&&JSON.parse(opts.item)||[]
			this.type = opts.type && opts.type || 'checkbox'
			console.log(this.value)
			// 查询用户列表
			this.status = 'loading'
			uni.showLoading({
				title: '加载中...'
			})
			findUserList({loginFlag:'1'}).then(res=>{
				if(res.status == 200){
					this.list = res.data || []
				} else {
					this.noDataText = res.message
				}
				this.status = 'nomore'
				uni.hideLoading()
			})
		},
		methods: {
			// 选中门店,item 返回的是数组
			chooseOk(item) {
				console.log(item)
				//关闭当前页面,这里处理数据逻辑
				uni.$emit("selKpUsers",item)
				uni.navigateBack()
			},
		}
	}
</script>

<style lang="scss">
	page{
		height: 100%;
	}
</style>