<template>
	<el-container>
		<el-header>
			<div class="right-panel">
				<el-input v-model="query.batch__contains" 
					placeholder="批次号" 
					clearable 
					style="width: 200px;"
				></el-input>
				<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">
			<scTable
				ref="table"
				:apiObj="apiObj"
				:params="params"
				:query="params"
				id="exportDiv"
				row-key="id"
				stripe
			>
				<el-table-column label="批次编号" fixed="left" prop="batch">
				</el-table-column>
				<el-table-column label="版型" prop="number" fixed="left">
					<template #default="scope">
						{{ scope.row.material_start_name }}{{ scope.row.material_start_model }}
					</template>
				</el-table-column>
				<el-table-column label="扭转数" fixed="left">
					<template #default="scope">
						{{ scope.row.data.扭后检测_count_use }}
					</template>
				</el-table-column>
				<el-table-column label="扭后内质" align="center" class-name="colorheader1">
					<el-table-column label="合格" class-name="colorheader1">
						<el-table-column label="数量" class-name="colorheader1">
							<template #default="scope">
								<span v-if="scope.row.data.扭后检测_含缺陷_暗点不合格&&scope.row.data.扭后检测_含缺陷_暗点重">{{ scope.row.data.扭后检测_count_use - scope.row.data.扭后检测_含缺陷_暗点不合格 - scope.row.data.扭后检测_含缺陷_暗点重 }}</span>
								<span v-else>
									<span v-if="scope.row.data.扭后检测_含缺陷_暗点重">{{ scope.row.data.扭后检测_count_use - scope.row.data.扭后检测_含缺陷_暗点重 }}</span>
									<span v-else-if="scope.row.data.扭后检测_含缺陷_暗点不合格">{{ scope.row.data.扭后检测_count_use - scope.row.data.扭后检测_含缺陷_暗点不合格 }}</span>
									<span v-else>{{ scope.row.data.扭后检测_count_use }}</span>
								</span>
							</template>
						</el-table-column>
						<el-table-column label="比例" class-name="colorheader1">
							<template #default="scope">
								<span v-if="scope.row.data.扭后检测_含缺陷_暗点不合格&&scope.row.data.扭后检测_含缺陷_暗点重">{{100- scope.row.data.扭后检测_含缺陷_暗点不合格_比例 - scope.row.data.扭后检测_含缺陷_暗点重_比例 }}%</span>
								<span v-else>
									<span v-if="scope.row.data.扭后检测_含缺陷_暗点重">{{ 100 - scope.row.data.扭后检测_含缺陷_暗点重_比例 }}%</span>
									<span v-else-if="scope.row.data.扭后检测_含缺陷_暗点不合格">{{100- scope.row.data.扭后检测_含缺陷_暗点不合格_比例 }}%</span>
									<span v-else>100%</span>
								</span>
							</template>
						</el-table-column>
					</el-table-column>
					<el-table-column label="可加工" class-name="colorheader1">
						<el-table-column label="数量" class-name="colorheader1">	
							<template #default="scope">
								<span>{{ scope.row.data.扭后检测_含缺陷_暗点不合格?scope.row.data.扭后检测_含缺陷_暗点不合格:0 }}</span>
							</template>
						</el-table-column>
						<el-table-column label="比例" class-name="colorheader1">
							<template #default="scope">
								<span>{{  scope.row.data.扭后检测_含缺陷_暗点不合格?scope.row.data.扭后检测_含缺陷_暗点不合格_比例:0 }}%</span>
							</template>
						</el-table-column>
					</el-table-column>
				</el-table-column>
				<el-table-column label="黑网格" align="center" class-name="colorheader2">
					<el-table-column label="无" class-name="colorheader2">
						<el-table-column label="数量" class-name="colorheader2">
							<template #default="scope">
								<span v-if="scope.row.data.扭后检测_含缺陷_黑网轻&&scope.row.data.扭后检测_含缺陷_黑网重">{{ scope.row.data.扭后检测_count_use - scope.row.data.扭后检测_含缺陷_黑网轻 - scope.row.data.扭后检测_含缺陷_黑网重 }}</span>
								<span v-else>
									<span v-if="scope.row.data.扭后检测_含缺陷_黑网轻">{{ scope.row.data.扭后检测_count_use - scope.row.data.扭后检测_含缺陷_黑网轻 }}</span>
									<span v-else-if="scope.row.data.扭后检测_含缺陷_黑网重">{{ scope.row.data.扭后检测_count_use - scope.row.data.扭后检测_含缺陷_黑网重 }}</span>
									<span v-else>{{ scope.row.data.扭后检测_count_use }}</span>
								</span>
							</template>
						</el-table-column>
						<el-table-column label="比例" class-name="colorheader2">
							<template #default="scope">
								<span v-if="scope.row.data.扭后检测_含缺陷_黑网轻&&scope.row.data.扭后检测_含缺陷_黑网重">{{100- scope.row.data.扭后检测_含缺陷_黑网重_比例 - scope.row.data.扭后检测_含缺陷_黑网轻_比例 }}%</span>
								<span v-else>
									<span v-if="scope.row.data.扭后检测_含缺陷_黑网轻">{{ 100 - scope.row.data.扭后检测_含缺陷_黑网轻_比例 }}%</span>
									<span v-else-if="scope.row.data.扭后检测_含缺陷_黑网重">{{100- scope.row.data.扭后检测_含缺陷_黑网重_比例 }}%</span>
									<span v-else>100%</span>
								</span>
							</template>
						</el-table-column>
					</el-table-column>
					<el-table-column label="轻" class-name="colorheader2">
						<el-table-column label="数量" class-name="colorheader2">
							<template #default="scope">
								<span>{{ scope.row.data.扭后检测_含缺陷_黑网轻?scope.row.data.扭后检测_含缺陷_黑网轻:0 }}</span>
							</template>
						</el-table-column>
						<el-table-column label="比例" class-name="colorheader2">
							<template #default="scope">
								<span>{{  scope.row.data.扭后检测_含缺陷_黑网轻_比例?scope.row.data.扭后检测_含缺陷_黑网轻_比例:0 }}%</span>
							</template>
						</el-table-column>
					</el-table-column>
					<el-table-column label="重" class-name="colorheader2">
						<el-table-column label="数量" class-name="colorheader2">
							<template #default="scope">
								<span>{{ scope.row.data.扭后检测_含缺陷_黑网重?scope.row.data.扭后检测_含缺陷_黑网重:0 }}</span>
							</template>
						</el-table-column>
						<el-table-column label="比例" class-name="colorheader2">
							<template #default="scope">
								<span>{{  scope.row.data.扭后检测_含缺陷_黑网重_比例?scope.row.data.扭后检测_含缺陷_黑网重_比例:0 }}%</span>
							</template>
						</el-table-column>
					</el-table-column>
				</el-table-column>
				<el-table-column label="白网格" align="center" class-name="colorheader3">
					<el-table-column label="无" class-name="colorheader3">
						<el-table-column label="数量" class-name="colorheader3">
							<template #default="scope">
								<span v-if="scope.row.data.扭后检测_含缺陷_白网轻&&scope.row.data.扭后检测_含缺陷_白网重">{{ scope.row.data.扭后检测_count_use - scope.row.data.扭后检测_含缺陷_白网轻 - scope.row.data.扭后检测_含缺陷_白网重 }}</span>
								<span v-else>
									<span v-if="scope.row.data.扭后检测_含缺陷_白网轻">{{ scope.row.data.扭后检测_count_use - scope.row.data.扭后检测_含缺陷_白网轻 }}</span>
									<span v-else-if="scope.row.data.扭后检测_含缺陷_白网重">{{ scope.row.data.扭后检测_count_use - scope.row.data.扭后检测_含缺陷_白网重 }}</span>
									<span v-else>{{ scope.row.data.扭后检测_count_use }}</span>
								</span>
							</template>
						</el-table-column>
						<el-table-column label="比例" class-name="colorheader3">
							<template #default="scope">
								<span v-if="scope.row.data.扭后检测_含缺陷_白网轻&&scope.row.data.扭后检测_含缺陷_白网重">{{100- scope.row.data.扭后检测_含缺陷_白网重_比例 - scope.row.data.扭后检测_含缺陷_白网轻_比例 }}%</span>
								<span v-else>
									<span v-if="scope.row.data.扭后检测_含缺陷_白网轻">{{ 100 - scope.row.data.扭后检测_含缺陷_白网轻_比例 }}%</span>
									<span v-else-if="scope.row.data.扭后检测_含缺陷_白网重">{{100- scope.row.data.扭后检测_含缺陷_白网重_比例 }}%</span>
									<span v-else>100%</span>
								</span>
							</template>
						</el-table-column>
					</el-table-column>
					<el-table-column label="轻" class-name="colorheader3">
						<el-table-column label="数量" class-name="colorheader3">
							<template #default="scope">
								<span>{{ scope.row.data.扭后检测_含缺陷_白网轻?scope.row.data.扭后检测_含缺陷_白网轻:0 }}</span>
							</template>
						</el-table-column>
						<el-table-column label="比例" class-name="colorheader3">
							<template #default="scope">
								<span>{{  scope.row.data.扭后检测_含缺陷_白网轻_比例?scope.row.data.扭后检测_含缺陷_白网轻_比例:0 }}%</span>
							</template>
						</el-table-column>
					</el-table-column>
					<el-table-column label="重" class-name="colorheader3">
						<el-table-column label="数量" class-name="colorheader3">
							<template #default="scope">
								<span>{{ scope.row.data.扭后检测_含缺陷_白网重?scope.row.data.扭后检测_含缺陷_白网重:0 }}</span>
							</template>
						</el-table-column>
						<el-table-column label="比例" class-name="colorheader3">
							<template #default="scope">
								<span>{{  scope.row.data.扭后检测_含缺陷_白网重_比例?scope.row.data.扭后检测_含缺陷_白网重_比例:0 }}%</span>
							</template>
						</el-table-column>
					</el-table-column>
				</el-table-column>
				<el-table-column label="小网" align="center" class-name="colorheader4">
					<el-table-column label="无" class-name="colorheader4">
						<el-table-column label="数量" class-name="colorheader4">
							<template #default="scope">
								<span v-if="scope.row.data.扭后检测_含缺陷_小网轻&&scope.row.data.扭后检测_含缺陷_小网重">{{ scope.row.data.扭后检测_count_use - scope.row.data.扭后检测_含缺陷_小网轻 - scope.row.data.扭后检测_含缺陷_小网重 }}</span>
								<span v-else>
									<span v-if="scope.row.data.扭后检测_含缺陷_小网轻">{{ scope.row.data.扭后检测_count_use - scope.row.data.扭后检测_含缺陷_小网轻 }}</span>
									<span v-else-if="scope.row.data.扭后检测_含缺陷_小网重">{{ scope.row.data.扭后检测_count_use - scope.row.data.扭后检测_含缺陷_小网重 }}</span>
									<span v-else>{{ scope.row.data.扭后检测_count_use }}</span>
								</span>
							</template>
						</el-table-column>
						<el-table-column label="比例" class-name="colorheader4">
							<template #default="scope">
								<span v-if="scope.row.data.扭后检测_含缺陷_小网轻&&scope.row.data.扭后检测_含缺陷_小网重">{{100- scope.row.data.扭后检测_含缺陷_小网重_比例 - scope.row.data.扭后检测_含缺陷_小网轻_比例 }}%</span>
								<span v-else>
									<span v-if="scope.row.data.扭后检测_含缺陷_小网轻">{{ 100 - scope.row.data.扭后检测_含缺陷_小网轻_比例 }}%</span>
									<span v-else-if="scope.row.data.扭后检测_含缺陷_小网重">{{100- scope.row.data.扭后检测_含缺陷_小网重_比例 }}%</span>
									<span v-else>100%</span>
								</span>
							</template>
						</el-table-column>
					</el-table-column>
					<el-table-column label="轻" class-name="colorheader4">
						<el-table-column label="数量" class-name="colorheader4">
							<template #default="scope">
								<span>{{ scope.row.data.扭后检测_含缺陷_小网轻?scope.row.data.扭后检测_含缺陷_小网轻:0 }}</span>
							</template>
						</el-table-column>
						<el-table-column label="比例" class-name="colorheader4">
							<template #default="scope">
								<span>{{  scope.row.data.扭后检测_含缺陷_小网轻_比例?scope.row.data.扭后检测_含缺陷_小网轻_比例:0 }}%</span>
							</template>
						</el-table-column>
					</el-table-column>
					<el-table-column label="重" class-name="colorheader4">
						<el-table-column label="数量" class-name="colorheader4">
							<template #default="scope">
								<span>{{ scope.row.data.扭后检测_含缺陷_小网重?scope.row.data.扭后检测_含缺陷_小网重:0 }}</span>
							</template>
						</el-table-column>
						<el-table-column label="比例" class-name="colorheader4">
							<template #default="scope">
								<span>{{  scope.row.data.扭后检测_含缺陷_小网重_比例?scope.row.data.扭后检测_含缺陷_小网重_比例:0 }}%</span>
							</template>
						</el-table-column>
					</el-table-column>
				</el-table-column>
				<el-table-column label="分辨率" align="center" class-name="colorheader5">
					<el-table-column label="测试数量" class-name="colorheader5">
						<template #default="scope">
							<span>{{ scope.row.data.扭后检测_count_use }} </span>
						</template>
					</el-table-column>
					<el-table-column label="国内" class-name="colorheader5">
						<el-table-column label="数量" class-name="colorheader5">
							<template #default="scope">
								<span>{{ scope.row.data.扭后检测_含缺陷_分辨率?scope.row.data.扭后检测_含缺陷_分辨率:0}}</span>
							</template>
						</el-table-column>
						<el-table-column label="比例" class-name="colorheader5">
							<template #default="scope">
								<span>{{ scope.row.data.扭后检测_含缺陷_分辨率?scope.row.data.扭后检测_含缺陷_分辨率_比例:0}}%</span>
							</template>
						</el-table-column>
					</el-table-column>
					<el-table-column label="出口" class-name="colorheader5">
						<el-table-column label="数量" class-name="colorheader5">
							<template #default="scope">
								<span>{{ scope.row.data.扭后检测_含缺陷_分辨率?scope.row.data.扭后检测_含缺陷_分辨率:0}}</span>
							</template>
						</el-table-column>
						<el-table-column label="比例" class-name="colorheader5">
							<template #default="scope">
								<span>{{ scope.row.data.扭后检测_含缺陷_分辨率?scope.row.data.扭后检测_含缺陷_分辨率_比例:0}}%</span>
							</template>
						</el-table-column>
					</el-table-column>
					<el-table-column label="不合格" class-name="colorheader5">
						<el-table-column label="数量" class-name="colorheader5">
							<template #default="scope">
								<span>{{ scope.row.data.扭后检测_含缺陷_分辨率?scope.row.data.扭后检测_含缺陷_分辨率:0}}</span>
							</template>
						</el-table-column>
						<el-table-column label="比例" class-name="colorheader5">
							<template #default="scope">
								<span>{{ scope.row.data.扭后检测_含缺陷_分辨率?scope.row.data.扭后检测_含缺陷_分辨率_比例:0}}%</span>
							</template>
						</el-table-column>
					</el-table-column>
				</el-table-column>
				<el-table-column label="加工数" align="center" class-name="colorheader6">
					<el-table-column label="数量" class-name="colorheader6">
						<template #default="scope">
							<span>{{ scope.row.data.扭后检测_count_ok }} </span>
						</template>
					</el-table-column>
					<el-table-column label="比例" class-name="colorheader6">
						<template #default="scope">
							<span>{{ scope.row.data.扭后检测_合格率 }}</span>
						</template>
					</el-table-column>
				</el-table-column>
				<el-table-column label="毛坯扭送" align="center" class-name="colorheader7">
					<el-table-column label="数量" class-name="colorheader7">
						<template #default="scope">
							<span>{{ scope.row.data.扭后检测_count_ok }} </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>
				<el-table-column label="扭送损失" align="center" class-name="colorheader1">
					<el-table-column label="炸裂情况" class-name="colorheader1">
						<el-table-column label="完好" class-name="colorheader1">
							<el-table-column label="数量" class-name="colorheader1">
								<template #default="scope">
									<span v-if="scope.row.data.扭后检测_含缺陷_扭后炸纹&&scope.row.data.扭后检测_含缺陷_扭后炸废">{{ scope.row.data.扭后检测_count_use - scope.row.data.扭后检测_含缺陷_扭后炸纹 - scope.row.data.扭后检测_含缺陷_扭后炸废 }}</span>
								<span v-else>
									<span v-if="scope.row.data.扭后检测_含缺陷_扭后炸纹">{{ scope.row.data.扭后检测_count_use - scope.row.data.扭后检测_含缺陷_扭后炸纹 }}</span>
									<span v-else-if="scope.row.data.扭后检测_含缺陷_扭后炸废">{{ scope.row.data.扭后检测_count_use - scope.row.data.扭后检测_含缺陷_扭后炸废 }}</span>
									<span v-else>{{ scope.row.data.扭后检测_count_use }}</span>
								</span>
								</template>
							</el-table-column>
							<el-table-column label="比例" class-name="colorheader1">
								<template #default="scope">
									<span v-if="scope.row.data.扭后检测_含缺陷_扭后炸纹&&scope.row.data.扭后检测_含缺陷_扭后炸废">{{100- scope.row.data.扭后检测_含缺陷_扭后炸纹 - scope.row.data.扭后检测_含缺陷_扭后炸废 }}%</span>
									<span v-else>
										<span v-if="scope.row.data.扭后检测_含缺陷_扭后炸纹">{{ 100 - scope.row.data.扭后检测_含缺陷_扭后炸纹_比例 }}</span>
										<span v-else-if="scope.row.data.扭后检测_含缺陷_扭后炸废">{{100- scope.row.data.扭后检测_含缺陷_扭后炸废_比例 }}%</span>
										<span v-else>100%</span>
									</span>
								</template>
							</el-table-column>
						</el-table-column>
						<el-table-column label="崩炸" class-name="colorheader1">
							<el-table-column label="数量" class-name="colorheader1">
								<template #default="scope">
									<span>{{ scope.row.data.扭后检测_含缺陷_扭后炸纹?扭后检测_含缺陷_扭后炸纹:0 }}</span>
								</template>
							</el-table-column>
							<el-table-column label="比例" class-name="colorheader1">
								<template #default="scope">
									<span>{{  scope.row.data.扭后检测_含缺陷_扭后炸纹?scope.row.data.扭后检测_含缺陷_扭后炸纹_比列:0 }}%</span>
								</template>
							</el-table-column>
						</el-table-column>
						<el-table-column label="炸废" class-name="colorheader1">
							<el-table-column label="数量" class-name="colorheader1">
								<template #default="scope">
									<span>{{ scope.row.data.扭后检测_含缺陷_扭后炸废?扭后检测_含缺陷_扭后炸废:0 }}</span>
								</template>
							</el-table-column>
							<el-table-column label="比例" class-name="colorheader1">
								<template #default="scope">
									<span>{{  scope.row.data.扭后检测_含缺陷_扭后炸废?scope.row.data.扭后检测_含缺陷_扭后炸废_比列:0 }}%</span>
								</template>
							</el-table-column>
						</el-table-column>
					</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.扭后检测_count_ok }} </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="外形偏(0.5mm)" align="center" class-name="colorheader2">
				</el-table-column> -->
				<el-table-column label="实验名称备注" prop="batch" align="center" class-name="colorheader3">
				</el-table-column>
				<el-table-column label="检测设备" align="center" class-name="colorheader4">
					<template #default="scope">
						<span>{{ scope.row.data.扭后检测_缺陷_备注 }}</span>
					</template>
				</el-table-column>
			</scTable>
		</el-main>
	</el-container>
