@@ -193,6 +197,7 @@ const exportLoading = ref(false)
const total = ref(2) // 列表的总页数
const list = ref
([]) // 列表的数据
const queryFormRef = ref() // 搜索的表单
+const selectedOrders = ref([]) // 选中的订单列表
// 表单搜索
const queryParams = ref({
pageNo: 1, // 页数
@@ -287,6 +292,33 @@ const resetQuery = () => {
handleQuery()
}
+/** 处理订单选择变化 */
+const handleSelectionChange = (selection: TradeOrderApi.OrderVO[]) => {
+ selectedOrders.value = selection
+ console.log('当前已选中订单数量:', selection.length)
+}
+
+/** 批量打印 */
+const handleBatchPrint = () => {
+ if (selectedOrders.value.length === 0) {
+ ElMessage.warning('请先选择要打印的订单')
+ return
+ }
+
+ // 筛选有物流面单的订单
+ const ordersWithLabel = selectedOrders.value.filter(order => order.logisticsLabel)
+
+ if (ordersWithLabel.length === 0) {
+ ElMessage.warning('所选订单中没有可打印的物流面单')
+ return
+ }
+
+ ElMessage.success(`准备打印${ordersWithLabel.length}个订单的物流面单`)
+
+ // 在一个新窗口中展示所有面单
+ openBatchPrintWindow(ordersWithLabel)
+}
+
/** 查看订单详情 */
const openDetail = (id: number) => {
push({ name: 'TradeOrderDetail', params: { id } })
@@ -347,6 +379,132 @@ onMounted(async () => {
})
+/** 批量打开多个订单的面单在一个窗口 */
+const openBatchPrintWindow = (orders: TradeOrderApi.OrderVO[]) => {
+ // 生成所有订单的HTML内容
+ const ordersHtml = orders.map((order, index) => {
+ const orderItems = order.items || []
+ const productText = orderItems.map(item => `${item.spuName} × ${item.count}`).join('
')
+
+ return `
+ 0 ? 'style="page-break-before: always;"' : ''}>
+
+

+
+ ${productText}
+
+
+
+ `
+ }).join('')
+
+ const htmlContent = `
+
+
+
+
+
+ 批量打印物流面单 (共${orders.length}个订单)
+
+
+
+
+
+
+ ${ordersHtml}
+
+
+ `
+
+ // 在新窗口中打开
+ const newWindow = window.open('', '_blank', 'scrollbars=yes,resizable=yes')
+ if (newWindow) {
+ newWindow.document.write(htmlContent)
+ newWindow.document.close()
+ // 窗口最大化
+ newWindow.moveTo(0, 0)
+ newWindow.resizeTo(screen.width, screen.height)
+ } else {
+ ElMessage.error('无法打开新窗口,请检查浏览器弹窗设置')
+ }
+}
+
/** 在新窗口打开带文字的图片 */
const openInNewWindow = () => {
if (!rowLogisticsLabel.value || !currentOrderRow.value) {