review:【iot 物联网】场景联动的逻辑
This commit is contained in:
@ -50,6 +50,7 @@
|
|||||||
<!-- 服务参数配置 -->
|
<!-- 服务参数配置 -->
|
||||||
<div v-if="action.identifier" class="space-y-16px">
|
<div v-if="action.identifier" class="space-y-16px">
|
||||||
<el-form-item label="服务参数" required>
|
<el-form-item label="服务参数" required>
|
||||||
|
<!-- TODO@puhui999:这里有个 idea 告警 -->
|
||||||
<JsonParamsInput
|
<JsonParamsInput
|
||||||
v-model="paramsValue"
|
v-model="paramsValue"
|
||||||
type="service"
|
type="service"
|
||||||
@ -102,7 +103,7 @@ const emit = defineEmits<{
|
|||||||
|
|
||||||
const action = useVModel(props, 'modelValue', emit)
|
const action = useVModel(props, 'modelValue', emit)
|
||||||
|
|
||||||
// 简化后的状态变量
|
// 状态变量
|
||||||
const thingModelProperties = ref<ThingModelProperty[]>([]) // 物模型属性列表
|
const thingModelProperties = ref<ThingModelProperty[]>([]) // 物模型属性列表
|
||||||
const loadingThingModel = ref(false) // 物模型加载状态
|
const loadingThingModel = ref(false) // 物模型加载状态
|
||||||
const selectedService = ref<ThingModelService | null>(null) // 选中的服务对象
|
const selectedService = ref<ThingModelService | null>(null) // 选中的服务对象
|
||||||
@ -126,6 +127,7 @@ const paramsValue = computed({
|
|||||||
})
|
})
|
||||||
|
|
||||||
// 参数验证处理
|
// 参数验证处理
|
||||||
|
// TODO @puhui999:这个还需要哇?
|
||||||
const handleParamsValidate = (result: { valid: boolean; message: string }) => {
|
const handleParamsValidate = (result: { valid: boolean; message: string }) => {
|
||||||
// 可以在这里处理验证结果,比如显示错误信息
|
// 可以在这里处理验证结果,比如显示错误信息
|
||||||
console.log('参数验证结果:', result)
|
console.log('参数验证结果:', result)
|
||||||
@ -165,10 +167,7 @@ const handleProductChange = (productId?: number) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 处理设备变化事件 */
|
||||||
* 处理设备变化事件
|
|
||||||
* @param deviceId 设备ID
|
|
||||||
*/
|
|
||||||
const handleDeviceChange = (deviceId?: number) => {
|
const handleDeviceChange = (deviceId?: number) => {
|
||||||
// 当设备变化时,清空参数配置
|
// 当设备变化时,清空参数配置
|
||||||
if (action.value.deviceId !== deviceId) {
|
if (action.value.deviceId !== deviceId) {
|
||||||
@ -176,10 +175,7 @@ const handleDeviceChange = (deviceId?: number) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 处理服务变化事件 */
|
||||||
* 处理服务变化事件
|
|
||||||
* @param serviceIdentifier 服务标识符
|
|
||||||
*/
|
|
||||||
const handleServiceChange = (serviceIdentifier?: string) => {
|
const handleServiceChange = (serviceIdentifier?: string) => {
|
||||||
// 根据服务标识符找到对应的服务对象
|
// 根据服务标识符找到对应的服务对象
|
||||||
const service = serviceList.value.find((s) => s.identifier === serviceIdentifier) || null
|
const service = serviceList.value.find((s) => s.identifier === serviceIdentifier) || null
|
||||||
@ -200,13 +196,10 @@ const handleServiceChange = (serviceIdentifier?: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取物模型TSL数据
|
* 获取物模型 TSL 数据
|
||||||
* @param productId 产品ID
|
|
||||||
* @returns 物模型TSL数据
|
|
||||||
*/
|
*/
|
||||||
const getThingModelTSL = async (productId: number) => {
|
const getThingModelTSL = async (productId: number) => {
|
||||||
if (!productId) return null
|
if (!productId) return null
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await ThingModelApi.getThingModelTSLByProductId(productId)
|
return await ThingModelApi.getThingModelTSLByProductId(productId)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -215,10 +208,7 @@ const getThingModelTSL = async (productId: number) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 加载物模型属性(可写属性)*/
|
||||||
* 加载物模型属性(可写属性)
|
|
||||||
* @param productId 产品ID
|
|
||||||
*/
|
|
||||||
const loadThingModelProperties = async (productId: number) => {
|
const loadThingModelProperties = async (productId: number) => {
|
||||||
if (!productId) {
|
if (!productId) {
|
||||||
thingModelProperties.value = []
|
thingModelProperties.value = []
|
||||||
@ -249,16 +239,12 @@ const loadThingModelProperties = async (productId: number) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 加载服务列表 */
|
||||||
* 加载服务列表
|
|
||||||
* @param productId 产品ID
|
|
||||||
*/
|
|
||||||
const loadServiceList = async (productId: number) => {
|
const loadServiceList = async (productId: number) => {
|
||||||
if (!productId) {
|
if (!productId) {
|
||||||
serviceList.value = []
|
serviceList.value = []
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loadingServices.value = true
|
loadingServices.value = true
|
||||||
const tslData = await getThingModelTSL(productId)
|
const tslData = await getThingModelTSL(productId)
|
||||||
@ -277,11 +263,7 @@ const loadServiceList = async (productId: number) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 从 TSL 加载服务信息(用于编辑模式回显)*/
|
||||||
* 从TSL加载服务信息(用于编辑模式回显)
|
|
||||||
* @param productId 产品ID
|
|
||||||
* @param serviceIdentifier 服务标识符
|
|
||||||
*/
|
|
||||||
const loadServiceFromTSL = async (productId: number, serviceIdentifier: string) => {
|
const loadServiceFromTSL = async (productId: number, serviceIdentifier: string) => {
|
||||||
// 先加载服务列表
|
// 先加载服务列表
|
||||||
await loadServiceList(productId)
|
await loadServiceList(productId)
|
||||||
@ -293,11 +275,7 @@ const loadServiceFromTSL = async (productId: number, serviceIdentifier: string)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 根据参数类型获取默认值 */
|
||||||
* 根据参数类型获取默认值
|
|
||||||
* @param param 参数对象
|
|
||||||
* @returns 默认值
|
|
||||||
*/
|
|
||||||
const getDefaultValueForParam = (param: any) => {
|
const getDefaultValueForParam = (param: any) => {
|
||||||
switch (param.dataType) {
|
switch (param.dataType) {
|
||||||
case 'int':
|
case 'int':
|
||||||
@ -323,9 +301,7 @@ const getDefaultValueForParam = (param: any) => {
|
|||||||
// 防止重复初始化的标志
|
// 防止重复初始化的标志
|
||||||
const isInitialized = ref(false)
|
const isInitialized = ref(false)
|
||||||
|
|
||||||
/**
|
/** 初始化组件数据 */
|
||||||
* 初始化组件数据
|
|
||||||
*/
|
|
||||||
const initializeComponent = async () => {
|
const initializeComponent = async () => {
|
||||||
if (isInitialized.value) return
|
if (isInitialized.value) return
|
||||||
|
|
||||||
@ -346,9 +322,7 @@ const initializeComponent = async () => {
|
|||||||
isInitialized.value = true
|
isInitialized.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 组件初始化 */
|
||||||
* 组件初始化
|
|
||||||
*/
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
initializeComponent()
|
initializeComponent()
|
||||||
})
|
})
|
||||||
|
|||||||
@ -78,6 +78,7 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
<!-- 值输入 -->
|
<!-- 值输入 -->
|
||||||
|
<!-- TODO @puhui999:这种用 include 更简洁 -->
|
||||||
<el-col
|
<el-col
|
||||||
:span="
|
:span="
|
||||||
triggerType === IotRuleSceneTriggerTypeEnum.DEVICE_SERVICE_INVOKE ||
|
triggerType === IotRuleSceneTriggerTypeEnum.DEVICE_SERVICE_INVOKE ||
|
||||||
@ -95,6 +96,7 @@
|
|||||||
required
|
required
|
||||||
>
|
>
|
||||||
<!-- 服务调用参数配置 -->
|
<!-- 服务调用参数配置 -->
|
||||||
|
<!-- TODO @puhui999:中英文之间,有个空格哈? -->
|
||||||
<JsonParamsInput
|
<JsonParamsInput
|
||||||
v-if="triggerType === IotRuleSceneTriggerTypeEnum.DEVICE_SERVICE_INVOKE"
|
v-if="triggerType === IotRuleSceneTriggerTypeEnum.DEVICE_SERVICE_INVOKE"
|
||||||
v-model="condition.value"
|
v-model="condition.value"
|
||||||
@ -152,6 +154,7 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
|
<!-- TODO @puhui999:这个是不是跟阿里云,还是一致一点哈? -->
|
||||||
<el-row :gutter="16">
|
<el-row :gutter="16">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="操作符" required>
|
<el-form-item label="操作符" required>
|
||||||
|
|||||||
@ -444,6 +444,7 @@ const generateExampleJson = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 处理数据回显的函数
|
// 处理数据回显的函数
|
||||||
|
// TODO @puhui999:注释风格;
|
||||||
const handleDataDisplay = (value: string) => {
|
const handleDataDisplay = (value: string) => {
|
||||||
if (!value || !value.trim()) {
|
if (!value || !value.trim()) {
|
||||||
paramsJson.value = ''
|
paramsJson.value = ''
|
||||||
@ -504,6 +505,7 @@ watch(
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
/** TODO @puhui999:unocss,看看哪些可以搞掉哈。 */
|
||||||
/* 弹出层内容样式 */
|
/* 弹出层内容样式 */
|
||||||
.json-params-detail-content {
|
.json-params-detail-content {
|
||||||
padding: 4px 0;
|
padding: 4px 0;
|
||||||
|
|||||||
@ -66,6 +66,7 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 定时触发配置 -->
|
<!-- 定时触发配置 -->
|
||||||
|
<!-- TODO @puhui999:改成定时触发配置后,就改不回来了。 -->
|
||||||
<TimerTriggerConfig
|
<TimerTriggerConfig
|
||||||
v-else-if="triggerItem.type === TriggerTypeEnum.TIMER"
|
v-else-if="triggerItem.type === TriggerTypeEnum.TIMER"
|
||||||
:model-value="triggerItem.cronExpression"
|
:model-value="triggerItem.cronExpression"
|
||||||
|
|||||||
Reference in New Issue
Block a user