<template>
	<view class="ammeter-warp">

		<view class="all-con-item-box" style="margin-top: 0!important;">
			<Section :title="$t('homePage.device.volqua')">
			</Section>
			<view class="chart-box">
				<view class="time-box" @click="openVolTime">
					<view class="time">
						{{voltimeArr[0]}}
					</view>~
					<view class="time">
						{{voltimeArr[1]}}
					</view>
				</view>
				<zero-loading v-if="volLoading" position="absolute"></zero-loading>
				<charts v-else :id="'pcsChart'" :options="vol_option"></charts>
			</view>
		</view>

		<view class="all-con-item-box">
			<Section :title="$t('homePage.device.curqua')" />
		
			
			<view class="chart-box">
				<view class="time-box" @click="openCurTime">
					<view class="time">
						{{curtimeArr[0]}}
					</view>~
					<view class="time">
						{{curtimeArr[1]}}
					</view>
				</view>
					<zero-loading v-if="curLoading" position="absolute"></zero-loading>
				<charts :id="'pcsChart'" :options="cur_option"></charts>
			</view>
		</view>

		<view class="all-con-item-box">
			<Section :title="$t('homePage.device.acRea')">
			</Section>
			<view class="chart-box">
				<view class="time-box" @click="openPowTime">
					<view class="time">
						{{powtimeArr[0]}}
					</view>~
					<view class="time">
						{{powtimeArr[1]}}
					</view>
				</view>
				<zero-loading v-if="powLoading" position="absolute"></zero-loading>
				<charts v-else :id="'pcsChart'" :options="pow_option"></charts>
			</view>
		</view>

		<view class="all-con-item-box">
			<Section :title="$t('homePage.device.runData')">
			</Section>
					<zero-loading v-if="runLoading" position="absolute"></zero-loading>
			<view v-else class="group-box">
				<view class="group-item" @click="showHistory($t('homePage.device.avol'), 'Ua', 'ele_meter','V','')">
					 <view class="history-icon">
        	 <image src="/static/aidex/images/history-icon.png"></image>
        </view>
					<view class="item-icon">
						<image src="/static/aidex/images/zjrl.png"></image>
						<!-- <i class="iconfont icon-pingtaiyunhangtianshu"></i> -->
					</view>
					<view class="item-con">
						<view class="item-num">{{panelData.Ua | isNull}}

						</view>
						<view class="item-title">{{this.$t('homePage.device.avol')}}(V)</view>
					</view>
				</view>


				<view class="group-item" @click="showHistory($t('homePage.device.acur'), 'Ia', 'ele_meter','A','')">
					 <view class="history-icon">
        	 <image src="/static/aidex/images/history-icon.png"></image>
        </view>
					<view class="item-icon">
						<image src="/static/aidex/images/zjrl.png"></image>
					</view>
					<view class="item-con">
						<view class="item-num">{{ panelData.Ia | isNull}}

						</view>
						<view class="item-title">{{this.$t('homePage.device.acur')}}(A)</view>
					</view>
				</view>


				<view class="group-item" @click="showHistory($t('homePage.device.bvol'), 'Ub', 'ele_meter','V','')">
					 <view class="history-icon">
        	 <image src="/static/aidex/images/history-icon.png"></image>
        </view>
					<view class="item-icon">
						<image src="/static/aidex/images/dqgl.png"></image>
					</view>
					<view class="item-con">
						<view class="item-num">{{panelData.Ub | isNull}}

						</view>
						<view class="item-title">{{this.$t('homePage.device.bvol')}}(V)</view>
					</view>
				</view>

				<view class="group-item" @click="showHistory($t('homePage.device.bcur'), 'Ib', 'ele_meter','A','')">
					 <view class="history-icon">
        	 <image src="/static/aidex/images/history-icon.png"></image>
        </view>
					<view class="item-icon">
						<image src="/static/aidex/images/zjrl.png"></image>
						<!-- <i class="iconfont icon-pingtaiyunhangtianshu"></i> -->
					</view>
					<view class="item-con">
						<view class="item-num">{{panelData.Ib | isNull}}

						</view>
						<view class="item-title">{{this.$t('homePage.device.bcur')}}(A)</view>
					</view>
				</view>


				<view class="group-item" @click="showHistory($t('homePage.device.cvol'), 'Uc', 'ele_meter','V','')">
					 <view class="history-icon">
        	 <image src="/static/aidex/images/history-icon.png"></image>
        </view>
					<view class="item-icon">
						<image src="/static/aidex/images/zjrl.png"></image>
					</view>
					<view class="item-con">
						<view class="item-num">{{ panelData.Uc | isNull}}

						</view>
						<view class="item-title">{{this.$t('homePage.device.cvol')}}(V)</view>
					</view>
				</view>


				<view class="group-item" @click="showHistory($t('homePage.device.ccur'), 'Ic', 'ele_meter','A','')">
					 <view class="history-icon">
        	 <image src="/static/aidex/images/history-icon.png"></image>
        </view>
					<view class="item-icon">
						<image src="/static/aidex/images/dqgl.png"></image>
					</view>
					<view class="item-con">
						<view class="item-num">{{panelData.Ic | isNull}}

						</view>
						<view class="item-title">{{this.$t('homePage.device.ccur')}}(A)</view>
					</view>
				</view>

				<view class="group-item" @click="showHistory($t('homePage.device.abLineVol'), 'Uab', 'ele_meter','V','')">
					 <view class="history-icon">
        	 <image src="/static/aidex/images/history-icon.png"></image>
        </view>
					<view class="item-icon">
						<image src="/static/aidex/images/zjrl.png"></image>
						<!-- <i class="iconfont icon-pingtaiyunhangtianshu"></i> -->
					</view>
					<view class="item-con">
						<view class="item-num">{{panelData.Uab | isNull}}

						</view>
						<view class="item-title">{{this.$t('homePage.device.abLineVol')}}(V)</view>
					</view>
				</view>


				<view class="group-item" @click="showHistory($t('homePage.device.bcLineVol'), 'Ubc', 'ele_meter','V','')">
					 <view class="history-icon">
        	 <image src="/static/aidex/images/history-icon.png"></image>
        </view>
					<view class="item-icon">
						<image src="/static/aidex/images/zjrl.png"></image>
					</view>
					<view class="item-con">
						<view class="item-num">{{ panelData.Ubc | isNull}}

						</view>
						<view class="item-title">{{this.$t('homePage.device.bcLineVol')}}(V)</view>
					</view>
				</view>


				<view class="group-item" @click="showHistory($t('homePage.device.caLineVol'), 'Uca', 'ele_meter','V','')">
					 <view class="history-icon">
        	 <image src="/static/aidex/images/history-icon.png"></image>
        </view>
					<view class="item-icon">
						<image src="/static/aidex/images/dqgl.png"></image>
					</view>
					<view class="item-con">
						<view class="item-num">{{panelData.Uca | isNull}}

						</view>
						<view class="item-title">{{$t('homePage.device.caLineVol')}}(V)</view>
					</view>
				</view>
			</view>
		</view>





		<view class="all-con-item-box">
			<Section :title="$t('homePage.device.runData')">
			</Section>
			<zero-loading v-if="runLoading" position="absolute"></zero-loading>
			<view v-else class="group-box border-bottom padding-top-30 padding-bottom-30"
				@click="showHistory($t('homePage.device.zxygzdl'), 'totalCharge', 'ele_meter','kWh','')">
				<view class="other-value">
					<view class="top-value">
						<view class="title">
							{{this.$t('homePage.device.zxygzdl')}}
						</view>
						<view class="zhexian-icon">
							<image src="/static/aidex/images/zhexian.png"></image>
						</view>
						<view class="value">
							{{ panelData.totalCharge | kwhFormat}}{{panelData.totalCharge | kwhUnitFormat}}
						</view>
					</view>
					<view class="bottom-value">
						<view>
							{{this.$t('homePage.device.dlj')}}：{{ panelData.forwardActE1 | isNull}}
						</view>

						<view>
							{{this.$t('homePage.device.dlf')}}：{{ panelData.forwardActE2 | isNull}}
						</view>

						<view>
							{{this.$t('homePage.device.dlp')}}：{{ panelData.forwardActE3 | isNull}}
						</view>
						<view>
							{{this.$t('homePage.device.dlg')}}：{{ panelData.forwardActE4 | isNull}}
						</view>

					</view>
				</view>

			</view>

			<view class="group-box border-bottom padding-top-30 padding-bottom-30"
				@click="showHistory($t('homePage.device.fxygzdl'), 'totalDisCharge', 'ele_meter','kWh','')">
				<view class="other-value">
					<view class="top-value">
						<view class="title">
							{{this.$t('homePage.device.fxygzdl')}}
						</view>
						<view class="zhexian-icon">
							<image src="/static/aidex/images/zhexian.png"></image>
						</view>
						<view class="value">
							{{ panelData.totalDisCharge | kwhFormat}}{{panelData.totalDisCharge | kwhUnitFormat}}
						</view>
					</view>
					<view class="bottom-value">
						<view>
							{{this.$t('homePage.device.dlj')}}：{{ panelData.backwardActE1 | isNull}}
						</view>

						<view>
							{{this.$t('homePage.device.dlf')}}：{{ panelData.backwardActE2 | isNull}}
						</view>

						<view>
							{{this.$t('homePage.device.dlp')}}：{{ panelData.backwardActE3 | isNull}}
						</view>
						<view>
							{{this.$t('homePage.device.dlg')}}：{{ panelData.backwardActE4 | isNull}}
						</view>

					</view>
				</view>

			</view>


			<view class="group-box border-bottom padding-top-30 padding-bottom-30"
				@click="showHistory($t('homePage.device.hxyggl'), 'mergePower', 'ele_meter','W','')">
				<view class="other-value">
					<view class="top-value">
						<view class="title">
							{{this.$t('homePage.device.hxyggl')}}
						</view>
						<view class="zhexian-icon">
							<image src="/static/aidex/images/zhexian.png"></image>
						</view>
						<view class="value">
							{{ panelData.mergePower}}W
						</view>
					</view>
					<view class="bottom-value">
						<view>
							{{this.$t('homePage.device.a')}}：{{ panelData.activePowerA}}
						</view>

						<view>
							{{this.$t('homePage.device.b')}}：{{ panelData.activePowerB}}
						</view>

						<view>
							{{this.$t('homePage.device.c')}}：{{ panelData.activePowerC}}
						</view>

					</view>
				</view>

			</view>

			<view class="group-box border-bottom padding-top-30 padding-bottom-30"
				@click="showHistory($t('homePage.device.hxwggl'), 'reactivePower', 'ele_meter','Var','')">
				<view class="other-value">
					<view class="top-value">
						<view class="title">
							{{this.$t('homePage.device.hxwggl')}}
						</view>
						<view class="zhexian-icon">
							<image src="/static/aidex/images/zhexian.png"></image>
						</view>
						<view class="value">
							{{ panelData.reactivePower}}Var
						</view>
					</view>
					<view class="bottom-value">
						<view>
							{{this.$t('homePage.device.a')}}：{{ panelData.reactivePowerA}}
						</view>

						<view>
							{{this.$t('homePage.device.b')}}：{{ panelData.reactivePowerB}}
						</view>

						<view>
							{{this.$t('homePage.device.c')}}：{{ panelData.reactivePowerC}}
						</view>

					</view>
				</view>

			</view>

			<view class="group-box padding-top-30 padding-bottom-30"
				@click="showHistory($t('homePage.device.hxglys'), 'PFactor', 'ele_meter','','')">
				<view class="other-value">
					<view class="top-value">
						<view class="title">
							{{this.$t('homePage.device.hxglys')}}
						</view>
						<view class="zhexian-icon">
							<image src="/static/aidex/images/zhexian.png"></image>
						</view>
						<view class="value">
							{{ panelData.PFactor}}
						</view>
					</view>
					<view class="bottom-value">
						<view>
							{{this.$t('homePage.device.a')}}：{{ panelData.PFactorA}}
						</view>

						<view>
							{{this.$t('homePage.device.b')}}：{{ panelData.PFactorB}}
						</view>

						<view>
							{{this.$t('homePage.device.c')}}：{{ panelData.PFactorC}}
						</view>

					</view>
				</view>

			</view>
		</view>



		<view style="position: fixed;z-index: 99999999;">
			<uni-datetime-picker ref="valTime" @change="selectVolTime" v-model="voltimeArr" :clearIcon="false"
				type="datetimerange" :end="endTime" rangeSeparator="~" :border="false" />

			<uni-datetime-picker ref="curTime" @change="selectCurTime" v-model="curtimeArr" :clearIcon="false"
				type="datetimerange" :end="endTime" rangeSeparator="~" />

			<uni-datetime-picker ref="powTime" @change="selectPowTime" v-model="powtimeArr" :clearIcon="false"
				type="datetimerange" :end="endTime" rangeSeparator="~" />
				
		</view>
		<historyModal :is-show.sync="histroyShow" :title="chartTitle" :params="hisParams" />
	</view>
