【类 型】:feat 读取参数
【原 因】: 【过 程】:像非空请求参数 有返回值 显示参数值 【影 响】:
This commit is contained in:
parent
b89b1894fd
commit
8a59e75e29
@ -84,12 +84,14 @@
|
|||||||
@click="publishFun('{initAcce:2}')" type="primary">已摆好</el-button>
|
@click="publishFun('{initAcce:2}')" type="primary">已摆好</el-button>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<!-- 写入参数 -->
|
<!-- 读写参数 -->
|
||||||
<template v-else-if="dialogItem === 'paramBox'">
|
<template v-else-if="dialogItem === 'paramBox'">
|
||||||
<el-input v-model="paramItem" placeholder="参数名"></el-input>
|
<el-input v-model="paramItem" placeholder="参数名"></el-input>
|
||||||
<el-input v-model="paramValue" placeholder="值" class="m-t-20"></el-input>
|
<el-input v-model="paramValue" placeholder="值" class="m-t-20"></el-input>
|
||||||
<span slot="footer" class="dialog-footer">
|
<span slot="footer" class="dialog-footer">
|
||||||
<el-button size="medium" @click="dialogVisible = false">关闭</el-button>
|
<el-button size="medium" @click="dialogVisible = false">关闭</el-button>
|
||||||
|
<el-button size="medium" type="primary"
|
||||||
|
@click="paramValue = '';clearPlanePar(); publishFun(`{'getParam':'${paramItem}'}`);">读取</el-button>
|
||||||
<el-button size="medium" type="primary"
|
<el-button size="medium" type="primary"
|
||||||
@click="publishFun(`{'setParam':{'item':'${paramItem}','value':'${paramValue}'}}`)">写入</el-button>
|
@click="publishFun(`{'setParam':{'item':'${paramItem}','value':'${paramValue}'}}`)">写入</el-button>
|
||||||
</span>
|
</span>
|
||||||
@ -308,9 +310,9 @@
|
|||||||
<div class="m-t-5">加速度计</div>
|
<div class="m-t-5">加速度计</div>
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button size="medium" type="primary" class="flex1 butIcon"
|
<el-button size="medium" type="primary" class="flex1 butIcon"
|
||||||
@click="speakText('写入参数'); dialogVisible = true; dialogTitle = '写入参数'; dialogItem = 'paramBox';">
|
@click="speakText('读写参数'); dialogVisible = true; dialogTitle = '读写参数'; dialogItem = 'paramBox';">
|
||||||
<i class="iconfont icon-canshupeizhi f-s-24"></i>
|
<i class="iconfont icon-canshupeizhi f-s-24"></i>
|
||||||
<div class="m-t-5">写入参数</div>
|
<div class="m-t-5">读写参数</div>
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -355,8 +357,8 @@ export default {
|
|||||||
id: ''
|
id: ''
|
||||||
},
|
},
|
||||||
waringTags: [], // 任务栏 提示标签 有退款 超重 等
|
waringTags: [], // 任务栏 提示标签 有退款 超重 等
|
||||||
paramItem: '', // 写入参数 键
|
paramItem: '', // 参数 键
|
||||||
paramValue: ''// 写入参数 值
|
paramValue: ''// 参数 值
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
@ -453,6 +455,15 @@ export default {
|
|||||||
return this.plane.planeState.acceState
|
return this.plane.planeState.acceState
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* @description: 从飞控获取的参数键值对
|
||||||
|
*/
|
||||||
|
parameterValue () {
|
||||||
|
if (this.plane && this.plane.planeState && this.plane.planeState.parameterValue) {
|
||||||
|
return this.plane.planeState.parameterValue
|
||||||
|
}
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -956,6 +967,11 @@ export default {
|
|||||||
this.waringTags.splice(dIndex, 1)
|
this.waringTags.splice(dIndex, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
// 飞机状态参数默认值 复位
|
||||||
|
clearPlanePar () {
|
||||||
|
// 调用 Vuex 的 mutation 更新对应飞机的 parameterValue
|
||||||
|
this.$store.commit('updateParameterValue', { planeId: this.$route.params.id, parameterValue: '{}' })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
@ -1001,6 +1017,21 @@ export default {
|
|||||||
if (!found) {
|
if (!found) {
|
||||||
this.questForm.id = ''
|
this.questForm.id = ''
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
// 监听parameterValue 对比飞控更新的 参数名 和 要读取的参数名一致 把值显示出来
|
||||||
|
parameterValue (val) {
|
||||||
|
// 反序列化 JSON 字符串
|
||||||
|
const parsed = JSON.parse(val)
|
||||||
|
|
||||||
|
// 假设 JSON 只有一个键值对,提取参数名和值
|
||||||
|
const key = Object.keys(parsed)[0] // 获取键名
|
||||||
|
const value = parsed[key] // 获取键对应的值
|
||||||
|
|
||||||
|
// 更新 data 中的 paramName 和 paramValue
|
||||||
|
if (key === this.paramItem) {
|
||||||
|
this.paramValue = value
|
||||||
|
}
|
||||||
|
this.paramName = key
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
destroyed () {
|
destroyed () {
|
||||||
|
@ -43,6 +43,15 @@ const store = new Vuex.Store({
|
|||||||
setAirList (state, list) {
|
setAirList (state, list) {
|
||||||
state.airList = list
|
state.airList = list
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* @description:更新飞机的 parameterValue
|
||||||
|
*/
|
||||||
|
updateParameterValue (state, { planeId, parameterValue }) {
|
||||||
|
const plane = state.airList.find(plane => plane.id === planeId) // 根据 planeId 查找飞机
|
||||||
|
if (plane) {
|
||||||
|
plane.planeState.parameterValue = parameterValue // 更新 parameterValue
|
||||||
|
}
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* @description: 设置站点列表
|
* @description: 设置站点列表
|
||||||
*/
|
*/
|
||||||
@ -288,7 +297,8 @@ const store = new Vuex.Store({
|
|||||||
position: [], // [[经度,维度,相对高度]]累计数组
|
position: [], // [[经度,维度,相对高度]]累计数组
|
||||||
battCapacity: null, // 电池容量
|
battCapacity: null, // 电池容量
|
||||||
homePosition: null, // 返航点位置
|
homePosition: null, // 返航点位置
|
||||||
wpnavSpeed: null// 飞机返航速度 米/秒
|
wpnavSpeed: null, // 飞机返航速度 米/秒
|
||||||
|
parameterValue: null// 请求的参数键值对 需要序列化
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (res.data.status === 1) {
|
if (res.data.status === 1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user