Compare commits

..

No commits in common. "177a61327c4e0c8ffb843a1c9474f2fd62ae17e9" and "b192d7edb78f7715a4f916356494ddff7eb7cf8a" have entirely different histories.

1 changed files with 39 additions and 91 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(null)"
<el-button size="mini" type="primary" @click="addDevice()"
>添加设备</el-button
>
<el-button size="mini" type="primary" @click="uploadCode()"
@ -56,13 +56,7 @@
>
</template>
</el-table-column>
<el-table-column align="center" label="二维码">
<template slot-scope="{ row }">
<el-button type="text" @click="showQrCode(row)"
>查看</el-button
>
</template>
</el-table-column>
<el-table-column prop="qrCode" align="center" label="二维码" />
<el-table-column align="center" label="绑定状态">
<template slot-scope="{ row }">
<el-tag
@ -94,13 +88,6 @@
@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"
@ -128,7 +115,7 @@
>
<!-- 设备添加表单 -->
<template slot="outerContent">
<template v-if="dialogConfig.outerTitle !== '绑定记录'">
<template v-if="dialogConfig.outerTitle === '添加设备'">
<el-form
label-width="80px"
:model="addDeviceParams"
@ -179,34 +166,12 @@
/>
</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,
@ -233,7 +198,7 @@ export default {
pageSize: 10,
keyWords: '',
},
// /
//
addDeviceParams: {
iotType: '',
iotCode: '',
@ -265,9 +230,6 @@ export default {
selectList: [],
// Api
getDeviceBindRecordApi,
uploadOpen: false,
rowObj: {},
qrCode: '',
}
},
@ -284,18 +246,12 @@ export default {
},
/** 搜索按钮 */
handelQuery() {
this.getDeviceList(this.queryParams)
this.getDeviceList()
},
/** 添加设备 */
addDevice(row) {
if (!row) {
this.dialogConfig.outerTitle = '添加设备'
} else {
this.dialogConfig.outerTitle = '修改设备'
this.addDeviceParams.iotCode = row.iotCode
this.addDeviceParams.iotType = parseInt(row.iotType)
}
addDevice() {
this.dialogConfig.outerWidth = '40%'
this.dialogConfig.outerTitle = '添加设备'
this.dialogConfig.outerVisible = true
},
@ -316,12 +272,9 @@ export default {
if (valid) {
// 1. Api
const res = await addDeviceInfoApi(this.addDeviceParams)
if (res.code === 200) {
let title =
this.dialogConfig.outerTitle === '添加设备'
? '新增'
: '修改'
this.$message.success(`${title}成功!`)
this.$message.success('新增成功!')
this.dialogConfig.outerVisible = false
this.addDeviceParams.iotType = ''
this.addDeviceParams.iotCode = ''
@ -350,6 +303,36 @@ export default {
this.dialogConfig.outerVisible = false
},
/** 删除按钮 */
handleDelete(id) {
this.$confirm('是否确定删除当前设备, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(async () => {
const res = await deleteDeviceApi(id)
if (res.code === 200) {
this.$message.success('删除成功!')
this.getDeviceList()
}
})
},
/** 解绑按钮 */
handleUnbind(iotId) {
this.$confirm('是否确定解绑当前设备, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(async () => {
const res = await unbindDeviceApi({ id: iotId, iotId })
console.log('解绑设备', res)
if (res.code === 200) {
this.$message.success('解绑成功!')
this.getDeviceList()
}
})
},
/** 删除和解绑设备 */
handleDeleteAndUnbind(id, type) {
const title = type === 1 ? '删除' : '解绑'
@ -387,41 +370,6 @@ export default {
}
})
},
/** 查看二维码 */
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>