<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.devcode" size="small" placeholder="设备编号" clearable/> </search-item> <search-item> <el-select v-model="listQuery.status" size="small" placeholder="下发状态" filterable clearable> <el-option v-for="item in statusList" :key="item.name" :label="item.name" :value="item.name"/> </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" @selectionChange="handleSelectionChange" @change="changePage"> <template slot="btns"> <el-button class="edit_btn" size="small" @click="sendAll">全部设备下发</el-button> <el-button class="edit_btn" size="small" @click="send">设备下发</el-button> </template> <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 === 'channel1'"> <span v-html="allNum(scope.row.elecMinAlarm1,scope.row.elecMaxAlarm1,scope.row.voltMinAlarm1,scope.row.voltMaxAlarm1,scope.row.channelOpenTime1,scope.row.channelCloseTime1)"/> </div> <div v-else-if="column.value === 'channel2'"> <span v-html="allNum(scope.row.elecMinAlarm2,scope.row.elecMaxAlarm2,scope.row.voltMinAlarm2,scope.row.voltMaxAlarm2,scope.row.channelOpenTime2,scope.row.channelCloseTime2)"/> </div> <div v-else-if="column.value === 'channel3'"> <span v-html="allNum(scope.row.elecMinAlarm3,scope.row.elecMaxAlarm3,scope.row.voltMinAlarm3,scope.row.voltMaxAlarm3,scope.row.channelOpenTime3,scope.row.channelCloseTime3)"/> </div> <div v-else-if="column.value === 'channel4'"> <span v-html="allNum(scope.row.elecMinAlarm4,scope.row.elecMaxAlarm4,scope.row.voltMinAlarm4,scope.row.voltMaxAlarm4,scope.row.channelOpenTime4,scope.row.channelCloseTime4)"/> </div> <div v-else> <span>{{ scope.row[column.value] }}</span> </div> </template> </el-table-column> </template> </normal-table> </app-container> </template> <script> import { deviceConfigLog, toDevice, toDeviceAll } from '@/api/system/base' export default { name: 'ListLog', data() { return { listQuery: { devcode: '', // 设备编号/设备名称 status: '', offset: 1, limit: 20, sort: 'devcode', order: 'asc' }, // 筛选条件 columns: [ { text: '设备编号', value: 'devcode', align: 'center', width: 150 }, { text: '电信设备编号', value: 'teleDeviceId', align: 'center' }, { text: '采集开始时间', value: 'collectStartTime', align: 'center', width: 150 }, { text: '采集间隔', value: 'collectCycle', align: 'center', width: 80 }, { text: '采集次数', value: 'collectCnt', align: 'center', width: 80 }, { text: '通道1', value: 'channel1', align: 'center' }, { text: '通道2', value: 'channel2', align: 'center' }, { text: '通道3', value: 'channel3', align: 'center' }, { text: '通道4', value: 'channel4', align: 'center' }, { text: '下发时间', value: 'ts', align: 'center', width: 150 }, { text: '下发状态', value: 'status', align: 'center', width: 90 } ], total: 0, // 数据总数 list: [], // 报警列表 listLoading: true, // 列表加载 multipleSelection: [], // 多选选中项 dialogFormVisible: false, alarmStatusList: [{ name: '正在报警', value: '1' }, { name: '已取消', value: '2' }], // 报警状态列表 statusList: [{ name: '未下发' }, { name: '已下发' }], alarmTypeList: [], timeRange: [], // 时间范围 tableOption: { head: { show: true, // 是否需要标题栏, text: '数据列表' // 标题名称 }, options: { needIndex: true, // 是否需要序号列 needMultSelect: true }, toolsOption: { selectColumns: false, // 是否需要筛选列 refresh: false // 是否需要刷新按钮 } } // 表格属性 } }, created() { this.fetchData()// 获取数据 }, activated() { this.fetchData() }, methods: { allNum(num1, num2, num3, num4, num5, num6) { var str = num1 if (num1.length !== 0) str += ('A/' + num2) else str += ('/' + num2) if (num2.length !== 0) str += ('A/' + num3) else str += ('/' + num3) if (num3.length !== 0) str += ('V/' + num4) else str += ('/' + num4) if (num4.length !== 0) str += ('V/' + num5 + '/' + num6) else str += ('/' + num5 + '/' + num6) return str // return num1 + 'A/' + num2 + 'A/' + num3 + 'V/' + num4 + 'V/' + num5 + '/' + num6 }, fetchData(isNowPage = true) { this.listLoading = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 this.listQuery.offset = 1 } deviceConfigLog(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) }, // 设备下发 send() { if (this.checkSelection()) { const devIds = [] this.multipleSelection.forEach(function(value, index) { devIds.push(value.devcode) }) this.$confirm( '确定要下发参数到所选设备吗?', '确认操作', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' } ).then(() => { toDevice(devIds).then(response => { if (response.code === 200) { this.$message.success('信息发送成功') this.fetchData() } }) }) } else { this.$message.error('至少选中一项') } }, // 设备下发 sendAll() { this.$confirm( '确定要下发参数到全部设备吗?', '确认操作', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' } ).then(() => { toDeviceAll(this.listQuery).then(response => { if (response.code === 200) { this.$message.success('信息发送成功') this.fetchData() } }) }) }, showDetail(row) { this.dialogFormVisible = true this.$refs.alarmdetail.initDialog(this.dialogFormVisible, row) }, clearInput() { this.listQuery = { name: '', // 姓名 sex: '', // 性别 nation: '', // 民族 collReason: '', // 采集原因 cardType: '', // 证件类型 idCardNo: '', // 证件号码 alarmReason: '', // 报警原因 startTime: '', // 开始时间 endTime: '', // 结束时间 offset: 1, limit: 20, sort: '', order: '' } this.timeRange = [] this.fetchData(false) }, changePage(val) { if (val && val.size) { this.listQuery.limit = val.size } if (val && val.page) { this.listQuery.offset = val.page } this.fetchData() }, // 多选触发方法 handleSelectionChange(val) { this.multipleSelection = val }, // 检查选择情况 checkSelection() { if (this.multipleSelection.length === 0) { return false } else { return true } } } } </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>