<template>
	<div>
		<el-dialog :visible.sync="dialogVisible" width="300px" height="500px">
			<el-button size="mini" type="primary" @click="handleConfirm">确定</el-button>
			<el-tree :data="dataTree" :props="defaultProps" node-key="id" @node-click="handleNodeClick" default-expand-all
			 :expand-on-click-node="false">
			</el-tree>
		</el-dialog>
	</div>
</template>

<script>
	import axios from '@/axios';

	export default {
		data() {
			return {
				dataTree: [],
				defaultProps: {
					children: 'children',
					label: function(data, node) {
						return data.sysDepartment.deptName;
					},
				},
				dialogVisible: false,
				data: {},
				node:{}
			};
		},
		methods: {
			// 获取table数据
			getDataTree() {
				//console.log("获取table数据getDataTree")
				var url = 'SysDepartment/queryDeptTree.do'
				var param = {}
				axios.get(url, param).then(response => {
					this.dataTree = response.data.data
					
				});
			},
			handleNodeClick(data) {
				//console.log(JSON.stringify(data))
				this.node = data.sysDepartment
			},
			show() {
				this.getDataTree()
				this.dialogVisible = true
			},
			handleConfirm() {
				this.$emit('receviceFromChild', this.node);
				this.dialogVisible = false
			},
		}
	}
</script>

<style>

</style>
