iot设备修改调试

This commit is contained in:
BianLzhaoMin 2024-08-05 17:41:27 +08:00
parent dddc269455
commit 177a61327c
1 changed files with 84 additions and 10 deletions

View File

@ -12,7 +12,7 @@
<el-button size="mini" type="primary" @click="handelQuery()"
>搜索</el-button
>
<el-button size="mini" type="primary" @click="addDevice()"
<el-button size="mini" type="primary" @click="addDevice(null)"
>添加设备</el-button
>
<el-button size="mini" type="primary" @click="uploadCode()"
@ -58,7 +58,7 @@
</el-table-column>
<el-table-column align="center" label="二维码">
<template slot-scope="{ row }">
<el-button type="text" size="small" @click="showQrCode(row)"
<el-button type="text" @click="showQrCode(row)"
>查看</el-button
>
</template>
@ -94,6 +94,13 @@
@click="handleDeleteAndUnbind(row.iotId, 1)"
>删除</el-button
>
<el-button
type="text"
icon="el-icon-edit"
style="color: #67c23a"
@click="addDevice(row)"
>修改</el-button
>
<el-button
type="text"
icon="el-icon-document-delete"
@ -121,7 +128,7 @@
>
<!-- 设备添加表单 -->
<template slot="outerContent">
<template v-if="dialogConfig.outerTitle === '添加设备'">
<template v-if="dialogConfig.outerTitle !== '绑定记录'">
<el-form
label-width="80px"
:model="addDeviceParams"
@ -172,12 +179,34 @@
/>
</template>
</DialogModel>
<!-- 二维码弹框 -->
<el-dialog
title="查看二维码"
:visible.sync="uploadOpen"
v-if="uploadOpen"
width="500px"
append-to-body
>
<div style="text-align: center">
<div class="qrCodeImg">
<div id="qrcode" class="qrcode" ref="codeItem"></div>
</div>
<div class="maCode">二维码编号{{ rowObj.qrCode }}</div>
</div>
<div
slot="footer"
class="dialog-footer"
style="text-align: center"
></div>
</el-dialog>
</div>
</template>
<script>
import DialogModel from '@/components/DialogModel' //
import TableModel from '@/components/TableModel' //
import QRCode from 'qrcodejs2'
import { dialogConfig } from './config'
import {
addDeviceInfoApi,
@ -204,7 +233,7 @@ export default {
pageSize: 10,
keyWords: '',
},
//
// /
addDeviceParams: {
iotType: '',
iotCode: '',
@ -236,6 +265,9 @@ export default {
selectList: [],
// Api
getDeviceBindRecordApi,
uploadOpen: false,
rowObj: {},
qrCode: '',
}
},
@ -252,12 +284,18 @@ export default {
},
/** 搜索按钮 */
handelQuery() {
this.getDeviceList()
this.getDeviceList(this.queryParams)
},
/** 添加设备 */
addDevice() {
this.dialogConfig.outerWidth = '40%'
addDevice(row) {
if (!row) {
this.dialogConfig.outerTitle = '添加设备'
} else {
this.dialogConfig.outerTitle = '修改设备'
this.addDeviceParams.iotCode = row.iotCode
this.addDeviceParams.iotType = parseInt(row.iotType)
}
this.dialogConfig.outerWidth = '40%'
this.dialogConfig.outerVisible = true
},
@ -278,9 +316,12 @@ export default {
if (valid) {
// 1. Api
const res = await addDeviceInfoApi(this.addDeviceParams)
if (res.code === 200) {
this.$message.success('新增成功!')
let title =
this.dialogConfig.outerTitle === '添加设备'
? '新增'
: '修改'
this.$message.success(`${title}成功!`)
this.dialogConfig.outerVisible = false
this.addDeviceParams.iotType = ''
this.addDeviceParams.iotCode = ''
@ -346,8 +387,41 @@ export default {
}
})
},
/** 查看二维码 */
showQrCode() {},
showQrCode(row) {
if (!row.qrCode) {
this.$message.error('当前设备没有二维码')
return
}
this.rowObj = row
this.uploadOpen = true
this.qrCode = row.qrCode
let str = this.qrUrl + row.qrCode
this.$nextTick(() => {
this.$refs.codeItem.innerHTML = ''
let qrCode = new QRCode(this.$refs.codeItem, {
text: str, //
width: 256,
height: 256,
colorDark: '#000000',
colorLight: '#ffffff',
correctLevel: QRCode.CorrectLevel.H,
})
}, 500)
},
},
}
</script>
<style scoped>
.qrCodeImg {
display: flex;
align-items: center;
justify-content: center;
}
.maCode {
margin-top: 15px;
font-size: 18px;
}
</style>