fix: 修改场景联动数据显示

This commit is contained in:
100011797 2023-03-30 14:19:50 +08:00
parent 7ab063a790
commit 048d8508a6
4 changed files with 44 additions and 37 deletions

View File

@ -326,13 +326,13 @@ const onFormSave = () => {
..._data.message, ..._data.message,
}, },
}); });
emit('change', { // emit('change', {
propertiesName: // propertiesName:
deviceMessageType.value === 'INVOKE_FUNCTION' // deviceMessageType.value === 'INVOKE_FUNCTION'
? _function.value?.name // ? _function.value?.name
: _property.value?.name, // : _property.value?.name,
propertiesValue: modelRef.propertiesValue, // propertiesValue: modelRef.propertiesValue,
}); // });
}) })
.catch((err: any) => { .catch((err: any) => {
reject(err); reject(err);

View File

@ -120,15 +120,31 @@ const onTypeSelect = (key: any, _index: number) => {
}; };
const onTagSelect = (_data: any, _index: number) => { const onTagSelect = (_data: any, _index: number) => {
const newList = [...unref(tagList)]; const indexType = tagList.value[_index].type;
const indexType = newList[_index].type; const _item = handleItem({ ..._data, value: undefined, type: indexType })
newList.splice( tagList.value[_index] = _item
_index, const newValue = tagList.value.map((item: any) => {
1, return {
handleItem({ ..._data, value: undefined, type: indexType }), column: item.id,
); type: item?.type,
tagList.value = newList; value: item?.value,
onValueChange() };
});
emits('update:value', [{ value: newValue, name: '标签' }]);
emits('change', [{ value: newValue, name: '标签' }], tagList.value);
};
const onValueChange = () => {
const _data = tagList.value.filter((item) => item?.value !== undefined);
const newValue = _data.map((item: any) => {
return {
column: item.id,
type: item?.type,
value: item?.value,
};
});
emits('update:value', [{ value: newValue, name: '标签' }]);
emits('change', [{ value: newValue, name: '标签' }], _data);
}; };
watch( watch(
@ -170,19 +186,6 @@ watch(
}, },
); );
const onValueChange = () => {
const _data = tagList.value.filter((item) => !!item?.value);
const newValue = _data.map((item: any) => {
return {
column: item.id,
type: item?.type,
value: item?.value,
};
});
emits('update:value', [{ value: newValue, name: '标签' }]);
emits('change', [{ value: newValue, name: '标签' }], _data);
};
onMounted(() => { onMounted(() => {
if(props.value?.[0]?.value){ if(props.value?.[0]?.value){
const arr: any[] = [] const arr: any[] = []

View File

@ -145,10 +145,10 @@ const onSave = (_data: any) => {
item.upperKey = 'scene.deviceId'; item.upperKey = 'scene.deviceId';
} }
const _options: any = { const _options: any = {
name: '-', // // name: '-', //
type: '', // // type: '', //
properties: '', // // properties: '', //
propertiesValue: '', // // propertiesValue: '', //
selector: DeviceModel.selector, // selector: DeviceModel.selector, //
triggerName: data.value.options?.trigger?.name || '触发设备', triggerName: data.value.options?.trigger?.name || '触发设备',
...DeviceOptions.value, ...DeviceOptions.value,
@ -165,15 +165,18 @@ const onSave = (_data: any) => {
_options.propertiesValue = _options.propertiesValue =
(typeof _options?.propertiesValue === 'object' (typeof _options?.propertiesValue === 'object'
? JSON.stringify(_options?.propertiesValue) ? JSON.stringify(_options?.propertiesValue)
: `${_options?.propertiesValue}`) || : _options?.propertiesValue)
DeviceModel?.selectorValues?.[0]?.value;
} }
emit('save', item, _options); emit('save', item, JSON.parse(JSON.stringify(_options)));
}; };
const onProductChange = (_val: any, bol: boolean) => { const onProductChange = (_val: any, bol: boolean) => {
if (!bol) { if (!bol) {
DeviceModel.selectorValues = undefined; DeviceModel.selectorValues = undefined;
DeviceModel.deviceId = ''
DeviceModel.selector = 'fixed',
DeviceModel.upperKey = ''
DeviceModel.source = 'fixed'
const flag = isActionChange( const flag = isActionChange(
JSON.parse(_val.metadata || '{}'), JSON.parse(_val.metadata || '{}'),
DeviceModel?.message, DeviceModel?.message,

View File

@ -519,9 +519,10 @@ const onType = (_type: string) => {
*/ */
const onSave = (data: ActionsType, options: any) => { const onSave = (data: ActionsType, options: any) => {
const { key, terms } = _data.value.branches![props.branchesName].then?.[props.thenName].actions?.[props.name] const { key, terms } = _data.value.branches![props.branchesName].then?.[props.thenName].actions?.[props.name]
console.log({...props.options, ...options})
const actionItem: ActionsType = { const actionItem: ActionsType = {
...data, ...data,
options, options: {...props.options, ...options},
key, key,
terms terms
} }