</template>

<script>
	import Section from '@/components/section/index.vue'
	import charts from "@/components/charts/index";
	import {
		beforeDayTime,
		dataConversion
	} from '@/common/common.js'
	import historyModal from '@/components/history-modal/index.vue'
	export default {
		components: {
			Section,
			charts,
			historyModal
		},
		data() {
			return {
				loading: false,
				vol_option: {},
				cur_option: {},
				pow_option: {},
				history_option: {},
				chartLoading: false,
				stationId: null,
				srcId: null,
				voltimeArr: [],
				curtimeArr: [],
				powtimeArr: [],
				panelData: {},
				chartTitle: null,
				histroyShow: false,
				chartTitle: null,
				hisParams: {},
				volLoading:false,
				curLoading:false,
				powLoading:false,
				runLoading:false,
				panelLoading:false,
				endTime: dataConversion(new Date()),

			}
		},
		computed: {
			currentStation() {
				return this.vuex_currentStation
			}
		},
		watch: {
			currentStation: {
				handler(val) {
					this.stationId = val.id;
					this.voltimeArr = beforeDayTime()
					this.curtimeArr = beforeDayTime()
					this.powtimeArr = beforeDayTime()
				},
				deep: true,
				immediate: true
			}
		},

		methods: {
			openVolTime() {
				this.$refs.valTime.show()
			},

			openCurTime() {
				this.$refs.curTime.show()
			},

			openPowTime() {
				this.$refs.powTime.show()
			},
			showHistory(name, modelCol, modelType, unit) {
				this.hisParams = {
					modelCol: modelCol,
					modelType: modelType,
					unit: unit,
					srcId: this.srcId
				}
				this.chartTitle = name
				this.histroyShow = true
			},

			getData(srcId) {
				this.loading = true
				this.srcId = srcId
				const api = [
					this.getVol(),
					this.getCur(),
					this.getPow(),
					this.getStatus()
				]
				Promise.all(api).then(result => {
					this.err = result
					this.loading = false
				})

			},
			getStatus() {
				this.runLoading = true
				const self = this

				this.$u.api.deviceList
					.GetNewValue({
						stationId: this.stationId,
						srcId: this.srcId,
						colList: ['Ia', 'Ib', 'Ic', 'Ua', 'Ub', 'Uc', 'Uab', 'Ubc', 'Uca',
							'backwardActE1', 'backwardActE2', 'backwardActE3', 'backwardActE4', 'forwardActE1',
							'forwardActE2', 'forwardActE3', 'forwardActE4', 'totalCharge', 'totalDisCharge',
							'mergePower', 'activePowerA', 'activePowerB', 'activePowerC', 'reactivePower',
							'reactivePowerA', 'reactivePowerB', 'reactivePowerC', 'PFactor', 'PFactorA',
							'PFactorB', 'PFactorC'
						]
					}).then((res) => {
						this.panelData = {
							Ia: res.data.Ia?.value,
							Ib: res.data.Ib?.value,
							Ic: res.data.Ic?.value,
							Ua: res.data.Ua?.value,
							Ub: res.data.Ub?.value,
							Uc: res.data.Uc?.value,
							Uab: res.data.Uab?.value,
							Ubc: res.data.Ubc?.value,
							Uca: res.data.Uca?.value,


							backwardActE1: res.data.backwardActE1?.value,
							backwardActE2: res.data.backwardActE2?.value,
							backwardActE3: res.data.backwardActE3?.value,
							backwardActE4: res.data.backwardActE4?.value,
							forwardActE1: res.data.forwardActE1?.value,
							forwardActE2: res.data.forwardActE2?.value,
							forwardActE3: res.data.forwardActE3?.value,
							forwardActE4: res.data.forwardActE4?.value,
							totalCharge: res.data.totalCharge?.value,
							totalDisCharge: res.data.totalDisCharge?.value,


							mergePower: res.data.mergePower?.value,
							activePowerA: res.data.activePowerA?.value,
							activePowerB: res.data.activePowerB?.value,
							activePowerC: res.data.activePowerC?.value,
							reactivePower: res.data.reactivePower?.value,
							reactivePowerA: res.data.reactivePowerA?.value,
							reactivePowerB: res.data.reactivePowerB?.value,
							reactivePowerC: res.data.reactivePowerC?.value,
							PFactor: res.data.PFactor?.value,
							PFactorA: res.data.PFactorA?.value,
							PFactorB: res.data.PFactorB?.value,
							PFactorC: res.data.PFactorC?.value,


						}
					}).finally(() => {
						this.runLoading = false
					})
			},
			selectVolTime(val) {
				this.getVol()
			},
			selectCurTime() {
				this.getCur()
			},
			selectPowTime() {
				this.getPow()
			},
			getPow() {
				this.powLoading = true
				const self = this
				return new Promise((resolve, reject) => {
					self.$u.api.deviceList
						.GetTtackHisData({
							colName: ["reactivePower", "activePower"],
							beginTime: this.powtimeArr[0],
							endTime: this.powtimeArr[1],
							stationId: this.stationId,
							srcId: this.srcId
						})
						.then((res) => {
							self.initPow(res.data);
							resolve(res);
						})
						.finally(() => {
							this.powLoading = false
						})
				});
			},
			getCur() {
				this.curLoading = true
				const self = this
				return new Promise((resolve, reject) => {
					self.$u.api.deviceList
						.GetTtackHisData({
							colName: ["Ia", "Ib", "Ic"],
							beginTime: this.curtimeArr[0],
							endTime: this.curtimeArr[1],
							stationId: this.stationId,
							srcId: this.srcId
						})
						.then((res) => {
							self.initCur(res.data);
							resolve(res);
						})
						.finally(() => {
							this.curLoading = false
						})
				});
			},
			getVol() {
				this.volLoading = true
				const self = this
				return new Promise((resolve, reject) => {
					self.$u.api.deviceList
						.GetTtackHisData({
							colName: ["Ua", "Ub", "Uc"],
							beginTime: this.voltimeArr[0],
							endTime: this.voltimeArr[1],
							stationId: this.stationId,
							srcId: this.srcId
						})
						.then((res) => {
							self.initVol(res.data);
							resolve(res);
						})
						.finally(() => {
							this.volLoading = false
						})
				});
			},
			initPow(val) {

				const xAxisData = []
				const yAxisData1 = []
				const yAxisData2 = []
				const yAxisData3 = []
				if (val.length > 1) {
					val[0].staticCurveList.forEach(v => {
						xAxisData.push(v.date)
						yAxisData1.push(v.digital)
					})
					val[1].staticCurveList.forEach(v => {
						yAxisData2.push(v.digital)
					})
				}
				let minValue = '0'
				let maxValue = '0'
				const list = yAxisData1.concat(yAxisData2).concat(yAxisData3)
				const precision = 10 // 精度
				maxValue = Math.ceil(Math.max.apply(null, list) * precision) / precision
				minValue = Math.floor(Math.min.apply(null, list) * precision) / precision
				this.pow_option = {
					animationDuration: 500,
					animationEasing: "cubicInOut",
					tooltip: {
						trigger: "axis",
						textStyle: {
							textShadowBlur: 10, // 重点
							textShadowColor: 'transparent', // 重点
						},
						axisPointer: {},
						confine: true,
						position: function(point, params, dom, rect, size) {
							// 鼠标坐标和提示框位置的参考坐标系是：以外层div的左上角那一点为原点，x轴向右，y轴向下
							// 提示框位置
							var x = 0; // x坐标位置
							var y = 0; // y坐标位置

							// 当前鼠标位置
							var pointX = point[0];
							var pointY = point[1];

							// 外层div大小
							// var viewWidth = size.viewSize[0];
							// var viewHeight = size.viewSize[1];

							// 提示框大小
							var boxWidth = size.contentSize[0];
							var boxHeight = size.contentSize[1];

							// boxWidth > pointX 说明鼠标左边放不下提示框
							if (boxWidth > pointX) {
								x = 5; // 自己定个x坐标值，以防出屏
								y -= 15; // 防止点被覆盖住，可根据情况自行调节
							} else {
								// 左边放的下
								x = pointX - boxWidth - 15;
							}

							// boxHeight > pointY 说明鼠标上边放不下提示框
							if (boxHeight + 20 > pointY) {
								y = pointY + 15;
							} else if (boxHeight > pointY) {
								y = 5;
							} else {
								// 上边放得下
								y += pointY - boxHeight;
							}
							return [x, y];
						},
					},
					grid: {
						top: '20%',
						bottom: '10%',
						containLabel: true
					},
					brush: {
						toolbox: ['lineX'],
						xAxisIndex: 'all', // 指定哪些 series 可以被刷选
						throttleType: 'debounce', // 开启选中延迟后调用回调延迟
						throttleDelay: 600, // 选中延迟后调用回调延迟时
						brushStyle: {
							borderWidth: 1,
							color: 'rgba(120,140,180,0.3)',
							borderColor: 'red'
						}
					},
					color: ['#009C77', '#BFE49F'],
					legend: {},
					xAxis: {
						type: 'category',
						boundaryGap: false,
						data: xAxisData,
						axisLabel: {
							show: true,
							color: "#A3A3A3",
							formatter: function(params) {
								let newParamsName = '';
								const paramsNameNumber = params.length; // 文字总长度
								const provideNumber = 11; //一行显示几个字
								const rowNumber = Math.ceil(paramsNameNumber / provideNumber);
								if (paramsNameNumber > provideNumber) {
									for (let p = 0; p < rowNumber; p++) {
										const start = p * provideNumber;
										const end = start + provideNumber;
										const tempStr = p === rowNumber - 1 ? params.substring(start,
											paramsNameNumber) : params.substring(start, end) + '\n';
										newParamsName += tempStr;
									}
								} else {
									newParamsName = params;
								}
								return newParamsName;
							},
						},
						axisLine: {
							lineStyle: {
								color: ['#A3A3A3']
							}
						}
					},
					yAxis: [{
						type: 'value',
						axisLabel: {
							color: '#A3A3A3'
						},
						name: this.$t('homePage.device.totalActivePower') + '/W',
						axisLine: {
							show: false,
							lineStyle: {
								color: ['#A3A3A3']
							}
						},
						nameTextStyle: {
							color: '#A3A3A3',
							padding: [0, 0, 0, 70]
						},
						max: maxValue,

					}, {
						type: 'value',
						axisLabel: {
							color: '#A3A3A3'
						},
						nameTextStyle: {
							color: '#A3A3A3',
							padding: [0, 70, 0, 0]
						},
						name: this.$t('homePage.device.totalReactivePower') + '/Var',
						axisLine: {
							show: false,
							lineStyle: {
								color: ['#A3A3A3']
							}
						},
						max: maxValue,

					}],
					series: [{
							name:  this.$t('homePage.device.active'),
							data: yAxisData2,
							type: 'line',
							// lineStyle: {
							// 	color: '#0f94da'
							// },
							// areaStyle: {
							// 	opacity: 0,
							// 	color: '#0f94da'
							// }
						},
						{
							name: this.$t('homePage.device.reactive'),
							data: yAxisData1,
							yAxisIndex: 1,
							type: 'line',
							// lineStyle: {
							// 	color: '#f0c252'
							// },
							// areaStyle: {
							// 	opacity: 0,
							// 	color: '#f0c252'
							// }
						}
					]
				}

			},
			initCur(val) {

				const xAxisData = []
				const yAxisData1 = []
				const yAxisData2 = []
				const yAxisData3 = []
				if (val.length > 0) {
					val[0].staticCurveList.forEach(v => {
						xAxisData.push(v.date)
						yAxisData1.push(v.digital)
					})
					val[1].staticCurveList.forEach(v => {
						yAxisData2.push(v.digital)
					})
					val[2].staticCurveList.forEach(v => {
						yAxisData3.push(v.digital)
					})
				}
				let minValue = '0'
				let maxValue = '0'
				const list = yAxisData1.concat(yAxisData2).concat(yAxisData3)
				const precision = 10 // 精度
				maxValue = Math.ceil(Math.max.apply(null, list) * precision) / precision
				minValue = Math.floor(Math.min.apply(null, list) * precision) / precision
				this.cur_option = {
					animationDuration: 500,
					animationEasing: "cubicInOut",
					tooltip: {
						trigger: "axis",
						textStyle: {
							textShadowBlur: 10, // 重点
							textShadowColor: 'transparent', // 重点
						},
						axisPointer: {},
						confine: true,
						position: function(point, params, dom, rect, size) {
							// 鼠标坐标和提示框位置的参考坐标系是：以外层div的左上角那一点为原点，x轴向右，y轴向下
							// 提示框位置
							var x = 0; // x坐标位置
							var y = 0; // y坐标位置

							// 当前鼠标位置
							var pointX = point[0];
							var pointY = point[1];

							// 外层div大小
							// var viewWidth = size.viewSize[0];
							// var viewHeight = size.viewSize[1];

							// 提示框大小
							var boxWidth = size.contentSize[0];
							var boxHeight = size.contentSize[1];

							// boxWidth > pointX 说明鼠标左边放不下提示框
							if (boxWidth > pointX) {
								x = 5; // 自己定个x坐标值，以防出屏
								y -= 15; // 防止点被覆盖住，可根据情况自行调节
							} else {
								// 左边放的下
								x = pointX - boxWidth - 15;
							}

							// boxHeight > pointY 说明鼠标上边放不下提示框
							if (boxHeight + 20 > pointY) {
								y = pointY + 15;
							} else if (boxHeight > pointY) {
								y = 5;
							} else {
								// 上边放得下
								y += pointY - boxHeight;
							}
							return [x, y];
						},
					},
					grid: {
						top: '20%',
						bottom: '10%',
						containLabel: true
					},
					brush: {
						toolbox: ['lineX'],
						xAxisIndex: 'all', // 指定哪些 series 可以被刷选
						throttleType: 'debounce', // 开启选中延迟后调用回调延迟
						throttleDelay: 600, // 选中延迟后调用回调延迟时
						brushStyle: {
							borderWidth: 1,
							color: 'rgba(120,140,180,0.3)',
							borderColor: 'red'
						}
					},
					color: ['#009C77', '#f0c252', '#0f94da'],
					legend: {},
					xAxis: {
						type: 'category',
						boundaryGap: false,
						data: xAxisData,
						axisLabel: {
							show: true,
							color: "#A3A3A3",
							formatter: function(params) {
								let newParamsName = '';
								const paramsNameNumber = params.length; // 文字总长度
								const provideNumber = 11; //一行显示几个字
								const rowNumber = Math.ceil(paramsNameNumber / provideNumber);
								if (paramsNameNumber > provideNumber) {
									for (let p = 0; p < rowNumber; p++) {
										const start = p * provideNumber;
										const end = start + provideNumber;
										const tempStr = p === rowNumber - 1 ? params.substring(start,
											paramsNameNumber) : params.substring(start, end) + '\n';
										newParamsName += tempStr;
									}
								} else {
									newParamsName = params;
								}
								return newParamsName;
							},
						},

						axisLine: {
							lineStyle: {
								color: ['#A3A3A3']
							}
						}
					},
					yAxis: {
						type: 'value',
						axisLabel: {
							color: '#A3A3A3'
						},
						nameTextStyle: {
							color: '#A3A3A3',
							padding: [0, 0, 0, 40]
						},
						name: this.$t('homePage.device.current') + '(A)',
						axisLine: {
							show: false,
							lineStyle: {
								color: ['#A3A3A3']
							}
						},
						max: maxValue,
					},
					series: [{
							name:  this.$t('homePage.device.acur'),
							data: yAxisData1,
							type: 'line',
							lineStyle: {
								color: '#009C77'
							},
							areaStyle: {
								opacity: 0,
								color: '#009C77'
							}
						},
						{
							name: this.$t('homePage.device.bcur'),
							data: yAxisData2,
							type: 'line',
							lineStyle: {
								color: '#f0c252'
							},
							areaStyle: {
								opacity: 0,
								color: '#f0c252'
							}
						},
						{
							name: this.$t('homePage.device.ccur'),
							data: yAxisData3,
							type: 'line',
							lineStyle: {
								color: '#0f94da'
							},
							areaStyle: {
								opacity: 0,
								color: '#0f94da'
							}
						}
					]
				}

			},
			initVol(val) {
				const xAxisData = []
				const yAxisData1 = []
				const yAxisData2 = []
				const yAxisData3 = []
				if (val.length > 0) {
					val[0].staticCurveList.forEach(v => {
						xAxisData.push(v.date)
						yAxisData1.push(v.digital)
					})
					val[1].staticCurveList.forEach(v => {
						yAxisData2.push(v.digital)
					})
					val[2].staticCurveList.forEach(v => {
						yAxisData3.push(v.digital)
					})
				}
				let minValue = '0'
				let maxValue = '0'
				const list = yAxisData1.concat(yAxisData2).concat(yAxisData3)
				const precision = 10 // 精度
				maxValue = Math.ceil(Math.max.apply(null, list) * precision) / precision
				minValue = Math.floor(Math.min.apply(null, list) * precision) / precision
				this.vol_option = {
					animationDuration: 500,
					animationEasing: "cubicInOut",
					tooltip: {
						trigger: "axis",
						textStyle: {
							textShadowBlur: 10, // 重点
							textShadowColor: 'transparent', // 重点
						},
						axisPointer: {},
						confine: true,
						position: function(point, params, dom, rect, size) {
							// 鼠标坐标和提示框位置的参考坐标系是：以外层div的左上角那一点为原点，x轴向右，y轴向下
							// 提示框位置
							var x = 0; // x坐标位置
							var y = 0; // y坐标位置

							// 当前鼠标位置
							var pointX = point[0];
							var pointY = point[1];

							// 外层div大小
							// var viewWidth = size.viewSize[0];
							// var viewHeight = size.viewSize[1];

							// 提示框大小
							var boxWidth = size.contentSize[0];
							var boxHeight = size.contentSize[1];

							// boxWidth > pointX 说明鼠标左边放不下提示框
							if (boxWidth > pointX) {
								x = 5; // 自己定个x坐标值，以防出屏
								y -= 15; // 防止点被覆盖住，可根据情况自行调节
							} else {
								// 左边放的下
								x = pointX - boxWidth - 15;
							}

							// boxHeight > pointY 说明鼠标上边放不下提示框
							if (boxHeight + 20 > pointY) {
								y = pointY + 15;
							} else if (boxHeight > pointY) {
								y = 5;
							} else {
								// 上边放得下
								y += pointY - boxHeight;
							}
							return [x, y];
						},
					},
					grid: {
						top: '20%',
						bottom: '10%',
						containLabel: true
					},
					brush: {
						toolbox: ['lineX'],
						xAxisIndex: 'all', // 指定哪些 series 可以被刷选
						throttleType: 'debounce', // 开启选中延迟后调用回调延迟
						throttleDelay: 600, // 选中延迟后调用回调延迟时
						brushStyle: {
							borderWidth: 1,
							color: 'rgba(120,140,180,0.3)',
							borderColor: 'red'
						}
					},
					color: ['#009C77', '#f0c252', '#0f94da'],
					legend: {},
					xAxis: {
						type: 'category',
						boundaryGap: false,
						data: xAxisData,
						axisLabel: {
							show: true,
							color: "#A3A3A3",
							formatter: function(params) {
								let newParamsName = '';
								const paramsNameNumber = params.length; // 文字总长度
								const provideNumber = 11; //一行显示几个字
								const rowNumber = Math.ceil(paramsNameNumber / provideNumber);
								if (paramsNameNumber > provideNumber) {
									for (let p = 0; p < rowNumber; p++) {
										const start = p * provideNumber;
										const end = start + provideNumber;
										const tempStr = p === rowNumber - 1 ? params.substring(start,
											paramsNameNumber) : params.substring(start, end) + '\n';
										newParamsName += tempStr;
									}
								} else {
									newParamsName = params;
								}
								return newParamsName;
							},
						},

						axisLine: {
							lineStyle: {
								color: ['A3A3A3']
							}
						}
					},
					yAxis: {
						type: 'value',
						axisLabel: {
							color: '#A3A3A3'
						},
						name: this.$t('homePage.device.vol') + '(V)',
						nameTextStyle: {
							color: '#A3A3A3',
							padding: [0, 0, 0, 40] // 上右下左与原位置距离
						},
						axisLine: {
							show: false,
							lineStyle: {
								color: ['#A3A3A3']
							}
						},
						max: maxValue
					},
					series: [{
							name: this.$t('homePage.device.avol'),
							data: yAxisData1,
							type: 'line',
							lineStyle: {
								color: '#009C77'
							},
							areaStyle: {
								opacity: 0,
								color: '#009C77'
							}
						},
						{
							name: this.$t('homePage.device.bvol'),
							data: yAxisData2,
							type: 'line',
							lineStyle: {
								color: '#f0c252'
							},
							areaStyle: {
								opacity: 0,
								color: '#f0c252'
							}
						},
						{
							name: this.$t('homePage.device.cvol'),
							data: yAxisData3,
							type: 'line',
							lineStyle: {
								color: '#0f94da'
							},
							areaStyle: {
								opacity: 0,
								color: '#0f94da'
							}
						}
					]
				}

			}
		},
	}
