<template>
	<el-container>
		<el-header>
			<div class="right-panel">
				<el-date-picker
					v-model="queryDate"
					type="date"
					placeholder="查询日期"
					value-format="YYYY-MM-DD"
					style="width: 160px"
				>
				</el-date-picker>
				<el-button
					type="primary"
					icon="el-icon-search"
					@click="handleQuery"
				></el-button>
			</div>
		</el-header>
		<el-main>
			<!-- 0 -->
			<el-card shadow="never" style="margin-bottom: 8px">
				<el-row :gutter="10">
					<el-col :lg="10">
						<el-card shadow="never">
							<div id="bachart0"></div>
						</el-card>
					</el-col>
					<el-col :lg="14">
						<el-card shadow="never" style="position: relative">
							<el-button
								@click="handleExport(0)"
								class="tables"
								type="primary"
								>导出</el-button
							>
							<el-table
								:data="tableData0"
								id="exportDiv0"
								:height="300"
							>
								<el-table-column type="index" width="50" />
								<el-table-column label="物料名称" prop="物料名称" min-width="100">
								</el-table-column>
								<el-table-column label="生产数" prop="生产数">
								</el-table-column>
								<el-table-column label="合格数" prop="合格数">
								</el-table-column>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</el-table-column>
								<el-table-column label="前道不良" prop="加工前不良">
								</el-table-column>
								<el-table-column label="不合格原因及数量" align="center">
									<el-table-column label="崩边-来料(B)" prop="崩边-来料(B)"></el-table-column>
									<el-table-column label="其他" prop="其他"></el-table-column>
									<el-table-column label="合计" prop="不合格数"></el-table-column>
								</el-table-column>
							</el-table>
						</el-card>
					</el-col>
				</el-row>
			</el-card>
			<!-- 1 -->
			<el-card shadow="never" style="margin-bottom: 8px">
				<el-row :gutter="10">
					<el-col :lg="10">
						<el-card shadow="never">
							<div id="bachart1"></div>
						</el-card>
					</el-col>
					<el-col :lg="14">
						<el-card shadow="never" style="position: relative">
							<el-button
								@click="handleExport(1)"
								class="tables"
								type="primary"
								>导出</el-button
							>
							<el-table
								:data="tableData1"
								id="exportDiv1"
								:height="300"
							>
								<el-table-column type="index" width="50" />
								<el-table-column label="物料名称" prop="物料名称" min-width="100">
								</el-table-column>
								<el-table-column label="生产数" prop="生产数">
								</el-table-column>
								<el-table-column label="合格数" prop="合格数">
								</el-table-column>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</el-table-column>
								<el-table-column label="前道不良" prop="加工前不良">
								</el-table-column>
								<el-table-column label="不合格原因及数量" align="center">
									<el-table-column label="破损" prop="破损"></el-table-column>
									<el-table-column label="线痕" prop="线痕"></el-table-column>
									<el-table-column label="麻点" prop="麻点"></el-table-column>
									<el-table-column label="小崩边" prop="小崩边"></el-table-column>
									<el-table-column label="雾面" prop="雾面"></el-table-column>
									<el-table-column label="水纹" prop="水纹"></el-table-column>
									<el-table-column label="崩边" prop="崩边"></el-table-column>
									<el-table-column label="气泡" prop="气泡"></el-table-column>
									<el-table-column label="划伤" prop="划伤"></el-table-column>
									<el-table-column label="人为磕碰" prop="人为磕碰"></el-table-column>
									<el-table-column label="设备故障" prop="设备故障"></el-table-column>
									<el-table-column label="调机破损" prop="调机破损"></el-table-column>
									<el-table-column label="断裂" prop="断裂"></el-table-column>
									<el-table-column label="裂纹" prop="裂纹"></el-table-column>
									<el-table-column label="脏污" prop="脏污"></el-table-column>
									<el-table-column label="断点" prop="断点"></el-table-column>
									<el-table-column label="其他" prop="其他"></el-table-column>
									<el-table-column label="合计" prop="不合格数"></el-table-column>
								</el-table-column>
							</el-table>
						</el-card>
					</el-col>
				</el-row>
			</el-card>
			<!-- 2 -->
			<el-card shadow="never" style="margin-bottom: 8px">
				<el-row :gutter="10">
					<el-col :lg="10">
						<el-card shadow="never">
							<div id="bachart2"></div>
						</el-card>
					</el-col>
					<el-col :lg="14">
						<el-card shadow="never" style="position: relative">
							<el-button
								@click="handleExport(2)"
								class="tables"
								type="primary"
								>导出</el-button
							>
							<el-table
								:data="tableData2"
								id="exportDiv2"
								:height="300"
							>
								<el-table-column type="index" width="50" />
								<el-table-column label="物料名称"	 prop="物料名称" min-width="100">
								</el-table-column>
								<el-table-column label="生产数" prop="生产数">
								</el-table-column>
								<el-table-column label="合格数" prop="合格数">
								</el-table-column>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</el-table-column>
								<el-table-column label="前道不良" prop="加工前不良">
								</el-table-column>
								<el-table-column label="不合格原因及数量" align="center">
									<el-table-column label="其他" prop="其他"></el-table-column>
									<el-table-column label="合计" prop="不合格数"></el-table-column>
								</el-table-column>
							</el-table>
						</el-card>
					</el-col>
				</el-row>
			</el-card>
			<!-- 3 -->
			<el-card shadow="never" style="margin-bottom: 8px">
				<el-row :gutter="10">
					<el-col :lg="10">
						<el-card shadow="never">
							<div id="bachart3"></div>
						</el-card>
					</el-col>
					<el-col :lg="14">
						<el-card shadow="never" style="position: relative">
							<el-button
								@click="handleExport(3)"
								class="tables"
								type="primary"
								>导出</el-button
							>
							<el-table
								:data="tableData3"
								id="exportDiv3"
								:height="300"
							>
								<el-table-column type="index" width="50" />
								<el-table-column label="物料名称"	 prop="物料名称" min-width="100">
								</el-table-column>
								<el-table-column label="生产数" prop="生产数">
								</el-table-column>
								<el-table-column label="合格数" prop="合格数">
								</el-table-column>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</el-table-column>
								<el-table-column label="前道不良" prop="加工前不良">
								</el-table-column>
								<el-table-column label="不合格原因及数量" align="center">
									<el-table-column label="其他" prop="其他"></el-table-column>
									<el-table-column label="合计" prop="不合格数"></el-table-column>
								</el-table-column>
							</el-table>
						</el-card>
					</el-col>
				</el-row>
			</el-card>
			<!-- 4 -->
			<el-card shadow="never" style="margin-bottom: 8px">
				<el-row :gutter="10">
					<el-col :lg="10">
						<el-card shadow="never">
							<div id="bachart4"></div>
						</el-card>
					</el-col>
					<el-col :lg="14">
						<el-card shadow="never" style="position: relative">
							<el-button
								@click="handleExport(4)"
								class="tables"
								type="primary"
								>导出</el-button
							>
							<el-table
								:data="tableData4"
								id="exportDiv4"
								:height="300"
							>
								<el-table-column type="index" width="50" />
								<el-table-column label="物料名称"	 prop="物料名称" min-width="100">
								</el-table-column>
								<el-table-column label="生产数" prop="生产数">
								</el-table-column>
								<el-table-column label="合格数" prop="合格数">
								</el-table-column>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</el-table-column>
								<el-table-column label="前道不良" prop="加工前不良">
								</el-table-column>
								<el-table-column label="不合格原因及数量" align="center">
									<el-table-column label="破损" prop="破损"></el-table-column>
									<el-table-column label="线痕" prop="线痕"></el-table-column>
									<el-table-column label="麻点" prop="麻点"></el-table-column>
									<el-table-column label="小崩边" prop="小崩边"></el-table-column>
									<el-table-column label="雾面" prop="雾面"></el-table-column>
									<el-table-column label="水纹" prop="水纹"></el-table-column>
									<el-table-column label="崩边" prop="崩边"></el-table-column>
									<el-table-column label="气泡" prop="气泡"></el-table-column>
									<el-table-column label="划伤" prop="划伤"></el-table-column>
									<el-table-column label="其他" prop="其他"></el-table-column>
									<el-table-column label="合计" prop="不合格数"></el-table-column>
								</el-table-column>
								
							</el-table>
						</el-card>
					</el-col>
				</el-row>
			</el-card>
			<!-- 5 -->
			<el-card shadow="never" style="margin-bottom: 8px">
				<el-row :gutter="10">
					<el-col :lg="10">
						<el-card shadow="never">
							<div id="bachart5"></div>
						</el-card>
					</el-col>
					<el-col :lg="14">
						<el-card shadow="never" style="position: relative">
							<el-button
								@click="handleExport(5)"
								class="tables"
								type="primary"
								>导出</el-button
							>
							<el-table
								:data="tableData5"
								id="exportDiv5"
								:height="300"
							>
								<el-table-column type="index" width="50" />
								<el-table-column label="物料名称"	 prop="物料名称" min-width="100">
								</el-table-column>
								<el-table-column label="生产数" prop="生产数">
								</el-table-column>
								<el-table-column label="合格数" prop="合格数">
								</el-table-column>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</el-table-column>
								<el-table-column label="前道不良" prop="加工前不良">
								</el-table-column>
								<el-table-column label="不合格原因及数量" align="center">
									<el-table-column label="其他" prop="其他"></el-table-column>
									<el-table-column label="合计" prop="不合格数"></el-table-column>
								</el-table-column>
								
							</el-table>
						</el-card>
					</el-col>
				</el-row>
			</el-card>
			<!-- 6 -->
			<el-card shadow="never" style="margin-bottom: 8px">
				<el-row :gutter="10">
					<el-col :lg="10">
						<el-card shadow="never">
							<div id="bachart6"></div>
						</el-card>
					</el-col>
					<el-col :lg="14">
						<el-card shadow="never" style="position: relative">
							<el-button
								@click="handleExport(6)"
								class="tables"
								type="primary"
								>导出</el-button
							>
							<el-table
								:data="tableData6"
								id="exportDiv6"
								:height="300"
							>
								<el-table-column type="index" width="50" />
								<el-table-column label="物料名称"	 prop="物料名称" min-width="100">
								</el-table-column>
								<el-table-column label="生产数" prop="生产数">
								</el-table-column>
								<el-table-column label="合格数" prop="合格数">
								</el-table-column>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</el-table-column>
								<el-table-column label="前道不良" prop="加工前不良">
								</el-table-column>
								<el-table-column label="不合格原因及数量" align="center">
									<el-table-column label="破损" prop="破损"></el-table-column>
									<el-table-column label="线痕" prop="线痕"></el-table-column>
									<el-table-column label="麻点" prop="麻点"></el-table-column>
									<el-table-column label="小崩边" prop="小崩边"></el-table-column>
									<el-table-column label="雾面" prop="雾面"></el-table-column>
									<el-table-column label="水纹" prop="水纹"></el-table-column>
									<el-table-column label="崩边" prop="崩边"></el-table-column>
									<el-table-column label="气泡" prop="气泡"></el-table-column>
									<el-table-column label="划伤" prop="划伤"></el-table-column>
									<el-table-column label="其他" prop="其他"></el-table-column>
									<el-table-column label="合计" prop="不合格数"></el-table-column>
								</el-table-column>
							</el-table>
						</el-card>
					</el-col>
				</el-row>
			</el-card>
			<!-- 7 -->
			<el-card shadow="never" style="margin-bottom: 8px">
				<el-row :gutter="10">
					<el-col :lg="10">
						<el-card shadow="never">
							<div id="bachart7"></div>
						</el-card>
					</el-col>
					<el-col :lg="14">
						<el-card shadow="never" style="position: relative">
							<el-button
								@click="handleExport(7)"
								class="tables"
								type="primary"
								>导出</el-button
							>
							<el-table
								:data="tableData7"
								id="exportDiv7"
								:height="300"
							>
								<el-table-column type="index" width="50" />
								<el-table-column label="物料名称"	 prop="物料名称" min-width="100">
								</el-table-column>
								<el-table-column label="生产数" prop="生产数">
								</el-table-column>
								<el-table-column label="合格数" prop="合格数">
								</el-table-column>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</el-table-column>
								<el-table-column label="前道不良" prop="加工前不良">
								</el-table-column>
								<el-table-column label="不合格原因及数量" align="center">
									<el-table-column label="破损" prop="破损"></el-table-column>
									<el-table-column label="线痕" prop="线痕"></el-table-column>
									<el-table-column label="麻点" prop="麻点"></el-table-column>
									<el-table-column label="小崩边" prop="小崩边"></el-table-column>
									<el-table-column label="雾面" prop="雾面"></el-table-column>
									<el-table-column label="水纹" prop="水纹"></el-table-column>
									<el-table-column label="崩边" prop="崩边"></el-table-column>
									<el-table-column label="气泡" prop="气泡"></el-table-column>
									<el-table-column label="划伤" prop="划伤"></el-table-column>
									<el-table-column label="其他" prop="其他"></el-table-column>
									<el-table-column label="合计" prop="不合格数"></el-table-column>
								</el-table-column>
							</el-table>
						</el-card>
					</el-col>
				</el-row>
			</el-card>
			<!-- 8 -->
			<el-card shadow="never" style="margin-bottom: 8px">
				<el-row :gutter="10">
					<el-col :lg="10">
						<el-card shadow="never">
							<div id="bachart8"></div>
						</el-card>
					</el-col>
					<el-col :lg="14">
						<el-card shadow="never" style="position: relative">
							<el-button
								@click="handleExport(8)"
								class="tables"
								type="primary"
								>导出</el-button
							>
							<el-table
								:data="tableData8"
								id="exportDiv8"
								:height="300"
							>
								<el-table-column type="index" width="50" />
								<el-table-column label="物料名称"	 prop="物料名称" min-width="100">
								</el-table-column>
								<el-table-column label="生产数" prop="生产数">
								</el-table-column>
								<el-table-column label="合格数" prop="合格数">
								</el-table-column>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</el-table-column>
								<el-table-column label="前道不良" prop="加工前不良">
								</el-table-column>
								<el-table-column label="不合格原因及数量" align="center">
									<el-table-column label="破损" prop="破损"></el-table-column>
									<el-table-column label="线痕" prop="线痕"></el-table-column>
									<el-table-column label="麻点" prop="麻点"></el-table-column>
									<el-table-column label="小崩边" prop="小崩边"></el-table-column>
									<el-table-column label="雾面" prop="雾面"></el-table-column>
									<el-table-column label="水纹" prop="水纹"></el-table-column>
									<el-table-column label="崩边" prop="崩边"></el-table-column>
									<el-table-column label="气泡" prop="气泡"></el-table-column>
									<el-table-column label="划伤" prop="划伤"></el-table-column>
									<el-table-column label="其他" prop="其他"></el-table-column>
									<el-table-column label="合计" prop="不合格数"></el-table-column>
								</el-table-column>
							</el-table>
						</el-card>
					</el-col>
				</el-row>
			</el-card>
			<!-- 9 -->
			<el-card shadow="never" style="margin-bottom: 8px">
				<el-row :gutter="10">
					<el-col :lg="10">
						<el-card shadow="never">
							<div id="bachart9"></div>
						</el-card>
					</el-col>
					<el-col :lg="14">
						<el-card shadow="never" style="position: relative">
							<el-button
								@click="handleExport(9)"
								class="tables"
								type="primary"
								>导出</el-button
							>
							<el-table
								:data="tableData9"
								id="exportDiv9"
								:height="300"
							>
								<el-table-column type="index" width="50" />
								<el-table-column label="物料名称"	 prop="物料名称" min-width="100">
								</el-table-column>
								<el-table-column label="生产数" prop="生产数">
								</el-table-column>
								<el-table-column label="合格数" prop="合格数">
								</el-table-column>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</el-table-column>
								<el-table-column label="前道不良" prop="加工前不良">
								</el-table-column>
								<el-table-column label="不合格原因及数量" align="center">
									<el-table-column label="破损" prop="破损"></el-table-column>
									<el-table-column label="线痕" prop="线痕"></el-table-column>
									<el-table-column label="麻点" prop="麻点"></el-table-column>
									<el-table-column label="小崩边" prop="小崩边"></el-table-column>
									<el-table-column label="雾面" prop="雾面"></el-table-column>
									<el-table-column label="水纹" prop="水纹"></el-table-column>
									<el-table-column label="崩边" prop="崩边"></el-table-column>
									<el-table-column label="气泡" prop="气泡"></el-table-column>
									<el-table-column label="划伤" prop="划伤"></el-table-column>
									<el-table-column label="内圈不良" prop="内圈不良"></el-table-column>
									<el-table-column label="断裂" prop="断裂"></el-table-column>
									<el-table-column label="裂纹" prop="裂纹"></el-table-column>
									<el-table-column label="少料" prop="少料"></el-table-column>
									<el-table-column label="来料不圆" prop="来料不圆"></el-table-column>
									<el-table-column label="其他" prop="其他"></el-table-column>
									<el-table-column label="合计" prop="不合格数"></el-table-column>
								</el-table-column>
							</el-table>
						</el-card>
					</el-col>
				</el-row>
			</el-card>
			<!-- 10 -->
			<el-card shadow="never" style="margin-bottom: 8px">
				<el-row :gutter="10">
					<el-col :lg="10">
						<el-card shadow="never">
							<div id="bachart10"></div>
						</el-card>
					</el-col>
					<el-col :lg="14">
						<el-card shadow="never" style="position: relative">
							<el-button
								@click="handleExport(10)"
								class="tables"
								type="primary"
								>导出</el-button
							>
							<el-table
								:data="tableData10"
								id="exportDiv10"
								:height="300"
							>
								<el-table-column type="index" width="50" />
								<el-table-column label="物料名称"	 prop="物料名称" min-width="100">
								</el-table-column>
								<el-table-column label="生产数" prop="生产数">
								</el-table-column>
								<el-table-column label="合格数" prop="合格数">
								</el-table-column>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</el-table-column>
								<el-table-column label="前道不良" prop="加工前不良">
								</el-table-column>
								<el-table-column label="不合格原因及数量" align="center">
									<el-table-column label="破损" prop="破损"></el-table-column>
									<el-table-column label="线痕" prop="线痕"></el-table-column>
									<el-table-column label="麻点" prop="麻点"></el-table-column>
									<el-table-column label="小崩边" prop="小崩边"></el-table-column>
									<el-table-column label="雾面" prop="雾面"></el-table-column>
									<el-table-column label="水纹" prop="水纹"></el-table-column>
									<el-table-column label="崩边" prop="崩边"></el-table-column>
									<el-table-column label="气泡" prop="气泡"></el-table-column>
									<el-table-column label="划伤" prop="划伤"></el-table-column>
									<el-table-column label="内圈不良" prop="内圈不良"></el-table-column>
									<el-table-column label="断裂" prop="断裂"></el-table-column>
									<el-table-column label="裂纹" prop="裂纹"></el-table-column>
									<el-table-column label="少料" prop="少料"></el-table-column>
									<el-table-column label="来料不圆" prop="来料不圆"></el-table-column>
									<el-table-column label="合计" prop="不合格数"></el-table-column>
								</el-table-column>
							</el-table>
						</el-card>
					</el-col>
				</el-row>
			</el-card>
			<!-- 11 -->
			<el-card shadow="never" style="margin-bottom: 8px">
				<el-row :gutter="10">
					<el-col :lg="10">
						<el-card shadow="never">
							<div id="bachart11"></div>
						</el-card>
					</el-col>
					<el-col :lg="14">
						<el-card shadow="never" style="position: relative">
							<el-button
								@click="handleExport(11)"
								class="tables"
								type="primary"
								>导出</el-button
							>
							<el-table
								:data="tableData11"
								id="exportDiv11"
								:height="300"
							>
								<el-table-column type="index" width="50" />
								<el-table-column label="物料名称"	 prop="物料名称" min-width="100">
								</el-table-column>
								<el-table-column label="生产数" prop="生产数">
								</el-table-column>
								<el-table-column label="合格数" prop="合格数">
								</el-table-column>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</el-table-column>
								<el-table-column label="前道不良" prop="加工前不良">
								</el-table-column>
								<el-table-column label="不合格原因及数量" align="center">
									<el-table-column label="破损" prop="破损"></el-table-column>
									<el-table-column label="线痕" prop="线痕"></el-table-column>
									<el-table-column label="麻点" prop="麻点"></el-table-column>
									<el-table-column label="小崩边" prop="小崩边"></el-table-column>
									<el-table-column label="雾面" prop="雾面"></el-table-column>
									<el-table-column label="水纹" prop="水纹"></el-table-column>
									<el-table-column label="崩边" prop="崩边"></el-table-column>
									<el-table-column label="气泡" prop="气泡"></el-table-column>
									<el-table-column label="划伤" prop="划伤"></el-table-column>
									<el-table-column label="人为磕碰" prop="人为磕碰"></el-table-column>
									<el-table-column label="设备故障" prop="设备故障"></el-table-column>
									<el-table-column label="调机破损" prop="调机破损"></el-table-column>
									<el-table-column label="断裂" prop="断裂"></el-table-column>
									<el-table-column label="裂纹" prop="裂纹"></el-table-column>
									<el-table-column label="脏污" prop="脏污"></el-table-column>
									<el-table-column label="断点" prop="断点"></el-table-column>
									<el-table-column label="其他" prop="其他"></el-table-column>
									<el-table-column label="合计" prop="不合格数"></el-table-column>
								</el-table-column>
							</el-table>
						</el-card>
					</el-col>
				</el-row>
			</el-card>
			<!-- 12 -->
			<el-card shadow="never" style="margin-bottom: 8px">
				<el-row :gutter="10">
					<el-col :lg="10">
						<el-card shadow="never">
							<div id="bachart12"></div>
						</el-card>
					</el-col>
					<el-col :lg="14">
						<el-card shadow="never" style="position: relative">
							<el-button
								@click="handleExport(12)"
								class="tables"
								type="primary"
								>导出</el-button
							>
							<el-table
								:data="tableData12"
								id="exportDiv12"
								:height="300"
							>
								<el-table-column type="index" width="50" />
								<el-table-column label="物料名称"	 prop="物料名称" min-width="100">
								</el-table-column>
								<el-table-column label="生产数" prop="生产数">
								</el-table-column>
								<el-table-column label="合格数" prop="合格数">
								</el-table-column>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</el-table-column>
								<el-table-column label="前道不良" prop="加工前不良">
								</el-table-column>
								<el-table-column label="不合格数" align="center">
									<el-table-column label="破损" prop="破损"></el-table-column>
									<el-table-column label="线痕" prop="线痕"></el-table-column>
									<el-table-column label="麻点" prop="麻点"></el-table-column>
									<el-table-column label="小崩边" prop="小崩边"></el-table-column>
									<el-table-column label="雾面" prop="雾面"></el-table-column>
									<el-table-column label="水纹" prop="水纹"></el-table-column>
									<el-table-column label="崩边" prop="崩边"></el-table-column>
									<el-table-column label="气泡" prop="气泡"></el-table-column>
									<el-table-column label="划伤" prop="划伤"></el-table-column>
									<el-table-column label="其他" prop="其他"></el-table-column>
									<el-table-column label="合计" prop="不合格数"></el-table-column>
								</el-table-column>
							
							</el-table>
						</el-card>
					</el-col>
				</el-row>
			</el-card>
			<!-- 13 -->
			<el-card shadow="never" style="margin-bottom: 8px">
				<el-row :gutter="10">
					<el-col :lg="10">
						<el-card shadow="never">
							<div id="bachart13"></div>
						</el-card>
					</el-col>
					<el-col :lg="14">
						<el-card shadow="never" style="position: relative">
							<el-button
								@click="handleExport(13)"
								class="tables"
								type="primary"
								>导出</el-button
							>
							<el-table
								:data="tableData13"
								id="exportDiv13"
								:height="300"
							>
								<el-table-column type="index" width="50" />
								<el-table-column label="物料名称"	 prop="物料名称" min-width="100">
								</el-table-column>
								<el-table-column label="生产数" prop="生产数">
								</el-table-column>
								<el-table-column label="合格数" prop="合格数">
								</el-table-column>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</el-table-column>
								<el-table-column label="前道不良" prop="加工前不良">
								</el-table-column>
								<el-table-column label="不合格数" align="center">
									<el-table-column label="破损" prop="破损"></el-table-column>
									<el-table-column label="线痕" prop="线痕"></el-table-column>
									<el-table-column label="麻点" prop="麻点"></el-table-column>
									<el-table-column label="小崩边" prop="小崩边"></el-table-column>
									<el-table-column label="雾面" prop="雾面"></el-table-column>
									<el-table-column label="水纹" prop="水纹"></el-table-column>
									<el-table-column label="崩边" prop="崩边"></el-table-column>
									<el-table-column label="气泡" prop="气泡"></el-table-column>
									<el-table-column label="划伤" prop="划伤"></el-table-column>
									<el-table-column label="其他" prop="其他"></el-table-column>
									<el-table-column label="合计" prop="不合格数"></el-table-column>
								</el-table-column>
							</el-table>
						</el-card>
					</el-col>
				</el-row>
			</el-card>
			<!-- 14 -->
			<el-card shadow="never" style="margin-bottom: 8px">
				<el-row :gutter="10">
					<el-col :lg="10">
						<el-card shadow="never">
							<div id="bachart14"></div>
						</el-card>
					</el-col>
					<el-col :lg="14">
						<el-card shadow="never" style="position: relative">
							<el-button
								@click="handleExport(14)"
								class="tables"
								type="primary"
								>导出</el-button
							>
							<el-table
								:data="tableData14"
								id="exportDiv14"
								:height="300"
							>
								<el-table-column type="index" width="50" />
								<el-table-column label="物料名称"	 prop="物料名称" min-width="100">
								</el-table-column>
								<el-table-column label="生产数" prop="生产数">
								</el-table-column>
								<el-table-column label="合格数" prop="合格数">
								</el-table-column>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</el-table-column>
								<el-table-column label="前道不良" prop="加工前不良">
								</el-table-column>
								<el-table-column label="不合格数" align="center">
									<el-table-column label="破损" prop="破损"></el-table-column>
									<el-table-column label="线痕" prop="线痕"></el-table-column>
									<el-table-column label="麻点" prop="麻点"></el-table-column>
									<el-table-column label="小崩边" prop="小崩边"></el-table-column>
									<el-table-column label="雾面" prop="雾面"></el-table-column>
									<el-table-column label="水纹" prop="水纹"></el-table-column>
									<el-table-column label="崩边" prop="崩边"></el-table-column>
									<el-table-column label="气泡" prop="气泡"></el-table-column>
									<el-table-column label="划伤" prop="划伤"></el-table-column>
									<el-table-column label="其他" prop="其他"></el-table-column>
									<el-table-column label="合计" prop="不合格数"></el-table-column>
								</el-table-column>
							</el-table>
						</el-card>
					</el-col>
				</el-row>
			</el-card>
			<!-- 15 -->
			<el-card shadow="never" style="margin-bottom: 8px">
				<el-row :gutter="10">
					<el-col :lg="10">
						<el-card shadow="never">
							<div id="bachart15"></div>
						</el-card>
					</el-col>
					<el-col :lg="14">
						<el-card shadow="never" style="position: relative">
							<el-button
								@click="handleExport(15)"
								class="tables"
								type="primary"
								>导出</el-button
							>
							<el-table
								:data="tableData15"
								id="exportDiv15"
								:height="300"
							>
								<el-table-column type="index" width="50" />
								<el-table-column label="物料名称"	 prop="物料名称" min-width="100">
								</el-table-column>
								<el-table-column label="生产数" prop="生产数">
								</el-table-column>
								<el-table-column label="合格数" prop="合格数">
								</el-table-column>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</el-table-column>
								<el-table-column label="前道不良" prop="加工前不良">
								</el-table-column>
								<el-table-column label="不合格数" align="center">
									<el-table-column label="准合格(B)" prop="准合格(B)"></el-table-column>
									<el-table-column label="圆准(B)" prop="圆准(B)"></el-table-column>
									<el-table-column label="外径发货片(B)" prop="外径发货片(B)"></el-table-column>
									<el-table-column label="黑圈内径" prop="黑圈内径"></el-table-column>
									<el-table-column label="圆度" prop="圆度"></el-table-column>
									<el-table-column label="黑圈外径" prop="黑圈外径"></el-table-column>
									<el-table-column label="产品外径小" prop="产品外径小"></el-table-column>
									<el-table-column label="产品同心度" prop="产品同心度"></el-table-column>
									<el-table-column label="黑圈缺口" prop="黑圈缺口"></el-table-column>
									<el-table-column label="前道崩" prop="前道崩"></el-table-column>
									<el-table-column label="产品外径大(返修)" prop="产品外径大(返修)"></el-table-column>
									<el-table-column label="破损" prop="破损"></el-table-column>
									<el-table-column label="合计" prop="不合格数"></el-table-column>
								</el-table-column>
							</el-table>
						</el-card>
					</el-col>
				</el-row>
			</el-card>
			<!-- 16 -->
			<el-card shadow="never" style="margin-bottom: 8px">
				<el-row :gutter="10">
					<el-col :lg="10">
						<el-card shadow="never">
							<div id="bachart16"></div>
						</el-card>
					</el-col>
					<el-col :lg="14">
						<el-card shadow="never" style="position: relative">
							<el-button
								@click="handleExport(16)"
								class="tables"
								type="primary"
								>导出</el-button
							>
							<el-table
								:data="tableData16"
								id="exportDiv16"
								:height="300"
							>
								<el-table-column type="index" width="50" />
								<el-table-column label="物料名称"	 prop="物料名称" min-width="100">
								</el-table-column>
								<el-table-column label="生产数" prop="生产数">
								</el-table-column>
								<el-table-column label="合格数" prop="合格数">
								</el-table-column>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</el-table-column>
								<el-table-column label="前道不良" prop="加工前不良">
								</el-table-column>
								<el-table-column label="不合格数" align="center">
									<el-table-column label="破损" prop="破损"></el-table-column>
									<el-table-column label="线痕" prop="线痕"></el-table-column>
									<el-table-column label="麻点" prop="麻点"></el-table-column>
									<el-table-column label="小崩边" prop="小崩边"></el-table-column>
									<el-table-column label="雾面" prop="雾面"></el-table-column>
									<el-table-column label="水纹" prop="水纹"></el-table-column>
									<el-table-column label="崩边" prop="崩边"></el-table-column>
									<el-table-column label="气泡" prop="气泡"></el-table-column>
									<el-table-column label="划伤" prop="划伤"></el-table-column>
									<el-table-column label="其他" prop="其他"></el-table-column>
									<el-table-column label="合计" prop="不合格数"></el-table-column>
								</el-table-column>
							</el-table>
						</el-card>
					</el-col>
				</el-row>
			</el-card>
			<!-- 17 -->
			<el-card shadow="never" style="margin-bottom: 8px">
				<el-row :gutter="10">
					<el-col :lg="10">
						<el-card shadow="never">
							<div id="bachart17"></div>
						</el-card>
					</el-col>
					<el-col :lg="14">
						<el-card shadow="never" style="position: relative">
							<el-button
								@click="handleExport(17)"
								class="tables"
								type="primary"
								>导出</el-button
							>
							<el-table
								:data="tableData17"
								id="exportDiv17"
								:height="300"
							>
								<el-table-column type="index" width="50" />
								<el-table-column label="物料名称"	 prop="物料名称" min-width="100">
								</el-table-column>
								<el-table-column label="生产数" prop="生产数">
								</el-table-column>
								<el-table-column label="合格数" prop="合格数">
								</el-table-column>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</el-table-column>
								<el-table-column label="前道不良" prop="加工前不良">
								</el-table-column>
								<el-table-column label="不合格数" align="center">
									<el-table-column label="浅水纹(B)" prop="浅水纹(B)"></el-table-column>
									<el-table-column label="浅气泡(B)" prop="浅气泡(B)"></el-table-column>
									<el-table-column label="浅划麻(B)" prop="浅划麻(B)"></el-table-column>
									<el-table-column label="小崩边(B)" prop="小崩边(B)"></el-table-column>
									<el-table-column label="脏(返修)" prop="脏(返修)"></el-table-column>
									<el-table-column label="气泡" prop="气泡"></el-table-column>
									<el-table-column label="黑圈变形" prop="黑圈变形"></el-table-column>
									<el-table-column label="双面划麻" prop="双面划麻"></el-table-column>
									<el-table-column label="重水纹" prop="重水纹"></el-table-column>
									<el-table-column label="棕点" prop="棕点"></el-table-column>
									<el-table-column label="倒角" prop="倒角"></el-table-column>
									<el-table-column label="大崩" prop="大崩"></el-table-column>
									<el-table-column label="棕圈" prop="棕圈"></el-table-column>
									<el-table-column label="蓝圈" prop="蓝圈"></el-table-column>
									<el-table-column label="破损" prop="破损"></el-table-column>
									<el-table-column label="漏光" prop="漏光"></el-table-column>
									<el-table-column label="尺寸小" prop="尺寸小"></el-table-column>
									<el-table-column label="发白" prop="发白"></el-table-column>
									<el-table-column label="划麻(返修)" prop="划麻(返修)"></el-table-column>
									<el-table-column label="黑圈缺口" prop="黑圈缺口"></el-table-column>
									<el-table-column label="合计" prop="不合格数"></el-table-column>
								</el-table-column>
							</el-table>
						</el-card>
					</el-col>
				</el-row>
			</el-card>
			<!-- 18 -->
			<el-card shadow="never" style="margin-bottom: 8px">
				<el-row :gutter="10">
					<el-col :lg="10">
						<el-card shadow="never">
							<div id="bachart18"></div>
						</el-card>
					</el-col>
					<el-col :lg="14">
						<el-card shadow="never" style="position: relative">
							<el-button
								@click="handleExport(18)"
								class="tables"
								type="primary"
								>导出</el-button
							>
							<el-table
								:data="tableData18"
								id="exportDiv18"
								:height="300"
							>
								<el-table-column type="index" width="50" />
								<el-table-column label="物料名称"	 prop="物料名称" min-width="100">
								</el-table-column>
								<el-table-column label="生产数" prop="生产数">
								</el-table-column>
								<el-table-column label="合格数" prop="合格数">
								</el-table-column>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</el-table-column>
								<el-table-column label="前道不良" prop="加工前不良">
								</el-table-column>
								<el-table-column label="不合格数" align="center">
									<el-table-column label="破损" prop="破损"></el-table-column>
									<el-table-column label="线痕" prop="线痕"></el-table-column>
									<el-table-column label="麻点" prop="麻点"></el-table-column>
									<el-table-column label="小崩边" prop="小崩边"></el-table-column>
									<el-table-column label="雾面" prop="雾面"></el-table-column>
									<el-table-column label="水纹" prop="水纹"></el-table-column>
									<el-table-column label="崩边" prop="崩边"></el-table-column>
									<el-table-column label="气泡" prop="气泡"></el-table-column>
									<el-table-column label="划伤" prop="划伤"></el-table-column>
									<el-table-column label="其他" prop="其他"></el-table-column>
									<el-table-column label="合计" prop="不合格数"></el-table-column>
								</el-table-column>
							</el-table>
						</el-card>
					</el-col>
				</el-row>
			</el-card>
		</el-main>
	</el-container>
