<template>
	<el-container>
		<el-header>
			<div class="left-panel">
				<el-button
					type="primary"
					icon="el-icon-download"
					@click="tableExport"
					v-loading="exportLoading"
					>导出</el-button
				>
			</div>
			<div class="right-panel">
				<el-date-picker
					v-model="query.test_date"
					type="date"
					placeholder="选择日期"
					value-format="YYYY-MM-DD"
				/>
				<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
				id="myTable"
				:params="params"
				:query="query"
			>
				<el-table-column type="index" width="50" />
				<el-table-column
					label="物料名称"
					prop="material_name"
					show-overflow-tooltip
					min-width="100"
				>
				</el-table-column>
				<el-table-column
					label="编号"
					prop="batch"
					show-overflow-tooltip
					min-width="100"
				>
					<template #default="scope">
						＇{{ scope.row.batch }}
					</template>
				</el-table-column>
				<el-table-column label="抽样数量" prop="count">
				</el-table-column>
				<el-table-column label="合格数">
					<template #default="scope">
						{{ scope.row.count - scope.row.count_notok }}
					</template>
				</el-table-column>
				<el-table-column label="不合格数" prop="count_notok">
				</el-table-column>
				<el-table-column label="不合格原因" align="center">
					<el-table-column label="炸纹" prop="count_n_zw">
					</el-table-column>
					<el-table-column label="条纹" prop="count_n_tw">
					</el-table-column>
					<el-table-column label="气泡" prop="count_n_qp">
					</el-table-column>
					<el-table-column label="弯曲" prop="count_n_wq">
					</el-table-column>
					<el-table-column label="断裂" prop="count_n_dl">
					</el-table-column>
					<el-table-column label="偏壁" prop="count_n_pb">
					</el-table-column>
					<el-table-column label="大小头" prop="count_n_dxt">
					</el-table-column>
					<el-table-column label="气线" prop="count_n_qx">
					</el-table-column>
					<el-table-column label="结石" prop="count_n_js">
					</el-table-column>
					<el-table-column label="杂质" prop="count_n_zz">
					</el-table-column>
					<el-table-column label="颜色青" prop="count_n_ysq">
					</el-table-column>
					<el-table-column label="划伤" prop="count_n_hs">
					</el-table-column>
					<el-table-column label="扁" prop="count_n_b">
					</el-table-column>
					<el-table-column label="其他" prop="count_n_qt">
					</el-table-column>
				</el-table-column>
				<el-table-column label="检测结果" prop="is_testok">
					<template #default="scope">
						<el-tag type="success" v-if="scope.row.is_testok"
							>合格</el-tag
						>
						<el-tag type="danger" v-else>不合格</el-tag>
					</template>
				</el-table-column>
				<el-table-column label="检测时间" prop="test_date">
				</el-table-column>
				<el-table-column label="检测人" prop="test_user_name">
				</el-table-column>
				<el-table-column label="物料id">
					<template #default="scope">
						＇{{ scope.row.material }}
					</template>
				</el-table-column>
			</scTable>
		</el-main>
	</el-container>
</template>
<script>
export default {
	name: "rparty",
	data() {
		return {
			apiObj: this.$API.inm.mioitem.list,
			query: {
				page: 1,
				page_size: 20,
			},
			params: {
				page: 1,
				page_size: 20,
				mio__state: 20,
				mio__type: "do_in",
				test_date__isnull: 0,
			},
			selection: [],
			state_: {
				10: "",
				20: "",
			},
			exportLoading: false,
		};
	},
	mounted() {},
	methods: {
		handleQuery() {
			this.$refs.table.queryData(this.query);
		},
		resetQuery() {
			this.query = {};
		},
		tableExport() {
			this.exportLoading = true;
			this.$XLSX("#myTable", "库存检验记录");
			this.exportLoading = false;
		},
	},
};
</script>
