feat(退回记录): 新增退回记录多标签页(退回收件任务/退回收件登记/退回拆包单/未退登记/收件/退回拆包作业)

新增:

- data/returnrecord tab 合并页 + router/map 映射(支持 ?tab= 刷新回到该页签)

- api/returnreceivedtask(list/create/delete-ids)

退回收件任务:

- 列表/筛选(关键词移至工具栏、是否有登记)/分页;新建(仅标题,批次号服务端生成);多选批量删除;登记数列(el-tag)

收件 tab:

- 左=锁定任务+扫码登记表单(无左侧label),右=该任务登记列表(语义化列+'-')

- 备注可复用下拉(localStorage)且常驻;扫码枪焦点无关自动登记(防双提交)

- 仅从任务列表「登记收件」进入,切走即移除页签

其它:

- 退回拆包单内嵌「拆包作业」入口;作业页键盘监听随激活态收放;进行中任务离开拦截

- 退回收件登记移除内置扫码表单/扫描人员工号;点 tab 清筛选;运单退回登记更名未退登记

- ScanBox/弹窗/单位换算等若干交互修复
This commit is contained in:
liufumingren 2026-10-05 20:13:35 +08:00
parent bf5471bd1b
commit 0b00014427
12 changed files with 1842 additions and 105 deletions

View File

