<template>
	<div>
		<el-dialog  title="所属单位" :visible.sync="dialogVisible" :width="width" :height="height">
			<el-form :inline="true" :model="query" label-position="right" label-width="100px" size="small">
				<el-form-item label="代理商编码">
					<el-input v-model="query.agentCd" style="width:140px;">
					</el-input>
				</el-form-item>
				<el-form-item label="代理商名称">
					<el-input v-model="query.agentNm" style="width:180px;">
					</el-input>
				</el-form-item>
				<el-button size="mini" type="primary" plain @click="search">查询</el-button>
			</el-form>
			<el-table :data="tableData" stripe border style="width: 99%;">
				<el-table-column prop="id" label="编码" v-if="isShow">
				</el-table-column>
				<el-table-column prop="agentCd" label="代理商编码">
				</el-table-column>
				<el-table-column prop="agentNm" label="代理商名称">
				</el-table-column>
				<el-table-column label="操作">
					<template slot-scope="scope">
						<el-button size="mini" type="danger" @click="sendToParent(scope.row)">选择</el-button>
					</template>
				</el-table-column>
			</el-table>
			<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
			 :page-sizes="pageSizes" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="totalRows">
			</el-pagination>

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

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

	export default {
		props: {
			tableProperty: [],
			url: '',
			width: '',
			height: ''
		},
		data() {
			return {
				tableData: [],
				currentPage: 1,
				totalRows: 0,
				pageSizes: [10, 20, 30, 40],
				pageSize: 10,
				query: {
					agentCd: '',
					agentNm: '',
				},
				isShow: false,
				dialogVisible: false,
			};
		},
		methods: {
			getTableData() {
				var url = 'SysUser/queryAttr1.do'
				var param = {
					page: this.currentPage,
					rows: this.pageSize,
					agentCd: this.query.agentCd,
					agentNm: this.query.agentNm,
				}
				
				axios.get(url, param).then(response => {

					this.tableData = response.data.data.list
					this.totalRows = response.data.data.total
					if (response) {
						this.loading = false
					} else {
						this.loading = true
					}
				});
			},
			// 修改每页行数
			handleSizeChange(val) {
				this.pageSize = val
				this.getTableData()
			},
			// 修改当前页事件
			handleCurrentChange(val) {
				this.currentPage = val
				this.getTableData()
			},
			sendToParent: function(row) {
				this.$emit('receviceFromChild', row);
				this.dialogVisible = false
			},
			show() {
				console.log('-------2222')
				this.dialogVisible = true
				this.getTableData()
				
			},
			search() {
				this.getTableData()

			}
		},
		mounted() {
			this.getTableData()
		}
	}
</script>
