Commit 068dec34 authored by 小费同学阿's avatar 小费同学阿 💬

uhf功能修复-筛选

parent 334a776d
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
<!--展示页--> <!--展示页-->
<div class="" style="margin-bottom: 10px;font-size: 60px">{{ resultInfo.length }}</div> <div class="" style="margin-bottom: 10px;font-size: 60px">{{ resultInfo.length }}</div>
<el-table :data="tableList" style="width: 100%"> <el-table :data="tableList" style="width: 100%">
<el-table-column prop="typeId" label="ID" min-width="210rpx" /> <el-table-column prop="typeId" label="ID" min-width="220" />
<el-table-column prop="rssi" label="RSSI" min-width="60rpx" /> <el-table-column prop="rssi" label="RSSI" min-width="60" />
<el-table-column label="操作" min-width="100rpx"> <el-table-column label="操作" min-width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button @click="handleFilter(scope.row)">筛选</el-button> <el-button @click="handleFilter(scope.row)">筛选</el-button>
</template> </template>
...@@ -103,20 +103,6 @@ export default { ...@@ -103,20 +103,6 @@ export default {
data() { data() {
return { return {
// 假数据 // 假数据
tableList: [
{ typeId: 1, rssi: -55 },
{ typeId: 2, rssi: -65 },
{ typeId: 3, rssi: -45 },
{ typeId: 4, rssi: -75 },
{ typeId: 5, rssi: -40 }
],
// 定义音量范围数组
volumeRanges: [
['0', '-30', 5],
['-31', '-50', 4],
['-51', '-90', 3],
['-91', '-1000', 2]
],
selectValue: '', selectValue: '',
selectValueList: [], selectValueList: [],
dialogVisible: false, // 控制对话框显示与隐藏 dialogVisible: false, // 控制对话框显示与隐藏
...@@ -160,42 +146,28 @@ export default { ...@@ -160,42 +146,28 @@ export default {
}) })
}, },
methods: { methods: {
// 处理筛选并匹配音量值
matchVolumeRange(rssi, volumeRanges) {
for (let i = 0; i < volumeRanges.length; i++) {
const range = volumeRanges[i]
const start = parseInt(range[0], 10) // 将字符串转换为整数
const end = parseInt(range[1], 10) // 将字符串转换为整数
const parsedRssi = parseInt(rssi, 10)
if (parsedRssi <= start && parsedRssi >= end) {
return range[2] // 返回匹配的音量等级
}
}
return null // 如果没有匹配,返回null
},
// 清除筛选值 // 清除筛选值
clearSelect() { clearSelect() {
this.dialogVisibleSelect = false this.dialogVisibleSelect = false
this.selectValue = '' this.selectValue = ''
this.selectValueList = [] this.selectValueList = []
}, },
// 点击当条筛选值 // 点击当条筛选值
handleFilter(row) { handleFilter(row) {
console.log('当前行的RSSI值:', row.rssi) console.log('当前行的typeId值:', row.typeId)
// 检查元素是否已经存在于数组中 // 检查元素是否已经存在于数组中
if (!this.selectValueList.includes(row.rssi)) { if (!this.selectValueList.includes(row.typeId)) {
// 如果不存在,则添加到数组中 // 如果不存在,则添加到数组中
this.selectValueList.push(row.rssi) this.selectValueList.push(row.typeId)
// 给筛选设置设置默认值,将数组中的元素用逗号拼接 // 给筛选设置设置默认值,将数组中的元素用逗号拼接
this.selectValue = this.selectValueList.join(',') this.selectValue = this.selectValueList.join(',')
console.log('打印selectValueList值:', this.selectValueList) console.log('打印selectValueList值:', this.selectValueList)
console.log('打印selectValue值:', this.selectValue) console.log('打印selectValue值:', this.selectValue)
// 匹配音量值并打印结果
const matchedVolumes = this.selectValueList.map(rssi => this.matchVolumeRange(rssi, this.volumeRanges))
console.log('匹配的音量值数组:', matchedVolumes)
} else { } else {
// 如果已存在,可以在这里添加一些逻辑,比如打印一条消息或者什么都不做 // 如果已存在,可以在这里添加一些逻辑,比如打印一条消息或者什么都不做
console.log('该RSSI值已存在,不再添加。') console.log('该typeId值已存在,不再添加。')
console.log('打印selectValueList值:', this.selectValueList) console.log('打印selectValueList值:', this.selectValueList)
console.log('打印selectValue值:', this.selectValue) console.log('打印selectValue值:', this.selectValue)
} }
...@@ -229,8 +201,10 @@ export default { ...@@ -229,8 +201,10 @@ export default {
this.startState = true this.startState = true
const params = { const params = {
flag: 'startPower', flag: 'startPower',
selectValue: this.selectValueList,
tokenMsg: getToken() tokenMsg: getToken()
} }
// 补充逻辑:如果设置筛选有值就调筛选逻辑,传id过去,筛选没值就不传id过去
this.$WebView.startPower(params).then(res => { this.$WebView.startPower(params).then(res => {
this.imgUrlForm = JSON.parse(res) this.imgUrlForm = JSON.parse(res)
}) })
...@@ -335,7 +309,6 @@ export default { ...@@ -335,7 +309,6 @@ export default {
console.log('调用前', getToken()) console.log('调用前', getToken())
const params = { const params = {
flag: 'addVolume', flag: 'addVolume',
subPath: 'jbcheck',
tokenMsg: getToken() tokenMsg: getToken()
} }
this.$WebView.addVolume(params).then(res => { this.$WebView.addVolume(params).then(res => {
...@@ -349,7 +322,6 @@ export default { ...@@ -349,7 +322,6 @@ export default {
console.log('调用前', getToken()) console.log('调用前', getToken())
const params = { const params = {
flag: 'reduceVolume', flag: 'reduceVolume',
subPath: 'jbcheck',
tokenMsg: getToken() tokenMsg: getToken()
} }
this.$WebView.reduceVolume(params).then(res => { this.$WebView.reduceVolume(params).then(res => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment