<template>
	<div>
		<el-dialog  title="物料" :visible.sync="dialogVisible" width="500" height="400">
			<el-form :inline="true" :model="query" label-position="right" label-width="100px" size="small">
				<el-form-item label="物料">
					<el-input v-model="query.material" style="width:140px;">
					</el-input>
				</el-form-item>
				<el-form-item label="钢种">
					<el-input v-model="query.standard" 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="name" label="物料名称" width="120">
				</el-table-column>
				<el-table-column prop="standard" label="种类" width="120">
				</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: {
		
		},
		data() {
			return {
				tableData: [],
				currentPage: 1,
				totalRows: 0,
				pageSizes: [10, 20, 30, 40],
				pageSize: 10,
				query: {
					material: '',
					standard: '',
				},
				isShow: false,
				dialogVisible: false,
			};
		},
		methods: {
			getTableData() {
				var url = 'MaintMaterial/query.do'
				var param = {
					page: this.currentPage,
					rows: this.pageSize,
					material: this.query.material,
					standard: this.query.standard,
				}
				axios.get(url, param).then(response => {
					if (response.data.code == 0) {
						this.tableData = response.data.data.list
						this.totalRows = response.data.data.total
					} else {
						this.$message({
							type: 'error',
							message: '失败！' + response.data.msg,
						});
					}
				});
			},
			// 修改每页行数
			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() {
				this.dialogVisible = true
				this.getTableData()
			},
			search() {
				this.currentPage = 1
				this.getTableData()

			}
		},
		mounted() {
			 
		}
	}
</script>
