Merge remote-tracking branch 'origin/main' into main
CI / server typecheck + tests (push) Canceled after 0s
CI / web typecheck + tests + miniprogram syntax (push) Canceled after 0s
CI / eslint (观察项,C7 骨架) (push) Canceled after 0s
CI / npm audit (critical 硬拦) (push) Canceled after 0s

This commit is contained in:
Ubuntu
2026-10-14 14:20:15 +08:00
2 changed files with 59 additions and 24 deletions
@@ -85,6 +85,32 @@ Web 改为**浏览器打印**(当前页宿主 + `window.print()`,打到热
各管各**);明细弹层商品格内加「打印标签」小按钮,点击即打该行一张标签。
- 文案**不新增 key**:复用既有 `picking.modal.printLabel`(`打印标签` / `Print labels` / `Cetak label`)。
### 2.4 打印机选择弹层必须 `root-portal`(2026-10-14 现场修复「弹窗被遮挡」)
**现象**(开发者真机截图):分拣面板点「打印」弹出「选择蓝牙热敏机」后,弹窗**不居中、且下半部分被底部
「一键确认 / 分拣完成」条与底部 tab 栏(工作台/通知/我的)盖住**,看不见设备列表与「重新搜索 / 取消」。
**根因**(两因叠加,都在页面层):
1. 三个面板都嵌在 `pages/home` 的 `<view class="home-purchase-embed anim-rise anim-rise--delay-2">` 工作区里;
`.anim-rise` 用 `animation: rise-in ... both`,最后一帧是 `transform: translateY(0)` ⇒ **动画结束后永久保留**
一个非 `none` 的 `transform` ⇒ 该容器成为 `position: fixed` 的**包含块**(`top:50%` 按整块工作区算,
不再按视口)并自建**层叠上下文**。
2. `van-popup` 默认 `z-index = 100`;底部 tab 栏 `app-tab-bar .tab-bar` 也是 `z-index: 100`,
而 tab 栏在工作区**之后**(`home.wxml` 末尾)⇒ 同 z-index 后绘者胜,弹层被盖。
**处置**(`components/ble-printer-sheet/index.wxml`):弹层外面包 `<root-portal enable="{{true}}">`
(弹层挂到**页面根**:脱离包含块 ⇒ 重新按视口居中;z-index 回到页面根参与比较)+ `van-popup z-index="10000"`
(高于 tab 栏 100 与底栏 99,与面板内其它弹层 `batch-mask`/`modal-mask` 同值)。
> 这是本仓库**既有做法**:`picking-panel` 的底栏/批量框、`preparation-panel` 的底栏/报告框、
> `purchase-today-panel` 的三个弹层、`processing-panel` / `admin-preparations-panel` / `order-entry-panel` /
> `cost-management-panel` / `product-trace-panel` / `bid-panel` 的弹层**全部外包 `root-portal`**;
> 本次只是给 `ble-printer-sheet` 补上(漏网的唯一一个)。
> ⚠️ 与「弹层改居中」同一理由:该组件为**共享件**,备货 / 采购 / 分拣三面板同时受益。
> ⚠️ 未顺手改 `.anim-rise`(去掉保留 transform 会影响整个工作区的固定元素定位)——只回修弹层自身。
> ⚠️ `stock-inbound-panel` 的 `.sheet-mask`(z-index 999,未 portal)是**同类隐患**,本次不动,仅登记。
## 3. 不动的(冻结面)
- **旧链路**:`print_jobs` / `weigh_devices` / `printJobService` / `mobilePickingPrintService` /
@@ -107,7 +133,7 @@ Web 改为**浏览器打印**(当前页宿主 + `window.print()`,打到热
| `miniprogram/components/picking-panel/index.wxml` | 改 | 行内「打印」按钮 + canvas + ble-printer-sheet |
| `miniprogram/components/picking-panel/index.wxss` | 改 | `.print-canvas`(复用既有 `.btn-print-row`) |
| `miniprogram/components/picking-panel/index.json` | 改 | 注册 `ble-printer-sheet` |
| `miniprogram/components/ble-printer-sheet/index.wxml` | 改 | 弹层改居中(`position="center"`) |
| `miniprogram/components/ble-printer-sheet/index.wxml` | 改 | 弹层改居中(`position="center"`);**外包 `root-portal` + `z-index=10000`**(§2.4,修「弹窗被底部 tab 栏遮住」) |
| `miniprogram/components/ble-printer-sheet/index.wxss` | 改 | 居中卡片样式 |
| `src/utils/pickingLabelPrint.ts` | 新增 | 生成 50×30mm 标签 HTML(同旧秤端版式)+ 走浏览器打印 |
| `src/utils/pickingLabelPrint.test.ts` | 新增 | 契约测试(纸宽/多页/转义/二维码/重量行换算) |
@@ -117,7 +143,8 @@ Web 改为**浏览器打印**(当前页宿主 + `window.print()`,打到热
- [ ] 小程序分拣面板每行出现「打印」按钮;点按能连已绑定 BLE 热敏机打出与旧秤端**同版式**的标签
(分拣标签 / 客户 / 品名 / 重量:X.XX 斤 / 日期 + 右上二维码及码文;无订单号)。
- [ ] 未绑定打印机时点「打印」弹出 `ble-printer-sheet` 选择设备并保存;**该弹层为居中弹窗**。
- [ ] 未绑定打印机时点「打印」弹出 `ble-printer-sheet` 选择设备并保存;**该弹层为居中弹窗**,
**设备列表与「重新搜索 / 取消」完整可见**(不得被底部按钮条 / 底部 tab 栏遮住,见 §2.4)。
- [ ] Web 分拣明细弹层每行出现「打印标签」;点按生成 **50×30mm** 标签页(同版式、含内联二维码)并弹浏览器打印对话框。
- [ ] 多行一次传入 = 多页标签(一签一页;当前 UI 为「一行一按钮」,多页能力已就绪),由 `pickingLabelPrint.test.ts` 钉住。
- [ ] 小程序「备货历史 / 采购历史」打印**行为与产物不变**(`thermalPrint` 默认分支未改)。
@@ -141,3 +168,4 @@ Web 改为**浏览器打印**(当前页宿主 + `window.print()`,打到热
| v1 | 2026-10-13 | 分拣标签打印换通道:小程序 BLE 热敏 + Web 浏览器打印;不走旧 `print_jobs` 链路 |
| v2 | 2026-10-13 | 标签加**二维码**(当时误取装框码);`ble-printer-sheet` 弹层改**居中**(共享组件,同影响备货/采购面板) |
| v3 | 2026-10-13 | 按「与旧秤端逐项一致」重做版式:标题「分拣标签」+ 客户/品名/重量(斤)/日期 + 右上二维码及码文,**不印订单号**;二维码内容回到**商品条码**;Web 纸宽 58mm→**50×30mm** |
| v4 | 2026-10-14 | 修现场「打印机选择弹窗被遮挡」:弹层外包 `root-portal` + `z-index=10000`(§2.4) |
@@ -1,23 +1,30 @@
<van-popup show="{{show}}" position="center" bind:close="onClose">
<view class="sheet">
<view class="sheet-title">选择蓝牙热敏机</view>
<view class="sheet-hint">只连 BLE 小票机。得力 M1022W 等 A4 激光机请用「A4 文档」打印,不要在这里搜索。</view>
<view wx:if="{{error}}" class="sheet-error">{{error}}</view>
<view wx:if="{{scanning}}" class="sheet-muted">正在搜索附近设备…</view>
<view wx:elif="{{!devices.length && !error}}" class="sheet-muted">未发现带名称的 BLE 设备,请打开打印机并靠近手机</view>
<view
wx:for="{{devices}}"
wx:key="deviceId"
class="device-row"
data-id="{{item.deviceId}}"
bindtap="onPick"
>
<view class="device-name">{{item.name}}</view>
<view class="device-rssi">信号 {{item.RSSI}}</view>
<!-- 必须 root-portal:三个面板(分拣/备货/采购)都嵌在 pages/home 的
`.home-purchase-embed.anim-rise` 工作区里,该容器因 `animation-fill-mode: both`
永久保留 `transform: translateY(0)` ⇒ 成为 `position: fixed` 的包含块,
弹层既不按视口居中,又困在它的层叠上下文内,被底部 tab 栏(`.tab-bar` z-index:100)盖住。
z-index 取 10000,与面板内其它弹层(batch-mask / modal-mask)一致。 -->
<root-portal enable="{{true}}">
<van-popup show="{{show}}" position="center" z-index="10000" bind:close="onClose">
<view class="sheet">
<view class="sheet-title">选择蓝牙热敏机</view>
<view class="sheet-hint">只连 BLE 小票机。得力 M1022W 等 A4 激光机请用「A4 文档」打印,不要在这里搜索。</view>
<view wx:if="{{error}}" class="sheet-error">{{error}}</view>
<view wx:if="{{scanning}}" class="sheet-muted">正在搜索附近设备…</view>
<view wx:elif="{{!devices.length && !error}}" class="sheet-muted">未发现带名称的 BLE 设备,请打开打印机并靠近手机</view>
<view
wx:for="{{devices}}"
wx:key="deviceId"
class="device-row"
data-id="{{item.deviceId}}"
bindtap="onPick"
>
<view class="device-name">{{item.name}}</view>
<view class="device-rssi">信号 {{item.RSSI}}</view>
</view>
<view class="sheet-actions">
<view class="sheet-btn" bindtap="scan">重新搜索</view>
<view class="sheet-btn sheet-btn--ghost" bindtap="onClose">取消</view>
</view>
</view>
<view class="sheet-actions">
<view class="sheet-btn" bindtap="scan">重新搜索</view>
<view class="sheet-btn sheet-btn--ghost" bindtap="onClose">取消</view>
</view>
</view>
</van-popup>
</van-popup>
</root-portal>