From bd069516274449e30a1665b7d7c695627ace5401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A3=B7=E5=8F=B6?= <14103883+leaf-phos@user.noreply.gitee.com> Date: Sat, 19 Apr 2025 17:45:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/bst/device.js | 1 + src/api/bst/dsLog.js | 44 +++ .../device/components/DeviceEditDialog.vue | 153 ++++++++++ .../components/DeviceSendCommandDialog.vue | 70 +++-- src/views/bst/device/index.vue | 121 ++------ src/views/bst/dsLog/index.vue | 284 ++++++++++++++++++ .../gateway/components/GatewayEditDialog.vue | 131 ++++++++ src/views/bst/gateway/index.vue | 60 +--- .../components/GatewayDeviceEditDialog.vue | 139 +++++++++ src/views/bst/gatewayDevice/index.vue | 55 ++-- 10 files changed, 854 insertions(+), 204 deletions(-) create mode 100644 src/api/bst/dsLog.js create mode 100644 src/views/bst/device/components/DeviceEditDialog.vue create mode 100644 src/views/bst/dsLog/index.vue create mode 100644 src/views/bst/gateway/components/GatewayEditDialog.vue create mode 100644 src/views/bst/gatewayDevice/components/GatewayDeviceEditDialog.vue diff --git a/src/api/bst/device.js b/src/api/bst/device.js index c97fd28..01bf602 100644 --- a/src/api/bst/device.js +++ b/src/api/bst/device.js @@ -47,6 +47,7 @@ export function delDevice(id) { export function sendDeviceCommand(data) { return request({ url: '/bst/device/send', + timeout: 60000, method: 'post', data: data }) diff --git a/src/api/bst/dsLog.js b/src/api/bst/dsLog.js new file mode 100644 index 0000000..555cf8a --- /dev/null +++ b/src/api/bst/dsLog.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 查询数据日志列表 +export function listDsLog(query) { + return request({ + url: '/bst/dsLog/list', + method: 'get', + params: query + }) +} + +// 查询数据日志详细 +export function getDsLog(id) { + return request({ + url: '/bst/dsLog/' + id, + method: 'get' + }) +} + +// 新增数据日志 +export function addDsLog(data) { + return request({ + url: '/bst/dsLog', + method: 'post', + data: data + }) +} + +// 修改数据日志 +export function updateDsLog(data) { + return request({ + url: '/bst/dsLog', + method: 'put', + data: data + }) +} + +// 删除数据日志 +export function delDsLog(id) { + return request({ + url: '/bst/dsLog/' + id, + method: 'delete' + }) +} diff --git a/src/views/bst/device/components/DeviceEditDialog.vue b/src/views/bst/device/components/DeviceEditDialog.vue new file mode 100644 index 0000000..874f833 --- /dev/null +++ b/src/views/bst/device/components/DeviceEditDialog.vue @@ -0,0 +1,153 @@ + + + \ No newline at end of file diff --git a/src/views/bst/device/components/DeviceSendCommandDialog.vue b/src/views/bst/device/components/DeviceSendCommandDialog.vue index 7157ca3..8167452 100644 --- a/src/views/bst/device/components/DeviceSendCommandDialog.vue +++ b/src/views/bst/device/components/DeviceSendCommandDialog.vue @@ -2,7 +2,7 @@ - + - - + + - - + + 次 + + + @@ -46,22 +39,36 @@ import { sendDeviceCommand } from '@/api/bst/device'; export default { name: 'DeviceSendCommandDialog', - components: { FormCol, AreaRemoteSelect }, + components: { FormCol }, props: { visible: { type: Boolean, default: false }, - ids: { - type: Array, - default: () => [] + mac: { + type: String, + default: null, }, }, data() { return { form: {}, rules: { - } + mac: [ + { required: true, message: '请输入MAC', trigger: 'blur' } + ], + command: [ + { required: true, message: '请输入命令', trigger: 'blur' } + ], + timeout: [ + { required: true, message: '请输入超时时间', trigger: 'blur' } + ], + tryCount: [ + { required: true, message: '请输入尝试次数', trigger: 'blur' } + ], + }, + resData: null, + submitLoading: false, } }, computed: { @@ -80,10 +87,12 @@ export default { }, reset() { this.form = { - mac: this.ids, + mac: this.mac, command: null, - + timeout: 10, + tryCount: 1, }; + this.resData = null; this.$nextTick(() => { this.$refs.form && this.$refs.form.clearValidate(); }); @@ -91,11 +100,16 @@ export default { submitForm() { this.$refs.form.validate(valid => { if (valid) { - this.form.ids = this.ids; + this.submitLoading = true; sendDeviceCommand(this.form).then(res => { - this.$message.success("划拨成功"); - this.dialogVisible = false; - this.$emit('success'); + if (res.data == null) { + this.resData = '响应数据为空'; + } else { + this.resData = JSON.stringify(res.data); + } + this.$message.success('发送成功'); + }).finally(() => { + this.submitLoading = false; }) } }); diff --git a/src/views/bst/device/index.vue b/src/views/bst/device/index.vue index 5dd5c70..e673219 100644 --- a/src/views/bst/device/index.vue +++ b/src/views/bst/device/index.vue @@ -89,10 +89,7 @@ {{d.row[column.key]}} - diff --git a/src/views/bst/gateway/components/GatewayEditDialog.vue b/src/views/bst/gateway/components/GatewayEditDialog.vue new file mode 100644 index 0000000..4614db2 --- /dev/null +++ b/src/views/bst/gateway/components/GatewayEditDialog.vue @@ -0,0 +1,131 @@ + + + \ No newline at end of file diff --git a/src/views/bst/gateway/index.vue b/src/views/bst/gateway/index.vue index dff5afa..19c059d 100644 --- a/src/views/bst/gateway/index.vue +++ b/src/views/bst/gateway/index.vue @@ -122,27 +122,20 @@ @pagination="getList" /> - - - - - - - - - - - + + \ No newline at end of file diff --git a/src/views/bst/gatewayDevice/index.vue b/src/views/bst/gatewayDevice/index.vue index 2817a54..78144b6 100644 --- a/src/views/bst/gatewayDevice/index.vue +++ b/src/views/bst/gatewayDevice/index.vue @@ -79,6 +79,13 @@ + + @@ -106,23 +113,12 @@ @pagination="getList" /> - - - - - - - - - - - - - - + + @@ -130,6 +126,7 @@ import { listGatewayDevice, getGatewayDevice, delGatewayDevice, addGatewayDevice, updateGatewayDevice } from "@/api/bst/gatewayDevice"; import { $showColumns } from '@/utils/mixins'; import FormCol from "@/components/FormCol/index.vue"; +import GatewayDeviceEditDialog from './components/GatewayDeviceEditDialog.vue'; // 默认排序字段 const defaultSort = { @@ -139,9 +136,9 @@ const defaultSort = { export default { name: "GatewayDevice", - dicts: ['device_type'], + dicts: ['device_type', 'online_status'], mixins: [$showColumns], - components: {FormCol}, + components: {FormCol, GatewayDeviceEditDialog}, props: { query: { type: Object, @@ -158,7 +155,9 @@ export default { {key: 'deviceMac', visible: true, label: '设备MAC', minWidth: null, sortable: true, overflow: false, align: 'center', width: null}, {key: 'deviceType', visible: true, label: '设备类型', minWidth: null, sortable: true, overflow: false, align: 'center', width: null}, {key: 'lastHeartTime', visible: true, label: '最后心跳', minWidth: null, sortable: true, overflow: false, align: 'center', width: null}, - {key: 'createTime', visible: true, label: '连接时间', minWidth: null, sortable: true, overflow: false, align: 'center', width: null}, + {key: 'gatewayLastOnlineTime', visible: true, label: '网关最后在线', minWidth: null, sortable: true, overflow: false, align: 'center', width: null}, + {key: 'heartBeat', visible: true, label: '心跳间隔', minWidth: null, sortable: true, overflow: false, align: 'center', width: null}, + {key: 'createTime', visible: true, label: '绑定时间', minWidth: null, sortable: true, overflow: false, align: 'center', width: null}, ], // 排序方式 orderSorts: ['ascending', 'descending', null], @@ -207,7 +206,9 @@ export default { lastHeartTime: [ { required: true, message: "最后一次心跳时间不能为空", trigger: "blur" } ] - } + }, + // 选中的ID + id: null, }; }, created() { @@ -269,19 +270,13 @@ export default { }, /** 新增按钮操作 */ handleAdd() { - this.reset(); + this.id = null; this.open = true; - this.title = "添加网关设备"; }, /** 修改按钮操作 */ handleUpdate(row) { - this.reset(); - const id = row.id || this.ids - getGatewayDevice(id).then(response => { - this.form = response.data; - this.open = true; - this.title = "修改网关设备"; - }); + this.id = row.id || this.ids[0]; + this.open = true; }, /** 提交按钮 */ submitForm() {