</template>
<script>
import * as echarts from "echarts";
import T from "@/components/scEcharts/echarts-theme-T.js";
echarts.registerTheme("T", T);
import scEcharts from "@/components/scEcharts";
function deepCopy(obj) {
	return JSON.parse(JSON.stringify(obj));
}
const ondDayTime = 86400000;
export default {
	name: "chart",
	components: {
		scEcharts,
	},
	data() {
		return {
			query: {
				mgroup_name:'',
				start_date:'',
				end_date:'',
			},
			queryDate:'',
			currentYear: "",
			currentMonth: "",
			mgroupList: ['外协白片抛', '扫边A', '黑化', '退火', '减薄A', '减薄B', '精雕', '外协出司检', '外协一次抛', '磨抛一次抛', '外扫', '扫边B', '倒角','成品抛', '一次超洗', '尺寸检验', '二次超洗', '外观检验', '三次超洗'],
			basicOption: {
				backgroundColor: "transparent",
				title: {
					text: "合格数统计",
				},
				tooltip: {
					trigger: "item",
				},
				legend: {
					top: "3",
					right: "3%",
				},
				grid: {
					top: "80px",
				},
				tooltip: {
					trigger: "axis",
				},
				lenged: [],
				series: [],
			},
			tableData0: [],
			tableData1: [],
			tableData2: [],
			tableData3: [],
			tableData4: [],
			tableData5: [],
			tableData6: [],
			tableData7: [],
			tableData8: [],
			tableData9: [],
			tableData10: [],
			tableData11: [],
			tableData12: [],
			tableData13: [],
			tableData14: [],
			tableData15: [],
			tableData16: [],
			tableData17: [],
			tableData18: [],
			options:[],
		};
	},
	mounted() {
		this.getMgroup();
	},
	methods: {
		getWeekDate(dates){
			let that = this;
			dates = new Date(dates);
			let week =dates.getDay(); //当前时间的week数
			let weekFirst = 0, weekLast = 0; 
			if (week == 0) {
				weekFirst = 6;
				weekLast = 0; //周日特殊处理
			} else {
				weekFirst = week - 1;
				weekLast = 7 - week;
			}
			let first = new Date(dates.getTime() - weekFirst * ondDayTime); //本周周一
			let last = new Date(new Date(dates.getTime() + weekLast * ondDayTime)); //本周周日
			let dateArr = [];
			for (let i = 0; i < 7; i++) {
				let itemDate = new Date(first.getTime() + i * ondDayTime);
				let item = itemDate.toISOString().split('T')[0];
				dateArr.push(item);
			}
			that.weekDateList = dateArr;
			that.query.start_date =first.toISOString().split('T')[0];
			that.query.end_date =last.toISOString().split('T')[0];
			that.options.forEach((item,index)=>{
				that.getData(item,index);
			})
		},
		setChart(name, option = null) {
			// 根据name 渲染数据, option需填写，否则option为模拟数据
			var myChart = echarts.getInstanceByDom(
				document.getElementById(name)
			);
			if (myChart == undefined) {
				myChart = echarts.init(document.getElementById(name), "T");
			}
			if (option == null) {
				option = Object.assign({}, this.basicOption);
			}
			setTimeout(() => {
				try {
					myChart.setOption(option);
				} catch (error) {}
			}, 500);
		},
		getMgroup(){
			let that = this;
			that.$API.mtm.mgroup.list.req({ page: 0}).then((res) => {
				let arr = [];
				res.forEach(item=>{
					let indexes = that.mgroupList.indexOf(item.name);
					if(indexes>-1){
						// that.getDefect(item.id,indexes);
						arr[indexes] = item.name;
					}
				})
				that.query.mgroup_name = arr[0];
				that.options = arr;
				let nowDate = new Date();
				that.getWeekDate(nowDate);
			});
		},
		// getDefect(id,index){
		// 	let that = this;
		// 	that.$API.mtm.defect.list.req({ page: 0, mgroup_id: id}).then((res) => {
		// 		let arr = [];
		// 		res.forEach(item=>{
		// 			arr.push(item.name);
		// 		})
		// 		that["tableData"+index] = arr;
		// 	});
		// },
		getData(mgroup_name,mgroup_index) {
			let that = this;
			let option = deepCopy(that.basicOption);
			let query = deepCopy(that.query);
			query.mgroup_name = mgroup_name;
			option.title.text = mgroup_name+"合格数统计";
			let obj = {};
			obj.query = query;
			that.$API.bi.dataset.exec.req('lineDay_m3', obj).then((res) => {
				let tableData = res.data2.ds0 ? res.data2.ds0 : [];
				let names = 'tableData'+mgroup_index;
				let defectList = [];
				let defectObject = {};
				let countOk = 0;
				if (tableData.length > 0) {
					let chartObj = {
						name:mgroup_name,
						data: [{name: "合格数",value: 0}],
						type: "pie",
						radius: ["30%", "65%"],
						center: ["40%", "55%"],
						label: {
							show: true,
							position: "outside",
							formatter: "{b} : {c} ({d}%)",
						},
					};
					//将数据分类
					tableData.forEach((ite) => {
						countOk += ite.合格数;
						if(ite.缺陷统计!==null){
							ite.缺陷统计 = JSON.parse(ite.缺陷统计);
							for(let key in ite.缺陷统计){
								ite[key] = ite.缺陷统计[key];
								if(defectList.indexOf(key)<0){
									defectList.push(key);
									defectObject[key] = ite.缺陷统计[key];
								}else{
									defectObject[key] += ite.缺陷统计[key];
								}
							}
						}
					});
					chartObj.data[0].value = countOk;
					for(let key in defectObject){
						let objItem = {};
						objItem.name = key;
						objItem.value = defectObject[key];
						chartObj.data.push(objItem);
					}
					option.series.push(chartObj);
					let chartId = 'bachart'+mgroup_index;
					that.setChart(chartId, option);
				} else {
					let chartObj = {
						name:mgroup_name,
						data: [{name: "合格数",value: 0}],
						type: "pie",
						radius: ["30%", "65%"],
						center: ["40%", "55%"],
						label: {
							show: true,
							position: "outside",
							formatter: "{b} : {c} ({d}%)",
						},
					};
					option.series.push(chartObj)
					let chartId = 'bachart'+mgroup_index;
					that.setChart(chartId, option);
				}
				that[names] = tableData;
				console.log(names,tableData);
			});
		},
		handleQuery() {
			this.getWeekDate(this.queryDate);
		},
		handleExport(val) {
			this.exportLoading = true;
			let id = "#exportDiv" + val;
			let name = "合格数统计";
			this.$XLSX(id, name);
			this.exportLoading = false;
		},
	},
};
</script>

<style scoped>
#bachart1,#bachart2,#bachart3,#bachart4,
#bachart5,#bachart6,#bachart7,#bachart8,
#bachart9,#bachart10,#bachart11,#bachart12,
#bachart13,#bachart14,#bachart15,#bachart16,
#bachart17,#bachart18,#bachart0{
	width: 100%;
	height: 300px;
}
.tables {
	position: absolute;
	top: 6px;
	left: 4px;
	z-index: 10;
}
</style>
