<template>
	<el-main
		class="main-container mainlayout-flex"
		v-loading.fullscreen.lock="fullscreenLoading"
	>
		<div style="display: flex">
			<!--左边 -->
			<div class="page-left">
				<!--最近打开 -->
				<div class="page-left-1">
					<p class="page-title">快捷入口</p>
					<!-- <div class="serch">
          <input type="text" placeholder="搜索您想要的菜单" />
          </div>-->
					<div class="tag_main">
						<!-- <p class="page-title-1">最近搜索</p> -->
						<el-tag
							:key="item.name"
							@click="handleOpenPage(item)"
							v-for="item in openlist"
							>{{ item.title }}</el-tag
						>
					</div>
				</div>
			</div>
			<!--右边---待办任务 -->
			<div class="page-right">
				<div class="page-right-1">
					<p class="page-title">最近下载</p>
					<div class="tag_main">
						<div
							class="dbrw-main page-main"
							style="max-height: 290px"
						>
							<el-table
								:data="tableData"
								border
								style="width: 100%"
							>
								<el-table-column
									align="left"
									label="任务类型"
									prop="type"
								>
									<template #default="scope">
										<span>{{
											getPageObjValue(
												typelist,
												scope.row.type + ''
											)
										}}</span>
									</template>
								</el-table-column>
								<el-table-column
									align="left"
									label="操作日期"
									prop="date"
								/>
								<el-table-column
									align="left"
									label="状态"
									prop="status"
								>
									<template #default="scope">
										<span
											style="color: #3ad6ac"
											v-if="
												scope.row.status === '导出成功'
											"
										>
											{{ scope.row.status }}
											<i
												class="iconfont icon-chenggong"
											></i>
										</span>
										<span
											style="color: #ff5363"
											v-if="
												scope.row.status === '导出失败'
											"
										>
											{{ scope.row.status }}
											<i
												class="iconfont icon-shijing"
											></i>
										</span>
										<span
											style="color: #fdc027"
											v-if="
												scope.row.status === '正在导出'
											"
											>{{
												scope.row.status + '...'
											}}</span
										>
									</template>
								</el-table-column>
								<el-table-column
									align="left"
									label="附件"
									prop="filePath"
								>
									<template #default="scope">
										<a
											:href="scope.row.filePath"
											class="text-blue"
											v-if="
												scope.row.statusKey == 1 &&
												Math.abs(
													(new Date(
														scope.row.date
													).getTime() -
														new Date().getTime()) /
														(24 * 60 * 60 * 1000)
												) <= 7
											"
											>下载</a
										>
										<a
											style="color: #ccc; cursor: no-drop"
											v-else
											>下载文件</a
										>
									</template>
								</el-table-column>
								<el-table-column
									align="left"
									label="操作人"
									prop="userName"
								/>
							</el-table>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="tishi">
			<ul>
				<li>核心数据分析</li>
				<li class="xx">注：每30分钟计算一次</li>
				<!--数据更新于2023年02月27日 10:21-->
				<!-- <li class="xx">刷新</li> -->
				<li class="update">
					<i
						class="iconfont icon-shuaxin syncDataBtn"
						@click="getrefreshclick"
					></i>
				</li>
			</ul>
		</div>
		<!-- 即时销售情况 -->
		<div class="xiaoshou">
			<div class="sales">
				<div class="sales-1">
					<p class="page-title">即时销售情况</p>
					<el-select
						v-model="selectValue1"
						class="bb-bumen"
						size="large"
						@change="handleChange1"
						style="width: 150px"
					>
						<!-- <el-option class="f_12" label="全部" value="0"></el-option> -->
						<el-option
							v-for="item in productDeptList"
							:key="item.id"
							:label="item.name"
							:value="item.id"
						/>
					</el-select>
					<div class="amount">
						<p class="amount-p">销售额</p>
						<span class="jine"
							>￥{{
								(SalToDayqData.toDayAmount / 10000)
									.toFixed(2)
									.replace(/\.?0+$/, '')
							}}万</span
						>
						<!-- <span class="jine">￥{{ SalToDayqData.toDayAmount }}元</span> -->
						<!-- 不等于(不等于的情况下在判断大小改变央视)-->
						<div
							v-if="
								SalToDayqData.toDayAmount !==
								SalToDayqData.yesterDayAmount
							"
						>
							<div
								:class="
									SalToDayqData.toDayAmount >
									SalToDayqData.yesterDayAmount
										? 'bagcolorg'
										: 'bagcolorr'
								"
							>
								<span>
									{{
										SalToDayqData.toDayAmount >
										SalToDayqData.yesterDayAmount
											? '￥'
											: '￥'
									}}
									{{
										(
											SalToDayqData.yesterDayAmount /
											10000
										).toFixed(2)
									}}万&nbsp;&nbsp;&nbsp;&nbsp;
								</span>
								<span>昨日</span>
							</div>
							<img
								class="amount-r1"
								src="/src/assets/rise.png"
								alt
								v-if="
									SalToDayqData.toDayAmount >
									SalToDayqData.yesterDayAmount
								"
							/>
							<img
								class="amount-r1"
								v-else
								src="/src/assets/down.png"
							/>
							<img
								class="amount-r2"
								src="/src/assets/rise1.png"
								alt
								v-if="
									SalToDayqData.toDayAmount >
									SalToDayqData.yesterDayAmount
								"
							/>
							<img
								class="amount-r2"
								v-else
								src="/src/assets/down1.png"
							/>
						</div>
						<!-- 等于 -->
						<div
							v-if="
								SalToDayqData.toDayAmount ==
								SalToDayqData.yesterDayAmount
							"
						>
							<div class="bagcolory">
								<span>
									{{
										SalToDayqData.yesterDayAmount / 10000
									}}万&nbsp;&nbsp; &nbsp;&nbsp;
								</span>

								<span>昨日</span>
							</div>
							<img
								class="amount-r1"
								src="/src/assets/equal.png"
								alt
							/>
							<img
								class="amount-r2"
								src="/src/assets/equal1.png"
								alt
							/>
						</div>
					</div>
					<div class="amount">
						<p class="amount-p">销售量</p>
						<span class="jine">{{
							SalToDayqData.toDayNumber
						}}</span>
						<!-- 不等于(不等于的情况下在判断大小改变央视)-->
						<div
							v-if="
								SalToDayqData.toDayNumber !==
								SalToDayqData.yesterDayNumber
							"
						>
							<div
								:class="
									SalToDayqData.toDayNumber >
									SalToDayqData.yesterDayNumber
										? 'bagcolorg'
										: 'bagcolorr'
								"
							>
								<span>
									{{
										SalToDayqData.toDayNumber >
										SalToDayqData.yesterDayNumber
											? ''
											: ''
									}}
									{{
										SalToDayqData.yesterDayNumber
									}}&nbsp;&nbsp;&nbsp;&nbsp;
								</span>
								<span>昨日</span>
							</div>
							<img
								class="amount-r1"
								src="/src/assets/rise.png"
								alt
								v-if="
									SalToDayqData.toDayNumber >
									SalToDayqData.yesterDayNumber
								"
							/>
							<img
								class="amount-r1"
								v-else
								src="/src/assets/down.png"
							/>
							<img
								class="amount-r2"
								src="/src/assets/rise1.png"
								alt
								v-if="
									SalToDayqData.toDayNumber >
									SalToDayqData.yesterDayNumber
								"
							/>
							<img
								class="amount-r2"
								v-else
								src="/src/assets/down1.png"
							/>
						</div>
						<!-- 等于 -->
						<div
							v-if="
								SalToDayqData.toDayNumber ==
								SalToDayqData.yesterDayNumber
							"
						>
							<div class="bagcolory">
								<span>
									{{
										SalToDayqData.yesterDayNumber
									}}&nbsp;&nbsp; &nbsp;&nbsp;
								</span>
								<span>昨日</span>
								<img
									class="amount-r1"
									src="/src/assets/equal.png"
									alt
								/>
								<img
									class="amount-r2"
									src="/src/assets/equal1.png"
									alt
								/>
							</div>
						</div>
					</div>
					<div class="amount">
						<p class="amount-p">出库额</p>
						<span class="jine"
							>￥{{
								(SalToDayqData.outStock_ToDayAmount / 10000)
									.toFixed(2)
									.replace(/\.?0+$/, '')
							}}万</span
						>
						<!-- 不等于(不等于的情况下在判断大小改变央视)-->
						<div
							v-if="
								SalToDayqData.outStock_ToDayAmount !==
								SalToDayqData.outStock_YesterDayAmount
							"
						>
							<div
								:class="
									SalToDayqData.outStock_ToDayAmount >
									SalToDayqData.outStock_YesterDayAmount
										? 'bagcolorg'
										: 'bagcolorr'
								"
							>
								<span>
									{{
										SalToDayqData.outStock_ToDayAmount >
										SalToDayqData.outStock_YesterDayAmount
											? '￥'
											: '￥'
									}}
									{{
										(
											SalToDayqData.outStock_YesterDayAmount /
											10000
										).toFixed(2)
									}}万&nbsp;&nbsp;&nbsp;&nbsp;
								</span>
								<span>昨日</span>
							</div>
							<img
								class="amount-r1"
								src="/src/assets/rise.png"
								alt
								v-if="
									SalToDayqData.outStock_ToDayAmount >
									SalToDayqData.outStock_YesterDayAmount
								"
							/>
							<img
								class="amount-r1"
								v-else
								src="/src/assets/down.png"
							/>
							<img
								class="amount-r2"
								src="/src/assets/rise1.png"
								alt
								v-if="
									SalToDayqData.outStock_ToDayAmount >
									SalToDayqData.outStock_YesterDayAmount
								"
							/>
							<img
								class="amount-r2"
								v-else
								src="/src/assets/down1.png"
							/>
						</div>
						<!-- 等于 -->
						<div
							v-if="
								SalToDayqData.outStock_ToDayAmount ==
								SalToDayqData.outStock_YesterDayAmount
							"
						>
							<div class="bagcolory">
								<span>
									{{
										SalToDayqData.outStock_ToDayAmount /
										10000
									}}万&nbsp;&nbsp; &nbsp;&nbsp;
								</span>
								<span>昨日</span>
							</div>
							<img
								class="amount-r1"
								src="/src/assets/equal.png"
								alt
							/>
							<img
								class="amount-r2"
								src="/src/assets/equal1.png"
								alt
							/>
						</div>
					</div>
					<div class="amount">
						<p class="amount-p">出库量</p>
						<span class="jine">{{
							SalToDayqData.outStock_ToDayNumber
						}}</span>
						<div
							v-if="
								SalToDayqData.outStock_ToDayNumber !==
								SalToDayqData.outStock_YesterDayNumber
							"
						>
							<div
								:class="
									SalToDayqData.outStock_ToDayNumber >
									SalToDayqData.outStock_YesterDayNumber
										? 'bagcolorg'
										: 'bagcolorr'
								"
							>
								<span>
									{{
										SalToDayqData.outStock_ToDayNumber <
											SalToDayqData.outStock_YesterDayNumber &&
										SalToDayqData.outStock_ToDayNumber >
											SalToDayqData.outStock_YesterDayNumber
											? ''
											: ''
									}}
									{{
										SalToDayqData.outStock_YesterDayNumber
									}}&nbsp;&nbsp;&nbsp;&nbsp;
								</span>
								<span>昨日</span>
							</div>

							<img
								class="amount-r1"
								src="/src/assets/rise.png"
								alt
								v-if="
									SalToDayqData.outStock_ToDayNumber >
									SalToDayqData.outStock_YesterDayNumber
								"
							/>
							<img
								class="amount-r1"
								v-else
								src="/src/assets/down.png"
							/>
							<img
								class="amount-r2"
								src="/src/assets/rise1.png"
								alt
								v-if="
									SalToDayqData.outStock_ToDayNumber >
									SalToDayqData.outStock_YesterDayNumber
								"
							/>
							<img
								class="amount-r2"
								v-else
								src="/src/assets/down1.png"
							/>
						</div>
						<!-- 等于 -->
						<div
							v-if="
								SalToDayqData.outStock_ToDayNumber ==
								SalToDayqData.outStock_YesterDayNumber
							"
						>
							<div class="bagcolory">
								<span>
									{{
										SalToDayqData.outStock_YesterDayNumber
									}}&nbsp;&nbsp; &nbsp;&nbsp;
								</span>
								<span>昨日</span>
								<img
									class="amount-r1"
									src="/src/assets/equal.png"
									alt
								/>
								<img
									class="amount-r2"
									src="/src/assets/equal1.png"
									alt
								/>
							</div>
						</div>
					</div>
				</div>
			</div>
			<!-- 报表 -->
			<div class="bb">
				<p class="page-title">实时销售分析</p>
				<ul class="tian">
					<li
						:class="active1 ? ' active' : ''"
						id="at1"
						@click="getcheckad()"
					>
						按天
					</li>
					<li
						:class="!active1 ? ' active' : ''"
						id="ay1"
						@click="getcheckad1()"
					>
						按月
					</li>
				</ul>
				<div id="main" style="width: 100%; height: 395px"></div>
			</div>
			<div class="bb">
				<p class="page-title">实时出库分析</p>
				<div id="main1" style="width: 100%; height: 395px"></div>
			</div>
		</div>
		<!-- 库存情况 -->
		<div class="kucun">
			<p class="page-title">库存情况</p>
			<div class="bb">
				<p class="page-title">库存金额分析</p>
				<el-select
					v-model="selectValue"
					class="bumen"
					placeholder="Select"
					size="large"
					@change="handleChange"
					style="width: 150px"
				>
					<el-option
						v-for="item in vals"
						:key="item.id"
						:label="item.name"
						:value="item.id"
					/>
				</el-select>
				<ul class="tian">
					<li
						:class="active2 ? ' active' : ''"
						@click="getcheckad4(1)"
					>
						按天
					</li>
					<li
						:class="!active2 ? ' active' : ''"
						@click="getcheckad4(2)"
					>
						按月
					</li>
				</ul>
				<div id="main2" style="width: 100%; height: 395px"></div>
			</div>
			<div class="bb">
				<ul class="main3-tit">
					<li :class="tit1 ? 'tit1' : ''" @click="getcheckac(1)">
						库存周转天数
					</li>
					<li :class="!tit1 ? 'tit1' : ''" @click="getcheckac(2)">
						库存周转率
					</li>
				</ul>
				<div id="main3" style="width: 100%; height: 395px"></div>
			</div>
		</div>
		<!-- 生产产值分析 -->
		<div class="bb">
			<p class="page-title">生产产值分析</p>
			<el-select
				v-model="selectValue2"
				class="bumen"
				placeholder="Select"
				size="large"
				@change="handleChange2"
				style="width: 150px"
			>
				<!-- <el-option class="f_12" label="全部" value="0"></el-option> -->
				<el-option
					v-for="item in productDeptList"
					:key="item.id"
					:label="item.name"
					:value="item.id"
				/>
			</el-select>
			<ul class="tian">
				<li :class="active3 ? ' active' : ''" @click="getcheckad2(1)">
					按天
				</li>
				<li :class="!active3 ? ' active' : ''" @click="getcheckad2(2)">
					按月
				</li>
			</ul>
			<div id="main4" style="width: 100%; height: 395px"></div>
		</div>
		<!-- 准交分析 -->
		<div class="bb">
			<p class="page-title">准交分析</p>
			<el-select
				v-model="selectValue3"
				class="bumen"
				placeholder="Select"
				size="large"
				@change="handleChange3"
				style="width: 90px"
			>
				<el-option
					v-for="item in valas"
					:key="item.id"
					:label="item.name"
					:value="item.id"
				/>
			</el-select>
			<ul class="tian">
				<li :class="active ? ' active' : ''" @click="getcheckad3(1)">
					按天
				</li>
				<li :class="!active ? ' active' : ''" @click="getcheckad3(2)">
					按月
				</li>
			</ul>
			<div id="main5" style="width: 100%; height: 395px"></div>
		</div>
		<!-- 销售排行榜 -->
		<div class="Saleslist">
			<p class="page-title">销售排行榜（top 10）</p>
			<ul class="tian">
				<li
					:class="active4 ? ' active' : ''"
					@click="getSalerabjing(7)"
				>
					7天
				</li>
				<li
					:class="active5 ? ' active' : ''"
					@click="getSalerabjing(14)"
				>
					14天
				</li>
				<li
					:class="active6 ? ' active' : ''"
					@click="getSalerabjing(30)"
				>
					30天
				</li>
			</ul>
			<div class="tag_main">
				<div class="dbrw-main page-main">
					<el-table
						:max-height="heightNum"
						:data="requesttableData"
						border
						style="width: 100%"
						v-loading="isLoading"
					>
						<el-table-column
							align="left"
							width
							label="序号"
							type="index"
							:index="indexMethod"
						/>
						<el-table-column
							align="left"
							label="编码"
							prop="materialNumber"
						/>
						<el-table-column
							align="left"
							label="名称"
							prop="materialName"
						/>
						<el-table-column
							align="left"
							label="规格型号"
							prop="specification"
						/>
						<el-table-column
							align="left"
							label="销售额"
							sortable
							prop="saleAmount"
						/>
						<el-table-column
							align="left"
							label="订单量"
							sortable
							prop="orderCount"
						/>
						<el-table-column
							align="left"
							label="销量"
							sortable
							prop="saleNumber"
						/>
					</el-table>
				</div>
			</div>
		</div>
	</el-main>