</template>

<script>
export default {
	name: "statistics_guan",
	data() {
		return {
			params: {
				ordering:'-data__扭后检测_小日期',
				querys:[[{field:"data__has_key",compare:"",value:"扭后检测_日期"}]],
			},
			query:{
				name__contains:'',
				batch__contains:'',
				last_time__gte:'',
				last_time__lte:'',
			},
			apiObj: this.$API.wpm.batchstquery,
			options:[],
			tableData:[],
		};
	},
	methods: {
		handleQuery(){
			let that = this;
			let querys = [[{field:"wm",value:0,compare:"isnull"},{field:"data__has_key",compare:"",value:"扭后检测_批次号"}]];
			let obj = {},obj1 = {},obj2 = {},obj3 = {};
			obj.field = 'data__扭后检测_批次号';
			obj.value = that.query.batch__contains;
			obj.compare = '';

			obj1.field = 'last_time';
			obj1.value = that.query.last_time__gte;
			obj1.compare = 'gte';

			obj2.field = 'last_time';
			obj2.value = that.query.last_time__lte;
			obj2.compare = 'lte';

			obj3.field = 'data__扭后检测_物料名';
			obj3.value = that.query.name__contains;
			obj3.compare = '';

			if(that.query.batch__contains!==''&&that.query.batch__contains!==null){
				querys[0].push(obj);
			}
			if(that.query.last_time__gte!==''&&that.query.last_time__gte!==null){
				querys[0].push(obj1);
			}
			if(that.query.last_time__lte!==''&&that.query.last_time__lte!==null){
				querys[0].push(obj2);
			}
			if(that.query.name__contains!==''&&that.query.name__contains!==null){
				querys[0].push(obj3);
			}
			that.params.querys = querys;
			this.$refs.table.queryData(that.params);
		},
		getCountQt(data,type){
			let count_qt = 0,count = 0;
		   
		}
	},
};
</script>

<style scoped>
</style>
