WMS_PDA/src/components/WorkbenchPrint/WorkbenchPrint.vue
zm2000 35113f7fe0 fix: 收货明细弹窗样式优化与真机按钮间隔修复
- 收货任务详情(receivingDetail)
  - 收货明细弹窗参考“更多操作”弹窗:标题/顶部圆角/间距对齐,整体弹窗调高、标题与底部固定区调矮
  - 弹窗内容与各面板字号统一:标题40rpx、正文36rpx、汇总值34rpx加粗、标签/时间30rpx
  - 底部新增固定「关闭/确认收货」按钮(蓝色36rpx)
  - 确认删除、商品信息不完整、完成收货由 uni.showModal 改为自定义弹窗(参考整单作废/确认删除样式)
  - 各面板左右留白收窄并对齐

- 收货清单(receivingList)
  - 标签文字与冒号之间增加间隔(label-colon),创建/更新时间标签同步处理

- 打印(WorkbenchPrint)
  - 打印选项及工作台/打印机/模板选择弹窗底部按钮间隔由 flex gap 改为兄弟选择器 margin-left,兼容旧真机

- 首页(index)
  - 通知信息标题与数值加粗 font-weight: 600 → bold

- 库位查询(locationInquiry)
  - 启用筛选时不提示查询到的商品数量,避免与底部筛选后合计不一致
2026-11-23 17:59:03 +08:00

541 lines
13 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.

