diff --git a/src/views/device/Instance/Detail/EdgeMap/MSelect.vue b/src/views/device/Instance/Detail/EdgeMap/MSelect.vue
index 1b66df49..f465c18d 100644
--- a/src/views/device/Instance/Detail/EdgeMap/MSelect.vue
+++ b/src/views/device/Instance/Detail/EdgeMap/MSelect.vue
@@ -1,14 +1,14 @@
-
-
+ {{ item.name }}{{ item.name }}
-
+
\ No newline at end of file
diff --git a/src/views/rule-engine/Scene/Save/action/Device/actions/FunctionItem.vue b/src/views/rule-engine/Scene/Save/action/Device/actions/FunctionItem.vue
new file mode 100644
index 00000000..4ac0e416
--- /dev/null
+++ b/src/views/rule-engine/Scene/Save/action/Device/actions/FunctionItem.vue
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/views/rule-engine/Scene/Save/action/Device/actions/WriteProperty.vue b/src/views/rule-engine/Scene/Save/action/Device/actions/WriteProperty.vue
index d4ac0fba..b9765483 100644
--- a/src/views/rule-engine/Scene/Save/action/Device/actions/WriteProperty.vue
+++ b/src/views/rule-engine/Scene/Save/action/Device/actions/WriteProperty.vue
@@ -1,50 +1,59 @@
-
-
-
-
-
+
+
+
+
- {{ item?.name }}
- {{ item?.name }}
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/views/rule-engine/Scene/Save/action/Device/actions/index.ts b/src/views/rule-engine/Scene/Save/action/Device/actions/index.ts
new file mode 100644
index 00000000..4926b165
--- /dev/null
+++ b/src/views/rule-engine/Scene/Save/action/Device/actions/index.ts
@@ -0,0 +1,10 @@
+export const handleParamsData = (data: any[]): any[] => {
+ return data?.map(item => {
+ return {
+ ...item,
+ key: item.column,
+ disabled: !!item.children?.length,
+ children: handleParamsData(item.children)
+ }
+ }) || []
+}
\ No newline at end of file
diff --git a/src/views/rule-engine/Scene/Save/action/Device/actions/index.vue b/src/views/rule-engine/Scene/Save/action/Device/actions/index.vue
index c4f27a45..aad5a4ae 100644
--- a/src/views/rule-engine/Scene/Save/action/Device/actions/index.vue
+++ b/src/views/rule-engine/Scene/Save/action/Device/actions/index.vue
@@ -22,7 +22,6 @@
showSearch
placeholder="请选择功能"
v-model:value="modelRef.message.functionId"
- @change="(val) => onFunctionChange(val, [])"
>
-
+
@@ -79,7 +82,7 @@ import EditTable from './EditTable.vue';
import WriteProperty from './WriteProperty.vue';
import { queryBuiltInParams } from '@/api/rule-engine/scene';
import { useSceneStore } from '@/store/scene';
-import { storeToRefs } from 'pinia'
+import { storeToRefs } from 'pinia';
const sceneStore = useSceneStore();
const { data } = storeToRefs(sceneStore);
@@ -149,22 +152,31 @@ const deviceMessageType = computed(() => {
const builtInList = ref([]);
-const onFunctionChange = (val: string, values?: any[]) => {
+const functions = computed(() => {
const _item = (metadata.value?.functions || []).find((item: any) => {
- return val === item.id;
+ return modelRef.message?.functionId === item.id;
});
- const list = (_item?.inputs || []).map((item: any) => {
- const _a = values?.find((i) => i.name === item.id);
- return {
- id: item.id,
- value: _a?.value,
- valueType: item?.valueType?.type,
- ..._a,
- name: item.name,
- };
+ return _item?.inputs || [];
+});
+
+const _property = computed(() => {
+ const _item = (metadata.value?.properties || []).find((item: any) => {
+ if (deviceMessageType.value === 'WRITE_PROPERTY') {
+ return (
+ Object.keys(modelRef.message.properties || {})?.[0] === item.id
+ );
+ }
+ return modelRef.message?.properties === item.id;
});
- modelRef.message.inputs = list;
-};
+ return _item;
+});
+
+const _function = computed(() => {
+ const _item = (metadata.value?.functions || []).find((item: any) => {
+ return modelRef.message?.functionId === item.id;
+ });
+ return _item;
+});
const onMessageTypeChange = (val: string) => {
if (['WRITE_PROPERTY', 'INVOKE_FUNCTION'].includes(val)) {
@@ -175,22 +187,18 @@ const onMessageTypeChange = (val: string) => {
};
queryBuiltInParams(unref(data), _params).then((res: any) => {
if (res.status === 200) {
- builtInList.value = res.result
+ builtInList.value = res.result;
}
});
}
};
watch(
- () => [
- props.values?.productDetail,
- props.values.selectorValues,
- props.values?.selector,
- ],
- ([newVal1, newVal2, newVal3]) => {
- if (newVal1?.id) {
- if (newVal3?.selector === 'fixed') {
- const id = newVal2?.[0]?.value;
+ () => props.values,
+ (newVal) => {
+ if (newVal?.productDetail?.id) {
+ if (newVal?.selector === 'fixed') {
+ const id = newVal?.selectorValues?.[0]?.value;
if (id) {
detail(id).then((resp) => {
if (resp.status === 200) {
@@ -201,7 +209,9 @@ watch(
});
}
} else {
- metadata.value = JSON.parse(newVal1?.metadata || '{}');
+ metadata.value = JSON.parse(
+ newVal?.productDetail?.metadata || '{}',
+ );
}
}
},
@@ -211,24 +221,36 @@ watch(
watch(
() => props.values?.message,
(newVal) => {
- console.log(newVal)
if (newVal?.messageType) {
modelRef.message = newVal;
- if (newVal.messageType === 'INVOKE_FUNCTION' && newVal.functionId) {
- onFunctionChange(newVal.functionId, newVal?.inputs);
+ if (newVal.messageType === 'READ_PROPERTY') {
+ modelRef.message.properties = newVal.properties?.[0];
}
- onMessageTypeChange(newVal.messageType)
+ onMessageTypeChange(newVal.messageType);
}
},
- { deep: true, immediate: true },
+ { immediate: true },
);
const onFormSave = () => {
return new Promise((resolve, reject) => {
formRef.value
.validate()
- .then(async (_data: any) => {
- resolve(_data);
+ .then((_data: any) => {
+ // 处理三种情况的值的格式
+ const _properties = _data.message.properties || modelRef.message.properties
+ const obj = {
+ message: {
+ ...modelRef.message,
+ ..._data.message,
+ properties: _data.message.messageType === 'READ_PROPERTY' ? [_properties] : _properties,
+ propertiesName:
+ deviceMessageType.value === 'INVOKE_FUNCTION'
+ ? _function.value?.name
+ : _property.value?.name,
+ },
+ }
+ resolve(obj);
})
.catch((err: any) => {
reject(err);
diff --git a/src/views/rule-engine/Scene/Save/action/Device/device/Device.vue b/src/views/rule-engine/Scene/Save/action/Device/device/Device.vue
index 00eb1e33..33e8c8fd 100644
--- a/src/views/rule-engine/Scene/Save/action/Device/device/Device.vue
+++ b/src/views/rule-engine/Scene/Save/action/Device/device/Device.vue
@@ -7,7 +7,7 @@
target="scene-trigger-device-device"
/>
-
-
+
\ No newline at end of file
diff --git a/src/views/rule-engine/Scene/Save/action/Device/device/index.vue b/src/views/rule-engine/Scene/Save/action/Device/device/index.vue
index 0bffa2b4..bc159f5f 100644
--- a/src/views/rule-engine/Scene/Save/action/Device/device/index.vue
+++ b/src/views/rule-engine/Scene/Save/action/Device/device/index.vue
@@ -30,13 +30,7 @@
name="selectorValues"
:rules="[{ required: true, message: '请选择关系' }]"
>
-
+
([]);
const builtInList = ref([]);
const tagList = ref([]);
-const relationList = ref([]);
const TypeList = [
{
@@ -199,27 +193,10 @@ const sourceChangeEvent = async () => {
const array = filterTree(resp.result as any[]);
//判断相同产品才有按变量
// if (props.formProductId === DeviceModel.productId)// TODO
- builtInList.value = array;
+ builtInList.value = [] // array;
}
};
-const queryRelationList = () => {
- NoticeApi.getRelationUsers({
- paging: false,
- sorts: [{ name: 'createTime', order: 'desc' }],
- terms: [{ termType: 'eq', column: 'objectTypeName', value: '设备' }],
- }).then((resp) => {
- if (resp.status === 200) {
- relationList.value = (resp.result as any[]).map((item) => {
- return {
- label: item.name,
- value: item.relation,
- };
- });
- }
- });
-};
-
const filterType = async () => {
const _list = TypeList.filter((item) => item.value === 'fixed');
if (unref(data)?.trigger?.type === 'device') {
@@ -266,11 +243,8 @@ const filterType = async () => {
}
};
-const onSelectorChange = (val: string) => {
+const onSelectorChange = () => {
modelRef.selectorValues = undefined;
- if (val === 'relation') {
- queryRelationList();
- }
};
const onDeviceChange = (_detail: any) => {
@@ -306,7 +280,7 @@ const onTagChange = (val: any[], arr: any[]) => {
if (arr) {
tagList.value = arr;
}
- emits('save', unref(modelRef), {});
+ emits('save', unref(modelRef), {}, {tagList: tagList.value});
};
const onVariableChange = (val: any, node: any) => {
diff --git a/src/views/rule-engine/Scene/Save/action/Device/index.vue b/src/views/rule-engine/Scene/Save/action/Device/index.vue
index b5f87a40..698cab78 100644
--- a/src/views/rule-engine/Scene/Save/action/Device/index.vue
+++ b/src/views/rule-engine/Scene/Save/action/Device/index.vue
@@ -154,23 +154,23 @@ const onSave = (_data: any) => {
productName: DeviceModel.productDetail.name,
relationName: DeviceModel.relationName,
triggerName: data.value.options?.trigger?.name || '触发设备',
- taglist: [],
+ tagList: [],
columns: [],
otherColumns: [],
};
- _options.name = DeviceModel.deviceDetail?.name;
+ _options.name = DeviceModel.deviceDetail?.name || DeviceModel.selectorValues?.[0]?.name;
const _type = _data.message.messageType;
if (_type === 'INVOKE_FUNCTION') {
_options.type = '执行';
- _options.properties = DeviceModel.propertiesName;
+ _options.properties = _data.message.propertiesName;
}
if (_type === 'READ_PROPERTY') {
_options.type = '读取';
- _options.properties = DeviceModel.propertiesName;
+ _options.properties = _data.message.propertiesName;
}
if (_type === 'WRITE_PROPERTY') {
_options.type = '设置';
- _options.properties = DeviceModel.propertiesName;
+ _options.properties = _data.message.propertiesName;
_options.propertiesValue =
typeof DeviceModel.propertiesValue === 'object'
? JSON.stringify(DeviceModel.propertiesValue)
@@ -183,7 +183,7 @@ const onSave = (_data: any) => {
}
}
if (_options.selector === 'tag') {
- _options.taglist = DeviceModel.tagList.map((it) => ({
+ _options.tagList = DeviceModel.tagList.map((it) => ({
name: it.column || it.name,
type: it.type ? (it.type === 'and' ? '并且' : '或者') : '',
value: it.value,
@@ -205,6 +205,10 @@ const save = async (step?: number) => {
if (deviceRef.value) {
await deviceRef.value?.onFormSave();
current.value = 2;
+ } else {
+ if(DeviceModel.selector === 'fixed' && DeviceModel.selectorValues?.length){
+ current.value = 2;
+ }
}
} else {
if (actionRef.value) {
@@ -228,8 +232,8 @@ const prev = () => {
const saveClick = () => save();
-const onDeviceSave = (_data: any, _detail: any) => {
- Object.assign(DeviceModel, _data);
+const onDeviceSave = (_data: any, _detail: any, obj?: any) => {
+ Object.assign(DeviceModel, {..._data, ...obj});
DeviceModel.deviceDetail = _detail;
};
diff --git a/src/views/system/Apply/Save/components/RequestTable.vue b/src/views/system/Apply/Save/components/RequestTable.vue
index 7ebb7f31..b25cdc2c 100644
--- a/src/views/system/Apply/Save/components/RequestTable.vue
+++ b/src/views/system/Apply/Save/components/RequestTable.vue
@@ -2,7 +2,7 @@
新增
-
@@ -115,7 +116,6 @@