feat:【IoT 物联网】增加配置推送哈

pull/790/head
YunaiV 2025-06-20 09:36:27 +08:00
parent df54780b65
commit 983699f636
3 changed files with 39 additions and 1 deletions

View File

@ -20,13 +20,16 @@
保存
</el-button>
<el-button v-else @click="enableEdit"></el-button>
<!-- TODO @芋艿缺一个下发按钮 -->
<el-button v-if="!isEditing" type="success" @click="handleConfigPush" :loading="pushLoading">
配置推送
</el-button>
</div>
</div>
</template>
<script lang="ts" setup>
import { DeviceApi, DeviceVO } from '@/api/iot/device/device'
import { IotDeviceMessageMethodEnum } from '@/views/iot/utils/constants'
import { jsonParse } from '@/utils'
import { isEmpty } from '@/utils/is'
@ -42,6 +45,7 @@ const emit = defineEmits<{
const message = useMessage()
const loading = ref(false) //
const pushLoading = ref(false) //
const config = ref<any>({}) // config
const hasJsonError = ref(false) // JSON
@ -74,6 +78,32 @@ const saveConfig = async () => {
isEditing.value = false
}
/** 配置推送处理函数 */
const handleConfigPush = async () => {
try {
//
await message.confirm('确定要推送配置到设备吗?此操作将远程更新设备配置。', '配置推送确认')
pushLoading.value = true
//
await DeviceApi.sendDeviceMessage({
deviceId: props.device.id,
method: IotDeviceMessageMethodEnum.CONFIG_PUSH.method,
params: config.value
})
message.success('配置推送成功!')
} catch (error) {
if (error !== 'cancel') {
message.error('配置推送失败!')
console.error('配置推送错误:', error)
}
} finally {
pushLoading.value = false
}
}
/** 更新设备配置 */
const updateDeviceConfig = async () => {
try {

View File

@ -30,6 +30,7 @@
</el-button>
</el-button-group>
</el-form-item>
<!-- TODO @芋艿参考阿里云实时刷新 -->
<el-form-item>
<el-switch
size="large"

View File

@ -43,5 +43,12 @@ export const IotDeviceMessageMethodEnum = {
method: 'thing.service.invoke',
name: '服务调用',
upstream: false
},
// ========== 设备配置 ==========
CONFIG_PUSH: {
method: 'thing.config.push',
name: '配置推送',
upstream: false
}
}