review:【iot 物联网】场景联动的逻辑

pull/808/head
YunaiV 2025-08-06 22:01:35 +08:00
parent e53a676bf6
commit 18573d6206
4 changed files with 18 additions and 38 deletions

View File

@ -50,6 +50,7 @@
<!-- 服务参数配置 -->
<div v-if="action.identifier" class="space-y-16px">
<el-form-item label="服务参数" required>
<!-- TODO@puhui999这里有个 idea 告警 -->
<JsonParamsInput
v-model="paramsValue"
type="service"
@ -102,7 +103,7 @@ const emit = defineEmits<{
const action = useVModel(props, 'modelValue', emit)
//
//
const thingModelProperties = ref<ThingModelProperty[]>([]) //
const loadingThingModel = ref(false) //
const selectedService = ref<ThingModelService | null>(null) //
@ -126,6 +127,7 @@ const paramsValue = computed({
})
//
// TODO @puhui999
const handleParamsValidate = (result: { valid: boolean; message: string }) => {
//
console.log('参数验证结果:', result)
@ -165,10 +167,7 @@ const handleProductChange = (productId?: number) => {
}
}
/**
* 处理设备变化事件
* @param deviceId 设备ID
*/
/** 处理设备变化事件 */
const handleDeviceChange = (deviceId?: number) => {
//
if (action.value.deviceId !== deviceId) {
@ -176,10 +175,7 @@ const handleDeviceChange = (deviceId?: number) => {
}
}
/**
* 处理服务变化事件
* @param serviceIdentifier 服务标识符
*/
/** 处理服务变化事件 */
const handleServiceChange = (serviceIdentifier?: string) => {
//
const service = serviceList.value.find((s) => s.identifier === serviceIdentifier) || null
@ -200,13 +196,10 @@ const handleServiceChange = (serviceIdentifier?: string) => {
}
/**
* 获取物模型TSL数据
* @param productId 产品ID
* @returns 物模型TSL数据
* 获取物模型 TSL 数据
*/
const getThingModelTSL = async (productId: number) => {
if (!productId) return null
try {
return await ThingModelApi.getThingModelTSLByProductId(productId)
} catch (error) {
@ -215,10 +208,7 @@ const getThingModelTSL = async (productId: number) => {
}
}
/**
* 加载物模型属性可写属性
* @param productId 产品ID
*/
/** 加载物模型属性(可写属性)*/
const loadThingModelProperties = async (productId: number) => {
if (!productId) {
thingModelProperties.value = []
@ -249,16 +239,12 @@ const loadThingModelProperties = async (productId: number) => {
}
}
/**
* 加载服务列表
* @param productId 产品ID
*/
/** 加载服务列表 */
const loadServiceList = async (productId: number) => {
if (!productId) {
serviceList.value = []
return
}
try {
loadingServices.value = true
const tslData = await getThingModelTSL(productId)
@ -277,11 +263,7 @@ const loadServiceList = async (productId: number) => {
}
}
/**
* 从TSL加载服务信息用于编辑模式回显
* @param productId 产品ID
* @param serviceIdentifier 服务标识符
*/
/** 从 TSL 加载服务信息(用于编辑模式回显)*/
const loadServiceFromTSL = async (productId: number, serviceIdentifier: string) => {
//
await loadServiceList(productId)
@ -293,11 +275,7 @@ const loadServiceFromTSL = async (productId: number, serviceIdentifier: string)
}
}
/**
* 根据参数类型获取默认值
* @param param 参数对象
* @returns 默认值
*/
/** 根据参数类型获取默认值 */
const getDefaultValueForParam = (param: any) => {
switch (param.dataType) {
case 'int':
@ -323,9 +301,7 @@ const getDefaultValueForParam = (param: any) => {
//
const isInitialized = ref(false)
/**
* 初始化组件数据
*/
/** 初始化组件数据 */
const initializeComponent = async () => {
if (isInitialized.value) return
@ -346,9 +322,7 @@ const initializeComponent = async () => {
isInitialized.value = true
}
/**
* 组件初始化
*/
/** 组件初始化 */
onMounted(() => {
initializeComponent()
})

View File

@ -78,6 +78,7 @@
</el-col>
<!-- 值输入 -->
<!-- TODO @puhui999这种用 include 更简洁 -->
<el-col
:span="
triggerType === IotRuleSceneTriggerTypeEnum.DEVICE_SERVICE_INVOKE ||
@ -95,6 +96,7 @@
required
>
<!-- 服务调用参数配置 -->
<!-- TODO @puhui999中英文之间有个空格哈 -->
<JsonParamsInput
v-if="triggerType === IotRuleSceneTriggerTypeEnum.DEVICE_SERVICE_INVOKE"
v-model="condition.value"
@ -152,6 +154,7 @@
</el-col>
</el-row>
<!-- TODO @puhui999这个是不是跟阿里云还是一致一点哈 -->
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="操作符" required>

View File

@ -444,6 +444,7 @@ const generateExampleJson = () => {
}
//
// TODO @puhui999
const handleDataDisplay = (value: string) => {
if (!value || !value.trim()) {
paramsJson.value = ''
@ -504,6 +505,7 @@ watch(
</script>
<style scoped>
/** TODO @puhui999unocss看看哪些可以搞掉哈。 */
/* 弹出层内容样式 */
.json-params-detail-content {
padding: 4px 0;

View File

@ -66,6 +66,7 @@
/>
<!-- 定时触发配置 -->
<!-- TODO @puhui999改成定时触发配置后就改不回来了 -->
<TimerTriggerConfig
v-else-if="triggerItem.type === TriggerTypeEnum.TIMER"
:model-value="triggerItem.cronExpression"