<template>
	<!-- 历史数据 -->
	<el-dialog width="60%" :title="'控制记录'" :visible.sync="historyLoading" append-to-body :close-on-click-modal="false">
		<el-table :data="zlData" size="small" style="width: 100%">
			<el-table-column prop="deviceid" label="设备ID " fixed min-width="130%" />
			<el-table-column prop="deviceName" label="设备名称" fixed />
			<el-table-column prop="item" label="检测项">
				<template slot-scope="scope">
					<div v-for="item in items" :key="item.code">
						<div v-if="scope.row.item === item.code">{{ item.subject }}</div>
					</div>
				</template>
			</el-table-column>
			<el-table-column prop="name" label="控制名称" />
			<el-table-column prop="msg" label="通知消息" />
			<el-table-column prop="warntype" label="控制类型">
				<template slot-scope="scope">
					<div v-for="item in dictMap.warntype" :key="item.id">
						<div v-if="scope.row.warntype === item.value">{{ item.label }}</div>
					</div>
				</template>
			</el-table-column>
			<el-table-column prop="min" label="下限" />
			<el-table-column prop="max" label="上限" />
			<el-table-column prop="operation" label="操作" />
			<el-table-column prop="creationTime" label="操作时间" min-width="130%" />
		</el-table>
		<!--分页组件-->
		<el-pagination :total="total" :current-page="page + 1" style="margin-top: 8px" layout="total, prev, pager, next, sizes" @size-change="sizeChange" @current-change="pageChange" />
	</el-dialog>
</template>
<script>
import { queryAllByUseridNoPage } from '@/api/sDevice'
import initDict from '@/mixins/initDict'
import { reqApi } from '@/api/sfyt.js'
import { selectAll } from '@/api/sItem'
export default {
	mixins: [initDict],
	name: 'history',

	data() {
		return {
			items: '',
			page: 1,
			size: 10,
			total: 0,
			historyLoading: false,
			valueseldata: this.valueseldata1,
			zlData: [],
		}
	},
	created() {
		this.$nextTick(() => {
			// this.init()
			this.getDictMap('isnot,radiostatus,warntype')
			this.loadAlleviceByUser()
			this.selectAllForm()
		})
	},
	mounted() {
		this.$nextTick(() => {
			this.ctrl()
		})
	},
	methods: {
		selectAllForm() {
			selectAll().then(response => {
				this.items = response
			})
		},
		loadAlleviceByUser() {
			queryAllByUseridNoPage().then(response => {
				this.devices = response
			})
		},
		parentHandleclick() {
			this.historyLoading = true
		},
		ctrl() {
			let param = {}
			param.page = this.page
			param.size = this.size
			reqApi.aiopRecord(param).then(res => {
				console.log(res, 'aiopRecord')
				this.zlData = res.Data
				this.total = res.total
			})
		},
		pageChange(e) {
			console.log(e)
			this.page = e
			this.ctrl()
		},
		sizeChange(e) {
			this.page = 1
			this.size = e
			this.ctrl()
		},
	},
}
</script>
