feat(inbox): 站内信消息列表和群组列表功能增强

- 消息列表: 增加货主下拉多选、时间范围查询,请求格式对齐 pagination/where 结构
- 消息列表: 表格列优化(隐藏外部ID/目标类型/渠道/父消息ID,新增发送人列)
- 群组列表: 增加货主下拉多选、是否禁用筛选,默认过滤已启用群组
- 群组列表: 表格列优化(货主ID→货主名称,快递编码→系统快递名称,新增AI回复列)
- 群组编辑: 货主/快递接口下拉改用 index.loadStores / index.loadExpressInterfaces
- 群组编辑: 系统快递编码筛选联动快递接口列表
This commit is contained in:
liufumingren 2026-08-08 01:53:21 +08:00
parent 2d955cf961
commit 21b0249097
6 changed files with 181 additions and 73 deletions

View File

@ -6,14 +6,10 @@ const v = '1.0'
// 站内信模块 API
// ============================================================
/** 站内信列表查询参数 */
/** 站内信列表查询参数(对齐 order.pendingOrder.list 格式) */
export interface InboxListParams {
direction?: string // 消息方向筛选:inbound(收件)/ outbound(回信)
pushStatus?: number // 推送状态筛选:0=待推送 1=推送中 2=已送达 3=失败
targetChannel?: string // 目标渠道筛选:wecom / dingtalk / feishu / warehouse_api / webhook
keyword?: string // 关键词搜索,模糊匹配 ext_id 和 ref_code
page?: number // 页码,默认 1
pageSize?: number // 每页数量,默认 20,最大 200
pagination?: { page?: number; pageSize?: number }
where?: Record<string, { operator: string; value: any }>
}
/** 站内信消息列表(inbox.message.list) */

View File

