代码优化

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 = '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,
// }

View File

@ -1,52 +1,104 @@
<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
:model="queryForm"
ref="queryForm"
size="small"
:inline="true"
label-width="68px"
v-show="showSearch"
>
<el-form-item label="关键字" prop="keyWord"> <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-form-item> <el-form-item>
<el-button type="primary" size="small" @click="handleQuery">搜索</el-button> <el-button type="primary" size="small" @click="handleQuery"
<el-button type="primary" size="small" @click="addIOT">添加设备</el-button> >搜索</el-button
<el-button type="primary" size="small" @click="downloadQRCord">下载二维码</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-item>
</el-form> </el-form>
<el-row :gutter="10" class="mb8"> <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-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="selection" width="55" align="center" />
<el-table-column <el-table-column
type="index" type="index"
label="序号" label="序号"
align="center" align="center"
width="55" 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="iotCode" align="center" />
<el-table-column label="设备状态" prop="iotStatus" align="center"> <el-table-column label="设备状态" prop="iotStatus" align="center">
<template v-slot="{ row }"> <template v-slot="{ row }">
<el-tag v-if="row.iotStatus == 0" type="success">在线</el-tag> <el-tag size="mini" v-if="row.iotStatus == 0" type="success"
<el-tag v-else type="danger">掉线</el-tag> >在线</el-tag
>
<el-tag size="mini" v-else type="danger">下线</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="prCode" label="二维码" align="center"> <el-table-column prop="prCode" label="二维码" align="center">
<template v-slot="{ row }"> <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> </template>
</el-table-column> </el-table-column>
<el-table-column label="状态" align="center"> <el-table-column label="状态" align="center">
<template v-slot="{ row }"> <template v-slot="{ row }">
<el-tag v-if="row.bindStatus == 0" type="success">已绑定</el-tag> <el-tag
<el-tag v-else type="danger">未绑定</el-tag> v-if="row.bindStatus == 0"
type="success"
size="mini"
>已绑定</el-tag
>
<el-tag v-else type="warning" size="mini">未绑定</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center"> <el-table-column label="操作" align="center">
<template v-slot="{ row }"> <template v-slot="{ row }">
<el-button type="text" size="small" @click="handleCheck(row)" icon="el-icon-view">记录</el-button> <el-button
<el-button type="text" size="small" @click="handleEdit(row)" icon="el-icon-edit-outline">修改</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 <el-button
type="text" type="text"
size="small" 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 style="text-align: center">
<div class="qrCodeImg"> <div class="qrCodeImg">
<div id="qrcode" class="qrcode" ref="codeItem"></div> <div id="qrcode" class="qrcode" ref="codeItem"></div>
</div> </div>
<div class="maCode">二维码编号{{ rowObj.qrCode }}</div> <div class="maCode">二维码编号{{ rowObj.qrCode }}</div>
</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>
<!-- 添加/修改 设备弹框 --> <!-- 添加/修改 设备弹框 -->
<el-dialog :title="title" :visible.sync="IOTOpen" width="500px" append-to-body> <el-dialog
<el-form :model="IOTForm" ref="IOTForm" label-width="120px" size="small" :rules="rules"> :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-form-item label="设备类型: " prop="iotType">
<el-select v-model="IOTForm.iotType" filterable clearable placeholder="请选择设备类型" style="width: 280px"> <el-select
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" /> 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-select>
</el-form-item> </el-form-item>
<el-form-item label="设备编号: " prop="iotCode"> <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> </el-form-item>
<!-- 修改设备状态: 使用Switch开关 --> <!-- 修改设备状态: 使用Switch开关 -->
<el-form-item label="设备状态: " prop="iotStatus" v-if="isEdit"> <el-form-item label="设备状态: " prop="iotStatus" v-if="isEdit">
<el-switch <el-switch
v-model="IOTForm.iotStatus" v-model="IOTForm.iotStatus"
active-text="在线" active-text="在线"
inactive-text="掉线" inactive-text="线"
:active-value="0" :active-value="0"
:inactive-value="1" :inactive-value="1"
/> />
@ -126,7 +214,13 @@
<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: {
@ -155,22 +249,32 @@ export default {
iotStatus: '', iotStatus: '',
}, },
options: [ options: [
{ // {
value: '125', // value: '125',
label: '定位设备', // label: '',
}, // },
{ // {
value: '126', // value: '126',
label: '检测设备', // label: '',
}, // },
], ],
title: '', title: '',
IOTOpen: false, IOTOpen: false,
// //
rules: { rules: {
iotType: [{ required: true, message: '请选择设备类型', trigger: 'change' }], iotType: [
{
required: true,
message: '请选择设备类型',
trigger: 'change',
},
],
iotCode: [ iotCode: [
{ required: true, message: '请输入设备编号', trigger: 'blur' }, {
required: true,
message: '请输入设备编号',
trigger: 'blur',
},
{ {
// 线(-) 线(_) // 线(-) 线(_)
pattern: /^[a-zA-Z0-9_-]+$/, pattern: /^[a-zA-Z0-9_-]+$/,
@ -200,16 +304,22 @@ export default {
console.log('🚀 ~ getList ~ 获取列表', params) 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 {
const res = await selectList()
this.options = res.data
} catch (err) {
console.log('🚀 ~ getIotType ~ err:', err)
}
// () // ()
// .then(res => { // .then(res => {
// this.options = res.data // this.options = res.data
@ -299,7 +409,7 @@ export default {
}) })
.then(() => { .then(() => {
// //
deleteIotById(row.iotId).then(res => { deleteIotById(row.iotId).then((res) => {
// //
this.$message({ this.$message({
type: 'success', type: 'success',
@ -330,9 +440,11 @@ export default {
type: 'warning', type: 'warning',
}) })
.then(async () => { .then(async () => {
let { data } = await getRecordListAll({ iotId: params.iotId }) let { data } = await getRecordListAll({
iotId: params.iotId,
})
console.log('🚀 ~ .then ~ res:', data) console.log('🚀 ~ .then ~ res:', data)
data.forEach(item => { data.forEach((item) => {
if (!item.unBindTime) { if (!item.unBindTime) {
params.maCode = item.maCode params.maCode = item.maCode
params.typeId = item.typeId params.typeId = item.typeId
@ -357,7 +469,7 @@ export default {
}, },
// //
submit() { submit() {
this.$refs.IOTForm.validate(valid => { this.$refs.IOTForm.validate((valid) => {
if (valid) { if (valid) {
console.log('🚀 ~ submit ~ 确认提交', this.IOTForm) console.log('🚀 ~ submit ~ 确认提交', this.IOTForm)
let params = {} let params = {}
@ -373,7 +485,7 @@ export default {
} }
} }
addOrUpdate(params) addOrUpdate(params)
.then(res => { .then((res) => {
this.IOTOpen = false this.IOTOpen = false
// isEdit ? '' : '' // isEdit ? '' : ''
this.$message({ this.$message({
@ -382,7 +494,7 @@ export default {
}) })
this.getList() this.getList()
}) })
.catch(err => { .catch((err) => {
console.log('🚀 ~ submit ~ err:', err) console.log('🚀 ~ submit ~ err:', err)
}) })
} }

View File

@ -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, '行程信息--')

View File

@ -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"