feat(staff): WA员工 modal 列对齐云客(序号/员工信息/员工WhatsApp/客户WhatsApp/添加时间/最后沟通)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
浅念
2026-08-11 14:58:38 +08:00
parent 05d1e41d31
commit 0cc9408371
+46 -12
View File
@@ -270,12 +270,37 @@ const detailCols = ref<any[]>([])
const fmtTime = (_r: any, _c: any, v: any): string =>
typeof v === 'number' && v > 0 ? formatTime(v) : v ? String(v) : '--'
const baseCustomerCols = [
{ prop: 'friend_nickname', label: '客户', minWidth: 140 },
{ prop: 'phone', label: '客户号码', width: 130 },
{ prop: 'last_chat_time', label: '最后沟通', width: 150, formatter: fmtTime },
{ prop: 'add_time', label: '添加时间', width: 150, formatter: fmtTime },
]
/**
* WA 员工 modal 列(对齐云客 WA 真机,6 列):
* 序号 / 员工信息 / 员工WhatsApp / 客户WhatsApp / 添加时间 / 最后沟通时间.
* 序号/员工信息/员工WhatsApp/客户WhatsApp 为注入字段(同 Phase B 微信 modal 模式),
* 由 fetcher 在每条 Customer 上合成;add_time/last_chat_time 为 Customer 本身字段。
*/
function waModalCols(_row: Account): any[] {
return [
{ prop: '_serial', label: '序号', width: 70, align: 'center' },
{ prop: 'staff_info', label: '员工信息', minWidth: 140 },
{ prop: 'staff_wx', label: '员工WhatsApp', minWidth: 140 },
{ prop: 'friend_wx', label: '客户WhatsApp', minWidth: 160 },
{ prop: 'add_time', label: '添加时间', width: 150, formatter: fmtTime },
{ prop: 'last_chat_time', label: '最后沟通时间', width: 150, formatter: fmtTime },
]
}
/** 为 WA modal 一页 Customer 合成注入字段(序号跨页连续 + 员工/客户显示字段)。 */
function injectWaModalFields(rows: any[], page: number, pageSize: number, row: Account): any[] {
const startIdx = (page - 1) * pageSize
const staffInfo = joinFields(cellText(row, 'userName'), cellText(row, 'phone'))
// WA 员工可能无 alias,用 nickName+phone,兜底 account_id。
const staffWx = joinFields(cellText(row, 'nickName'), cellText(row, 'phone'), row.account_id)
return rows.map((c, i) => ({
...c,
_serial: startIdx + i + 1,
staff_info: staffInfo,
staff_wx: staffWx,
friend_wx: joinFields(c.friend_nickname, c.friend_id),
}))
}
function openAddedModal(row: Account) {
// ⚠️ WA customer has no add_time (Task 2 confirmed: WA raw_json lacks
@@ -284,9 +309,16 @@ function openAddedModal(row: Account) {
// 用 owner_account_id(=account_id,始终存在)而非 user_id(可能 null 导致全表泄漏)。
// 标题如实写"客户列表"——非"添加人数",因 WA 无法按 add_time 精确筛新增。
detailTitle.value = `客户列表 · ${row.user_name ?? row.account_id}`
detailCols.value = baseCustomerCols
detailFetcher.value = (p, s) =>
getCustomers({ owner_account_id: row.account_id, channel: row.channel, page: p, page_size: s })
detailCols.value = waModalCols(row)
detailFetcher.value = async (p, s) => {
const res = await getCustomers({
owner_account_id: row.account_id,
channel: row.channel,
page: p,
page_size: s,
})
return { ...res, items: injectWaModalFields(res.items, p, s, row) }
}
detailOpen.value = true
}
@@ -295,15 +327,17 @@ function openTalkedModal(row: Account) {
// channels). 用 owner_account_id(始终存在)而非 user_id(可能 null)。
const since = Date.now() - 7 * 86400000
detailTitle.value = `沟通人数 · ${row.user_name ?? row.account_id}`
detailCols.value = baseCustomerCols
detailFetcher.value = (p, s) =>
getCustomers({
detailCols.value = waModalCols(row)
detailFetcher.value = async (p, s) => {
const res = await getCustomers({
owner_account_id: row.account_id,
channel: row.channel,
last_chat_since: since,
page: p,
page_size: s,
})
return { ...res, items: injectWaModalFields(res.items, p, s, row) }
}
detailOpen.value = true
}