</script>

<style lang="scss" scoped>
	.ammeter-warp {
		height: 100% !important;
		background-color: #f5f5f5;

		.all-con-item-box {
			background: #ffffff;
			border-radius: 16rpx;
			padding: 30rpx;
			width: 710rpx;
			border: 16rpx;
			position: relative;
			margin-top: 30rpx;
			box-shadow: 0px 4rpx 16rpx rgba(0, 0, 0, 0.08);

			.group-box {
				width: 100%;
				display: flex;
				flex-wrap: wrap;
				position: relative;


				.other-value {
					display: flex;
					flex-direction: column;
					width: 100%;

					.top-value {
						display: flex;
						justify-content: space-between;
						position: relative;

						.title {
							font-size: 24rpx;
							color: rgba(40, 40, 40, 1);
						}

						.zhexian-icon {
							position: absolute;
							right: 70%;

							image {
								width: 28rpx;
								height: 28rpx;
							}
						}

						.value {
							font-size: 32rpx;
							color: rgba(0, 156, 119, 1);
							font-weight: 400;
						}
					}

					.bottom-value {
						width: 100%;
						display: flex;
						justify-content: space-between;
						font-size: 24rpx;
						color: rgba(153, 153, 153, 1);
					}
				}
			}



			.group-item {
				display: flex;
				flex-direction: column;
				align-items: center;
				width: 199rpx;

				justify-content: center;
				background: #d7e9e548;
				border-radius: 10rpx;
				margin: 10rpx 10rpx;
				position: relative;
				padding: 10rpx 0;

				.history-icon {
					position: absolute;
					right: 0rpx;
					top: 0rpx;
				}

				image {
					width: 40rpx;
					height: 40rpx;
				}

				.item-con {
					display: flex;
					flex-direction: column;
					align-items: center;
					// margin-left: 15rpx;
					width: 100%;

					.item-title {
						width: 100%;
						font-size: 24rpx;
						color: #2a2a2a;
						margin-top: 10rpx;
						text-align: center;
						white-space: nowrap;
						overflow: hidden; //文本超出隐藏
						text-overflow: ellipsis; //文本超出省略号替
					}

					.item-num {
						font-size: 36rpx;
						color: #282828;
						font-weight: bold;
						max-width: 90%;
						text-align: center;

					}

					.item-unit {
						color: #cccccc;
						font-size: 16rpx;
						padding-left: 10rpx;
					}
				}
			}
		}

		.time-box {
			display: flex;
			justify-content: space-around;
			align-items: center;
			font-size: 28rpx;
			margin-top: 20rpx;
			// border: 1px solid #a3a3a3;
			background-color: #f5f5f5;
			border-radius: 8rpx;
			padding: 10rpx;


			.time {

				font-size: 28rpx;
				white-space: nowrap;
			}
		}

		.chart-box {
			width: 650rpx;
			height: 500rpx;
			margin-top: 20rpx;
			position: relative;
		}

		.slot-content {
			padding: 20rpx;
		}


		.border-bottom {
			border-bottom: 4rpx dotted #e5e5e5;
		}

		.border-right {
			border-right: 4rpx dotted #e5e5e5;
		}

		.padding-top-30 {
			padding-top: 30rpx;
		}

		.padding-bottom-30 {
			padding-bottom: 30rpx;
		}

	}
</style>