front/src/views/order/myOrders/index.vue
zzh 5a26ae0048 feat: 小红书模块迁移、登录重构与 xhs-agent-desktop 桌面 Agent
- 新增小红书前端模块(启动服务、内容分析、爆款创作、发布记录、技能卡片、拟人设置、AI 助手)

- 新增 xhs-agent-desktop 独立桌面 Agent,对接 OMS 任务调度

- 登录页重构,整合微信登录与 OMS JWT 认证

- 订单、渠道、用户中心等页面与 API 增强

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 16:13:13 +08:00

1286 lines
42 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script lang="ts" setup>
import { ref, computed, onMounted, nextTick } from 'vue';
import { IconSettings } from '@arco-design/web-vue/es/icon';
import { Message, Modal } from '@arco-design/web-vue';
import HandsontablePro from '@/components/HandsontablePro/index.vue';
import PaginationPro from '@/components/PaginationPro/index.vue';
import { useTableContainerHeight } from '@/composables/useTableContainerHeight';
import { useI18n } from 'vue-i18n';
import {
postOrderList,
getOrderStatusCounts,
getOrderDetail,
postOrderPay,
postOrderPreDeclare,
postOrderIntercept,
postOrderCancelIntercept,
postOrderDelete,
postOrderPrint,
postOrderExport,
postOrderTrackUpsertSmallBag,
postOrderDownstreamForwardCreateOne,
type OrderTrackUpsertResult,
type OrderDownstreamForwardResult,
} from '@/api/order';
import { notifyCustomerBalanceChanged } from '@/api/customer/accountFlow';
import OrderDetailDrawer from './components/OrderDetailDrawer.vue';
import OrderPrintModal from '@/components/PrintTemplate/OrderPrintModal.vue';
import { useHiprintClientState } from '@/utils/hiprint/hiprintClientState';
import {
ORDER_STATUS_TABS,
ORDER_STATUS_ALL,
resolveOrderStatusCode,
isOrderDeletable,
getOrderStatusMeta,
} from '@/constants/orderStatus';
defineOptions({
name: 'MyOrders',
});
const { t } = useI18n();
const { tableContainerRef, tableHeight } = useTableContainerHeight();
// 订单详情抽屉
const detailDrawerRef = ref<InstanceType<typeof OrderDetailDrawer>>();
const currentOrder = ref<any>(null);
/** 兼容后端 camelCase / PascalCase */
function pick(raw: Record<string, any> | undefined, ...keys: string[]) {
if (!raw) return undefined;
for (const k of keys) {
const v = raw[k];
if (v !== undefined && v !== null && v !== '') return v;
}
return undefined;
}
/** 列表行与表格列对齐:接口用 serviceNo/clientNo/trackNo,表格用运单号/客户单号/跟踪号 */
function normalizeOrderRow(raw: any) {
const r = raw?.receiver || raw?.Receiver || {};
const wl = raw?.weightList || raw?.WeightList;
const lastW =
Array.isArray(wl) && wl.length ? wl[wl.length - 1] : undefined;
const serviceNo = pick(raw, 'serviceNo', 'ServiceNo', 'waybillNo', 'WaybillNo');
const clientNo = pick(raw, 'clientNo', 'ClientNo', 'customerOrderNo', 'CustomerOrderNo');
const trackNo = pick(raw, 'trackNo', 'TrackNo', 'trackingNo', 'TrackingNo');
const productCode = pick(raw, 'productCode', 'ProductCode');
const productName = pick(raw, 'productName', 'ProductName');
const channelCode = pick(raw, 'channelCode', 'ChannelCode');
const channelName = pick(raw, 'channelName', 'ChannelName');
const isPaidRaw = pick(raw, 'isPaid', 'IsPaid');
return {
...raw,
waybillNo: serviceNo ?? '',
customerOrderNo: clientNo ?? '',
trackingNo: trackNo ?? '',
productCode: productCode ?? '',
productName: productName ?? productCode ?? '',
channelCode: channelCode ?? '',
channelName: channelName ?? channelCode ?? '',
isPaid: isPaidRaw === true || isPaidRaw === 1 || isPaidRaw === '1',
consignee: pick(raw, 'consignee', 'Consignee') ?? pick(r, 'recipientsName', 'RecipientsName') ?? '',
consigneePhone: pick(raw, 'consigneePhone', 'ConsigneePhone') ?? pick(r, 'phone', 'Phone') ?? '',
consigneeAddress: pick(raw, 'consigneeAddress', 'ConsigneeAddress') ?? pick(r, 'streetAddress1', 'StreetAddress1') ?? '',
consigneePostcode: pick(raw, 'consigneePostcode', 'ConsigneePostcode') ?? pick(r, 'zipCode', 'ZipCode') ?? '',
consigneeState: pick(raw, 'consigneeState', 'ConsigneeState') ?? pick(r, 'province', 'Province') ?? '',
consigneeCity: pick(raw, 'consigneeCity', 'ConsigneeCity') ?? pick(r, 'city', 'City') ?? '',
consigneeCountry: pick(raw, 'consigneeCountry', 'ConsigneeCountry') ?? pick(r, 'country', 'Country') ?? '',
consigneeCountryName: pick(raw, 'consigneeCountryName', 'ConsigneeCountryName') ?? '',
ioss: pick(raw, 'ioss', 'Ioss', 'IOSS') ?? '',
eori: pick(raw, 'eori', 'Eori', 'EORI') ?? pick(r, 'eori', 'Eori') ?? '',
shippingMethod: productName ?? productCode ?? '',
serviceChannel: channelName ?? channelCode ?? '',
chargeableWeight:
pick(raw, 'chargeableWeight', 'ChargeableWeight') ??
pick(lastW as any, 'chargeableWeight', 'ChargeableWeight') ??
'',
receivableAmount: pick(raw, 'receivableAmount', 'ReceivableAmount') ?? '',
orderStatus: pick(raw, 'orderStatus', 'OrderStatus') ?? raw?.orderStatus,
status: resolveOrderStatusCode(raw) || pick(raw, 'status', 'Status') || raw?.status,
cargoAttribute: pick(raw, 'cargoAttribute', 'CargoAttribute') ?? raw?.cargoAttribute,
createTime: pick(raw, 'createTime', 'CreateTime') ?? raw?.createTime,
receiveTime: pick(raw, 'receiveTime', 'ReceiveTime') ?? raw?.receiveTime,
shipTime: pick(raw, 'shipTime', 'ShipTime') ?? raw?.shipTime,
payTime: pick(raw, 'payTime', 'PayTime') ?? raw?.payTime,
signTime: pick(raw, 'signTime', 'SignTime') ?? raw?.signTime,
warehouse: pick(raw, 'warehouse', 'Warehouse') ?? raw?.warehouse,
};
}
async function openDetailWithOptionalFetch(row: any) {
currentOrder.value = row;
detailDrawerRef.value?.openDrawer();
const id = row?.id;
if (id == null || id === '') return;
try {
const detail = await getOrderDetail(id);
currentOrder.value = normalizeOrderRow({ ...row, ...detail });
} catch {
/* 保留列表行数据 */
}
}
function handleOrderDetailUpdated(row: any) {
currentOrder.value = normalizeOrderRow(row);
const idx = orderList.value.findIndex((it) => Number(it.id) === Number(row?.id));
if (idx >= 0) {
orderList.value[idx] = normalizeOrderRow({ ...orderList.value[idx], ...row });
}
}
const handleOrderDetailClick = (row: number) => {
if (row >= 0 && row < orderList.value.length) {
openDetailWithOptionalFetch(orderList.value[row]);
}
};
// 当前激活的标签页(与后端 OrderStatusCodes 一致)
const activeTab = ref<string>(ORDER_STATUS_ALL);
const tabCounts = ref<Record<string, number>>({});
const tabs = computed(() =>
ORDER_STATUS_TABS.map((meta) => ({
key: meta.value,
labelKey: meta.labelKey,
showCount: meta.showTabCount !== false,
count: tabCounts.value[meta.value] ?? null,
})),
);
async function loadTabCounts() {
try {
const { total, counts } = await getOrderStatusCounts();
const next: Record<string, number> = {
[ORDER_STATUS_ALL]: total,
};
for (const meta of ORDER_STATUS_TABS) {
if (meta.value === ORDER_STATUS_ALL) continue;
next[meta.value] = counts[meta.value] ?? 0;
}
tabCounts.value = next;
} catch {
/* 角标失败不影响列表 */
}
}
async function refreshListAndTabCounts() {
await Promise.all([loadOrderList(), loadTabCounts()]);
}
// 分页相关数据
const currentPage = ref(1);
const pageSize = ref(50);
const totalCount = ref(0);
const orderList = ref<any[]>([]);
const listLoading = ref(false);
let listRequestSeq = 0;
const selectedRowCount = ref(0);
/** 表格选中行(用于批量操作) */
const selectedOrderRows = ref<any[]>([]);
const actionSubmitting = ref(false);
const printConnectionState = useHiprintClientState();
const singlePrintVisible = ref(false);
const batchPrintVisible = ref(false);
const singlePrintItems = ref<Array<{ id: number | string; label: string; url: string }>>([]);
const batchPrintItems = ref<Array<{ id: number | string; label: string; url: string }>>([]);
const trackUpsertModalVisible = ref(false);
const trackUpsertResultText = ref('');
const downstreamForwardModalVisible = ref(false);
const downstreamForwardResultText = ref('');
function formatTrackUpsertResult(waybillNo: string, result: OrderTrackUpsertResult): string {
const lines = [`【${waybillNo || '-'}】`];
if (result.skipped) {
lines.push(`跳过:${result.skipReason || '未知原因'}`);
return lines.join('\n');
}
lines.push(`HTTP:${result.statusCode ?? '-'}`);
lines.push(`成功:${result.success ? '是' : '否'}`);
if (result.responseBody) {
lines.push(`响应:${result.responseBody}`);
}
if (result.curlCommand) {
lines.push('curl:');
lines.push(result.curlCommand);
} else if (result.requestJson) {
lines.push(`请求:${result.requestJson}`);
}
return lines.join('\n');
}
const handleCreateTrackOrder = async () => {
const rows = requireSelectedRows();
if (!rows.length) return;
actionSubmitting.value = true;
const resultBlocks: string[] = [];
try {
for (const row of rows) {
const id = getOrderRowId(row)!;
const waybillNo = row.waybillNo || row.serviceNo || String(id);
try {
const result = await postOrderTrackUpsertSmallBag({ id });
resultBlocks.push(formatTrackUpsertResult(waybillNo, result));
} catch (e: any) {
resultBlocks.push(`【${waybillNo}】失败:${e?.message || '请求异常'}`);
}
}
trackUpsertResultText.value = resultBlocks.join('\n\n');
trackUpsertModalVisible.value = true;
} finally {
actionSubmitting.value = false;
}
};
function formatDownstreamForwardResult(
waybillNo: string,
result: OrderDownstreamForwardResult
): string {
const lines = [
`【${waybillNo || '-'}】`,
`standardCode:createOrderOne`,
];
if (result.supplierCode) {
lines.push(`supplierCode:${result.supplierCode}`);
}
lines.push(`URL:${result.url || '-'}`);
lines.push(`HTTP:${result.statusCode ?? '-'}`);
lines.push(`成功:${result.success ? '是' : '否'}`);
if (result.responseBody) {
lines.push(`响应:${result.responseBody}`);
}
if (result.requestJson) {
lines.push(`请求体:${result.requestJson}`);
}
return lines.join('\n');
}
const handleForwardDownstreamCreate = async () => {
const rows = requireSelectedRows();
if (!rows.length) return;
actionSubmitting.value = true;
const resultBlocks: string[] = [];
try {
for (const row of rows) {
const id = getOrderRowId(row)!;
const waybillNo = row.waybillNo || row.serviceNo || String(id);
try {
const result = await postOrderDownstreamForwardCreateOne({ id });
resultBlocks.push(formatDownstreamForwardResult(waybillNo, result));
} catch (e: any) {
resultBlocks.push(`【${waybillNo}】失败:${e?.message || '请求异常'}`);
}
}
downstreamForwardResultText.value = resultBlocks.join('\n\n');
downstreamForwardModalVisible.value = true;
} finally {
actionSubmitting.value = false;
}
};
function getOrderRowId(row: any): number | string | undefined {
if (row == null) return undefined;
const id = row.id ?? row.Id;
if (id === undefined || id === null || id === '') return undefined;
return id;
}
function requireSelectedRows(): any[] {
const rows = selectedOrderRows.value.filter((r) => getOrderRowId(r) != null);
if (!rows.length) {
Message.warning('请先选择订单');
return [];
}
return rows;
}
const loadOrderList = async () => {
const requestSeq = ++listRequestSeq;
const status = activeTab.value === ORDER_STATUS_ALL ? ORDER_STATUS_ALL : activeTab.value;
listLoading.value = true;
try {
const { items, total } = await postOrderList({
page: currentPage.value,
pageSize: pageSize.value,
status,
});
if (requestSeq !== listRequestSeq) {
return;
}
const mapped = (items || []).map((row) => normalizeOrderRow(row));
orderList.value = mapped;
totalCount.value = total;
tabCounts.value[status] = total;
} catch (e: any) {
if (requestSeq !== listRequestSeq) {
return;
}
orderList.value = [];
totalCount.value = 0;
Message.error(e?.message || '加载订单列表失败');
} finally {
if (requestSeq === listRequestSeq) {
listLoading.value = false;
}
}
};
// 当前页数据(HandsontablePro 用)
const processedTableData = computed(() => orderList.value);
// 标签页切换
const handleTabChange = (key: string) => {
if (activeTab.value === key) {
return;
}
activeTab.value = key;
currentPage.value = 1;
orderList.value = [];
selectedOrderRows.value = [];
selectedRowCount.value = 0;
loadOrderList();
};
// 操作按钮处理(依赖表格多选行;导出按当前 tab 条件,无需选行)
const handlePay = async () => {
const rows = requireSelectedRows();
if (!rows.length) return;
actionSubmitting.value = true;
try {
for (const row of rows) {
await postOrderPay({ id: getOrderRowId(row)! });
}
Message.success('支付请求已提交');
notifyCustomerBalanceChanged();
await refreshListAndTabCounts();
} catch (e: any) {
Message.error(e?.message || '操作失败');
} finally {
actionSubmitting.value = false;
}
};
const handlePreDeclare = async () => {
const rows = requireSelectedRows();
if (!rows.length) return;
actionSubmitting.value = true;
try {
for (const row of rows) {
await postOrderPreDeclare({ id: getOrderRowId(row)! });
}
Message.success('预报已提交');
await refreshListAndTabCounts();
} catch (e: any) {
Message.error(e?.message || '操作失败');
} finally {
actionSubmitting.value = false;
}
};
const handleIntercept = async () => {
const rows = requireSelectedRows();
if (!rows.length) return;
actionSubmitting.value = true;
try {
for (const row of rows) {
await postOrderIntercept({ id: getOrderRowId(row)! });
}
Message.success('拦截已提交');
await refreshListAndTabCounts();
} catch (e: any) {
Message.error(e?.message || '操作失败');
} finally {
actionSubmitting.value = false;
}
};
const handleCancelIntercept = async () => {
const rows = requireSelectedRows();
if (!rows.length) return;
actionSubmitting.value = true;
try {
for (const row of rows) {
await postOrderCancelIntercept({ id: getOrderRowId(row)! });
}
Message.success('已取消拦截');
await refreshListAndTabCounts();
} catch (e: any) {
Message.error(e?.message || '操作失败');
} finally {
actionSubmitting.value = false;
}
};
const handleDelete = () => {
const rows = requireSelectedRows();
if (!rows.length) return;
const blocked = rows.filter((row) => !isOrderDeletable(resolveOrderStatusCode(row)));
if (blocked.length) {
Message.warning('仅草稿或已预报订单可删除');
return;
}
Modal.confirm({
title: '确认删除',
content: `确定删除选中的 ${rows.length} 条订单吗?`,
onOk: async () => {
actionSubmitting.value = true;
try {
for (const row of rows) {
await postOrderDelete({ id: getOrderRowId(row)! });
}
Message.success('已删除');
await refreshListAndTabCounts();
} catch (e: any) {
Message.error(e?.message || '删除失败');
throw e;
} finally {
actionSubmitting.value = false;
}
},
});
};
function buildPrintItem(row: any, printUrl: string) {
const id = getOrderRowId(row)!;
const label = row?.waybillNo || row?.trackingNo || row?.customerOrderNo || String(id);
return { id, label, url: printUrl };
}
function isUsablePrintUrl(raw: unknown) {
const value = String(raw ?? '').trim();
if (!value) return false;
if (value.includes('获取中')) return false;
return true;
}
const handleSinglePrint = async () => {
singlePrintVisible.value = false;
singlePrintItems.value = [];
const rows = requireSelectedRows();
if (!rows.length) return;
if (rows.length > 1) {
Message.warning('单个打印仅支持选择 1 条订单');
return;
}
if (!printConnectionState.enabled || !printConnectionState.connected) {
Message.warning('请先在顶部打开并连接打印开关');
return;
}
actionSubmitting.value = true;
try {
const row = rows[0];
const { printUrl } = await postOrderPrint({ id: getOrderRowId(row)! });
if (!isUsablePrintUrl(printUrl)) {
Message.info('未获取到打印文件,已打开打印弹窗供预览布局');
singlePrintVisible.value = true;
return;
}
singlePrintItems.value = [buildPrintItem(row, printUrl)];
singlePrintVisible.value = true;
} catch (e: any) {
Message.error(e?.message || '打印失败');
} finally {
actionSubmitting.value = false;
}
};
const handleBatchPrint = async () => {
batchPrintVisible.value = false;
batchPrintItems.value = [];
const rows = requireSelectedRows();
if (!rows.length) return;
if (!printConnectionState.enabled || !printConnectionState.connected) {
Message.warning('请先在顶部打开并连接打印开关');
return;
}
actionSubmitting.value = true;
try {
const items: Array<{ id: number | string; label: string; url: string }> = [];
for (const row of rows) {
const { printUrl } = await postOrderPrint({ id: getOrderRowId(row)! });
if (isUsablePrintUrl(printUrl)) {
items.push(buildPrintItem(row, printUrl));
}
}
if (!items.length) {
Message.info('未获取到可打印文件,已打开打印弹窗供预览布局');
batchPrintVisible.value = true;
return;
}
batchPrintItems.value = items;
batchPrintVisible.value = true;
} catch (e: any) {
Message.error(e?.message || '批量打印失败');
} finally {
actionSubmitting.value = false;
}
};
const handleExport = async () => {
actionSubmitting.value = true;
try {
const status = activeTab.value === ORDER_STATUS_ALL ? ORDER_STATUS_ALL : activeTab.value;
const { downloadUrl } = await postOrderExport({
status,
keyword: '',
createTimeStart: '',
createTimeEnd: '',
});
if (downloadUrl) window.open(downloadUrl, '_blank');
Message.success(downloadUrl ? '导出链接已打开' : '导出已提交');
} catch (e: any) {
Message.error(e?.message || '导出失败');
} finally {
actionSubmitting.value = false;
}
};
const handleModifyOrder = () => {
};
const onMoreActionClick = (key: string) => {
if (key === 'intercept') return handleIntercept();
if (key === 'cancelIntercept') return handleCancelIntercept();
if (key === 'delete') return handleDelete();
if (key === 'export') return handleExport();
if (key === 'modifyOrder') return handleModifyOrder();
};
// 分页处理函数
const handlePageChange = (page: number) => {
currentPage.value = page;
loadOrderList();
};
const handlePageSizeChange = (size: number) => {
pageSize.value = size;
currentPage.value = 1;
loadOrderList();
};
// HandsontablePro 列定义
const hotColumns = computed(() => [
{ key: 'waybillNo', label: t('order.myOrders.table.waybillNo'), width: 270 },
{ key: 'customerOrderNo', label: t('order.myOrders.table.customerOrderNo'), width: 180 },
{ key: 'trackingNo', label: t('order.myOrders.table.trackingNo'), width: 180 },
{ key: 'shippingMethod', label: t('order.myOrders.table.shippingMethod'), width: 120 },
{ key: 'serviceChannel', label: t('order.myOrders.table.serviceChannel'), width: 120 },
{ key: 'isPaid', label: t('order.myOrders.table.isPaid'), width: 80 },
{ key: 'cargoAttribute', label: t('order.myOrders.table.cargoAttribute'), width: 85 },
{ key: 'consigneeCountry', label: t('order.myOrders.table.consigneeCountry'), width: 120 },
{ key: 'chargeableWeight', label: t('order.myOrders.table.chargeableWeight'), width: 95 },
{ key: 'receivableAmount', label: t('order.myOrders.table.receivableAmount'), width: 95 },
{ key: 'consignee', label: t('order.myOrders.table.consignee'), width: 90 },
{ key: 'consigneePhone', label: t('order.myOrders.table.consigneePhone'), width: 110 },
{ key: 'consigneeAddress', label: t('order.myOrders.table.consigneeAddress'), width: 140 },
{ key: 'consigneePostcode', label: t('order.myOrders.table.consigneePostcode'), width: 90 },
{ key: 'consigneeState', label: t('order.myOrders.table.consigneeState'), width: 90 },
{ key: 'consigneeCity', label: t('order.myOrders.table.consigneeCity'), width: 90 },
{ key: 'ioss', label: t('order.myOrders.table.ioss'), width: 100 },
{ key: 'eori', label: t('order.myOrders.table.eori'), width: 100 },
{ key: 'orderStatus', label: t('order.myOrders.table.orderStatus'), width: 90 },
{ key: 'createTime', label: t('order.myOrders.table.createTime'), width: 150 },
{ key: 'receiveTime', label: t('order.myOrders.table.receiveTime'), width: 150 },
{ key: 'shipTime', label: t('order.myOrders.table.shipTime'), width: 150 },
{ key: 'payTime', label: t('order.myOrders.table.payTime'), width: 150 },
{ key: 'signTime', label: t('order.myOrders.table.signTime'), width: 150 },
{ key: 'warehouse', label: t('order.myOrders.table.warehouse'), width: 90 },
]);
const iconView = '<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" style="width:16px;height:16px;color:var(--app-primary-color,#2D8C8C);"><path d="M8 2C4.5 2 1.73 4.11 0 7c1.73 2.89 4.5 5 8 5s6.27-2.11 8-5c-1.73-2.89-4.5-5-8-5zM8 11.5c-2.48 0-4.5-2.02-4.5-4.5S5.52 2.5 8 2.5s4.5 2.02 4.5 4.5S10.48 11.5 8 11.5zM8 4.5c-1.38 0-2.5 1.12-2.5 2.5S6.62 9.5 8 9.5s2.5-1.12 2.5-2.5S9.38 4.5 8 4.5z" fill="currentColor"/></svg>';
const actionRenderer = (row: any, rowIndex: number) => {
return `<div class="view-icon-wrapper" data-action="view" data-row-index="${rowIndex}" style="display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 4px; border-radius: 4px; transition: all 0.2s;">${iconView}</div>`;
};
const customCellRenderer = (row: number, col: number, value: any, rowData: any) => {
const colOffset = 2; // action + serialNo
const dataColIndex = col - colOffset;
if (dataColIndex < 0 || dataColIndex >= hotColumns.value.length) return null;
const colKey = hotColumns.value[dataColIndex].key;
if (colKey === 'cargoAttribute' && value) {
const cargoKey = `order.myOrders.drawer.cargoAttribute.${value}`;
const translated = t(cargoKey);
return translated !== cargoKey ? translated : value;
}
if (colKey === 'orderStatus') {
const code = resolveOrderStatusCode(rowData);
const meta = getOrderStatusMeta(code);
const tagColor = meta?.tagColor ?? '#86909c';
const tagBgColor = meta?.tagBgColor ?? '#f2f3f5';
const statusText = meta ? t(meta.labelKey) : (rowData?.orderStatus || code || '--');
return `<span style="display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; color: ${tagColor}; background-color: ${tagBgColor}; white-space: nowrap;">${statusText}</span>`;
}
if (colKey === 'isPaid') {
const paid = rowData?.isPaid === true || rowData?.isPaid === 1 || rowData?.IsPaid === true || rowData?.IsPaid === 1;
const tagColor = paid ? '#00b42a' : '#86909c';
const tagBgColor = paid ? '#e8f8e8' : '#f2f3f5';
const paidText = paid ? t('order.myOrders.drawer.yes') : t('order.myOrders.drawer.no');
return `<span style="display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; color: ${tagColor}; background-color: ${tagBgColor}; white-space: nowrap;">${paidText}</span>`;
}
if (colKey === 'consigneeCountry') {
const code = rowData?.consigneeCountry || value || '';
const name = rowData?.consigneeCountryName || '';
if (code && name) return `${code} ${name}`;
return name || code || null;
}
if (['chargeableWeight', 'receivableAmount'].includes(colKey)) {
return value != null && value !== '' ? Number(value).toLocaleString() : null;
}
// 首列添加 data-row-status 用于行背景样式
if (colKey === 'waybillNo') {
const statusCode = resolveOrderStatusCode(rowData);
return `<span data-row-status="${statusCode}">${value || '--'}</span>`;
}
return null;
};
const handleActionClick = (row: any) => {
openDetailWithOptionalFetch(row);
};
const handleSelectionChange = (rows: any[]) => {
selectedOrderRows.value = rows ?? [];
selectedRowCount.value = selectedOrderRows.value.length;
};
onMounted(() => {
nextTick(() => {
loadOrderList();
loadTabCounts();
});
});
</script>
<template>
<div class="my-orders-container">
<!-- 标签页导航和操作按钮 -->
<div class="tabs-actions-section">
<div class="tabs-container">
<div
v-for="tab in tabs"
:key="tab.key"
:class="['tab-item', { active: activeTab === tab.key }]"
@click="handleTabChange(tab.key)"
>
<span class="tab-label">{{ tab.label || $t(tab.labelKey) }}</span>
<span v-if="tab.showCount && tab.count != null" class="tab-count">({{ tab.count }})</span>
</div>
</div>
<div class="actions-right">
<a-button class="btn-pay" :loading="actionSubmitting" @click="handlePay">{{ t('order.myOrders.actions.pay') }}</a-button>
<a-button class="btn-predeclare" :loading="actionSubmitting" @click="handlePreDeclare">{{ t('order.myOrders.actions.predeclare') }}</a-button>
<a-button class="btn-track" :loading="actionSubmitting" @click="handleCreateTrackOrder">{{ t('order.myOrders.actions.createTrackOrder') }}</a-button>
<a-button class="btn-downstream" :loading="actionSubmitting" @click="handleForwardDownstreamCreate">{{ t('order.myOrders.actions.forwardDownstreamCreate') }}</a-button>
<a-button class="btn-print" :loading="actionSubmitting" @click="handleSinglePrint">单个打印</a-button>
<a-button class="btn-print" :loading="actionSubmitting" @click="handleBatchPrint">批量打印</a-button>
<a-dropdown trigger="click" position="bl">
<a-button class="btn-settings">
<icon-settings />
</a-button>
<template #content>
<a-doption @click="onMoreActionClick('intercept')">{{ t('order.myOrders.actions.intercept') }}</a-doption>
<a-doption @click="onMoreActionClick('cancelIntercept')">{{ t('order.myOrders.actions.cancelIntercept') }}</a-doption>
<a-doption @click="onMoreActionClick('delete')">{{ t('order.myOrders.actions.delete') }}</a-doption>
<a-doption @click="onMoreActionClick('export')">{{ t('order.myOrders.actions.export') }}</a-doption>
<a-doption @click="onMoreActionClick('modifyOrder')">{{ t('order.myOrders.actions.modifyOrder') }}</a-doption>
</template>
</a-dropdown>
</div>
</div>
<!-- 订单表格区域 -->
<div class="table-section">
<!-- 表格操作按钮和分页控制 -->
<div class="table-toolbar">
<div class="toolbar-left">
<span class="selected-count">
{{ t('order.myOrders.selectedCount', { count: selectedRowCount }) }}
</span>
</div>
<div class="toolbar-right">
<div class="pagination-controls">
<PaginationPro
:total-count="totalCount"
v-model:current-page="currentPage"
v-model:page-size="pageSize"
@page-change="handlePageChange"
@page-size-change="handlePageSizeChange"
/>
</div>
</div>
</div>
<div ref="tableContainerRef" class="list-wrap">
<a-spin :loading="listLoading" class="table-spin">
<HandsontablePro
:key="`${activeTab}-${currentPage}-${orderList.length}`"
:columns="hotColumns"
:data="processedTableData"
:total="totalCount"
:current-page="currentPage"
:page-size="pageSize"
:show-action-column="true"
:action-column-position="'start'"
:action-column-width="60"
:action-renderer="actionRenderer"
:custom-cell-renderer="customCellRenderer"
:stretch-columns="true"
:height="tableHeight"
@action-click="handleActionClick"
@selection-change="handleSelectionChange"
/>
</a-spin>
</div>
</div>
<!-- 订单详情抽屉(左侧) -->
<OrderDetailDrawer
ref="detailDrawerRef"
:order="currentOrder"
@updated="handleOrderDetailUpdated"
/>
<OrderPrintModal v-model:visible="singlePrintVisible" mode="single" :items="singlePrintItems" />
<OrderPrintModal v-model:visible="batchPrintVisible" mode="batch" :items="batchPrintItems" />
<a-modal
v-model:visible="trackUpsertModalVisible"
title="轨迹同步结果"
:width="720"
:footer="false"
>
<pre class="track-upsert-result">{{ trackUpsertResultText }}</pre>
</a-modal>
<a-modal
v-model:visible="downstreamForwardModalVisible"
:title="t('order.myOrders.modal.downstreamForwardTitle')"
:width="800"
:footer="false"
>
<pre class="track-upsert-result">{{ downstreamForwardResultText }}</pre>
</a-modal>
</div>
</template>
<style lang="less" scoped>
.my-orders-container {
width: 100%;
box-sizing: border-box;
padding: 16px 16px 24px;
background-color: #f0f3f4;
flex: 1;
min-height: 0;
overflow-x: hidden;
overflow-y: hidden;
display: flex;
flex-direction: column;
}
.page-header {
margin-bottom: 24px;
h2 {
margin: 0;
font-size: 24px;
font-weight: 600;
color: #262626;
}
}
.tabs-actions-section {
background: #fff;
border-radius: 8px;
padding: 0 16px;
margin-bottom: 16px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
display: flex;
justify-content: space-between;
align-items: center;
flex-shrink: 0;
}
.tabs-container {
display: flex;
align-items: center;
gap: 0;
flex: 1;
}
.tab-item {
padding: 16px 20px;
cursor: pointer;
border-bottom: 3px solid transparent;
transition: all 0.3s;
position: relative;
&:hover {
background-color: #f8f9fa;
}
&.active {
border-bottom-color: var(--app-primary-color);
.tab-label {
color: var(--app-primary-color);
font-weight: 600;
}
}
.tab-label {
font-size: 14px;
color: #262626;
transition: color 0.3s;
}
.tab-count {
font-size: 12px;
color: #8c8c8c;
margin-left: 4px;
}
}
.actions-right {
display: flex;
gap: var(--app-button-gap, 8px);
align-items: center;
padding: 16px 0;
.arco-btn {
border-radius: 4px;
font-weight: 500;
transition: all 0.3s ease;
border: 2px solid;
position: relative;
overflow: hidden;
padding: 8px 16px;
height: auto;
// 支付按钮 - 淡黄色
&.btn-pay {
background: #fffbe6;
border-color: #ffd666;
color: #d46b08;
&:hover:not(:disabled) {
background: #fff7d1;
border-color: #ffc53d;
}
&:active:not(:disabled) {
background: #fff1b8;
border-color: #ffb020;
}
}
// 预报按钮 - 主题色
&.btn-predeclare {
background: var(--app-primary-color);
border-color: var(--app-primary-color);
color: #ffffff;
&:hover:not(:disabled) {
background: var(--app-primary-color-hover);
border-color: var(--app-primary-color-hover);
}
&:active:not(:disabled) {
background: var(--app-primary-color-hover);
border-color: var(--app-primary-color-hover);
}
}
&.btn-track {
background: #fff;
border-color: var(--app-primary-color);
color: var(--app-primary-color);
&:hover:not(:disabled) {
background: rgba(var(--primary-6), 0.06);
}
}
&.btn-downstream {
background: #f6ffed;
border-color: #95de64;
color: #389e0d;
&:hover:not(:disabled) {
background: #d9f7be;
}
}
// 拦截按钮 - 主题色
&.btn-intercept {
background: var(--app-primary-color);
border-color: var(--app-primary-color);
color: #ffffff;
&:hover:not(:disabled) {
background: var(--app-primary-color-hover);
border-color: var(--app-primary-color-hover);
}
&:active:not(:disabled) {
background: var(--app-primary-color-hover);
border-color: var(--app-primary-color-hover);
}
}
// 取消拦截按钮 - 主题色
&.btn-cancel-intercept {
background: var(--app-primary-color);
border-color: var(--app-primary-color);
color: #ffffff;
&:hover:not(:disabled) {
background: var(--app-primary-color-hover);
border-color: var(--app-primary-color-hover);
}
&:active:not(:disabled) {
background: var(--app-primary-color-hover);
border-color: var(--app-primary-color-hover);
}
}
// 删除按钮 - 主题色
&.btn-delete {
background: var(--app-primary-color);
border-color: var(--app-primary-color);
color: #ffffff;
&:hover:not(:disabled) {
background: var(--app-primary-color-hover);
border-color: var(--app-primary-color-hover);
}
&:active:not(:disabled) {
background: var(--app-primary-color-hover);
border-color: var(--app-primary-color-hover);
}
}
// 打印按钮 - 主题色
&.btn-print {
background: var(--app-primary-color);
border-color: var(--app-primary-color);
color: #ffffff;
&:hover:not(:disabled) {
background: var(--app-primary-color-hover);
border-color: var(--app-primary-color-hover);
}
&:active:not(:disabled) {
background: var(--app-primary-color-hover);
border-color: var(--app-primary-color-hover);
}
}
// 导出按钮 - 主题色
&.btn-export {
background: var(--app-primary-color);
border-color: var(--app-primary-color);
color: #ffffff;
&:hover:not(:disabled) {
background: var(--app-primary-color-hover);
border-color: var(--app-primary-color-hover);
}
&:active:not(:disabled) {
background: var(--app-primary-color-hover);
border-color: var(--app-primary-color-hover);
}
}
// 修改订单按钮 - 主题色
&.btn-modify {
background: var(--app-primary-color);
border-color: var(--app-primary-color);
color: #ffffff;
&:hover:not(:disabled) {
background: var(--app-primary-color-hover);
border-color: var(--app-primary-color-hover);
}
&:active:not(:disabled) {
background: var(--app-primary-color-hover);
border-color: var(--app-primary-color-hover);
}
}
// 设置按钮 - 主题色
&.btn-settings {
background: var(--app-primary-color);
border-color: var(--app-primary-color);
color: #ffffff;
padding: 8px 12px;
min-width: 36px;
&:hover:not(:disabled) {
background: var(--app-primary-color-hover);
border-color: var(--app-primary-color-hover);
}
&:active:not(:disabled) {
background: var(--app-primary-color-hover);
border-color: var(--app-primary-color-hover);
}
}
// 禁用状态
&:disabled {
opacity: 1;
cursor: not-allowed;
background: rgba(169, 169, 169, 0.8) !important;
border-color: rgba(169, 169, 169, 0.8) !important;
color: #ffffff !important;
transform: none !important;
box-shadow: none !important;
}
}
}
.table-section {
background: #fff;
border-radius: 8px;
padding: 0;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
overflow: hidden;
}
.table-toolbar {
padding: 16px 16px 0;
margin-bottom: 16px;
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: nowrap;
.toolbar-left {
flex: 1;
.selected-count {
font-size: 14px;
color: #4e5969;
.count-number {
color: #f53f3f;
font-weight: 600;
margin: 0 2px;
}
}
}
.toolbar-right {
.pagination-controls {
display: flex;
align-items: center;
}
}
}
.table-spin {
width: 100%;
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
:deep(.arco-spin) {
width: 100%;
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
}
:deep(.arco-spin-children) {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
}
}
.list-wrap {
width: 100%;
overflow: hidden;
flex: 1;
min-height: 0;
padding: 0 16px 16px;
box-sizing: border-box;
display: flex;
flex-direction: column;
overscroll-behavior: contain;
touch-action: pan-x pan-y;
:deep(.handsontable-pro-container) {
width: 100%;
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
}
.handsontable-wrapper {
width: 100%;
:deep(.handsontable) {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
border: none !important;
// 覆盖 Handsontable 默认的 table 边框
table {
border: none !important;
}
.ht_master,
.ht_clone_top,
.ht_clone_left,
.ht_clone_corner {
border: none !important;
}
.wtHolder {
border: none !important;
}
.htCore {
border-collapse: separate;
border-spacing: 0;
border: none !important;
td {
border-right: 0.5px solid #f0f0f0 !important;
border-bottom: 0.5px solid #f0f0f0 !important;
border-top: none !important;
border-left: none !important;
padding: 7px 16px;
font-size: 13px;
line-height: 1.4;
color: #262626;
transition: all 0.2s ease;
background: #fff;
text-align: center !important;
vertical-align: middle !important;
&:hover {
background-color: #fafafa;
}
}
tr {
transition: all 0.2s ease;
&:hover {
td {
// hover时,如果单元格已经有背景色(状态背景),则稍微加深
// 否则使用默认hover颜色
&:not([style*="background-color"]) {
background-color: #fafafa;
}
}
}
}
th {
background: #f5f5f5 !important; // 表头背景颜色改为淡灰色
border-right: 0.5px solid #f0f0f0 !important;
border-bottom: 0.5px solid #f0f0f0 !important;
border-top: none !important;
border-left: none !important;
}
// 根据订单状态设置行背景
tbody tr:has([data-row-status="problematic"]) td {
background-color: #fff1f0 !important;
}
tbody tr:has([data-row-status="pendingPayment"]) td {
background-color: #fffbe6 !important;
}
// 操作列眼睛图标 hover
.view-icon-wrapper {
&:hover {
background-color: var(--app-primary-color-light, #e6f7f7);
svg {
color: var(--app-primary-color-hover) !important;
}
}
}
// 隐藏筛选图标的边框
.changeType {
border: none !important;
box-shadow: none !important;
background: transparent !important;
}
// 隐藏筛选图标容器的边框
.ht_master .ht_clone_top th .changeType,
.ht_clone_top th .changeType,
.htCore th .changeType,
th .changeType {
border: none !important;
box-shadow: none !important;
background: transparent !important;
}
}
.ht_master .wtHolder {
overflow: auto;
}
.handsontableInput {
display: none;
}
}
}
}
// 响应式设计
@media (max-width: 768px) {
.tabs-container {
overflow-x: auto;
flex-wrap: nowrap;
}
.actions-right {
flex-wrap: wrap;
gap: 4px;
}
.action-btn {
font-size: 12px;
padding: 0 8px;
height: 28px;
}
}
.track-upsert-result {
margin: 0;
max-height: 480px;
overflow: auto;
padding: 12px;
background: #f7f8fa;
border-radius: 4px;
font-size: 12px;
line-height: 1.6;
white-space: pre-wrap;
word-break: break-all;
}
</style>