<template> <app-container> <search-area :need-clear="true" :need-search-more="false" type="seperate" size="small" search-more-type="default" @search="fetchData" @clear="clearInput"> <!--一般查询条件--> <search-item> <el-input v-model.trim="listQuery.keyword" size="small" placeholder="灯箱编号/灯箱名称" clearable/> </search-item> <search-item> <el-select v-model="listQuery.groupId" size="small" placeholder="设备组" clearable> <el-option v-for="item in groupList" :key="item.id" :label="item.groupName" :value="item.id"/> </el-select> </search-item> </search-area> <normal-table :data="list" :head="tableOption.head" :query="listQuery" :total="total" :list-loading="listLoading" :options="tableOption.options" :tools-option="tableOption.toolsOption" size="small" @change="changePage"> <template slot="columns"> <el-table-column v-for="column in columns" :key="column.value" :label="column.text" :width="column.width" :align="column.align" show-overflow-tooltip> <template slot-scope="scope"> <div v-if="column.value === 'A'"> <span v-html="allNum(scope.row.electricityA,scope.row.voltageA,scope.row.powerA)"/> </div> <div v-else-if="column.value === 'B'"> <span v-html="allNum(scope.row.electricityB,scope.row.voltageA,scope.row.powerB)"/> </div> <div v-else-if="column.value === 'C'"> <span v-html="allNum(scope.row.electricityC,scope.row.voltageA,scope.row.powerC)"/> </div> <div v-else> <span>{{ scope.row[column.value] }}</span> </div> </template> </el-table-column> <el-table-column label="操作" align="center" width="130"> <template slot-scope="scope"> <el-button type="text" size="small" @click="showHistory(scope.row)">查看历史</el-button> </template> </el-table-column> </template> </normal-table> <!--查询结果Table显示--> <div> <el-row class="table-title"> <el-col :span="6"><div class="title-header"><i class="el-icon-menu"/>数据列表</div></el-col> </el-row> <el-table v-loading="listLoading" :data="list" class="table" border> <el-table-column :index="indexMethod" label="序号" width="55" align="center" type="index" /> <el-table-column v-for="column in columns" :key="column.value" :label="column.text" :width="column.width" :align="column.align" show-overflow-tooltip> <template slot-scope="scope"> <div v-if="column.value === 'A'"> <span v-html="allNum(scope.row.electricityA,scope.row.voltageA,scope.row.powerA)"/> </div> <div v-else-if="column.value === 'B'"> <span v-html="allNum(scope.row.electricityB,scope.row.voltageA,scope.row.powerB)"/> </div> <div v-else-if="column.value === 'C'"> <span v-html="allNum(scope.row.electricityC,scope.row.voltageA,scope.row.powerC)"/> </div> <div v-else> <span>{{ scope.row[column.value] }}</span> </div> </template> </el-table-column> </el-table> </div> <box-history v-show="dialogFormVisible" ref="boxhistory"/> </app-container> </template> <script> import { getGroupList, getBoxLatest } from '@/api/system/report' import BoxHistory from './boxHistory' export default { name: 'BoxData', components: { BoxHistory }, data() { return { listQuery: { keyword: '', groupId: '', offset: 1, limit: 20, sort: '', order: '' }, // 筛选条件 columns: [ { text: '灯箱编号', value: 'lampboxCode', align: 'center' }, { text: '灯箱名称', value: 'lampboxName', align: 'center' }, { text: 'A相', value: 'A', align: 'center', width: 200 }, { text: 'B相', value: 'B', align: 'center', width: 200 }, { text: 'C相', value: 'C', align: 'center', width: 200 } ], groupList: [], total: 0, // 数据总数 list: [], // 报警列表 listLoading: true, // 列表加载 dialogFormVisible: false, alarmReasonList: [], // 报警原因列表 timeRange: [], // 时间范围 tableOption: { head: { show: true, // 是否需要标题栏, text: '数据列表' // 标题名称 }, options: { needIndex: true, // 是否需要序号列 needMultSelect: false }, toolsOption: { selectColumns: false, // 是否需要筛选列 refresh: false // 是否需要刷新按钮 } } // 表格属性 } }, created() { this.fetchGroupList() // 获取人员标签列表 this.fetchData()// 获取数据 }, activated() { this.fetchData() }, methods: { allNum(num1, num2, num3) { return num1 + 'A/' + num2 + 'V/' + num3 + 'W' }, fetchData(isNowPage = true) { this.listLoading = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 this.listQuery.offset = 1 } console.log(this.listQuery) getBoxLatest(this.listQuery).then(response => { if (response.code === 200) { this.list = response.data.rows this.total = parseInt(response.data.total) } else { this.$message.error(response.message) } this.listLoading = false }) }, // 查询数据 search() { this.fetchData(false) }, showHistory(row) { this.dialogFormVisible = true this.$refs.boxhistory.initDialog(this.dialogFormVisible, row) }, clearInput() { this.listQuery = { keyword: '', groupId: '', offset: 1, limit: 20, sort: '', order: '' } this.timeRange = [] this.fetchData(false) }, // 获取类型列表 fetchGroupList() { getGroupList('3').then(response => { this.groupList = response.data }) }, changePage(val) { if (val && val.size) { this.listQuery.limit = val.size } if (val && val.page) { this.listQuery.offset = val.page } this.fetchData() } } } </script> <style rel="stylesheet/scss" lang="scss" scoped> $tableTitleHeight:46px; .app-container{ margin-bottom:20px } .table{ margin-bottom: 20px; } .small-row-class{ height: 15px; } .pagination-container{ margin-bottom: 50px; } .table-title{ background-color:rgba(243, 243, 243, 1); height: $tableTitleHeight; .title-header{ line-height:$tableTitleHeight; color: #606266; font-size: 15px; i{ margin-left: 5px; margin-right: 5px; } } } .edit_btns{ .edit_btn{ float:right; margin:7px 3px;//为了需要居中显示margin-top和bottom要用$tableTitleHeight减去按钮原高度除以2 } } </style> <style rel="stylesheet/scss" lang="scss"> .small-row-class td{ padding:2px 0px; } </style>