feat(order): 待审核列表提示被隐藏的未绑定商品订单数

拉单提示「成功 9 单」但列表只显示 3 单,实际是明细商品未采集/未绑定的订单被
默认过滤(exclude_unbound=1)掉了,界面上看不到任何线索,容易误判为漏拉。

- service/orderStatus.list:exclude_unbound=1 时额外统计未过滤总数,返回 hiddenUnbound
- controller/orderStatus.index:输出 hidden_unbound
- contract.orderStatusPage:补 hidden_unbound 字段
- 前端 StatusPanel:工具栏显示「另有 N 单未显示」(hover 说明原因),点击即切到「含未绑定」

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
liufumingren 2026-11-07 21:15:01 +08:00
parent d179cd3993
commit 8e2419c870
5 changed files with 60 additions and 18 deletions

View File

@ -2511,7 +2511,10 @@ module.exports = {
archived_at: { type: 'string', description: '归档时间(仅历史表)' },
transferred_at: { type: 'string', description: '转入历史时间(仅历史表)' },
},
orderStatusPage: buildPage('orderStatusItem', '订单列表'),
orderStatusPage: {
...buildPage('orderStatusItem', '订单列表'),
hidden_unbound: { type: 'integer', description: '因「含未绑定商品」被隐藏的订单数(exclude_unbound=1 时返回)' },
},
orderStatusListResponse: buildListResponse('orderStatusPage'),
/** 新建订单(含发货单口径:可直接带 items 创建明细) */
createOrderStatusRequest: {

View File

@ -79,8 +79,12 @@ class OrderStatusController extends Controller {
const { ctx } = this;
const { page, pageSize, offset, limit } = parsePagination(ctx.query);
try {
const { list, total } = await ctx.service.orderStatus.list({ ...ctx.query, offset, limit });
ctx.body = { code: 0, message: 'success', data: buildPageResult(list, total, { page, pageSize }) };
const { list, total, hiddenUnbound } = await ctx.service.orderStatus.list({ ...ctx.query, offset, limit });
ctx.body = {
code: 0,
message: 'success',
data: { ...buildPageResult(list, total, { page, pageSize }), hidden_unbound: hiddenUnbound || 0 },
};
} catch (err) {
this._fail(ctx, err, '查询订单列表失败');
}

View File

@ -454,25 +454,32 @@ class OrderStatusService extends Service {
// exclude_unbound=1:排除「有未绑定系统商品的明细」的订单(订单页默认只看已解析订单)
// 用 EXISTS 子查询而非 IN 列表,避免未绑定订单很多时拼接超长参数
if (String(p.exclude_unbound) === '1') {
where[Op.and].push(
ctx.app.Sequelize.literal(
'NOT EXISTS (SELECT 1 FROM order_status_items oi WHERE oi.order_id = `' + Model.tableName + '`.id ' +
`AND oi.principal_id = ${principalId} AND oi.parse_status = 2)`
)
);
}
const excludeUnbound = String(p.exclude_unbound) === '1';
const unboundClause = ctx.app.Sequelize.literal(
'NOT EXISTS (SELECT 1 FROM order_status_items oi WHERE oi.order_id = `' + Model.tableName + '`.id ' +
`AND oi.principal_id = ${principalId} AND oi.parse_status = 2)`
);
const whereWithUnbound = excludeUnbound
? { ...where, [Op.and]: [ ...where[Op.and], unboundClause ] }
: where;
const { count, rows } = await Model.findAndCountAll({
where,
where: whereWithUnbound,
offset: p.offset,
limit: p.limit,
order: [[ 'id', 'DESC' ]],
});
// 「因商品未绑定被隐藏」的订单数:前端据此提示「另有 N 单未显示」,避免看起来像漏拉
let hiddenUnbound = 0;
if (excludeUnbound) {
const totalWithUnbound = await Model.count({ where });
hiddenUnbound = Math.max(0, Number(totalWithUnbound) - Number(count));
}
const list = rows.map(row => row.get({ plain: true }));
await this._attachListMeta(list, principalId, status);
return { list, total: count };
return { list, total: count, hiddenUnbound };
}
/**

View File

@ -294,10 +294,14 @@ export interface OrderStatusArchiveResult {
/** 订单列表(按 status 定位状态表;principal_id 由请求拦截器注入) */
export function getOrderStatusList(params: OrderStatusQuery) {
return get<{ list: OrderStatusItem[]; total: number; page: number; pageSize: number }>(
'/order-status/list',
params as unknown as object,
)
return get<{
list: OrderStatusItem[]
total: number
page: number
pageSize: number
/** 因商品未绑定被隐藏的订单数(仅 exclude_unbound=1 时返回) */
hidden_unbound?: number
}>('/order-status/list', params as unknown as object)
}
/** 筛选项数据源:状态枚举 + 当前主体下的店铺/仓库 + 归档阈值 */

View File

@ -143,12 +143,24 @@ async function retryOneExternalSend(row: OrderStatusItem) {
/** 「含未绑定商品订单」开关(默认关闭:不显示含未绑定商品的订单) */
const showUnboundOrders = ref(false)
/** 因商品未绑定被隐藏的订单数(后端 hidden_unbound),用于提示「不是没拉到,是没显示」 */
const hiddenUnbound = ref(0)
function onUnboundSwitchChange() {
query.page = 1
search()
}
/** 只在「待审核 + 仅已绑定」视图下提示被隐藏的数量 */
const showHiddenUnboundHint = computed(
() => props.status === 'pending' && !showUnboundOrders.value && hiddenUnbound.value > 0,
)
function onShowUnboundClick() {
showUnboundOrders.value = true
onUnboundSwitchChange()
}
const { loading, list, total, elapsed, fetchList, search, handlePageChange, handleSizeChange } =
useListPage<OrderStatusItem, typeof query>({
query,
@ -181,7 +193,10 @@ const { loading, list, total, elapsed, fetchList, search, handlePageChange, hand
const sendStatus = isDeliveryException.value ? '2,3' : query.external_send_status
if (sendStatus) params.external_send_status = sendStatus
}
return getOrderStatusList(params as never)
return getOrderStatusList(params as never).then(res => {
hiddenUnbound.value = Number(res?.hidden_unbound) || 0
return res
})
},
})
@ -846,6 +861,15 @@ onBeforeUnmount(() => {
<span v-else-if="selectedIds.length" class="toolbar-hint">已选 {{ selectedIds.length }} 条</span>
</div>
<div class="toolbar-right">
<el-tooltip
v-if="showHiddenUnboundHint"
content="这些订单已拉取入库,但明细商品未采集到或未绑定系统商品,点此显示"
placement="top"
>
<el-tag type="warning" size="small" effect="plain" class="external-send-tag" @click="onShowUnboundClick">
另有 {{ hiddenUnbound }} 单未显示
</el-tag>
</el-tooltip>
<el-switch
v-if="props.status === 'pending'"
v-model="showUnboundOrders"