代码优化
This commit is contained in:
parent
440198e36b
commit
354f3f5ac5
|
|
@ -6,21 +6,15 @@
|
||||||
// const qrUrl = 'https://z.csgmall.com.cn/gl/qrCode/qrCodePage?qrCode='; //南网
|
// const qrUrl = 'https://z.csgmall.com.cn/gl/qrCode/qrCodePage?qrCode='; //南网
|
||||||
|
|
||||||
// const qrUrl = process.env.NODE_ENV === 'production' ? 'http://192.168.0.14:18866/qrCode/qrCodePage?qrCode=' : 'http://192.168.0.14:21624/qrCode/qrCodePage?qrCode='
|
// const qrUrl = process.env.NODE_ENV === 'production' ? 'http://192.168.0.14:18866/qrCode/qrCodePage?qrCode=' : 'http://192.168.0.14:21624/qrCode/qrCodePage?qrCode='
|
||||||
let qrUrl = ''
|
|
||||||
const origin = window.location.origin
|
|
||||||
if (origin == 'http://112.29.103.165:21626') {
|
|
||||||
qrUrl = 'http://112.29.103.165:21626/qrCode/qrCodePage?qrCode='
|
const qrUrl = process.env.NODE_ENV === 'production' ? 'http://192.168.0.62:21624/sgzbgl/qrCode/qrCodePage?qrCode=' : 'http://192.168.0.14:18866/qrCode/qrCodePage?qrCode='
|
||||||
} else {
|
export default {
|
||||||
qrUrl = 'http://192.168.0.14:18866/qrCode/qrCodePage?qrCode='
|
qrUrl,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// const qrUrl = process.env.NODE_ENV === 'production' ? 'https://z.csgmall.com.cn/sgzbgl/qrCode/qrCodePage?qrCode=' : 'http://192.168.0.14:18866/qrCode/qrCodePage?qrCode='
|
|
||||||
// export default {
|
|
||||||
// qrUrl,
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,405 +1,517 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="app-container" v-if="!isShow">
|
<div class="app-container" v-if="!isShow">
|
||||||
<el-form :model="queryForm" ref="queryForm" size="small" :inline="true" label-width="68px" v-show="showSearch">
|
<el-form
|
||||||
<el-form-item label="关键字" prop="keyWord">
|
:model="queryForm"
|
||||||
<el-input v-model="queryForm.keyWord" clearable placeholder="请输入关键字" @keyup.enter.native="handleQuery" />
|
ref="queryForm"
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" size="small" @click="handleQuery">搜索</el-button>
|
|
||||||
<el-button type="primary" size="small" @click="addIOT">添加设备</el-button>
|
|
||||||
<el-button type="primary" size="small" @click="downloadQRCord">下载二维码</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
|
|
||||||
<el-row :gutter="10" class="mb8">
|
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<el-table :data="tableData" style="width: 100%" @selection-change="selectionChange">
|
|
||||||
<el-table-column type="selection" width="55" align="center" />
|
|
||||||
<el-table-column
|
|
||||||
type="index"
|
|
||||||
label="序号"
|
|
||||||
align="center"
|
|
||||||
width="55"
|
|
||||||
:index="indexContinuation(queryParams.pageNum, queryParams.pageSize)"
|
|
||||||
/>
|
|
||||||
<el-table-column label="设备类型" prop="iotTypeName" align="center" />
|
|
||||||
<el-table-column label="设备编号" prop="iotCode" align="center" />
|
|
||||||
<el-table-column label="设备状态" prop="iotStatus" align="center">
|
|
||||||
<template v-slot="{ row }">
|
|
||||||
<el-tag v-if="row.iotStatus == 0" type="success">在线</el-tag>
|
|
||||||
<el-tag v-else type="danger">掉线</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="prCode" label="二维码" align="center">
|
|
||||||
<template v-slot="{ row }">
|
|
||||||
<el-button type="text" size="small" @click="showQrCode(row)">查看</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="状态" align="center">
|
|
||||||
<template v-slot="{ row }">
|
|
||||||
<el-tag v-if="row.bindStatus == 0" type="success">已绑定</el-tag>
|
|
||||||
<el-tag v-else type="danger">未绑定</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="操作" align="center">
|
|
||||||
<template v-slot="{ row }">
|
|
||||||
<el-button type="text" size="small" @click="handleCheck(row)" icon="el-icon-view">记录</el-button>
|
|
||||||
<el-button type="text" size="small" @click="handleEdit(row)" icon="el-icon-edit-outline">修改</el-button>
|
|
||||||
<el-button
|
|
||||||
type="text"
|
|
||||||
size="small"
|
size="small"
|
||||||
style="color: red"
|
:inline="true"
|
||||||
@click="handleDelete(row)"
|
label-width="68px"
|
||||||
v-if="row.bindStatus == 1"
|
v-show="showSearch"
|
||||||
icon="el-icon-delete"
|
>
|
||||||
>
|
<el-form-item label="关键字" prop="keyWord">
|
||||||
删除
|
<el-input
|
||||||
</el-button>
|
v-model="queryForm.keyWord"
|
||||||
<el-button
|
clearable
|
||||||
type="text"
|
placeholder="请输入关键字"
|
||||||
size="small"
|
@keyup.enter.native="handleQuery"
|
||||||
style="color: red"
|
/>
|
||||||
@click="handleUnbind(row)"
|
</el-form-item>
|
||||||
v-if="row.bindStatus == 0"
|
<el-form-item>
|
||||||
icon="el-icon-connection"
|
<el-button type="primary" size="small" @click="handleQuery"
|
||||||
>
|
>搜索</el-button
|
||||||
解绑
|
>
|
||||||
</el-button>
|
<el-button type="primary" size="small" @click="addIOT"
|
||||||
</template>
|
>添加设备</el-button
|
||||||
</el-table-column>
|
>
|
||||||
</el-table>
|
<!-- <el-button type="primary" size="small" @click="downloadQRCord"
|
||||||
|
>下载二维码</el-button
|
||||||
|
> -->
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
<pagination
|
<el-row :gutter="10" class="mb8">
|
||||||
v-show="total > 0"
|
<right-toolbar
|
||||||
:total="total"
|
:showSearch.sync="showSearch"
|
||||||
:page.sync="queryParams.pageNum"
|
@queryTable="getList"
|
||||||
:limit.sync="queryParams.pageSize"
|
></right-toolbar>
|
||||||
@pagination="getList"
|
</el-row>
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- 二维码弹框 -->
|
<el-table
|
||||||
<el-dialog title="查看二维码" :visible.sync="uploadOpen" width="500px" append-to-body>
|
:data="tableData"
|
||||||
<div style="text-align: center">
|
style="width: 100%"
|
||||||
<div class="qrCodeImg">
|
@selection-change="selectionChange"
|
||||||
<div id="qrcode" class="qrcode" ref="codeItem"></div>
|
>
|
||||||
</div>
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
<div class="maCode">二维码编号:{{ rowObj.qrCode }}</div>
|
<el-table-column
|
||||||
</div>
|
type="index"
|
||||||
<div slot="footer" class="dialog-footer" style="text-align: center"></div>
|
label="序号"
|
||||||
</el-dialog>
|
align="center"
|
||||||
|
width="55"
|
||||||
|
:index="
|
||||||
|
indexContinuation(queryParams.pageNum, queryParams.pageSize)
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
label="设备类型"
|
||||||
|
prop="iotTypeName"
|
||||||
|
align="center"
|
||||||
|
/>
|
||||||
|
<el-table-column label="设备编号" prop="iotCode" align="center" />
|
||||||
|
<el-table-column label="设备状态" prop="iotStatus" align="center">
|
||||||
|
<template v-slot="{ row }">
|
||||||
|
<el-tag size="mini" v-if="row.iotStatus == 0" type="success"
|
||||||
|
>在线</el-tag
|
||||||
|
>
|
||||||
|
<el-tag size="mini" v-else type="danger">下线</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="prCode" label="二维码" align="center">
|
||||||
|
<template v-slot="{ row }">
|
||||||
|
<el-button type="text" size="small" @click="showQrCode(row)"
|
||||||
|
>查看</el-button
|
||||||
|
>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="状态" align="center">
|
||||||
|
<template v-slot="{ row }">
|
||||||
|
<el-tag
|
||||||
|
v-if="row.bindStatus == 0"
|
||||||
|
type="success"
|
||||||
|
size="mini"
|
||||||
|
>已绑定</el-tag
|
||||||
|
>
|
||||||
|
<el-tag v-else type="warning" size="mini">未绑定</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" align="center">
|
||||||
|
<template v-slot="{ row }">
|
||||||
|
<el-button
|
||||||
|
type="text"
|
||||||
|
size="small"
|
||||||
|
@click="handleCheck(row)"
|
||||||
|
icon="el-icon-view"
|
||||||
|
>记录</el-button
|
||||||
|
>
|
||||||
|
<el-button
|
||||||
|
type="text"
|
||||||
|
size="small"
|
||||||
|
@click="handleEdit(row)"
|
||||||
|
icon="el-icon-edit-outline"
|
||||||
|
>修改</el-button
|
||||||
|
>
|
||||||
|
<el-button
|
||||||
|
type="text"
|
||||||
|
size="small"
|
||||||
|
style="color: red"
|
||||||
|
@click="handleDelete(row)"
|
||||||
|
v-if="row.bindStatus == 1"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="text"
|
||||||
|
size="small"
|
||||||
|
style="color: red"
|
||||||
|
@click="handleUnbind(row)"
|
||||||
|
v-if="row.bindStatus == 0"
|
||||||
|
icon="el-icon-connection"
|
||||||
|
>
|
||||||
|
解绑
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
<!-- 添加/修改 设备弹框 -->
|
<pagination
|
||||||
<el-dialog :title="title" :visible.sync="IOTOpen" width="500px" append-to-body>
|
v-show="total > 0"
|
||||||
<el-form :model="IOTForm" ref="IOTForm" label-width="120px" size="small" :rules="rules">
|
:total="total"
|
||||||
<el-form-item label="设备类型: " prop="iotType">
|
:page.sync="queryParams.pageNum"
|
||||||
<el-select v-model="IOTForm.iotType" filterable clearable placeholder="请选择设备类型" style="width: 280px">
|
:limit.sync="queryParams.pageSize"
|
||||||
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
|
@pagination="getList"
|
||||||
</el-select>
|
/>
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="设备编号: " prop="iotCode">
|
<!-- 二维码弹框 -->
|
||||||
<el-input v-model="IOTForm.iotCode" clearable placeholder="请输入设备编号" style="width: 280px" />
|
<el-dialog
|
||||||
</el-form-item>
|
title="查看二维码"
|
||||||
<!-- 修改设备状态: 使用Switch开关 -->
|
:visible.sync="uploadOpen"
|
||||||
<el-form-item label="设备状态: " prop="iotStatus" v-if="isEdit">
|
width="500px"
|
||||||
<el-switch
|
append-to-body
|
||||||
v-model="IOTForm.iotStatus"
|
>
|
||||||
active-text="在线"
|
<div style="text-align: center">
|
||||||
inactive-text="掉线"
|
<div class="qrCodeImg">
|
||||||
:active-value="0"
|
<div id="qrcode" class="qrcode" ref="codeItem"></div>
|
||||||
:inactive-value="1"
|
</div>
|
||||||
/>
|
<div class="maCode">二维码编号:{{ rowObj.qrCode }}</div>
|
||||||
</el-form-item>
|
</div>
|
||||||
</el-form>
|
<div
|
||||||
<div slot="footer" class="dialog-footer">
|
slot="footer"
|
||||||
<el-button @click="IOTOpen = false">取 消</el-button>
|
class="dialog-footer"
|
||||||
<el-button type="primary" @click="submit">确 定</el-button>
|
style="text-align: center"
|
||||||
</div>
|
></div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</div>
|
|
||||||
<div v-else>
|
<!-- 添加/修改 设备弹框 -->
|
||||||
<BindDetails ref="bindDetails" :isShow="isShow" :iotId="iotId" />
|
<el-dialog
|
||||||
</div>
|
:title="title"
|
||||||
|
:visible.sync="IOTOpen"
|
||||||
|
width="500px"
|
||||||
|
append-to-body
|
||||||
|
>
|
||||||
|
<el-form
|
||||||
|
:model="IOTForm"
|
||||||
|
ref="IOTForm"
|
||||||
|
label-width="120px"
|
||||||
|
size="small"
|
||||||
|
:rules="rules"
|
||||||
|
>
|
||||||
|
<el-form-item label="设备类型: " prop="iotType">
|
||||||
|
<el-select
|
||||||
|
v-model="IOTForm.iotType"
|
||||||
|
filterable
|
||||||
|
clearable
|
||||||
|
placeholder="请选择设备类型"
|
||||||
|
style="width: 280px"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in options"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="设备编号: " prop="iotCode">
|
||||||
|
<el-input
|
||||||
|
v-model="IOTForm.iotCode"
|
||||||
|
clearable
|
||||||
|
placeholder="请输入设备编号"
|
||||||
|
style="width: 280px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<!-- 修改设备状态: 使用Switch开关 -->
|
||||||
|
<el-form-item label="设备状态: " prop="iotStatus" v-if="isEdit">
|
||||||
|
<el-switch
|
||||||
|
v-model="IOTForm.iotStatus"
|
||||||
|
active-text="在线"
|
||||||
|
inactive-text="下线"
|
||||||
|
:active-value="0"
|
||||||
|
:inactive-value="1"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button @click="IOTOpen = false">取 消</el-button>
|
||||||
|
<el-button type="primary" @click="submit">确 定</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<BindDetails ref="bindDetails" :isShow="isShow" :iotId="iotId" />
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import BindDetails from './component/BindDetails'
|
import BindDetails from './component/BindDetails'
|
||||||
import QRCode from 'qrcodejs2'
|
import QRCode from 'qrcodejs2'
|
||||||
import { addOrUpdate, getIotList, deleteIotById, getRecordListAll, unbindIot } from '@/api/store/iotManagement.js'
|
import {
|
||||||
|
addOrUpdate,
|
||||||
|
getIotList,
|
||||||
|
deleteIotById,
|
||||||
|
getRecordListAll,
|
||||||
|
unbindIot,
|
||||||
|
} from '@/api/store/iotManagement.js'
|
||||||
export default {
|
export default {
|
||||||
name: 'IOTequipment',
|
name: 'IOTequipment',
|
||||||
components: {
|
components: {
|
||||||
BindDetails,
|
BindDetails,
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
isShow: false,
|
|
||||||
showSearch: true, // 是否显示搜索
|
|
||||||
uploadOpen: false, // 二维码弹框
|
|
||||||
rowObj: {},
|
|
||||||
qrCode: '',
|
|
||||||
qrUrl: this.globalUrl.qrUrl,
|
|
||||||
queryForm: {
|
|
||||||
keyWord: '',
|
|
||||||
},
|
|
||||||
total: 0,
|
|
||||||
queryParams: {
|
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 10,
|
|
||||||
},
|
|
||||||
tableData: [],
|
|
||||||
IOTForm: {
|
|
||||||
iotType: '',
|
|
||||||
iotCode: '',
|
|
||||||
iotStatus: '',
|
|
||||||
},
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
value: '125',
|
|
||||||
label: '定位设备',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: '126',
|
|
||||||
label: '检测设备',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
title: '',
|
|
||||||
IOTOpen: false,
|
|
||||||
// 校验
|
|
||||||
rules: {
|
|
||||||
iotType: [{ required: true, message: '请选择设备类型', trigger: 'change' }],
|
|
||||||
iotCode: [
|
|
||||||
{ required: true, message: '请输入设备编号', trigger: 'blur' },
|
|
||||||
{
|
|
||||||
// 限制输入字母数字 短横线(-) 下划线(_)
|
|
||||||
pattern: /^[a-zA-Z0-9_-]+$/,
|
|
||||||
message: '请输入正确的设备编码',
|
|
||||||
trigger: 'blur',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
isEdit: false,
|
|
||||||
iotId: undefined,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.getList()
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
handleQuery() {
|
|
||||||
console.log('🚀 ~ handleQuery ~ 查询:', this.queryForm.keyWord)
|
|
||||||
this.getList()
|
|
||||||
},
|
},
|
||||||
getList() {
|
data() {
|
||||||
const params = {
|
return {
|
||||||
keyWord: this.queryForm.keyWord || '',
|
isShow: false,
|
||||||
pageNum: this.queryParams.pageNum,
|
showSearch: true, // 是否显示搜索
|
||||||
pageSize: this.queryParams.pageSize,
|
uploadOpen: false, // 二维码弹框
|
||||||
}
|
rowObj: {},
|
||||||
console.log('🚀 ~ getList ~ 获取列表', params)
|
qrCode: '',
|
||||||
|
qrUrl: this.globalUrl.qrUrl,
|
||||||
|
queryForm: {
|
||||||
|
keyWord: '',
|
||||||
|
},
|
||||||
|
total: 0,
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
},
|
||||||
|
tableData: [],
|
||||||
|
IOTForm: {
|
||||||
|
iotType: '',
|
||||||
|
iotCode: '',
|
||||||
|
iotStatus: '',
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
// {
|
||||||
|
// value: '125',
|
||||||
|
// label: '定位设备',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// value: '126',
|
||||||
|
// label: '检测设备',
|
||||||
|
// },
|
||||||
|
],
|
||||||
|
title: '',
|
||||||
|
IOTOpen: false,
|
||||||
|
// 校验
|
||||||
|
rules: {
|
||||||
|
iotType: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择设备类型',
|
||||||
|
trigger: 'change',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
iotCode: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入设备编号',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// 限制输入字母数字 短横线(-) 下划线(_)
|
||||||
|
pattern: /^[a-zA-Z0-9_-]+$/,
|
||||||
|
message: '请输入正确的设备编码',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
isEdit: false,
|
||||||
|
iotId: undefined,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleQuery() {
|
||||||
|
console.log('🚀 ~ handleQuery ~ 查询:', this.queryForm.keyWord)
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
|
getList() {
|
||||||
|
const params = {
|
||||||
|
keyWord: this.queryForm.keyWord || '',
|
||||||
|
pageNum: this.queryParams.pageNum,
|
||||||
|
pageSize: this.queryParams.pageSize,
|
||||||
|
}
|
||||||
|
console.log('🚀 ~ getList ~ 获取列表', params)
|
||||||
|
|
||||||
getIotList(params)
|
getIotList(params)
|
||||||
.then(res => {
|
.then((res) => {
|
||||||
this.tableData = res.rows
|
this.tableData = res.rows
|
||||||
this.total = res.total
|
this.total = res.total
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch((err) => {
|
||||||
console.log('🚀 ~ getList ~ err:', err)
|
console.log('🚀 ~ getList ~ err:', err)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 获取设备类型
|
// 获取设备类型
|
||||||
getDeviceType() {
|
async getDeviceType() {
|
||||||
// 接口()
|
try {
|
||||||
// .then(res => {
|
const res = await selectList()
|
||||||
// this.options = res.data
|
this.options = res.data
|
||||||
// })
|
} catch (err) {
|
||||||
// .catch(err => {
|
console.log('🚀 ~ getIotType ~ err:', err)
|
||||||
// console.log('🚀 ~ getDeviceType ~ err:', err)
|
|
||||||
// })
|
|
||||||
},
|
|
||||||
addIOT() {
|
|
||||||
this.title = '添加设备'
|
|
||||||
this.IOTOpen = true
|
|
||||||
this.isEdit = false
|
|
||||||
this.getDeviceType()
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.IOTForm = {
|
|
||||||
iotType: '',
|
|
||||||
iotCode: '',
|
|
||||||
}
|
|
||||||
this.$refs.IOTForm.resetFields()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
downloadQRCord() {
|
|
||||||
this.$confirm('是否下载二维码?', '提示', {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
cancelButtonText: '取消',
|
|
||||||
type: 'warning',
|
|
||||||
}).then(() => {
|
|
||||||
// this.$message({
|
|
||||||
// type: 'success',
|
|
||||||
// message: '下载成功',
|
|
||||||
// })
|
|
||||||
})
|
|
||||||
},
|
|
||||||
showQrCode(row) {
|
|
||||||
console.log(row)
|
|
||||||
if (row.qrCode == null) {
|
|
||||||
this.$message.error('当前设备没有二维码')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.rowObj = row
|
|
||||||
this.uploadOpen = true
|
|
||||||
this.qrCode = row.qrCode
|
|
||||||
let str = this.qrUrl + row.qrCode
|
|
||||||
console.log('🚀 ~ showQrCode ~ str:', str)
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.$refs.codeItem.innerHTML = ''
|
|
||||||
var qrcode = new QRCode(this.$refs.codeItem, {
|
|
||||||
text: str, //二维码内容
|
|
||||||
width: 256,
|
|
||||||
height: 256,
|
|
||||||
colorDark: '#000000',
|
|
||||||
colorLight: '#ffffff',
|
|
||||||
correctLevel: QRCode.CorrectLevel.H,
|
|
||||||
})
|
|
||||||
// console.log('🚀 ~ showQrCode ~ qrcode:', qrcode)
|
|
||||||
}, 500)
|
|
||||||
},
|
|
||||||
handleCheck(row) {
|
|
||||||
console.log('🚀 ~ handleCheck ~ 记录:', row)
|
|
||||||
this.isShow = true
|
|
||||||
this.iotId = row.iotId
|
|
||||||
},
|
|
||||||
handleEdit(row) {
|
|
||||||
console.log('🚀 ~ handleEdit ~ 修改:', row)
|
|
||||||
// 修改IOT设备
|
|
||||||
this.title = '修改设备'
|
|
||||||
this.IOTOpen = true
|
|
||||||
this.isEdit = true
|
|
||||||
this.getDeviceType()
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.$refs.IOTForm.resetFields()
|
|
||||||
this.IOTForm = {
|
|
||||||
iotId: row.iotId,
|
|
||||||
iotType: row.iotType,
|
|
||||||
iotCode: row.iotCode,
|
|
||||||
iotStatus: row.iotStatus,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
handleDelete(row) {
|
|
||||||
console.log('🚀 ~ handleDelete ~ 删除:', row)
|
|
||||||
// 弹框提示
|
|
||||||
this.$confirm('是否删除该设备?', '系统提示', {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
cancelButtonText: '取消',
|
|
||||||
type: 'warning',
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
// 删除
|
|
||||||
deleteIotById(row.iotId).then(res => {
|
|
||||||
// 提示
|
|
||||||
this.$message({
|
|
||||||
type: 'success',
|
|
||||||
message: '删除成功',
|
|
||||||
})
|
|
||||||
this.getList()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
this.$message({
|
|
||||||
type: 'info',
|
|
||||||
message: '已取消删除',
|
|
||||||
})
|
|
||||||
})
|
|
||||||
},
|
|
||||||
handleUnbind(row) {
|
|
||||||
try {
|
|
||||||
const params = {
|
|
||||||
id: undefined,
|
|
||||||
iotId: row.iotId,
|
|
||||||
maCode: '',
|
|
||||||
typeId: undefined,
|
|
||||||
}
|
|
||||||
console.log('🚀 ~ handleUnbind ~ 解绑', row)
|
|
||||||
this.$confirm('确定解绑设备吗?', '提示', {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
cancelButtonText: '取消',
|
|
||||||
type: 'warning',
|
|
||||||
})
|
|
||||||
.then(async () => {
|
|
||||||
let { data } = await getRecordListAll({ iotId: params.iotId })
|
|
||||||
console.log('🚀 ~ .then ~ res:', data)
|
|
||||||
data.forEach(item => {
|
|
||||||
if (!item.unBindTime) {
|
|
||||||
params.maCode = item.maCode
|
|
||||||
params.typeId = item.typeId
|
|
||||||
params.id = item.id
|
|
||||||
}
|
|
||||||
})
|
|
||||||
console.log('🚀 ~ .then ~ maCode:', params)
|
|
||||||
await unbindIot(params)
|
|
||||||
this.$message.success('解绑成功')
|
|
||||||
this.getList()
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.log('🚀 ~ handleUnbind ~ err:', err)
|
|
||||||
this.$message.info('已取消解绑')
|
|
||||||
})
|
|
||||||
} catch (err) {
|
|
||||||
console.log('🚀 ~ handleUnbind ~ error', err)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
selectionChange(val) {
|
|
||||||
console.log('🚀 ~ selectionChange ~ val:', val)
|
|
||||||
},
|
|
||||||
// 确认提交
|
|
||||||
submit() {
|
|
||||||
this.$refs.IOTForm.validate(valid => {
|
|
||||||
if (valid) {
|
|
||||||
console.log('🚀 ~ submit ~ 确认提交', this.IOTForm)
|
|
||||||
let params = {}
|
|
||||||
if (this.isEdit) {
|
|
||||||
// 修改
|
|
||||||
params = {
|
|
||||||
...this.IOTForm,
|
|
||||||
}
|
}
|
||||||
} else {
|
// 接口()
|
||||||
// 添加
|
// .then(res => {
|
||||||
params = {
|
// this.options = res.data
|
||||||
...this.IOTForm,
|
// })
|
||||||
|
// .catch(err => {
|
||||||
|
// console.log('🚀 ~ getDeviceType ~ err:', err)
|
||||||
|
// })
|
||||||
|
},
|
||||||
|
addIOT() {
|
||||||
|
this.title = '添加设备'
|
||||||
|
this.IOTOpen = true
|
||||||
|
this.isEdit = false
|
||||||
|
this.getDeviceType()
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.IOTForm = {
|
||||||
|
iotType: '',
|
||||||
|
iotCode: '',
|
||||||
|
}
|
||||||
|
this.$refs.IOTForm.resetFields()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
downloadQRCord() {
|
||||||
|
this.$confirm('是否下载二维码?', '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
}).then(() => {
|
||||||
|
// this.$message({
|
||||||
|
// type: 'success',
|
||||||
|
// message: '下载成功',
|
||||||
|
// })
|
||||||
|
})
|
||||||
|
},
|
||||||
|
showQrCode(row) {
|
||||||
|
console.log(row)
|
||||||
|
if (row.qrCode == null) {
|
||||||
|
this.$message.error('当前设备没有二维码')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
this.rowObj = row
|
||||||
addOrUpdate(params)
|
this.uploadOpen = true
|
||||||
.then(res => {
|
this.qrCode = row.qrCode
|
||||||
this.IOTOpen = false
|
let str = this.qrUrl + row.qrCode
|
||||||
// 提示 isEdit ? '修改成功' : '添加成功'
|
console.log('🚀 ~ showQrCode ~ str:', str)
|
||||||
this.$message({
|
this.$nextTick(() => {
|
||||||
type: 'success',
|
this.$refs.codeItem.innerHTML = ''
|
||||||
message: this.isEdit ? '修改成功' : '添加成功',
|
var qrcode = new QRCode(this.$refs.codeItem, {
|
||||||
})
|
text: str, //二维码内容
|
||||||
this.getList()
|
width: 256,
|
||||||
|
height: 256,
|
||||||
|
colorDark: '#000000',
|
||||||
|
colorLight: '#ffffff',
|
||||||
|
correctLevel: QRCode.CorrectLevel.H,
|
||||||
|
})
|
||||||
|
// console.log('🚀 ~ showQrCode ~ qrcode:', qrcode)
|
||||||
|
}, 500)
|
||||||
|
},
|
||||||
|
handleCheck(row) {
|
||||||
|
console.log('🚀 ~ handleCheck ~ 记录:', row)
|
||||||
|
this.isShow = true
|
||||||
|
this.iotId = row.iotId
|
||||||
|
},
|
||||||
|
handleEdit(row) {
|
||||||
|
console.log('🚀 ~ handleEdit ~ 修改:', row)
|
||||||
|
// 修改IOT设备
|
||||||
|
this.title = '修改设备'
|
||||||
|
this.IOTOpen = true
|
||||||
|
this.isEdit = true
|
||||||
|
this.getDeviceType()
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.IOTForm.resetFields()
|
||||||
|
this.IOTForm = {
|
||||||
|
iotId: row.iotId,
|
||||||
|
iotType: row.iotType,
|
||||||
|
iotCode: row.iotCode,
|
||||||
|
iotStatus: row.iotStatus,
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(err => {
|
},
|
||||||
console.log('🚀 ~ submit ~ err:', err)
|
handleDelete(row) {
|
||||||
|
console.log('🚀 ~ handleDelete ~ 删除:', row)
|
||||||
|
// 弹框提示
|
||||||
|
this.$confirm('是否删除该设备?', '系统提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
})
|
})
|
||||||
}
|
.then(() => {
|
||||||
})
|
// 删除
|
||||||
|
deleteIotById(row.iotId).then((res) => {
|
||||||
|
// 提示
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '删除成功',
|
||||||
|
})
|
||||||
|
this.getList()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.$message({
|
||||||
|
type: 'info',
|
||||||
|
message: '已取消删除',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleUnbind(row) {
|
||||||
|
try {
|
||||||
|
const params = {
|
||||||
|
id: undefined,
|
||||||
|
iotId: row.iotId,
|
||||||
|
maCode: '',
|
||||||
|
typeId: undefined,
|
||||||
|
}
|
||||||
|
console.log('🚀 ~ handleUnbind ~ 解绑', row)
|
||||||
|
this.$confirm('确定解绑设备吗?', '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(async () => {
|
||||||
|
let { data } = await getRecordListAll({
|
||||||
|
iotId: params.iotId,
|
||||||
|
})
|
||||||
|
console.log('🚀 ~ .then ~ res:', data)
|
||||||
|
data.forEach((item) => {
|
||||||
|
if (!item.unBindTime) {
|
||||||
|
params.maCode = item.maCode
|
||||||
|
params.typeId = item.typeId
|
||||||
|
params.id = item.id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
console.log('🚀 ~ .then ~ maCode:', params)
|
||||||
|
await unbindIot(params)
|
||||||
|
this.$message.success('解绑成功')
|
||||||
|
this.getList()
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log('🚀 ~ handleUnbind ~ err:', err)
|
||||||
|
this.$message.info('已取消解绑')
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
console.log('🚀 ~ handleUnbind ~ error', err)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
selectionChange(val) {
|
||||||
|
console.log('🚀 ~ selectionChange ~ val:', val)
|
||||||
|
},
|
||||||
|
// 确认提交
|
||||||
|
submit() {
|
||||||
|
this.$refs.IOTForm.validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
console.log('🚀 ~ submit ~ 确认提交', this.IOTForm)
|
||||||
|
let params = {}
|
||||||
|
if (this.isEdit) {
|
||||||
|
// 修改
|
||||||
|
params = {
|
||||||
|
...this.IOTForm,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 添加
|
||||||
|
params = {
|
||||||
|
...this.IOTForm,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
addOrUpdate(params)
|
||||||
|
.then((res) => {
|
||||||
|
this.IOTOpen = false
|
||||||
|
// 提示 isEdit ? '修改成功' : '添加成功'
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: this.isEdit ? '修改成功' : '添加成功',
|
||||||
|
})
|
||||||
|
this.getList()
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log('🚀 ~ submit ~ err:', err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.qrCodeImg {
|
.qrCodeImg {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
.maCode {
|
.maCode {
|
||||||
margin-top: 15px;
|
margin-top: 15px;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,7 @@
|
||||||
<span>({{ deviceType }})</span>
|
<span>({{ deviceType }})</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="equipment">
|
<div class="equipment"> 定位设备编号: {{ iotCode }} </div>
|
||||||
定位设备编号: {{ equipmentNumber }}
|
|
||||||
</div>
|
|
||||||
<div class="equipment" v-if="false">{{ engineering }}工程</div>
|
<div class="equipment" v-if="false">{{ engineering }}工程</div>
|
||||||
<el-row :gutter="24">
|
<el-row :gutter="24">
|
||||||
<el-col :span="16">
|
<el-col :span="16">
|
||||||
|
|
@ -253,6 +251,10 @@ export default {
|
||||||
},
|
},
|
||||||
/** 查询按钮 */
|
/** 查询按钮 */
|
||||||
async handleQuery() {
|
async handleQuery() {
|
||||||
|
if (this.queryForm.date.length < 1) {
|
||||||
|
this.$message.error('请选择时间范围!')
|
||||||
|
return
|
||||||
|
}
|
||||||
this.tripParams.iotId = this.iotCode
|
this.tripParams.iotId = this.iotCode
|
||||||
const res = await getIotDeviceTripApi({ ...this.tripParams })
|
const res = await getIotDeviceTripApi({ ...this.tripParams })
|
||||||
console.log(res, '行程信息--')
|
console.log(res, '行程信息--')
|
||||||
|
|
|
||||||
|
|
@ -125,8 +125,7 @@
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<el-row :gutter="10" class="mb8">
|
<el-row :gutter="10" class="mb8">
|
||||||
<el-col :span="1.5">
|
<!-- <el-col :span="1.5">
|
||||||
<!-- 推送 -->
|
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
plain
|
plain
|
||||||
|
|
@ -135,7 +134,7 @@
|
||||||
:disabled="ids.length == 0"
|
:disabled="ids.length == 0"
|
||||||
>推送租赁平台</el-button
|
>推送租赁平台</el-button
|
||||||
>
|
>
|
||||||
</el-col>
|
</el-col> -->
|
||||||
<right-toolbar
|
<right-toolbar
|
||||||
:showSearch.sync="showSearch"
|
:showSearch.sync="showSearch"
|
||||||
@queryTable="getList"
|
@queryTable="getList"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue