This commit is contained in:
yin 2026-08-13 18:16:38 +08:00
parent 40ea445e4f
commit b92745c8ec
24 changed files with 1518 additions and 24 deletions

View File

@ -0,0 +1,338 @@
import request from '@/utils/request'
const v = '1.0'
// ============ returnUnpack.create ============
/** returnUnpack.create 请求参数 */
export type ReturnUnpackCreateParams = {
/** 拆包的运单号(退回包裹运单号,必填,用于反查原单/货主信息) */
waybill_code: string
/** 摄像头ID列表,如 [1,2,3],关联 wms_camera.id(非正整数会被过滤) */
camera_ids?: number[]
/** 关联退回收到单ID(wms_return_received.id),非必填,允许独立拆包 */
return_received_id?: number
/** 备注(最长 500 字符,超出截断) */
remark?: string
}
/** returnUnpack.create:开拆包单(明细不在此提交,由 returnUnpack.addDetail 逐件录入) */
export function returnUnpackCreate(data: ReturnUnpackCreateParams): Promise<any> {
return request({
url: '/system',
method: 'post',
params: {
method: 'returnUnpack.create',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
// ============ returnUnpack.addDetail ============
/** returnUnpack.addDetail 请求参数 */
export type ReturnUnpackAddDetailParams = {
/** 拆包单ID(returnUnpack.create 返回的依据) */
id: number
/** 系统商品ID(wms_stock_warehouse.id),为空即无关联货物 */
stock_id?: number
/** 数量,默认 1(小于 1 按 1 处理) */
quantity?: number
/** 产品状态:normal 正常(默认)/ damaged 破损 */
product_status?: 'normal' | 'damaged'
/** 备注(最长 500 字符,超出截断) */
remark?: string
}
/** returnUnpack.addDetail:以拆包单ID为依据录入一条明细 */
export function returnUnpackAddDetail(data: ReturnUnpackAddDetailParams): Promise<any> {
return request({
url: '/system',
method: 'post',
params: {
method: 'returnUnpack.addDetail',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
// ============ returnUnpack.updateDetail ============
/** returnUnpack.updateDetail 请求参数 */
export type ReturnUnpackUpdateDetailParams = {
/** 拆包单ID */
id: number
/** 明细ID(returnUnpack.addDetail 返回) */
detail_id: number
/** 数量(小于 1 按 1 处理,变更时才触发主表重算) */
quantity?: number
/** 备注(最长 500 字符,超出截断) */
remark?: string
}
/** returnUnpack.updateDetail:更新明细(仅允许更新 quantity/remark) */
export function returnUnpackUpdateDetail(data: ReturnUnpackUpdateDetailParams): Promise<any> {
return request({
url: '/system',
method: 'post',
params: {
method: 'returnUnpack.updateDetail',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
// ============ returnUnpack.removeDetail ============
/** returnUnpack.removeDetail 请求参数 */
export type ReturnUnpackRemoveDetailParams = {
/** 拆包单ID */
id: number
/** 明细ID(returnUnpack.addDetail 返回) */
detail_id: number
}
/** returnUnpack.removeDetail:删除拆包单下的一条明细(硬删除) */
export function returnUnpackRemoveDetail(data: ReturnUnpackRemoveDetailParams): Promise<any> {
return request({
url: '/system',
method: 'post',
params: {
method: 'returnUnpack.removeDetail',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
// ============ returnUnpack.cancel ============
/** returnUnpack.cancel 请求参数 */
export type ReturnUnpackCancelParams = {
/** 拆包单ID */
id: number
}
/** returnUnpack.cancel:取消拆包单(仅供未完成状态作业取消) */
export function returnUnpackCancel(data: ReturnUnpackCancelParams): Promise<any> {
return request({
url: '/system',
method: 'post',
params: {
method: 'returnUnpack.cancel',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
// ============ returnUnpack.submit ============
/** returnUnpack.submit 请求参数 */
export type ReturnUnpackSubmitParams = {
/** 拆包单ID */
id: number
}
/** returnUnpack.submit:提交确认(转 completed 终态并回写 end_time) */
export function returnUnpackSubmit(data: ReturnUnpackSubmitParams): Promise<any> {
return request({
url: '/system',
method: 'post',
params: {
method: 'returnUnpack.submit',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
// ============ returnUnpack.list ============
/** returnUnpack.list 的 where 筛选条件 */
export type ReturnUnpackListWhere = {
/** 拆包单号(模糊搜索,传 {operator:'like',value} 或直接值) */
unpack_no?: string | { operator: string; value: any }
/** 运单号(模糊搜索,传 {operator:'like',value} 或直接值) */
waybill_code?: string | { operator: string; value: any }
/** 拆包日期范围 { operator:'between'|'gte'|'lte'|'gt'|'lt', value:[start,end] 或单值 } */
unpack_date?: { operator: 'between' | 'gte' | 'lte' | 'gt' | 'lt'; value: [string, string] | string }
/** 拆包开始时间范围 */
start_time?: { operator: 'between' | 'gte' | 'lte' | 'gt' | 'lt'; value: [string, string] | string }
/** 拆包结束时间范围 */
end_time?: { operator: 'between' | 'gte' | 'lte' | 'gt' | 'lt'; value: [string, string] | string }
/** 拆包状态(等值):unpacking 拆包中 / completed 完成 / cancelled 作废 */
status?: 'unpacking' | 'completed' | 'cancelled'
/** 明细识别状态(等值):none_recognized / partial_recognized / all_recognized */
detail_status?: 'none_recognized' | 'partial_recognized' | 'all_recognized'
/** 拆包人员工号ID(等值) */
unpacker_id?: number
/** 关联退回收到单ID(等值) */
return_received_id?: number
/** 货主ID(等值) */
store_id?: number
/** 原运单ID(等值) */
order_express_id?: number
/** 原订单ID(等值) */
order_id?: number
}
/** returnUnpack.list 排序参数 */
export type ReturnUnpackListSort = {
/** 排序字段 */
sortField?:
| 'id'
| 'created_at'
| 'updated_at'
| 'unpack_date'
| 'start_time'
| 'end_time'
| 'unpack_no'
| 'waybill_code'
/** 排序方向:asc / desc */
sortOrder?: 'asc' | 'desc'
}
/** returnUnpack.list 请求参数 */
export type ReturnUnpackListParams = {
pagination?: { page?: number; pageSize?: number }
where?: ReturnUnpackListWhere
sort?: ReturnUnpackListSort
}
/** returnUnpack.list:拆包单分页列表(仓库隔离,服务端注入 warehouse_id) */
export function returnUnpackList(data: ReturnUnpackListParams = {}): Promise<any> {
return request({
url: '/system',
method: 'post',
params: {
method: 'returnUnpack.list',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
// ============ returnUnpack.detailList ============
/** returnUnpack.detailList 的 where 筛选条件 */
export type ReturnUnpackDetailListWhere = {
/** 拆包单ID(等值) */
unpack_id?: number
/** 系统商品ID(wms_stock_warehouse.id,等值) */
stock_id?: number
/** 扫描条码(模糊搜索,传 {operator:'like',value} 或直接值) */
barcode?: string | { operator: string; value: any }
/** 是否识别(等值):1 识别到系统商品 / 0 非识别物品 */
is_recognized?: 0 | 1
/** 产品状态(等值):normal 正常 / damaged 破损 */
product_status?: 'normal' | 'damaged'
}
/** returnUnpack.detailList 排序参数 */
export type ReturnUnpackDetailListSort = {
/** 排序字段 */
sortField?: 'id' | 'created_at' | 'updated_at' | 'quantity'
/** 排序方向:asc / desc */
sortOrder?: 'asc' | 'desc'
}
/** returnUnpack.detailList 请求参数 */
export type ReturnUnpackDetailListParams = {
pagination?: { page?: number; pageSize?: number }
where?: ReturnUnpackDetailListWhere
sort?: ReturnUnpackDetailListSort
}
/** returnUnpack.detailList:拆包明细分页列表(命中识别商品时含 stockWarehouse 关联) */
export function returnUnpackDetailList(data: ReturnUnpackDetailListParams = {}): Promise<any> {
return request({
url: '/system',
method: 'post',
params: {
method: 'returnUnpack.detailList',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
// ============ returnUnpack.detail ============
/** returnUnpack.detail 请求参数 */
export type ReturnUnpackDetailParams = {
/** 拆包单ID */
id: number
}
/** returnUnpack.detail:拆包单详情(主表 + 明细 + 视频副表 + 退回收到单) */
export function returnUnpackDetail(data: ReturnUnpackDetailParams): Promise<any> {
return request({
url: '/system',
method: 'post',
params: {
method: 'returnUnpack.detail',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
// ============ returnUnpack.delete ============
/** returnUnpack.delete 请求参数 */
export type ReturnUnpackDeleteParams = {
/** 拆包单ID */
id: number
}
/** returnUnpack.delete:删除拆包单(后台管理,不限制状态) */
export function returnUnpackDelete(data: ReturnUnpackDeleteParams): Promise<any> {
return request({
url: '/system',
method: 'post',
params: {
method: 'returnUnpack.delete',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
// ============ 模块导出 ============
export const returnUnpackModule = {
create: returnUnpackCreate,
addDetail: returnUnpackAddDetail,
updateDetail: returnUnpackUpdateDetail,
removeDetail: returnUnpackRemoveDetail,
cancel: returnUnpackCancel,
submit: returnUnpackSubmit,
list: returnUnpackList,
detailList: returnUnpackDetailList,
detail: returnUnpackDetail,
delete: returnUnpackDelete
}

View File

@ -70,13 +70,23 @@ export function shopsEdit(data: {
})
}
/** 按店铺所属平台生成授权会话 */
/** shops.GetAuthorizeSessionKey 响应 */
export interface ShopAuthorizeSessionKeyResponse {
flag: string
code: number
message: string
data: {
message: string
}
}
/** 按店铺所属平台生成授权会话(callbackurl 必填;视频号平台另传 appId/toUserName) */
export function shopGetAuthorizeSessionKey(data: {
id: number
callbackurl?: string
callbackurl: string
appId?: string
toUserName?: string
}) {
}): Promise<ShopAuthorizeSessionKeyResponse> {
return request({
url: '/system',
method: 'post',

View File

@ -68,6 +68,7 @@
:class="{ 'field-control--multi': isMultiValueTextOperator(customConditions[field.value].operator) }"
>
<el-select
v-if="!field.hideOperator"
v-model="customConditions[field.value].operator"
placeholder="条件类型"
size="small"

View File

@ -77,6 +77,8 @@ export default {
'waybill':'waybill',
'inbox_messages':'messages',
'inbox_groups':'groups',
'returnReceived':'Return Received',
'returnUnpack':'Return Unpack',
},
"login": {
"title": "Login",

View File

@ -80,6 +80,8 @@ export default {
'waybill':'运单',
'inbox_messages':'消息',
'inbox_groups':'群组',
'returnReceived':'退回收件',
'returnUnpack':'退回拆包',
},
"login": {
"title": "登录",

View File

@ -101,7 +101,7 @@ import LangSelect from '@/components/LangSelect/index.vue'
import TopMenu from './TopMenu.vue'
import dayjs from 'dayjs'
import { useFullscreen } from '@vueuse/core'
import { afterSaleWorkCount, afterSaleWorkList } from '@/api/afterSale/index'
import { afterSaleWorkCount, afterSaleWorkList } from '@/api/aftersale/index'
const { isFullscreen, toggle } = useFullscreen()

View File

@ -74,4 +74,5 @@ export const componentMap: Record<string, any> = {
'system/setting/storeExpressBindingPolicy/index':() => import('@/views/system/setting/storeExpressBindingPolicy/index.vue'),
'inbox/message/index': () => import('@/views/inbox/message/index.vue'),
'inbox/group/index': () => import('@/views/inbox/group/index.vue'),
'express/returnUnpack/index': () => import('@/views/express/returnUnpack/index.vue'),
};

View File

@ -254,7 +254,7 @@ import {
type AfterSale,
type AfterSaleStep,
type AfterSaleRelated,
} from '@/api/afterSale/index'
} from '@/api/aftersale/index'
import { orderQueryOrderLogList, type OrderLogListItem } from '@/api/order.index/orderindex'
import { getCOSUploadConfig, uploadSuccessNotify } from '@/api/index/index'
import {

View File

@ -35,7 +35,7 @@
<script setup lang="ts">
import { ref, reactive } from 'vue'
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
import { afterSaleRegisterClaim } from '@/api/afterSale/index'
import { afterSaleRegisterClaim } from '@/api/aftersale/index'
import { CLAIM_STATUS_MAP } from '@/views/afterSale/list/afterSale-config'
const props = defineProps<{ afterSaleId: number; claimNeeded?: 0|1; claimAmount?: number|null; claimStatus?: string|null; carrierClaimNeeded?: 0|1; carrierClaimAmount?: number|null; carrierClaimStatus?: string|null }>()

View File

@ -39,7 +39,7 @@
import { ref, reactive } from 'vue'
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
import { Plus } from '@element-plus/icons-vue'
import { afterSaleHandleWorkOrder } from '@/api/afterSale/index'
import { afterSaleHandleWorkOrder } from '@/api/aftersale/index'
import { getCOSUploadConfig, uploadSuccessNotify } from '@/api/index/index'
const props = defineProps<{ afterSaleId: number; currentStatus?: string }>()

View File

@ -20,7 +20,7 @@
<script setup lang="ts">
import { ref, reactive } from 'vue'
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
import { afterSaleTransfer } from '@/api/afterSale/index'
import { afterSaleTransfer } from '@/api/aftersale/index'
const props = defineProps<{ afterSaleId: number }>()
const emit = defineEmits<{ success: [] }>()

View File

@ -353,7 +353,7 @@ import {
type AfterSaleHandleWorkOrderParams,
type AfterSaleTransferParams,
type AfterSaleRegisterClaimParams,
} from '@/api/afterSale/index'
} from '@/api/aftersale/index'
import { getCOSUploadConfig, uploadSuccessNotify } from '@/api/index/index'
import {
AFTER_SALE_TYPE_MAP,

View File

@ -267,6 +267,24 @@ export const afterSaleAvailableFields = [
{ label: '财务组', value: 'finance' },
],
},
{
value: 'claim_status',
label: '索赔状态',
type: 'select',
placeholder: '请选择索赔状态',
operators: ['eq'],
defaultOperator: 'eq',
options: Object.entries(CLAIM_STATUS_MAP).map(([k, v]) => ({ label: v, value: k })),
},
{
value: 'carrier_claim_status',
label: '承运人索赔状态',
type: 'select',
placeholder: '请选择承运人索赔状态',
operators: ['eq'],
defaultOperator: 'eq',
options: Object.entries(CLAIM_STATUS_MAP).map(([k, v]) => ({ label: v, value: k })),
},
{
value: 'waybill_no',
label: '运单号',

View File

@ -233,7 +233,7 @@ import {
type AfterSaleCreateParams,
type AfterSaleUpdateParams,
type AfterSaleTransferParams,
} from '@/api/afterSale/index'
} from '@/api/aftersale/index'
import {
getAfterSaleAvailableFields,
afterSaleAvailableFields,

View File

@ -89,6 +89,11 @@
<span v-else>-</span>
</template>
<template #column-store_id="{ row }">
<span v-if="row.store_id != null">{{ row.store_id }}</span>
<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>
@ -111,7 +116,16 @@
<!-- 登记记录 -->
<el-descriptions title="登记信息" :column="3" border size="small" class="detail-section">
<el-descriptions-item label="登记ID">{{ detailData.record?.id ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="退回运单号">{{ detailData.record?.waybill_code ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="退回运单号">
<span
v-if="detailData.record?.waybill_code"
class="waybill-copyable"
role="button"
title="点击复制"
@click="copyWaybillCode(detailData.record.waybill_code)"
>{{ detailData.record.waybill_code }}</span>
<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>
@ -160,7 +174,7 @@
<script setup lang="ts">
import { computed, onMounted, reactive, ref } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { returnReceivedList, returnReceivedCreate, returnReceivedDetail, returnReceivedDelete } from '@/api/returnReceived'
import { returnReceivedList, returnReceivedCreate, returnReceivedDetail, returnReceivedDelete } from '@/api/returnreceived'
import { loadStores } from '@/api/index/index'
import { extractStoreListFromResponse, fillStoreScanFieldOptions } from '@/views/order/orderManagement/config/order-common-config'
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
@ -185,6 +199,36 @@ function formatFlag(val: any): string {
return val == null || val === '' ? '-' : String(val)
}
async function copyWaybillCode(text: string) {
if (!text) {
ElMessage.warning('当前无退回收件运单号可复制')
return
}
try {
if (navigator.clipboard?.writeText) {
await navigator.clipboard.writeText(text)
} else {
throw new Error('no clipboard api')
}
ElMessage.success('退回收件运单号已复制到剪贴板')
} catch {
try {
const textarea = document.createElement('textarea')
textarea.value = text
textarea.setAttribute('readonly', 'readonly')
textarea.style.position = 'fixed'
textarea.style.left = '-9999px'
document.body.appendChild(textarea)
textarea.select()
document.execCommand('copy')
document.body.removeChild(textarea)
ElMessage.success('退回收件运单号已复制到剪贴板')
} catch {
ElMessage.error('复制失败,请手动复制')
}
}
}
// ==================== 配置 ====================
const availableFields = returnReceivedAvailableFields
@ -512,6 +556,16 @@ onMounted(() => {
}
}
.waybill-copyable {
cursor: pointer;
color: #409eff;
user-select: none;
&:hover {
text-decoration: underline;
}
}
.empty-tip {
color: #909399;
font-size: 13px;

View File

@ -46,15 +46,20 @@ export const returnReceivedAvailableFields = [
// 对齐 returnReceived.list 实际响应字段
// ============================================================
export const returnReceivedColumns = [
{ prop: 'waybill_code', label: '退回收件运单号', minWidth: '180', showOverflowTooltip: true, sortable: 'custom' },
{ 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' },
{ prop: 'is_original_return', label: '是否原单退回', width: '110' },
{ prop: 'store_remark', label: '货主备注', minWidth: '140', showOverflowTooltip: true },
{ prop: 'order_express_id', label: '原运单ID', width: '100' },
{ prop: 'order_id', label: '原订单ID', width: '100' },
{ prop: 'store_remark', label: '货主备注', minWidth: '140', showOverflowTooltip: true },
{ prop: 'remark', label: '备注', minWidth: '120', showOverflowTooltip: true },
{ prop: 'created_at', label: '登记时间', width: '170', sortable: 'custom' },
{ prop: 'updated_at', label: '更新时间', width: '170', sortable: 'custom' },
{ prop: 'actions', label: '操作', width: '140', fixed: 'right' },
]

View File

@ -0,0 +1,909 @@
<template>
<div class="order-sub-container">
<scan-box
ref="scanBox"
cache-key="express:returnUnpack"
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="scan-create">
<el-input
v-model="createForm.waybillCode"
size="small"
class="create-input"
placeholder="退回运单号(扫码/输入)"
clearable
@keyup.enter="handleCreate"
/>
<el-input
v-model="createForm.remark"
size="small"
class="create-remark"
placeholder="备注(可选)"
clearable
@keyup.enter="handleCreate"
/>
<el-button
type="primary"
size="small"
:loading="createLoading"
@click="handleCreate"
>开拆包单</el-button>
</div>
</div>
</div>
<div class="split-stack">
<div class="upper-wrapper">
<upper-table
ref="upperTable"
title="退回拆包单列表"
default-align="center"
table-id="express-returnUnpack-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"
@sort-change="handleSortChange"
>
<template #column-status="{ row }">
<el-tag :type="statusTagType(row.status)" size="small">
{{ statusLabel(row.status) }}
</el-tag>
</template>
<template #column-detail_status="{ row }">
<el-tag :type="detailStatusTagType(row.detail_status)" size="small">
{{ detailStatusLabel(row.detail_status) }}
</el-tag>
</template>
<template #column-is_original_return="{ row }">
<el-tag :type="row.is_original_return ? 'success' : 'info'" size="small">
{{ row.is_original_return ? '是' : '否' }}
</el-tag>
</template>
<template #column-store_id="{ row }">
<span v-if="row.store_id != null">{{ row.store_id }}</span>
<span v-else>-</span>
</template>
<template #column-actions="{ row }">
<div class="operation-actions">
<el-button size="small" type="primary" link @click.stop="handleViewDetail(row)">详情</el-button>
<el-button
v-if="row.status === 'unpacking'"
size="small"
type="success"
link
@click.stop="handleSubmit(row)"
>提交</el-button>
<el-button
v-if="row.status === 'unpacking'"
size="small"
type="warning"
link
@click.stop="handleCancel(row)"
>取消</el-button>
<el-button size="small" type="danger" link @click.stop="handleDelete(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="1080px" destroy-on-close align-center>
<div v-loading="detailLoading" class="detail-content">
<template v-if="detailRecord">
<!-- 主表信息 -->
<el-descriptions title="拆包单信息" :column="3" border size="small" class="detail-section">
<el-descriptions-item label="拆包单ID">{{ detailRecord.id ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="拆包单号">
<span
v-if="detailRecord.unpack_no"
class="copyable"
role="button"
title="点击复制"
@click="copyText(detailRecord.unpack_no)"
>{{ detailRecord.unpack_no }}</span>
<span v-else>-</span>
</el-descriptions-item>
<el-descriptions-item label="退回运单号">
<span
v-if="detailRecord.waybill_code"
class="copyable"
role="button"
title="点击复制"
@click="copyText(detailRecord.waybill_code)"
>{{ detailRecord.waybill_code }}</span>
<span v-else>-</span>
</el-descriptions-item>
<el-descriptions-item label="拆包状态">
<el-tag :type="statusTagType(detailRecord.status)" size="small">{{ statusLabel(detailRecord.status) }}</el-tag>
</el-descriptions-item>
<el-descriptions-item label="明细识别状态">
<el-tag :type="detailStatusTagType(detailRecord.detail_status)" size="small">{{ detailStatusLabel(detailRecord.detail_status) }}</el-tag>
</el-descriptions-item>
<el-descriptions-item label="是否原单退回">
<el-tag :type="detailRecord.is_original_return ? 'success' : 'info'" size="small">
{{ detailRecord.is_original_return ? '是' : '否' }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="物品种类">{{ detailRecord.total_items ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="总数量">{{ detailRecord.total_quantity ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="拆包人员">{{ detailRecord.unpacker_name ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="拆包日期">{{ formatTime(detailRecord.unpack_date) }}</el-descriptions-item>
<el-descriptions-item label="拆包开始时间">{{ formatTime(detailRecord.start_time) }}</el-descriptions-item>
<el-descriptions-item label="拆包结束时间">{{ formatTime(detailRecord.end_time) }}</el-descriptions-item>
<el-descriptions-item label="货主ID">{{ detailRecord.store_id ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="原运单ID">{{ detailRecord.order_express_id ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="原订单ID">{{ detailRecord.order_id ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="货主备注" :span="3">{{ detailRecord.store_remark || '-' }}</el-descriptions-item>
<el-descriptions-item label="备注" :span="3">{{ detailRecord.remark || '-' }}</el-descriptions-item>
</el-descriptions>
<!-- 原订单信息 -->
<el-descriptions v-if="detailOrder" title="原订单信息" :column="3" border size="small" class="detail-section">
<el-descriptions-item label="订单ID">{{ detailOrder.id ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="订单号">{{ detailOrder.order_no ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="货主ID">{{ detailOrder.store_id ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="收件人">{{ detailOrder.receiver_name ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="联系电话">{{ detailOrder.receiver_tel ?? detailOrder.receiver_mobile ?? '-' }}</el-descriptions-item>
<el-descriptions-item label="商品件数">{{ detailOrder.items?.length ?? '-' }}</el-descriptions-item>
</el-descriptions>
<!-- 明细表格 -->
<div class="detail-list-header">
<span class="detail-list-title">拆包明细({{ detailList.length }})</span>
<el-button
v-if="detailRecord.status === 'unpacking'"
type="primary"
size="small"
@click="openAddDetail"
>录明细</el-button>
</div>
<el-table :data="detailList" size="small" border class="detail-table" empty-text="暂无明细">
<el-table-column prop="id" label="明细ID" width="80" />
<el-table-column prop="barcode" label="条码" min-width="140" show-overflow-tooltip />
<el-table-column prop="stock_id" label="商品ID" width="90">
<template #default="{ row }">{{ row.stock_id ?? '-' }}</template>
</el-table-column>
<el-table-column prop="item_code" label="商品编码" min-width="120" show-overflow-tooltip />
<el-table-column prop="item_name" label="商品名称" min-width="140" show-overflow-tooltip />
<el-table-column prop="spec" label="规格" min-width="120" show-overflow-tooltip />
<el-table-column prop="is_recognized" label="是否识别" width="90">
<template #default="{ row }">
<el-tag :type="row.is_recognized ? 'success' : 'info'" size="small">
{{ row.is_recognized ? '已识别' : '未识别' }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="product_status" label="产品状态" width="100">
<template #default="{ row }">
<el-tag :type="row.product_status === 'damaged' ? 'danger' : 'success'" size="small">
{{ row.product_status === 'damaged' ? '破损' : '正常' }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="quantity" label="数量" width="80" />
<el-table-column prop="remark" label="备注" min-width="120" show-overflow-tooltip />
<el-table-column v-if="detailRecord.status === 'unpacking'" label="操作" width="130" fixed="right">
<template #default="{ row }">
<el-button size="small" type="primary" link @click="openEditDetail(row)">编辑</el-button>
<el-button size="small" type="danger" link @click="handleRemoveDetail(row)">移除</el-button>
</template>
</el-table-column>
</el-table>
</template>
</div>
<template #footer>
<template v-if="detailRecord?.status === 'unpacking'">
<el-button type="success" :loading="submitLoading" @click="handleSubmit(detailRecord)">提交确认</el-button>
<el-button type="warning" :loading="cancelLoading" @click="handleCancel(detailRecord)">取消拆包</el-button>
</template>
<el-button type="danger" :loading="deleteLoading" @click="handleDelete(detailRecord)">删除</el-button>
<el-button @click="detailVisible = false">关闭</el-button>
</template>
</el-dialog>
<!-- ========== 录明细 / 编辑明细弹窗 ========== -->
<el-dialog
v-model="detailFormVisible"
:title="detailForm.isEdit ? '编辑明细' : '录明细'"
width="480px"
destroy-on-close
align-center
>
<el-form :model="detailForm" label-width="90px" size="small">
<el-form-item label="商品ID">
<el-input
v-model="detailForm.stockId"
placeholder="系统商品ID,留空表示无关联货物"
clearable
/>
</el-form-item>
<el-form-item label="数量">
<el-input-number v-model="detailForm.quantity" :min="1" :max="999999" class="full-width" />
</el-form-item>
<el-form-item label="产品状态">
<el-select v-model="detailForm.productStatus" placeholder="请选择产品状态" class="full-width">
<el-option label="正常" value="normal" />
<el-option label="破损" value="damaged" />
</el-select>
</el-form-item>
<el-form-item label="备注">
<el-input v-model="detailForm.remark" type="textarea" :rows="2" maxlength="500" show-word-limit placeholder="备注(可选)" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="detailFormVisible = false">取消</el-button>
<el-button type="primary" :loading="detailFormLoading" @click="submitDetailForm">确定</el-button>
</template>
</el-dialog>
</div>
</template>
<script setup lang="ts">
import { onMounted, reactive, ref } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import {
returnUnpackList,
returnUnpackCreate,
returnUnpackDetail,
returnUnpackAddDetail,
returnUnpackUpdateDetail,
returnUnpackRemoveDetail,
returnUnpackSubmit,
returnUnpackCancel,
returnUnpackDelete,
} from '@/api/returnunpack'
import { loadStores } from '@/api/index/index'
import { extractStoreListFromResponse, fillStoreScanFieldOptions } from '@/views/order/orderManagement/config/order-common-config'
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
import { returnUnpackAvailableFields, returnUnpackColumns, returnUnpackToolbarButtons } from './returnUnpack-config'
import ScanBox from '@/components/ScanBox/index.vue'
import UpperTable from '@/components/UpperTable/index.vue'
import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue'
// ==================== 常量 / 工具 ====================
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 })
}
function statusLabel(val: any): string {
const map: Record<string, string> = {
unpacking: '拆包中',
completed: '已完成',
cancelled: '已作废',
}
return map[String(val)] ?? String(val ?? '-')
}
function statusTagType(val: any): 'success' | 'warning' | 'info' | 'danger' {
const map: Record<string, 'success' | 'warning' | 'info' | 'danger'> = {
unpacking: 'warning',
completed: 'success',
cancelled: 'info',
}
return map[String(val)] ?? 'info'
}
function detailStatusLabel(val: any): string {
const map: Record<string, string> = {
all_recognized: '全部识别',
partial_recognized: '部分识别',
none_recognized: '未识别',
}
return map[String(val)] ?? String(val ?? '-')
}
function detailStatusTagType(val: any): 'success' | 'warning' | 'info' | 'danger' {
const map: Record<string, 'success' | 'warning' | 'info' | 'danger'> = {
all_recognized: 'success',
partial_recognized: 'warning',
none_recognized: 'info',
}
return map[String(val)] ?? 'info'
}
function isOk(res: any): boolean {
return Boolean(res && (res.code === 1 || res.code === 200 || res.code === 20000))
}
async function copyText(text: string) {
if (!text) {
ElMessage.warning('无可复制内容')
return
}
try {
if (navigator.clipboard?.writeText) {
await navigator.clipboard.writeText(text)
} else {
throw new Error('no clipboard api')
}
ElMessage.success('已复制到剪贴板')
} catch {
try {
const textarea = document.createElement('textarea')
textarea.value = text
textarea.setAttribute('readonly', 'readonly')
textarea.style.position = 'fixed'
textarea.style.left = '-9999px'
document.body.appendChild(textarea)
textarea.select()
document.execCommand('copy')
document.body.removeChild(textarea)
ElMessage.success('已复制到剪贴板')
} catch {
ElMessage.error('复制失败,请手动复制')
}
}
}
// ==================== 配置 ====================
const availableFields = returnUnpackAvailableFields
const columns = returnUnpackColumns
const tableSize = 'small'
const toolbarButtons: ToolbarButtonConfig[] = returnUnpackToolbarButtons
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
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 currentSort = ref<{ prop: string; order: string }>({ prop: '', order: '' })
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() {
/* 点击行无默认行为,详情通过操作列触发 */
}
// ==================== 条件转换 ====================
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.value : cond
if (value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0)) continue
switch (key) {
case 'unpack_no':
case 'waybill_code':
where[key] = { operator: 'like', value: String(value) }
break
case 'unpack_date':
where.unpack_date = { operator: 'between', value }
break
case 'status':
case 'detail_status':
where[key] = String(value)
break
case 'store_id': {
const n = Number(value)
if (!Number.isNaN(n)) where[key] = n
break
}
default:
where[key] = value
}
}
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,
}
if (currentSort.value.prop) {
params.sort = {
sortField: currentSort.value.prop,
sortOrder: currentSort.value.order === 'ascending' ? 'asc' : 'desc',
}
}
const res: any = await returnUnpackList(params)
if (isOk(res)) {
const data = res.data ?? res
tableData.value = data.list ?? data.items ?? []
const total = data.pagination?.total ?? data.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
}
}
function handleRefresh() {
fetchData()
}
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()
}
function handleSortChange({ prop, order }: any) {
currentSort.value = { prop: prop ?? '', order: order ?? '' }
pagination.currentPage = 1
upperPagination.currentPage = 1
fetchData()
}
// ==================== 开拆包单 ====================
const createLoading = ref(false)
const createForm = reactive({ waybillCode: '', remark: '' })
async function handleCreate() {
const code = createForm.waybillCode.trim()
if (!code) {
ElMessage.warning('请先扫描或输入退回运单号')
return
}
createLoading.value = true
try {
const res: any = await returnUnpackCreate({
waybill_code: code,
remark: createForm.remark ? createForm.remark.trim() : undefined,
})
if (isOk(res)) {
const data = res.data ?? res
if (data.is_original_return) {
ElMessage.success(`开单成功:命中原单退回,拆包单ID ${data.id}`)
} else {
ElMessage.success(`开单成功:拆包单ID ${data.id}`)
}
createForm.waybillCode = ''
createForm.remark = ''
fetchData()
if (data.id) {
handleViewDetail({ id: data.id })
}
} else {
ElMessage.error(res?.message || '开单失败')
}
} catch {
// 请求层已提示错误
} finally {
createLoading.value = false
}
}
// ==================== 详情 ====================
const detailVisible = ref(false)
const detailLoading = ref(false)
const detailRecord = ref<any>(null)
const detailOrder = ref<any>(null)
const detailList = ref<any[]>([])
async function handleViewDetail(row: any) {
detailVisible.value = true
detailLoading.value = true
detailRecord.value = null
detailOrder.value = null
detailList.value = []
try {
const res: any = await returnUnpackDetail({ id: row.id })
if (isOk(res)) {
const data = res.data ?? res
detailRecord.value = data.record ?? data
detailOrder.value = data.related?.order ?? data.order ?? null
detailList.value = detailRecord.value?.details ?? []
} else {
ElMessage.error(res?.message || '获取详情失败')
}
} catch {
// 请求层已提示错误
} finally {
detailLoading.value = false
}
}
async function refreshDetail() {
if (!detailRecord.value?.id) return
await handleViewDetail({ id: detailRecord.value.id })
}
// ==================== 明细操作 ====================
const detailFormVisible = ref(false)
const detailFormLoading = ref(false)
const detailForm = reactive({
isEdit: false,
detailId: null as number | null,
stockId: '',
quantity: 1,
productStatus: 'normal' as 'normal' | 'damaged',
remark: '',
})
function openAddDetail() {
detailForm.isEdit = false
detailForm.detailId = null
detailForm.stockId = ''
detailForm.quantity = 1
detailForm.productStatus = 'normal'
detailForm.remark = ''
detailFormVisible.value = true
}
function openEditDetail(row: any) {
detailForm.isEdit = true
detailForm.detailId = row.id
detailForm.stockId = row.stock_id != null ? String(row.stock_id) : ''
detailForm.quantity = row.quantity ?? 1
detailForm.productStatus = row.product_status ?? 'normal'
detailForm.remark = row.remark ?? ''
detailFormVisible.value = true
}
async function submitDetailForm() {
if (!detailRecord.value?.id) return
const unpackId = detailRecord.value.id
const stockIdRaw = String(detailForm.stockId).trim()
const stockId = stockIdRaw ? Number(stockIdRaw) : undefined
detailFormLoading.value = true
try {
let res: any
if (detailForm.isEdit) {
if (!detailForm.detailId) {
ElMessage.warning('缺少明细ID')
return
}
res = await returnUnpackUpdateDetail({
id: unpackId,
detail_id: detailForm.detailId,
quantity: detailForm.quantity,
remark: detailForm.remark ? detailForm.remark.trim() : undefined,
})
} else {
res = await returnUnpackAddDetail({
id: unpackId,
stock_id: stockId,
quantity: detailForm.quantity,
product_status: detailForm.productStatus,
remark: detailForm.remark ? detailForm.remark.trim() : undefined,
})
}
if (isOk(res)) {
ElMessage.success(detailForm.isEdit ? '明细更新成功' : '明细录入成功')
detailFormVisible.value = false
await refreshDetail()
fetchData()
} else {
ElMessage.error(res?.message || (detailForm.isEdit ? '明细更新失败' : '明细录入失败'))
}
} catch {
// 请求层已提示错误
} finally {
detailFormLoading.value = false
}
}
async function handleRemoveDetail(row: any) {
if (!detailRecord.value?.id) return
try {
await ElMessageBox.confirm(
`确认移除该明细(明细ID ${row.id})?移除为物理删除,不可恢复。`,
'移除明细确认',
{ type: 'warning', confirmButtonText: '移除', cancelButtonText: '取消' }
)
} catch {
return
}
try {
const res: any = await returnUnpackRemoveDetail({ id: detailRecord.value.id, detail_id: row.id })
if (isOk(res)) {
ElMessage.success('明细移除成功')
await refreshDetail()
fetchData()
} else {
ElMessage.error(res?.message || '明细移除失败')
}
} catch {
// 请求层已提示错误
}
}
// ==================== 提交 / 取消 / 删除 ====================
const submitLoading = ref(false)
const cancelLoading = ref(false)
const deleteLoading = ref(false)
async function handleSubmit(row: any) {
try {
await ElMessageBox.confirm(
`确认提交拆包单「${row.unpack_no ?? row.id}」?提交后转为已完成终态,不可再录/移除明细。`,
'提交确认',
{ type: 'warning', confirmButtonText: '提交', cancelButtonText: '取消' }
)
} catch {
return
}
submitLoading.value = true
try {
const res: any = await returnUnpackSubmit({ id: row.id })
if (isOk(res)) {
ElMessage.success('提交成功')
await refreshDetail()
fetchData()
} else {
ElMessage.error(res?.message || '提交失败')
}
} catch {
// 请求层已提示错误
} finally {
submitLoading.value = false
}
}
async function handleCancel(row: any) {
try {
await ElMessageBox.confirm(
`确认取消拆包单「${row.unpack_no ?? row.id}」?取消将硬删除该单及全部明细,不可恢复。`,
'取消拆包确认',
{ type: 'warning', confirmButtonText: '取消拆包', cancelButtonText: '返回' }
)
} catch {
return
}
cancelLoading.value = true
try {
const res: any = await returnUnpackCancel({ id: row.id })
if (isOk(res)) {
ElMessage.success('已取消拆包单')
detailVisible.value = false
fetchData()
} else {
ElMessage.error(res?.message || '取消拆包失败')
}
} catch {
// 请求层已提示错误
} finally {
cancelLoading.value = false
}
}
async function handleDelete(row: any) {
try {
await ElMessageBox.confirm(
`确认删除拆包单「${row.unpack_no ?? row.id}」?删除为物理删除(含全部明细),不可恢复。`,
'删除确认',
{ type: 'warning', confirmButtonText: '删除', cancelButtonText: '取消' }
)
} catch {
return
}
deleteLoading.value = true
try {
const res: any = await returnUnpackDelete({ id: row.id })
if (isOk(res)) {
ElMessage.success('删除成功')
detailVisible.value = false
fetchData()
} else {
ElMessage.error(res?.message || '删除失败')
}
} catch {
// 请求层已提示错误
} finally {
deleteLoading.value = false
}
}
// ==================== 货主选项加载 ====================
async function loadStoreOptions() {
try {
const storesRes: any = await loadStores()
fillStoreScanFieldOptions(availableFields, extractStoreListFromResponse(storesRes))
} catch {
fillStoreScanFieldOptions(availableFields, [])
}
}
onMounted(() => {
loadStoreOptions()
fetchData()
})
</script>
<style scoped lang="scss">
@use "../../order/orderManagement/styles/order-sub.scss";
.scan-create {
display: flex;
align-items: center;
gap: 8px;
flex: 0 0 auto;
.create-input {
width: 220px;
}
.create-remark {
width: 160px;
}
}
.operation-actions {
display: flex;
align-items: center;
justify-content: center;
gap: 4px;
flex-wrap: wrap;
}
.detail-content {
min-height: 160px;
.detail-section {
margin-bottom: 16px;
&:last-child {
margin-bottom: 0;
}
}
.copyable {
cursor: pointer;
color: #409eff;
&:hover {
text-decoration: underline;
}
}
.detail-list-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 8px;
.detail-list-title {
font-size: 14px;
font-weight: 600;
color: #303133;
}
}
.detail-table {
width: 100%;
}
}
.full-width {
width: 100%;
}
</style>

View File

@ -0,0 +1,86 @@
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
// ============================================================
// 退回拆包(returnUnpack) - ScanBox 筛选字段
// 对齐 returnUnpack.list 接口文档 where 参数
// ============================================================
export const returnUnpackAvailableFields = [
{
value: 'unpack_no',
label: '拆包单号',
type: 'text',
placeholder: '拆包单号模糊搜索',
operators: ['like'],
defaultOperator: 'like',
},
{
value: 'waybill_code',
label: '退回运单号',
type: 'text',
placeholder: '运单号模糊搜索',
operators: ['like'],
defaultOperator: 'like',
},
{
value: 'status',
label: '拆包状态',
type: 'select',
placeholder: '请选择拆包状态',
options: [
{ label: '拆包中', value: 'unpacking' },
{ label: '已完成', value: 'completed' },
{ label: '已作废', value: 'cancelled' },
],
},
{
value: 'detail_status',
label: '明细识别状态',
type: 'select',
placeholder: '请选择明细识别状态',
options: [
{ label: '全部识别', value: 'all_recognized' },
{ label: '部分识别', value: 'partial_recognized' },
{ label: '未识别', value: 'none_recognized' },
],
},
{
value: 'unpack_date',
label: '拆包日期',
type: 'datetimerange',
},
{
value: 'store_id',
label: '货主',
type: 'select',
placeholder: '请选择货主',
options: [] as { label: string; value: unknown }[],
},
]
// ============================================================
// 退回拆包(returnUnpack) - UpperTable 列配置
// 对齐 returnUnpack.list 实际响应字段
// ============================================================
export const returnUnpackColumns = [
{ prop: 'id', label: 'ID', width: '80', sortable: 'custom' },
{ prop: 'unpack_no', label: '拆包单号', minWidth: '170', showOverflowTooltip: true, copyAction: 'copy' as const },
{ prop: 'waybill_code', label: '退回运单号', minWidth: '180', showOverflowTooltip: true, copyAction: 'copy' as const },
{ prop: 'status', label: '拆包状态', width: '100' },
{ prop: 'detail_status', label: '明细状态', width: '110' },
{ prop: 'total_items', label: '物品种类', width: '90' },
{ prop: 'total_quantity', label: '总数量', width: '90' },
{ prop: 'unpacker_name', label: '拆包人', minWidth: '100', showOverflowTooltip: true },
{ prop: 'unpack_date', label: '拆包日期', width: '130' },
{ prop: 'is_original_return', label: '原单退回', width: '100' },
{ prop: 'store_id', label: '货主ID', width: '90' },
{ prop: 'created_at', label: '创建时间', width: '170', sortable: 'custom' },
{ prop: 'actions', label: '操作', width: '240', fixed: 'right' },
]
// ============================================================
// 工具栏按钮
// ============================================================
export const returnUnpackToolbarButtons: ToolbarButtonConfig[] = [
{ key: 'refresh', label: '刷新', category: 'refresh', size: 'small', loadingKey: 'loading', action: 'loadData' },
{ key: 'columnConfig', label: '字段设置', category: 'setting', size: 'small', action: 'openColumnConfigPanel' },
]

View File

@ -152,7 +152,7 @@
<script setup lang="ts">
import { ref, reactive, computed, watch, onMounted } from 'vue'
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
import { afterSaleCreate, type AfterSaleCreateParams } from '@/api/afterSale/index'
import { afterSaleCreate, type AfterSaleCreateParams } from '@/api/aftersale/index'
import { AFTER_SALE_TYPE_MAP } from '@/views/afterSale/list/afterSale-config'
import { loadStores } from '@/api/index/index'
import { extractStoreListFromResponse, mapStoreListToSelectOptions } from '@/views/order/orderManagement/config/order-common-config'

View File

@ -200,7 +200,7 @@
<script setup lang="ts">
import { onMounted, reactive, ref, computed, watch } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { afterSaleWorkList, afterSaleBatchSetPendingFeedback, afterSaleBatchClose, type AfterSaleListParams } from '@/api/afterSale/index'
import { afterSaleWorkList, afterSaleBatchSetPendingFeedback, afterSaleBatchClose, type AfterSaleListParams } from '@/api/aftersale/index'
import {
getAfterSaleAvailableFields,
afterSaleAvailableFields,

View File

@ -543,12 +543,14 @@ async function loadData() {
try {
// 直接使用 handleConditionChange 保存的完整条件(含 operator),避免丢失操作符信息
const where = currentCondition.value || {}
const topParams = extractTopLevelParams(currentConditionRaw.value)
// console.log('当前筛选条件:', where)
const params: any = {
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
where,
order: currentSort.prop ? { [currentSort.prop]: currentSort.order === 'ascending' ? 'ASC' : 'DESC' } : undefined
order: currentSort.prop ? { [currentSort.prop]: currentSort.order === 'ascending' ? 'ASC' : 'DESC' } : undefined,
...topParams
}
if (quickSearch.value) {
@ -594,6 +596,26 @@ async function loadFilterData() {
}
}
/** 顶层查询参数(与 where 平级,不放 where 内) */
const TOP_LEVEL_FIELDS = ['stock_query_where']
/** 从 ScanBox 条件中提取顶层参数(filterDepleted / entry_order_id / stock_query_where) */
function extractTopLevelParams(condition: any): Record<string, any> {
if (!condition || typeof condition !== 'object') return {}
const source = condition.conditions && typeof condition.conditions === 'object'
? condition.conditions
: condition
const params: Record<string, any> = {}
for (const key of TOP_LEVEL_FIELDS) {
const c = source[key]
if (c === undefined || c === null) continue
const val = c && typeof c === 'object' && 'value' in c ? c.value : c
if (val === undefined || val === null || val === '') continue
params[key] = val
}
return params
}
function normalizeToWhere(condition: any) {
if (!condition) return {}
@ -654,6 +676,7 @@ function normalizeToWhere(condition: any) {
if (condition.conditions && typeof condition.conditions === 'object') {
const where: any = {}
Object.keys(condition.conditions).forEach(k => {
if (TOP_LEVEL_FIELDS.includes(k)) return
const result = processConditionValue(k, condition.conditions[k])
if (result) where[k] = result
})
@ -664,6 +687,7 @@ function normalizeToWhere(condition: any) {
if (typeof condition === 'object') {
const where: any = {}
Object.keys(condition).forEach(k => {
if (TOP_LEVEL_FIELDS.includes(k)) return
const result = processConditionValue(k, condition[k])
if (result) where[k] = result
})
@ -699,12 +723,14 @@ function handleSubmit() {
const handleConditionClear = () => {
currentCondition.value = null // 清空已保存的条件
currentConditionRaw.value = null // 清空原始条件,避免顶层参数残留
pagination.currentPage = 1
loadData()
}
function handleConditionReset() {
currentCondition.value = null // 清空已保存的条件
currentConditionRaw.value = null // 清空原始条件,避免顶层参数残留
pagination.currentPage = 1
// 如果 ScanBox 提供 reset/clear 方法,调用以清空筛选条件
if (scanBox.value?.reset) {

View File

@ -229,6 +229,14 @@ export const availableFields: ReceivingScanFieldConfig[] = [
filterable: true,
options: []
}),
receivingScanBasicField({
value: 'stock_query_where',
label: '商品搜索',
type: 'text',
placeholder: '商品条码/编码/ID',
hideOperator: true,
defaultOperator: 'eq'
}),
// ===== 流程状态 =====
receivingScanWorkflowField({

View File

@ -182,6 +182,7 @@ const upperTable = ref<any>(null)
const route = useRoute()
const initialConditions = ref<any>(null)
const currentCondition = ref<any>(null)
const currentConditionRaw = ref<any>(null)
const {
splitStackRef,
@ -390,6 +391,26 @@ function formatTime(val: any) {
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
}
/** 顶层查询参数(与 where 平级,不放 where 内) */
const TOP_LEVEL_FIELDS = ['stock_query_where']
/** 从 ScanBox 条件中提取顶层参数(对齐 storage/receiving) */
function extractTopLevelParams(condition: any): Record<string, any> {
if (!condition || typeof condition !== 'object') return {}
const source = condition.conditions && typeof condition.conditions === 'object'
? condition.conditions
: condition
const params: Record<string, any> = {}
for (const key of TOP_LEVEL_FIELDS) {
const c = source[key]
if (c === undefined || c === null) continue
const val = c && typeof c === 'object' && 'value' in c ? c.value : c
if (val === undefined || val === null || val === '') continue
params[key] = val
}
return params
}
function normalizeToWhere(condition: any) {
if (!condition) return {}
const conds = condition?.conditions && typeof condition.conditions === 'object'
@ -398,6 +419,7 @@ function normalizeToWhere(condition: any) {
const where: any = {}
for (const [key, val] of Object.entries(conds)) {
if (TOP_LEVEL_FIELDS.includes(key)) continue
if (val === null || val === undefined || val === '') continue
if (typeof val === 'object' && !Array.isArray(val) && ('operator' in val! || 'value' in val!)) {
where[key] = val
@ -428,7 +450,9 @@ async function loadData() {
loading.value = true
const start = Date.now()
try {
const where = currentCondition.value || normalizeToWhere(scanBox.value?.getConditions?.() || {})
const rawCondition = currentConditionRaw.value ?? scanBox.value?.getConditions?.() ?? {}
const where = currentCondition.value || normalizeToWhere(rawCondition)
const topParams = extractTopLevelParams(rawCondition)
const params: any = {
pagination: {
@ -439,7 +463,8 @@ async function loadData() {
sortField: currentSort.prop,
sortOrder: currentSort.order === 'ascending' ? 'ASC' : 'DESC'
} : undefined,
where
where,
...topParams
}
const res = await receivingApi.getReceivingListStore(params)
@ -478,6 +503,7 @@ async function loadFilterData() {
}
function handleConditionChange(condition: any) {
currentConditionRaw.value = condition
currentCondition.value = normalizeToWhere(condition)
pagination.currentPage = 1
loadData()
@ -492,12 +518,14 @@ function handleSortChange({ prop, order }: any) {
function handleConditionClear() {
currentCondition.value = null
currentConditionRaw.value = null
pagination.currentPage = 1
loadData()
}
function handleConditionReset() {
currentCondition.value = null
currentConditionRaw.value = null
pagination.currentPage = 1
if (scanBox.value?.reset) {
scanBox.value.reset()

View File

@ -320,7 +320,12 @@ const authForm = reactive({
/** 视频号平台需要 appId + toUserName,callbackUrl 固定为 "-" */
const isWechatChannel = computed(() => {
const code = String(authForm.platformCode || '').trim().toLowerCase()
return code === 'shipinhao' || code === '视频号'
const name = String(authForm.platform_name || '').trim().toLowerCase()
return (
code.includes('shipinhao') ||
code.includes('视频号') ||
name.includes('视频号')
)
})
const authNeedCallbackUrl = computed(() => {
@ -684,14 +689,15 @@ async function submitConfirmAuthorize() {
authConfirmLoading.value = true
try {
const payload: { id: number; callbackurl?: string; appId?: string; toUserName?: string } = {
id: authForm.shopId
const payload: { id: number; callbackurl: string; appId?: string; toUserName?: string } = {
id: authForm.shopId,
callbackurl: ''
}
if (isWechatChannel.value) {
payload.appId = authForm.appId.trim()
payload.toUserName = authForm.toUserName.trim()
payload.callbackurl = '-'
} else if (authNeedCallbackUrl.value) {
} else {
payload.callbackurl = String(authForm.callbackurl || '').trim()
}
@ -700,7 +706,7 @@ async function submitConfirmAuthorize() {
ElMessage.error(res?.message || '确认授权失败')
return
}
ElMessage.success(res?.message || '授权成功')
ElMessage.success(res?.data?.message || res?.message || '授权成功')
authDialogVisible.value = false
loadList()
} catch {