<template>
	<div>
		<el-dialog   :visible.sync="dialogVisible" :width="width" :height="height">
			<el-row :gutter="10">
				<el-col :span="10">
					<el-input   v-model="queryParam"></el-input>
				</el-col>
				<el-col :span="2">
					<el-button size="mini" type="primary" @click="search">查询</el-button>
				</el-col>
			</el-row>

			<el-table :data="tableData" highlight-current-row border>
				<el-table-column v-for="item in tableProperty" :key="item.id" :prop="item.tableProp" :label="item.tableLabel"
				 :width="item.tableWidth"  v-if="item.isShow==='0'">
				</el-table-column>
				<el-table-column label="操作" :width="100">
					<template slot-scope="scope">
						<el-button size="mini" type="danger" @click="sendToParent(scope.row)">选择</el-button>
					</template>
				</el-table-column>
			</el-table>

		</el-dialog>
	</div>
</template>

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

	export default {
		props: {
			tableProperty: [ ],
			url: '',
			width: '',
			height: ''
		},
		data() {
			return {
				tableData: [],
				queryParam: '',
				dialogVisible: false,
			};
		},
		methods: {
			getTableData() {
				var url = this.url
				var param = {
					queryParam: this.queryParam,
				}
				axios.get(url, param).then(response => {
					if (response.data.code == '0') {
						this.tableData = response.data.data
					} else {
						this.$message({
							type: 'error',
							message: '操作失败!' + response.data.msg
						});
					}
				});
			},
			search() {
				this.getTableData()
			},

			show() {
				this.dialogVisible = true
			},
			sendToParent: function(row) { //传参方法
				//console.log("sendToParent" + row)
				this.$emit('receviceFromChild', row);
				this.dialogVisible = false

			}
			// 			//查询table列
			// 			getTableProperty() {
			// 				//console.log("获取table数据getTableData")
			// 				var url = 'CodeMachine/queryTableProperty.do'
			// 				var param = {
			// 					bussinessName: 'T_MAINT_CUSTOMER'
			// 				}
			// 				axios.get(url, param).then(response => {
			// 					this.tableProperty = response.data
			// 				});
			// 			},

		}
	}
</script>

<style>

</style>
