代码优化

This commit is contained in:
BianLzhaoMin 2024-08-09 13:53:32 +08:00
parent 440198e36b
commit 354f3f5ac5
4 changed files with 503 additions and 396 deletions

View File

@ -6,21 +6,15 @@
// 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='
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='
} else {
qrUrl = 'http://192.168.0.14:18866/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='
export default {
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,
// }

View File

@ -1,52 +1,104 @@
<template>
<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
:model="queryForm"
ref="queryForm"
size="small"
:inline="true"
label-width="68px"
v-show="showSearch"
>
<el-form-item label="关键字" prop="keyWord">
<el-input v-model="queryForm.keyWord" clearable placeholder="请输入关键字" @keyup.enter.native="handleQuery" />
<el-input
v-model="queryForm.keyWord"
clearable
placeholder="请输入关键字"
@keyup.enter.native="handleQuery"
/>
</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-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>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table :data="tableData" style="width: 100%" @selection-change="selectionChange">
<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)"
:index="
indexContinuation(queryParams.pageNum, queryParams.pageSize)
"
/>
<el-table-column
label="设备类型"
prop="iotTypeName"
align="center"
/>
<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>
<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>
<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>
<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"
@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"
@ -80,33 +132,69 @@
/>
<!-- 二维码弹框 -->
<el-dialog title="查看二维码" :visible.sync="uploadOpen" width="500px" append-to-body>
<el-dialog
title="查看二维码"
:visible.sync="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>
<div
slot="footer"
class="dialog-footer"
style="text-align: center"
></div>
</el-dialog>
<!-- 添加/修改 设备弹框 -->
<el-dialog :title="title" :visible.sync="IOTOpen" width="500px" append-to-body>
<el-form :model="IOTForm" ref="IOTForm" label-width="120px" size="small" :rules="rules">
<el-dialog
: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
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-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="掉线"
inactive-text="线"
:active-value="0"
:inactive-value="1"
/>
@ -126,7 +214,13 @@
<script>
import BindDetails from './component/BindDetails'
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 {
name: 'IOTequipment',
components: {
@ -155,22 +249,32 @@ export default {
iotStatus: '',
},
options: [
{
value: '125',
label: '定位设备',
},
{
value: '126',
label: '检测设备',
},
// {
// value: '125',
// label: '',
// },
// {
// value: '126',
// label: '',
// },
],
title: '',
IOTOpen: false,
//
rules: {
iotType: [{ required: true, message: '请选择设备类型', trigger: 'change' }],
iotType: [
{
required: true,
message: '请选择设备类型',
trigger: 'change',
},
],
iotCode: [
{ required: true, message: '请输入设备编号', trigger: 'blur' },
{
required: true,
message: '请输入设备编号',
trigger: 'blur',
},
{
// 线(-) 线(_)
pattern: /^[a-zA-Z0-9_-]+$/,
@ -200,16 +304,22 @@ export default {
console.log('🚀 ~ getList ~ 获取列表', params)
getIotList(params)
.then(res => {
.then((res) => {
this.tableData = res.rows
this.total = res.total
})
.catch(err => {
.catch((err) => {
console.log('🚀 ~ getList ~ err:', err)
})
},
//
getDeviceType() {
async getDeviceType() {
try {
const res = await selectList()
this.options = res.data
} catch (err) {
console.log('🚀 ~ getIotType ~ err:', err)
}
// ()
// .then(res => {
// this.options = res.data
@ -299,7 +409,7 @@ export default {
})
.then(() => {
//
deleteIotById(row.iotId).then(res => {
deleteIotById(row.iotId).then((res) => {
//
this.$message({
type: 'success',
@ -330,9 +440,11 @@ export default {
type: 'warning',
})
.then(async () => {
let { data } = await getRecordListAll({ iotId: params.iotId })
let { data } = await getRecordListAll({
iotId: params.iotId,
})
console.log('🚀 ~ .then ~ res:', data)
data.forEach(item => {
data.forEach((item) => {
if (!item.unBindTime) {
params.maCode = item.maCode
params.typeId = item.typeId
@ -357,7 +469,7 @@ export default {
},
//
submit() {
this.$refs.IOTForm.validate(valid => {
this.$refs.IOTForm.validate((valid) => {
if (valid) {
console.log('🚀 ~ submit ~ 确认提交', this.IOTForm)
let params = {}
@ -373,7 +485,7 @@ export default {
}
}
addOrUpdate(params)
.then(res => {
.then((res) => {
this.IOTOpen = false
// isEdit ? '' : ''
this.$message({
@ -382,7 +494,7 @@ export default {
})
this.getList()
})
.catch(err => {
.catch((err) => {
console.log('🚀 ~ submit ~ err:', err)
})
}

View File

@ -13,9 +13,7 @@
<span>({{ deviceType }})</span>
</div>
<div class="equipment">
定位设备编号: {{ equipmentNumber }}
</div>
<div class="equipment"> 定位设备编号: {{ iotCode }} </div>
<div class="equipment" v-if="false">{{ engineering }}工程</div>
<el-row :gutter="24">
<el-col :span="16">
@ -253,6 +251,10 @@ export default {
},
/** 查询按钮 */
async handleQuery() {
if (this.queryForm.date.length < 1) {
this.$message.error('请选择时间范围!')
return
}
this.tripParams.iotId = this.iotCode
const res = await getIotDeviceTripApi({ ...this.tripParams })
console.log(res, '行程信息--')

View File

@ -125,8 +125,7 @@
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<!-- 推送 -->
<!-- <el-col :span="1.5">
<el-button
type="primary"
plain
@ -135,7 +134,7 @@
:disabled="ids.length == 0"
>推送租赁平台</el-button
>
</el-col>
</el-col> -->
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"