From 8d817c5365a90a8eda77e37341713fa8378e3a4b Mon Sep 17 00:00:00 2001 From: xieyonghong <18010623010@163.com> Date: Mon, 24 Apr 2023 17:39:17 +0800 Subject: [PATCH] fix: bug#12122 --- .../Scene/Save/action/Notify/VariableDefinitions.vue | 3 ++- .../Scene/Save/action/Notify/variableItem/User.vue | 12 +++++++++--- .../Scene/Save/components/Terms/ParamsItem.vue | 4 ++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/views/rule-engine/Scene/Save/action/Notify/VariableDefinitions.vue b/src/views/rule-engine/Scene/Save/action/Notify/VariableDefinitions.vue index 1e225a76..cbd420a5 100644 --- a/src/views/rule-engine/Scene/Save/action/Notify/VariableDefinitions.vue +++ b/src/views/rule-engine/Scene/Save/action/Notify/VariableDefinitions.vue @@ -14,7 +14,7 @@ :rules="[ { validator: (_rule, value) => checkValue(_rule, value, item), - trigger: ['change', 'blur'], + trigger: ['blur', 'change'], }, ]" > @@ -103,6 +103,7 @@ const getType = (item: any) => { }; const checkValue = (_rule: any, value: any, item: any) => { + console.log('checkValue',value) if(!value){ return Promise.resolve(); } diff --git a/src/views/rule-engine/Scene/Save/action/Notify/variableItem/User.vue b/src/views/rule-engine/Scene/Save/action/Notify/variableItem/User.vue index b4c58a45..d2bc13b6 100644 --- a/src/views/rule-engine/Scene/Save/action/Notify/variableItem/User.vue +++ b/src/views/rule-engine/Scene/Save/action/Notify/variableItem/User.vue @@ -65,8 +65,8 @@ v-else style="width: calc(100% - 120px)" placeholder="请选择收信人" - @select=" - (key, node) => onChange(source, key, node?.isRelation, node?.name) + @change=" + (key, label) => onChange(source, key, undefined, label) " :tree-data="treeData" :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }" @@ -209,6 +209,7 @@ const treeData = ref([ ]); const mySource = ref('relation'); const labelMap = new Map(); +const treeDataMap = new Map() const getRelationUsers = async (notifyType: string, notifierId: string) => { let resp = undefined; @@ -250,6 +251,7 @@ const getUser = async (_source: string, triggerType: string) => { } if (platformResp.status === 200) { newTree[0].children = platformResp.result.map((item: any) => { + treeDataMap.set(item.id, item) return { ...item, value: item.id, @@ -265,6 +267,7 @@ const getUser = async (_source: string, triggerType: string) => { key: 'p2', selectable: false, children: relationResp.result.map((item: any) => { + treeDataMap.set(item.id, item) return { ...item, value: item.id, @@ -324,6 +327,7 @@ const onChange = ( _name?: string, ) => { let _values: any = undefined; + const _names: string[] = Array.isArray(_name) ? _name : [_name || '']; if (Array.isArray(_value)) { if (props?.notify?.notifyType === 'email') { @@ -339,7 +343,9 @@ const onChange = ( } } } else { - _values = getObj(_source, _value, isRelation); + const item = treeDataMap.get(_value) + const _isRelation = item.isRelation + _values = getObj(_source, _value, _isRelation); } emit('update:value', _values); emit('change', _names.filter((item) => !!item).join(',')); diff --git a/src/views/rule-engine/Scene/Save/components/Terms/ParamsItem.vue b/src/views/rule-engine/Scene/Save/components/Terms/ParamsItem.vue index 8b200349..0013a53b 100644 --- a/src/views/rule-engine/Scene/Save/components/Terms/ParamsItem.vue +++ b/src/views/rule-engine/Scene/Save/components/Terms/ParamsItem.vue @@ -316,13 +316,13 @@ const termsTypeSelect = (e: { key: string, name: string }) => { const valueSelect = (v: any, label: string, labelObj: Record, option: any) => { if (paramsValue.value?.source === 'metric') { - paramsValue.metric = option?.id + paramsValue.value.metric = option?.id } const newValues = { ...paramsValue } if (paramsValue.value?.source !== 'metric') { - delete newValues.metric + delete newValues.value.metric } emit('update:value', { ...newValues })