@ -10,6 +10,8 @@ export type ReturnReceivedCreateParams = {
waybill_code: string
/** 备注 */
remark?: string
/** 退回收件任务ID(不传默认 1 = 系统预设「历史收件」) */
return_received_task_id?: number
}
/** returnReceived.create:退回包裹扫码登记(30日内同仓库同单号幂等,以第一次为准) */
@ -43,6 +45,8 @@ export type ReturnReceivedListWhere = {
scanner_name?: string
/** 货主ID(等值) */
store_id?: number
/** 退回收件任务ID(等值) */
return_received_task_id?: number
/** 运单ID(等值,原单退回时回填) */
order_express_id?: number
/** 订单ID(等值,原单退回时回填) */

View File

@ -0,0 +1,187 @@
import request from '@/utils/request'
const v = '1.0'
const SYSTEM_URL = '/system'
// ============ 通用类型 ============
/** 退回收件任务记录(表 wms_return_received_task) */
export type ReturnReceivedTaskRecord = {
id: number
/** 批次号(服务端自动生成 RT+YYYYMMDD+5位序号;系统预设「历史收件」id=1) */
batch_no: string
/** 标题 */
title: string
/** 仓库ID(服务端注入;系统级任务为 0) */
warehouse_id?: number
/** 创建人账户ID(服务端注入) */
creator_id?: number
/** 创建人名称快照(服务端注入) */
creator_name?: string
/** 登记数:该任务下已登记(wms_return_received)的记录条数 */
register_count?: number
created_at?: string
updated_at?: string
[key: string]: unknown
}
/** 退回收件任务分页信息 */
export type ReturnReceivedTaskPagination = {
page: number
pageSize: number
total: number
totalPages?: number
hasPrevious?: boolean
hasNext?: boolean
}
/** returnReceivedTask.list 的 where 筛选条件 */
export type ReturnReceivedTaskListWhere = {
/**
* 关键词搜索(项目 quickWhere 惯例,传字符串):
* 在 标题(title)/ 编号(batch_no)/ 创建人(creator_name)三个字段中 OR 模糊匹配
*/
quickWhere?: string
/** 标题(支持 {operator, value} 或直接值) */
title?: string | { operator: string; value: any }
/** 编号(支持 {operator, value} 或直接值) */
batch_no?: string | { operator: string; value: any }
/** 创建人(支持 {operator, value} 或直接值) */
creator_name?: string | { operator: string; value: any }
/** 创建时间范围 */
created_at?: { operator: 'between' | 'gte' | 'lte'; value: [string, string] | string }
/** 更新时间范围 */
updated_at?: { operator: 'between' | 'gte' | 'lte'; value: [string, string] | string }
[key: string]: unknown
}
/** returnReceivedTask.list 排序参数 */
export type ReturnReceivedTaskListSort = {
/** 排序字段白名单:id / batch_no / created_at / updated_at(默认 id desc) */
sortField?: 'id' | 'batch_no' | 'created_at' | 'updated_at'
sortOrder?: 'asc' | 'desc'
}
/** returnReceivedTask.list 请求参数 */
export type ReturnReceivedTaskListParams = {
pagination?: { page?: number; pageSize?: number }
where?: ReturnReceivedTaskListWhere
sort?: ReturnReceivedTaskListSort
}
/** returnReceivedTask.list 响应(/system 网关:业务字段与信封同级,兼容 data 包裹) */
export type ReturnReceivedTaskListResponse = {
flag?: string
/** 业务码:1 / 200 / 20000 均视为成功 */
code?: number
message?: string
timestamp?: number
list?: ReturnReceivedTaskRecord[]
pagination?: ReturnReceivedTaskPagination
data?: {
list?: ReturnReceivedTaskRecord[]
pagination?: ReturnReceivedTaskPagination
}
}
/** returnReceivedTask.list:退回收件任务分页列表(仓库隔离:本仓库 + 系统级 warehouse_id=0) */
export function returnReceivedTaskList(
data: ReturnReceivedTaskListParams = {}
): Promise<ReturnReceivedTaskListResponse> {
return request({
url: SYSTEM_URL,
method: 'post',
params: {
method: 'returnReceivedTask.list',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
// ============ returnReceivedTask.create ============
/** returnReceivedTask.create 请求参数(批次号由服务端自动生成,不接受外部传入) */
export type ReturnReceivedTaskCreateParams = {
/** 标题(可选) */
title?: string
}
/** returnReceivedTask.create 响应(平铺形态,兼容 data 包裹) */
export type ReturnReceivedTaskCreateResponse = {
flag?: string
code?: number
message?: string
timestamp?: number
/** 新建的任务记录 */
record?: ReturnReceivedTaskRecord
id?: number
batch_no?: string
title?: string
data?: {
record?: ReturnReceivedTaskRecord
id?: number
batch_no?: string
title?: string
}
}
/**
* returnReceivedTask.create:创建退回收件任务
* - warehouse_id / creator_id / creator_name 由服务端从上下文注入,前端一律不传
* - 批次号由服务端自动生成(不接受前端传入)
* - 需登录,免 API 权限校验
*/
export function returnReceivedTaskCreate(
data: ReturnReceivedTaskCreateParams = {}
): Promise<ReturnReceivedTaskCreateResponse> {
return request({
url: SYSTEM_URL,
method: 'post',
params: {
method: 'returnReceivedTask.create',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
// ============ returnReceivedTask.delete ============
/** returnReceivedTask.delete 请求参数 */
export type ReturnReceivedTaskDeleteParams = {
/** 任务主键ID数组(批量删除) */
ids: number[]
}
/**
* returnReceivedTask.delete:批量删除退回收件任务(硬删除)
* - 已有收件登记引用该任务 → 409 不可删除
* - 系统预设 id=1(历史收件)→ 404 不可删除
*/
export function returnReceivedTaskDelete(data: ReturnReceivedTaskDeleteParams): Promise<any> {
return request({
url: SYSTEM_URL,
method: 'post',
params: {
method: 'returnReceivedTask.delete',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
// ============ 模块导出 ============
export const returnReceivedTaskModule = {
list: returnReceivedTaskList,
create: returnReceivedTaskCreate,
remove: returnReceivedTaskDelete
}

View File

@ -72,6 +72,8 @@ export const componentMap: Record<string, any> = {
'video/cameraServer/index': () => import('@/views/video/newcamaraserver/index.vue'),
'video/camera/index': () => import('@/views/video/newcamara/index.vue'),
'data/packingflow': () => import('@/views/data/packingflow/index.vue'),
/** 退回记录:退回拆包单 + 退回收件登记(tab 合并) */
'data/returnrecord': () => import('@/views/data/returnrecord/index.vue'),
'system/setting/printcomputer/index':() => import('@/views/system/setting/printcomputer/index.vue'),
'express/index':() => import('@/views/express/waybill/index.vue'),
/** 退回收件登记 */

View File

@ -0,0 +1,515 @@
<template>
<div class="receive-register">
<!-- 左:操作表单 + 参数(任务已锁定,不可切换) -->
<div class="receive-left">
<div class="panel-title">收件登记</div>
<el-descriptions :column="1" size="small" border class="task-params">
<el-descriptions-item label="任务">{{ taskLabel || '—' }}</el-descriptions-item>
</el-descriptions>
<el-form :model="form" label-width="0" class="register-form" @submit.prevent>
<el-form-item>
<el-input
ref="waybillInputRef"
v-model="form.waybillCode"
placeholder="退回运单号(扫码/输入)"
clearable
@keyup.enter="handleRegister"
/>
</el-form-item>
<el-form-item>
<el-select
v-model="form.remark"
class="full-width"
clearable
filterable
allow-create
default-first-option
placeholder="备注(可选,可复用)"
@change="handleRemarkChange"
>
<el-option v-for="opt in remarkOptions" :key="opt" :label="opt" :value="opt">
<span class="remark-option-content">
<span class="remark-option-label" :title="opt">{{ opt }}</span>
<el-button
class="remark-option-delete"
type="danger"
link
size="small"
@mousedown.stop.prevent
@click.stop.prevent="removeRemarkOption(opt)"
>删除</el-button>
</span>
</el-option>
<el-option :value="REMARK_ADD_OPTION_VALUE" label="+ 添加备注选项" class="remark-add-option" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" :loading="registerLoading" @click="handleRegister">扫码登记</el-button>
<el-button @click="clearWaybill">重置</el-button>
</el-form-item>
</el-form>
</div>
<!-- 右:当前任务的登记列表 -->
<div class="receive-right">
<div class="panel-head">
<span class="panel-title">任务登记列表</span>
<el-button size="small" :loading="listLoading" @click="handleRefresh">刷新</el-button>
</div>
<div class="table-wrap">
<upper-table
ref="upperTable"
table-id="data-returnrecord-receive-register-list"
default-align="center"
:data="list"
:columns="columns"
:table-size="tableSize"
:enable-column-config="true"
:pagination="pagination"
:show-index="true"
:loading="listLoading"
:query-time="queryTime"
@page-change="handlePageChange"
@page-size-change="handlePageSizeChange"
>
<template #column-is_notified="{ row }">
<span :class="getStatusTextClass(row.is_notified ? 'success' : 'info')">
{{ row.is_notified ? '已通知' : '未通知' }}
</span>
</template>
<template #column-is_original_return="{ row }">
<span :class="getStatusTextClass(row.is_original_return ? 'success' : 'info')">
{{ row.is_original_return ? '是' : '否' }}
</span>
</template>
<template #column-order_express_id="{ row }">
<span v-if="row.order_express_id != null">{{ row.order_express_id }}</span>
<span v-else>-</span>
</template>
<template #column-order_id="{ row }">
<span v-if="row.order_id != null">{{ row.order_id }}</span>
<span v-else>-</span>
</template>
<template #empty>
<div class="empty-tip">该任务暂无登记记录</div>
</template>
</upper-table>
</div>
</div>
<el-dialog
v-model="remarkAddVisible"
title="添加备注选项"
width="420px"
align-center
append-to-body
>
<el-input
v-model="remarkDraft"
maxlength="500"
show-word-limit
placeholder="请输入备注内容"
@keyup.enter="confirmAddRemarkOption"
/>
<template #footer>
<el-button size="small" @click="remarkAddVisible = false">取消</el-button>
<el-button size="small" type="primary" @click="confirmAddRemarkOption">保存</el-button>
</template>
</el-dialog>
</div>
</template>
<script setup lang="ts">
import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue'
import { ElMessage } from 'element-plus'
import { returnReceivedCreate, returnReceivedList } from '@/api/returnreceived'
import { returnReceivedColumns } from '@/views/express/returnReceived/returnReceived-config'
import { getStatusTextClass } from '@/views/order/orderManagement/config/order-common-config'
import UpperTable from '@/components/UpperTable/index.vue'
import { useBarcodeScan } from '@/composables/useBarcodeScan'
const props = defineProps<{
/** 锁定的退回收件任务ID(仅能从任务列表「登记收件」进入) */
taskId?: number | null
/** 任务展示名(标题 / 批次号) */
taskLabel?: string
/** 进入序号:每次从任务列表点击「登记收件」自增,保证重复进入同一任务也刷新 */
receiveSeq?: number
}>()
const tableSize = 'small'
/** 复用退回收件登记列配置,去掉操作列(本页只读展示当前任务登记) */
const columns = computed(() => (returnReceivedColumns as any[]).filter((c) => c.prop !== 'actions'))
const upperTable = ref<any>(null)
const waybillInputRef = ref<any>(null)
const form = reactive({ waybillCode: '', remark: loadSelectedRemark() })
const registerLoading = ref(false)
const listLoading = ref(false)
const queryTime = ref(0)
const list = ref<any[]>([])
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
function normalizeTaskId(raw: unknown): number | null {
if (raw === undefined || raw === null || raw === '') return null
const n = Number(raw)
return Number.isInteger(n) && n > 0 ? n : null
}
// ==================== 列表查询 ====================
async function loadList() {
const taskId = normalizeTaskId(props.taskId)
if (!taskId) {
list.value = []
pagination.total = 0
return
}
listLoading.value = true
const start = Date.now()
try {
const res: any = await returnReceivedList({
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
where: { return_received_task_id: taskId },
})
if (res && (res.code === 1 || res.code === 200 || res.code === 20000)) {
const data = res.data ?? res
list.value = data.list ?? data.items ?? []
pagination.total = data.pagination?.total ?? data.total ?? 0
} else {
list.value = []
pagination.total = 0
ElMessage.error(res?.message || '获取登记列表失败')
}
} catch (error) {
console.error('获取登记列表失败:', error)
list.value = []
pagination.total = 0
} finally {
queryTime.value = Date.now() - start
listLoading.value = false
}
}
function handleRefresh() {
loadList()
}
function handlePageChange(page: number) {
pagination.currentPage = page
loadList()
}
function handlePageSizeChange(size: number) {
pagination.pageSize = size
pagination.currentPage = 1
loadList()
}
// ==================== 扫码登记 ====================
/** 只清空运单号;备注常驻,未切换前一直沿用同一备注 */
function clearWaybill() {
form.waybillCode = ''
}
async function handleRegister() {
// 防重:扫码枪回车会同时触发全局 onScan 与输入框 @keyup.enter(keyup 不受 keydown 的 stopPropagation 影响)→ 避免双提交
if (registerLoading.value) return
const taskId = normalizeTaskId(props.taskId)
if (!taskId) {
ElMessage.warning('未锁定退回收件任务,无法登记')
return
}
const code = form.waybillCode.trim()
if (!code) {
ElMessage.warning('请先扫描或输入退回收件运单号')
return
}
registerLoading.value = true
try {
const res: any = await returnReceivedCreate({
waybill_code: code,
remark: form.remark ? form.remark.trim() : undefined,
return_received_task_id: taskId,
})
if (res && (res.code === 1 || res.code === 200 || res.code === 20000)) {
const data = res.data ?? res
const urgentTip = data.is_urgent ? '(加急件)' : ''
if (data.duplicated) {
ElMessage.warning(`该运单号 30 日内已登记(记录ID ${data.record?.id ?? data.id}),已返回第一次登记结果${urgentTip}`)
} else if (data.is_original_return) {
ElMessage.success(`登记成功:命中原单退回,原运单ID ${data.record?.order_express_id ?? data.order_express_id}${urgentTip}`)
} else {
ElMessage.success(`登记成功${urgentTip}`)
}
clearWaybill()
pagination.currentPage = 1
loadList()
nextTick(() => waybillInputRef.value?.focus?.())
} else {
ElMessage.error(res?.message || '登记失败')
}
} catch {
// 请求层已提示错误
} finally {
registerLoading.value = false
}
}
// ==================== 备注下拉选项(localStorage 持久化,参考退件拆包) ====================
const REMARK_OPTIONS_STORAGE_KEY = 'returnReceived:remarkOptions'
/** 当前选中的备注(常驻:跨连续登记/重进/刷新沿用) */
const REMARK_SELECTED_STORAGE_KEY = 'returnReceived:remarkSelected'
/** 下拉中「添加备注选项」的占位值(仅触发弹窗,不写入数据) */
const REMARK_ADD_OPTION_VALUE = '__add_remark_option__'
const remarkOptions = ref<string[]>(loadRemarkOptions())
const remarkAddVisible = ref(false)
const remarkDraft = ref('')
const remarkPrevValue = ref(form.remark)
/** 读取常驻备注 */
function loadSelectedRemark(): string {
try {
return String(localStorage.getItem(REMARK_SELECTED_STORAGE_KEY) ?? '')
} catch {
return ''
}
}
/** 持久化常驻备注 */
function persistSelectedRemark(value: string) {
try {
localStorage.setItem(REMARK_SELECTED_STORAGE_KEY, String(value ?? ''))
} catch {
// 存储失败忽略
}
}
function loadRemarkOptions(): string[] {
try {
const raw = localStorage.getItem(REMARK_OPTIONS_STORAGE_KEY)
if (!raw) return []
const parsed = JSON.parse(raw)
if (!Array.isArray(parsed)) return []
return parsed.map((v: any) => String(v ?? '').trim()).filter(Boolean)
} catch {
return []
}
}
function persistRemarkOptions() {
try {
localStorage.setItem(REMARK_OPTIONS_STORAGE_KEY, JSON.stringify(remarkOptions.value))
} catch {
// 存储失败忽略
}
}
/** 新增备注选项(去重),返回规范化后的值 */
function addRemarkOption(text: string): string {
const value = String(text ?? '').trim()
if (!value) return ''
if (!remarkOptions.value.some((o) => o === value)) {
remarkOptions.value.push(value)
persistRemarkOptions()
}
return value
}
/** 删除备注选项(仅从选项列表移除,不影响已登记记录) */
function removeRemarkOption(text: string) {
const value = String(text ?? '').trim()
const idx = remarkOptions.value.findIndex((o) => o === value)
if (idx < 0) return
remarkOptions.value.splice(idx, 1)
persistRemarkOptions()
}
/** 备注下拉变更:拦截「添加备注选项」,其余值自动入库 localStorage */
function handleRemarkChange(value: string) {
if (value === REMARK_ADD_OPTION_VALUE) {
remarkDraft.value = ''
remarkAddVisible.value = true
// 回退占位值,避免脏值写入
form.remark = remarkPrevValue.value
return
}
remarkPrevValue.value = value || ''
persistSelectedRemark(remarkPrevValue.value)
if (value) addRemarkOption(value)
}
/** 弹窗确定:新增备注选项并回填 */
function confirmAddRemarkOption() {
const value = String(remarkDraft.value ?? '').trim()
if (!value) {
ElMessage.warning('请输入备注内容')
return
}
addRemarkOption(value)
form.remark = value
remarkPrevValue.value = value
persistSelectedRemark(value)
remarkAddVisible.value = false
remarkDraft.value = ''
}
// ==================== 扫码枪(焦点无关,直接进运单号并登记) ====================
useBarcodeScan({
enabled: () => !registerLoading.value,
onScan: (code: string) => {
form.waybillCode = code
void handleRegister()
},
})
onMounted(() => {
loadList()
nextTick(() => waybillInputRef.value?.focus?.())
})
// 从任务列表进入(含重复进入同一任务):清空运单号(备注常驻)+ 重查当前任务登记列表
watch(
() => props.receiveSeq,
(val, oldVal) => {
if (val === oldVal) return
clearWaybill()
pagination.currentPage = 1
loadList()
nextTick(() => waybillInputRef.value?.focus?.())
}
)
</script>
<style scoped lang="scss">
.receive-register {
display: flex;
gap: 10px;
height: 100%;
width: 100%;
padding: 10px;
box-sizing: border-box;
background-color: #f0f2f5;
.receive-left {
flex: 0 0 340px;
display: flex;
flex-direction: column;
gap: 12px;
padding: 12px;
background: #fff;
border: 1px solid #ebeef5;
border-radius: 6px;
overflow: auto;
}
.receive-right {
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
gap: 8px;
padding: 12px;
background: #fff;
border: 1px solid #ebeef5;
border-radius: 6px;
overflow: hidden;
}
.panel-title {
font-size: 14px;
font-weight: 600;
color: #303133;
}
.panel-head {
display: flex;
align-items: center;
justify-content: space-between;
flex-shrink: 0;
}
.task-params {
:deep(.el-descriptions__label) {
width: 70px;
background: #fafbfc;
font-weight: 500;
}
}
.register-form {
margin-top: 4px;
}
.full-width {
width: 100%;
}
.table-wrap {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
:deep(.upper-table-container) {
height: 100%;
display: flex;
flex-direction: column;
}
:deep(.table-container) {
height: auto !important;
flex: 1 1 auto;
min-height: 0;
overflow: hidden;
}
}
.empty-tip {
color: #909399;
font-size: 13px;
padding: 16px;
}
}
/* 备注下拉选项:el-select 下拉被 teleport 到 body,样式必须放顶层(不能嵌套在 .receive-register 内) */
.remark-add-option {
color: #409eff;
}
.remark-option-content {
display: flex;
align-items: center;
gap: 8px;
width: 100%;
}
.remark-option-label {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.remark-option-delete {
flex-shrink: 0;
padding: 0;
height: auto;
font-size: 13px;
cursor: pointer;
}
</style>

View File

@ -0,0 +1,497 @@
<template>
<div class="order-sub-container">
<scan-box
ref="scanBox"
cache-key="data:returnrecord:returnReceivedTask"
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"
/>
<el-divider direction="vertical" />
<div class="toolbar-keyword">
<el-input
v-model="keyword"
size="small"
class="keyword-input"
placeholder="关键词:标题 / 批次号 / 创建人"
clearable
@keyup.enter="handleKeywordSearch"
@clear="handleKeywordSearch"
/>
<el-button type="primary" size="small" :loading="loading" @click="handleKeywordSearch">搜索</el-button>
</div>
</div>
</div>
<div class="split-stack">
<div class="upper-wrapper upper-wrapper--full">
<upper-table
ref="upperTable"
title="退回收件任务列表"
default-align="center"
table-id="data-returnrecord-returnReceivedTask-list"
:data="tableData"
:columns="columns"
:table-size="tableSize"
:enable-column-config="true"
:pagination="pagination"
:show-index="true"
:show-selection="true"
:loading="loading"
:query-time="queryTime"
@selection-change="handleSelectionChange"
@page-change="handlePageChange"
@page-size-change="handlePageSizeChange"
@refresh="handleRefresh"
@sort-change="handleSortChange"
>
<template #column-title="{ row }">
<span class="task-title">{{ row.title || '—' }}</span>
</template>
<template #column-register_count="{ row }">
<el-tag size="small" :type="Number(row.register_count) > 0 ? 'primary' : 'info'">
{{ Number(row.register_count) || 0 }}
</el-tag>
</template>
<template #column-actions="{ row }">
<div class="wave-operation-actions">
<el-button size="small" type="success" link @click.stop="handleRegisterReceive(row)">
登记收件
</el-button>
<el-button size="small" type="primary" link @click.stop="handleViewRegistrations(row)">
查看登记
</el-button>
</div>
</template>
<template #empty>
<div class="empty-tip">暂无退回收件任务</div>
</template>
</upper-table>
</div>
</div>
</div>
<!-- ========== 新建任务弹窗 ========== -->
<el-dialog
v-model="createVisible"
title="新建退回收件任务"
width="440px"
align-center
:close-on-click-modal="false"
>
<el-form :model="createForm" label-width="72px" @submit.prevent>
<el-form-item label="标题">
<el-input
v-model="createForm.title"
maxlength="100"
show-word-limit
placeholder="请输入任务标题(可选)"
clearable
@keyup.enter="handleCreate"
/>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="createVisible = false">取消</el-button>
<el-button type="primary" :loading="createLoading" @click="handleCreate">确定</el-button>
</template>
</el-dialog>
</div>
</template>
<script setup lang="ts">
import { computed, onMounted, reactive, ref } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import {
returnReceivedTaskList,
returnReceivedTaskCreate,
returnReceivedTaskDelete,
} from '@/api/returnreceivedtask'
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
import {
returnReceivedTaskAvailableFields,
returnReceivedTaskColumns,
returnReceivedTaskToolbarButtons,
} from '../returnReceivedTask-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 { safeInvoke } from '@/utils/safe-invoke'
// ==================== 配置 ====================
const availableFields = returnReceivedTaskAvailableFields
const columns = returnReceivedTaskColumns
const tableSize = 'small'
const toolbarButtons: ToolbarButtonConfig[] = returnReceivedTaskToolbarButtons
// ==================== 工具栏按钮状态 ====================
const buttonLoadingMap = computed<Record<string, boolean>>(() => ({
loading: loading.value,
createLoading: createLoading.value,
batchDeleteLoading: deleteLoading.value,
}))
const buttonDisabledMap = ref<Record<string, boolean>>({ hasNoSelection: true })
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(),
openCreateDialog: () => openCreateDialog(),
handleBatchDelete: () => { void handleBatchDelete() },
openColumnConfigPanel: () => openColumnConfigPanel(),
}
function openColumnConfigPanel() {
upperTable.value?.openColumnConfig?.()
}
function handleToolbarButtonClick(action: string) {
const handler = toolbarActionMap[action]
if (!handler) return
safeInvoke(() => handler())
}
// ==================== 事件 ====================
const emit = defineEmits<{
(e: 'view-registrations', row: any): void
(e: 'register-receive', row: any): void
}>()
/** 点击「查看登记」→ 通知外层跳到「退回收件登记」并按该任务筛选 */
function handleViewRegistrations(row: any) {
if (!row?.id) return
emit('view-registrations', row)
}
/** 点击「登记收件」→ 通知外层进入「收件」tab 并锁定该任务 */
function handleRegisterReceive(row: any) {
if (!row?.id) return
emit('register-receive', row)
}
// ==================== 数据状态 ====================
const scanBox = ref<any>(null)
const upperTable = ref<any>(null)
const loading = ref(false)
const createLoading = ref(false)
const deleteLoading = ref(false)
const queryTime = ref(0)
const tableData = ref<any[]>([])
const selectionRows = ref<any[]>([])
const currentConditions = ref<Record<string, any>>({})
const currentSort = ref<{ prop: string; order: string }>({ prop: '', order: '' })
/** 工具栏关键词搜索(对应 list 的 where.quickWhere:标题/批次号/创建人 OR 模糊) */
const keyword = ref('')
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
// ==================== ScanBox 事件 ====================
function handleConditionChange(conditions: Record<string, any>) {
currentConditions.value = conditions ?? {}
pagination.currentPage = 1
fetchData()
}
function handleConditionReset() {
currentConditions.value = {}
pagination.currentPage = 1
fetchData()
}
function handleConditionClear() {
currentConditions.value = {}
pagination.currentPage = 1
fetchData()
}
// ==================== 条件转换 ====================
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
const value = cond && typeof cond === 'object' && 'value' in cond ? (cond as any).value : cond
if (
value === undefined ||
value === null ||
value === '' ||
(Array.isArray(value) && value.length === 0)
) {
continue
}
switch (key) {
// quickWhere:项目惯例,直接传字符串(服务端在标题/编号/创建人三字段 OR 模糊)
case 'quickWhere':
where.quickWhere = String(value)
break
case 'title':
case 'batch_no':
case 'creator_name':
where[key] = { operator: 'like', value: String(value) }
break
case 'has_register':
where.has_register = Boolean(value)
break
case 'created_at':
case 'updated_at':
where[key] = { operator: 'between', value }
break
default:
where[key] = value
}
}
return where
}
// ==================== 数据查询 ====================
async function fetchData() {
loading.value = true
const start = Date.now()
try {
const where = buildWhereFromConditions(currentConditions.value)
const keywordText = keyword.value.trim()
if (keywordText) where.quickWhere = keywordText
const params: any = {
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
}
if (Object.keys(where).length) params.where = where
if (currentSort.value.prop) {
params.sort = {
sortField: currentSort.value.prop,
sortOrder: currentSort.value.order === 'ascending' ? 'asc' : 'desc',
}
}
const res: any = await returnReceivedTaskList(params)
if (res && (res.code === 1 || res.code === 200 || res.code === 20000)) {
const data = res.data ?? res
tableData.value = data.list ?? data.items ?? []
pagination.total = data.pagination?.total ?? data.total ?? 0
} else {
tableData.value = []
pagination.total = 0
ElMessage.error(res?.message || '获取退回收件任务列表失败')
}
} catch (error) {
console.error('获取退回收件任务列表失败:', error)
tableData.value = []
pagination.total = 0
} finally {
queryTime.value = Date.now() - start
loading.value = false
}
}
function handleRefresh() {
fetchData()
}
/** 关键词搜索:回到第 1 页并查询 */
function handleKeywordSearch() {
pagination.currentPage = 1
fetchData()
}
function handlePageChange(page: number) {
pagination.currentPage = page
fetchData()
}
function handlePageSizeChange(size: number) {
pagination.pageSize = size
pagination.currentPage = 1
fetchData()
}
function handleSortChange({ prop, order }: any) {
currentSort.value = { prop: prop ?? '', order: order ?? '' }
pagination.currentPage = 1
fetchData()
}
// ==================== 新建任务 ====================
const createVisible = ref(false)
const createForm = reactive({ title: '' })
function openCreateDialog() {
createForm.title = ''
createVisible.value = true
}
async function handleCreate() {
if (createLoading.value) return
createLoading.value = true
try {
const payload: Record<string, string> = {}
const title = createForm.title.trim()
if (title) payload.title = title
const res: any = await returnReceivedTaskCreate(payload)
if (res && (res.code === 1 || res.code === 200 || res.code === 20000)) {
const data = res.data ?? res
const createdBatchNo = data.record?.batch_no ?? data.batch_no
const createdTitle = data.record?.title ?? data.title
ElMessage.success(
`新建任务成功${createdBatchNo ? `:${createdBatchNo}` : ''}${createdTitle ? `(${createdTitle})` : ''}`
)
createVisible.value = false
pagination.currentPage = 1
fetchData()
} else {
ElMessage.error(res?.message || '新建任务失败')
}
} catch {
// 请求层已提示错误
} finally {
createLoading.value = false
}
}
// ==================== 批量删除任务 ====================
function handleSelectionChange(rows: any[]) {
selectionRows.value = rows || []
buttonDisabledMap.value = {
...buttonDisabledMap.value,
hasNoSelection: selectionRows.value.length === 0,
}
}
async function handleBatchDelete() {
const rows = selectionRows.value
if (!rows.length) {
ElMessage.warning('请先勾选要删除的任务')
return
}
// 前置校验:系统预设任务、已有登记的任务不可删除
const presetRows = rows.filter((r) => Number(r?.id) === 1)
const usedRows = rows.filter((r) => Number(r?.id) !== 1 && Number(r?.register_count) > 0)
if (presetRows.length || usedRows.length) {
const tips: string[] = []
if (presetRows.length) tips.push('系统预设任务「历史收件」不可删除')
if (usedRows.length) {
const names = usedRows.map((r) => r.title || r.batch_no || r.id).join('、')
tips.push(`以下任务已有登记不可删除:${names}`)
}
ElMessage.warning(tips.join(';'))
return
}
const ids = rows
.map((r) => Number(r?.id))
.filter((id) => Number.isInteger(id) && id > 0)
if (!ids.length) {
ElMessage.warning('选中的任务无有效ID')
return
}
try {
await ElMessageBox.confirm(
`确认批量删除选中的 ${ids.length} 个任务?删除后不可恢复。`,
'批量删除确认',
{ type: 'warning', confirmButtonText: '删除', cancelButtonText: '取消' }
)
} catch {
return
}
deleteLoading.value = true
try {
const res: any = await returnReceivedTaskDelete({ ids })
if (res && (res.code === 1 || res.code === 200 || res.code === 20000)) {
ElMessage.success(`已删除 ${ids.length} 个任务`)
upperTable.value?.clearSelection?.()
selectionRows.value = []
buttonDisabledMap.value = { ...buttonDisabledMap.value, hasNoSelection: true }
// 当前页删空时回退一页,避免停留在空页
if (tableData.value.length <= ids.length && pagination.currentPage > 1) {
pagination.currentPage -= 1
}
fetchData()
} else {
ElMessage.error(res?.message || '批量删除失败')
}
} catch {
// 请求层已提示错误(如 409 已有登记不可删除)
} finally {
deleteLoading.value = false
}
}
onMounted(() => {
fetchData()
})
</script>
<style scoped lang="scss">
@use "../../../order/orderManagement/styles/order-sub.scss";
.toolbar-keyword {
display: flex;
align-items: center;
gap: 8px;
flex: 0 0 auto;
.keyword-input {
width: 260px;
}
}
.task-title {
font-weight: 500;
color: #303133;
}
.wave-operation-actions {
display: flex;
align-items: center;
justify-content: center;
gap: 4px;
flex-wrap: wrap;
}
.empty-tip {
color: #909399;
font-size: 13px;
padding: 16px;
}
</style>

View File

@ -0,0 +1,415 @@
<template>
<div class="return-record-wrapper" :style="{ height: containerHeight }">
<!-- 顶部多标签页区域(对齐 order/orderManagement 的 tab-section) -->
<div class="tab-section">
<el-tabs
v-model="activeTab"
tab-position="top"
type="border-card"
class="tab-container"
:before-leave="handleBeforeLeave"
@tab-click="handleTabClick"
@tab-change="handleTabChange"
>
<el-tab-pane
v-for="tab in visibleTabs"
:key="tab.name"
:name="tab.name"
:lazy="false"
>
<template #label>
<span class="custom-tab-label">{{ tab.label }}</span>
</template>
</el-tab-pane>
</el-tabs>
</div>
<!-- 主内容区容器(对齐 order/orderManagement 的 main-container) -->
<div class="main-container">
<transition name="tab-fade" mode="out-in">
<!--
tab 缓存策略由「更多设置」控制(tabCacheEnabled / tabCacheMax):
启用时用 KeepAlive 缓存各 tab 组件(超出 max 按 LRU 淘汰最久未用),
关闭时不缓存、每次切换重新挂载。
-->
<KeepAlive v-if="tabCacheEnabled" :max="tabCacheMax">
<component :is="activeComponent" v-bind="activeComponentProps" />
</KeepAlive>
<component v-else :is="activeComponent" v-bind="activeComponentProps" />
</transition>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, watch, computed, markRaw, onMounted, onUnmounted } from 'vue'
import { useRoute, useRouter, onBeforeRouteLeave } from 'vue-router'
import { ElMessageBox } from 'element-plus'
import { useSettingsStore } from '@/stores/modules/settings'
import { useExperimentalStore } from '@/stores/modules/experimental'
import ReturnUnpack from '@/views/express/returnUnpack/index.vue'
import ReturnUnpackWork from '@/views/express/returnUnpackwork/index.vue'
import ReturnReceived from '@/views/express/returnReceived/index.vue'
import ReturnWaybill from '@/views/express/returnwaybill/index.vue'
import ReturnReceivedTaskPanel from './components/ReturnReceivedTaskPanel.vue'
import ReceiveRegisterPanel from './components/ReceiveRegisterPanel.vue'
const route = useRoute()
const router = useRouter()
const settingsStore = useSettingsStore()
const experimentalStore = useExperimentalStore()
/** tab 缓存开关(实验性设置,默认开) */
const tabCacheEnabled = computed(() => experimentalStore.tabCacheEnabled)
/** tab 缓存最大数量(实验性设置,默认 2,超出 LRU 淘汰最久未用) */
const tabCacheMax = computed(() => experimentalStore.tabCacheMax)
/** 容器高度对齐 order/orderManagement(随顶部快捷栏展开状态调整) */
const containerHeight = computed(() =>
settingsStore.shortcutExpanded ? 'calc(100vh - 150px)' : 'calc(100vh - 100px)'
)
type ReturnRecordTabItem = {
name: string
label: string
component: any
}
/** 退回记录 = 退回收件任务 + 退回收件登记 + 退回拆包单 + 未退登记 + 收件 + 退回拆包作业(按 tab 合并;「收件」仅任务带入后可见,「退回拆包作业」固定最后) */
const tabs = ref<ReturnRecordTabItem[]>([
{
name: 'returnReceivedTask',
label: '退回收件任务',
component: markRaw(ReturnReceivedTaskPanel),
},
{
name: 'returnReceived',
label: '退回收件登记',
component: markRaw(ReturnReceived),
},
{
name: 'returnUnpack',
label: '退回拆包单',
component: markRaw(ReturnUnpack),
},
{
name: 'returnwaybill',
label: '未退登记',
component: markRaw(ReturnWaybill),
},
{
name: 'receive',
label: '收件',
component: markRaw(ReceiveRegisterPanel),
},
{
name: 'unpackwork',
label: '退回拆包作业',
component: markRaw(ReturnUnpackWork),
},
])
/** 默认页签(始终为 tabs 第一项) */
const defaultTabName = tabs.value[0]!.name
const activeTab = ref(defaultTabName)
/** 当前激活页签对应的组件(渲染在主内容区 main-container 中,对齐 order/orderManagement) */
const activeComponent = computed(() => {
const tab = tabs.value.find((t) => t.name === activeTab.value)
return tab?.component
})
/** 「退回收件任务」行点击跳转携带的任务ID */
const pendingTaskId = ref<number | null>(null)
/** 跳转序号:每次点击自增,保证重复点击同一任务也能重新应用筛选 */
const taskJumpSeq = ref(0)
/** 点击「退回收件任务」行 → 跳到「退回收件登记」并按该任务ID筛选 */
function handleViewTaskRegistrations(row: any) {
const id = Number(row?.id)
pendingTaskId.value = Number.isInteger(id) && id > 0 ? id : null
taskJumpSeq.value += 1
activeTab.value = 'returnReceived'
}
/** 「收件」tab:默认不可进入,只能从任务列表「登记收件」进入并锁定任务 */
const receiveEntered = ref(false)
const receiveTaskId = ref<number | null>(null)
const receiveTaskLabel = ref('')
const receiveSeq = ref(0)
/** 「退回拆包作业」是否有进行中的拆包任务(由工作台 emit 同步) */
const unpackWorkActive = ref(false)
/** 工作台「进行中任务」状态回调 */
function handleUnpackWorkActiveTaskChange(active: boolean) {
unpackWorkActive.value = active
}
/** 可见 tab:「收件」仅在被任务带入后才显示 */
const visibleTabs = computed(() =>
tabs.value.filter((t) => t.name !== 'receive' || receiveEntered.value)
)
/** 任务列表「登记收件」→ 进入「收件」tab 并锁定该任务 */
function handleRegisterReceive(row: any) {
const id = Number(row?.id)
receiveTaskId.value = Number.isInteger(id) && id > 0 ? id : null
receiveTaskLabel.value = String(row?.title || row?.batch_no || row?.id || '')
receiveSeq.value += 1
receiveEntered.value = true
activeTab.value = 'receive'
}
/** 「退回拆包单」内点击「拆包作业」→ 切到「退回拆包作业」tab */
function handleOpenUnpackWork() {
activeTab.value = 'unpackwork'
}
/** 「退回收件登记」tab 点击次数:每次点击自增,通知该 tab 组件清除筛选条件 */
const resetFilterSeq = ref(0)
/** 点击 tab:进入「退回收件登记」时清除其筛选条件(程序化切换不触发 tab-click,不影响任务跳转筛选) */
function handleTabClick(pane: any) {
if (String(pane?.paneName) === 'returnReceived') {
resetFilterSeq.value += 1
}
}
/** 当前 tab 组件的动态 props(按 tab 分派,避免给无关组件挂事件) */
const activeComponentProps = computed<Record<string, any>>(() => {
if (activeTab.value === 'returnReceived') {
return {
taskId: pendingTaskId.value,
taskJumpSeq: taskJumpSeq.value,
resetFilterSeq: resetFilterSeq.value,
}
}
if (activeTab.value === 'returnReceivedTask') {
return {
onViewRegistrations: handleViewTaskRegistrations,
onRegisterReceive: handleRegisterReceive,
}
}
if (activeTab.value === 'returnUnpack') {
return { embedded: true, onOpenUnpackWork: handleOpenUnpackWork }
}
if (activeTab.value === 'receive') {
return {
taskId: receiveTaskId.value,
taskLabel: receiveTaskLabel.value,
receiveSeq: receiveSeq.value,
}
}
if (activeTab.value === 'unpackwork') {
return { onActiveTaskChange: handleUnpackWorkActiveTaskChange }
}
return {}
})
// 切换标签(tab-change:v-model 已更新后触发):写入地址栏 ?tab=,刷新后回到该页签
const handleTabChange = (tabName: string | number) => {
const name = String(tabName)
// 离开「收件」后即移除该页签(只能从任务列表「登记收件」重新进入)
if (name !== 'receive') {
receiveEntered.value = false
}
const queryTab = route.query.tab === undefined || route.query.tab === null ? '' : String(route.query.tab)
if (queryTab === name) return
// AppMain 的 router-view key 为 route.name(非 fullPath),仅 query 变化不会触发整页重建
router.replace({ query: { ...route.query, tab: name } })
}
// ==================== 离开拦截(通过放行 / 不通过拦截) ====================
/** 通用离开确认:确认返回 true(放行),取消/关闭返回 false(拦截) */
async function confirmLeave(message: string): Promise<boolean> {
try {
await ElMessageBox.confirm(message, '离开确认', {
type: 'warning',
confirmButtonText: '离开',
cancelButtonText: '取消',
distinguishCancelAndClose: true,
})
return true
} catch {
return false
}
}
const LEAVE_RECEIVE_TIP = '离开「收件」页面后需从任务列表重新进入,确认离开?'
const LEAVE_UNPACK_WORK_TIP = '「退回拆包作业」存在进行中的拆包任务,确认离开?'
/** 离开某个页签是否需要拦截:需拦截时返回提示语,不需返回空串 */
function resolveLeaveTip(oldName: string): string {
if (oldName === 'receive' && receiveEntered.value) return LEAVE_RECEIVE_TIP
if (oldName === 'unpackwork' && unpackWorkActive.value) return LEAVE_UNPACK_WORK_TIP
return ''
}
/**
* el-tabs 切换前拦截。
* - 旧页签不需拦截 → 放行
* - receiveEntered 已为 false(已确认过)→ 放行,避免路由离开时重复弹窗
*/
async function handleBeforeLeave(activeName: string | number, oldName: string | number) {
const tip = resolveLeaveTip(String(oldName))
if (!tip) return true
return await confirmLeave(tip)
}
// 切换页面 / 关闭标签页(路由离开)时拦截;确认后同步隐藏「收件」页签
onBeforeRouteLeave(async () => {
const tip = resolveLeaveTip(activeTab.value)
if (!tip) return true
const canLeave = await confirmLeave(tip)
if (canLeave && activeTab.value === 'receive') receiveEntered.value = false
return canLeave
})
// 关闭浏览器页签 / 刷新时提示(浏览器原生提示,文案不可自定义)
function handleBeforeUnload(event: BeforeUnloadEvent) {
if (!resolveLeaveTip(activeTab.value)) return
event.preventDefault()
event.returnValue = ''
}
onMounted(() => window.addEventListener('beforeunload', handleBeforeUnload))
onUnmounted(() => window.removeEventListener('beforeunload', handleBeforeUnload))
/**
* 地址栏 ?tab= 变化(首屏 / 刷新 / 前进后退 / 本页写入)时同步本地页签。
* 非法 / 缺失 tab(含未带入任务的 receive)时归位到默认页签。
*/
watch(
() => route.query.tab,
(newTab) => {
const validTabs = visibleTabs.value.map((tab) => tab.name)
const raw = newTab === undefined || newTab === null ? '' : String(newTab).trim()
if (raw && validTabs.includes(raw)) {
activeTab.value = raw
return
}
activeTab.value = defaultTabName
},
{ immediate: true }
)
</script>
<style lang="scss" scoped>
.return-record-wrapper {
position: relative;
width: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
}
/* ===== 顶部多标签页区域(对齐 order/orderManagement 的 tab-section) ===== */
.tab-section {
flex-shrink: 0;
position: relative;
background: #fff;
border: 1px solid #e8eef7;
border-bottom: none;
border-radius: 6px 6px 0 0;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
overflow: hidden;
}
.tab-container {
display: flex;
flex-direction: column;
:deep(.el-tabs__header) {
margin-bottom: 0;
flex-shrink: 0;
}
:deep(.el-tabs__header.is-top) {
padding: 4px 12px 0 12px;
background: #f8fbff;
border-bottom: 1px solid #e8eef7;
margin: 0;
}
:deep(.el-tabs__nav-wrap::after) {
display: none;
}
:deep(.el-tabs__item.is-top) {
height: 38px;
line-height: 38px;
padding: 0 20px;
border-radius: 6px 6px 0 0;
color: #606266;
font-size: 14px;
font-weight: 500;
transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
border: 1px solid transparent;
border-bottom: none;
margin-right: 4px;
}
:deep(.el-tabs__item.is-top:hover) {
color: #409eff;
background-color: rgba(64, 158, 255, 0.05);
}
:deep(.el-tabs__item.is-top.is-active) {
color: #409eff;
font-weight: 600;
background: #ffffff;
border-color: #e8eef7;
border-bottom: 2px solid #ffffff;
margin-bottom: -1px;
position: relative;
z-index: 1;
}
:deep(.el-tabs__active-bar) {
height: 2px;
border-radius: 2px;
background-color: #409eff;
bottom: 0;
}
/* 隐藏内容区,仅展示标签头(对齐 order/orderManagement) */
:deep(.el-tabs__content) {
display: none;
}
}
.custom-tab-label {
display: inline-flex;
align-items: center;
gap: 6px;
}
/* ===== 主内容区容器(对齐 order/orderManagement 的 main-container) ===== */
.main-container {
flex: 1;
display: flex;
flex-direction: column;
min-height: 0;
background: #fff;
border: 1px solid #e8eef7;
border-top: none;
border-radius: 0 0 6px 6px;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
overflow: hidden;
}
/* ===== 页签切换淡入淡出(对齐 storage/generalreport 的 tab-fade) ===== */
.tab-fade-enter-active,
.tab-fade-leave-active {
transition: opacity 0.2s ease;
opacity: 1;
}
.tab-fade-enter-from,
.tab-fade-leave-to {
opacity: 0;
}
</style>

View File

@ -0,0 +1,80 @@
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
// ============================================================
// 退回收件任务(returnReceivedTask) - ScanBox 筛选字段
// 对齐 returnReceivedTask.list 接口 where 参数
// ============================================================
export const returnReceivedTaskAvailableFields = [
{
value: 'title',
label: '标题',
type: 'text',
placeholder: '标题模糊搜索',
operators: ['like'],
defaultOperator: 'like',
},
{
value: 'batch_no',
label: '批次号',
type: 'text',
placeholder: '批次号模糊搜索',
operators: ['like'],
defaultOperator: 'like',
},
{
value: 'creator_name',
label: '创建人',
type: 'text',
placeholder: '创建人模糊搜索',
operators: ['like'],
defaultOperator: 'like',
},
{
value: 'has_register',
label: '是否有登记',
type: 'boolean',
placeholder: '请选择是否有登记',
},
{
value: 'created_at',
label: '创建时间',
type: 'datetimerange',
},
{
value: 'updated_at',
label: '更新时间',
type: 'datetimerange',
},
]
// ============================================================
// 退回收件任务(returnReceivedTask) - UpperTable 列配置
// 对齐 returnReceivedTask.list 响应字段
// ============================================================
export const returnReceivedTaskColumns = [
{ prop: 'id', label: '任务ID', width: '90', sortable: 'custom' },
{
prop: 'batch_no',
label: '批次号',
minWidth: '180',
showOverflowTooltip: true,
sortable: 'custom',
copyAction: 'copy' as const,
},
{ prop: 'title', label: '标题', minWidth: '160', showOverflowTooltip: true },
{ prop: 'creator_name', label: '创建人', minWidth: '110', showOverflowTooltip: true },
{ prop: 'register_count', label: '登记数', width: '90' },
{ prop: 'created_at', label: '创建时间', width: '170', sortable: 'custom' },
{ prop: 'updated_at', label: '更新时间', width: '170', sortable: 'custom' },
{ prop: 'actions', label: '操作', width: '170', fixed: 'right' },
]
// ============================================================
// 工具栏按钮
// ============================================================
export const returnReceivedTaskToolbarButtons: ToolbarButtonConfig[] = [
{ key: 'refresh', label: '刷新', category: 'refresh', size: 'small', loadingKey: 'loading', action: 'loadData' },
{ key: 'create', label: '新建任务', category: 'action', type: 'primary', size: 'small', loadingKey: 'createLoading', action: 'openCreateDialog' },
{ key: 'batchDelete', label: '批量删除', category: 'cancel', size: 'small', disabledKey: 'hasNoSelection', loadingKey: 'batchDeleteLoading', action: 'handleBatchDelete' },
{ key: 'columnConfig', label: '字段设置', category: 'setting', size: 'small', action: 'openColumnConfigPanel' },
]

View File

@ -23,31 +23,6 @@
:layout-key="toolbarLayoutKey"
@action="handleToolbarButtonClick"
/>
<el-divider direction="vertical" />
<div class="scan-register">
<el-input
v-model="registerForm.waybillCode"
size="small"
class="register-input"
placeholder="退回运单号(扫码/输入)"
clearable
@keyup.enter="handleRegister"
/>
<el-input
v-model="registerForm.remark"
size="small"
class="register-remark"
placeholder="备注(可选)"
clearable
@keyup.enter="handleRegister"
/>
<el-button
type="primary"
size="small"
:loading="registerLoading"
@click="handleRegister"
>扫码登记</el-button>
</div>
</div>
</div>
@ -135,7 +110,6 @@
<span v-else>-</span>
</el-descriptions-item>
<el-descriptions-item label="扫描日期">{{ formatTime(detailData.record?.scan_date) }}</el-descriptions-item>
<el-descriptions-item label="扫描人员工号">{{ detailData.record?.scanner_id ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="扫描人员">{{ detailData.record?.scanner_name ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="仓库ID">{{ detailData.record?.warehouse_id ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="货主ID">{{ detailData.record?.store_id ?? '-' }}</el-descriptions-item>
@ -202,9 +176,9 @@
</template>
<script setup lang="ts">
import { computed, onMounted, reactive, ref } from 'vue'
import { computed, onMounted, reactive, ref, watch } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { returnReceivedList, returnReceivedCreate, returnReceivedDetail, returnReceivedDelete, returnReceivedExport, returnReceivedExportTaskProgress } from '@/api/returnreceived'
import { returnReceivedList, returnReceivedDetail, returnReceivedDelete, returnReceivedExport, returnReceivedExportTaskProgress } from '@/api/returnreceived'
import { loadStores } from '@/api/index/index'
import { extractStoreListFromResponse, fillStoreScanFieldOptions, getStatusTextClass } from '@/views/order/orderManagement/config/order-common-config'
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
@ -216,6 +190,20 @@ import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
import { safeInvoke } from '@/utils/safe-invoke'
// ==================== Props ====================
/**
* 外部传入的退回收件任务ID(来自「退回收件任务」tab 点击跳转)。
* 有效时自动把 return_received_task_id 注入 ScanBox 筛选条件并入 where。
*/
const props = defineProps<{
taskId?: number | string | null
/** 跳转序号:每次从「退回收件任务」点击自增,使重复点击同一任务也能重新应用筛选 */
taskJumpSeq?: number
/** 「退回收件登记」tab 点击次数:变化时清除筛选条件 */
resetFilterSeq?: number
}>()
// ==================== 常量 / 工具 ====================
function formatTime(val: any): string {
@ -446,6 +434,11 @@ function buildWhereFromConditions(conditions: Record<string, any>) {
case 'waybill_code':
where.waybill_code = { operator: 'like', value: String(value) }
break
case 'return_received_task_id': {
const n = Number(value)
if (!Number.isNaN(n) && n > 0) where.return_received_task_id = n
break
}
case 'scan_date':
where.scan_date = { operator: 'between', value }
break
@ -453,7 +446,6 @@ function buildWhereFromConditions(conditions: Record<string, any>) {
case 'updated_at':
where[key] = { operator: 'between', value }
break
case 'scanner_id':
case 'store_id':
case 'order_express_id':
case 'order_id': {
@ -480,7 +472,10 @@ async function fetchData() {
loading.value = true
const start = Date.now()
try {
const where = buildWhereFromConditions(currentConditions.value)
// 以 ScanBox 当前条件为准(支持外部注入任务ID后立即查询,且不受快照恢复的 emit 覆盖)
const conditions = scanBox.value?.getConditions?.() ?? currentConditions.value
currentConditions.value = conditions ?? {}
const where = buildWhereFromConditions(conditions)
const params: any = {
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
where,
@ -540,46 +535,6 @@ function handleSortChange({ prop, order }: any) {
fetchData()
}
// ==================== 扫码登记 ====================
const registerLoading = ref(false)
const registerForm = reactive({ waybillCode: '', remark: '' })
async function handleRegister() {
const code = registerForm.waybillCode.trim()
if (!code) {
ElMessage.warning('请先扫描或输入退回收件运单号')
return
}
registerLoading.value = true
try {
const res: any = await returnReceivedCreate({
waybill_code: code,
remark: registerForm.remark ? registerForm.remark.trim() : undefined,
})
if (res && (res.code === 1 || res.code === 200 || res.code === 20000)) {
const data = res.data ?? res
const urgentTip = data.is_urgent ? '(加急件)' : ''
if (data.duplicated) {
ElMessage.warning(`该运单号 30 日内已登记(记录ID ${data.record?.id ?? data.id}),已返回第一次登记结果${urgentTip}`)
} else if (data.is_original_return) {
ElMessage.success(`登记成功:命中原单退回,原运单ID ${data.record?.order_express_id ?? data.order_express_id}${urgentTip}`)
} else {
ElMessage.success(`登记成功${urgentTip}`)
}
registerForm.waybillCode = ''
registerForm.remark = ''
fetchData()
} else {
ElMessage.error(res?.message || '登记失败')
}
} catch {
// 请求层已提示错误
} finally {
registerLoading.value = false
}
}
// ==================== 详情 ====================
const detailVisible = ref(false)
@ -640,32 +595,78 @@ async function loadStoreOptions() {
}
}
// ==================== 外部任务筛选(「退回收件任务」tab 点击跳转) ====================
function normalizeTaskId(raw: unknown): number | null {
if (raw === undefined || raw === null || raw === '') return null
const n = Number(raw)
return Number.isInteger(n) && n > 0 ? n : null
}
/** 把外部传入的任务ID写入 ScanBox 筛选条件(退回收件任务ID = 等值)并立即查询 */
function applyExternalTaskFilter() {
const taskId = normalizeTaskId(props.taskId)
// setFieldCondition 仅更新内部条件与草稿快照、不触发 emit,需自行回到第一页并查询
scanBox.value?.setFieldCondition?.(
'return_received_task_id',
{ operator: 'eq', value: taskId ?? '' },
{ autoSubmit: false }
)
pagination.currentPage = 1
upperPagination.currentPage = 1
fetchData()
}
/**
* 清除筛选条件并重新查询。
* 注意:ScanBox 对外暴露的 reset() 只重置字段、不 emit(避免与 @reset 递归),
* clear() 会清筛选快照并 emit condition-clear → 触发 handleConditionClear 重新查询。
* 两者配合才完成「清空字段 + 清快照 + 刷新列表」。
*/
function clearFiltersAndReload() {
scanBox.value?.reset?.()
scanBox.value?.clear?.()
}
onMounted(() => {
loadStoreOptions()
fetchData()
if ((props.resetFilterSeq ?? 0) > 0) {
// 点击「退回收件登记」tab 进入:清除筛选条件并刷新
clearFiltersAndReload()
} else if (normalizeTaskId(props.taskId)) {
// 带任务ID进入时,先注入筛选条件再查询
applyExternalTaskFilter()
} else {
fetchData()
}
// 恢复被中断的退回收到导出任务(存在未完成任务时自动弹进度弹窗继续轮询)
resumeExportTaskFromStorage()
})
// 从「退回收件任务」tab 点击跳转时,重新应用筛选条件(含重复点击同一任务)
watch(
() => props.taskJumpSeq,
(val, oldVal) => {
if (val === oldVal) return
if (!scanBox.value) return
applyExternalTaskFilter()
}
)
// 点击「退回收件登记」tab 时清除筛选条件并刷新
watch(
() => props.resetFilterSeq,
(val, oldVal) => {
if (val === oldVal) return
if (!scanBox.value) return
clearFiltersAndReload()
}
)
</script>
<style scoped lang="scss">
@use "../../order/orderManagement/styles/order-sub.scss";
.scan-register {
display: flex;
align-items: center;
gap: 8px;
flex: 0 0 auto;
.register-input {
width: 220px;
}
.register-remark {
width: 160px;
}
}
.wave-operation-actions {
display: flex;
align-items: center;

View File

@ -13,19 +13,19 @@ export const returnReceivedAvailableFields = [
operators: ['like'],
defaultOperator: 'like',
},
{
value: 'return_received_task_id',
label: '退回收件任务ID',
type: 'number',
placeholder: '退回收件任务ID(等值)',
operators: ['eq'],
defaultOperator: 'eq',
},
{
value: 'scan_date',
label: '扫描时间',
type: 'datetimerange',
},
{
value: 'scanner_id',
label: '扫描人员工号',
type: 'number',
placeholder: '工号ID等值匹配',
operators: ['eq'],
defaultOperator: 'eq',
},
{
value: 'scanner_name',
label: '扫描人员名称',
@ -83,7 +83,6 @@ export const returnReceivedColumns = [
// { prop: 'id', label: '登记ID', width: '90', sortable: 'custom' },
{ prop: 'waybill_code', label: '退回收件运单号', minWidth: '180', showOverflowTooltip: true, sortable: 'custom', copyAction: 'copy' as const },
{ prop: 'scan_date', label: '扫描日期', width: '170', sortable: 'custom' },
{ prop: 'scanner_id', label: '扫描人员工号', width: '110' },
{ prop: 'scanner_name', label: '扫描人员', minWidth: '100', showOverflowTooltip: true },
// { prop: 'warehouse_id', label: '仓库ID', width: '100' },
// { prop: 'store_id', label: '货主ID', width: '100' },

View File

@ -23,7 +23,11 @@
:layout-key="toolbarLayoutKey"
@action="handleToolbarButtonClick"
/>
<!-- <el-divider direction="vertical" /> -->
<!-- 内嵌到「退回记录」时,提供进入「退回拆包作业」的入口 -->
<template v-if="embedded">
<el-divider direction="vertical" />
<el-button type="primary" size="small" @click="emit('open-unpack-work')">拆包作业</el-button>
</template>
</div>
</div>
@ -368,6 +372,13 @@ import VideoPlayerDialog from './components/VideoPlayerDialog.vue'
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
// ==================== Props / Emits ====================
/** 是否作为「退回记录」内嵌 tab 使用(显示「拆包作业」入口) */
defineProps<{ embedded?: boolean }>()
const emit = defineEmits<{ (e: 'open-unpack-work'): void }>()
// ==================== 常量 / 工具 ====================
function formatTime(val: any): string {

View File

@ -650,7 +650,7 @@
</template>
<script setup lang="ts">
import { computed, nextTick, onMounted, onUnmounted, reactive, ref, watch } from 'vue'
import { computed, nextTick, onActivated, onDeactivated, onMounted, onUnmounted, reactive, ref, watch } from 'vue'
import { ElMessage } from 'element-plus'
import {
returnUnpackCreate,
@ -674,6 +674,11 @@ import { orderDetail, orderList } from '@/api/order.index/orderindex'
import { parseOrderDetailPayload, normalizeOrderDetailItems } from '@/views/order/orderManagement/utils/order-index-helpers'
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
// ==================== Emits ====================
/** 进行中任务状态变化(供内嵌外壳做离开拦截) */
const emit = defineEmits<{ (e: 'active-task-change', active: boolean): void }>()
type CameraRow = CameraLiveItem & { id: number }
const waybillInputRef = ref<any>(null)
@ -2122,11 +2127,28 @@ function handleKeydown(e: KeyboardEvent) {
}
}
// 是否有进行中的拆包任务(已创建且未提交/取消)→ 通知内嵌外壳做离开拦截
watch(
() => !!createResult.value?.id,
(active) => {
emit('active-task-change', active)
},
{ immediate: true }
)
/** 全局扫码键盘监听:挂载/激活时注册,卸载/失活时摘除(内嵌为 tab 切走后不再后台响应扫码) */
function startKeydownListener() {
window.addEventListener('keydown', handleKeydown)
}
function stopKeydownListener() {
window.removeEventListener('keydown', handleKeydown)
}
onMounted(async () => {
loadUnpackList()
await loadCameraList()
restoreCameraSelection()
window.addEventListener('keydown', handleKeydown)
startKeydownListener()
nextTick(() => {
renderBarcodes()
focusTarget.value = 'waybill'
@ -2134,8 +2156,12 @@ onMounted(async () => {
})
})
// keep-alive(含内嵌 tab)激活/失活时同步监听
onActivated(startKeydownListener)
onDeactivated(stopKeydownListener)
onUnmounted(() => {
window.removeEventListener('keydown', handleKeydown)
stopKeydownListener()
})
async function submitDetailForm() {

View File

@ -70,7 +70,7 @@
<div class="upper-wrapper">
<upper-table
ref="upperTable"
title="运单退回登记列表"
title="未退登记列表"
default-align="center"
table-id="express-returnwaybill-list"
:data="tableData"
@ -124,7 +124,7 @@
</template>
<template #empty>
<div class="empty-tip">暂无运单退回登记数据</div>
<div class="empty-tip">暂无未退登记数据</div>
</template>
</upper-table>
</div>
@ -132,7 +132,7 @@
</div>
<!-- ========== 详情弹窗 ========== -->
<el-dialog v-model="detailVisible" title="运单退回登记详情" width="720px" destroy-on-close align-center>
<el-dialog v-model="detailVisible" title="未退登记详情" width="720px" destroy-on-close align-center>
<div v-loading="detailLoading" class="detail-content">
<el-descriptions v-if="detailRecord" title="登记信息" :column="2" border size="small">
<el-descriptions-item label="登记ID">{{ detailRecord.id ?? '-' }}</el-descriptions-item>
@ -173,7 +173,7 @@
</el-dialog>
<!-- ========== 编辑弹窗 ========== -->
<el-dialog v-model="editVisible" title="编辑运单退回登记" width="480px" destroy-on-close align-center>
<el-dialog v-model="editVisible" title="编辑未退登记" width="480px" destroy-on-close align-center>
<el-form :model="editForm" label-width="80px" size="small">
<el-form-item label="运单号">
<el-input v-model="editForm.waybillCode" placeholder="运单号" clearable />
@ -421,10 +421,10 @@ async function fetchData() {
tableData.value = []
pagination.total = 0
upperPagination.total = 0
ElMessage.error(res?.message || '获取运单退回登记列表失败')
ElMessage.error(res?.message || '获取未退登记列表失败')
}
} catch (error) {
console.error('获取运单退回登记列表失败:', error)
console.error('获取未退登记列表失败:', error)
tableData.value = []
pagination.total = 0
upperPagination.total = 0