</template>
<script>
import { mapState, mapActions } from 'vuex';
import { getObjValue } from '@/utils/pubulic.js';
import * as echarts from 'echarts';
export default {
	data() {
		return {
			fullscreenLoading: false, // loding
			vals: [
				{
					name: '所有',
					id: -1,
				},
			],
			valas: [
				{
					name: '销售准交',
					id: 1,
				},
				{
					name: '生产准交',
					id: 2,
				},
				{
					name: '采购准交',
					id: 3,
				},
			],
			spaceNum: 0, //y最大值
			active: true,
			active1: true,
			active2: true,
			tit1: true,
			active3: true,
			active4: false,
			active5: false,
			active6: false,
			selectValue: -1,
			selectValue1: -1,
			selectValue2: -1,
			selectValue3: 1,
			typelist: {},
			statuslsit: {},
			search: {
				orgId: '', // 组织id
				pageNo: 1, // 页码
				pageSize: 50, // 页数
				type: '', // 单据类型(任务类型)
				status: '', // 状态
				beginDate: '', // 下单时间 开始s
				endDate: '', // 下单时间 结束
				user: '', // 操作人
			},
			windowHeight: 0,
			heightNum: 0,
			tableData: [],
			productDeptList: [
				{
					name: '全部',
					id: -1,
				},
			], //部门
			turnovertlist: [],
			daysType: -1,
			activeName: 'first',
			statistics: {}, // 核心数据
			openlist: [], // 最近打开
			value: '',
			_beforeUnload_time: '',
			_gap_time: '',
			currentTarget: 0,
			requesttableData: [], //销售排行
			requesdata: {
				orgid: 0,
				days: 7,
				sort: 1,
			},
			timeType1: 1,
			timeType2: 1,
			timeType3: 1,
			//即时销售情况
			SalToDayqData: {
				toDayAmount: 0, //今日销售额
				toDayNumber: 0, //今日销售量
				yesterDayAmount: 0, //昨日销售额
				yesterDayNumber: 0, //昨日销售量
				outStock_ToDayAmount: 0, //销售出库今日额
				outStock_ToDayNumber: 0, //销售出库今日量
				outStock_YesterDayAmount: 0, //销售出库昨日额
				outStock_YesterDayNumber: 0, //销售出库昨日量
			},
			SalToDaydata: {
				//销售
				deptId: -1,
				orgId: 0,
			},
			SalOrdertableData: [], //实时销售图表日
			SalOrderdata: {
				deptId: -1,
				orgId: 0,
			},
			SalOrderReportdata: {
				// /实时销售图表月
				deptId: -1,
				orgId: 0,
			},
			SalOutStockReport: {
				// 月实时出库分析
				deptId: -1,
				orgId: 0,
			},
			SalOutStockdata: {
				//日实时出库分析
				deptId: -1,
				orgId: 0,
			},
			Inventorydata: {
				//库存金额分析
				orgId: 0,
				stockId: -1,
				timeType: 1,
			},
			InventoryTurnoverdata: {
				//库存周转天数及周转率
				orgId: 0,
				stockId: -1,
				timeType: 1,
			},
			ProductValuedata: {
				//生产产值分析
				orgId: 0,
				stockId: -1,
				timeType: 1,
			},
			Accuratedata: {
				//准交分析
				orgId: 0,
				orderType: 1,
				timeType: 1,
			},
		};
	},
	computed: {
		...mapState({
			orgId: (state) => (state && state.user ? state.user.orgId : null),
			unitDataList: (state) => state.storeData.allUnit,
			orgIdArr: (state) =>
				JSON.stringify(state) !== '{}' ? state.user.orgIdArr : null, //获取组织
		}),
		getPageObjValue: function () {
			// 根据key值显示对应的键名
			return function (arr, key) {
				return getObjValue(arr, key);
			};
		},
	},
	watch: {
		orgId(value) {
			if (value) {
				this.search.orgId = value;
				this.getFileDownManagerQuery();

				//调用组织仓库接口
				this.getstokid();
				this.getProductdept();
				location.reload();
			}
		},
	},
	created() {
		this.windowHeight = document.documentElement.clientHeight;
		this.heightNum =
			this.windowHeight - (40 + 30 + 54 + 34 + 34 + 34 + 16 + 16);

		this.search.orgId = this.orgId;
		this.Accuratedata.orgId = this.orgId;
		this.SalToDaydata.orgId = this.orgId;
		this.SalOutStockdata.orgId = this.orgId;
		this.SalOutStockReport.orgId = this.orgId;
		this.SalOrderdata.orgId = this.orgId;
		this.SalOrderReportdata.orgId = this.orgId;
		this.ProductValuedata.orgId = this.orgId;
		this.Inventorydata.orgId = this.orgId;
		this.InventoryTurnoverdata.orgId = this.orgId;

		this.getSalerabjing(7); //销售排行
		this.getsalresult(); //销售数据
		this.getstokid();
		this.getselectList();
		this.getOpendList();
		this.getFileDownManagerQuery();
		this.statisticsToal();
		this.getProductdept(); //获取部门信息
		this.openFullScreen2();
		// 获取全局单位
		if (this.unitDataList.length == 0) {
			this.$http.get('SysConfig/GetUnitAllProperty').then((r) => {
				if (r.status === 200) {
					this.setAllUnit(r.data);
				}
			});
		}
	},
	mounted() {
		this.$nextTick(() => {
			this.getcheckday(1);
			this.getcheckmonth1(1);
			this.getcheckmonth2(1);
			this.getcheckmonth3(1);
		});
	},

	methods: {
		...mapActions({
			setAllUnit: 'storeData/setAllUnit',
		}),
		indexMethod(index) {
			return index + 1;
		},

		// loading加载
		openFullScreen2() {
			this.fullscreenLoading = true;
			setTimeout(() => {
				this.fullscreenLoading = false;
			}, 500);
		},

		//点击手动刷新数据  /api/v{version}/DataAnalysis/Flushed
		getrefreshclick() {
			//data中的数据要恢复到初始化状态
			this.$nextTick(() => {
				this.getSalerabjing(7); //销售排行
				this.getsalresult(); //销售数据
				this.getcheckday(1);
				this.getcheckmonth1(1);
				this.getcheckmonth2(1);
				this.getcheckmonth3(1);
				// this.getrefresh()
				this.getstokid();
				this.statisticsToal();
				this.getProductdept(); //获取部门信息
			});
		},
		//获取仓库
		getstokid() {
			this.$http
				.get('SysConfig/GetWarehouseByOrg/' + this.orgId)
				.then((res) => {
					if (res.status === 200) {
						res.data.forEach((item) => {
							this.vals.push(item);
						});
					}
				});
		},
		// 获取部门数据
		getProductdept() {
			this.$http.post('SysConfig/GetDept/' + this.orgId).then((res) => {
				if (res.status === 200) {
					this.productDeptList = [
						...this.productDeptList,
						...res.data[0].children,
					];
				}
			});
		},
		//切换仓库改变数据
		handleChange(val) {
			this.selectValue = val;
			this.Inventorydata.stockId = val;
			this.InventoryTurnoverdata.stockId = val;
			this.Inventorydata.orgId = this.orgId;
			this.InventoryTurnoverdata.orgId = this.orgId;
			this.getcheckmonth1(this.Inventorydata.timeType);
		},

		//切换部门改变销售数据
		handleChange1(val) {
			this.selectValue1 = val;
			this.SalToDaydata.orgId = this.orgId;
			this.SalToDaydata.deptId = val;
			this.SalOutStockdata.orgId =
				this.SalOutStockReport.orgId =
				this.SalOrderdata.orgId =
				this.SalOrderReportdata.orgId =
					this.orgId;
			this.SalOutStockdata.deptId =
				this.SalOutStockReport.deptId =
				this.SalOrderdata.deptId =
				this.SalOrderReportdata.deptId =
					val;
			this.getsalresult();
			if (this.timeType1 === 1) {
				this.getcheckday();
			} else {
				this.getcheckmonth();
			}
		},
		//切换部门改变生产产值数据
		handleChange2(val) {
			this.selectValue2 = val;
			this.ProductValuedata.deptId = val;
			this.ProductValuedata.orgId = this.orgId;
			this.getcheckmonth2(this.ProductValuedata.timeType);
		},
		//切换部门改变生产产值数据
		handleChange3(val) {
			this.selectValue3 = val;
			this.Accuratedata.orderType = val;
			this.Accuratedata.orgId = val;
			this.getcheckmonth3(this.Accuratedata.timeType);
		},

		// 销售
		getsalresult() {
			this.$http
				.showLoading(false)
				.post('DataAnalysis/SalToDayReport', this.SalToDaydata)
				.then((res) => {
					if (res.status === 200) {
						this.SalToDayqData = res.data;
					}
				});
		},
		getgetcheckacs(type) {
			if (type === 1) {
				//库存周转天

				var chartDom3;
				var myChart3;
				chartDom3 = document.getElementById('main3');
				myChart3 = echarts.init(chartDom3);

				this.$http
					.post(
						'DataAnalysis/InventoryTurnover',
						this.InventoryTurnoverdata
					)
					.then((res) => {
						let xlsit = [];
						let y1 = [];
						if (res.status === 200) {
							res.data.forEach((item) => {
								xlsit.push(item.date);
								y1.push(item.turnoverDays);
							});
							let Max1 = this.calMax(y1);
							this.option3 = {
								tooltip: {
									trigger: 'axis',
									axisPointer: {
										type: 'cross',
										crossStyle: {
											color: '#999',
										},
									},
								},
								resize: true,
								grid: {
									// 让图表占满容器
									// top: '3%',
									left: '2%',
									right: '2%',
									containLabel: true,
									//bottom: '3%',
								},
								xAxis: [
									{
										type: 'category',
										data: xlsit,
										axisPointer: {
											type: 'shadow',
										},
										axisLabel: {
											color: '#999',
										},
										axisLine: {
											lineStyle: {
												color: '#DCDFE6',
											},
										},
									},
								],
								yAxis: [
									{
										type: 'value',
										name: '天数',
										// min: 0,
										// max: 35,
										// interval: 7,
										axisLabel: {
											formatter: (value) => {
												let val = Math.ceil(value);
												return `${val}`;
											},
										},
									},
								],
								series: [
									{
										name: '天',
										type: 'bar',
										tooltip: {
											valueFormatter: function (value) {
												let val = value
													.toFixed(2)
													.replace(/\.?0+$/, '');
												return val + ' ';
											},
										},
										data: y1,
										barWidth: 16, //柱状宽度
										itemStyle: {
											normal: {
												//柱状颜色和圆角
												color: new echarts.graphic.LinearGradient(
													0,
													0,
													0,
													1,
													[
														{
															offset: 0,
															color: '#6AE4FC',
														},
														{
															offset: 1,
															color: '#3CBFFF',
														},
													]
												),
												barBorderRadius: [6, 6, 6, 6], // （顺时针左上，右上，右下，左下）
											},
										},
									},
								],
							};
							let isArray;
							for (let i = 0; i < y1.length; i++) {
								if (y1[i] === 0) {
									isArray = true;
								} else {
									isArray = false;
									break;
								}
							}

							if (isArray) {
								if ((this.option3.yAxis[0].max = 10)) {
									this.option3.yAxis[0].max = Max1 = 100; //设置左侧最大值
								}
							} else {
								this.option3.yAxis[0].max = Max1; //设置左侧最大值
							}

							this.option3.yAxis[0].interval = Max1 / 6; //设置左侧刻度间隔距离，平均为10份
							this.option3 && myChart3.setOption(this.option3);

							window.addEventListener('resize', () => {
								chart.resize();
							});
						}
					});
			} else if (type === 2) {
				//库存周转率
				var chartDom3;
				var myChart3;
				chartDom3 = document.getElementById('main3');
				myChart3 = echarts.init(chartDom3);
				this.$http
					.post(
						'DataAnalysis/InventoryTurnover',
						this.InventoryTurnoverdata
					)
					.then((res) => {
						let xlsit = [];
						let y1 = [];
						if (res.status === 200) {
							res.data.forEach((item) => {
								xlsit.push(item.date);
								y1.push(item.turnoverRate);
							});
							//y1和y2的最大值
							let Max1 = this.calMax(y1);
							this.option31 = {
								xAxis: [
									{
										type: 'category',
										data: xlsit,
										axisPointer: {
											type: 'shadow',
										},
										axisLabel: {
											color: '#999',
										},
										axisLine: {
											lineStyle: {
												color: '#DCDFE6',
											},
										},
									},
								],
								yAxis: [
									{
										type: 'value',
										name: '周转率',
										min: 0,
										max: 100,
										interval: 20,
										axisLabel: {
											formatter: (value) => {
												let val = Math.ceil(value);
												return `${val}` + '%';
											},
										},
									},
								],
								series: [
									{
										name: '周转率',
										type: 'bar',
										tooltip: {
											valueFormatter: function (value) {
												let val = value
													.toFixed(2)
													.replace(/\.?0+$/, '');
												return val + ' %';
											},
										},
										symbolSize: 20,
										data: y1,
										type: 'scatter',
									},
								],
							};
							let isArray;
							for (let i = 0; i < y1.length; i++) {
								if (y1[i] === 0) {
									isArray = true;
								} else {
									isArray = false;
									break;
								}
							}

							if (isArray) {
								if ((this.option31.yAxis[0].max = 10)) {
									this.option31.yAxis[0].max = Max1 = 100; //设置左侧最大值
								}
							} else {
								this.option31.yAxis[0].max = Max1; //设置左侧最大值
							}
							console.log('Max1--------------->', Max1);
							this.option31.yAxis[0].interval = Max1 / 5; //设置左侧刻度间隔距离，平均为10份
							this.option3 && myChart3.setOption(this.option31);

							window.addEventListener('resize', () => {
								chart.resize();
							});
						}
					});
			}
		},

		//切换周转天数和周转率
		getcheckac(type) {
			this.tit1 = !this.tit1;
			this.getgetcheckacs(type);
		},
		//切换销售图标统计(日)
		getcheckad(type) {
			this.active1 = true;
			this.getcheckday();
		},
		//切换销售图标统计(月)
		getcheckad1(type) {
			this.active1 = false;
			this.getcheckmonth();
		},
		//切换准交分析
		getcheckad3(type) {
			this.active = !this.active;
			// this.Accuratedata.orgId = this.orgId
			this.getcheckmonth3(type);
		},
		//切换生产产值数据
		getcheckad2(type) {
			this.active3 = !this.active3;
			this.getcheckmonth2(type);
		},
		//库存情况切换按天按月
		getcheckad4(type) {
			this.active2 = !this.active2;
			this.getcheckmonth1(type);
			// this.getgetcheckacs()
		},
		//在这里
		calMax(arr, spaceNum = 10) {
			//计算最大值
			let maxA = Math.max(...arr); // 最大值A
			let maxint = Math.ceil(maxA / spaceNum); //最大平均值（向上取整）= 最大值A / 间隔数
			let maxB = maxint * spaceNum; // 最大值B = 最大平均值 * 间隔数  （注：最大值B>最大值A）
			return Math.max(maxB, 10); // 为了防止maxB数据为0时，Y轴不显示，给个默认最大值10
		},
		getcheckday() {
			this.timeType1 = 1;
			var chartDom;
			var myChart;
			var chartDoma;
			var myCharta;

			chartDom = document.getElementById('main');
			myChart = echarts.init(chartDom);
			chartDoma = document.getElementById('main1');
			myCharta = echarts.init(chartDoma);
			// 首页-销售图标统计(日)
			this.$http
				.post('DataAnalysis/SalOrderReport_Day', this.SalOrderdata)
				.then((res) => {
					let xlsit = [];
					let y1 = [];
					let y2 = [];
					if (res.status === 200) {
						res.data.forEach((item) => {
							xlsit.push(item.day);
							y1.push(item.amout); //销售额度
							y2.push(item.number); //销售量
						});
						//y1和y2的最大值
						let Max1 = this.calMax(y1);
						let Max2 = this.calMax(y2);
						//  报表
						this.option = {
							tooltip: {
								trigger: 'axis',
								axisPointer: {
									type: 'cross',
									crossStyle: {
										color: '#999',
									},
								},
							},
							resize: true,
							grid: {
								// 让图表占满容器
								left: '2%',
								right: '2%',
								containLabel: true,
							},
							legend: {
								data: ['销售额', '销量'],
							},
							xAxis: [
								{
									type: 'category',
									data: xlsit, //日期
									axisPointer: {
										type: 'shadow',
									},
									axisLabel: {
										color: '#999',
									},
									axisLine: {
										lineStyle: {
											color: '#DCDFE6',
										},
									},
								},
							],
							yAxis: [
								{
									type: 'value',
									name: '销售额',
									scale: true, //自适应
									axisLabel: {
										formatter: (value) => {
											if (value > 10000) {
												let val = Math.ceil(
													value / 10000
												);
												return `${val}` + '万';
											} else {
												let val = Math.ceil(value);
												return `${val}`;
											}
										},
									},
								},

								{
									type: 'value',
									name: '销量',
									scale: true, //自适应
									axisLabel: {
										formatter: (value) => {
											let val = Math.ceil(value);
											return `${val}`;
										},
									},
								},
							],
							series: [
								{
									name: '销售额',
									type: 'line',
									tooltip: {
										valueFormatter: function (value) {
											let val = value
												.toFixed(2)
												.replace(/\.?0+$/, '');
											return val + '';
										},
									},
									// yAxisIndex: 1,
									data: y1, //--销量--
									type: 'line',
									smooth: true, //设置平滑曲线
									lineStyle: {
										// 设置线条上点的颜色（和图例的颜色）
										normal: {
											color: '#298DFFFF',
										},
									},
								},
								{
									name: '销量',
									type: 'bar',
									yAxisIndex: 1,
									tooltip: {
										valueFormatter: function (value) {
											let val = value
												.toFixed(2)
												.replace(/\.?0+$/, '');
											return val;
										},
									},
									data: y2, //--销售额--
									barWidth: 16, //柱状宽度
									itemStyle: {
										normal: {
											//柱状颜色和圆角
											color: '#D4E8FF',
											barBorderRadius: [6, 6, 6, 6], // （顺时针左上，右上，右下，左下）
											// 移入当前的柱状图时改变颜色
										},
										emphasis: {
											color: '#298DFF',
										},
									},
								},
							],
						};
						let isArray;
						for (let i = 0; i < y1.length; i++) {
							if (y1[i] === 0) {
								isArray = true;
							} else {
								isArray = false;
								break;
							}
						}

						if (isArray) {
							if ((this.option.yAxis[0].max = 10)) {
								this.option.yAxis[0].max = Max1 = 300000; //设置左侧最大值
							}
						} else {
							this.option.yAxis[0].max = Max1; //设置左侧最大值
						}
						let isArray1;
						for (let i1 = 0; i1 < y2.length; i1++) {
							if (y2[i1] === 0) {
								isArray1 = true;
							} else {
								isArray1 = false;
								break;
							}
						}
						if (isArray1) {
							if ((this.option.yAxis[1].max = 10)) {
								this.option.yAxis[1].max = Max2 = 10000; //设置左侧最大值
							}
						} else {
							this.option.yAxis[1].max = Max2; //设置左侧最大值
						}
						// this.option.yAxis[0].max = Max1 //设置左侧最大值
						// this.option.yAxis[1].max = Max2 //设置右侧最大值

						this.option.yAxis[0].interval = Max1 / 6; //设置左侧刻度间隔距离，平均为10份
						this.option.yAxis[1].interval = Max2 / 6; //设置右侧刻度间隔距离，平均为10份
						this.option && myChart.setOption(this.option);
						window.addEventListener('resize', () => {
							chart.resize();
						});
					}
				});
			//首页-销售出库图标统计(日)
			this.$http
				.post(
					'DataAnalysis/SalOutStockReport_Day',
					this.SalOutStockdata
				)
				.then((res) => {
					let xlsit = [];
					let y1 = [];
					let y2 = [];
					if (res.status === 200) {
						res.data.forEach((item) => {
							xlsit.push(item.day);
							y1.push(item.amout);
							y2.push(item.number);
						});
						//y1和y2的最大值
						let Max1 = this.calMax(y1);
						let Max2 = this.calMax(y2);
						//  报表
						this.optiona = {
							tooltip: {
								trigger: 'axis',
								axisPointer: {
									type: 'cross',
									crossStyle: {
										color: '#999',
									},
								},
							},
							resize: true,
							grid: {
								// 让图表占满容器
								// top: '3%',
								left: '2%',
								right: '2%',
								containLabel: true,
								//bottom: '3%',
							},
							legend: {
								data: ['出库额', '出库量'],
							},
							xAxis: [
								{
									type: 'category',
									data: xlsit,
									axisPointer: {
										type: 'shadow',
									},
									axisLabel: {
										color: '#999',
									},
									axisLine: {
										lineStyle: {
											color: '#DCDFE6',
										},
									},
								},
							],
							yAxis: [
								{
									type: 'value',
									name: '出库额',

									scale: true, //自适应
									axisLabel: {
										formatter: (value) => {
											if (value > 10000) {
												let val = Math.ceil(
													value / 10000
												);
												return `${val}` + '万';
											} else {
												let val = Math.ceil(value);
												return `${val}`;
											}
										},
									},
								},
								{
									type: 'value',
									name: '出库量',
									scale: true, //自适应

									axisLabel: {
										formatter: (value) => {
											let val = Math.ceil(value);
											return `${val}`;
										},
									},
								},
							],

							series: [
								{
									name: '出库额',
									type: 'line',
									tooltip: {
										valueFormatter: function (value) {
											let val = value
												.toFixed(2)
												.replace(/\.?0+$/, '');
											return val + '';
										},
									},
									smooth: true, //设置平滑曲线
									data: y1,
									itemStyle: {
										// 设置点的颜色
										normal: {
											color: '#04CC8DFF',
										},
									},
									lineStyle: {
										// 设置线条上点的颜色（和图例的颜色）
										normal: {
											color: '#04CC8DFF',
										},
									},
								},
								{
									name: '出库量',
									type: 'bar',
									yAxisIndex: 1,
									tooltip: {
										valueFormatter: function (value) {
											let val = value
												.toFixed(2)
												.replace(/\.?0+$/, '');
											return val + '';
										},
									},
									data: y2,
									type: 'bar',
									barWidth: 16, //柱状宽度
									itemStyle: {
										normal: {
											//柱状颜色和圆角
											color: '#CDF5E8',
											barBorderRadius: [6, 6, 6, 6], // （顺时针左上，右上，右下，左下）
										},
										emphasis: {
											color: '#04CC8D',
										},
									},
								},
							],
						};
						let isArray;
						for (let i = 0; i < y1.length; i++) {
							if (y1[i] === 0) {
								isArray = true;
							} else {
								isArray = false;
								break;
							}
						}
						if (isArray) {
							if ((this.optiona.yAxis[0].max = 10)) {
								this.optiona.yAxis[0].max = Max1 = 300000; //设置左侧最大值
							}
						} else {
							this.optiona.yAxis[0].max = Max1; //设置左侧最大值
						}
						let isArray1;
						for (let i1 = 0; i1 < y2.length; i1++) {
							if (y2[i1] === 0) {
								isArray1 = true;
							} else {
								isArray1 = false;
								break;
							}
						}
						if (isArray1) {
							if ((this.optiona.yAxis[1].max = 10)) {
								this.optiona.yAxis[1].max = Max2 = 10000; //设置左侧最大值
							}
						} else {
							this.optiona.yAxis[1].max = Max2; //设置左侧最大值
						}
						// this.optiona.yAxis[0].max = Max1 //设置左侧最大值
						// this.optiona.yAxis[1].max = Max2 //设置右侧最大值
						this.optiona.yAxis[0].interval = Max1 / 6; //设置左侧刻度间隔距离，平均为10份
						this.optiona.yAxis[1].interval = Max2 / 6; //设置右侧刻度间隔距离，平均为10份
						this.optiona && myCharta.setOption(this.optiona);
						window.addEventListener('resize', () => {
							chart.resize();
						});
					}
				});
		},
		getcheckmonth() {
			//销售额月度
			this.timeType1 = 2;
			var chartDom;
			var myChart;
			var chartDoma;
			var myCharta;
			chartDom = document.getElementById('main');
			myChart = echarts.init(chartDom);
			chartDoma = document.getElementById('main1');
			myCharta = echarts.init(chartDoma);
			// 首页-销售图标统计(月)
			this.$http
				.post(
					'DataAnalysis/SalOrderReport_Month',
					this.SalOrderReportdata
				)
				.then((res) => {
					let xlsit = [];
					let y1 = [];
					let y2 = [];
					if (res.status === 200) {
						res.data.forEach((item) => {
							xlsit.push(item.day);
							y1.push(item.amout);
							y2.push(item.number);
						});
						//y1和y2的最大值
						let Max1 = this.calMax(y1);
						let Max2 = this.calMax(y2);
						//  报表
						this.option = {
							tooltip: {
								trigger: 'axis',
								axisPointer: {
									type: 'cross',
									crossStyle: {
										color: '#999',
									},
								},
							},
							resize: true,
							grid: {
								// 让图表占满容器
								left: '2%',
								right: '2%',
								containLabel: true,
							},
							legend: {
								data: ['销售额', '销量'],
							},
							xAxis: [
								{
									type: 'category',
									data: xlsit, //日期
									axisPointer: {
										type: 'shadow',
									},
									axisLabel: {
										color: '#999',
									},
									axisLine: {
										lineStyle: {
											color: '#DCDFE6',
										},
									},
								},
							],
							yAxis: [
								{
									type: 'value',
									name: '销售额',
									scale: true, //自适应
									axisLabel: {
										formatter: (value) => {
											if (value > 10000) {
												let val = Math.ceil(
													value / 10000
												);
												return `${val}` + '万';
											} else {
												let val = Math.ceil(value);
												return `${val}`;
											}
										},
									},
								},
								{
									type: 'value',
									name: '销量',
									scale: true, //自适应
									axisLabel: {
										formatter: (value) => {
											let val = Math.ceil(value);
											return `${val}`;
										},
									},
								},
							],
							series: [
								{
									name: '销售额',
									type: 'line',
									tooltip: {
										valueFormatter: function (value) {
											let val = value
												.toFixed(2)
												.replace(/\.?0+$/, '');
											return val + '';
										},
									},
									// yAxisIndex: 1,
									data: y1, //--销量--
									type: 'line',
									smooth: true, //设置平滑曲线
									lineStyle: {
										// 设置线条上点的颜色（和图例的颜色）
										normal: {
											color: '#298DFFFF',
										},
									},
								},
								{
									name: '销量',
									type: 'bar',
									yAxisIndex: 1,
									tooltip: {
										valueFormatter: function (value) {
											let val = value
												.toFixed(2)
												.replace(/\.?0+$/, '');
											return val;
										},
									},
									data: y2, //--销售额--
									barWidth: 16, //柱状宽度
									itemStyle: {
										normal: {
											//柱状颜色和圆角
											color: '#D4E8FF',
											barBorderRadius: [6, 6, 6, 6], // （顺时针左上，右上，右下，左下）
											// 移入当前的柱状图时改变颜色
										},
										emphasis: {
											color: '#298DFF',
										},
									},
								},
							],
						};
						let isArray;
						for (let i = 0; i < y1.length; i++) {
							if (y1[i] === 0) {
								isArray = true;
							} else {
								isArray = false;
								break;
							}
						}
						if (isArray) {
							if ((this.option.yAxis[0].max = 10)) {
								this.option.yAxis[0].max = Max1 = 300000; //设置左侧最大值
							}
						} else {
							this.option.yAxis[0].max = Max1; //设置左侧最大值
						}
						let isArray1;
						for (let i1 = 0; i1 < y2.length; i1++) {
							if (y2[i1] === 0) {
								isArray1 = true;
							} else {
								isArray1 = false;
								break;
							}
						}
						if (isArray1) {
							if ((this.option.yAxis[1].max = 10)) {
								this.option.yAxis[1].max = Max2 = 10000; //设置左侧最大值
							}
						} else {
							this.option.yAxis[1].max = Max2; //设置左侧最大值
						}
						// this.option.yAxis[0].max = Max1 //设置左侧最大值
						// this.option.yAxis[1].max = Max2 //设置右侧最大值
						this.option.yAxis[0].interval = Max1 / 6; //设置左侧刻度间隔距离，平均为10份
						this.option.yAxis[1].interval = Max2 / 6; //设置右侧刻度间隔距离，平均为10份
						this.option && myChart.setOption(this.option);
						window.addEventListener('resize', () => {
							chart.resize();
						});
					}
				});
			//首页-销售出库图标统计(月)
			this.$http
				.post(
					'DataAnalysis/SalOutStockReport_Month',
					this.SalOutStockReport
				)
				.then((res) => {
					let xlsit = [];
					let y1 = [];
					let y2 = [];
					if (res.status === 200) {
						res.data.forEach((item) => {
							xlsit.push(item.day);
							y1.push(item.amout);
							y2.push(item.number);
						});
						//y1和y2的最大值
						let Max1 = this.calMax(y1);
						let Max2 = this.calMax(y2);
						//  报表
						this.optiona = {
							tooltip: {
								trigger: 'axis',
								axisPointer: {
									type: 'cross',
									crossStyle: {
										color: '#999',
									},
								},
							},
							resize: true,
							grid: {
								// 让图表占满容器
								// top: '3%',
								left: '2%',
								right: '2%',
								containLabel: true,
								//bottom: '3%',
							},
							legend: {
								data: ['出库额', '出库量'],
							},
							xAxis: [
								{
									type: 'category',
									data: xlsit,
									axisPointer: {
										type: 'shadow',
									},
									axisLabel: {
										color: '#999',
									},
									axisLine: {
										lineStyle: {
											color: '#DCDFE6',
										},
									},
								},
							],
							yAxis: [
								{
									type: 'value',
									name: '出库额',

									scale: true, //自适应
									axisLabel: {
										formatter: (value) => {
											if (value > 10000) {
												let val = Math.ceil(
													value / 10000
												);
												return `${val}` + '万';
											} else {
												let val = Math.ceil(value);
												return `${val}`;
											}
										},
									},
								},
								{
									type: 'value',
									name: '出库量',

									scale: true, //自适应
									axisLabel: {
										formatter: (value) => {
											let val = Math.ceil(value);
											return `${val}`;
										},
									},
								},
							],
							series: [
								{
									name: '出库额',
									type: 'line',
									tooltip: {
										valueFormatter: function (value) {
											let val = value
												.toFixed(2)
												.replace(/\.?0+$/, '');
											return val + '';
										},
									},
									smooth: true, //设置平滑曲线
									data: y1,
									itemStyle: {
										// 设置点的颜色
										normal: {
											color: '#04CC8DFF',
										},
									},
									lineStyle: {
										// 设置线条上点的颜色（和图例的颜色）
										normal: {
											color: '#04CC8DFF',
										},
									},
								},
								{
									name: '出库量',
									type: 'bar',
									yAxisIndex: 1,
									tooltip: {
										valueFormatter: function (value) {
											let val = value
												.toFixed(2)
												.replace(/\.?0+$/, '');
											return val + '';
										},
									},
									data: y2,
									type: 'bar',
									barWidth: 16, //柱状宽度
									itemStyle: {
										normal: {
											//柱状颜色和圆角
											color: '#CDF5E8',
											barBorderRadius: [6, 6, 6, 6], // （顺时针左上，右上，右下，左下）
										},
										emphasis: {
											color: '#04CC8D',
										},
									},
								},
							],
						};
						this.optiona.yAxis[0].max = Max1; //设置左侧最大值
						this.optiona.yAxis[1].max = Max2; //设置右侧最大值
						this.optiona.yAxis[0].interval = Max1 / 6; //设置左侧刻度间隔距离，平均为10份
						this.optiona.yAxis[1].interval = Max2 / 6; //设置右侧刻度间隔距离，平均为10份
						this.optiona && myCharta.setOption(this.optiona);
						window.addEventListener('resize', () => {
							chart.resize();
						});
					}
				});
		},
		getcheckmonth1(type) {
			this.Inventorydata.timeType = type;
			//库存金额分析
			var chartDom2;
			var myChart2;
			chartDom2 = document.getElementById('main2');
			myChart2 = echarts.init(chartDom2);
			this.$http
				.post('DataAnalysis/InventoryAmount', this.Inventorydata)
				.then((res) => {
					let xlsit = [];
					let y1 = [];
					if (res.status === 200) {
						res.data.forEach((item) => {
							xlsit.push(item.date);
							y1.push(item.amount);
						});
						//y1和y2的最大值
						let Max1 = this.calMax(y1);
						this.option2 = {
							tooltip: {
								trigger: 'axis',
								axisPointer: {
									type: 'cross',
									crossStyle: {
										color: '#999',
									},
								},
							},
							resize: true,
							grid: {
								// 让图表占满容器
								// top: '3%',
								left: '2%',
								right: '2%',
								containLabel: true,
								//bottom: '3%',
							},
							xAxis: [
								{
									type: 'category',
									data: xlsit,
									axisPointer: {
										type: 'shadow',
									},
									axisLabel: {
										color: '#999',
									},
									axisLine: {
										lineStyle: {
											color: '#DCDFE6',
										},
									},
								},
							],
							yAxis: [
								{
									type: 'value',
									name: '库存额',
									min: 0,
									max: 2500000,
									axisLabel: {
										formatter: (value) => {
											if (value > 10000) {
												let val = Math.ceil(
													value / 10000
												);
												return `${val}` + '万';
											} else {
												let val = Math.ceil(value);
												return `${val}`;
											}
										},
									},
								},
							],
							series: [
								{
									name: '库存额',
									type: 'bar',
									tooltip: {
										valueFormatter: function (value) {
											let val = value
												.toFixed(2)
												.replace(/\.?0+$/, '');
											return val + ' ';
										},
									},
									data: y1,
									type: 'line',
									smooth: true, //设置平滑曲线

									itemStyle: {
										// 设置点的颜色
										normal: {
											color: '#FA5757FF',
										},
									},
								},
							],
						};
						let isArray;
						for (let i = 0; i < y1.length; i++) {
							if (y1[i] === 0) {
								isArray = true;
							} else {
								isArray = false;
								break;
							}
						}
						if (isArray) {
							if ((this.option2.yAxis[0].max = 10)) {
								this.option2.yAxis[0].max = Max1 = 300000; //设置左侧最大值
							}
						} else {
							this.option2.yAxis[0].max = Max1; //设置左侧最大值
						}

						// this.option2.yAxis[0].max = Max1 //设置左侧最大值
						this.option2.yAxis[0].interval = Max1 / 6; //设置左侧刻度间隔距离，平均为10份
						this.option2 && myChart2.setOption(this.option2);
						window.addEventListener('resize', () => {
							chart.resize();
						});
					}
				});

			this.InventoryTurnoverdata.timeType = type;
			if (this.tit1) {
				this.getgetcheckacs(1);
			} else if (!this.tit1) {
				this.getgetcheckacs(2);
			}
		},
		getcheckmonth2(type) {
			this.ProductValuedata.timeType = type;
			var chartDom4;
			var myChart4;
			chartDom4 = document.getElementById('main4');
			myChart4 = echarts.init(chartDom4);
			//生产产值分析
			this.$http
				.post('DataAnalysis/ProductValue', this.ProductValuedata)
				.then((res) => {
					let xlsit = [];
					let y1 = [];
					if (res.status === 200) {
						res.data.forEach((item) => {
							xlsit.push(item.date);
							y1.push(item.outputValue);
						});
						//y1和y2的最大值
						let Max1 = this.calMax(y1);
						this.option4 = {
							tooltip: {
								trigger: 'axis',
								axisPointer: {
									type: 'cross',
									crossStyle: {
										color: '#999',
									},
								},
							},
							resize: true,
							grid: {
								// 让图表占满容器
								// top: '3%',
								left: '2%',
								right: '2%',
								containLabel: true,
								//bottom: '3%',
							},
							xAxis: [
								{
									type: 'category',
									data: xlsit,
									axisPointer: {
										type: 'shadow',
									},
									axisLabel: {
										color: '#999',
									},
									axisLine: {
										lineStyle: {
											color: '#DCDFE6',
										},
									},
								},
							],
							yAxis: [
								{
									type: 'value',
									name: '产值',
									min: 0,
									max: 10000,
									axisLabel: {
										formatter: (value) => {
											if (value > 10000) {
												let val = Math.ceil(
													value / 10000
												);
												return `${val}` + '万';
											} else {
												let val = Math.ceil(value);
												return `${val}`;
											}
										},
									},
								},
							],
							series: [
								{
									name: '产值',
									type: 'bar',
									tooltip: {
										valueFormatter: function (value) {
											let val = value
												.toFixed(2)
												.replace(/\.?0+$/, '');
											return val;
										},
									},
									data: y1,
									type: 'line',
									smooth: true, //设置平滑曲线

									itemStyle: {
										// 设置点的颜色
										normal: {
											color: '#FC7C49FF',
										},
									},
								},
							],
						};

						let isArray;
						for (let i = 0; i < y1.length; i++) {
							if (y1[i] === 0) {
								isArray = true;
							} else {
								isArray = false;
								break;
							}
						}
						if (isArray) {
							if ((this.option4.yAxis[0].max = 10)) {
								this.option4.yAxis[0].max = Max1 = 100; //设置左侧默认最大值
							}
						} else {
							this.option4.yAxis[0].max = Max1; //设置左侧最大值
						}

						// this.option4.yAxis[0].max = Max1 //设置左侧最大值
						this.option4.yAxis[0].interval = Max1 / 6; //设置左侧刻度间隔距离，平均为10份
						this.option4 && myChart4.setOption(this.option4);
						window.addEventListener('resize', () => {
							chart.resize();
						});
					}
				});
		},
		getcheckmonth3(type) {
			this.Accuratedata.timeType = type;
			this.Accuratedata.orgId = this.orgId;
			// console.log(this.Accuratedata, '=this.Accuratedata====xxxx')
			var chartDom5;
			var myChart5;
			chartDom5 = document.getElementById('main5');
			myChart5 = echarts.init(chartDom5);
			//准交分析
			this.$http
				.post('DataAnalysis/AccurateDelivery', this.Accuratedata)
				.then((res) => {
					let xlsit = [];
					let y1 = [];
					let y2 = [];
					if (res.status === 200) {
						res.data.forEach((item) => {
							xlsit.push(item.date);
							y1.push(item.averageDeliveryDays);
							y2.push(item.accurateDeliveryRate * 100);
						});
						let Max1 = this.calMax(y1);
						// let Max2 = this.calMax(y2)
						this.option5 = {
							tooltip: {
								trigger: 'axis',
								axisPointer: {
									type: 'cross',
									crossStyle: {
										color: '#999',
									},
								},
							},
							legend: {
								data: ['准交率', '平均交付天数'],
							},
							resize: true,
							grid: {
								// 让图表占满容器
								// top: '3%',
								left: '2%',
								right: '2%',
								containLabel: true,
								//bottom: '3%',
							},
							xAxis: [
								{
									type: 'category',
									data: xlsit,
									axisPointer: {
										type: 'shadow',
									},
									axisLabel: {
										color: '#999',
									},
									axisLine: {
										lineStyle: {
											color: '#DCDFE6',
										},
									},
								},
							],
							yAxis: [
								{
									type: 'value',
									name: '准交率',
									min: 0,
									max: 100,
									interval: 20,
									axisLabel: {
										formatter: '{value} %',
									},
								},
								{
									type: 'value',
									name: '平均交付天数',
									min: 0,
									max: 50,
									interval: 10,
									axisLabel: {
										formatter: '{value} ',
									},
								},
							],
							series: [
								{
									name: '准交率',
									type: 'line',
									tooltip: {
										valueFormatter: function (value) {
											let val = value
												.toFixed(2)
												.replace(/\.?0+$/, '');
											return val + ' %';
											// return value;
										},
									},
									data: y2,
									smooth: true, //设置平滑曲线
									itemStyle: {
										// 设置点的颜色
										normal: {
											color: '#796DFFFF',
										},
									},
									lineStyle: {
										// 设置线条上点的颜色（和图例的颜色）
										normal: {
											color: '#796DFFFF',
										},
									},
								},
								{
									name: '平均交付天数',
									yAxisIndex: 1,
									tooltip: {
										valueFormatter: function (value) {
											let val = value
												.toFixed(2)
												.replace(/\.?0+$/, '');
											return val + '';
										},
									},
									data: y1,
									type: 'bar',

									barWidth: 16, //柱状宽度
									itemStyle: {
										normal: {
											//柱状颜色和圆角
											color: '#E4E2FF',
											barBorderRadius: [6, 6, 6, 6], // （顺时针左上，右上，右下，左下）
										},
										emphasis: {
											color: '#796DFF',
										},
									},
								},
							],
						};
						let isArray;
						for (let i = 0; i < y1.length; i++) {
							if (y1[i] === 0) {
								isArray = true;
							} else {
								isArray = false;
								break;
							}
						}
						if (isArray) {
							if ((this.option5.yAxis[1].max = 10)) {
								this.option5.yAxis[1].max = Max1 = 100; //设置左侧默认最大值
							}
						} else {
							this.option5.yAxis[1].max = Max1; //设置左侧最大值
						}
						this.option5.yAxis[1].interval = Max1 / 5; //设置左侧刻度间隔距离，平均为10份
						this.option5 && myChart5.setOption(this.option5);
						window.addEventListener('resize', () => {
							chart.resize();
						});
					}
				});
		},

		//切换销售排行天数

		//销售排行榜top10
		getSalerabjing(type) {
			this.active4 = !this.active4;
			if (type === 7) {
				this.active4 = true;
				this.active5 = false;
				this.active6 = false;
			} else if (type === 14) {
				this.active5 = true;
				this.active4 = false;
				this.active6 = false;
			} else if (type === 30) {
				this.active6 = true;
				this.active5 = false;
				this.active4 = false;
			}

			this.requesdata.days = type;
			this.requesdata.orgid = this.orgId;
			this.$http
				.post('DataAnalysis/SaleRanking', this.requesdata)
				.then((res) => {
					if (res.status === 200) {
						this.requesttableData = res.data;
					}
				});
		},

		//手动刷新数据  /api/v{version}/DataAnalysis/Flushed
		getrefresh() {
			this.$http.post('/DataAnalysis/Flushed').then((res) => {
				if (res.status === 200) {
					this.$message.success({
						message: '刷新成功',
						showClose: true,
					});
				}
			});
		},

		//获取任务下拉和状态下拉数据
		getselectList() {
			this.$http.get('FileDownManager/GetStatus').then((res) => {
				if (res.status === 200) {
					this.typelist = res.data.type;
					this.statuslsit = res.data.status;
				}
			});
		},
		// 获取导出下载列表数据
		getFileDownManagerQuery() {
			this.$http
				.post('FileDownManager/FileDownManagerQuery', this.search)
				.then((res) => {
					if (res.status === 200) {
						this.tableData = res.data.list;
					}
				});
		},
		// 核心数据统计
		statisticsToal() {
			// this.$http.get('Home/statistics').then(res => {
			//   if (res.status === 200) {
			//     this.statistics = res.data
			//     for (const key in this.statistics) {
			//       if (key !== 'createDate') {
			//         this.statistics[key] = Number(this.statistics[key]).toFixed(2) * 1
			//       }
			//     }
			//     console.log('核心数据统计', this.statistics)
			//   }
			// })
		},
		// 获取最近打开的数据
		getOpendList() {
			this.$http.post('Home/GetOpendList').then((res) => {
				if (res.status === 200) {
					this.openlist = res.data;
				}
			});
		},

		// 点击最近打开
		handleOpenPage(item) {
			this.$router.push({
				path: item.path,
			});
			//记录最近打开菜单
			this.$http.post('Home/open', { menuId: item.menuId });
		},
		handleClick(tab, event) {
			console.log(tab, event);
		},
	},
};
</script>
<style lang="scss" scoped>
@import '@/assets/style/index1.scss';

.isactive {
	::v-deep(.page-main .lab1) {
		color: #4178d5 !important;
	}
}
::v-deep(.el-input__suffix) {
	position: absolute;
	height: 100%;
	right: 5px;
	top: 0;
	text-align: center;
	color: var(--el-input-icon-color, var(--el-text-color-placeholder));
	transition: all var(--el-transition-duration);
	pointer-events: none;
	display: flex !important;
	align-items: center !important;
}
</style>
