review:【iot 物联网】场景联动的逻辑
parent
e53a676bf6
commit
18573d6206
|
@ -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()
|
||||
})
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 @puhui999:unocss,看看哪些可以搞掉哈。 */
|
||||
/* 弹出层内容样式 */
|
||||
.json-params-detail-content {
|
||||
padding: 4px 0;
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
/>
|
||||
|
||||
<!-- 定时触发配置 -->
|
||||
<!-- TODO @puhui999:改成定时触发配置后,就改不回来了。 -->
|
||||
<TimerTriggerConfig
|
||||
v-else-if="triggerItem.type === TriggerTypeEnum.TIMER"
|
||||
:model-value="triggerItem.cronExpression"
|
||||
|
|
Loading…
Reference in New Issue