fix: 修改场景联动
This commit is contained in:
parent
ad64371a04
commit
d4dbc450ea
|
@ -73,15 +73,21 @@
|
||||||
style="margin-top: 50px"
|
style="margin-top: 50px"
|
||||||
>
|
>
|
||||||
<template #description>
|
<template #description>
|
||||||
暂无数据,请先
|
<template v-if="!isPermission"
|
||||||
<PermissionButton
|
>暂无权限, 请联系管理员</template
|
||||||
type="link"
|
|
||||||
style="padding: 0"
|
|
||||||
hasPermission="link/AccessConfig:add"
|
|
||||||
@click="handleAdd"
|
|
||||||
>
|
>
|
||||||
添加{{ providerType[props.channel] }}接入网关
|
<template v-else>
|
||||||
</PermissionButton>
|
暂无数据,请先
|
||||||
|
<j-button
|
||||||
|
type="link"
|
||||||
|
style="padding: 0"
|
||||||
|
@click="handleAdd"
|
||||||
|
>
|
||||||
|
添加{{
|
||||||
|
providerType[props.channel]
|
||||||
|
}}接入网关
|
||||||
|
</j-button>
|
||||||
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</j-empty>
|
</j-empty>
|
||||||
<div
|
<div
|
||||||
|
@ -166,9 +172,11 @@ import DeviceApi from '@/api/media/device';
|
||||||
import { getImage } from '@/utils/comm';
|
import { getImage } from '@/utils/comm';
|
||||||
import { gatewayType } from '@/views/media/Device/typings';
|
import { gatewayType } from '@/views/media/Device/typings';
|
||||||
import { providerType } from '../const';
|
import { providerType } from '../const';
|
||||||
import { useMenuStore } from '@/store/menu';
|
import { usePermissionStore } from '@/store/permission';
|
||||||
|
|
||||||
const menuStory = useMenuStore();
|
const isPermission = usePermissionStore().hasPermission(
|
||||||
|
'link/AccessConfig:add',
|
||||||
|
);
|
||||||
|
|
||||||
type Emits = {
|
type Emits = {
|
||||||
(e: 'update:visible', data: boolean): void;
|
(e: 'update:visible', data: boolean): void;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<ParamsDropdown
|
<ParamsDropdown
|
||||||
placeholder="请选择"
|
|
||||||
:options="handleOptions"
|
:options="handleOptions"
|
||||||
:tabsOptions="tabOptions"
|
:tabsOptions="tabOptions"
|
||||||
:metricOptions="upperOptions"
|
:metricOptions="upperOptions"
|
||||||
|
@ -10,7 +9,7 @@
|
||||||
valueName="id"
|
valueName="id"
|
||||||
>
|
>
|
||||||
<template v-slot="{ label }">
|
<template v-slot="{ label }">
|
||||||
<j-input :value="label" readonly />
|
<j-input :value="label" readonly placeholder="请选择" />
|
||||||
</template>
|
</template>
|
||||||
</ParamsDropdown>
|
</ParamsDropdown>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -113,9 +113,10 @@ const deleteItem = (_index: number) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onTypeSelect = (key: any, _index: number) => {
|
const onTypeSelect = (key: any, _index: number) => {
|
||||||
const indexItem = tagList[_index];
|
const indexItem = tagList.value[_index];
|
||||||
indexItem.type = key;
|
indexItem.type = key;
|
||||||
tagList.value[_index] = indexItem;
|
tagList.value[_index] = indexItem;
|
||||||
|
onValueChange()
|
||||||
};
|
};
|
||||||
|
|
||||||
const onTagSelect = (_data: any, _index: number) => {
|
const onTagSelect = (_data: any, _index: number) => {
|
||||||
|
@ -127,6 +128,7 @@ const onTagSelect = (_data: any, _index: number) => {
|
||||||
handleItem({ ..._data, value: undefined, type: indexType }),
|
handleItem({ ..._data, value: undefined, type: indexType }),
|
||||||
);
|
);
|
||||||
tagList.value = newList;
|
tagList.value = newList;
|
||||||
|
onValueChange()
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
@ -173,7 +175,7 @@ const onValueChange = () => {
|
||||||
const newValue = _data.map((item: any) => {
|
const newValue = _data.map((item: any) => {
|
||||||
return {
|
return {
|
||||||
column: item.id,
|
column: item.id,
|
||||||
type: item?.valueType,
|
type: item?.type,
|
||||||
value: item?.value,
|
value: item?.value,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -181,10 +183,21 @@ const onValueChange = () => {
|
||||||
emits('change', [{ value: newValue, name: '标签' }], _data);
|
emits('change', [{ value: newValue, name: '标签' }], _data);
|
||||||
};
|
};
|
||||||
|
|
||||||
// onMounted(() => {
|
onMounted(() => {
|
||||||
// // console.log(tagList.value, props.tagData, props.value)
|
if(props.value?.[0]?.value){
|
||||||
// // emits('change', props.value, _data);
|
const arr: any[] = []
|
||||||
// })
|
props.value?.[0]?.value.map((item: any) => {
|
||||||
|
const _item = props.tagData.find(i => i.id === item.column)
|
||||||
|
if(_item){
|
||||||
|
arr.push({
|
||||||
|
..._item,
|
||||||
|
...item,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
emits('change', props.value, arr);
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
/>
|
/>
|
||||||
</j-form-item>
|
</j-form-item>
|
||||||
<j-form-item
|
<j-form-item
|
||||||
v-else-if="modelRef.selector === 'tag'"
|
v-else-if="modelRef.selector === 'tag' && isTags"
|
||||||
name="selectorValues"
|
name="selectorValues"
|
||||||
:rules="[{ required: true, message: '请选择标签' }]"
|
:rules="[{ required: true, message: '请选择标签' }]"
|
||||||
>
|
>
|
||||||
|
@ -80,6 +80,7 @@ import Tag from './Tag.vue';
|
||||||
import RelationSelect from './RelationSelect.vue';
|
import RelationSelect from './RelationSelect.vue';
|
||||||
import { getParams } from '../../../util';
|
import { getParams } from '../../../util';
|
||||||
import { handleParamsData } from '../../../components/Terms/util';
|
import { handleParamsData } from '../../../components/Terms/util';
|
||||||
|
import _ from 'lodash';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
values: {
|
values: {
|
||||||
|
@ -107,6 +108,11 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 首次操作标签数据option回显问题
|
||||||
|
const isTags = computed(() => {
|
||||||
|
return _.map(list.value, 'value').includes('tag');
|
||||||
|
});
|
||||||
|
|
||||||
// save保存deviceDetail
|
// save保存deviceDetail
|
||||||
const emits = defineEmits(['save', 'cancel']);
|
const emits = defineEmits(['save', 'cancel']);
|
||||||
|
|
||||||
|
@ -281,17 +287,10 @@ const onTagChange = (val: any[], arr: any[]) => {
|
||||||
modelRef.source = 'fixed';
|
modelRef.source = 'fixed';
|
||||||
}
|
}
|
||||||
const tagName = arr.map((i, _index) => {
|
const tagName = arr.map((i, _index) => {
|
||||||
return `${_index !== 0 && _index !== (arr || []).length && i.type}${
|
const _type = (_index !== 0 && _index !== (arr || []).length && i.type) ? (i.type === 'and' ? '并且' : '或者') : '';
|
||||||
i.name
|
return `${_type}${i.name}为${i.value}`;
|
||||||
}为${i.value}`;
|
|
||||||
});
|
});
|
||||||
console.log(tagName)
|
emits('save', unref(modelRef), { tagName: tagName.join('') });
|
||||||
emits(
|
|
||||||
'save',
|
|
||||||
unref(modelRef),
|
|
||||||
{},
|
|
||||||
arr ? { tagName: tagName.join('') } : {},
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onVariableChange = (val: any, node: any) => {
|
const onVariableChange = (val: any, node: any) => {
|
||||||
|
@ -315,7 +314,7 @@ watch(
|
||||||
() => props.productDetail,
|
() => props.productDetail,
|
||||||
async (newVal) => {
|
async (newVal) => {
|
||||||
await sourceChangeEvent();
|
await sourceChangeEvent();
|
||||||
if (newVal) {
|
if (newVal?.id) {
|
||||||
filterType(newVal);
|
filterType(newVal);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -72,6 +72,7 @@ import { onlyMessage } from '@/utils/comm';
|
||||||
|
|
||||||
import { useSceneStore } from '@/store/scene';
|
import { useSceneStore } from '@/store/scene';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
|
import { isActionChange } from '../../util';
|
||||||
|
|
||||||
const sceneStore = useSceneStore();
|
const sceneStore = useSceneStore();
|
||||||
const { data } = storeToRefs(sceneStore);
|
const { data } = storeToRefs(sceneStore);
|
||||||
|
@ -173,11 +174,17 @@ const onSave = (_data: any) => {
|
||||||
const onProductChange = (_val: any, bol: boolean) => {
|
const onProductChange = (_val: any, bol: boolean) => {
|
||||||
if (!bol) {
|
if (!bol) {
|
||||||
DeviceModel.selectorValues = undefined;
|
DeviceModel.selectorValues = undefined;
|
||||||
DeviceModel.message = {
|
const flag = isActionChange(
|
||||||
messageType: 'INVOKE_FUNCTION',
|
JSON.parse(_val.metadata || '{}'),
|
||||||
};
|
DeviceModel?.message,
|
||||||
|
);
|
||||||
|
if (!flag) {
|
||||||
|
DeviceModel.message = {
|
||||||
|
messageType: 'INVOKE_FUNCTION',
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
productDetail.value = _val
|
productDetail.value = _val;
|
||||||
DeviceOptions.value.productName = _val?.name;
|
DeviceOptions.value.productName = _val?.name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,8 @@ type DeviceModelType = {
|
||||||
message: {
|
message: {
|
||||||
properties?: any;
|
properties?: any;
|
||||||
messageType: string;
|
messageType: string;
|
||||||
inputs?: any[]
|
inputs?: any[];
|
||||||
|
functionId?: string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
}"
|
}"
|
||||||
:params="params"
|
:params="params"
|
||||||
:gridColumn="2"
|
:gridColumn="2"
|
||||||
|
:noPagination="true"
|
||||||
:rowSelection="{
|
:rowSelection="{
|
||||||
selectedRowKeys: _selectedRowKeys,
|
selectedRowKeys: _selectedRowKeys,
|
||||||
onChange: onSelectChange,
|
onChange: onSelectChange,
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
/>
|
/>
|
||||||
</j-form-item>
|
</j-form-item>
|
||||||
</j-form>
|
</j-form>
|
||||||
|
<j-empty v-else style="margin: 20px 0" description="暂无模板变量" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
|
|
@ -203,11 +203,11 @@ const onCancel = () => {
|
||||||
emit('cancel');
|
emit('cancel');
|
||||||
};
|
};
|
||||||
const onOk = async () => {
|
const onOk = async () => {
|
||||||
let _data = undefined
|
let _data = null
|
||||||
if(variable.value.length){
|
if(variable.value.length){
|
||||||
_data = await variableRef.value.onSave()
|
_data = await variableRef.value.onSave()
|
||||||
}
|
}
|
||||||
formModel.variables = _data || [];
|
formModel.variables = _data;
|
||||||
const { options, ...extra } = formModel;
|
const { options, ...extra } = formModel;
|
||||||
emit('save', { ...extra }, { ...options });
|
emit('save', { ...extra }, { ...options });
|
||||||
};
|
};
|
||||||
|
|
|
@ -66,7 +66,9 @@ const save = async () => {
|
||||||
if (formData) {
|
if (formData) {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
const branches = data.value.branches?.filter(item => item)
|
const branches = data.value.branches?.filter(item => item)
|
||||||
const resp = await modify(data.value.id!, { ...data.value, branches }).then(res => res)
|
const resp: any = await modify(data.value.id!, { ...data.value, branches }).then(res => res).catch(() => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
loading.value = false
|
loading.value = false
|
||||||
if (resp.success) {
|
if (resp.success) {
|
||||||
menuStore.jumpPage('rule-engine/Scene')
|
menuStore.jumpPage('rule-engine/Scene')
|
||||||
|
|
|
@ -121,3 +121,33 @@ export const EventEmitter = {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const isActionChange = (_metadata: any, _message: any) => {
|
||||||
|
const _properties = _metadata?.properties || [];
|
||||||
|
const _functions = _metadata?.functions || [];
|
||||||
|
if (
|
||||||
|
_message?.messageType === 'READ_PROPERTY' &&
|
||||||
|
_message?.properties?.[0]
|
||||||
|
) {
|
||||||
|
const _item = _properties.find(
|
||||||
|
(i: any) => i.id === _message?.properties?.[0],
|
||||||
|
);
|
||||||
|
return _item?.id;
|
||||||
|
} else if (
|
||||||
|
_message?.messageType === 'INVOKE_FUNCTION' &&
|
||||||
|
_message?.functionId
|
||||||
|
) {
|
||||||
|
const _item = _functions.find(
|
||||||
|
(i: any) => i.id === _message?.functionId,
|
||||||
|
);
|
||||||
|
return _item?.id;
|
||||||
|
} else if (_message?.messageType === 'WRITE_PROPERTY') {
|
||||||
|
const _data = Object.keys(_message?.properties)?.[0]
|
||||||
|
if (_data) {
|
||||||
|
const _item = _functions.find((i: any) => i.id === _data);
|
||||||
|
return _item?.id;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue