fix: bug#12122

This commit is contained in:
xieyonghong 2023-04-24 17:39:17 +08:00
parent 5ac7ff4906
commit 8d817c5365
3 changed files with 13 additions and 6 deletions

View File

@ -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();
}

View File

@ -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<any[]>([
]);
const mySource = ref<string>('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(','));

View File

@ -316,13 +316,13 @@ const termsTypeSelect = (e: { key: string, name: string }) => {
const valueSelect = (v: any, label: string, labelObj: Record<number, any>, 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 })