<!-- components/workbench-print.vue -->
<template>
<view class="container">
<view class="workbench-print">
<!-- 内容区域 -->
<scroll-view scroll-y class="scroll-container">
<view class="section">
<!-- 工作台选择 -->
<view class="detail-item selectable" @click="showWorkbenchSelector = true">
<text class="detail-item-label">选择打印台:</text>
<view class="detail-item-value">
<text>{{ selectedWorkbench ? selectedWorkbench.name : "点击选择打印台" }}</text>
<u-icon name="arrow-right" size="24" color="#666"></u-icon>
</view>
</view>
<!-- 打印机选择(工作台选中后出现) -->
<view class="detail-item selectable" v-if="selectedWorkbench" @click="showPrinterSelector = true">
<text class="detail-item-label">打印机:</text>
<view class="detail-item-value">
<text>{{ selectedPrinter ? selectedPrinter.name : "点击选择打印机" }}</text>
<u-icon name="arrow-right" size="24" color="#666"></u-icon>
</view>
</view>
<!-- 打印模板选择 -->
<view class="detail-item selectable" @click="showTemplateSelector = true"
v-if="printData.type != 'express'">
<text class="detail-item-label">打印模板:</text>
<view class="detail-item-value">
<text>{{ selectedTemplate ?
`${selectedTemplate.template_name}【${selectedTemplate.page_width} *
${selectedTemplate.page_height}】` : "点击选择打印模板" }}</text>
<u-icon name="arrow-right" size="24" color="#666"></u-icon>
</view>
</view>
<view v-else></view>
</view>
</scroll-view>
<!-- 操作按钮 -->
<view class="action-buttons">
<u-button type="info" @click="handleCancel">
取消
</u-button>
<u-button type="primary" :disabled="!selectedWorkbench || !selectedTemplate || !selectedPrinter"
@click="handlePrint" :loading="printing">
{{ printing ? '打印中...' : '开始打印' }}
</u-button>
</view>
</view>
<!-- 工作台选择弹窗 -->
<u-popup :show="showWorkbenchSelector" mode="bottom" round="20" closeable @close="showWorkbenchSelector = false">
<view class="workbench-selector-popup">
<view class="popup-header">
<text class="popup-title">选择打印工作台</text>
</view>
<scroll-view scroll-y class="workbench-list" style="height: 40vh;">
<view v-for="workbench in workbenchList" :key="workbench.id" class="workbench-item"
:class="{ selected: selectedWorkbench && selectedWorkbench.id === workbench.id }"
@click="selectWorkbench(workbench)">
<u-icon name="coupon" size="40" color="#2979ff"></u-icon>
<view class="workbench-info">
<text class="workbench-name">{{ workbench.name }}</text>
</view>
<u-icon v-if="selectedWorkbench && selectedWorkbench.id === workbench.id" name="checkbox-mark"
size="28" color="#2979ff"></u-icon>
</view>
<view v-if="workbenchList.length === 0" class="empty-state">
<u-icon name="server-man" size="60" color="#ccc"></u-icon>
<text class="empty-text">暂无可用工作台</text>
</view>
</scroll-view>
<view class="popup-actions">
<u-button type="info" @click="showWorkbenchSelector = false">取消</u-button>
<u-button type="primary" @click="confirmWorkbenchSelection" :disabled="!selectedWorkbench">
确定
</u-button>
</view>
</view>
</u-popup>
<!-- 打印机选择弹窗 -->
<u-popup :show="showPrinterSelector" mode="bottom" round="20" closeable @close="showPrinterSelector = false">
<view class="printer-selector-popup">
<view class="popup-header">
<text class="popup-title">选择打印机</text>
</view>
<scroll-view scroll-y class="printer-list" style="height: 40vh;">
<view v-for="printer in printerList" :key="printer.id" class="printer-item"
:class="{ selected: selectedPrinter && selectedPrinter.name === printer.name }"
@click="selectPrinter(printer)">
<view class="printer-info">
<text class="printer-name">{{ printer.name }}</text>
</view>
<u-icon v-if="selectedPrinter && selectedPrinter.name === printer.name" name="checkbox-mark"
size="28" color="#2979ff"></u-icon>
</view>
<view v-if="printerList.length === 0" class="empty-state">
<u-icon name="printer-man" size="60" color="#ccc"></u-icon>
<text class="empty-text">暂无可用打印机</text>
</view>
</scroll-view>
<view class="popup-actions">
<u-button type="info" @click="showPrinterSelector = false">取消</u-button>
<u-button type="primary" @click="confirmPrinterSelection" :disabled="!selectedPrinter">
确定
</u-button>
</view>
</view>
</u-popup>
<!-- 打印模板选择弹窗 -->
<u-popup :show="showTemplateSelector" mode="bottom" round="20" closeable @close="showTemplateSelector = false">
<view class="template-selector-popup">
<view class="popup-header">
<text class="popup-title">选择打印模板</text>
</view>
<scroll-view scroll-y class="template-list" style="height: 40vh;">
<view v-for="template in templateList" :key="template.id" class="template-item"
:class="{ selected: selectedTemplate && selectedTemplate.id === template.id }"
@click="selectTemplate(template)">
<view class="template-info">
<text class="template-name">{{ template.template_name }}【{{ template.page_width }} * {{
template.page_height }}】</text>
</view>
<u-icon v-if="selectedTemplate && selectedTemplate.id === template.id" name="checkbox-mark"
size="28" color="#2979ff"></u-icon>
</view>
<view v-if="templateList.length === 0" class="empty-state">
<u-icon name="file-text" size="60" color="#ccc"></u-icon>
<text class="empty-text">暂无可用模板</text>
</view>
</scroll-view>
<view class="popup-actions">
<u-button type="info" @click="showTemplateSelector = false">取消</u-button>
<u-button type="primary" @click="confirmTemplateSelection" :disabled="!selectedTemplate">
确定
</u-button>
</view>
</view>
</u-popup>
</view>
</template>
<script>
export default {
name: 'WorkbenchPrint',
props: {
printData: {
type: Object,
default: () => ({})
}
},
data() {
return {
//显示弹窗相关
showWorkbenchSelector: false,
showTemplateSelector: false,
showPrinterSelector: false,
// 工作台相关
workbenchList: [],
selectedWorkbench: null,
// 打印机相关
printerList: [],
selectedPrinter: null,
// 模板相关
templateList: [],
selectedTemplate: null,
// 状态相关
printing: false,
}
},
mounted() {
this.init();
},
methods: {
// 初始化
async init() {
await this.loadWorkbenchList();
await this.loadTemplateList();
},
// 加载工作台列表
async loadWorkbenchList() {
try {
const workbenches = await this.$http('print.getList');
console.log('工作台列表:', workbenches);
if (workbenches.code == "200") {
this.workbenchList = workbenches.data.list || [];
console.log("工作台列表:", this.workbenchList);
} else {
throw new Error(workbenches.message || '加载工作台失败');
}
} catch (error) {
console.error('加载工作台列表失败:', error);
uni.showToast({
title: '加载工作台失败',
icon: 'none'
});
}
},
// 加载模板列表
async loadTemplateList() {
try {
const templates = await this.$http('common.listTemplatesByType', {
businessType: this.printData.type
});
console.log('模板列表:', templates);
if (templates.code == "200") {
this.templateList = templates.data || [];
console.log("模板列表:", this.templateList);
} else {
throw new Error(templates.message || '加载模板失败');
}
} catch (error) {
console.error('加载模板列表失败:', error);
uni.showToast({
title: '加载模板失败',
icon: 'none'
});
}
},
// 选择工作台
// 选择工作台
async selectWorkbench(workbench) {
this.selectedWorkbench = workbench;
},
async selectPrinter(printer) {
this.selectedPrinter = printer;
},
// 加载打印机列表
async loadPrinterList(workbenchId) {
try {
const res = await this.$http("print.getComputerPrinter", {
id: workbenchId
});
this.printerList = res.data || [];
this.printerList.forEach(printer => {
if(this.selectedWorkbench.default_printer && printer.printer_name === this.selectedWorkbench.default_printer){
this.selectedPrinter = printer;
}
});
} catch (error) {
this.printerList = [];
uni.showToast({ title: '加载打印机失败', icon: 'none' });
}
},
// 确认工作台选择
async confirmWorkbenchSelection() {
this.showWorkbenchSelector = false;
// 选择后加载打印机列表
await this.loadPrinterList(this.selectedWorkbench.id);
//检查默认打印机是否在列表中
console.log("选择的工作台:", this.selectedWorkbench);
console.log("打印机列表:", this.printerList);
this.selectedPrinter = null;
if(this.selectedWorkbench.default_printer_name){
const defaultPrinter = this.printerList.find(printer => printer.name === this.selectedWorkbench.default_printer_name);
if(defaultPrinter){
this.selectedPrinter = defaultPrinter;
}
}
},
async confirmPrinterSelection() {
this.showPrinterSelector = false;
},
// 选择模板
selectTemplate(template) {
this.selectedTemplate = template;
},
// 确认模板选择
confirmTemplateSelection() {
this.showTemplateSelector = false;
},
// 取消打印选项弹窗
handleCancel() {
this.$emit('cancel');
},
// 处理打印
async handlePrint() {
if (!this.selectedWorkbench) {
uni.showToast({
title: '请选择打印工作台',
icon: 'none'
});
return;
}
if (!this.selectedTemplate) {
uni.showToast({
title: '请选择打印模板',
icon: 'none'
});
return;
}
this.printing = true;
try {
const printInfo = {
type: "customize",
computerId: this.selectedWorkbench.id,
template: this.selectedTemplate,
data: this.printData.value,
printer: this.selectedPrinter.name,
timestamp: Date.now(),
size: 1
};
// 调用打印API
const res = await this.$store.dispatch('print/sendPrint', printInfo);
console.log(res);
if (res.flag == "failure") {
uni.showToast({
title: res.message || '打印失败',
icon: 'failure'
});
} else {
uni.showToast({
title: '打印任务已发送',
icon: 'success'
});
}
// 触发父组件事件
this.$emit('print', printInfo);
} catch (error) {
console.error('打印失败:', error);
uni.showToast({
title: error.message || '打印失败',
icon: 'none'
});
} finally {
this.printing = false;
}
}
}
}
</script>
<style scoped lang="scss">
.container {
width: 100%;
height: 100%;
}
.workbench-print {
height: 100%;
padding: 20rpx;
display: flex;
flex-direction: column;
box-sizing: border-box;
.scroll-container {
flex: 1;
}
.section {
padding-bottom: 40rpx;
}
.detail-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 24rpx 0;
border-bottom: 1rpx solid #f5f5f5;
&.selectable {
cursor: pointer;
&:active {
background-color: #f9f9f9;
}
}
.detail-item-label {
font-size: 36rpx;
color: #333;
font-weight: 500;
}
.detail-item-value {
display: flex;
align-items: center;
gap: 16rpx;
font-size: 36rpx;
color: #666;
max-width: 60%;
text-align: right;
text {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}
.action-buttons {
margin-top: auto;
padding-top: 30rpx;
border-top: 1rpx solid #eee;
display: flex;
::v-deep .u-button {
flex: 1;
font-size: 36rpx !important;
}
::v-deep .u-button + .u-button {
margin-left: 24rpx;
}
}
}
.printer-selector-popup,
.workbench-selector-popup,
.template-selector-popup {
background-color: #fff;
border-radius: 40rpx 40rpx 0 0;
overflow: hidden;
.popup-header {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
padding: 32rpx 30rpx 24rpx;
flex-shrink: 0;
border-bottom: 1rpx solid #f0f0f0;
.popup-title {
font-size: 38rpx;
font-weight: bold;
color: #333;
}
}
.workbench-list,
.printer-list,
.template-list {
padding: 24rpx 32rpx;
box-sizing: border-box;
.workbench-item,
.printer-item,
.template-item {
display: flex;
align-items: center;
padding: 24rpx;
margin-bottom: 16rpx;
border-radius: 16rpx;
border: 2rpx solid #eee;
&:active {
background-color: #f9f9f9;
}
&.selected {
border-color: #2979ff;
background-color: #f0f7ff;
}
.workbench-info,
.printer-info,
.template-info {
flex: 1;
margin-left: 24rpx;
.workbench-name,
.printer-name,
.template-name {
font-size: 36rpx;
color: #333;
font-weight: 500;
}
}
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
padding: 80rpx 0;
.empty-text {
margin-top: 24rpx;
font-size: 36rpx;
color: #999;
}
}
}
.popup-actions {
display: flex;
padding: 24rpx 32rpx;
border-top: 1rpx solid #f0f0f0;
.u-button {
flex: 1;
}
::v-deep .u-button {
font-size: 36rpx !important;
}
::v-deep .u-button + .u-button {
margin-left: 24rpx;
}
}
}
</style>