<template>
	<el-container>
		<el-header>
			<div class="right-panel">
				<!-- <el-select v-model="query.mgroup_name" 
				placeholder="请选择工段">
					<el-option
						v-for="item in options"
						:key="item"
						:label="item"
						:value="item"
					>
					</el-option>
				</el-select> -->
				<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="设备名称" 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="生产数">
								</el-table-column>
								<el-table-column label="合格数" prop="合格数">
								</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>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</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="设备名称" min-width="100">
								</el-table-column>
								<el-table-column label="日期">
									<template #default="scope">
										{{ scope.row.日期 }}
									</template>
								</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="不合格数" 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>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</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="2"
								: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="设备名称" min-width="100">
								</el-table-column>
								<el-table-column label="日期">
									<template #default="scope">
										{{ scope.row.日期 }}
									</template>
								</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="不合格数" 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>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</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="设备名称" min-width="100">
								</el-table-column>
								<el-table-column label="日期">
									<template #default="scope">
										{{ scope.row.日期 }}
									</template>
								</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="不合格数" 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>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</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="设备名称" min-width="100">
								</el-table-column>
								<el-table-column label="日期">
									<template #default="scope">
										{{ scope.row.日期 }}
									</template>
								</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="不合格数" 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>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</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="设备名称" min-width="100">
								</el-table-column>
								<el-table-column label="日期">
									<template #default="scope">
										{{ scope.row.日期 }}
									</template>
								</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="不合格数" 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>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</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="设备名称" min-width="100">
								</el-table-column>
								<el-table-column label="日期">
									<template #default="scope">
										{{ scope.row.日期 }}
									</template>
								</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="不合格数" 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>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</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="设备名称" min-width="100">
								</el-table-column>
								<el-table-column label="日期">
									<template #default="scope">
										{{ scope.row.日期 }}
									</template>
								</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="不合格数" 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>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</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="设备名称" min-width="100">
								</el-table-column>
								<el-table-column label="日期">
									<template #default="scope">
										{{ scope.row.日期 }}
									</template>
								</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="不合格数" 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>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</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="设备名称" min-width="100">
								</el-table-column>
								<el-table-column label="日期">
									<template #default="scope">
										{{ scope.row.日期 }}
									</template>
								</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="不合格数" 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>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</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="设备名称" min-width="100">
								</el-table-column>
								<el-table-column label="日期">
									<template #default="scope">
										{{ scope.row.日期 }}
									</template>
								</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="不合格数" 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>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</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="设备名称" min-width="100">
								</el-table-column>
								<el-table-column label="日期">
									<template #default="scope">
										{{ scope.row.日期 }}
									</template>
								</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="不合格数" 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>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</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="设备名称" min-width="100">
								</el-table-column>
								<el-table-column label="日期">
									<template #default="scope">
										{{ scope.row.日期 }}
									</template>
								</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="不合格数" 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>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</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="设备名称" min-width="100">
								</el-table-column>
								<el-table-column label="日期">
									<template #default="scope">
										{{ scope.row.日期 }}
									</template>
								</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="不合格数" 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>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</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="设备名称" min-width="100">
								</el-table-column>
								<el-table-column label="日期">
									<template #default="scope">
										{{ scope.row.日期 }}
									</template>
								</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="不合格数" 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>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</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="设备名称" min-width="100">
								</el-table-column>
								<el-table-column label="日期">
									<template #default="scope">
										{{ scope.row.日期 }}
									</template>
								</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="不合格数" 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>
								<el-table-column label="合格率" prop="合格率">
									<template #default="scope">
										{{ (scope.row.合格率).toFixed(2) }}%
									</template>
								</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:'',
				group_bys_material: "",
				order_bys_material: "",
				select_cols_material: ""
			},
			queryDate:'',
			currentYear: "",
			currentMonth: "",
			nameList: [],
			basicOption: {
				backgroundColor: "transparent",
				title: {
					text: "合格数统计",
				},
				grid: {
					top: "80px",
				},
				tooltip: {
					trigger: "axis",
				},
				xAxis: {
					type: "category",
					data: ["周一","周二","周三","周四","周五","周六","周日"],
				},
				yAxis: {
					type: "value",
				},
				lenged: [],
				series: [],
			},
			tableData0: [],
			tableData1: [],
			tableData2: [],
			tableData3: [],
			tableData4: [],
			tableData5: [],
			tableData6: [],
			tableData7: [],
			tableData8: [],
			tableData9: [],
			tableData10: [],
			tableData11: [],
			tableData12: [],
			tableData13: [],
			tableData14: [],
			tableData15: [],
			options:[],
		};
	},
	mounted() {
		let that = this;
		let nowDate = new Date();
		that.getMgroup();
		// that.getWeekDate(nowDate);
	},
	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;
			// console.log('dateArr',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=>{
					arr.push(item.name)
				})
				that.query.mgroup_name = arr[0];
				that.options = arr;
				let nowDate = new Date();
				that.getWeekDate(nowDate);
			});
		},
		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_m', obj).then((res) => {
				let tableData = res.data2.ds0 ? res.data2.ds0 : [];
				let names = 'tableData'+mgroup_index;
				that[names] = tableData;
				if (tableData.length > 0) {
					let dataList = [],nameList = [],datas = [];
					tableData.forEach((ite) => {
						if (nameList.indexOf(ite.物料名) > -1) {} else {
							nameList.push(ite.物料名);
							dataList.push([])
							datas.push([0,0,0,0,0,0,0]);
							let obj = {
								name:ite.物料名,
								data: [],
								stack: "Ad",
								type: "bar",
								barWidth: "15px",
							};
							option.series.push(obj)
						}
					});
					that.nameList = nameList;
					tableData.forEach((item) => {
						let indexX = nameList.indexOf(item.物料名);
						dataList[indexX].push(item);
					});
					for(let i = 0;i<dataList.length;i++){
						for(let j = 0;j<dataList[i].length;j++){
							let index = that.weekDateList.indexOf(dataList[i][j].日期);
							datas[i][index] = dataList[i][j].合格数; //将当前日期对应的合格数添加到datas中
						}
					}
					for(let n=0;n<nameList.length;n++){
						option.series[n].data = datas[n];
					}
					let chartId = 'bachart'+mgroup_index;
					that.setChart(chartId, option);
				} else {
					let chartId = 'bachart'+mgroup_index;
					that.setChart(chartId, option);
				}
			});
		},
		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,#bachart0{
	width: 100%;
	height: 300px;
}
.tables {
	position: absolute;
	top: 6px;
	left: 4px;
	z-index: 10;
}
</style>