@ -42,6 +42,21 @@ export function loadWarehouses(data?: Record<string, unknown>) {
} as any)
}
/** 当前仓库下的快递接口下拉列表,可传入 systemExpressCode 过滤 */
export function loadExpressInterfaces(data?: { systemExpressCode?: string }) {
return request({
url: '/system',
method: 'post',
params: {
method: 'index.loadExpressInterfaces',
v: '1.0',
timestamp: new Date().getTime()
},
data: data ?? {},
isSystemApi: true
} as any)
}
export function getCOSUploadConfig(data:any){
return request({
url: '/system',

View File

@ -4,6 +4,14 @@ import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/o
// 站内信群组 - ScanBox 筛选字段
// ============================================================
export const groupAvailableFields = [
{
value: 'store_id',
label: '货主',
type: 'select',
multiple: true,
placeholder: '请选择货主',
options: [] as { label: string; value: unknown }[],
},
{
value: 'groupType',
label: '群类型',
@ -25,20 +33,32 @@ export const groupAvailableFields = [
operators: ['contains'],
defaultOperator: 'contains',
},
{
value: 'is_blocked',
label: '是否禁用',
type: 'select',
placeholder: '请选择状态',
operators: ['eq'],
defaultOperator: 'eq',
options: [
{ label: '启用', value: 0 },
{ label: '禁用', value: 1 },
],
},
]
// ============================================================
// 站内信群组 - UpperTable 列配置
// ============================================================
export const groupColumns = [
{ prop: 'id', label: 'ID', width: '70' },
{ prop: 'group_name', label: '群名称', minWidth: '160', showOverflowTooltip: true },
{ prop: 'group_id', label: '群ID', minWidth: '160', showOverflowTooltip: true },
{ prop: 'group_type', label: '群类型', width: '100' },
{ prop: 'sub_type', label: '子类型', width: '100' },
{ prop: 'store_id', label: '货主ID', width: '90' },
{ prop: 'express_interfaces', label: '快递接口', minWidth: '140', showOverflowTooltip: true },
{ prop: 'system_express_code', label: '系统快递编码', minWidth: '140', showOverflowTooltip: true },
{ prop: 'store_name', label: '货主', minWidth: '120', showOverflowTooltip: true },
{ prop: 'express_interfaces', label: '快递接口', minWidth: '160', showOverflowTooltip: true },
{ prop: 'system_express_name', label: '系统快递', width: '110', showOverflowTooltip: true },
{ prop: 'ai_enabled', label: 'AI回复', width: '90' },
{ prop: 'is_blocked', label: '状态', width: '80' },
{ prop: 'created_at', label: '创建时间', width: '170' },
{ prop: 'actions', label: '操作', width: '220', fixed: 'right' },

View File

@ -7,6 +7,7 @@
:tree-props="{ children: 'children', label: 'label' }"
:auto-submit="false"
:available-fields="availableFields"
:initial-conditions="initialConditions"
@condition-change="handleConditionChange"
@reset="handleConditionReset"
@condition-clear="handleConditionClear"
@ -52,7 +53,7 @@
<template #column-express_interfaces="{ row }">
<template v-if="row.express_interfaces && row.express_interfaces.length">
<el-tag v-for="(iface, idx) in row.express_interfaces" :key="idx" size="small" style="margin: 1px 2px">
{{ iface }}
{{ iface.name || iface }}
</el-tag>
</template>
<span v-else>-</span>
@ -64,6 +65,12 @@
</el-tag>
</template>
<template #column-ai_enabled="{ row }">
<el-tag size="small" :type="row.ai_enabled ? 'success' : 'info'">
{{ row.ai_enabled ? '开' : '关' }}
</el-tag>
</template>
<template #column-actions="{ row }">
<el-button size="small" type="primary" link @click.stop="handleEdit(row)">编辑</el-button>
<el-button size="small" :type="row.is_blocked ? 'success' : 'danger'" link @click.stop="handleToggleDisable(row)">
@ -87,7 +94,7 @@
<el-form ref="bindFormRef" :model="bindForm" :rules="bindRules" label-width="100px" size="small">
<el-form-item label="选择货主" prop="storeId">
<el-select v-model="bindForm.storeId" placeholder="请选择货主" filterable style="width: 100%" :loading="storeLoading">
<el-option v-for="store in storeList" :key="store.id" :label="store.name" :value="store.id" />
<el-option v-for="store in storeList" :key="store.value" :label="store.label" :value="store.value" />
</el-select>
</el-form-item>
<el-form-item label="子类型">
@ -139,7 +146,12 @@
</el-form-item>
<el-form-item v-if="editForm.groupType === 'store'" label="关联货主" prop="storeId">
<el-select v-model="editForm.storeId" placeholder="请选择货主" filterable clearable style="width: 100%" :loading="storeLoading">
<el-option v-for="store in storeList" :key="store.id" :label="store.counterparty_name" :value="store.id" />
<el-option v-for="store in storeList" :key="store.value" :label="store.label" :value="store.value" />
</el-select>
</el-form-item>
<el-form-item v-if="editForm.groupType === 'express'" label="系统快递编码" prop="systemExpressCode">
<el-select v-model="editForm.systemExpressCode" placeholder="请选择系统快递编码" filterable clearable style="width: 100%" :loading="expressLoading" @change="onSystemExpressCodeChange">
<el-option v-for="item in expressCodeOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item v-if="editForm.groupType === 'express'" label="快递接口" prop="expressInterfaces">
@ -147,11 +159,6 @@
<el-option v-for="item in expressInterfaceOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item v-if="editForm.groupType === 'express'" label="系统快递编码" prop="systemExpressCode">
<el-select v-model="editForm.systemExpressCode" placeholder="请选择系统快递编码" filterable clearable style="width: 100%" :loading="expressLoading">
<el-option v-for="item in expressCodeOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="AI 自动回复">
<el-switch v-model="editForm.aiEnabled" :active-value="1" :inactive-value="0" active-text="开" inactive-text="关" />
</el-form-item>
@ -212,8 +219,8 @@ import {
inboxGroupMessages,
inboxBindCode,
} from '@/api/inbox/inbox'
import { storeList as fetchStoreList } from '@/api/storewarehouse.store/storeWarehouse'
import { expressInterfaceList } from '@/api/setting.expressinterface/expressInterface'
import { loadStores, loadExpressInterfaces } from '@/api/index/index'
import { extractStoreListFromResponse, fillStoreScanFieldOptions, mapStoreListToSelectOptions } from '@/views/order/orderManagement/config/order-common-config'
import { expressIndexGetExpressList } from '@/api/setting.express/express'
import { groupAvailableFields, groupColumns } from './group-config'
import ScanBox from '@/components/ScanBox/index.vue'
@ -255,8 +262,16 @@ function handleConditionChange(conditions: Record<string, any>) {
upperPagination.currentPage = 1
fetchData()
}
function handleConditionReset() { currentConditions.value = {}; pagination.currentPage = 1; upperPagination.currentPage = 1; fetchData() }
function handleConditionClear() { currentConditions.value = {}; pagination.currentPage = 1; upperPagination.currentPage = 1; fetchData() }
function handleConditionReset() {
currentConditions.value = { is_blocked: { value: 0, operator: 'eq', type: 'select' } }
pagination.currentPage = 1; upperPagination.currentPage = 1
fetchData()
}
function handleConditionClear() {
currentConditions.value = {}
pagination.currentPage = 1; upperPagination.currentPage = 1
fetchData()
}
function handleRowClick(row: any) { selectedRow.value = row }
// ==================== 数据查询 ====================
@ -265,8 +280,15 @@ function buildWhereFromConditions(conditions: Record<string, any>) {
const where: Record<string, any> = {}
for (const [key, cond] of Object.entries(conditions)) {
if (cond === undefined || cond === null || cond === '') continue
if (typeof cond === 'object' && cond.value !== undefined) where[key] = cond.value
else where[key] = cond
if (typeof cond === 'object' && cond.value !== undefined) {
const val = cond.value
const op = cond.operator || 'eq'
// 空值跳过
if (val === undefined || val === null || val === '' || (Array.isArray(val) && val.length === 0)) continue
where[key] = { operator: op, value: val }
} else {
where[key] = { operator: 'eq', value: cond }
}
}
return where
}
@ -275,7 +297,10 @@ async function fetchData() {
loading.value = true
try {
const where = buildWhereFromConditions(currentConditions.value)
const params: any = { page: pagination.currentPage, pageSize: pagination.pageSize, ...where }
const params: any = {
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
where,
}
const res: any = await inboxGroupList(params)
if (res && (res.code === 1 || res.code === 200 || res.code === 20000)) {
const data = res.data ?? res
@ -314,9 +339,15 @@ function resetBindForm() { bindFormRef.value?.resetFields() }
async function loadStoreList() {
storeLoading.value = true
try {
const res: any = await fetchStoreList({})
if (res && (res.code === 1 || res.code === 200 || res.code === 20000)) storeList.value = res.data?.list ?? res.data ?? []
} catch { /* ignore */ } finally { storeLoading.value = false }
const storesRes: any = await loadStores()
const rawStores = extractStoreListFromResponse(storesRes)
storeList.value = mapStoreListToSelectOptions(rawStores)
// 同时注入 ScanBox 货主筛选选项
fillStoreScanFieldOptions(availableFields, rawStores)
} catch {
storeList.value = []
fillStoreScanFieldOptions(availableFields, [])
} finally { storeLoading.value = false }
}
async function handleGenerateCode() {
@ -356,42 +387,52 @@ function handleEdit(row: any) {
editForm.groupId = row.group_id ?? ''; editForm.groupName = row.group_name ?? ''
editForm.groupType = row.group_type ?? ''; editForm.subType = row.sub_type ?? ''
editForm.storeId = row.store_id ?? null
editForm.expressInterfaces = Array.isArray(row.express_interfaces) ? [...row.express_interfaces] : []
editForm.expressInterfaces = Array.isArray(row.express_interfaces)
? row.express_interfaces.map((item: any) => (typeof item === 'object' ? item.id : item))
: []
editForm.systemExpressCode = row.system_express_code ?? ''
editForm.aiEnabled = row.ai_enabled ?? 1
editDialogVisible.value = true; loadStoreList()
if (editForm.groupType === 'express') { loadExpressCodes(); loadExpressInterfacesByCode() }
}
function resetEditForm() { editFormRef.value?.resetFields(); editingRow.value = null }
async function loadExpressOptions() {
expressLoading.value = true
async function loadExpressCodes() {
try {
const [ifaceRes, expressRes]: any[] = await Promise.all([
expressInterfaceList({ pagination: { page: 1, pageSize: 200 } }),
expressIndexGetExpressList({ systemOnly: true }),
])
const ifaceList = ifaceRes?.data?.list || ifaceRes?.data || []
expressInterfaceOptions.value = ifaceList.map((item: any) => ({
label: `${item.name || item.express_code || ''}(${item.id})`,
value: item.id,
}))
const expressRes: any = await expressIndexGetExpressList({ systemOnly: true })
const expressList = expressRes?.data?.list || expressRes?.data || []
expressCodeOptions.value = expressList.map((item: any) => ({
label: `${item.code || ''} - ${item.name || ''}`,
value: item.code || '',
}))
} catch {
expressInterfaceOptions.value = []
expressCodeOptions.value = []
}
}
async function loadExpressInterfacesByCode() {
expressLoading.value = true
try {
const ifaceRes: any = await loadExpressInterfaces(
editForm.systemExpressCode ? { systemExpressCode: editForm.systemExpressCode } : undefined
)
expressInterfaceOptions.value = ifaceRes?.expressInterfaces || []
} catch {
expressInterfaceOptions.value = []
} finally {
expressLoading.value = false
}
}
function onSystemExpressCodeChange() {
editForm.expressInterfaces = []
loadExpressInterfacesByCode()
}
function onEditGroupTypeChange() {
if (editForm.groupType !== 'express') { editForm.expressInterfaces = []; editForm.systemExpressCode = '' }
if (editForm.groupType !== 'store') editForm.storeId = null
if (editForm.groupType === 'express') loadExpressOptions()
if (editForm.groupType === 'express') { loadExpressCodes(); loadExpressInterfacesByCode() }
}
async function handleSubmitEdit() {
@ -459,7 +500,12 @@ async function fetchGroupMessages() {
function onMsgPageChange(page: number) { msgPagination.currentPage = page; fetchGroupMessages() }
function onMsgPageSizeChange(size: number) { msgPagination.pageSize = size; msgPagination.currentPage = 1; fetchGroupMessages() }
onMounted(() => { fetchData() })
// ==================== 默认筛选:仅显示启用群组 ====================
const initialConditions = {
is_blocked: { value: 0, operator: 'eq', type: 'select' },
}
onMounted(() => { loadStoreList(); fetchData() })
</script>
<style scoped lang="scss">

View File

@ -57,19 +57,6 @@
</el-tag>
</template>
<template #column-target_type="{ row }">
<el-tag size="small" :type="row.target_type === 'api' ? '' : 'info'">
{{ row.target_type ?? '-' }}
</el-tag>
</template>
<template #column-target_channel="{ row }">
<el-tag v-if="row.target_channel" size="small" :type="channelTagType(row.target_channel)">
{{ channelLabel(row.target_channel) }}
</el-tag>
<span v-else>-</span>
</template>
<template #column-push_status="{ row }">
<template v-if="row.direction === 'outbound'">
<el-tag size="small" :type="pushStatusTagType(row.push_status)">
@ -237,6 +224,8 @@ import {
inboxRetry,
inboxStats,
} from '@/api/inbox/inbox'
import { loadStores } from '@/api/index/index'
import { extractStoreListFromResponse, fillStoreScanFieldOptions } from '@/views/order/orderManagement/config/order-common-config'
import { messageAvailableFields, messageColumns } from './message-config'
import ScanBox from '@/components/ScanBox/index.vue'
import UpperTable from '@/components/UpperTable/index.vue'
@ -321,9 +310,24 @@ function buildWhereFromConditions(conditions: Record<string, any>) {
for (const [key, cond] of Object.entries(conditions)) {
if (cond === undefined || cond === null || cond === '') continue
if (typeof cond === 'object' && cond.value !== undefined) {
where[key] = cond.value
const val = cond.value
const op = cond.operator || 'eq'
// 空值跳过
if (val === undefined || val === null || val === '' || (Array.isArray(val) && val.length === 0)) continue
// 日期范围:拆分为 begin/end
if (Array.isArray(val) && val.length === 2 && (cond.type === 'daterange' || cond.type === 'datetimerange')) {
where[key] = {
operator: op,
value: [val[0] + ' 00:00:00', val[1] + ' 23:59:59'],
}
continue
}
where[key] = { operator: op, value: val }
} else {
where[key] = cond
where[key] = { operator: 'eq', value: cond }
}
}
return where
@ -335,9 +339,8 @@ async function fetchData() {
try {
const where = buildWhereFromConditions(currentConditions.value)
const params: any = {
page: pagination.currentPage,
pageSize: pagination.pageSize,
...where,
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
where,
}
const res: any = await inboxList(params)
if (res && (res.code === 1 || res.code === 200 || res.code === 20000)) {
@ -506,7 +509,25 @@ async function handleViewThread(row: any) {
finally { threadLoading.value = false }
}
// ==================== 货主列表加载 ====================
async function loadStoreOptions() {
try {
const storesRes: any = await loadStores()
fillStoreScanFieldOptions(availableFields, extractStoreListFromResponse(storesRes))
} catch {
fillStoreScanFieldOptions(availableFields, [])
} finally {
// 硬编码:无货主消息选项
const storeField = availableFields.find((f: any) => f.value === 'store_id')
if (storeField?.options) {
(storeField.options as any[]).unshift({ label: '无货主消息', value: 0 })
}
}
}
onMounted(() => {
loadStoreOptions()
fetchData()
fetchStats()
})

View File

@ -4,6 +4,22 @@ import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/o
// 站内信消息列表 - ScanBox 筛选字段(对齐 inbox.list 实际字段)
// ============================================================
export const messageAvailableFields = [
{
value: 'store_id',
label: '货主',
type: 'select',
multiple: true,
placeholder: '请选择货主',
options: [] as { label: string; value: unknown }[],
},
{
value: 'keyword',
label: '关键词',
type: 'text',
placeholder: '搜索群名称、内容、用户名称,多个用逗号分隔',
operators: ['contains'],
defaultOperator: 'contains',
},
{
value: 'direction',
label: '消息方向',
@ -58,12 +74,10 @@ export const messageAvailableFields = [
],
},
{
value: 'keyword',
label: '关键词',
type: 'text',
placeholder: '搜索 ext_id / content / group_name',
operators: ['contains'],
defaultOperator: 'contains',
value: 'created_at',
label: '创建时间',
type: 'daterange',
placeholder: '请选择时间范围',
},
]
@ -71,18 +85,14 @@ export const messageAvailableFields = [
// 站内信消息列表 - UpperTable 列配置(对齐 inbox.list 实际响应字段)
// ============================================================
export const messageColumns = [
{ prop: 'id', label: 'ID', width: '70' },
{ prop: 'ext_id', label: '外部ID', minWidth: '160', showOverflowTooltip: true },
{ prop: 'content', label: '正文', minWidth: '220', showOverflowTooltip: true },
{ prop: 'direction', label: '方向', width: '70' },
{ prop: 'source_type', label: '来源', width: '80' },
{ prop: 'target_type', label: '目标类型', width: '90' },
{ prop: 'target_channel', label: '渠道', width: '100' },
{ prop: 'group_name', label: '群名称', minWidth: '140', showOverflowTooltip: true },
{ prop: 'user_name', label: '发送人', minWidth: '120', showOverflowTooltip: true },
{ prop: 'store_name', label: '货主', minWidth: '140', showOverflowTooltip: true },
{ prop: 'push_status', label: '推送状态', width: '90' },
{ prop: 'retry_count', label: '重试', width: '60' },
{ prop: 'parent_id', label: '父消息ID', width: '90' },
{ prop: 'created_at', label: '创建时间', width: '170' },
{ prop: 'actions', label: '操作', width: '240', fixed: 'right' },
]