Commit 385f3cd6 by 14796

设备信息前端代码

parent 07042656
import request from '@/utils/request'
// 查询设备信息列表
export function listDevice(query) {
return request({
url: '/system/device/list',
method: 'get',
params: query
})
}
// 查询设备信息详细
export function getDevice(id) {
return request({
url: '/system/device/' + id,
method: 'get'
})
}
// 新增设备信息
export function addDevice(data) {
return request({
url: '/system/device',
method: 'post',
data: data
})
}
// 修改设备信息
export function updateDevice(data) {
return request({
url: '/system/device',
method: 'put',
data: data
})
}
// 删除设备信息
export function delDevice(id) {
return request({
url: '/system/device/' + id,
method: 'delete'
})
}
import request from '@/utils/request'
// 查询设备网关信息列表
export function listGateway(query) {
return request({
url: '/system/gateway/list',
method: 'get',
params: query
})
}
// 查询设备网关信息详细
export function getGateway(id) {
return request({
url: '/system/gateway/' + id,
method: 'get'
})
}
// 新增设备网关信息
export function addGateway(data) {
return request({
url: '/system/gateway',
method: 'post',
data: data
})
}
// 修改设备网关信息
export function updateGateway(data) {
return request({
url: '/system/gateway',
method: 'put',
data: data
})
}
// 删除设备网关信息
export function delGateway(id) {
return request({
url: '/system/gateway/' + id,
method: 'delete'
})
}
import request from '@/utils/request'
// 查询设备操作日志列表
export function listLog(query) {
return request({
url: '/system/log/list',
method: 'get',
params: query
})
}
// 查询设备操作日志详细
export function getLog(id) {
return request({
url: '/system/log/' + id,
method: 'get'
})
}
// 新增设备操作日志
export function addLog(data) {
return request({
url: '/system/log',
method: 'post',
data: data
})
}
// 修改设备操作日志
export function updateLog(data) {
return request({
url: '/system/log',
method: 'put',
data: data
})
}
// 删除设备操作日志
export function delLog(id) {
return request({
url: '/system/log/' + id,
method: 'delete'
})
}
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
<el-form-item label="设备名称" prop="devName">
<el-input
v-model="queryParams.devName"
placeholder="请输入设备名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="设备MAC" prop="devMac">
<el-input
v-model="queryParams.devMac"
placeholder="请输入设备MAC"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="设备ID" prop="devId">
<el-input
v-model="queryParams.devId"
placeholder="请输入设备ID"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<!-- <el-form-item label="设备密码" prop="devPsw">-->
<!-- <el-input-->
<!-- v-model="queryParams.devPsw"-->
<!-- placeholder="请输入设备密码"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="设备版本号" prop="devVer">-->
<!-- <el-input-->
<!-- v-model="queryParams.devVer"-->
<!-- placeholder="请输入设备版本号"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<el-form-item label="项目ID" prop="projtId">
<el-input
v-model="queryParams.projtId"
placeholder="请输入项目ID"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<!-- <el-form-item label="项目密码" prop="projtPsw">-->
<!-- <el-input-->
<!-- v-model="queryParams.projtPsw"-->
<!-- placeholder="请输入项目密码"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="分组" prop="group">-->
<!-- <el-input-->
<!-- v-model="queryParams.group"-->
<!-- placeholder="请输入分组"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="设备位置" prop="devPosition">-->
<!-- <el-input-->
<!-- v-model="queryParams.devPosition"-->
<!-- placeholder="请输入设备位置"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="设备网关dev_id" prop="gatewayId">-->
<!-- <el-input-->
<!-- v-model="queryParams.gatewayId"-->
<!-- placeholder="请输入设备网关dev_id"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="电量、电压" prop="voltage">-->
<!-- <el-input-->
<!-- v-model="queryParams.voltage"-->
<!-- placeholder="请输入电量、电压"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="信号值" prop="signalValue">-->
<!-- <el-input-->
<!-- v-model="queryParams.signalValue"-->
<!-- placeholder="请输入信号值"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:device:add']"
>新增
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:device:edit']"
>修改
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:device:remove']"
>删除
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['system:device:export']"
>导出
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="deviceList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="70" align="center"/>
<!-- <el-table-column label="${comment}" align="center" prop="id" />-->
<el-table-column label="设备名称" align="center" prop="devName"/>
<el-table-column label="设备MAC" align="center" prop="devMac"/>
<el-table-column label="设备ID" align="center" prop="devId"/>
<el-table-column label="设备密码" align="center" prop="devPsw"/>
<el-table-column label="设备版本号" align="center" prop="devVer"/>
<el-table-column label="设备类型 " align="center" prop="devType">
<template slot-scope="scope">
<dict-tag :options="dict.type.device_type" :value="scope.row.devType"/>
</template>
</el-table-column>
<el-table-column label="项目ID" align="center" prop="projtId"/>
<el-table-column label="项目密码" align="center" prop="projtPsw"/>
<el-table-column label="分组" align="center" prop="group"/>
<el-table-column label="设备状态" align="center" prop="status">
<template slot-scope="scope">
<dict-tag :options="dict.type.device_status" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark"/>
<el-table-column label="设备位置" align="center" prop="devPosition"/>
<el-table-column label="设备网关dev_id" align="center" prop="gatewayId"/>
<el-table-column label="电量、电压" align="center" prop="voltage"/>
<el-table-column label="信号值" align="center" prop="signalValue"/>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:device:edit']"
>修改
</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:device:remove']"
>删除
</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改设备信息对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="设备名称" prop="devName">
<el-input v-model="form.devName" placeholder="请输入设备名称"/>
</el-form-item>
<el-form-item label="设备MAC" prop="devMac">
<el-input v-model="form.devMac" placeholder="请输入设备MAC"/>
</el-form-item>
<el-form-item label="设备ID" prop="devId">
<el-input v-model="form.devId" placeholder="请输入设备ID"/>
</el-form-item>
<el-form-item label="设备密码" prop="devPsw">
<el-input v-model="form.devPsw" placeholder="请输入设备密码"/>
</el-form-item>
<el-form-item label="设备版本号" prop="devVer">
<el-select v-model="form.devVer" placeholder="请选择设备版本号">
<el-option
v-for="dict in dict.type.device_ver_type"
:key="dict.value"
:label="dict.label"
:value="parseInt(dict.value)"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="设备类型" prop="devType">
<el-select v-model="form.devType" placeholder="请选择设备类型">
<el-option
v-for="dict in dict.type.device_type"
:key="dict.value"
:label="dict.label"
:value="parseInt(dict.value)"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="项目ID" prop="projtId">
<el-input v-model="form.projtId" placeholder="请输入项目ID"/>
</el-form-item>
<el-form-item label="项目密码" prop="projtPsw">
<el-input v-model="form.projtPsw" placeholder="请输入项目密码"/>
</el-form-item>
<!-- <el-form-item label="分组" prop="group">-->
<!-- <el-input v-model="form.group" placeholder="请输入分组"/>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="备注" prop="remark">-->
<!-- <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>-->
<!-- </el-form-item>-->
<el-form-item label="设备位置" prop="devPosition">
<el-input v-model="form.devPosition" placeholder="请输入设备位置"/>
</el-form-item>
<el-form-item label="设备网关id" prop="gatewayId">
<el-input v-model="form.gatewayId" placeholder="请输入设备网关id"/>
</el-form-item>
<!-- <el-form-item label="电量、电压" prop="voltage">-->
<!-- <el-input v-model="form.voltage" placeholder="请输入电量、电压" />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="信号值" prop="signalValue">-->
<!-- <el-input v-model="form.signalValue" placeholder="请输入信号值" />-->
<!-- </el-form-item>-->
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {listDevice, getDevice, delDevice, addDevice, updateDevice} from "@/api/system/device";
export default {
name: "Device",
dicts: ['device_ver_type', 'device_type','device_status'],
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 设备信息表格数据
deviceList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
devName: null,
devMac: null,
devId: null,
devPsw: null,
devVer: null,
devType: null,
projtId: null,
projtPsw: null,
group: null,
status: null,
devPosition: null,
gatewayId: null,
voltage: null,
signalValue: null
},
// 表单参数
form: {},
// 表单校验
rules: {
devMac: [
{required: true, message: "设备MAC不能为空", trigger: "blur"}
],
// devId: [
// { required: true, message: "设备ID不能为空", trigger: "blur" }
// ],
devName: [
{required: true, message: "设备名称不能为空", trigger: "blur"}
]
}
};
},
created() {
this.getList();
},
methods: {
/** 查询设备信息列表 */
getList() {
this.loading = true;
listDevice(this.queryParams).then(response => {
this.deviceList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
devName: null,
devMac: null,
devId: null,
devPsw: null,
devVer: null,
devType: null,
projtId: null,
projtPsw: null,
group: null,
status: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
remark: null,
devPosition: null,
gatewayId: null,
voltage: null,
signalValue: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加设备信息";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getDevice(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改设备信息";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateDevice(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addDevice(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除设备信息编号为"' + ids + '"的数据项?').then(function () {
return delDevice(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
});
},
/** 导出按钮操作 */
handleExport() {
this.download('system/device/export', {
...this.queryParams
}, `device_${new Date().getTime()}.xlsx`)
}
}
};
</script>
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
<el-form-item label="设备名称" prop="devName">
<el-input
v-model="queryParams.devName"
placeholder="请输入设备名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="设备MAC" prop="devMac">
<el-input
v-model="queryParams.devMac"
placeholder="请输入设备MAC"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<!-- <el-form-item label="设备ID" prop="devId">-->
<!-- <el-input-->
<!-- v-model="queryParams.devId"-->
<!-- placeholder="请输入设备ID"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="设备密码" prop="devPsw">-->
<!-- <el-input-->
<!-- v-model="queryParams.devPsw"-->
<!-- placeholder="请输入设备密码"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="设备版本号" prop="devVer">-->
<!-- <el-input-->
<!-- v-model="queryParams.devVer"-->
<!-- placeholder="请输入设备版本号"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="网络分组" prop="group">-->
<!-- <el-input-->
<!-- v-model="queryParams.group"-->
<!-- placeholder="请输入网络分组"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="mqtt服务器IP/域名" prop="mqttIp">-->
<!-- <el-input-->
<!-- v-model="queryParams.mqttIp"-->
<!-- placeholder="请输入mqtt服务器IP/域名"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="mqtt服务器端口" prop="mqttPort">-->
<!-- <el-input-->
<!-- v-model="queryParams.mqttPort"-->
<!-- placeholder="请输入mqtt服务器端口"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="mqtt用户名" prop="mqttUser">-->
<!-- <el-input-->
<!-- v-model="queryParams.mqttUser"-->
<!-- placeholder="请输入mqtt用户名"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="mqtt用户密码" prop="mqttPaswd">-->
<!-- <el-input-->
<!-- v-model="queryParams.mqttPaswd"-->
<!-- placeholder="请输入mqtt用户密码"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="设备位置" prop="devPosition">-->
<!-- <el-input-->
<!-- v-model="queryParams.devPosition"-->
<!-- placeholder="请输入设备位置"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:gateway:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:gateway:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:gateway:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['system:gateway:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="gatewayList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<!-- <el-table-column label="${comment}" align="center" prop="id" />-->
<el-table-column label="设备名称" align="center" prop="devName" />
<el-table-column label="设备 MAC" align="center" prop="devMac" />
<el-table-column label="设备ID" align="center" prop="devId" />
<el-table-column label="设备密码" align="center" prop="devPsw" />
<el-form-item label="设备版本号" prop="devVer">
<el-select v-model="form.devVer" placeholder="请选择设备版本号">
<el-option
v-for="dict in dict.type.device_ver_type"
:key="dict.value"
:label="dict.label"
:value="parseInt(dict.value)"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="设备类型" prop="devType">
<el-select v-model="form.devType" placeholder="请选择设备类型">
<el-option
v-for="dict in dict.type.device_type"
:key="dict.value"
:label="dict.label"
:value="parseInt(dict.value)"
></el-option>
</el-select>
</el-form-item>
<el-table-column label="网络分组" align="center" prop="group" />
<el-table-column label="设备状态" align="center" prop="status" />
<el-table-column label="mqtt服务器IP/域名" align="center" prop="mqttIp" />
<el-table-column label="mqtt服务器端口" align="center" prop="mqttPort" />
<el-table-column label="mqtt用户名" align="center" prop="mqttUser" />
<el-table-column label="mqtt用户密码" align="center" prop="mqttPaswd" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="设备位置" align="center" prop="devPosition" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:gateway:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:gateway:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改设备网关信息对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="130px">
<el-form-item label="设备名称" prop="devName">
<el-input v-model="form.devName" placeholder="请输入设备名称" />
</el-form-item>
<el-form-item label="设备 MAC" prop="devMac">
<el-input v-model="form.devMac" placeholder="请输入设备 MAC" />
</el-form-item>
<el-form-item label="设备ID" prop="devId">
<el-input v-model="form.devId" placeholder="请输入设备ID" />
</el-form-item>
<el-form-item label="设备密码" prop="devPsw">
<el-input v-model="form.devPsw" placeholder="请输入设备密码" />
</el-form-item>
<el-form-item label="设备版本号" prop="devVer">
<el-select v-model="form.devVer" placeholder="请选择设备版本号">
<el-option
v-for="dict in dict.type.device_ver_type"
:key="dict.value"
:label="dict.label"
:value="parseInt(dict.value)"
></el-option>
</el-select>
</el-form-item>
<!-- <el-form-item label="网络分组" prop="group">-->
<!-- <el-input v-model="form.group" placeholder="请输入网络分组" />-->
<!-- </el-form-item>-->
<el-form-item label="mqtt服务器IP/域名" prop="mqttIp">
<el-input v-model="form.mqttIp" placeholder="请输入mqtt服务器IP/域名" />
</el-form-item>
<el-form-item label="mqtt服务器端口" prop="mqttPort">
<el-input v-model="form.mqttPort" placeholder="请输入mqtt服务器端口" />
</el-form-item>
<el-form-item label="mqtt用户名" prop="mqttUser">
<el-input v-model="form.mqttUser" placeholder="请输入mqtt用户名" />
</el-form-item>
<el-form-item label="mqtt用户密码" prop="mqttPaswd">
<el-input v-model="form.mqttPaswd" placeholder="请输入mqtt用户密码" />
</el-form-item>
<!-- <el-form-item label="备注" prop="remark">-->
<!-- <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />-->
<!-- </el-form-item>-->
<el-form-item label="设备位置" prop="devPosition">
<el-input v-model="form.devPosition" placeholder="请输入设备位置" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listGateway, getGateway, delGateway, addGateway, updateGateway } from "@/api/system/gateway";
export default {
name: "Gateway",
dicts: ['device_ver_type', 'device_type','device_status'],
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 设备网关信息表格数据
gatewayList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
devName: null,
devMac: null,
devId: null,
devPsw: null,
devVer: null,
devType: null,
group: null,
status: null,
mqttIp: null,
mqttPort: null,
mqttUser: null,
mqttPaswd: null,
devPosition: null
},
// 表单参数
form: {},
// 表单校验
rules: {
devMac: [
{ required: true, message: "设备MAC不能为空", trigger: "blur" }
],
devName: [
{ required: true, message: "设备名称不能为空", trigger: "blur" }
],
}
};
},
created() {
this.getList();
},
methods: {
/** 查询设备网关信息列表 */
getList() {
this.loading = true;
listGateway(this.queryParams).then(response => {
this.gatewayList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
devName: null,
devMac: null,
devId: null,
devPsw: null,
devVer: null,
devType: null,
group: null,
status: null,
mqttIp: null,
mqttPort: null,
mqttUser: null,
mqttPaswd: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
remark: null,
devPosition: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加设备网关信息";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getGateway(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改设备网关信息";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateGateway(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addGateway(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除设备网关信息编号为"' + ids + '"的数据项?').then(function() {
return delGateway(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('system/gateway/export', {
...this.queryParams
}, `gateway_${new Date().getTime()}.xlsx`)
}
}
};
</script>
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
<el-form-item label="设备mac" prop="devMac">
<el-input
v-model="queryParams.devMac"
placeholder="请输入设备mac"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="设备id" prop="devId">
<el-input
v-model="queryParams.devId"
placeholder="请输入设备id"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="请求的序列号" prop="seq">
<el-input
v-model="queryParams.seq"
placeholder="请输入请求的序列号"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<!-- <el-form-item label="消息描述:开门、开灯、网关设备绑定等" prop="mqttDescribe">-->
<!-- <el-input-->
<!-- v-model="queryParams.mqttDescribe"-->
<!-- placeholder="请输入消息描述:开门、开灯、网关设备绑定等"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="消息主题" prop="topic">-->
<!-- <el-input-->
<!-- v-model="queryParams.topic"-->
<!-- placeholder="请输入消息主题"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<!-- <el-row :gutter="10" class="mb8">-->
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="primary"-->
<!-- plain-->
<!-- icon="el-icon-plus"-->
<!-- size="mini"-->
<!-- @click="handleAdd"-->
<!-- v-hasPermi="['system:log:add']"-->
<!-- >新增</el-button>-->
<!-- </el-col>-->
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="success"-->
<!-- plain-->
<!-- icon="el-icon-edit"-->
<!-- size="mini"-->
<!-- :disabled="single"-->
<!-- @click="handleUpdate"-->
<!-- v-hasPermi="['system:log:edit']"-->
<!-- >修改</el-button>-->
<!-- </el-col>-->
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="danger"-->
<!-- plain-->
<!-- icon="el-icon-delete"-->
<!-- size="mini"-->
<!-- :disabled="multiple"-->
<!-- @click="handleDelete"-->
<!-- v-hasPermi="['system:log:remove']"-->
<!-- >删除</el-button>-->
<!-- </el-col>-->
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="warning"-->
<!-- plain-->
<!-- icon="el-icon-download"-->
<!-- size="mini"-->
<!-- @click="handleExport"-->
<!-- v-hasPermi="['system:log:export']"-->
<!-- >导出</el-button>-->
<!-- </el-col>-->
<!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>-->
<!-- </el-row>-->
<el-table v-loading="loading" :data="logList" @selection-change="handleSelectionChange">
<!-- <el-table-column type="selection" width="55" align="center" />-->
<!-- <el-table-column label="主键" align="center" prop="id" />-->
<el-table-column label="设备mac" align="center" prop="devMac" />
<el-table-column label="设备id" align="center" prop="devId" />
<el-table-column label="请求的序列号" align="center" prop="seq" />
<el-table-column label="消息类型" align="center" prop="mqttType" />
<el-table-column label="消息描述" align="center" prop="mqttDescribe" />
<el-table-column label="消息主体参数" align="center" prop="payload" />
<el-table-column label="消息主题" align="center" prop="topic" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<!-- <template slot-scope="scope">-->
<!-- <el-button-->
<!-- size="mini"-->
<!-- type="text"-->
<!-- icon="el-icon-edit"-->
<!-- @click="handleUpdate(scope.row)"-->
<!-- v-hasPermi="['system:log:edit']"-->
<!-- >修改</el-button>-->
<!-- <el-button-->
<!-- size="mini"-->
<!-- type="text"-->
<!-- icon="el-icon-delete"-->
<!-- @click="handleDelete(scope.row)"-->
<!-- v-hasPermi="['system:log:remove']"-->
<!-- >删除</el-button>-->
<!-- </template>-->
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改设备操作日志对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="设备mac" prop="devMac">
<el-input v-model="form.devMac" placeholder="请输入设备mac" />
</el-form-item>
<el-form-item label="设备id" prop="devId">
<el-input v-model="form.devId" placeholder="请输入设备id" />
</el-form-item>
<el-form-item label="请求的序列号" prop="seq">
<el-input v-model="form.seq" placeholder="请输入请求的序列号" />
</el-form-item>
<el-form-item label="消息描述:开门、开灯、网关设备绑定等" prop="mqttDescribe">
<el-input v-model="form.mqttDescribe" placeholder="请输入消息描述:开门、开灯、网关设备绑定等" />
</el-form-item>
<el-form-item label="消息主体参数" prop="payload">
<el-input v-model="form.payload" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="消息主题" prop="topic">
<el-input v-model="form.topic" placeholder="请输入消息主题" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listLog, getLog, delLog, addLog, updateLog } from "@/api/system/log";
export default {
name: "Log",
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 设备操作日志表格数据
logList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
devMac: null,
devId: null,
seq: null,
mqttType: null,
mqttDescribe: null,
payload: null,
topic: null,
},
// 表单参数
form: {},
// 表单校验
rules: {
}
};
},
created() {
this.getList();
},
methods: {
/** 查询设备操作日志列表 */
getList() {
this.loading = true;
listLog(this.queryParams).then(response => {
this.logList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
devMac: null,
devId: null,
seq: null,
mqttType: null,
mqttDescribe: null,
payload: null,
topic: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
remark: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加设备操作日志";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getLog(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改设备操作日志";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateLog(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addLog(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除设备操作日志编号为"' + ids + '"的数据项?').then(function() {
return delLog(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('system/log/export', {
...this.queryParams
}, `log_${new Date().getTime()}.xlsx`)
}
}
};
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment