<template>
	<div>
		<el-dialog title="添加信息" :visible.sync="dialogVisible" width="800px">
			<el-row>
				<el-col :span="4">
			<el-button type="success" @click="handleConfirm" style="width: 200px;">确定</el-button>
			 
			</el-col>
			</el-row>
			
			<el-row>
				<el-col :span="10">
					<div class="tree-container" style="width: 300px; padding-right: 50px;">
						<el-tree :data="dataTree" :props="defaultProps" node-key="id" :expand-on-click-node="false" @node-click="handleNodeClick"
						 default-expand-all>
						</el-tree>
					</div>
				</el-col>
				<el-col :span="14">
					<div class="dialog-table-container" style="padding-left: 150px;width: 271px;">
						<el-table :data="tableData" border highlight-current-row @row-click="handleRowClick">
							<el-table-column prop="id" label="编号" width="60" v-if="isShow">
							</el-table-column>
							<el-table-column prop="userName" label="用户姓名" width="150">
							</el-table-column>
							<el-table-column prop="userDesc" label="姓名" width="120">
							</el-table-column>
						</el-table>
					</div>
				</el-col>
			</el-row>
		</el-dialog>
	</div>
</template>

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

	export default {
		data() {
			return {
				dataTree: [],
				defaultProps: {
					children: 'children',
					label: 'text'
				},
				tableData: [],
				dialogVisible: false,
				user:{},
				isShow:false
			};
		},
		methods: {
			getDataTree() {
				//console.log("获取table数据getDataTree")
				var url = 'SysDepartment/queryTree.do?fid=0'
				var param = {}
				axios.get(url, param).then(response => {
					this.dataTree = response.data
				});
			},
			handleNodeClick(data) {
				//this.deptId = data.id
				//this.deptName = data.text
				this.getTableData(data.id)
			},
			getTableData(deptId) {
				var url = '/SysUser/queryByDept.do'
				var param = {
					deptId: deptId,
				}
				axios.get(url, param).then(response => {
					this.tableData = response.data.data
				});
			},
			handleRowClick(row) {
				this.user = row
			},
			show() {
				this.getDataTree()
				this.dialogVisible = true
			},
			handleConfirm() {
				this.$emit('receviceFromChild',this.user);
				this.dialogVisible = false
			},
		}
	}
</script>

<style>

</style>
