<template>
	<el-container>
		<el-header>
			<div class="right-panel">
				<el-input v-model="query.batch" 
				placeholder="批次号" 
				clearable 
				style="width: 200px;"
				></el-input>
				<el-select 
					v-model="query.shiftcc" 
					placeholder="尺寸班次"
					style="width: 130px;"
					:clearable="true"
				>
					<el-option 
						v-for="item in shiftOptions"
						:label="item.name" 
						:value="item.name"
					 	:key="item.id"
					></el-option>
				</el-select>
				<el-select 
					v-model="query.shiftwg" 
					placeholder="外观班次"
					style="width: 130px;"
					:clearable="true"
				>
					<el-option 
						v-for="item in shiftOptions"
						:label="item.name" 
						:value="item.name"
					 	:key="item.id"
					></el-option>
				</el-select>
				<el-date-picker
					v-model="query.cc_data_start"
					type="date"
					placeholder="尺寸检验开始日期"
					value-format="YYYY-MM-DD"
					clearable
					style="width: 130px; margin: 5px"
				></el-date-picker>
				<el-date-picker
					v-model="query.cc_data_end"
					type="date"
					placeholder="尺寸检验结束日期"
					value-format="YYYY-MM-DD"
					clearable
					style="width: 130px; margin:0"
				></el-date-picker>
				<el-date-picker
					v-model="query.wg_data_start"
					type="date"
					placeholder="外观检验开始日期"
					value-format="YYYY-MM-DD"
					clearable
					style="width: 130px; margin: 5px"
				></el-date-picker>
				<el-date-picker
					v-model="query.wg_data_end"
					type="date"
					placeholder="外观检验结束日期"
					value-format="YYYY-MM-DD"
					clearable
					style="width: 130px; margin:0"
				></el-date-picker>
				<el-date-picker
					v-model="query.fx_data_start"
					type="date"
					placeholder="返修开始日期"
					value-format="YYYY-MM-DD"
					clearable
					style="width: 130px; margin: 5px"
				></el-date-picker>
				<el-date-picker
					v-model="query.fx_data_end"
					type="date"
					placeholder="返修结束日期"
					value-format="YYYY-MM-DD"
					clearable
					style="width: 130px; margin:0"
				></el-date-picker>
				<el-button
					type="primary"
					icon="el-icon-search"
					@click="handleQuery"
				></el-button>
				<el-button
					@click="handleExport"
					class="tables"
					type="primary"
				>导出</el-button>
			</div>
		</el-header>
		<el-main class="nopadding">
			<el-table
				ref="table"
				:data="tableData"
				id="exportDiv"
				stripe
				class="totalFooterTable"
				style="height: 100%;"
				:summary-method="getSummaries" 
				show-summary
			>
				<el-table-column label="批次号" prop="batch" min-width="240" fixed="left">
					<template  #default="scope"><span>{{ scope.row.data.批次号 }}</span></template>
				</el-table-column>
				<el-table-column label="工艺" prop="gongyi" fixed="left">
				</el-table-column>
				<el-table-column label="尺寸检验" align="center" class-name="colorheader1">
					<el-table-column label="日期" class-name="colorheader1" width="90">
						<template  #default="scope"><span>{{ scope.row.data.尺寸检验_日期 }}</span></template>
					</el-table-column>
					<el-table-column label="班次" class-name="colorheader1" width="60">
						<template  #default="scope"><span>{{ scope.row.data.尺寸检验_班次 }}</span></template>
					</el-table-column>
					<el-table-column label="检验人" class-name="colorheader1">
						<template  #default="scope"><span>{{ scope.row.data.尺寸检验_操作人 }}</span></template>
					</el-table-column>
					<el-table-column label="检验数" class-name="colorheader1">
						<template  #default="scope"><span>{{ scope.row.data.尺寸检验_count_real }}</span></template>
					</el-table-column>
					<el-table-column label="黑圈内径" class-name="colorheader1">
						<template  #default="scope"><span>{{ scope.row.data.尺寸检验_缺陷_黑圈内径 }}</span></template>
					</el-table-column>
					<el-table-column label="比例(%)" class-name="colorheader1">
						<template  #default="scope"><span>{{ scope.row.data.尺寸检验_缺陷_黑圈内径_比例 }}</span></template>
					</el-table-column>
					<el-table-column label="黑圈外径" class-name="colorheader1">
						<template  #default="scope"><span>{{ scope.row.data.尺寸检验_缺陷_黑圈外径 }}</span></template>
					</el-table-column>
					<el-table-column label="比例(%)" class-name="colorheader1">
						<template  #default="scope"><span>{{ scope.row.data.尺寸检验_缺陷_黑圈外径_比例 }}</span></template>
					</el-table-column>
					<el-table-column label="产品同心度" class-name="colorheader1">
						<template  #default="scope"><span>{{ scope.row.data.尺寸检验_缺陷_产品同心度 }}</span></template>
					</el-table-column>
					<el-table-column label="比例(%)" class-name="colorheader1">
						<template  #default="scope"><span>{{ scope.row.data.尺寸检验_缺陷_产品同心度_比例 }}</span></template>
					</el-table-column>
					<el-table-column label="圆度" class-name="colorheader1">
						<template  #default="scope"><span>{{ scope.row.data.尺寸检验_缺陷_圆度 }}</span></template>
					</el-table-column>
					<el-table-column label="比例(%)" class-name="colorheader1">
						<template  #default="scope"><span>{{ scope.row.data.尺寸检验_缺陷_圆度_比例 }}</span></template>
					</el-table-column>
					<el-table-column label="产品外径小" class-name="colorheader1">
						<template  #default="scope"><span>{{ scope.row.data.尺寸检验_缺陷_产品外径小 }}</span></template>
					</el-table-column>
					<el-table-column label="产品外径大(返修)" class-name="colorheader1">
						<template  #default="scope"><span>{{ scope.row.data['尺寸检验_缺陷_产品外径大(返修)'] }}</span></template>
					</el-table-column>
					<el-table-column label="黑圈缺口" class-name="colorheader1">
						<template  #default="scope"><span>{{ scope.row.data.尺寸检验_缺陷_黑圈缺口 }}</span></template>
					</el-table-column>
					<el-table-column label="外径发货片(B)" class-name="colorheader1">
						<template  #default="scope"><span>{{ scope.row.data['尺寸检验_缺陷_外径发货片(B)'] }}</span></template>
					</el-table-column>
					<el-table-column label="前道崩" class-name="colorheader1">
						<template  #default="scope"><span>{{ scope.row.data.尺寸检验_缺陷_前道崩 }}</span></template>
					</el-table-column>
					<el-table-column label="合格数" class-name="colorheader1">
						<template  #default="scope"><span>{{ scope.row.data.尺寸检验_count_ok_full }}</span></template>
					</el-table-column>
					<el-table-column label="合格率(%)" class-name="colorheader1">
						<template  #default="scope"><span>{{ scope.row.data.尺寸检验_完全合格率 }}</span></template>
					</el-table-column>
					<el-table-column label="准合格(B)" class-name="colorheader1">
						<template  #default="scope"><span>{{ scope.row.data['尺寸检验_缺陷_准合格(B)'] }}</span></template>
					</el-table-column>
					<el-table-column label="圆度准合格" class-name="colorheader1">
						<template  #default="scope"><span>{{ scope.row.data['尺寸检验_缺陷_圆准(B)'] }}</span></template>
					</el-table-column>
					<el-table-column label="总合格数" class-name="colorheader1">
						<template  #default="scope"><span>{{ scope.row.data.尺寸检验_count_ok }}</span></template>
					</el-table-column>
					<el-table-column label="总合格率(%)" class-name="colorheader1">
						<template  #default="scope"><span>{{ scope.row.data.尺寸检验_合格率 }}</span></template>
					</el-table-column>
				</el-table-column>
				<el-table-column label="外观检验" align="center" class-name="colorheader2">
					<el-table-column label="日期" class-name="colorheader2" width="90">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_日期 }}</span></template>
					</el-table-column>
					<el-table-column label="班次" class-name="colorheader2" width="60">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_班次 }}</span></template>
					</el-table-column>
					<el-table-column label="检验人" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_操作人 }}</span></template>
					</el-table-column>
					<el-table-column label="检验数" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_count_real }}</span></template>
					</el-table-column>
					<el-table-column label="合格数" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_count_ok_full }}</span></template>
					</el-table-column>
					<el-table-column label="合格率(%)" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_完全合格率 }}</span></template>
					</el-table-column>
					<el-table-column label="划麻(返修)" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data['外观检验_缺陷_划麻(返修)'] }}</span></template>
					</el-table-column>
					<el-table-column label="比例(%)" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data['外观检验_缺陷_划麻(返修)_比例'] }}</span></template>
					</el-table-column>
					<el-table-column label="脏(返修)" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data['外观检验_缺陷_脏(返修)']}}</span></template>
					</el-table-column>
					<el-table-column label="比例(%)" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data['外观检验_缺陷_脏(返修)_比例'] }}</span></template>
					</el-table-column>
					<el-table-column label="气泡" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_缺陷_气泡 }}</span></template>
					</el-table-column>
					<el-table-column label="比例(%)" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_缺陷_气泡_比例 }}</span></template>
					</el-table-column>
					<el-table-column label="浅气泡(B)" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data['外观检验_缺陷_浅气泡(B)'] }}</span></template>
					</el-table-column>
					<el-table-column label="黑圈变形" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_缺陷_黑圈变形 }}</span></template>
					</el-table-column>
					<el-table-column label="黑圈缺口" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_缺陷_黑圈缺口 }}</span></template>
					</el-table-column>
					<el-table-column label="重水纹" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_缺陷_重水纹 }}</span></template>
					</el-table-column>
					<el-table-column label="浅水纹(B)" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data['外观检验_缺陷_浅水纹(B)'] }}</span></template>
					</el-table-column>
					<el-table-column label="大崩" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_缺陷_大崩 }}</span></template>
					</el-table-column>
					<el-table-column label="小崩边(B)" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data['外观检验_缺陷_小崩边(B)'] }}</span></template>
					</el-table-column>
					<el-table-column label="比例(%)" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data['外观检验_缺陷_小崩边(B)_比例'] }}</span></template>
					</el-table-column>
					<el-table-column label="棕点" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_缺陷_棕点 }}</span></template>
					</el-table-column>
					<el-table-column label="浅划麻(B)" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data['外观检验_缺陷_浅划麻(B)'] }}</span></template>
					</el-table-column>
					<el-table-column label="双面划麻" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_缺陷_双面划麻 }}</span></template>
					</el-table-column>
					<el-table-column label="倒角" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_缺陷_倒角 }}</span></template>
					</el-table-column>
					<el-table-column label="棕圈" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_缺陷_棕圈 }}</span></template>
					</el-table-column>
					<el-table-column label="蓝圈" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_缺陷_蓝圈 }}</span></template>
					</el-table-column>
					<el-table-column label="尺寸小" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_缺陷_尺寸小 }}</span></template>
					</el-table-column>
					<el-table-column label="破损" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_缺陷_破损 }}</span></template>
					</el-table-column>
					<el-table-column label="发白" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_缺陷_发白 }}</span></template>
					</el-table-column>
					<el-table-column label="裂纹" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_缺陷_裂纹 }}</span></template>
					</el-table-column>
					<el-table-column label="光圈" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_缺陷_光圈 }}</span></template>
					</el-table-column>
					<el-table-column label="漏光" class-name="colorheader2">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_缺陷_漏光 }}</span></template>
					</el-table-column>
				</el-table-column>
				<el-table-column label="一次返修" align="center" class-name="colorheader3">
					<el-table-column label="日期" class-name="colorheader3" width="90">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修_日期 }}</span></template>
					</el-table-column>
					<el-table-column label="检验人" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修_操作人 }}</span></template>
					</el-table-column>
					<el-table-column label="返修数" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修_count_real }}</span></template>
					</el-table-column>
					<el-table-column label="合格数" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修_count_ok }}</span></template>
					</el-table-column>
					<el-table-column label="完全合格数" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修_count_ok_full }}</span></template>
					</el-table-column>
					<el-table-column label="黑圈变形" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修_缺陷_黑圈变形 }}</span></template>
					</el-table-column>
					<el-table-column label="气泡" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修_缺陷_气泡 }}</span></template>
					</el-table-column>
					<el-table-column label="浅气泡(B)" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data['外观检验_返修_缺陷_浅气泡(B)'] }}</span></template>
					</el-table-column>
					<el-table-column label="划麻" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data['外观检验_返修_缺陷_划麻(返修)'] }}</span></template>
					</el-table-column>
					<el-table-column label="浅划麻(B)" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data['外观检验_返修_缺陷_浅划麻(B)'] }}</span></template>
					</el-table-column>
					<el-table-column label="双面划麻" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修_缺陷_双面划麻 }}</span></template>
					</el-table-column>
					<el-table-column label="浅水纹(B)" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data['外观检验_返修_缺陷_浅水纹(B)'] }}</span></template>
					</el-table-column>
					<el-table-column label="重水纹" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修_缺陷_重水纹 }}</span></template>
					</el-table-column>
					<el-table-column label="大崩" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修_缺陷_大崩 }}</span></template>
					</el-table-column>
					<el-table-column label="小崩边(B)" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data['外观检验_返修_缺陷_小崩边(B)'] }}</span></template>
					</el-table-column>
					<el-table-column label="倒角" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修_缺陷_倒角 }}</span></template>
					</el-table-column>
					<el-table-column label="棕点" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修_缺陷_棕点 }}</span></template>
					</el-table-column>
					<el-table-column label="漏光" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修_缺陷_漏光 }}</span></template>
					</el-table-column>
					<el-table-column label="黑圈缺口" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修_缺陷_黑圈缺口 }}</span></template>
					</el-table-column>
					<el-table-column label="破损" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修_缺陷_破损 }}</span></template>
					</el-table-column>
					<el-table-column label="发白" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修_缺陷_发白 }}</span></template>
					</el-table-column>
					<el-table-column label="裂纹" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修_缺陷_裂纹 }}</span></template>
					</el-table-column>
					<el-table-column label="光圈" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修_缺陷_光圈 }}</span></template>
					</el-table-column>
					<el-table-column label="尺寸小" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修_缺陷_尺寸小 }}</span></template>
					</el-table-column>
				</el-table-column>
				<el-table-column label="二次返修" align="center" class-name="colorheader3">
					<el-table-column label="日期" class-name="colorheader3" width="90">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修2_日期 }}</span></template>
					</el-table-column>
					<el-table-column label="检验人" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修2_操作人 }}</span></template>
					</el-table-column>
					<el-table-column label="返修数" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修2_count_real }}</span></template>
					</el-table-column>
					<el-table-column label="合格数" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修2_count_ok }}</span></template>
					</el-table-column>
					<el-table-column label="完全合格数" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修2_count_ok_full }}</span></template>
					</el-table-column>
					<el-table-column label="黑圈变形" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修2_缺陷_黑圈变形 }}</span></template>
					</el-table-column>
					<el-table-column label="气泡" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修2_缺陷_气泡 }}</span></template>
					</el-table-column>
					<el-table-column label="浅气泡(B)" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data['外观检验_返修2_缺陷_浅气泡(B)'] }}</span></template>
					</el-table-column>
					<el-table-column label="浅划麻(B)" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data['外观检验_返修2_缺陷_浅划麻(B)'] }}</span></template>
					</el-table-column>
					<el-table-column label="双面划麻" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修2_缺陷_双面划麻 }}</span></template>
					</el-table-column>
					<el-table-column label="浅水纹(B)" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data['外观检验_返修2_缺陷_浅水纹(B)'] }}</span></template>
					</el-table-column>
					<el-table-column label="重水纹" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修2_缺陷_重水纹 }}</span></template>
					</el-table-column>
					<el-table-column label="大崩" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修2_缺陷_大崩 }}</span></template>
					</el-table-column>
					<el-table-column label="小崩边(B)" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data['外观检验_返修2_缺陷_小崩边(B)'] }}</span></template>
					</el-table-column>
					<el-table-column label="倒角" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修2_缺陷_倒角 }}</span></template>
					</el-table-column>
					<el-table-column label="棕点" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修2_缺陷_棕点 }}</span></template>
					</el-table-column>
					<el-table-column label="漏光" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修2_缺陷_漏光 }}</span></template>
					</el-table-column>
					<el-table-column label="黑圈缺口" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修2_缺陷_黑圈缺口 }}</span></template>
					</el-table-column>
					<el-table-column label="破损" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修2_缺陷_破损 }}</span></template>
					</el-table-column>
					<el-table-column label="发白" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修2_缺陷_发白 }}</span></template>
					</el-table-column>
					<el-table-column label="裂纹" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修2_缺陷_裂纹 }}</span></template>
					</el-table-column>
					<el-table-column label="光圈" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修2_缺陷_光圈 }}</span></template>
					</el-table-column>
					<el-table-column label="尺寸小" class-name="colorheader3">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_返修2_缺陷_尺寸小 }}</span></template>
					</el-table-column>
				</el-table-column>
				<el-table-column label="外观总合格数" class-name="colorheader4">
					<template  #default="scope">
						<span v-if="scope.row.data.外观检验_完全总合格数==0&&scope.row.data.外观检验_count_ok_full">{{ scope.row.data.外观检验_count_ok_full }}</span>
						<span v-else>{{ scope.row.data.外观检验_完全总合格数 }}</span>
					</template>
				</el-table-column>
				<el-table-column label="外观总合格率(%)" class-name="colorheader5">
					<template  #default="scope">
						<span v-if="scope.row.data.外观检验_完全总合格率">{{ scope.row.data.外观检验_完全总合格率 }}</span>
						<span v-else-if="scope.row.data.外观检验_完全合格率">{{ scope.row.data.外观检验_完全合格率 }}</span>
						<span v-else>0</span>
					</template>
				</el-table-column>
				<el-table-column label="直通良率(%)" class-name="colorheader6">
					<template  #default="scope">
						<span v-if="scope.row.data.外观检验_完全直通合格率">{{ scope.row.data.外观检验_完全直通合格率 }}</span>
						<span v-else-if="scope.row.data.尺寸检验_合格率">{{ scope.row.data.尺寸检验_合格率 }}</span>
						<span v-else-if="scope.row.data.外观检验_完全总合格率">{{ scope.row.data.外观检验_完全总合格率 }}</span>
						<span v-else>0</span>
					</template>
				</el-table-column>
				<el-table-column label="抽检" align="center" class-name="colorheader7">
					<el-table-column label="日期" class-name="colorheader7" width="90">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_车间库存抽检_日期 }}</span></template>
					</el-table-column>
					<el-table-column label="黑圈变形" class-name="colorheader7">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_车间库存抽检_缺陷_黑圈变形 }}</span></template>
					</el-table-column>
					<el-table-column label="黑圈缺口" class-name="colorheader7">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_车间库存抽检_缺陷_黑圈缺口 }}</span></template>
					</el-table-column>
					<el-table-column label="光圈" class-name="colorheader7">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_车间库存抽检_缺陷_光圈 }}</span></template>
					</el-table-column>
					<el-table-column label="发白" class-name="colorheader7">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_车间库存抽检_缺陷_发白 }}</span></template>
					</el-table-column>
					<el-table-column label="漏光" class-name="colorheader7">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_车间库存抽检_缺陷_漏光 }}</span></template>
					</el-table-column>
					<el-table-column label="抽检不合格" class-name="colorheader7">
						<template  #default="scope"><span>{{ scope.row.data.外观检验_车间库存抽检_count_notok }}</span></template>
					</el-table-column>
					<el-table-column label="直通总合格数" class-name="colorheader7">
						<template  #default="scope"><span v-if="scope.row.data.外观检验_车间库存抽检_count_notok">{{ scope.row.data.外观检验_完全总合格数- scope.row.data.外观检验_车间库存抽检_count_notok}}</span></template>
					</el-table-column>
					<el-table-column label="直通良率" class-name="colorheader7">
						<template  #default="scope"><span v-if="scope.row.data.外观检验_车间库存抽检_count_notok">{{ (((scope.row.data.外观检验_完全总合格数- scope.row.data.外观检验_车间库存抽检_count_notok)/scope.row.data.尺寸检验_count_real)*100 ).toFixed(2)}}</span></template>
					</el-table-column>
				</el-table-column>
			</el-table>
		</el-main>
		<el-footer>
			<el-pagination 
					background 
					:small="true" 
					:total="dataTotal"
					layout="total, sizes, prev, pager, next, jumper"
					:page-size="params.page_size" 
					:page-sizes="[20, 50, 100, 200]" 
					:current-page="params.page"
					@current-change="getList" 
					@update:page-size="getList2"
				></el-pagination>
		</el-footer>
	</el-container>
