<template>
	<view>
		<cu-custom bgColor="bg-gradual-pink" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">组织架构</block>
		</cu-custom>
		<xiaolu-tree  :checkList="checkList"  v-if="tree.length>0"  :props="prop" @sendValue="confirm"  :isCheck="true" :treeNone="tree"></xiaolu-tree>
		
	</view>
</template>

<script>
	import api from '@/api/api'
	import XiaoluTree from'@/components/xiaolu-tree/tree.vue'
	export default {
		components: {
			XiaoluTree
		},
		data() {
			return {
				data:[],
				userUrl:'/sys/user/departList',
				departName:'',
				orgName:'',
				tree: [],
				checkList: [],
				backList: this.checkList,
				prop:{
				label: 'name',
				children: 'children',
				multiple:true,
				},
				max: 5,	
			}
			},
			created(){
				this.querydepartName()
				uni.setStorageSync("orgType",2);
			},
			onLoad(option) {
				 let { prop,arr } = option
				 // #ifdef H5
				let checkList = JSON.parse(decodeURIComponent(arr));
				// #endif
				// #ifdef MP-QQ||MP-WEIXIN||APP-NVUE||APP-PLUS
				let checkList = JSON.parse(arr);
				// #endif
				this.prop = JSON.parse(prop)
				this.checkList = checkList;
				//this.tree=treeNode;//树形数据赋值
				//this.querydepartName();
			},
			methods:{
				confirm(val,back) {
					if(back){
						this.backConfirm(val)
						return
					}
					this.backList = val;
				},
				
				// 返回上一页传参
				 backConfirm(val) {
					uni.$emit('selectSuccess',{list:val})
					uni.navigateBack();
				},
				
				querydepartName(s){
					this.$http.get(this.userUrl,{params:{departName:s}}).then(res=>{
						console.log("res",res)
						 this.tree=res.data.departName;
						 //this.orgName=res.data.orgName;
						
					}).catch(err => {
						console.log(err);
					});
				},
			
				
			}
			
	}
	
	
</script>

<style>
	.ins{
		background-color: #F1F1F1;
		width: 90%;
		height: 30px;
		margin:0 auto;
		border-radius:5px 5px 5px 5px; 
		margin-top: 20px;
		
	}
	.s{
		list-style-type:none;
		margin-left: -40px;
	}
	
	.imgs{
		width: 15px;
		height: 15px;
		float: right;
	}
	
	.top{
		  background-color: #5677AC;
		  width: 100%;
		  height: 40px;
		 
	}
</style>
