<template>
	<el-container>
		<el-header>
			<div class="right-panel">
				<el-date-picker
					v-model="query.last_time__gte"
					type="date"
					value-format="YYYY-MM-DD"
					placeholder="开始时间"
					style="width: 150px"
				/>
				<el-date-picker
					v-model="query.last_time__lte"
					type="date"
					value-format="YYYY-MM-DD"
					placeholder="结束时间"
					style="margin-left: 2px; width: 150px"
				/>
				<el-input v-model="query.name__contains" 
					placeholder="产品名称" 
					clearable 
					style="width: 200px;"
				></el-input>
				<el-input v-model="query.batch__contains" 
					placeholder="批次号" 
					clearable 
					style="width: 200px;"
				></el-input>
				<el-input v-model="query.number__contains" 
					placeholder="板段号" 
					clearable 
					style="width: 200px;"
				></el-input>
				<el-button
					type="primary"
					icon="el-icon-search"
					@click="handleQuery"
				></el-button>
			</div>
		</el-header>
		<el-main class="nopadding">
			<scTable
				ref="table"
				:apiObj="apiObj"
				:params="params"
				:query="querys"
				id="exportDiv"
				row-key="id"
				stripe
			>
				<el-table-column type="index" width="50"  fixed="left"/>
				<el-table-column label="产品名称" prop="material_name" fixed="left" min-width="100">
					<template #default="scope">
						<span>{{ scope.row.material_name.split('|')[0] }}</span>
					</template>
				</el-table-column>
				<el-table-column label="批次号" fixed="left">
					<template #default="scope">
						<span>{{ scope.row.data.扭后检测_批次号 }}</span>
					</template>
				</el-table-column>
				<el-table-column label="板号" prop="number" fixed="left">
				</el-table-column>
				<el-table-column label="炉号" prop="" 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="扭转角" align="center" class-name="colorheader1">
					<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.扭后检测_缺陷项_扭转角不合格?1-scope.row.data.扭后检测_缺陷项_扭转角不合格:1 }}</span>
						</template>
					</el-table-column>
				</el-table-column>
				<el-table-column label="暗点" align="center" 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 label="可加工" class-name="colorheader2">
						<template #default="scope">
							<span v-if="scope.row.data.扭后检测_检测项_暗点合格||scope.row.data.扭后检测_检测项_暗点不合格">0</span>
							<span v-else>1</span>
						</template>
					</el-table-column>
				</el-table-column>
				<el-table-column label="暗点重" align="center" class-name="colorheader3">
					<template #default="scope">
						<span>{{scope.row.data.扭后检测_缺陷项_暗点重?scope.row.data.扭后检测_缺陷项_暗点重:0 }}</span>
					</template>
				</el-table-column>
				<el-table-column label="黑网" align="center" class-name="colorheader4">
					<el-table-column label="轻" align="center" class-name="colorheader4">
						<template #default="scope">
							<span>{{ scope.row.data.扭后检测_缺陷项_黑网轻?scope.row.data.扭后检测_缺陷项_黑网轻:0 }}</span>
						</template>
					</el-table-column>
					<el-table-column label="重" align="center" class-name="colorheader4">
						<template #default="scope">
							<span>{{ scope.row.data.扭后检测_缺陷项_黑网重?scope.row.data.扭后检测_缺陷项_黑网重:0 }}</span>
						</template>
					</el-table-column>
					<el-table-column label="废" align="center" 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.扭后检测_缺陷项_白网重?scope.row.data.扭后检测_缺陷项_白网重:0 }}</span>
						</template>
					</el-table-column>
				</el-table-column>
				<el-table-column label="小网" align="center" class-name="colorheader6">
					<el-table-column label="轻" align="center" class-name="colorheader6">
						<template #default="scope">
							<span>{{scope.row.扭后检测_缺陷项_小网轻? scope.row.扭后检测_缺陷项_小网轻:0}}</span>
						</template>
					</el-table-column>
					<el-table-column label="重" align="center" class-name="colorheader6">
						<template #default="scope">
							<span>{{scope.row.扭后检测_缺陷项_小网重?scope.row.扭后检测_缺陷项_小网重:0 }}</span>
						</template>
					</el-table-column>
					<el-table-column label="废" align="center" class-name="colorheader6">
						<template #default="scope">
							<span>{{scope.row.扭后检测_缺陷项_小网废?scope.row.扭后检测_缺陷项_小网废:0 }}</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="扭后" align="center" class-name="colorheader1">
					<el-table-column label="炸纹" align="center" class-name="colorheader1">
						<template #default="scope">
							<span>{{scope.row.data.扭后检测_缺陷项_扭后炸纹?scope.row.data.扭后检测_缺陷项_扭后炸纹:0 }}</span>
						</template>
					</el-table-column>
					<el-table-column label="炸废" align="center" 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="改直" align="center" class-name="colorheader2">
					<template #default="scope">
						<span>{{scope.row.data.扭后检测_缺陷项_改直?scope.row.data.扭后检测_缺陷项_改直:0 }}</span>
					</template>
				</el-table-column>
				<el-table-column label="S畸变不合格" align="center" class-name="colorheader3">
					<template #default="scope">
						<span>{{scope.row.data.扭后检测_缺陷项_S畸变不合格?scope.row.data.扭后检测_缺陷项_S畸变不合格:0 }}</span>
					</template>
				</el-table-column>
				<el-table-column label="弓形畸变不合格" align="center" class-name="colorheader4">
					<template #default="scope">
						<span>{{scope.row.data.扭后检测_缺陷项_弓形畸变不合格?scope.row.data.扭后检测_缺陷项_S畸变不合格:0 }}</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="colorheader6">
					<template #default="scope">
						<span>{{scope.row.data.扭后检测_缺陷项_花丝?scope.row.data.扭后检测_缺陷项_花丝:0 }}</span>
					</template>
				</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="色差" align="center" class-name="colorheader1">
					<template #default="scope">
						<span>{{scope.row.data.扭后检测_缺陷项_色差?scope.row.data.扭后检测_缺陷项_色差:0 }}</span>
					</template>
				</el-table-column>
				<el-table-column label="改实验" align="center" class-name="colorheader2">
					<template #default="scope">
						<span>{{scope.row.data.扭后检测_缺陷项_改实验?scope.row.data.扭后检测_缺陷项_改实验:0 }}</span>
					</template>
				</el-table-column>
				<el-table-column label="备注" align="center" class-name="colorheader3">
					<template #default="scope">
						<span v-if="scope.row.扭后检测_备注">{{scope.row.扭后检测_备注 }}</span>
					</template>
				</el-table-column>
			</scTable>
		</el-main>
	</el-container>
</template>

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

			obj1.field = 'data__扭后检测_日期';
			obj1.value = that.query.last_time__gte;
			obj1.compare = 'gte';

			obj2.field = 'data__扭后检测_日期';
			obj2.value = that.query.last_time__lte;
			obj2.compare = 'lte';

			obj3.field = 'material__name';
			obj3.value = that.query.name__contains;
			obj3.compare = 'contains';

			obj4.field = 'number';
			obj4.value = that.query.number__contains;
			obj4.compare = 'contains';

			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);
			}
			if(that.query.number__contains!==''&&that.query.number__contains!==null){
				querys[0].push(obj4);
			}
			that.querys.querys = querys;
			this.$refs.table.queryData(that.querys);
		},
	},
};
</script>

<style scoped>
</style>