</template>

<script>
export default {
	name: "chart",
	data() {
		return {
			query:{
				batch:'',
				cc_data_start:'',
				cc_data_end:'',
				wg_data_start:'',
				wg_data_end:'',
				fx_data_start:'',
				fx_data_end:'',
				shiftcc:'',
				shiftwg:'',
			},
			params: {
				page:1,
				page_size:20,
				with_source_near:'yes',
				ordering:"-last_time",
				querys:[
					[{field:"data__has_key",compare:"",value:"尺寸检验_日期"}],
					[{field:"data__has_key",compare:"",value:"外观检验_日期"}],
					[{field:"data__has_key",compare:"",value:"外观检验_返修_日期"}]
				],
			},
			apiObj: this.$API.wpm.batchst,
			dataTotal:0,
			options:[],
			tableData:[],
			shiftOptions:[],
		};
	},
	mounted() {
		let that = this;
		that.getList();
		that.getShift();
	},
	methods: {
		getShift(){
			let that = this;
			that.$API.mtm.shift.list.req({page:0}).then((res) => {
				that.shiftOptions = res;
			});
		},
		getList(val){
			let that = this;
			that.params.page = val?val:1;
			that.$API.wpm.batchstquery.req(that.params).then((res) => {
				if (res.count > 0) {
					res.results.forEach(item=>{
						item.gongyi = '';
						if(item.source_near&&item.source_near[0]){
							let data = item.source_near[0].data;
							let gongyi  = '';
							for(let key in data){
								if(key.indexOf('外扫')>-1){
									gongyi = '外扫';
								}else if(key.indexOf('外协一次抛')>-1){
									gongyi = '外抛';
								}else{
									gongyi = '自家';
								}
							}
							item.gongyi = gongyi;
						}
					})
					that.tableData = res.results;
					that.dataTotal = res.count;
				}else{
					that.tableData = [];
					that.dataTotal = 0;
				}
			});
		},
		getList2(val){
			let that = this;
			that.params.page = 1;
			that.params.page_size = val;
			that.params.querys=[
				[{field:"data__has_key",compare:"",value:"尺寸检验_日期"}],
				[{field:"data__has_key",compare:"",value:"外观检验_日期"}],
				[{field:"data__has_key",compare:"",value:"外观检验_返修_日期"}]
			];
			that.getList(1);
		},
		handleQuery(){
			let that = this;
			that.params.page = 1;
			that.params.querys=[];
			let arrays = {};
			if(that.query.batch != "" && that.query.batch != null && that.query.batch != undefined&&that.query.batch.indexOf(' ')){
				let arrs = that.query.batch.split(' ');
				arrs.forEach((item, index) => {
					let obj = {};
					obj.value = item;
					obj.field = "batch";
					obj.compare = "contains";
					let newArrayName1 = 'arr1' + index; 
					let newArrayName2 = 'arr2' + index; 
					let newArrayName3 = 'arr3' + index; 
					arrays[newArrayName1] = [{field:"data__has_key",compare:"",value:"尺寸检验_日期"},obj]; 
					arrays[newArrayName2] = [{field:"data__has_key",compare:"",value:"外观检验_日期"},obj]; 
					arrays[newArrayName3] = [{field:"data__has_key",compare:"",value:"外观检验_返修_日期"},obj]; 
				});
			}else{
				let obj = {};
				obj.value =that.query.batch;
				obj.field = "batch";
				obj.compare = "contains";
				arrays.arr1=[{field:"data__has_key",compare:"",value:"尺寸检验_日期"},obj];
				arrays.arr2=[{field:"data__has_key",compare:"",value:"外观检验_日期"},obj];
				arrays.arr3=[{field:"data__has_key",compare:"",value:"外观检验_返修_日期"},obj];
			}
			for(let key in that.query){
				if(that.query[key] != ""&&that.query[key] != null&&that.query[key] != undefined&&key!='batch'){
					let obj = {};
					obj.value = that.query[key];
					if(key=='cc_data_start'){
						obj.compare = "gte";
						obj.field = "data__尺寸检验_日期";
					}
					if(key=='cc_data_end'){
						obj.compare = "lte";
						obj.field = "data__尺寸检验_日期";
					}
					if(key=='shiftcc'){
						obj.compare = "";
						obj.field = "data__尺寸检验_班次";
					}
					if(key=='wg_data_start'){
						obj.compare = "gte";
						obj.field = "data__外观检验_日期";
					}
					if(key=='wg_data_end'){
						obj.compare = "lte";
						obj.field = "data__外观检验_日期";
					}
					if(key=='shiftwg'){
						obj.compare = "";
						obj.field = "data__外观检验_班次";
					}
					if(key=='fx_data_start'){
						obj.compare = "gte";
						obj.field = "data__外观检验_返修_日期";
					}
					if(key=='fx_data_end'){
						obj.compare = "lte";
						obj.field = "data__外观检验_返修_日期";
					}
					if(that.query.batch != "" && that.query.batch != null && that.query.batch != undefined&&that.query.batch.indexOf(' ')){
						let arrs = that.query.batch.split(' ');
						arrs.forEach((item,index)=>{
							let newArrayName1 = 'arr1' + index; 
							let newArrayName2 = 'arr2' + index; 
							let newArrayName3 = 'arr3' + index; 
							arrays[newArrayName1].push(obj);
							arrays[newArrayName2].push(obj);
							arrays[newArrayName3].push(obj);
								
						});
					}else{
						arrays.arr1.push(obj);
						arrays.arr2.push(obj);
						arrays.arr3.push(obj);
					}
				}
			}
			for(let key in arrays){
				that.params.querys.push(arrays[key]);	
			}
			this.getList();
		},
		getSummaries({ columns, data }) {
			const sums = [];
			columns.forEach((column, index) => {
				if (index === 0) {
					sums[index] = "合计";
					return;
				}
				let propert = '';
				//尺寸检验
				if(index == 5&&column.label=='检验数'){
					propert = '尺寸检验_count_real';
				}else if(column.label=='黑圈内径'){
					propert = '尺寸检验_缺陷_黑圈内径';
				}else if(column.label=='黑圈外径'){
					propert = '尺寸检验_缺陷_黑圈外径';
				}else if(column.label=='产品同心度'){
					propert = '尺寸检验_缺陷_产品同心度';
				}else if(column.label=='圆度'){
					propert = '尺寸检验_缺陷_圆度';
				}else if(column.label=='产品外径小'){
					propert = '尺寸检验_缺陷_产品外径小';
				}else if(column.label=='产品外径大(返修)'){
					propert = '尺寸检验_缺陷_产品外径大(返修)';
				}else if(index == 16&&column.label=='黑圈缺口'){
					propert = '尺寸检验_缺陷_黑圈缺口';
				}else if(column.label=='外径发货片(B)'){
					propert = '尺寸检验_缺陷_外径发货片(B)';
				}else if(column.label=='前道崩'){
					propert = '尺寸检验_缺陷_前道崩';
				}else if(index==19&&column.label=='合格数'){
					propert = '尺寸检验_count_ok_full';
				}else if(column.label=='准合格(B)'){
					propert = '尺寸检验_缺陷_准合格(B)';
				}else if(column.label=='圆度准合格'){
					propert = '尺寸检验_缺陷_圆准(B)';
				}else if(column.label=='总合格数'){
					propert = '尺寸检验_count_ok';
				}else if(index == 28&&column.label=='检验数'){
					propert = '外观检验_count_real';
				}else if(index==29&&column.label=='合格数'){
					propert = '外观检验_count_ok_full';
				}else if(index==31&&column.label=='划麻(返修)'){
					propert = '外观检验_缺陷_划麻(返修)';
				}else if(index==33&&column.label=='脏(返修)'){
					propert = '外观检验_缺陷_脏(返修)';
				}else if(index==35&&column.label=='气泡'){
					propert = '外观检验_缺陷_气泡';
				}else if(index==37&&column.label=='浅气泡(B)'){
					propert = '外观检验_缺陷_浅气泡(B)';
				}else if(index==38&&column.label=='黑圈变形'){
					propert = '外观检验_缺陷_黑圈变形';
				}else if(index==39&&column.label=='黑圈缺口'){
					propert = '外观检验_缺陷_黑圈缺口';
				}else if(index==40&&column.label=='重水纹'){
					propert = '外观检验_缺陷_重水纹';
				}else if(index==41&&column.label=='浅水纹(B)'){
					propert = '外观检验_缺陷_浅水纹(B)';
				}else if(index==42&&column.label=='大崩'){
					propert = '外观检验_缺陷_大崩';
				}else if(index==43&&column.label=='小崩边(B)'){
					propert = '外观检验_缺陷_小崩边(B)';
				}else if(index==45&&column.label=='棕点'){
					propert = '外观检验_缺陷_棕点';
				}else if(index==46&&column.label=='浅划麻(B)'){
					propert = '外观检验_缺陷_浅划麻(B)';
				}else if(index==47&&column.label=='双面划麻'){
					propert = '外观检验_缺陷_双面划麻';
				}else if(index==48&&column.label=='倒角'){
					propert = '外观检验_缺陷_倒角';
				}else if(index==49&&column.label=='棕圈'){
					propert = '外观检验_缺陷_棕圈';
				}else if(index==50&&column.label=='蓝圈'){
					propert = '外观检验_缺陷_蓝圈';
				}else if(index==51&&column.label=='尺寸小'){
					propert = '外观检验_缺陷_尺寸小';
				}else if(index==52&&column.label=='破损'){
					propert = '外观检验_缺陷_破损';
				}else if(index==53&&column.label=='发白'){
					propert = '外观检验_缺陷_发白';
				}else if(index==54&&column.label=='裂纹'){
					propert = '外观检验_缺陷_裂纹';
				}else if(index==55&&column.label=='光圈'){
					propert = '外观检验_缺陷_光圈';
				}else if(index==56&&column.label=='漏光'){
					propert = '外观检验_缺陷_漏光';
				}else if(index == 59&&column.label=='返修数'){
					propert = '外观检验_返修_count_real';
				}else if(index==60&&column.label=='合格数'){
					propert = '外观检验_返修_count_ok_full';
				}else if(index==61&&column.label=='黑圈变形'){
					propert = '外观检验_返修_缺陷_黑圈变形';
				}else if(index==62&&column.label=='气泡'){
					propert = '外观检验_返修_缺陷_气泡';
				}else if(index==63&&column.label=='浅气泡(B)'){
					propert = '外观检验_返修_缺陷_浅气泡(B)';
				}else if(index==64&&column.label=='浅划麻(B)'){
					propert = '外观检验_返修_缺陷_浅划麻(B)';
				}else if(index==65&&column.label=='双面划麻'){
					propert = '外观检验_返修_缺陷_双面划麻';
				}else if(index==66&&column.label=='浅水纹(B)'){
					propert = '外观检验_返修_缺陷_浅水纹(B)';
				}else if(index==67&&column.label=='重水纹'){
					propert = '外观检验_返修_缺陷_重水纹';
				}else if(index==68&&column.label=='大崩'){
					propert = '外观检验_返修_缺陷_大崩';
				}else if(index==69&&column.label=='小崩边(B)'){
					propert = '外观检验_返修_缺陷_小崩边(B)';
				}else if(index==70&&column.label=='倒角'){
					propert = '外观检验_返修_缺陷_倒角';
				}else if(index==71&&column.label=='棕点'){
					propert = '外观检验_返修_缺陷_棕点';
				}else if(index==72&&column.label=='漏光'){
					propert = '外观检验_返修_缺陷_漏光';
				}else if(index==73&&column.label=='黑圈缺口'){
					propert = '外观检验_返修_缺陷_黑圈缺口';
				}else if(index==74&&column.label=='破损'){
					propert = '外观检验_返修_缺陷_破损';
				}else if(index==75&&column.label=='发白'){
					propert = '外观检验_返修_缺陷_发白';
				}else if(index==76&&column.label=='裂纹'){
					propert = '外观检验_返修_缺陷_裂纹';
				}else if(index==77&&column.label=='光圈'){
					propert = '外观检验_返修_缺陷_光圈';
				}else if(index==78&&column.label=='尺寸小'){
					propert = '外观检验_返修_缺陷_尺寸小';
				}else if(column.label=='外观总合格数'){
					propert = '外观检验_完全总合格数';
				}else if(index==83&&column.label=='黑圈变形'){
					propert = '外观检验_车间库存抽检_缺陷_黑圈变形';
				}else if(index==84&&column.label=='黑圈缺口'){
					propert = '外观检验_车间库存抽检_缺陷_黑圈缺口';
				}else if(index==85&&column.label=='光圈'){
					propert = '外观检验_车间库存抽检_缺陷_光圈';
				}else if(index==86&&column.label=='发白'){
					propert = '外观检验_车间库存抽检_缺陷_发白';
				}else if(index==87&&column.label=='漏光'){
					propert = '外观检验_车间库存抽检_缺陷_漏光';
				}else if(index==88&&column.label=='抽检不合格'){
					propert = '外观检验_车间库存抽检_count_notok';
				}
				if (propert!=='') {
					const values = data.map((item) =>
						Number(item.data[propert])
					);
					if (!values.every((value) => Number.isNaN(value))) {
						sums[index] = values.reduce((prev, curr) => {
							const value = Number(curr);
							let sum = Number(Number(prev) + Number(curr));
							if (!isNaN(value)) {
								return sum;
							} else {
								return prev;
							}
						}, 0);
					} 

				}
				if(index==7||index==9||index==11||index==13||index==20||index==24){
					if(sums[index-1]){
						sums[index] = ((sums[index-1]/sums[5])*100).toFixed(4);
					}
				}
				if(index==30||index==32||index==34||index==36||index==44){
					if(sums[index-1]){
						sums[index] = ((sums[index-1]/sums[28])*100).toFixed(4);
					}
				}
				if(index==79){
					let sum = 0;
					if(sums[29]){
						sum += sums[29];
					}
					if(sums[60]){
						sum += sums[60];
					}
					sums[index] = sum;
				}
				if(index==80){
					if(sums[79]&&sums[28]){
						sums[index] = ((sums[79]/sums[28])*100).toFixed(2);
					}
				}
				if(index==81){
					if(sums[80]&&sums[24]){
						sums[index] = ((sums[80]*sums[24])/100).toFixed(2);
					}
				}
				if(index==89){
					if(sums[88]&&sums[79]){
						sums[index] = sums[79]-sums[88];
					}
				}
				if(index==90){
					if(sums[89]&&sums[5]){
						sums[index] = ((sums[89]/sums[5])*100).toFixed(2);
					}
				}
			});
			return sums;
		},
		handleExport() {
			this.exportLoading = true;
			this.$XLSX("#exportDiv", "过程检验统计");
			this.exportLoading = false;
		},
	},
};
</script>

<style scoped>
</style>
