|
|
@@ -1,6 +1,7 @@ |
|
|
|
<template> |
|
|
|
<el-popover placement="bottom-start" :width="width" trigger="click" v-model:visible="visible"> |
|
|
|
<template #reference> |
|
|
|
<!-- {{ userInfo }} --> |
|
|
|
<el-select clearable v-model="userInfo" placeholder="请选择接收消息的用户" popper-class="popper-content" style="width: 100%" |
|
|
|
collapse-tags collapse-tags-tooltip @remove-tag="removeTag" multiple value-key="value"></el-select> |
|
|
|
</template> |
|
|
@@ -36,7 +37,8 @@ const props = defineProps({ |
|
|
|
default: 400, |
|
|
|
}, |
|
|
|
modelValue: { |
|
|
|
default: '', |
|
|
|
type: Array, |
|
|
|
default: () => [], |
|
|
|
}, |
|
|
|
type: { |
|
|
|
default: '', |
|
|
@@ -47,6 +49,14 @@ const props = defineProps({ |
|
|
|
}, |
|
|
|
}) |
|
|
|
let isNum = false |
|
|
|
|
|
|
|
// 监听 props.modelValue 变化,同步到本地变量 |
|
|
|
watchEffect(() => { |
|
|
|
if (props.modelValue && props.modelValue.length > 0) { |
|
|
|
localUserInfo.value = [...props.modelValue] |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
// 处理idList |
|
|
|
watchEffect(() => { |
|
|
|
const userList = props.userList |
|
|
@@ -70,15 +80,17 @@ const handleId = (userList) => { |
|
|
|
// 支持多种匹配方式:openId、value、wxOpenid |
|
|
|
let data = tableData.value.find( |
|
|
|
(tableItem) => |
|
|
|
tableItem.wxOpenid == item.openId |
|
|
|
tableItem.wxOpenid == item.openId|| |
|
|
|
tableItem.mpOpenid == item.openId |
|
|
|
) |
|
|
|
console.log(data,'table.data') |
|
|
|
// 如果找到了匹配的用户,使用实际的用户名,否则使用传入的标签 |
|
|
|
const label = data ? (data.userName || data.mobile) : (item.label || item.openId || item.value) |
|
|
|
console.log(label,'label') |
|
|
|
// const label = data ? (data.userName || data.mobile) : (item.label || item.openId || item.value) |
|
|
|
// console.log(label,'label') |
|
|
|
userInfoData.push({ |
|
|
|
label: label, |
|
|
|
value: item.openId || item.value, |
|
|
|
label: data?data.userName || data.mobile:'', |
|
|
|
value:data?data.openId||data.mpOpenid:'', |
|
|
|
// value: (data && (data.mpOpenid || data.wxOpenid || data.openId)) || item.mpOpenid || item.wxOpenid || item.openId || item.value, |
|
|
|
}) |
|
|
|
console.log(userInfoData,'userInfoData') |
|
|
|
if (data) { |
|
|
@@ -101,8 +113,11 @@ const handleId = (userList) => { |
|
|
|
} else { |
|
|
|
otherList.data = other |
|
|
|
} |
|
|
|
userInfo.value = userInfoData |
|
|
|
handleInitSelect() //选择当前页数据 |
|
|
|
userInfo.value = [...userInfoData] |
|
|
|
nextTick(() => { |
|
|
|
console.log(userInfo.value,'userInfo.value') |
|
|
|
handleInitSelect() //选择当前页数据 |
|
|
|
}) |
|
|
|
} |
|
|
|
// 切换页数 |
|
|
|
const switchPage = () => { |
|
|
@@ -139,11 +154,16 @@ const switchPage = () => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 本地管理显示的数据 |
|
|
|
const localUserInfo = ref<any[]>([]) |
|
|
|
|
|
|
|
const userInfo = computed({ |
|
|
|
get: function () { |
|
|
|
return props.modelValue |
|
|
|
return localUserInfo.value |
|
|
|
}, |
|
|
|
set: function (newValue) { |
|
|
|
console.log(newValue,'newValue') |
|
|
|
localUserInfo.value = newValue |
|
|
|
emit('update:modelValue', newValue) |
|
|
|
}, |
|
|
|
}) |