【类 型】:feat 读取参数

【原  因】:
【过  程】:像非空请求参数 有返回值 显示参数值
【影  响】:
This commit is contained in:
tk 2024-10-12 20:19:59 +08:00
parent b89b1894fd
commit 8a59e75e29
2 changed files with 47 additions and 6 deletions

View File

@ -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 () {

View File

@ -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) {