From b192d7edb78f7715a4f916356494ddff7eb7cf8a Mon Sep 17 00:00:00 2001 From: BianLzhaoMin <11485688+bianliangzhaomin123@user.noreply.gitee.com> Date: Mon, 5 Aug 2024 17:16:09 +0800 Subject: [PATCH] =?UTF-8?q?iot=E8=AE=BE=E5=A4=87=E8=A7=A3=E7=BB=91?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B0=83=E8=AF=95=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sgzb-ui/src/api/iotDevice/index.js | 8 ++++++++ sgzb-ui/src/views/iotDevice/index.vue | 27 ++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/sgzb-ui/src/api/iotDevice/index.js b/sgzb-ui/src/api/iotDevice/index.js index ea4d130c..96d88c02 100644 --- a/sgzb-ui/src/api/iotDevice/index.js +++ b/sgzb-ui/src/api/iotDevice/index.js @@ -24,6 +24,14 @@ export function getDeviceBindRecordApi(query) { params: query }) } +// 获取设备绑定详情 +export function getDeviceBindDetailsApi(params) { + return request({ + url: '/material/iotMachine/getRecordListAll', + method: 'get', + params, + }) +} // 解绑设备 export function unbindDeviceApi(data) { return request({ diff --git a/sgzb-ui/src/views/iotDevice/index.vue b/sgzb-ui/src/views/iotDevice/index.vue index 222dc43c..94d04986 100644 --- a/sgzb-ui/src/views/iotDevice/index.vue +++ b/sgzb-ui/src/views/iotDevice/index.vue @@ -179,6 +179,7 @@ import { deleteDeviceApi, unbindDeviceApi, getDeviceBindRecordApi, + getDeviceBindDetailsApi, } from '@/api/iotDevice' export default { components: { @@ -340,13 +341,33 @@ export default { cancelButtonText: '取消', type: 'warning', }).then(async () => { - let ApiFun = type === 1 ? deleteDeviceApi : unbindDeviceApi - let params = type === 1 ? id : { id } + let ApiFun = + type === 1 ? deleteDeviceApi : getDeviceBindDetailsApi + let params = type === 1 ? id : { iotId: id } const res = await ApiFun(params) - if (res.code === 200) { + if (type === 1 && res.code === 200) { this.$message.success(`${title}成功!`) this.getDeviceList() } + if (type === 2 && res.code === 200) { + const unbindParams = { + maCode: '', + iotId: id, + id: '', + typeId: '', + } + res.data.map((e) => { + if (!e.unBindTime) { + unbindParams.maCode = e.maCode + unbindParams.id = e.id + unbindParams.typeId = e.typeId + } + }) + unbindDeviceApi(unbindParams).then((res) => { + this.$message.success(`${title}成功!`) + this.getDeviceList() + }) + } }) }, },