<template>
	<div>
		<el-breadcrumb separator-class="el-icon-arrow-right">
			<el-breadcrumb-item>环境监测系统</el-breadcrumb-item>
			<el-breadcrumb-item :to="{ path: '/index/envi' }">环境监测</el-breadcrumb-item>
			<el-breadcrumb-item>24小时数据</el-breadcrumb-item>
		</el-breadcrumb>
		<el-card class="box-card">
			<el-table :data="data24" stripe style="width: 100%">
				<el-table-column prop="e" label="传感器通道"></el-table-column>
				<el-table-column prop="name" label="通道名称"></el-table-column>
				<el-table-column prop="min" label="最小值"></el-table-column>
				<el-table-column prop="mintime" label="最小时间">
					<template v-if="scope.row.mintime" slot-scope="scope">{{scope.row.mintime*1000 | formatTime}}</template>
				</el-table-column>
				<el-table-column prop="max" label="最大值"></el-table-column>
				<el-table-column prop="maxtime" label="最大时间">
               <template v-if="scope.row.maxtime" slot-scope="scope">{{scope.row.maxtime*1000 | formatTime}}</template>
            </el-table-column>
			</el-table>
			<el-pagination background layout="prev, pager, next" :total="0"></el-pagination>
		</el-card>
	</div>
</template>

<script>
export default {
	data() {
		return {
			//24小时数据
			data24: [],
			id: this.$route.params.id
		}
	},
	mounted() {
		this.get24List(this.id)
	},
	methods: {
		// 24小时数据
		get24List(id) {
			this.$axios({
				method: 'POST',
				url: '/api/api_gateway?method=weather.weather.qxz_day_data',
				data: this.qs.stringify({ device_id: id })
			}).then((res) => {
				let arr = new Array()
				let conf = res.data.data.conf
				let data = res.data.data.data
				if (conf && data && data.length > 0) {
					for (let i = 1; i < 31; i++) {
						for (let i1 in conf) {
							if (i == i1.slice(1)) {
								let obj = {}
								if (conf[i1]) {
									obj.e = i1
									let arr1 = conf[i1].split('#')
									obj.name = `${arr1[0]}(${arr1[1]})`
									if (data) {
										for (let item of data) {
											if (item.ekey == i1) {
												obj.min = item.min
												obj.mintime = item.mintime
												obj.max = item.max
												obj.maxtime = item.maxtime
											}
										}
										arr.push({
											e: obj.e,
											name: obj.name,
											min: obj.min,
											mintime:obj.mintime,
											max: obj.max,
											maxtime:obj.maxtime
										})
									}
								}
							}
						}
					}
					this.data24 = arr
				} else {
					this.data24 = []
				}
			})
		}
	}
}
</script>

<style lang='less' scoped>
</style>