<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"
				stripe
			>
				<el-table-column label="单号" prop="batch" align="center" fixed="left">
				</el-table-column>
				<el-table-column label="检测日期" fixed="left" prop="batch" width="90">
					<template #default="scope">
						{{ scope.row.data.毛坯检测_日期 }}
					</template>
				</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="放大率￠2mm" align="center" class-name="colorheader1">
					<el-table-column label="合格数" class-name="colorheader1">
						<template #default="scope">
							<span>{{ scope.row.data['毛坯检测_缺陷_放大率￠2mm不合格']?scope.row.data.毛坯检测_count_use-scope.row.data['毛坯检测_缺陷_放大率￠2mm不合格']:scope.row.data.毛坯检测_count_use }}</span>
						</template>
					</el-table-column>
					<el-table-column label="合格率" class-name="colorheader1">
						<template #default="scope">
							<span>{{  scope.row.data['毛坯检测_缺陷_放大率￠2mm不合格_比例']?100-scope.row.data['毛坯检测_缺陷_放大率￠2mm不合格_比例']:100 }}%</span>
						</template>
					</el-table-column>
				</el-table-column>
				<el-table-column label="放大率￠16mm" align="center" class-name="colorheader2">
					<el-table-column label="合格数" class-name="colorheader2">
						<template #default="scope">
							<span>{{ scope.row.data['毛坯检测_缺陷_放大率￠16mm不合格']?scope.row.data.毛坯检测_count_use-scope.row.data['毛坯检测_缺陷_放大率￠16mm不合格']:scope.row.data.毛坯检测_count_use }}</span>
						</template>
					</el-table-column>
					<el-table-column label="合格率" class-name="colorheader2">
						<template #default="scope">
							<span>{{  scope.row.data['毛坯检测_缺陷_放大率￠16mm不合格_比例']?100-scope.row.data['毛坯检测_缺陷_放大率￠16mm不合格_比例']:100 }}%</span>
						</template>
					</el-table-column>
				</el-table-column>
				<el-table-column label="剪切" align="center" class-name="colorheader3">
					<el-table-column label="合格数" class-name="colorheader3">
						<!-- 总数-不合格数-可加工数 -->
						<template #default="scope">
							<span v-if="scope.row.data['毛坯检测_缺陷_剪切￠18.3mm不合格']">
								<span v-if="scope.row.data['毛坯检测_缺陷_剪切￠18.3mm可加工']">{{ scope.row.data.毛坯检测_count_use-scope.row.data['毛坯检测_缺陷_剪切￠18.3mm不合格']-scope.row.data['毛坯检测_缺陷_剪切￠18.3mm可加工'] }}</span>
								<span v-else>{{ scope.row.data.毛坯检测_count_use-scope.row.data['毛坯检测_缺陷_剪切￠18.3mm不合格']}}</span>
							</span>
							<span v-else>
								<span v-if="scope.row.data['毛坯检测_缺陷_剪切￠18.3mm可加工']">{{ scope.row.data.毛坯检测_count_use-scope.row.data['毛坯检测_缺陷_剪切￠18.3mm可加工'] }}</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['毛坯检测_缺陷_剪切￠18.3mm不合格_比例']">
								<span v-if="scope.row.data['毛坯检测_缺陷_剪切￠18.3mm可加工_比例']">{{ 100-scope.row.data['毛坯检测_缺陷_剪切￠18.3mm不合格_比例']-scope.row.data['毛坯检测_缺陷_剪切￠18.3mm可加工_比例'] }}</span>
								<span v-else>{{ 100-scope.row.data['毛坯检测_缺陷_剪切￠18.3mm不合格_比例'] }}%</span>
							</span>
							<span v-else>
								<span v-if="scope.row.data['毛坯检测_缺陷_剪切￠18.3mm可加工_比例']">{{ 100-scope.row.data['毛坯检测_缺陷_剪切￠18.3mm可加工_比例'] }}%</span>
								<span v-else>100%</span>
							</span>
						</template>
					</el-table-column>
					<el-table-column label="可加工" class-name="colorheader3">
						<template #default="scope">
							<span>{{ scope.row.data['毛坯检测_缺陷_剪切￠18.3mm可加工']?scope.row.data['毛坯检测_缺陷_剪切￠18.3mm可加工']:0 }}</span>
						</template>
					</el-table-column>
					<el-table-column label="加工率" class-name="colorheader3">
						<template #default="scope">
							<span>{{  scope.row.data['毛坯检测_缺陷_剪切￠18.3mm可加工_比例']?scope.row.data['毛坯检测_缺陷_剪切￠18.3mm可加工_比例']:0 }}%</span>
						</template>
					</el-table-column>
				</el-table-column>
				<el-table-column label="暗点" align="center" class-name="colorheader4">
					<el-table-column label="内标数" class-name="colorheader4">
						<template #default="scope">
							<span>{{ scope.row.data.毛坯检测_缺陷_暗点不合格?scope.row.data.毛坯检测_count_use-scope.row.data.毛坯检测_缺陷_暗点不合格:scope.row.data.毛坯检测_count_use }}</span>
						</template>
					</el-table-column>
					<el-table-column label="合格率" class-name="colorheader4">
						<template #default="scope">
							<span>{{  scope.row.data.毛坯检测_缺陷_暗点不合格_比例?100-scope.row.data.毛坯检测_缺陷_暗点不合格_比例:100 }}%</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 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="崩炸" align="center" class-name="colorheader5">
					<el-table-column label="崩" align="center" class-name="colorheader5">
						<template #default="scope">
							<span>{{ scope.row.data.毛坯检测_缺陷_崩?scope.row.data.毛坯检测_缺陷_崩:0 }}</span>
						</template>
					</el-table-column>
					<el-table-column label="合格率" align="center" class-name="colorheader5">
						<template #default="scope">
							<span>{{  scope.row.data.毛坯检测_缺陷_崩_比例?100-scope.row.data.毛坯检测_缺陷_崩_比例:100 }}%</span>
						</template>
					</el-table-column>
					<el-table-column label="炸废" align="center" class-name="colorheader5">
						<template #default="scope">
							<span>{{ scope.row.data.毛坯检测_缺陷_炸废?scope.row.data.毛坯检测_缺陷_炸废:0 }}</span>
						</template>
					</el-table-column>
					<el-table-column label="合格率" align="center" class-name="colorheader5">
						<template #default="scope">
							<span>{{ scope.row.data.毛坯检测_缺陷_炸废_比例?100-scope.row.data.毛坯检测_缺陷_炸废_比例:100 }}%</span>
						</template>
					</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">
					<template #default="scope">
						<span>{{ scope.row.data.毛坯检测_缺陷_暗点不合格?scope.row.data.毛坯检测_缺陷_暗点不合格:0 }}</span>
					</template>
				</el-table-column>
				<el-table-column label="外形偏(0.5mm)" align="center" class-name="colorheader1">
				</el-table-column>
				<el-table-column label="备注" align="center" class-name="colorheader3">
					<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:{
				batch__contains:''
			},
			apiObj: this.$API.wpm.batchstquery,
			options:[],
			tableData:[],
		};
	},
	methods: {
		handleQuery(){
			let that = this;
			let querys = [[{field:"data__has_key",compare:"",value:"毛坯检测_日期"}]];
			let obj = {};
			obj.field = 'batch';
			obj.value = that.query.batch__contains;
			obj.compare = '';
			if(that.query.batch__contains!==''&&that.query.batch__contains!==null){
				querys[0].push(obj);
			}
			that.params.querys = querys;
			this.$refs.table.queryData(that.params);
		},
	},
};
</script>

<style scoped>
</style>
