fix: 优化场景联动-消息通知-内置参数

This commit is contained in:
xieyonghong 2023-04-25 15:32:52 +08:00
parent 1568102bbe
commit 229bec30ed
11 changed files with 78 additions and 31 deletions

View File

@ -52,6 +52,7 @@ const cpuSocket = getWebSocket(
)
?.pipe(map((res: any) => res.payload))
.subscribe((resp: any) => {
console.log(resp)
cpu.value = resp.value?.systemUsage || 0;
});
const jvmSocket = getWebSocket(

View File

@ -52,7 +52,7 @@
</template>
<script lang="ts" setup>
import { cloneDeep } from 'lodash-es';
import { cloneDeep, isObject } from 'lodash-es'
import ParamsDropdown from '../../../components/ParamsDropdown';
import { handleParamsData } from './index';
const props = defineProps({
@ -172,6 +172,7 @@ const onChange = () => {
};
const onValueChange = (val: any, label: string) => {
const optionColumn = isObject(val) && (val as any).metadata ? [(val as any).column] : []
const obj = {
[`${propertyModelRef.properties}`]: {
value: propertyModelRef?.propertiesValue,
@ -179,7 +180,7 @@ const onValueChange = (val: any, label: string) => {
},
};
emit('update:value', obj);
emit('change', label || val)
emit('change', label || val, optionColumn)
};
watch(

View File

@ -298,7 +298,7 @@ watch(
{ immediate: true },
);
const onWriteChange = (val: string) => {
const onWriteChange = (val: string, optionColumn: string[]) => {
modelRef.propertiesValue = val;
emit('change', {
propertiesName:
@ -306,7 +306,7 @@ const onWriteChange = (val: string) => {
? _function.value?.name
: _property.value?.name,
propertiesValue: modelRef.propertiesValue,
});
}, optionColumn);
};
const onFormSave = () => {

View File

@ -102,6 +102,10 @@ const props = defineProps({
parallel: {
type: Boolean,
},
options: {
type: Object,
default: () => ({})
}
});
const current = ref<number>(0);
@ -125,6 +129,7 @@ const DeviceModel = reactive<DeviceModelType>({
const DeviceOptions = ref<DeviceOptionType>({});
const emit = defineEmits<Emit>();
const optionColumnCache = ref<string[]>(props.options?.otherColumn || [])
const onCancel = () => {
emit('cancel');
@ -150,6 +155,7 @@ const onSave = (_data: any) => {
selector: DeviceModel.selector, //
triggerName: data.value.options?.trigger?.name || '触发设备',
...DeviceOptions.value,
otherColumns: []
};
const _type = _data.message.messageType;
if (_type === 'INVOKE_FUNCTION') {
@ -164,8 +170,9 @@ const onSave = (_data: any) => {
(typeof _options?.propertiesValue === 'object'
? JSON.stringify(_options?.propertiesValue)
: _options?.propertiesValue)
_options.otherColumns = optionColumnCache.value
}
console.log(item)
emit('save', item, JSON.parse(JSON.stringify(_options)));
};
@ -195,7 +202,8 @@ const onDeviceSave = (_data: any, obj?: any) => {
DeviceOptions.value = { ...unref(DeviceOptions), ...obj };
};
const onActionsChange = (options?: any) => {
const onActionsChange = (options?: any, optionColumn: string[]) => {
optionColumnCache.value = optionColumn
const obj = {
...DeviceOptions.value,
...options,

View File

@ -368,6 +368,7 @@
:branchGroup="thenName"
:branchesName="branchesName"
:data="data"
:options='_data.branches[branchesName].then[thenName].actions[name].options'
@cancel="onClose"
@save="onSave"
/>
@ -377,6 +378,7 @@
v-bind="props"
v-if="!!actionType"
:actionType="actionType"
:options='_data.branches[branchesName].then[thenName].actions[name].options'
@save="onPropsOk"
@cancel="onPropsCancel"
/>
@ -523,12 +525,17 @@ const onType = (_type: string) => {
const onSave = (data: ActionsType, options: any) => {
const { key, terms } = _data.value.branches![props.branchesName].then?.[props.thenName].actions?.[props.name]
console.log({...props.options, ...options})
const columns = new Set([...(props.options?.termsColumns || []), ...(options.otherColumns.filter((item?: string) => item))])
const actionItem: ActionsType = {
...data,
options: {...props.options, ...options},
options: {...props.options, ...options, columns: [...columns.values()]},
key,
terms
}
console.log(actionItem)
_data.value.branches![props.branchesName].then[props.thenName].actions.splice(props.name, 1, actionItem)
visible.value = false;

View File

@ -82,7 +82,10 @@ const onSave = (data: any, options?: any) => {
const item: ActionsType = {
...extra,
key: data.key,
options,
options: {
...options,
columns: options.otherColumns.filter((item?: string) => item)
},
};
emit('add', item)
visible.value = false

View File

@ -1,7 +1,7 @@
<template>
<div>
<template v-if="actionType === 'device'">
<Device v-bind="props" :value="data?.device" @cancel="onCancel" @save="onPropsOk" />
<Device v-bind="props" :value="data?.device" :options='options' @cancel="onCancel" @save="onPropsOk" />
</template>
<template v-else-if="actionType === 'notify'">
<Notify :options="data?.options" :value="data?.notify" @cancel="onCancel" @save="onPropsOk" />
@ -42,6 +42,10 @@ const props = defineProps({
type: String,
default: '',
},
options: {
type: Object,
default: () => ({})
}
});
const emit = defineEmits(['cancel', 'save']);

View File

@ -24,6 +24,7 @@
v-bind="props"
v-if="!!actionType"
:actionType="actionType"
:options='actionOptions'
@save="onPropsOk"
@cancel="onPropsCancel"
/>
@ -64,6 +65,10 @@ const props = defineProps({
parallel: {
type: Boolean,
},
actionOptions: {
type: Object,
default: () => ({})
}
});
const emit = defineEmits(['cancel', 'save']);

View File

@ -8,7 +8,7 @@
<j-form-item
:name="`${item?.id}`"
:label="item?.name"
v-for="item in variableDefinitions"
v-for="(item, index) in variableDefinitions"
:key="item.id"
:required="getType(item) !== 'file' ? true : false"
:rules="[
@ -22,19 +22,19 @@
:notify="notify"
v-if="getType(item) === 'user'"
v-model:value="modelRef[item.id]"
@change="(val) => onChange(val, 'user')"
@change="(val) => onChange(val, 'user', index)"
/>
<Org
:notify="notify"
v-else-if="getType(item) === 'org'"
v-model:value="modelRef[item.id]"
@change="(val) => onChange(val, 'org')"
@change="(val) => onChange(val, 'org', index)"
/>
<Tag
:notify="notify"
v-else-if="getType(item) === 'tag'"
v-model:value="modelRef[item.id]"
@change="(val) => onChange(val, 'tag')"
@change="(val) => onChange(val, 'tag', index)"
/>
<InputFile
v-else-if="getType(item) === 'file'"
@ -48,7 +48,7 @@
v-else
:item="item"
v-model:value="modelRef[item.id]"
@change="(val) => onChange(val, 'build-in')"
@change="(val, _options) => onChange(val, 'build-in', index, _options)"
/>
</j-form-item>
</j-form>
@ -70,16 +70,20 @@ const props = defineProps({
},
value: {
type: Object,
default: () => {},
default: () => ({}),
},
notify: {
type: Object,
default: () => {},
default: () => ({}),
},
template: {
type: Object,
default: () => {},
default: () => ({}),
},
options: {
type: Object,
default: () => ({})
}
});
const emit = defineEmits(['update:value', 'change']);
@ -87,15 +91,14 @@ const emit = defineEmits(['update:value', 'change']);
const formRef = ref();
const modelRef = reactive({});
const otherColumns = ref<(string | undefined)[]>(props.options?.otherColumns || [])
watchEffect(() => {
Object.assign(modelRef, props?.value);
});
watchEffect(() => {
if(props?.template?.template?.sendTo && props?.template?.template?.sendTo?.length){
emit('change', { sendTo: props?.template?.template?.sendTo.join(' ') });
}
emit('change', { sendTo: props?.template?.template?.sendTo?.join(' ') });
});
const getType = (item: any) => {
@ -103,7 +106,6 @@ const getType = (item: any) => {
};
const checkValue = (_rule: any, value: any, item: any) => {
console.log('checkValue',value)
if(!value){
return Promise.resolve();
}
@ -185,13 +187,21 @@ const checkValue = (_rule: any, value: any, item: any) => {
return Promise.resolve();
};
const onChange = (val: any, type: any) => {
const onChange = (val: any, type: any, index: number, options?: string) => {
if (type === 'build-in') {
otherColumns.value[index] = options
} else {
otherColumns.value[index] = undefined
}
if (type === 'org') {
emit('change', { orgName: val.join(',') });
emit('change', { orgName: val.join(','), otherColumns: [] });
} else if (type === 'tag') {
emit('change', { tagName: val });
emit('change', { tagName: val, otherColumns: [] });
} else if (type === 'user') {
emit('change', { sendTo: val });
emit('change', { sendTo: val, otherColumns: [] });
} else {
emit('change', { otherColumns: otherColumns.value });
}
};

View File

@ -60,6 +60,7 @@
:value="formModel.variables"
:notify="formModel"
:template="template"
:options='options'
@change="(val) => onValChange(val, 'variables')"
ref="variableRef"
/>
@ -82,7 +83,7 @@
</j-modal>
</template>
<script lang="ts" setup>
<script lang="ts" setup name='NotifyIndex'>
import NotifyWay from './NotifyWay.vue';
import NotifyConfig from './NotifyConfig.vue';
import NotifyTemplate from './NotifyTemplate.vue';
@ -99,7 +100,7 @@ const props = defineProps({
},
options: {
type: Object,
default: () => {},
default: () => ({}),
},
name: {
type: Number,

View File

@ -16,7 +16,7 @@
placeholder="请选择参数"
style="width: calc(100% - 120px)"
:fieldNames="{ label: 'name', value: 'id' }"
@change="(val, label) => itemOnChange(undefined, val, label)"
@change="(val, label, extra) => itemOnChange(undefined, val, label, extra)"
>
<template #title="{ fullName, description }">
<j-space>
@ -57,7 +57,7 @@
</j-input-group>
</template>
<script lang="ts" setup>
<script lang="ts" setup name='NotifyBuildIn'>
import { queryBuiltInParams } from '@/api/rule-engine/scene';
import { useSceneStore } from '@/store/scene';
import { storeToRefs } from 'pinia';
@ -103,15 +103,22 @@ const sourceChange = (val: any) => {
});
};
const itemOnChange = (val: any, _upperKey?: string, label?: any) => {
const itemOnChange = (val: any, _upperKey?: string, label?: any, extra?: any) => {
const item = extra?.triggerNode?.props
let othersColumns = ''
if (item && item.metadata) {
othersColumns = item.column
}
emit('update:value', {
...props.value,
value: val,
upperKey: _upperKey,
});
emit('change', {
sendTo: label?.[0] || val,
});
}, othersColumns);
};
const treeDataFilter = (arr: any[], type: string) => {