自动回复(inbox/autoReply) - 页面改为「左侧类型/子类型树 + 右侧配置区」两栏布局,树支持按类型名/子类型搜索 - 右侧类型信息与子类型列表重排:子类型改用 UpperTable,操作收敛为「配置 / 编辑 / 删除」链接按钮 - FunctionPanel / GroupPanel / NumberRulePanel 改用 UpperTable(统一 table-id、行 key 与列定义) - KeywordPanel 关键词编辑改为 task-panel 弹窗,补充字段说明文案 - panel.scss 增补共享面板样式,减少各面板重复定义 会话消息(inbox/message) - 会话链路由行内展开改为 task-panel 弹窗,时间线重做(收发方向标签、时间右对齐、 消息卡片悬停态),支持直接「回复」并在弹窗内展示收发条数统计 品牌 Logo(frontBrand / Navbar / login) - 新增 DEFAULT_BRAND_LOGO 常量与 isBrandExemptHost 计算属性 - 品牌豁免域名(主域名)恒用前端默认 Logo,不再消费后端 logo_url - 登录页与顶栏统一改用该常量,修正兜底路径 '../../../public/logo/1.png' 权限管理(setting/permission) - 列表迁移到 UpperTable(permissionColumns 抽到 permission-config) - 新增「路径 / 名称 / 标题」关键字过滤、客户端分页、工具栏按钮组与批量删除(按勾选态置灰) 通用组件 - UpperTable 新增 selectionMode='native':树形表格使用原生勾选列,展开箭头不再挤占勾选列, 并统一勾选框尺寸与行高 - 消息模块 DocSearchPicker 改为「单行筛选 + 表格填满高度 + 底部内嵌分页」, 新增重置、已选提示(多选时提示只取第一条) 样式与交互统一 - 售后类型列表/详情、账号角色列的状态标签改为 ut-status-text 彩色文本(去掉 el-tag 色块) - 售后列表、拣货车、打印电脑/工作台模板配置的工具栏按钮统一为 refresh / setting / action / cancel 四类,批量操作按 noSelection 置灰 - ExpressWaybillPanel 表格内容居中;绑定包材弹窗成功后直接关闭并移除结果展示区 - 隐藏拣货车「详情」入口与角色树面板头部
1184 lines
38 KiB
Vue
1184 lines
38 KiB
Vue
<template>
|
||
<div class="order-sub-container">
|
||
<scan-box
|
||
ref="scanBox"
|
||
cache-key="inbox:message"
|
||
width="220px"
|
||
:tree-props="{ children: 'children', label: 'label' }"
|
||
:auto-submit="false"
|
||
:available-fields="availableFields"
|
||
@condition-change="handleConditionChange"
|
||
@reset="handleConditionReset"
|
||
@condition-clear="handleConditionClear"
|
||
/>
|
||
|
||
<div class="main-content">
|
||
<div class="toolbar">
|
||
<div class="toolbar-left">
|
||
<order-toolbar-button-group
|
||
:buttons="toolbarButtons"
|
||
:resolve-disabled="resolveButtonDisabled"
|
||
:resolve-loading="resolveButtonLoading"
|
||
:resolve-label="resolveButtonLabel"
|
||
:layout-key="toolbarLayoutKey"
|
||
@action="handleToolbarButtonClick"
|
||
/>
|
||
<div v-if="statsData" class="toolbar-stats">
|
||
<!-- <el-divider direction="vertical" /> -->
|
||
<el-tag size="small" type="primary">收件 {{ statsInbound }} | 回信 {{ statsOutbound }}</el-tag>
|
||
<el-tag size="small" type="success">24h 新增 {{ statsData.recent_24h_count ?? 0 }}</el-tag>
|
||
<el-tag v-for="s in statsStatusTags" :key="s.status" size="small" :type="s.type">{{ s.label }} {{ s.count }}</el-tag>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="split-stack">
|
||
<div class="upper-wrapper">
|
||
<upper-table
|
||
ref="upperTable"
|
||
title="站内信消息列表"
|
||
default-align="center"
|
||
table-id="inbox-message-list"
|
||
:data="tableData"
|
||
:columns="columns"
|
||
:table-size="tableSize"
|
||
:pagination="upperPagination"
|
||
:show-index="true"
|
||
:show-actions="true"
|
||
:enable-column-config="true"
|
||
:loading="loading"
|
||
:query-time="queryTime"
|
||
@current-change="handleRowClick"
|
||
@page-change="handlePageChange"
|
||
@page-size-change="handlePageSizeChange"
|
||
@refresh="handleRefresh"
|
||
>
|
||
<template #column-direction="{ row }">
|
||
<span :class="getStatusTextClass(row.direction === 'inbound' ? 'primary' : 'success')">
|
||
{{ row.direction === 'inbound' ? '收件' : '回信' }}
|
||
</span>
|
||
</template>
|
||
|
||
<template #column-source_type="{ row }">
|
||
<span :class="getStatusTextClass(row.source_type === 'api' ? 'primary' : 'info')">
|
||
{{ sourceTypeLabel(row.source_type) }}
|
||
</span>
|
||
</template>
|
||
|
||
<template #column-target_type="{ row }">
|
||
<span :class="getStatusTextClass(row.target_type === 'api' ? 'primary' : 'info')">
|
||
{{ targetTypeLabel(row.target_type) }}
|
||
</span>
|
||
</template>
|
||
|
||
<template #column-push_status="{ row }">
|
||
<template v-if="row.direction === 'outbound'">
|
||
<span :class="getStatusTextClass(pushStatusTagType(row.push_status))">
|
||
{{ pushStatusLabel(row.push_status) }}
|
||
</span>
|
||
</template>
|
||
<span v-else>-</span>
|
||
</template>
|
||
|
||
<template #column-actions="{ row }">
|
||
<div class="wave-operation-actions">
|
||
<!-- <el-button size="small" type="primary" link @click.stop="handleViewDetail(row)">详情</el-button> -->
|
||
<el-button size="small" type="success" link @click.stop="handleOpenReply(row)">回信</el-button>
|
||
<el-button
|
||
v-if="row.direction === 'outbound' && row.push_status === 3"
|
||
size="small" type="warning" link
|
||
@click.stop="handleRetry(row)"
|
||
>重推</el-button>
|
||
<el-button size="small" type="info" link @click.stop="handleViewThread(row)">对话链</el-button>
|
||
</div>
|
||
</template>
|
||
|
||
<template #empty>
|
||
<div class="empty-tip">暂无站内信消息数据</div>
|
||
</template>
|
||
</upper-table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- ========== 弹窗 ========== -->
|
||
|
||
<!-- 消息详情弹窗 -->
|
||
<el-dialog v-model="detailVisible" title="消息详情" width="750px" destroy-on-close align-center>
|
||
<div v-if="detailData" class="detail-content">
|
||
<el-descriptions :column="2" border size="small">
|
||
<el-descriptions-item label="消息ID">{{ detailData.id }}</el-descriptions-item>
|
||
<el-descriptions-item label="外部ID">{{ detailData.ext_id ?? '-' }}</el-descriptions-item>
|
||
<el-descriptions-item label="仓库ID">{{ detailData.warehouse_id ?? '-' }}</el-descriptions-item>
|
||
<el-descriptions-item label="货主">{{ detailData.store_name ?? detailData.store_id ?? '-' }}</el-descriptions-item>
|
||
<el-descriptions-item label="消息方向">
|
||
<span :class="getStatusTextClass(detailData.direction === 'inbound' ? 'primary' : 'success')">
|
||
{{ detailData.direction === 'inbound' ? '收件' : '回信' }}
|
||
</span>
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="父消息ID">{{ detailData.parent_id ?? '-' }}</el-descriptions-item>
|
||
<el-descriptions-item label="来源类型">
|
||
<span :class="getStatusTextClass('primary')">{{ detailData.source_type ?? '-' }}</span>
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="目标类型">
|
||
<span :class="getStatusTextClass('primary')">{{ detailData.target_type ?? '-' }}</span>
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="目标渠道">
|
||
<span v-if="detailData.target_channel" :class="getStatusTextClass('primary')">{{ channelLabel(detailData.target_channel) }}</span>
|
||
<span v-else>-</span>
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="群名称">{{ detailData.group_name ?? '-' }}</el-descriptions-item>
|
||
<el-descriptions-item label="群ID">{{ detailData.group_id ?? '-' }}</el-descriptions-item>
|
||
<el-descriptions-item label="用户名">{{ detailData.user_name ?? '-' }}</el-descriptions-item>
|
||
<el-descriptions-item label="用户ID">{{ detailData.user_id ?? '-' }}</el-descriptions-item>
|
||
<el-descriptions-item label="推送状态">
|
||
<template v-if="detailData.direction === 'outbound'">
|
||
<span :class="getStatusTextClass(pushStatusTagType(detailData.push_status))">
|
||
{{ pushStatusLabel(detailData.push_status) }}
|
||
</span>
|
||
</template>
|
||
<span v-else>-</span>
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="已重试次数">{{ detailData.direction === 'outbound' ? (detailData.retry_count ?? 0) : '-' }}</el-descriptions-item>
|
||
<el-descriptions-item label="工单ID">{{ detailData.work_order_id ?? '-' }}</el-descriptions-item>
|
||
<el-descriptions-item label="工单号">{{ detailData.work_order_no ?? '-' }}</el-descriptions-item>
|
||
<el-descriptions-item label="创建时间">{{ formatTime(detailData.created_at) }}</el-descriptions-item>
|
||
<el-descriptions-item label="更新时间">{{ formatTime(detailData.updated_at) }}</el-descriptions-item>
|
||
<el-descriptions-item v-if="detailData.content" label="正文" :span="2">
|
||
<div class="content-text">{{ detailData.content }}</div>
|
||
</el-descriptions-item>
|
||
<el-descriptions-item v-if="detailData.flags && Object.keys(detailData.flags).length" label="处理标记" :span="2">
|
||
<pre class="json-pre">{{ JSON.stringify(detailData.flags, null, 2) }}</pre>
|
||
</el-descriptions-item>
|
||
<el-descriptions-item v-if="detailData.push_response" label="推送响应" :span="2">
|
||
<pre class="json-pre">{{ JSON.stringify(detailData.push_response, null, 2) }}</pre>
|
||
</el-descriptions-item>
|
||
</el-descriptions>
|
||
</div>
|
||
</el-dialog>
|
||
|
||
<!-- 回信弹窗:面板结构 / 尺寸对齐「批量修改平台信息」(UpdateOrderMetaForm) -->
|
||
<el-dialog
|
||
v-model="replyVisible"
|
||
class="system-reply-dialog"
|
||
width="min(560px, 92vw)"
|
||
destroy-on-close
|
||
align-center
|
||
append-to-body
|
||
:show-close="false"
|
||
:close-on-click-modal="false"
|
||
@closed="resetReplyForm"
|
||
>
|
||
<div class="task-panel">
|
||
<header class="task-panel__head">
|
||
<div class="task-panel__titles">
|
||
<h2>系统回信</h2>
|
||
<p>向目标渠道发送系统回信,JSON 字段请保持格式正确</p>
|
||
</div>
|
||
<button
|
||
class="task-panel__close"
|
||
type="button"
|
||
aria-label="关闭"
|
||
@click="replyVisible = false"
|
||
>
|
||
<svg viewBox="0 0 12 12" fill="none">
|
||
<path d="M1 1L11 11M11 1L1 11" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" />
|
||
</svg>
|
||
</button>
|
||
</header>
|
||
|
||
<div class="task-panel__body task-panel__body--scroll">
|
||
<el-form ref="replyFormRef" :model="replyForm" :rules="replyRules" class="task-panel__form">
|
||
<div class="task-panel__field">
|
||
<span class="task-panel__field-label">原消息 ID</span>
|
||
<strong class="task-panel__field-value">{{ replyForm.parentId || '—' }}</strong>
|
||
</div>
|
||
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label is-required">目标渠道</span>
|
||
<div class="task-panel__field-form">
|
||
<el-form-item prop="targetChannel">
|
||
<el-select v-model="replyForm.targetChannel" size="default" placeholder="请选择目标渠道" style="width: 100%">
|
||
<el-option label="企业微信" value="wecom" />
|
||
<el-option label="钉钉" value="dingtalk" />
|
||
<el-option label="飞书" value="feishu" />
|
||
<el-option label="仓库API" value="warehouse_api" />
|
||
<el-option label="Webhook" value="webhook" />
|
||
</el-select>
|
||
</el-form-item>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="task-panel__field task-panel__field--input">
|
||
<span class="task-panel__field-label">目标类型</span>
|
||
<div class="task-panel__field-form">
|
||
<el-select v-model="replyForm.targetType" size="default" placeholder="可选" clearable style="width: 100%">
|
||
<el-option label="IM" value="im" />
|
||
<el-option label="API" value="api" />
|
||
<el-option label="Webhook" value="webhook" />
|
||
</el-select>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="task-panel__field task-panel__field--input task-panel__field--textarea">
|
||
<span class="task-panel__field-label">扩展数据</span>
|
||
<div class="task-panel__field-form">
|
||
<el-input
|
||
v-model="replyForm.extDataJson"
|
||
type="textarea"
|
||
:rows="4"
|
||
resize="none"
|
||
size="default"
|
||
placeholder="JSON 格式"
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="task-panel__field task-panel__field--input task-panel__field--textarea">
|
||
<span class="task-panel__field-label">处理标记</span>
|
||
<div class="task-panel__field-form">
|
||
<el-input
|
||
v-model="replyForm.flagsJson"
|
||
type="textarea"
|
||
:rows="3"
|
||
resize="none"
|
||
size="default"
|
||
placeholder="JSON 格式"
|
||
/>
|
||
</div>
|
||
</div>
|
||
</el-form>
|
||
|
||
<p class="task-panel__form-tip">
|
||
目标渠道必填;扩展数据与处理标记需为合法 JSON(可留空),提交后立即推送到所选渠道。
|
||
</p>
|
||
</div>
|
||
|
||
<footer class="task-panel__foot">
|
||
<span class="task-panel__hint">提交前请确认目标渠道与 JSON 内容无误</span>
|
||
<div class="task-panel__actions">
|
||
<el-button size="small" @click="replyVisible = false">取消</el-button>
|
||
<el-button size="small" type="primary" :loading="replyLoading" @click="handleSubmitReply">确认回信</el-button>
|
||
</div>
|
||
</footer>
|
||
</div>
|
||
</el-dialog>
|
||
|
||
<!-- 对话链弹窗:面板结构 / 字段行对齐「新建波次策略」,时间轴仅做收发方向着色 -->
|
||
<el-dialog
|
||
v-model="threadVisible"
|
||
class="inbox-thread-dialog"
|
||
width="min(720px, 94vw)"
|
||
align-center
|
||
destroy-on-close
|
||
append-to-body
|
||
:show-close="false"
|
||
:close-on-click-modal="false"
|
||
>
|
||
<div class="task-panel">
|
||
<header class="task-panel__head">
|
||
<div class="task-panel__titles">
|
||
<h2>对话链</h2>
|
||
<p>按时间顺序查看该会话的收件与回信记录,共 {{ threadData.length }} 条</p>
|
||
</div>
|
||
<button
|
||
class="task-panel__close"
|
||
type="button"
|
||
aria-label="关闭"
|
||
@click="threadVisible = false"
|
||
>
|
||
<svg viewBox="0 0 12 12" fill="none">
|
||
<path d="M1 1L11 11M11 1L1 11" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" />
|
||
</svg>
|
||
</button>
|
||
</header>
|
||
|
||
<div class="task-panel__body task-panel__body--scroll">
|
||
<div class="task-panel__grid task-panel__grid--stats">
|
||
<div class="task-panel__field">
|
||
<span class="task-panel__field-label">对话条数</span>
|
||
<strong class="task-panel__field-value">{{ threadData.length }} 条</strong>
|
||
</div>
|
||
<div class="task-panel__field">
|
||
<span class="task-panel__field-label">收件</span>
|
||
<strong class="task-panel__field-value">
|
||
<span :class="getStatusTextClass('primary')">{{ threadInboundCount }}</span>
|
||
<span class="thread-unit">条</span>
|
||
</strong>
|
||
</div>
|
||
<div class="task-panel__field">
|
||
<span class="task-panel__field-label">回信</span>
|
||
<strong class="task-panel__field-value">
|
||
<span :class="getStatusTextClass('success')">{{ threadOutboundCount }}</span>
|
||
<span class="thread-unit">条</span>
|
||
</strong>
|
||
</div>
|
||
</div>
|
||
|
||
<ol v-if="threadData.length" class="thread-flow">
|
||
<li
|
||
v-for="item in threadData"
|
||
:key="item.id"
|
||
class="thread-flow__item"
|
||
:class="item.direction === 'inbound' ? 'is-inbound' : 'is-outbound'"
|
||
>
|
||
<span class="thread-flow__node" aria-hidden="true"></span>
|
||
<div class="thread-flow__card">
|
||
<div class="thread-flow__head">
|
||
<span class="thread-flow__badge">{{ item.direction === 'inbound' ? '收件' : '回信' }}</span>
|
||
<span v-if="item.target_channel" class="thread-flow__tag">{{ channelLabel(item.target_channel) }}</span>
|
||
<span
|
||
v-if="item.direction === 'outbound'"
|
||
class="thread-flow__tag"
|
||
:class="getStatusTextClass(pushStatusTagType(item.push_status))"
|
||
>{{ pushStatusLabel(item.push_status) }}</span>
|
||
<time class="thread-flow__time">{{ formatTime(item.created_at) }}</time>
|
||
</div>
|
||
<p v-if="item.content" class="thread-flow__text">{{ item.content }}</p>
|
||
<div v-if="item.ext_id || item.group_name" class="thread-flow__meta">
|
||
<span v-if="item.ext_id">外部ID:{{ item.ext_id }}</span>
|
||
<span v-if="item.group_name">群:{{ item.group_name }}</span>
|
||
</div>
|
||
</div>
|
||
</li>
|
||
</ol>
|
||
|
||
<div v-else v-loading="threadLoading" class="thread-flow__empty">暂无对话链数据</div>
|
||
</div>
|
||
|
||
<footer class="task-panel__foot">
|
||
<span class="task-panel__hint">时间正序排列;推送失败的回信可在列表中重推</span>
|
||
<div class="task-panel__actions">
|
||
<el-button size="small" @click="threadVisible = false">关闭</el-button>
|
||
<el-button size="small" type="primary" @click="handleReplyFromThread">回信</el-button>
|
||
</div>
|
||
</footer>
|
||
</div>
|
||
</el-dialog>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import { computed, onMounted, reactive, ref } from 'vue'
|
||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||
import {
|
||
inboxList,
|
||
inboxDetail,
|
||
inboxThread,
|
||
inboxReply,
|
||
inboxRetry,
|
||
inboxStats,
|
||
} from '@/api/inbox/inbox'
|
||
import { loadStores } from '@/api/index/index'
|
||
import { extractStoreListFromResponse, fillStoreScanFieldOptions, getStatusTextClass } 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'
|
||
import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue'
|
||
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
|
||
import { safeInvoke } from '@/utils/safe-invoke'
|
||
|
||
// ==================== 常量 ====================
|
||
|
||
const channelLabelMap: Record<string, string> = {
|
||
wecom: '企业微信', dingtalk: '钉钉', feishu: '飞书',
|
||
warehouse_api: '仓库API', webhook: 'Webhook',
|
||
}
|
||
const channelTagTypeMap: Record<string, string> = {
|
||
wecom: 'success', dingtalk: 'primary', feishu: '',
|
||
warehouse_api: 'warning', webhook: 'danger',
|
||
}
|
||
const pushStatusLabelMap: Record<number, string> = { 0: '待推送', 1: '推送中', 2: '已送达', 3: '失败' }
|
||
const pushStatusTagTypeMap: Record<number, string> = { 0: 'info', 1: 'warning', 2: 'success', 3: 'danger' }
|
||
const sourceTypeLabelMap: Record<string, string> = { im: 'IM', api: 'API', system: '系统' }
|
||
const targetTypeLabelMap: Record<string, string> = { im: 'IM', api: 'API', webhook: 'Webhook' }
|
||
|
||
function channelLabel(c: string) { return channelLabelMap[c] ?? c ?? '-' }
|
||
function channelTagType(c: string) { return channelTagTypeMap[c] ?? 'info' }
|
||
function pushStatusLabel(s: number) { return pushStatusLabelMap[s] ?? '未知' }
|
||
function pushStatusTagType(s: number) { return pushStatusTagTypeMap[s] ?? 'info' }
|
||
function sourceTypeLabel(s: string) { return sourceTypeLabelMap[s] ?? s ?? '-' }
|
||
function targetTypeLabel(s: string) { return targetTypeLabelMap[s] ?? s ?? '-' }
|
||
|
||
function formatTime(val: any): string {
|
||
if (val === null || val === undefined || val === '') return '-'
|
||
const d = new Date(val)
|
||
if (isNaN(d.getTime())) return String(val)
|
||
return d.toLocaleString('zh-CN', { hour12: false })
|
||
}
|
||
|
||
// ==================== 配置 ====================
|
||
|
||
const availableFields = messageAvailableFields
|
||
const columns = messageColumns
|
||
const tableSize = 'small'
|
||
|
||
const toolbarButtons: ToolbarButtonConfig[] = [
|
||
{ key: 'refresh', label: '刷新', category: 'refresh', size: 'small', loadingKey: 'loading', action: 'loadData' },
|
||
{ key: 'columnConfig', label: '字段设置', category: 'setting', size: 'small', action: 'openColumnConfigPanel' },
|
||
]
|
||
|
||
const buttonLoadingMap = ref<Record<string, boolean>>({ loading: false })
|
||
const buttonDisabledMap = ref<Record<string, boolean>>({})
|
||
const buttonLabelMap = ref<Record<string, string>>({})
|
||
const toolbarLayoutKey = ref('')
|
||
|
||
function resolveButtonLoading(loadingKey?: string) {
|
||
if (!loadingKey) return false
|
||
return Boolean(buttonLoadingMap.value[loadingKey])
|
||
}
|
||
function resolveButtonDisabled(disabledKey?: string) {
|
||
if (!disabledKey) return false
|
||
return Boolean(buttonDisabledMap.value[disabledKey])
|
||
}
|
||
function resolveButtonLabel(defaultLabel: string, dynamicLabelKey?: string) {
|
||
return dynamicLabelKey ? (buttonLabelMap.value[dynamicLabelKey] || defaultLabel) : defaultLabel
|
||
}
|
||
|
||
const toolbarActionMap: Record<string, () => void> = {
|
||
loadData: () => { handleRefresh() },
|
||
openColumnConfigPanel: () => openColumnConfigPanel(),
|
||
}
|
||
|
||
function openColumnConfigPanel() {
|
||
upperTable.value?.openColumnConfig?.()
|
||
}
|
||
|
||
function handleToolbarButtonClick(action: string) {
|
||
const handler = toolbarActionMap[action]
|
||
if (!handler) return
|
||
safeInvoke(() => handler())
|
||
}
|
||
|
||
// ==================== 数据状态 ====================
|
||
|
||
const scanBox = ref<any>(null)
|
||
const upperTable = ref<any>(null)
|
||
const loading = ref(false)
|
||
const queryTime = ref(0)
|
||
const tableData = ref<any[]>([])
|
||
const currentConditions = ref<Record<string, any>>({})
|
||
const selectedRow = ref<any>(null)
|
||
|
||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||
const upperPagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||
|
||
// ==================== ScanBox 事件 ====================
|
||
|
||
function handleConditionChange(conditions: Record<string, any>) {
|
||
currentConditions.value = conditions ?? {}
|
||
pagination.currentPage = 1
|
||
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 handleRowClick(row: any) {
|
||
selectedRow.value = row
|
||
}
|
||
|
||
// ==================== 数据查询 ====================
|
||
|
||
function buildWhereFromConditions(conditions: Record<string, any>) {
|
||
const where: Record<string, any> = {}
|
||
// scan-box 字段名 → API 参数名映射
|
||
const keyMap: Record<string, string> = { store_id: 'storeId' }
|
||
for (const [key, cond] of Object.entries(conditions)) {
|
||
if (cond === undefined || cond === null || cond === '') continue
|
||
const apiKey = keyMap[key] || key
|
||
|
||
// dateRange → startDate / endDate
|
||
if (apiKey === 'dateRange' && typeof cond === 'object') {
|
||
const val = cond.value
|
||
if (Array.isArray(val) && val.length === 2) {
|
||
where.startDate = val[0]
|
||
where.endDate = val[1]
|
||
}
|
||
continue
|
||
}
|
||
|
||
if (typeof cond === 'object' && cond.value !== undefined) {
|
||
const val = cond.value
|
||
if (val === undefined || val === null || val === '' || (Array.isArray(val) && val.length === 0)) continue
|
||
// 数组转为逗号分隔字符串(支持 storeId / groupId 多选)
|
||
where[apiKey] = Array.isArray(val) ? val.join(',') : val
|
||
} else {
|
||
where[apiKey] = cond
|
||
}
|
||
}
|
||
return where
|
||
}
|
||
|
||
async function fetchData() {
|
||
loading.value = true
|
||
const start = Date.now()
|
||
try {
|
||
const where = buildWhereFromConditions(currentConditions.value)
|
||
const params: any = {
|
||
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)) {
|
||
const data = res.data ?? res
|
||
tableData.value = data.list ?? data.items ?? []
|
||
const total = data.total ?? data.pagination?.total ?? 0
|
||
pagination.total = total
|
||
upperPagination.total = total
|
||
} else {
|
||
tableData.value = []
|
||
pagination.total = 0
|
||
upperPagination.total = 0
|
||
ElMessage.error(res?.message || '获取消息列表失败')
|
||
}
|
||
} catch (error) {
|
||
console.error('获取消息列表失败:', error)
|
||
tableData.value = []
|
||
pagination.total = 0
|
||
upperPagination.total = 0
|
||
} finally {
|
||
queryTime.value = Date.now() - start
|
||
loading.value = false
|
||
}
|
||
}
|
||
|
||
async function fetchStats() {
|
||
try {
|
||
const res: any = await inboxStats()
|
||
if (res && (res.code === 1 || res.code === 200 || res.code === 20000)) {
|
||
statsData.value = res.data ?? null
|
||
}
|
||
} catch { /* ignore */ }
|
||
}
|
||
|
||
const statsData = ref<any>(null)
|
||
const statsInbound = computed(() => {
|
||
const item = statsData.value?.total_by_direction?.find((d: any) => d.direction === 'inbound')
|
||
return item?.count ?? 0
|
||
})
|
||
const statsOutbound = computed(() => {
|
||
const item = statsData.value?.total_by_direction?.find((d: any) => d.direction === 'outbound')
|
||
return item?.count ?? 0
|
||
})
|
||
const statsStatusTags = computed(() => {
|
||
const list = statsData.value?.total_by_status as any[] | undefined
|
||
if (!list) return []
|
||
const typeMap: Record<number, string> = { 0: 'info', 1: 'warning', 2: 'success', 3: 'danger' }
|
||
const labelMap: Record<number, string> = { 0: '待推送', 1: '推送中', 2: '已送达', 3: '失败' }
|
||
return list.map((s: any) => ({
|
||
status: s.push_status,
|
||
count: s.count,
|
||
type: typeMap[s.push_status] ?? 'info',
|
||
label: labelMap[s.push_status] ?? `状态${s.push_status}`,
|
||
}))
|
||
})
|
||
|
||
function handleRefresh() {
|
||
fetchData()
|
||
fetchStats()
|
||
}
|
||
|
||
function handlePageChange(page: number) {
|
||
pagination.currentPage = page
|
||
upperPagination.currentPage = page
|
||
fetchData()
|
||
}
|
||
|
||
function handlePageSizeChange(size: number) {
|
||
pagination.pageSize = size
|
||
upperPagination.pageSize = size
|
||
pagination.currentPage = 1
|
||
upperPagination.currentPage = 1
|
||
fetchData()
|
||
}
|
||
|
||
// ==================== 详情 ====================
|
||
|
||
const detailVisible = ref(false)
|
||
const detailData = ref<any>(null)
|
||
|
||
async function handleViewDetail(row: any) {
|
||
detailVisible.value = true
|
||
detailData.value = null
|
||
try {
|
||
const res: any = await inboxDetail(row.id)
|
||
if (res && (res.code === 1 || res.code === 200 || res.code === 20000)) {
|
||
detailData.value = res.data ?? res
|
||
} else {
|
||
ElMessage.error(res?.message || '获取详情失败')
|
||
}
|
||
} catch { ElMessage.error('获取详情失败') }
|
||
}
|
||
|
||
// ==================== 回信 ====================
|
||
|
||
const replyVisible = ref(false)
|
||
const replyLoading = ref(false)
|
||
const replyFormRef = ref<FormInstance>()
|
||
const replyForm = reactive({ parentId: 0, targetChannel: '', targetType: '', extDataJson: '', flagsJson: '' })
|
||
const replyRules: FormRules = { targetChannel: [{ required: true, message: '请选择目标渠道', trigger: 'change' }] }
|
||
|
||
function handleOpenReply(row: any) {
|
||
replyForm.parentId = row.id
|
||
replyForm.targetChannel = row.target_channel ?? ''
|
||
replyForm.targetType = ''
|
||
replyForm.extDataJson = ''
|
||
replyForm.flagsJson = ''
|
||
replyVisible.value = true
|
||
}
|
||
|
||
function resetReplyForm() { replyFormRef.value?.resetFields() }
|
||
|
||
async function handleSubmitReply() {
|
||
const valid = await replyFormRef.value?.validate().catch(() => false)
|
||
if (!valid) return
|
||
replyLoading.value = true
|
||
try {
|
||
const data: any = { parentId: replyForm.parentId, targetChannel: replyForm.targetChannel }
|
||
if (replyForm.targetType) data.targetType = replyForm.targetType
|
||
if (replyForm.extDataJson) {
|
||
try { data.extData = JSON.parse(replyForm.extDataJson) }
|
||
catch { ElMessage.warning('扩展数据 JSON 格式不正确'); replyLoading.value = false; return }
|
||
}
|
||
if (replyForm.flagsJson) {
|
||
try { data.flags = JSON.parse(replyForm.flagsJson) }
|
||
catch { ElMessage.warning('处理标记 JSON 格式不正确'); replyLoading.value = false; return }
|
||
}
|
||
const res: any = await inboxReply(data)
|
||
if (res && (res.code === 1 || res.code === 200 || res.code === 20000)) {
|
||
ElMessage.success('回信成功')
|
||
replyVisible.value = false
|
||
fetchData()
|
||
} else { ElMessage.error(res?.message || '回信失败') }
|
||
} catch { ElMessage.error('回信失败') }
|
||
finally { replyLoading.value = false }
|
||
}
|
||
|
||
// ==================== 重推 ====================
|
||
|
||
async function handleRetry(row: any) {
|
||
try {
|
||
const res: any = await inboxRetry(row.id)
|
||
if (res && (res.code === 1 || res.code === 200 || res.code === 20000)) {
|
||
ElMessage.success('重推成功')
|
||
fetchData()
|
||
} else { ElMessage.error(res?.message || '重推失败') }
|
||
} catch { ElMessage.error('重推失败') }
|
||
}
|
||
|
||
// ==================== 对话链 ====================
|
||
|
||
const threadVisible = ref(false)
|
||
const threadLoading = ref(false)
|
||
const threadData = ref<any[]>([])
|
||
/** 触发对话链的原始行:用于在弹窗内直接发起回信 */
|
||
const threadRootRow = ref<any>(null)
|
||
|
||
const threadInboundCount = computed(
|
||
() => threadData.value.filter((item) => item?.direction === 'inbound').length
|
||
)
|
||
const threadOutboundCount = computed(
|
||
() => threadData.value.filter((item) => item?.direction === 'outbound').length
|
||
)
|
||
|
||
async function handleViewThread(row: any) {
|
||
threadRootRow.value = row ?? null
|
||
threadVisible.value = true
|
||
threadData.value = []
|
||
threadLoading.value = true
|
||
try {
|
||
const res: any = await inboxThread(row.id)
|
||
if (res && (res.code === 1 || res.code === 200 || res.code === 20000)) {
|
||
threadData.value = Array.isArray(res.data?.thread) ? res.data.thread : (Array.isArray(res.data) ? res.data : [])
|
||
} else { ElMessage.error(res?.message || '获取对话链失败') }
|
||
} catch { ElMessage.error('获取对话链失败') }
|
||
finally { threadLoading.value = false }
|
||
}
|
||
|
||
/** 对话链底部「回信」:复用行内回信弹窗,父消息取打开对话链的那条 */
|
||
function handleReplyFromThread() {
|
||
const row = threadRootRow.value
|
||
threadVisible.value = false
|
||
if (row) handleOpenReply(row)
|
||
}
|
||
|
||
// ==================== 货主列表加载 ====================
|
||
|
||
async function loadStoreOptions() {
|
||
try {
|
||
const storesRes: any = await loadStores()
|
||
fillStoreScanFieldOptions(availableFields, extractStoreListFromResponse(storesRes))
|
||
} catch {
|
||
fillStoreScanFieldOptions(availableFields, [])
|
||
}
|
||
}
|
||
|
||
onMounted(() => {
|
||
loadStoreOptions()
|
||
fetchData()
|
||
fetchStats()
|
||
})
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
@use "../../order/orderManagement/styles/order-sub.scss";
|
||
|
||
/* 工具栏右侧统计标签:与左侧按钮组垂直居中(toolbar-left 默认 align-items:flex-start) */
|
||
.toolbar-stats {
|
||
display: flex;
|
||
align-items: center;
|
||
flex-wrap: wrap;
|
||
gap: 6px;
|
||
align-self: center;
|
||
min-width: 0;
|
||
}
|
||
|
||
.wave-operation-actions {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
gap: 4px;
|
||
flex-wrap: wrap;
|
||
}
|
||
|
||
.detail-content {
|
||
.content-text {
|
||
background: #f5f7fa;
|
||
padding: 10px 14px;
|
||
border-radius: 4px;
|
||
font-size: 13px;
|
||
line-height: 1.6;
|
||
color: #303133;
|
||
word-break: break-all;
|
||
}
|
||
.json-pre {
|
||
background: #f5f7fa;
|
||
padding: 10px;
|
||
border-radius: 4px;
|
||
font-size: 12px;
|
||
max-height: 200px;
|
||
overflow: auto;
|
||
margin: 0;
|
||
}
|
||
}
|
||
|
||
/* 对话链时间轴:左侧竖线 + 方向色节点,卡片沿用面板 4px 圆角 / 1px 边框语言 */
|
||
.thread-flow {
|
||
position: relative;
|
||
margin: 0;
|
||
padding: 2px 0 2px 20px;
|
||
list-style: none;
|
||
|
||
/* 竖线:与节点圆心对齐(节点 9px,圆心 4.5px) */
|
||
&::before {
|
||
content: '';
|
||
position: absolute;
|
||
left: 4px;
|
||
top: 8px;
|
||
bottom: 8px;
|
||
width: 1px;
|
||
background: #e4e7ed;
|
||
}
|
||
|
||
&__item {
|
||
position: relative;
|
||
padding-bottom: 10px;
|
||
|
||
&:last-child {
|
||
padding-bottom: 0;
|
||
}
|
||
}
|
||
|
||
&__node {
|
||
position: absolute;
|
||
left: -20px;
|
||
top: 12px;
|
||
width: 9px;
|
||
height: 9px;
|
||
box-sizing: border-box;
|
||
border: 2px solid #909399;
|
||
border-radius: 50%;
|
||
background: #fff;
|
||
}
|
||
|
||
&__item.is-inbound &__node {
|
||
border-color: #409eff;
|
||
}
|
||
|
||
&__item.is-outbound &__node {
|
||
border-color: #67c23a;
|
||
}
|
||
|
||
&__card {
|
||
padding: 8px 12px;
|
||
border: 1px solid #ebeef5;
|
||
border-radius: 4px;
|
||
background: #fff;
|
||
transition: border-color 0.2s, box-shadow 0.2s;
|
||
|
||
&:hover {
|
||
border-color: #dcdfe6;
|
||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
|
||
}
|
||
}
|
||
|
||
&__head {
|
||
display: flex;
|
||
align-items: center;
|
||
flex-wrap: wrap;
|
||
gap: 6px;
|
||
margin-bottom: 4px;
|
||
}
|
||
|
||
&__badge {
|
||
flex: none;
|
||
padding: 0 6px;
|
||
border-radius: 2px;
|
||
font-size: 12px;
|
||
line-height: 18px;
|
||
color: #606266;
|
||
background: #f4f4f5;
|
||
}
|
||
|
||
&__item.is-inbound &__badge {
|
||
color: #409eff;
|
||
background: #ecf5ff;
|
||
}
|
||
|
||
&__item.is-outbound &__badge {
|
||
color: #67c23a;
|
||
background: #f0f9eb;
|
||
}
|
||
|
||
&__tag {
|
||
font-size: 12px;
|
||
line-height: 18px;
|
||
color: #606266;
|
||
}
|
||
|
||
/* 时间靠右,与标签同一基线 */
|
||
&__time {
|
||
margin-left: auto;
|
||
padding-left: 8px;
|
||
font-size: 12px;
|
||
line-height: 18px;
|
||
color: #909399;
|
||
font-variant-numeric: tabular-nums;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
&__text {
|
||
margin: 0;
|
||
font-size: 13px;
|
||
line-height: 1.6;
|
||
color: #303133;
|
||
white-space: pre-wrap;
|
||
word-break: break-word;
|
||
}
|
||
|
||
&__meta {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
gap: 2px 12px;
|
||
margin-top: 4px;
|
||
font-size: 12px;
|
||
line-height: 18px;
|
||
color: #909399;
|
||
word-break: break-all;
|
||
}
|
||
|
||
&__empty {
|
||
padding: 40px 0;
|
||
text-align: center;
|
||
font-size: 13px;
|
||
color: #909399;
|
||
}
|
||
}
|
||
|
||
.thread-unit {
|
||
margin-left: 2px;
|
||
font-size: 12px;
|
||
font-weight: 400;
|
||
color: #909399;
|
||
}
|
||
|
||
.empty-tip { color: #909399; font-size: 13px; padding: 16px; }
|
||
|
||
/* 系统回信:面板结构 / 尺寸对齐「手工录入运单号」(ManualWaybillForm) */
|
||
.task-panel {
|
||
background: #fff;
|
||
color: #303133;
|
||
|
||
&__head {
|
||
display: flex;
|
||
align-items: flex-start;
|
||
gap: 12px;
|
||
padding: 16px;
|
||
}
|
||
|
||
&__titles {
|
||
flex: 1;
|
||
min-width: 0;
|
||
|
||
h2 {
|
||
margin: 0;
|
||
font-size: 18px;
|
||
line-height: 24px;
|
||
font-weight: 400;
|
||
color: #303133;
|
||
}
|
||
|
||
p {
|
||
margin: 4px 0 0;
|
||
font-size: 12px;
|
||
line-height: 18px;
|
||
color: #909399;
|
||
}
|
||
}
|
||
|
||
&__close {
|
||
width: 24px;
|
||
height: 24px;
|
||
flex: none;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
border: none;
|
||
border-radius: 4px;
|
||
background: transparent;
|
||
color: #909399;
|
||
cursor: pointer;
|
||
transition: color 0.2s;
|
||
|
||
svg {
|
||
width: 12px;
|
||
height: 12px;
|
||
}
|
||
|
||
&:hover {
|
||
color: #409eff;
|
||
}
|
||
}
|
||
|
||
&__body {
|
||
padding: 12px 16px 0;
|
||
|
||
/* 两个 JSON 文本域较高:超出 64vh 时面板内滚动 */
|
||
&--scroll {
|
||
max-height: 64vh;
|
||
overflow-y: auto;
|
||
}
|
||
}
|
||
|
||
&__form {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 8px;
|
||
}
|
||
|
||
/* 双列栅格:每格一个「标签 + 值 / 控件」行,窄屏(<720px)自动降为单列 */
|
||
&__grid {
|
||
display: grid;
|
||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||
column-gap: 16px;
|
||
row-gap: 8px;
|
||
|
||
@media (max-width: 720px) {
|
||
grid-template-columns: minmax(0, 1fr);
|
||
}
|
||
|
||
/* 对话链概览:三格等分,并与下方时间轴留出间距 */
|
||
&--stats {
|
||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||
margin-bottom: 12px;
|
||
|
||
@media (max-width: 720px) {
|
||
grid-template-columns: minmax(0, 1fr);
|
||
}
|
||
}
|
||
}
|
||
|
||
&__field {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 16px;
|
||
min-height: 40px;
|
||
padding: 8px 12px;
|
||
border: 1px solid #ebeef5;
|
||
border-radius: 4px;
|
||
background: #fafafa;
|
||
|
||
/* 输入行:去掉灰色容器,与静态信息行区分 */
|
||
&--input {
|
||
align-items: flex-start;
|
||
min-height: 0;
|
||
padding: 4px 0 0 12px;
|
||
border: none;
|
||
border-radius: 0;
|
||
background: transparent;
|
||
|
||
.task-panel__field-label {
|
||
padding-top: 7px;
|
||
|
||
/* 输入行标签整体下移 7px,星号同步下移以保持与文字基线对齐 */
|
||
&.is-required::before {
|
||
top: 7px;
|
||
}
|
||
}
|
||
}
|
||
|
||
/* 多行文本行:标签与文本域顶部对齐 */
|
||
&--textarea {
|
||
padding-top: 8px;
|
||
}
|
||
}
|
||
|
||
&__field-label {
|
||
position: relative;
|
||
flex: 0 0 88px;
|
||
width: 88px;
|
||
padding-left: 10px;
|
||
box-sizing: border-box;
|
||
font-size: 12px;
|
||
line-height: 20px;
|
||
color: #606266;
|
||
text-align: left;
|
||
|
||
/* 必填星号绝对定位在标签左侧,不占用标签宽度,保证各行列对齐 */
|
||
&.is-required::before {
|
||
content: '*';
|
||
position: absolute;
|
||
left: 0;
|
||
top: 0;
|
||
color: #f56c6c;
|
||
line-height: 20px;
|
||
}
|
||
}
|
||
|
||
&__field-value {
|
||
font-size: 13px;
|
||
font-weight: 500;
|
||
color: #303133;
|
||
text-align: right;
|
||
word-break: break-all;
|
||
}
|
||
|
||
/* 输入控件容器:占满标签列右侧剩余宽度 */
|
||
&__field-form {
|
||
flex: 1;
|
||
min-width: 0;
|
||
max-width: none;
|
||
|
||
:deep(.el-form-item) {
|
||
flex: 1;
|
||
min-width: 0;
|
||
width: 100%;
|
||
margin-bottom: 0;
|
||
}
|
||
|
||
:deep(.el-form-item__content) {
|
||
margin-left: 0 !important;
|
||
width: 100%;
|
||
line-height: 1.4;
|
||
}
|
||
|
||
:deep(.el-form-item__error) {
|
||
position: static;
|
||
padding-top: 4px;
|
||
}
|
||
|
||
:deep(.el-select),
|
||
:deep(.el-input) {
|
||
width: 100%;
|
||
}
|
||
}
|
||
|
||
/* 表单下方统一提示条(表单内不再逐行挂提示) */
|
||
&__form-tip {
|
||
margin: 8px 0 0;
|
||
padding: 8px 12px;
|
||
border-radius: 4px;
|
||
background: #f4f4f5;
|
||
font-size: 12px;
|
||
line-height: 18px;
|
||
color: #909399;
|
||
}
|
||
|
||
&__foot {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 12px;
|
||
padding: 16px;
|
||
}
|
||
|
||
&__hint {
|
||
font-size: 12px;
|
||
color: #909399;
|
||
}
|
||
|
||
&__actions {
|
||
display: flex;
|
||
align-items: center;
|
||
/* 与工具栏按钮组(OrderToolbarButtonGroup)保持一致:gap 6px */
|
||
gap: 6px;
|
||
|
||
:deep(.el-button) {
|
||
margin-left: 0;
|
||
margin-right: 0;
|
||
}
|
||
}
|
||
}
|
||
|
||
/* 面板内嵌 el-form-item:去掉默认间距,错误提示改回文档流内展示 */
|
||
.task-panel__form {
|
||
:deep(.el-form-item) {
|
||
flex: 1;
|
||
min-width: 0;
|
||
margin-bottom: 0;
|
||
}
|
||
|
||
:deep(.el-form-item__content) {
|
||
margin-left: 0 !important;
|
||
width: 100%;
|
||
line-height: 1.4;
|
||
}
|
||
|
||
:deep(.el-form-item__error) {
|
||
position: static;
|
||
padding-top: 4px;
|
||
}
|
||
}
|
||
</style>
|
||
|
||
<style lang="scss">
|
||
/* el-dialog 会被 append 到 body:去掉默认头/内边距,统一交给面板 */
|
||
.el-dialog.system-reply-dialog,
|
||
.el-dialog.inbox-thread-dialog {
|
||
padding: 0;
|
||
overflow: hidden;
|
||
|
||
.el-dialog__header {
|
||
display: none;
|
||
}
|
||
|
||
.el-dialog__body {
|
||
padding: 0;
|
||
}
|
||
}
|
||
</style>
|