<template>
	<el-container>
		<el-header>
			<div class="left-panel">
			</div>
			<div class="right-panel">
				<el-input
					v-model="query.batch"
					placeholder="批次号"
					clearable
					style="width: 150px"
				></el-input>
				<el-button
					type="primary"
					icon="el-icon-search"
					@click="handleQuery"
					>查询</el-button
				>
			</div>
		</el-header>
		<el-main class="nopadding">
			<scTable
				ref="table"
				:apiObj="apiObj"
				row-key="id"
				stripe
				:params="query"
				:query="query"
			>
				<el-table-column type="index" width="50" />
				<el-table-column label="日期" prop="test_date"></el-table-column>
				<el-table-column label="批次号" prop="batch"> </el-table-column>
				<el-table-column label="物料名" prop="material_name" show-overflow-tooltip min-width="150"> </el-table-column>
				<el-table-column label="总数" prop="count"> </el-table-column>
				<el-table-column label="抽检数" prop="count_sampling"> </el-table-column>
				<el-table-column label="抽检合格数" prop="count_sampling_ok"> </el-table-column>
				<el-table-column label="合格数" prop="count_ok"> </el-table-column>
				<el-table-column label="不合格数" prop="count_notok"> </el-table-column>
			</scTable>
		</el-main>
		<check-dialog
			ref="checkDialogs"
			v-if="dialog.check"
			:materialCate="materialCate"
			:ftestWork="ftestWork"
			@closed="handleCheckClose"
		>
		</check-dialog>
	</el-container>
</template>
<script>
import checkDialog from "./productCheck.vue";
export default {
	name: "product_middle",
	components: {
		checkDialog,
	},
	data() {
		return {
			apiObj: this.$API.qm.ftestwork.list,
			query: {
				batch:''
			},
			dialog: {
				check: false,
			},
			ftestWork:'',
			materialCate:'',
			selection: [],
			exportLoading:false,
		};
	},
	methods: {
		handleQuery() {
			this.$refs.table.queryData(this.query);
		},
		resetQuery() {
			this.query = {};
		},
		table_check(row) {
			let that = this;
			that.materialCate = row.material_cate;
			that.ftestWork = row.id;
			that.dialog.check = true;
			this.$nextTick(() => {
				this.$refs.checkDialogs.open();
			});
		},
		exportExcel() {
            this.exportLoading = true;
            this.$XLSX('#myTable', "成品检验表")
            this.exportLoading = false;
        },
	},
};
</script>
