<template>
	<el-container>
		<el-header>
			<div class="left-panel">
				<el-button type="primary" icon="el-icon-download" v-loading="exportLoading" @click="exportExcel">导出</el-button>
			</div>
			<div class="right-panel">
				<el-select
					v-model="query.mgroup"
					clearable
					style="width: 150px"
				>
					<el-option
						v-for="item in mgroupOption"
						:key="item.id"
						:label="item.name"
						:value="item.id"
					>
					</el-option>
				</el-select>
				<el-date-picker
					v-model="query.handle_date"
					type="date"
					placeholder="选择日期"
					value-format="YYYY-MM-DD"
					style="width: 150px"
				/>
				<el-input
					v-model="query.search"
					placeholder="批次号"
					clearable
					style="width: 150px"
				></el-input>
				<el-button type="primary" @click="materialsChoses()"
					>选择物料</el-button
				>
				<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"
				:query="query"
			>
				<el-table-column type="index" width="50" />
				<el-table-column
					label="物料"
					prop="material_out_name"
					show-overflow-tooltip
					min-width="120"
				>
				</el-table-column>
				<el-table-column label="工序" prop="mgroup_name">
				</el-table-column>
				<el-table-column label="生产数" prop="count_real">
				</el-table-column>
				<el-table-column label="合格数" prop="count_ok">
				</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_hs">
					</el-table-column>
					<el-table-column label="挫伤" prop="count_n_zs">
					</el-table-column>
					<el-table-column label="杂质" prop="count_n_zz">
					</el-table-column>
					<el-table-column label="条纹" prop="count_n_tw">
					</el-table-column>
					<el-table-column label="短" prop="count_n_d">
					</el-table-column>
					<el-table-column label="锥度大" prop="count_n_zds">
					</el-table-column>
					<el-table-column label="气泡" prop="count_n_qp">
					</el-table-column>
					<el-table-column label="不亮" prop="count_n_bl">
					</el-table-column>
					<el-table-column label="横纹" prop="count_n_hw">
					</el-table-column>
					<el-table-column label="有皮" prop="count_n_yp">
					</el-table-column>
					<el-table-column label="爆皮" prop="count_n_bp">
					</el-table-column>
					<el-table-column label="色差" prop="count_n_sc">
					</el-table-column>
					<el-table-column label="炸纹" prop="count_n_zw">
					</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_tydd">
					</el-table-column>
					<el-table-column label="水雾" prop="count_n_sw">
					</el-table-column>
					<el-table-column label="壁厚偏差大" prop="count_n_bhpcd">
					</el-table-column>
					<el-table-column label="其他" prop="count_n_qt">
					</el-table-column>
				</el-table-column>
				<el-table-column label="班组" prop="shift_name">
				</el-table-column>
				<el-table-column
					label="所属车间"
					prop="belong_dept_name"
					show-overflow-tooltip
				>
				</el-table-column>
				<el-table-column label="操作时间" prop="handle_date">
				</el-table-column>
				<el-table-column label="处理人" prop="handle_user_name">
				</el-table-column>
			</scTable>
		</el-main>
		<el-dialog title="选择物料" v-model="materialsVisible" width="90%">
			<materials
				style="height: 500px"
				ref="materialsChose"
				@choseChange="choseChange"
			></materials>
		</el-dialog>
	</el-container>
</template>
<script>
import materials from "./../mtm/materials.vue";
export default {
	components: {
		materials,
	},
	name: "rparty",
	data() {
		return {
			apiObj: this.$API.wpm.mlog.list,
			query: {
				search: "",
				material: "",
				mgroup: "",
				handle_date: "",
			},
			selection: [],
			state_: {
				10: "",
				20: "",
			},
			mgroupOption: [],
			exportLoading:false,
			materialsVisible: false,
		};
	},
	mounted() {
		this.getMgroup();
	},
	methods: {
		materialsChoses() {
			this.materialsVisible = true;
		},
		choseChange(data) {
			this.query.material = data;
			this.$refs.table.queryData(this.query);
			this.materialsVisible = false;
		},
		getMgroup() {
			this.$API.mtm.mgroup.list.req({ page: 0 }).then((res) => {
				this.mgroupOption = res;
			});
		},
		handleQuery() {
			this.$refs.table.queryData(this.query);
		},
		resetQuery() {
			this.query = {};
		},
		exportExcel() {
            this.exportLoading = true;
            this.$XLSX('#myTable',"过程自检记录表")
            this.exportLoading = false;
        },
	},
};
</script>
