<template>
|
<TableLayout :permissions="['business:ywconditionergateway:query']">
|
<el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline>
|
<el-form-item label="网关MAC" prop="wgMac">
|
<el-input v-model="searchForm.wgMac" placeholder="MAC地址" clearable @keypress.enter.native="search" />
|
</el-form-item>
|
<el-form-item label="在线状态" prop="onlineStatus">
|
<el-select v-model="searchForm.onlineStatus" clearable placeholder="全部" style="min-width: 120px">
|
<el-option label="在线" value="在线" />
|
<el-option label="离线" value="离线" />
|
</el-select>
|
</el-form-item>
|
<el-form-item label="关键字" prop="keyword">
|
<el-input v-model="searchForm.keyword" placeholder="MAC/备注" clearable @keypress.enter.native="search" />
|
</el-form-item>
|
<section>
|
<el-button type="primary" icon="el-icon-search" @click="search">查询</el-button>
|
<el-button icon="el-icon-refresh" @click="reset">重置</el-button>
|
</section>
|
</el-form>
|
<template v-slot:table-wrap>
|
<ul class="toolbar">
|
<li>
|
<el-button
|
type="primary"
|
:loading="isSyncing"
|
v-permissions="['business:ywconditionergateway:sync']"
|
@click="handleSync"
|
>同步网关</el-button>
|
</li>
|
</ul>
|
<el-table v-loading="isWorking.search" :data="tableData.list" stripe>
|
<el-table-column prop="wgMac" label="网关MAC" min-width="150" align="center" show-overflow-tooltip />
|
<el-table-column prop="wgBz" label="备注" min-width="140" align="center" show-overflow-tooltip>
|
<template slot-scope="{ row }">{{ row.wgBz || '-' }}</template>
|
</el-table-column>
|
<el-table-column label="在线状态" min-width="100" align="center">
|
<template slot-scope="{ row }">
|
<span :class="row.onlineStatus === '在线' ? 'green' : 'red'">{{ row.onlineStatus || '-' }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="lastSyncDate" label="最后同步" min-width="160" align="center" />
|
<el-table-column label="操作" min-width="120" align="center" fixed="right">
|
<template slot-scope="{ row }">
|
<el-button type="text" @click="openLog(row)">上线/离线记录</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<pagination
|
@size-change="handleSizeChange"
|
@current-change="handlePageChange"
|
:pagination="tableData.pagination"
|
/>
|
</template>
|
<YwConditionerGatewayLogWindow ref="logWindow" />
|
</TableLayout>
|
</template>
|
|
<script>
|
import BaseTable from '@/components/base/BaseTable'
|
import TableLayout from '@/layouts/TableLayout'
|
import Pagination from '@/components/common/Pagination'
|
import * as gatewayApi from '@/api/business/ywconditionergateway'
|
import YwConditionerGatewayLogWindow from './components/YwConditionerGatewayLogWindow'
|
|
export default {
|
name: 'YwConditionerGateway',
|
extends: BaseTable,
|
components: { TableLayout, Pagination, YwConditionerGatewayLogWindow },
|
data () {
|
return {
|
searchForm: {
|
wgMac: '',
|
onlineStatus: '',
|
keyword: ''
|
},
|
isSyncing: false
|
}
|
},
|
created () {
|
this.api = gatewayApi
|
this.module = '空调网关'
|
this.configData['field.id'] = 'id'
|
this.configData['field.main'] = 'wgMac'
|
this.search()
|
},
|
methods: {
|
buildSearchModel () {
|
const model = {}
|
if (this.searchForm.wgMac) model.wgMac = this.searchForm.wgMac
|
if (this.searchForm.onlineStatus) model.onlineStatus = this.searchForm.onlineStatus
|
if (this.searchForm.keyword) model.keyword = this.searchForm.keyword
|
return model
|
},
|
handlePageChange (pageIndex) {
|
this.tableData.pagination.pageIndex = pageIndex || this.tableData.pagination.pageIndex
|
this.isWorking.search = true
|
gatewayApi.fetchList({
|
page: this.tableData.pagination.pageIndex,
|
capacity: this.tableData.pagination.pageSize,
|
model: this.buildSearchModel(),
|
sorts: this.tableData.sorts
|
})
|
.then(data => {
|
this.tableData.list = data.records || []
|
this.tableData.pagination.total = data.total || 0
|
})
|
.catch(() => {})
|
.finally(() => { this.isWorking.search = false })
|
},
|
reset () {
|
this.searchForm = { wgMac: '', onlineStatus: '', keyword: '' }
|
this.search()
|
},
|
handleSync () {
|
this.$dialog.actionConfirm('确认从智精灵平台同步全部网关吗?', '同步网关')
|
.then(() => {
|
this.isSyncing = true
|
gatewayApi.syncAll()
|
.then(res => {
|
this.$tip.apiSuccess(res || '同步成功')
|
this.search()
|
})
|
.catch(e => this.$tip.apiFailed(e))
|
.finally(() => { this.isSyncing = false })
|
})
|
.catch(() => {})
|
},
|
openLog (row) {
|
this.$refs.logWindow.open(row)
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
.green { color: #67c23a; }
|
.red { color: #f56c6c; }
|
</style>
|