feat(staffchat): 入口改造(StaffList/CustomerList微信行切新页)+useStaffProfile缓存+StatsPane固定列/金额格式+vitest依赖化
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -21,7 +21,8 @@ import { buildCustomerSections, fromTypeLabel, readField } from '@/utils/custome
|
||||
* WhatsApp客户 tab 对齐 云客 /cms/wechat/waBusiness/friendlist
|
||||
* (7 列: 序号/员工信息/员工WhatsApp/客户WhatsApp/添加时间/最新消息时间/操作).
|
||||
* 两 channel 列不同 → 各自独立列定义(同 StaffList 模式)。
|
||||
* 操作列「查看聊天记录」→ ChatTimeline;row-click 开全字段 drawer。
|
||||
* 操作列「查看聊天记录」→ 微信走新员工聊天窗口(staff-chat),WA 走 ChatTimeline;
|
||||
* row-click 开全字段 drawer。
|
||||
* 读字段用 readField(structured-first + raw_json fallback);时间用 cellTimeText
|
||||
* (number→formatTime,字符串直显)。
|
||||
*/
|
||||
@@ -249,12 +250,24 @@ function onWhatsappPageSizeChange(s: number): void { handlePageSizeChange('whats
|
||||
|
||||
// 侧栏菜单在同一页面内切换 ?channel= 时组件复用(不重挂载);go() 同时 setChannel,
|
||||
// 下方 channelStore watch 负责同步 activeTab + lazy-load。
|
||||
// ---- 操作列:查看聊天记录 → ChatTimeline ----
|
||||
// ---- 操作列:查看聊天记录。微信 → 新员工聊天窗口(single tab);
|
||||
// WA 保持旧 ChatTimeline(新窗口仅微信)。 ----
|
||||
function viewChat(row: Customer): void {
|
||||
if (!row.owner_account_id) {
|
||||
ElMessage.warning('该客户缺少归属账号,无法查看聊天记录')
|
||||
return
|
||||
}
|
||||
if (row.channel === 'wechat') {
|
||||
router.push({
|
||||
name: 'staff-chat',
|
||||
params: {
|
||||
ownerId: row.owner_account_id,
|
||||
tab: 'single',
|
||||
talkerId: row.friend_id,
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
router.push({
|
||||
name: 'chat',
|
||||
params: {
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
<!-- 员工聊天窗口骨架(对齐云客 wechat-window): 左栏资料卡+导航 / 中列会话 / 右列内容。
|
||||
各 pane 由 Task 10-14 逐个替换占位实现。 -->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { computed, ref, toRef } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { getAccounts } from '@/api'
|
||||
import type { Account } from '@/api/types'
|
||||
import StaffChatSide, { TAB_KEYS, type TabKey } from '@/components/staffchat/StaffChatSide.vue'
|
||||
import SessionPane from '@/components/staffchat/SessionPane.vue'
|
||||
import ChatMain from '@/components/staffchat/ChatMain.vue'
|
||||
import MomentsPane from '@/components/staffchat/MomentsPane.vue'
|
||||
import ContactsPane from '@/components/staffchat/ContactsPane.vue'
|
||||
import StatsPane from '@/components/staffchat/StatsPane.vue'
|
||||
import { useStaffProfile } from '@/composables/useStaffProfile'
|
||||
|
||||
const props = defineProps<{ ownerId: string; tab?: string; talkerId?: string }>()
|
||||
const router = useRouter()
|
||||
@@ -23,18 +22,10 @@ function isTabKey(v: string | undefined): v is TabKey {
|
||||
// 这里 computed 兜底 undefined/'' → single
|
||||
const tab = computed<TabKey>(() => (isTabKey(props.tab) ? props.tab : 'single'))
|
||||
|
||||
const profile = ref<Account | null>(null)
|
||||
// 员工资料卡: useStaffProfile 模块级缓存(与 StatsPane 共享,全 app 一份请求);
|
||||
// 后端未起/未命中 → null,StaffChatSide 以 ownerId 兜底显示
|
||||
const { profile } = useStaffProfile(toRef(props, 'ownerId'))
|
||||
const collapsed = ref(false)
|
||||
async function loadProfile() {
|
||||
try {
|
||||
const res = await getAccounts({ channel: 'wechat', page: 1, page_size: 100 })
|
||||
profile.value = res.items.find(a => a.account_id === props.ownerId) ?? null
|
||||
} catch {
|
||||
// 后端未起/请求失败: 资料卡退化为 ownerId 兜底显示
|
||||
profile.value = null
|
||||
}
|
||||
}
|
||||
watch(() => props.ownerId, loadProfile, { immediate: true })
|
||||
|
||||
function onSelectTab(t: TabKey) {
|
||||
router.push({ name: 'staff-chat', params: { ownerId: props.ownerId, tab: t } })
|
||||
|
||||
@@ -264,7 +264,12 @@ function viewGroups(row: Account): void {
|
||||
|
||||
async function viewChat(row: Account) {
|
||||
// 账号级聊天窗口(左侧会话列表 + 右消息流);对齐云客 badge→聊天窗口。
|
||||
await router.push({ name: 'chat', params: { channel: row.channel, ownerId: row.account_id } })
|
||||
// 微信 → 新员工聊天窗口(五视图);WA 保持旧 ChatTimeline(新窗口仅微信)。
|
||||
if (row.channel === 'wechat') {
|
||||
await router.push({ name: 'staff-chat', params: { ownerId: row.account_id, tab: 'single' } })
|
||||
} else {
|
||||
await router.push({ name: 'chat', params: { channel: row.channel, ownerId: row.account_id } })
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -369,12 +374,13 @@ function joinFields(...vals: (string | undefined | null)[]): string {
|
||||
return parts.length ? parts.join(' ') : '--'
|
||||
}
|
||||
|
||||
/** modal 客户微信 → 该员工×客户聊天(带 StaffList 当前日期窗)。缺失 owner/talker 静默 no-op。 */
|
||||
/** modal 客户微信 → 该员工×客户聊天(带 StaffList 当前日期窗)。缺失 owner/talker 静默 no-op。
|
||||
* 微信 → 新员工聊天窗口 single tab(modal 跳转不带 msgid 定位)。 */
|
||||
function openCustomerChat(row: Account, customer: StaffChatCustomer): void {
|
||||
if (!row.account_id || !customer.talker_id) return
|
||||
router.push({
|
||||
name: 'chat',
|
||||
params: { channel: 'wechat', ownerId: row.account_id, talkerId: customer.talker_id },
|
||||
name: 'staff-chat',
|
||||
params: { ownerId: row.account_id, tab: 'single', talkerId: customer.talker_id },
|
||||
query: { start: String(statsStart.value), end: String(statsEnd.value) },
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user