feat(ui): conversation account binding for send/receive primary/backup
- Filter account selector by conversation channelType - Add sortOrder priority input - Use currentBindConversation ref for binding context
This commit is contained in:
@@ -95,7 +95,7 @@
|
|||||||
<el-form-item label="账号">
|
<el-form-item label="账号">
|
||||||
<el-select v-model="bindAccountForm.accountId" placeholder="选择账号" style="width: 100%">
|
<el-select v-model="bindAccountForm.accountId" placeholder="选择账号" style="width: 100%">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="a in accounts"
|
v-for="a in filteredBindAccounts"
|
||||||
:key="a.id"
|
:key="a.id"
|
||||||
:label="a.accountName"
|
:label="a.accountName"
|
||||||
:value="a.id"
|
:value="a.id"
|
||||||
@@ -110,6 +110,9 @@
|
|||||||
<el-option label="接收备用号" :value="4" />
|
<el-option label="接收备用号" :value="4" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="优先级">
|
||||||
|
<el-input-number v-model="bindAccountForm.sortOrder" :min="0" style="width: 100%" />
|
||||||
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button @click="bindAccountVisible = false">取消</el-button>
|
<el-button @click="bindAccountVisible = false">取消</el-button>
|
||||||
@@ -214,6 +217,12 @@ function formatAccountName(id: number | undefined) {
|
|||||||
return accountMap.value.get(id) || id
|
return accountMap.value.get(id) || id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const filteredBindAccounts = computed(() => {
|
||||||
|
const channelType = currentBindConversation.value?.channelType
|
||||||
|
if (!channelType) return accounts.value
|
||||||
|
return accounts.value.filter((a: any) => a.channelType === channelType)
|
||||||
|
})
|
||||||
|
|
||||||
function formatConversationType(type: number | undefined) {
|
function formatConversationType(type: number | undefined) {
|
||||||
if (type === 1) return '单聊'
|
if (type === 1) return '单聊'
|
||||||
if (type === 2) return '群聊'
|
if (type === 2) return '群聊'
|
||||||
@@ -312,23 +321,25 @@ async function handleDelete(row: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const bindAccountVisible = ref(false)
|
const bindAccountVisible = ref(false)
|
||||||
const currentConversationId = ref<number | undefined>()
|
const currentBindConversation = ref<any>(null)
|
||||||
const bindAccountForm = reactive({
|
const bindAccountForm = reactive({
|
||||||
accountId: undefined as number | undefined,
|
accountId: undefined as number | undefined,
|
||||||
bindingType: 1,
|
bindingType: 1,
|
||||||
|
sortOrder: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
function openBindAccount(row: any) {
|
function openBindAccount(row: any) {
|
||||||
currentConversationId.value = row.id
|
currentBindConversation.value = row
|
||||||
bindAccountForm.accountId = undefined
|
bindAccountForm.accountId = undefined
|
||||||
bindAccountForm.bindingType = 1
|
bindAccountForm.bindingType = 1
|
||||||
|
bindAccountForm.sortOrder = 0
|
||||||
bindAccountVisible.value = true
|
bindAccountVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleBindAccount() {
|
async function handleBindAccount() {
|
||||||
if (!currentConversationId.value) return
|
if (!bindAccountForm.accountId || !currentBindConversation.value) return
|
||||||
try {
|
try {
|
||||||
await bindConversationAccount(currentConversationId.value, bindAccountForm)
|
await bindConversationAccount(currentBindConversation.value.id, bindAccountForm)
|
||||||
ElMessage.success('绑定成功')
|
ElMessage.success('绑定成功')
|
||||||
bindAccountVisible.value = false
|
bindAccountVisible.value = false
|
||||||
await loadConversations()
|
await loadConversations()
|
||||||
@@ -337,6 +348,8 @@ async function handleBindAccount() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const currentConversationId = ref<number | undefined>()
|
||||||
|
|
||||||
const bindTagsVisible = ref(false)
|
const bindTagsVisible = ref(false)
|
||||||
const bindTagsForm = reactive({
|
const bindTagsForm = reactive({
|
||||||
tagIds: [] as number[],
|
tagIds: [] as number[],
|
||||||
|
|||||||
Reference in New Issue
Block a user