feat(groups): align GroupList to 云客 — per-channel tabs, view-chat action
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+332
-343
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { getGroups } from '@/api'
|
||||
@@ -7,152 +7,200 @@ import type { Channel, Group } from '@/api/types'
|
||||
import { useChannelStore } from '@/stores/channel'
|
||||
import { channelLabel, formatTime } from '@/utils/format'
|
||||
import { buildGroupSections, readField } from '@/utils/groupFields'
|
||||
import { fromTypeLabel } from '@/utils/customerFields'
|
||||
|
||||
/**
|
||||
* 群列表 — channel-tabbed view mirroring 云客「沟通」板块的群列表.
|
||||
*
|
||||
* 微信群 tab 对齐 云客 /cms/wechat/wechatlist/wechatdetail/2/{wxId}
|
||||
* (7 列: 群信息/数据来源/群主信息/群成员数量/群成员好友数量/消息数量/操作).
|
||||
* WhatsApp群 tab 对齐 云客 /cms/wechat/waBusiness/friendlist 的群列表 tab
|
||||
* (8 列: 序号/员工信息/员工WhatsApp/群信息/群消息数量/添加时间/最新消息时间/操作).
|
||||
* 操作列「查看聊天记录」→ group-chat;row-click 开全字段 drawer。
|
||||
*
|
||||
* ⚠️ smoke.db 暂无群数据(chat_group 0 行)+ WA 群抓取缺失 → 表格空表(列结构对)。
|
||||
* 部分 wechat 群字段(fromType/群主昵称/群主wxId/群成员好友数量)与全部 WA 群字段为
|
||||
* 从云客采集推断,经 readField raw_json fallback 读取;待 smoke.db 有群数据核对。
|
||||
*/
|
||||
type TabKey = Channel
|
||||
interface TabState {
|
||||
items: Group[]
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
loading: boolean
|
||||
errorMsg: string | null
|
||||
loaded: boolean
|
||||
}
|
||||
function freshTabState(): TabState {
|
||||
return { items: [], total: 0, page: 1, pageSize: 20, loading: false, errorMsg: null, loaded: false }
|
||||
}
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const channelStore = useChannelStore()
|
||||
|
||||
// activeTab 跟随全局 channelStore(StaffList viewGroups 先 setChannel 再 push /groups)。
|
||||
// channel 总是具体值('wechat' | 'whatsapp'),不会是 'all'。
|
||||
const activeTab = ref<TabKey>(channelStore.channel === 'whatsapp' ? 'whatsapp' : 'wechat')
|
||||
const tabState = reactive<Record<TabKey, TabState>>({
|
||||
wechat: freshTabState(),
|
||||
whatsapp: freshTabState(),
|
||||
})
|
||||
|
||||
// 全字段抽屉(两 tab 共享)
|
||||
const drawerOpen = ref(false)
|
||||
const drawerGroup = ref<Group | null>(null)
|
||||
|
||||
// query 过滤(两 tab 共享)
|
||||
const ownerId = computed<string | null>(() =>
|
||||
route.query.owner_account_id ? String(route.query.owner_account_id) : null,
|
||||
)
|
||||
|
||||
const groups = ref<Group[]>([])
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = ref(20)
|
||||
const loading = ref(false)
|
||||
const errorMsg = ref<string | null>(null)
|
||||
|
||||
// All-fields drawer state.
|
||||
const drawerOpen = ref(false)
|
||||
const drawerGroup = ref<Group | null>(null)
|
||||
|
||||
const channelOptions = [
|
||||
{ value: 'all' as const, label: '全部渠道' },
|
||||
{ value: 'wechat' as const, label: '微信' },
|
||||
{ value: 'whatsapp' as const, label: 'WhatsApp' },
|
||||
]
|
||||
|
||||
const channelLabelCurrent = computed(() =>
|
||||
channelLabel(channelStore.channel === 'all' ? null : channelStore.channel),
|
||||
)
|
||||
|
||||
function channelTagType(c: Group['channel']) {
|
||||
return c === 'wechat' ? 'success' : 'warning'
|
||||
}
|
||||
|
||||
function onChannelChange(value: string | number | boolean | undefined): void {
|
||||
channelStore.setChannel(value as Channel | 'all')
|
||||
}
|
||||
|
||||
async function load(): Promise<void> {
|
||||
loading.value = true
|
||||
errorMsg.value = null
|
||||
try {
|
||||
const res = await getGroups({
|
||||
channel: channelStore.channel,
|
||||
page: page.value,
|
||||
page_size: pageSize.value,
|
||||
owner_account_id: ownerId.value ?? undefined,
|
||||
})
|
||||
groups.value = res.items
|
||||
total.value = res.total
|
||||
} catch (e) {
|
||||
errorMsg.value = (e as Error).message
|
||||
ElMessage.error(`群列表加载失败:${(e as Error).message}`)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handlePageChange(p: number): void {
|
||||
page.value = p
|
||||
load()
|
||||
}
|
||||
|
||||
function handlePageSizeChange(s: number): void {
|
||||
pageSize.value = s
|
||||
page.value = 1
|
||||
load()
|
||||
}
|
||||
|
||||
// React to the top-bar channel filter + owner_account_id query.
|
||||
watch(
|
||||
() => [channelStore.channel, ownerId.value] as const,
|
||||
() => {
|
||||
page.value = 1
|
||||
load()
|
||||
},
|
||||
)
|
||||
|
||||
/** Drop the ``owner_account_id`` query param while preserving any others. */
|
||||
function clearOwnerFilter(): void {
|
||||
const { owner_account_id: _drop, ...rest } = route.query
|
||||
void _drop
|
||||
router.replace({ query: rest })
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a raw_json camelCase key off a group, preferring the structured
|
||||
* snake_case column when it is populated. The first argument is the row so the
|
||||
* table can use the same helper as the drawer.
|
||||
*/
|
||||
// ---- cell helpers (structured-first via groupFields.readField) ----
|
||||
function cell(row: Group, camelKey: string): unknown {
|
||||
return readField(row, camelKey)
|
||||
}
|
||||
|
||||
function cellText(row: Group, camelKey: string): string {
|
||||
const v = cell(row, camelKey)
|
||||
return v === null || v === undefined || v === '' ? '--' : String(v)
|
||||
}
|
||||
|
||||
/** 时间列:number→formatTime;字符串直显;空→--。 */
|
||||
function cellTimeText(row: Group, camelKey: string): string {
|
||||
const v = cell(row, camelKey)
|
||||
if (typeof v === 'number' && Number.isFinite(v)) return formatTime(v)
|
||||
if (typeof v === 'string' && v.trim()) return v.trim()
|
||||
return '--'
|
||||
}
|
||||
/** 数字列,缺失回 0。 */
|
||||
function cellNum(row: Group, camelKey: string, fallback = 0): number {
|
||||
const v = cell(row, camelKey)
|
||||
return typeof v === 'number' && Number.isFinite(v) ? v : fallback
|
||||
}
|
||||
/** 数据来源列:fromType 代码→文案(复用 customerFields.fromTypeLabel)。 */
|
||||
function fromTypeText(row: Group): string {
|
||||
return fromTypeLabel(cell(row, 'fromType'))
|
||||
}
|
||||
function imageCell(row: Group, camelKey: string): string | undefined {
|
||||
const v = cell(row, camelKey)
|
||||
return typeof v === 'string' && v !== '' ? v : undefined
|
||||
}
|
||||
|
||||
function timeCell(row: Group, camelKey: string): number | undefined {
|
||||
const v = cell(row, camelKey)
|
||||
return typeof v === 'number' ? v : undefined
|
||||
/** WhatsApp tab 行序号(含分页偏移)。 */
|
||||
function waSerial(index: number): number {
|
||||
const st = tabState.whatsapp
|
||||
return (st.page - 1) * st.pageSize + index + 1
|
||||
}
|
||||
|
||||
function openDrawer(row: Group): void {
|
||||
// Row click opens the all-fields drawer; the timeline is reached from the
|
||||
// drawer's 查看聊天记录 action (preserves the owner/room/channel keying).
|
||||
drawerGroup.value = row
|
||||
drawerOpen.value = true
|
||||
// ---- per-tab loading ----
|
||||
async function loadTab(ch: TabKey): Promise<void> {
|
||||
const st = tabState[ch]
|
||||
st.loading = true
|
||||
st.errorMsg = null
|
||||
try {
|
||||
const res = await getGroups({
|
||||
channel: ch,
|
||||
page: st.page,
|
||||
page_size: st.pageSize,
|
||||
owner_account_id: ownerId.value ?? undefined,
|
||||
})
|
||||
st.items = res.items
|
||||
st.total = res.total
|
||||
st.loaded = true
|
||||
} catch (e) {
|
||||
st.errorMsg = (e as Error).message
|
||||
ElMessage.error(`群列表加载失败:${(e as Error).message}`)
|
||||
} finally {
|
||||
st.loading = false
|
||||
}
|
||||
}
|
||||
function handlePageChange(ch: TabKey, p: number): void {
|
||||
tabState[ch].page = p
|
||||
loadTab(ch)
|
||||
}
|
||||
function handlePageSizeChange(ch: TabKey, s: number): void {
|
||||
tabState[ch].pageSize = s
|
||||
tabState[ch].page = 1
|
||||
loadTab(ch)
|
||||
}
|
||||
function onWechatPageChange(p: number): void { handlePageChange('wechat', p) }
|
||||
function onWechatPageSizeChange(s: number): void { handlePageSizeChange('wechat', s) }
|
||||
function onWhatsappPageChange(p: number): void { handlePageChange('whatsapp', p) }
|
||||
function onWhatsappPageSizeChange(s: number): void { handlePageSizeChange('whatsapp', s) }
|
||||
|
||||
function onTabChange(name: string | number): void {
|
||||
const ch = String(name) as TabKey
|
||||
channelStore.setChannel(ch)
|
||||
if (!tabState[ch].loaded) loadTab(ch)
|
||||
}
|
||||
|
||||
const drawerSections = computed(() =>
|
||||
drawerGroup.value ? buildGroupSections(drawerGroup.value) : [],
|
||||
)
|
||||
|
||||
const drawerAvatarSrc = computed<string | undefined>(() => {
|
||||
const g = drawerGroup.value
|
||||
if (!g) return undefined
|
||||
return imageCell(g, 'headImageUrl') ?? undefined
|
||||
})
|
||||
|
||||
const drawerCanChat = computed(() => !!drawerGroup.value?.owner_account_id)
|
||||
|
||||
function goChatFromDrawer(): void {
|
||||
const row = drawerGroup.value
|
||||
if (!row) return
|
||||
// ---- 操作列:查看聊天记录 → group-chat ----
|
||||
function viewChat(row: Group): void {
|
||||
if (!row.owner_account_id) {
|
||||
ElMessage.warning('该群缺少归属账号,无法查看聊天记录')
|
||||
return
|
||||
}
|
||||
router.push({
|
||||
name: 'group-chat',
|
||||
params: {
|
||||
channel: row.channel,
|
||||
ownerId: row.owner_account_id,
|
||||
roomId: row.room_id,
|
||||
},
|
||||
params: { channel: row.channel, ownerId: row.owner_account_id, roomId: row.room_id },
|
||||
})
|
||||
}
|
||||
/** drawer 内「查看聊天记录」入口:drawerGroup 是 ref<Group|null>,模板嵌套不保证窄化,用 wrapper 守卫。 */
|
||||
function viewChatFromDrawer(): void {
|
||||
const row = drawerGroup.value
|
||||
if (!row) return
|
||||
viewChat(row)
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
/** 清除 owner_account_id query(保留其余 query)。 */
|
||||
function clearOwnerFilter(): void {
|
||||
const { owner_account_id: _drop, ...rest } = route.query
|
||||
void _drop
|
||||
router.replace({ query: rest })
|
||||
}
|
||||
|
||||
// ---- drawer ----
|
||||
function openDrawer(row: Group): void {
|
||||
drawerGroup.value = row
|
||||
drawerOpen.value = true
|
||||
}
|
||||
const drawerSections = computed(() =>
|
||||
drawerGroup.value ? buildGroupSections(drawerGroup.value) : [],
|
||||
)
|
||||
const drawerAvatarSrc = computed<string | undefined>(() => {
|
||||
const g = drawerGroup.value
|
||||
if (!g) return undefined
|
||||
// Group 类型无 head_image_url 结构化列(head_image_url 只在 Customer 上);
|
||||
// imageCell 经 groupFields.readField 已读 STRUCTURED_ALIAS + raw_json.headImageUrl。
|
||||
return imageCell(g, 'headImageUrl') ?? undefined
|
||||
})
|
||||
const drawerCanChat = computed(() => !!drawerGroup.value?.owner_account_id)
|
||||
|
||||
// 全局 channel 变化 → activeTab 跟随 + lazy-load(同 CustomerList)。
|
||||
watch(
|
||||
() => channelStore.channel,
|
||||
(ch) => {
|
||||
const next = ch === 'whatsapp' ? 'whatsapp' : 'wechat'
|
||||
if (next !== activeTab.value) {
|
||||
activeTab.value = next
|
||||
if (!tabState[next].loaded) loadTab(next)
|
||||
}
|
||||
},
|
||||
)
|
||||
// query(owner)变化 → 重置两 tab page + 重载当前 tab。
|
||||
watch(
|
||||
() => ownerId.value,
|
||||
() => {
|
||||
tabState.wechat.loaded = false
|
||||
tabState.whatsapp.loaded = false
|
||||
tabState.wechat.page = 1
|
||||
tabState.whatsapp.page = 1
|
||||
loadTab(activeTab.value)
|
||||
},
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
loadTab(activeTab.value)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -161,125 +209,165 @@ onMounted(load)
|
||||
<div>
|
||||
<h2 style="margin: 0 0 4px; font-size: 16px">群列表</h2>
|
||||
<span class="yk-groups__sub">
|
||||
共 {{ total }} 条
|
||||
共 {{ tabState[activeTab].total }} 条
|
||||
<template v-if="ownerId"> · 员工账号:{{ ownerId }}</template>
|
||||
· 渠道:{{ channelLabelCurrent }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="yk-groups__filters">
|
||||
<el-radio-group
|
||||
:model-value="channelStore.channel"
|
||||
size="small"
|
||||
@change="onChannelChange"
|
||||
>
|
||||
<el-radio-button
|
||||
v-for="opt in channelOptions"
|
||||
:key="opt.value"
|
||||
:value="opt.value"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</el-radio-button>
|
||||
</el-radio-group>
|
||||
<el-button
|
||||
v-if="ownerId"
|
||||
size="small"
|
||||
type="info"
|
||||
plain
|
||||
@click="clearOwnerFilter"
|
||||
>
|
||||
<el-button v-if="ownerId" size="small" type="info" plain @click="clearOwnerFilter">
|
||||
清除员工筛选
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-alert
|
||||
v-if="errorMsg"
|
||||
:title="errorMsg"
|
||||
type="error"
|
||||
show-icon
|
||||
:closable="false"
|
||||
style="margin-bottom: 12px"
|
||||
/>
|
||||
<el-tabs v-model="activeTab" class="yk-groups__tabs" @tab-change="onTabChange">
|
||||
<!-- ============================================================
|
||||
微信群 — 7 列,对齐云客 wechatdetail/2/{wxId}.
|
||||
============================================================ -->
|
||||
<el-tab-pane label="微信群" name="wechat">
|
||||
<el-alert
|
||||
v-if="tabState.wechat.errorMsg"
|
||||
:title="tabState.wechat.errorMsg"
|
||||
type="error"
|
||||
show-icon
|
||||
:closable="false"
|
||||
style="margin-bottom: 12px"
|
||||
/>
|
||||
<el-table
|
||||
v-loading="tabState.wechat.loading"
|
||||
:data="tabState.wechat.items"
|
||||
stripe
|
||||
border
|
||||
row-key="room_id"
|
||||
style="width: 100%"
|
||||
:row-class-name="() => 'yk-clickable-row'"
|
||||
empty-text="暂无微信群数据"
|
||||
@row-click="openDrawer"
|
||||
>
|
||||
<el-table-column label="群信息" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<div class="yk-staffinfo__nick" :title="cellText(row, 'chatRoomName')">{{ cellText(row, 'chatRoomName') }}</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="数据来源" min-width="110">
|
||||
<template #default="{ row }">{{ fromTypeText(row) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="群主信息" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<div class="yk-staffinfo__nick" :title="cellText(row, 'userName')">{{ cellText(row, 'userName') }}</div>
|
||||
<div class="yk-staffinfo__muted">{{ cellText(row, 'wxId') }}</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="群成员数量" width="110" align="right">
|
||||
<template #default="{ row }">{{ cellNum(row, 'memberCount') }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="群成员好友数量" width="130" align="right">
|
||||
<template #default="{ row }">{{ cellNum(row, 'contactCount') }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="消息数量" width="100" align="right">
|
||||
<template #default="{ row }">{{ cellNum(row, 'messageCount') }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="130" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" size="small" @click.stop="viewChat(row)">
|
||||
查看聊天记录
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="yk-groups__pager">
|
||||
<el-pagination
|
||||
:current-page="tabState.wechat.page"
|
||||
:page-size="tabState.wechat.pageSize"
|
||||
:page-sizes="[20, 50, 100]"
|
||||
:total="tabState.wechat.total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
background
|
||||
@current-change="onWechatPageChange"
|
||||
@size-change="onWechatPageSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="groups"
|
||||
stripe
|
||||
border
|
||||
row-key="room_id"
|
||||
style="width: 100%"
|
||||
:row-class-name="() => 'yk-clickable-row'"
|
||||
empty-text="暂无群数据"
|
||||
@row-click="openDrawer"
|
||||
>
|
||||
<el-table-column label="群名" min-width="180">
|
||||
<template #default="{ row }">
|
||||
{{ row.room_name || cellText(row, 'chatRoomName') || row.room_id }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="群ID" min-width="200" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<span style="font-family: monospace; font-size: 12px">{{ row.room_id }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="成员数" prop="member_count" width="90" align="right">
|
||||
<template #default="{ row }">{{ row.member_count ?? '--' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="群主" min-width="140">
|
||||
<template #default="{ row }">
|
||||
<span v-if="cell(row, 'userName') || cell(row, 'userPhone')">
|
||||
<template v-if="cell(row, 'userName')">{{ cellText(row, 'userName') }}</template>
|
||||
<span
|
||||
v-if="cell(row, 'userName') && cell(row, 'userPhone')"
|
||||
style="color: #c0c4cc"
|
||||
>
|
||||
/
|
||||
</span>
|
||||
<template v-if="cell(row, 'userPhone')">{{ cellText(row, 'userPhone') }}</template>
|
||||
</span>
|
||||
<span v-else style="color: #c0c4cc">--</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="归属微信" min-width="130">
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.owner_account_nickname">{{ row.owner_account_nickname }}</span>
|
||||
<span v-else-if="cell(row, 'wechatNickName')">{{ cellText(row, 'wechatNickName') }}</span>
|
||||
<span v-else-if="row.owner_account_id">{{ row.owner_account_id }}</span>
|
||||
<span v-else style="color: #c0c4cc">--</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="消息数" prop="message_count" width="90" align="right">
|
||||
<template #default="{ row }">{{ row.message_count ?? '--' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="最近聊天" width="160">
|
||||
<template #default="{ row }">
|
||||
{{ formatTime(row.last_chat_time ?? timeCell(row, 'lastChatTime')) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="渠道" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="channelTagType(row.channel)" size="small" effect="plain">
|
||||
{{ channelLabel(row.channel) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- ============================================================
|
||||
WhatsApp群 — 8 列,对齐云客 waBusiness/friendlist 群列表 tab.
|
||||
⚠️ WA 群抓取缺失 → 空表;字段推断,待 WA 抓取实现后核对。
|
||||
============================================================ -->
|
||||
<el-tab-pane label="WhatsApp群" name="whatsapp">
|
||||
<el-alert
|
||||
v-if="tabState.whatsapp.errorMsg"
|
||||
:title="tabState.whatsapp.errorMsg"
|
||||
type="error"
|
||||
show-icon
|
||||
:closable="false"
|
||||
style="margin-bottom: 12px"
|
||||
/>
|
||||
<el-table
|
||||
v-loading="tabState.whatsapp.loading"
|
||||
:data="tabState.whatsapp.items"
|
||||
stripe
|
||||
border
|
||||
row-key="room_id"
|
||||
style="width: 100%"
|
||||
:row-class-name="() => 'yk-clickable-row'"
|
||||
empty-text="暂无 WhatsApp 群数据"
|
||||
@row-click="openDrawer"
|
||||
>
|
||||
<el-table-column label="序号" width="70" align="center">
|
||||
<template #default="{ $index }">{{ waSerial($index) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="员工信息" min-width="150">
|
||||
<template #default="{ row }">
|
||||
<div class="yk-staffinfo__nick" :title="cellText(row, 'salesNickName')">{{ cellText(row, 'salesNickName') }}</div>
|
||||
<div class="yk-staffinfo__muted">{{ cellText(row, 'salePhone') }}</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="员工WhatsApp" min-width="200">
|
||||
<template #default="{ row }">
|
||||
<div class="yk-staffinfo__nick" :title="cellText(row, 'userName')">{{ cellText(row, 'userName') }}</div>
|
||||
<div class="yk-staffinfo__muted">{{ cellText(row, 'uid') }}</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="群信息" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<div class="yk-staffinfo__nick" :title="cellText(row, 'chatRoomName')">{{ cellText(row, 'chatRoomName') }}</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="群消息数量" width="120" align="right">
|
||||
<template #default="{ row }">{{ cellNum(row, 'messageCount') }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="添加时间" width="160">
|
||||
<template #default="{ row }">{{ cellTimeText(row, 'createTime') }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="最新消息时间" width="160">
|
||||
<template #default="{ row }">{{ cellTimeText(row, 'lastUpdate') }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="130" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" size="small" @click.stop="viewChat(row)">
|
||||
查看聊天记录
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="yk-groups__pager">
|
||||
<el-pagination
|
||||
:current-page="tabState.whatsapp.page"
|
||||
:page-size="tabState.whatsapp.pageSize"
|
||||
:page-sizes="[20, 50, 100]"
|
||||
:total="tabState.whatsapp.total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
background
|
||||
@current-change="onWhatsappPageChange"
|
||||
@size-change="onWhatsappPageSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
<div class="yk-groups__pager">
|
||||
<el-pagination
|
||||
:current-page="page"
|
||||
:page-size="pageSize"
|
||||
:page-sizes="[20, 50, 100]"
|
||||
:total="total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
background
|
||||
@current-change="handlePageChange"
|
||||
@size-change="handlePageSizeChange"
|
||||
/>
|
||||
</div>
|
||||
<p class="yk-groups__hint">点击任意一行查看群全部字段。</p>
|
||||
|
||||
<!-- All-fields drawer -->
|
||||
<!-- 全字段抽屉(保留现状:avatar + buildGroupSections + 查看聊天记录) -->
|
||||
<el-drawer
|
||||
v-model="drawerOpen"
|
||||
:title="drawerGroup ? `群详情 · ${drawerGroup.room_name ?? drawerGroup.room_id}` : '群详情'"
|
||||
@@ -288,19 +376,11 @@ onMounted(load)
|
||||
>
|
||||
<template v-if="drawerGroup">
|
||||
<div class="yk-drawer__topbar">
|
||||
<el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
:disabled="!drawerCanChat"
|
||||
@click="goChatFromDrawer"
|
||||
>
|
||||
<el-button type="primary" size="small" :disabled="!drawerCanChat" @click="viewChatFromDrawer">
|
||||
查看聊天记录
|
||||
</el-button>
|
||||
<span v-if="!drawerCanChat" class="yk-drawer__topbar-hint">
|
||||
该群缺少归属账号,无法查看聊天
|
||||
</span>
|
||||
<span v-if="!drawerCanChat" class="yk-drawer__topbar-hint">该群缺少归属账号,无法查看聊天</span>
|
||||
</div>
|
||||
|
||||
<div class="yk-drawer__avatar">
|
||||
<el-avatar :size="56" :src="drawerAvatarSrc" shape="square">
|
||||
{{ (drawerGroup.room_name || drawerGroup.room_id || '?').slice(0, 1) }}
|
||||
@@ -311,25 +391,17 @@ onMounted(load)
|
||||
</div>
|
||||
<div class="yk-drawer__avatar-sub">
|
||||
{{ channelLabel(drawerGroup.channel) }}
|
||||
<template v-if="cell(drawerGroup, 'wechatNickName')">
|
||||
· {{ cell(drawerGroup, 'wechatNickName') }}
|
||||
</template>
|
||||
<template v-if="cell(drawerGroup, 'wechatNickName')"> · {{ cellText(drawerGroup, 'wechatNickName') }}</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-for="section in drawerSections" :key="section.title" class="yk-drawer__section">
|
||||
<el-divider content-position="left">{{ section.title }}</el-divider>
|
||||
<dl class="yk-drawer__kv">
|
||||
<div v-for="f in section.fields" :key="f.key" class="yk-drawer__kv-item">
|
||||
<dt>{{ f.label }}</dt>
|
||||
<dd v-if="f.render === 'image'" class="yk-drawer__img">
|
||||
<el-image
|
||||
:src="String(f.value)"
|
||||
:preview-src-list="[String(f.value)]"
|
||||
fit="cover"
|
||||
hide-on-click-modal
|
||||
/>
|
||||
<el-image :src="String(f.value)" :preview-src-list="[String(f.value)]" fit="cover" hide-on-click-modal />
|
||||
</dd>
|
||||
<dd v-else-if="f.render === 'empty'" class="yk-drawer__empty">—</dd>
|
||||
<dd v-else>{{ f.text }}</dd>
|
||||
@@ -342,109 +414,26 @@ onMounted(load)
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.yk-groups__header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
gap: 16px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.yk-groups__header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
|
||||
.yk-groups__sub { color: #909399; font-size: 13px; }
|
||||
.yk-groups__filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
|
||||
.yk-groups__tabs { margin-top: 4px; }
|
||||
.yk-groups__pager { margin-top: 12px; display: flex; justify-content: flex-end; }
|
||||
.yk-groups__hint { margin: 8px 2px 0; font-size: 12px; color: #c0c4cc; }
|
||||
|
||||
.yk-groups__sub {
|
||||
color: #909399;
|
||||
font-size: 13px;
|
||||
}
|
||||
.yk-staffinfo__nick { font-weight: 600; font-size: 13px; color: #303133; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.yk-staffinfo__muted { font-size: 12px; color: #909399; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
|
||||
.yk-groups__filters {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.yk-groups__pager {
|
||||
margin-top: 12px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.yk-groups__hint {
|
||||
margin: 8px 2px 0;
|
||||
font-size: 12px;
|
||||
color: #c0c4cc;
|
||||
}
|
||||
|
||||
.yk-drawer__topbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.yk-drawer__topbar-hint {
|
||||
color: #c0c4cc;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.yk-drawer__avatar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.yk-drawer__avatar-meta {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.yk-drawer__avatar-name {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.yk-drawer__avatar-sub {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.yk-drawer__kv {
|
||||
margin: 0 0 8px;
|
||||
}
|
||||
|
||||
.yk-drawer__kv-item {
|
||||
display: grid;
|
||||
grid-template-columns: 110px 1fr;
|
||||
gap: 8px 12px;
|
||||
padding: 3px 0;
|
||||
}
|
||||
|
||||
.yk-drawer__kv dt {
|
||||
color: #909399;
|
||||
font-size: 13px;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.yk-drawer__kv dd {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
color: #303133;
|
||||
word-break: break-all;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.yk-drawer__img :deep(.el-image) {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid var(--el-border-color-light, #e4e7ed);
|
||||
}
|
||||
|
||||
.yk-drawer__empty {
|
||||
color: #c0c4cc;
|
||||
}
|
||||
.yk-drawer__topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
|
||||
.yk-drawer__topbar-hint { color: #c0c4cc; font-size: 12px; }
|
||||
.yk-drawer__avatar { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
|
||||
.yk-drawer__avatar-meta { min-width: 0; }
|
||||
.yk-drawer__avatar-name { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.yk-drawer__avatar-sub { font-size: 12px; color: #909399; margin-top: 2px; }
|
||||
.yk-drawer__kv { margin: 0 0 8px; }
|
||||
.yk-drawer__kv-item { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; padding: 3px 0; }
|
||||
.yk-drawer__kv dt { color: #909399; font-size: 13px; word-break: break-all; }
|
||||
.yk-drawer__kv dd { margin: 0; font-size: 13px; color: #303133; word-break: break-all; min-width: 0; }
|
||||
.yk-drawer__img :deep(.el-image) { width: 64px; height: 64px; border-radius: 4px; border: 1px solid var(--el-border-color-light, #e4e7ed); }
|
||||
.yk-drawer__empty { color: #c0c4cc; }
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user