feat: full-field display for message/staff/accounts (raw_json + drawers)
Replicates the Customer all-fields pattern across the remaining three entities. Backend now exposes `raw_json` on MessageOut / StaffOut / AccountOut so the frontend can render every 云客 source field without a second endpoint. Each entity gains a Chinese-label field utility + an el-drawer surfacing all fields (structured-first, raw_json fallback, unknown keys under 其他). Backend: - schemas.py: add `raw_json: dict | None` to MessageOut / StaffOut / AccountOut. MessageOut/StaffOut pick the column up via from_attributes; AccountOut is built explicitly in the router, which now threads `raw_json` through from both WechatAccount and WhatsappAccount rows. - tests: new raw_json serialization tests for messages, staff, accounts (assert populated dict round-trips verbatim + NULL serializes as null). Frontend (yunkes/): - New utils: messageFields.ts, staffFields.ts, accountFields.ts — each with a 中文 label map, ordered groups, structured-column preference, and an 其他 fallback for unknown raw_json keys. - Message: clicking a chat bubble opens an all-fields drawer (referMsg renders as pretty-printed JSON). Image preview + file download links stopPropagation so their own interactions still work. - Staff: row click → drawer; columns relabeled (员工ID, 销售手机). - Accounts: new AccountList.vue at /accounts with a 账号 nav item, unified WeChat/WhatsApp table (渠道/账号ID/昵称/微信号/归属员工/好友数/ 群数/收发/在职/最后更新), channel filter, pagination, row-click drawer. - api: add Account type + getAccounts(); add raw_json to Message/Staff. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,8 @@ import { ArrowLeft } from '@element-plus/icons-vue'
|
||||
import { getMessages } from '@/api'
|
||||
import type { Channel, Message } from '@/api/types'
|
||||
import MessageBubble from '@/components/MessageBubble.vue'
|
||||
import { channelLabel } from '@/utils/format'
|
||||
import { channelLabel, formatTime } from '@/utils/format'
|
||||
import { buildMessageSections } from '@/utils/messageFields'
|
||||
|
||||
/**
|
||||
* Chat timeline. Reused for two conversation shapes:
|
||||
@@ -141,6 +142,26 @@ function goBack(): void {
|
||||
}
|
||||
}
|
||||
|
||||
// All-fields drawer state for the message detail view.
|
||||
const drawerOpen = ref(false)
|
||||
const drawerMessage = ref<Message | null>(null)
|
||||
|
||||
function openDetail(m: Message): void {
|
||||
drawerMessage.value = m
|
||||
drawerOpen.value = true
|
||||
}
|
||||
|
||||
const drawerSections = computed(() =>
|
||||
drawerMessage.value ? buildMessageSections(drawerMessage.value) : [],
|
||||
)
|
||||
|
||||
const drawerTitle = computed(() => {
|
||||
const m = drawerMessage.value
|
||||
if (!m) return '消息详情'
|
||||
const when = m.timestamp ? formatTime(m.timestamp) : ''
|
||||
return `消息详情${when ? ` · ${when}` : ''}`
|
||||
})
|
||||
|
||||
// Reload when the route params change (navigating between conversations).
|
||||
watch(
|
||||
() => [props.channel, props.ownerId, props.talkerId, props.roomId] as const,
|
||||
@@ -200,8 +221,74 @@ onMounted(loadInitial)
|
||||
v-for="m in messages"
|
||||
:key="m.msg_id"
|
||||
:message="m"
|
||||
@open-detail="openDetail"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- All-fields drawer for the clicked message -->
|
||||
<el-drawer
|
||||
v-model="drawerOpen"
|
||||
:title="drawerTitle"
|
||||
direction="rtl"
|
||||
size="560px"
|
||||
>
|
||||
<template v-if="drawerMessage">
|
||||
<div class="yk-drawer__topmeta">
|
||||
<el-tag size="small" effect="plain">
|
||||
{{ channelLabel(channelTyped) }}
|
||||
</el-tag>
|
||||
<el-tag
|
||||
v-if="drawerMessage.type"
|
||||
size="small"
|
||||
type="info"
|
||||
effect="plain"
|
||||
>
|
||||
{{ drawerMessage.type }}
|
||||
<template v-if="drawerMessage.type_raw != null">
|
||||
({{ drawerMessage.type_raw }})
|
||||
</template>
|
||||
</el-tag>
|
||||
<el-tag
|
||||
v-if="drawerMessage.is_send != null"
|
||||
size="small"
|
||||
:type="drawerMessage.is_send ? 'success' : 'warning'"
|
||||
effect="plain"
|
||||
>
|
||||
{{ drawerMessage.is_send ? '发出' : '接收' }}
|
||||
</el-tag>
|
||||
</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
|
||||
/>
|
||||
</dd>
|
||||
<dd v-else-if="f.render === 'empty'" class="yk-drawer__empty">—</dd>
|
||||
<dd v-else-if="f.render === 'object'" class="yk-drawer__pre">
|
||||
<pre>{{ f.text }}</pre>
|
||||
</dd>
|
||||
<dd v-else>{{ f.text }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
</template>
|
||||
</el-drawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -213,4 +300,65 @@ onMounted(loadInitial)
|
||||
max-height: calc(100vh - var(--yk-header-height) - 140px);
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.yk-drawer__topmeta {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.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__pre {
|
||||
margin: 0;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.yk-drawer__pre pre {
|
||||
margin: 0;
|
||||
padding: 8px;
|
||||
background: var(--el-fill-color-light, #f5f7fa);
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
color: #303133;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
max-height: 240px;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user