feat(ui): 分组卡分原料/普通、滑动翻页、顶栏按工位改名

- 分组卡分开显示「独立入库原料 12 斤 · 普通入库 20 斤」;
  混合组不再误标成独立入库
- 待办列表支持左右滑动翻页(左划下一页 / 右划上一页);
  竖向、斜向、短距离滑动不触发,也不影响点卡选中
- 顶栏与窗口标题按工位改名:分拣工作站 / 入库工作站,
  logo 字同步(拣 / 入);退出登录回到「… - 登录」
- 版本号统一到 1.0.68(含 assets/version_info.txt)
This commit is contained in:
雨天
2026-11-22 20:15:32 +08:00
parent dde18c1d87
commit a74edd316e
6 changed files with 297 additions and 12 deletions
+3 -3
View File
@@ -1,16 +1,16 @@
VSVersionInfo(
ffi=FixedFileInfo(filevers=(1, 0, 66, 0), prodvers=(1, 0, 66, 0),
ffi=FixedFileInfo(filevers=(1, 0, 67, 0), prodvers=(1, 0, 67, 0),
mask=0x3f, flags=0x0, OS=0x40004, fileType=0x1,
subtype=0x0, date=(0, 0)),
kids=[
StringFileInfo([StringTable('080404B0', [
StringStruct('CompanyName', '配送中心'),
StringStruct('FileDescription', '入库分拣工作站'),
StringStruct('FileVersion', '1.0.67.0'),
StringStruct('FileVersion', '1.0.68.0'),
StringStruct('InternalName', 'WeighStation'),
StringStruct('OriginalFilename', '入库分拣工作站.exe'),
StringStruct('ProductName', '入库分拣工作站'),
StringStruct('ProductVersion', '1.0.67.0'),
StringStruct('ProductVersion', '1.0.68.0'),
StringStruct('LegalCopyright', '内部使用')])]),
VarFileInfo([VarStruct('Translation', [2052, 1200])])
]
+44 -2
View File
@@ -291,9 +291,51 @@ class ApiClient:
'grouped_inbound': True,
'group_lines': lines,
})
# 独立入库在分组键里带 independent 段;服务端没回 processing_details 时靠它识别。
# 组内可能同时有「独立入库·加工原材料」和普通订单行:把两边的量
# 算出来挂在行上,卡片才能分开显示(以前只挂一个“独立入库”标签,
# 32 斤看着像全是原料)。
try:
from core.matching.engine import is_independent_inbound
except Exception: # noqa: BLE001
def is_independent_inbound(_r): # type: ignore
return False
parts = {}
for i in ids:
fr = flat_by_id.get(i) or {}
kind = ('independent' if is_independent_inbound(fr)
else 'normal')
try:
q = float(fr.get('remaining_qty')
or fr.get('required_qty')
or fr.get('prepare_qty') or 0)
except (TypeError, ValueError):
q = 0.0
p = parts.setdefault(kind, {'kind': kind, 'qty': 0.0,
'rows': 0})
p['qty'] += q
p['rows'] += 1
if parts:
row['group_parts'] = [parts[k] for k in
('independent', 'normal') if k in parts]
# 独立入库在分组键里带 independent 段;服务端没回 processing_details
# 时靠它识别。但组里混有普通订单行时不能把整组标成独立入库。
gkey = str(g.get('group_key') or '').lower()
if (not row.get('processing_details')) and 'independent' in gkey:
only_indep = bool(parts) and all(
p['kind'] == 'independent' for p in parts.values())
mixed = bool(parts) and not only_indep
if mixed:
# 组里混有普通订单行:整组不能当“独立入库”去走单行结案。
# 标记是从首行(flat base)继承过来的,得清掉。
pd = row.get('processing_details')
if isinstance(pd, dict):
pd = dict(pd)
pd['independent_inbound'] = False
row['processing_details'] = pd
else:
row.pop('processing_details', None)
row.pop('independent_inbound', None)
elif (not row.get('processing_details')) and 'independent' in gkey \
and (only_indep or not parts):
row['processing_details'] = {'independent_inbound': True}
out.append(row)
return out
+4 -1
View File
@@ -112,7 +112,10 @@ def _activate_existing():
import ctypes
u = ctypes.windll.user32
h = (u.FindWindowW(None, '入库分拣工作站 - 登录')
or u.FindWindowW(None, '入库分拣工作站'))
or u.FindWindowW(None, '入库分拣工作站')
# v1.0.68:作业界面按工位改名了
or u.FindWindowW(None, '分拣工作站')
or u.FindWindowW(None, '入库工作站'))
if h:
u.ShowWindow(h, 9) # SW_RESTORE:最小化状态也能拉回来
u.BringWindowToTop(h)
+101
View File
@@ -327,6 +327,107 @@ simg.cfg['camera']['simulate'] = False
simg._learn_sample({'item_name': '苹果'})
check('真实摄像头才存样本', added == ['苹果'], str(added))
print('=== 15. 分组行拆出原料/普通各自的量 ===')
grouper = ApiClient({'server': {'base_url': 'http://x', 'mock': True},
'account': {}})
flat = [
{'id': 'g1', 'item_name': '冬瓜', 'unit': '斤', 'remaining_qty': 12,
'processing_details': {'independent_inbound': True}},
{'id': 'g2', 'item_name': '冬瓜', 'unit': '斤', 'remaining_qty': 20},
]
groups = [{'inspection_ids': ['g1', 'g2'],
'group_key': 'BR003|-|independent|purchase|SKU1|斤',
'group_hash': 'h1', 'item_name': '冬瓜', 'unit': '斤',
'total_prepare_qty': 32, 'lines': []}]
rows = grouper._preview_group_rows(groups, flat)
check('分组行算出来了', len(rows) == 1, str(len(rows)))
parts = {p['kind']: p for p in (rows[0].get('group_parts') or [])}
check('原料 12 斤', parts.get('independent', {}).get('qty') == 12.0,
str(parts))
check('普通 20 斤', parts.get('normal', {}).get('qty') == 20.0, str(parts))
from core.matching.engine import is_independent_inbound as _is_indep
check('混合组不能整组标成独立入库',
not _is_indep(rows[0]),
str(rows[0].get('processing_details')))
all_ind = [
{'id': 'x1', 'unit': '斤', 'remaining_qty': 5,
'processing_details': {'independent_inbound': True}},
{'id': 'x2', 'unit': '斤', 'remaining_qty': 7,
'processing_details': {'independent_inbound': True}},
]
rows2 = grouper._preview_group_rows(
[{'inspection_ids': ['x1', 'x2'],
'group_key': 'BR003|-|independent|purchase|SKU2|斤',
'group_hash': 'h2', 'item_name': '南瓜', 'unit': '斤'}], all_ind)
check('全原料组仍标记独立入库',
_is_indep(rows2[0]), str(rows2[0].get('processing_details')))
print('=== 16. 卡片黄底提示文案 ===')
check('混合:分开写两边',
app._indep_badge_text(rows[0]) == '独立入库原料 12 斤 · 普通入库 20 斤',
app._indep_badge_text(rows[0]))
check('全原料:保持原文案',
app._indep_badge_text(rows2[0]) == '独立入库 · 加工原材料',
app._indep_badge_text(rows2[0]))
check('全普通:不显示',
app._indep_badge_text({'group_parts': [{'kind': 'normal',
'qty': 32}],
'unit': '斤'}) == '',
app._indep_badge_text({'group_parts': [{'kind': 'normal',
'qty': 32}], 'unit': '斤'}))
check('无明细时回退旧判断(普通行不显示)',
app._indep_badge_text({'item_name': '冬瓜', 'unit': '斤'}) == '',
app._indep_badge_text({'item_name': '冬瓜', 'unit': '斤'}))
print('=== 17. 待办列表左右滑动翻页 ===')
app._page_count = 3
app._page = 1
app._layout_cards = lambda: None
def _ev(x, y):
return type('E', (), {'x_root': x, 'y_root': y})()
app._swipe_press(_ev(600, 300))
app._swipe_move(_ev(520, 302))
app._swipe_release(_ev(510, 302))
check('左划 → 下一页', app._page == 2, str(app._page))
app._swipe_press(_ev(500, 300))
app._swipe_move(_ev(600, 300))
app._swipe_release(_ev(620, 300))
check('右划 → 上一页', app._page == 1, str(app._page))
app._swipe_press(_ev(600, 300))
app._swipe_move(_ev(605, 400))
app._swipe_release(_ev(605, 420))
check('竖向拖动不翻页', app._page == 1, str(app._page))
app._swipe_press(_ev(600, 300))
app._swipe_move(_ev(560, 300))
app._swipe_release(_ev(555, 300))
check('横向位移不够不翻页', app._page == 1, str(app._page))
app._page_count = 1
app._page = 0
app._swipe_press(_ev(600, 300))
app._swipe_move(_ev(400, 300))
app._swipe_release(_ev(380, 300))
check('只有一页时不翻', app._page == 0, str(app._page))
print('=== 18. 顶栏/窗口标题按工位改名 ===')
check('分拣工位叫「分拣工作站」',
app._station_title('picking') == '分拣工作站',
app._station_title('picking'))
check('入库工位叫「入库工作站」',
app._station_title('inspection') == '入库工作站',
app._station_title('inspection'))
app.engine.station = 'picking'
app._paint_station()
check('窗口标题跟着变', app.root.title() == '分拣工作站', app.root.title())
root.destroy()
print('\n结果:%d 项通过,%d 项失败' % (ok, fail))
sys.exit(1 if fail else 0)
+125 -6
View File
@@ -39,7 +39,7 @@ class _BoolVar:
self._sw.set(v)
APP_VERSION = '1.0.67'
APP_VERSION = '1.0.68'
FONT_BIG = ('Microsoft YaHei', 14)
FONT_HUGE = ('Microsoft YaHei', 38, 'bold')
@@ -364,6 +364,11 @@ class App:
root = self.root
self.ready = False
self._logging_in = False
# 登录页回到产品名(退出登录/首次启动时把“分拣工作站”之类复位)
try:
root.title('入库分拣工作站 - 登录')
except Exception:
pass
for w in root.winfo_children():
w.destroy()
@@ -1295,10 +1300,14 @@ class App:
logo.create_image(0, 0, anchor='nw', image=self._logo_img)
logo.create_text(px(19), px(20), text='入', fill='white',
font=font(17, 'bold'))
self._logo_cv = logo
self._logo_text = logo.find_all()[-1] if logo.find_all() else None
self._bind_drag(logo)
lbl_brand = tk.Label(header, text='入库分拣工作站',
font=font(17, 'bold'), bg=C.surface, fg=C.ink)
lbl_brand = tk.Label(
header, text=self._station_title(self.engine.station),
font=font(17, 'bold'), bg=C.surface, fg=C.ink)
lbl_brand.pack(side='left')
self.lbl_brand = lbl_brand
self._bind_drag(lbl_brand)
# 工位标识:登录时定好,作业界面不提供第二个切换按钮
self.lbl_station = tk.Label(header, text='', font=font(12, 'bold'),
@@ -1632,6 +1641,7 @@ class App:
(0, 0), window=self.todo_grid, anchor='nw')
self.todo_canvas.bind('<Configure>', self._todo_on_resize)
self.todo_canvas.bind('<MouseWheel>', self._page_wheel)
self._bind_swipe(self.todo_canvas)
# v1.0.58:不再有拖动滚动,翻页状态如下
self._todo_scroll = None
self._page = 0 # 当前页(0 起)
@@ -1641,6 +1651,7 @@ class App:
# 点击判定(v1.0.57):按下→松手没挪过才算点。分页后拖动不再滚动,
# 但「按下→划走→松手」仍不算点,确认状态下不会误改判/误打印。
self._tap = TapGate()
self._swipe = None # 左右滑动翻页的起点(v1.0.68)
self._sel_rid = None
self.todo_cards = {}
self.todo_rows = {}
@@ -1678,9 +1689,34 @@ class App:
# 用 pack(before=ft) 插在结果条上面,不用另开窗口 —— 现场最烦弹窗。
self._build_focus_bar(right)
@staticmethod
def _station_title(station):
"""当前工位的软件名(顶栏 + 窗口标题)
两个工位共用同一个程序,但顶栏写“入库分拣工作站”对分拣台来说很
容易让人以为这是入库的机子。按工位分开叫,库管/调度一眼就知道
这台是干什么的。
"""
return '分拣工作站' if str(station) == 'picking' else '入库工作站'
def _paint_station(self):
"""工位只显示当前那一个(登录时定的),不做切换按钮。"""
picking = self.engine.station == 'picking'
name = self._station_title(self.engine.station)
try:
self.lbl_brand.configure(text=name)
except Exception:
pass
try:
self.root.title(name)
except Exception:
pass
try:
if getattr(self, '_logo_text', None) is not None:
self._logo_cv.itemconfigure(
self._logo_text, text='拣' if picking else '入')
except Exception:
pass
try:
self.lbl_station.configure(
text='分拣工位 · 打标签' if picking else '入库工位 · 不打标签',
@@ -3279,13 +3315,40 @@ class App:
return value.strip().lower() in ('1', 'true', 'yes', 'y', '是')
return bool(value)
def _indep_badge_text(self, r):
"""卡片上黄底提示的文案(返回空串 = 不显示)
同一商品可能既有「独立入库·加工原材料」又有普通订单行,合并成一张卡
后只挂一个“独立入库”会让人以为这 32 斤全是原料;有明细就分开写:
「独立入库原料 12 斤 · 普通入库 20 斤」
"""
parts = [p for p in ((r or {}).get('group_parts') or [])
if isinstance(p, dict)]
if parts:
inde = sum(float(p.get('qty') or 0) for p in parts
if p.get('kind') == 'independent')
norm = sum(float(p.get('qty') or 0) for p in parts
if p.get('kind') == 'normal')
unit = str((r or {}).get('unit') or '')
if inde > 0 and norm > 0:
return ('独立入库原料 %g %s · 普通入库 %g %s'
% (inde, unit, norm, unit))
if inde > 0:
return '独立入库 · 加工原材料'
return ''
return '独立入库 · 加工原材料' if self._is_independent_inbound(r) else ''
def _paint_independent_badge(self, card, r):
"""在商品名下方显示/隐藏独立入库提示,不参与业务数据。"""
badge = getattr(card, '_independent_badge', None)
if badge is None:
return
if self._is_independent_inbound(r):
badge.configure(text='独立入库 · 加工原材料')
text = self._indep_badge_text(r)
if text:
try:
badge.configure(text=text)
except Exception:
pass
if badge.winfo_manager() != 'pack':
badge.pack(before=getattr(card, '_meta_lbl', None),
side='top', anchor='w', padx=self._px(12),
@@ -3340,7 +3403,8 @@ class App:
c._name_lbl = lbl_name # _layout_cards 按列宽改 wraplength
badge = tk.Label(c, text='独立入库 · 加工原材料',
font=self._font(10, 'bold'), bg='#fff4d6',
fg='#9a5b00', anchor='w', justify='left')
fg='#9a5b00', anchor='w', justify='left',
wraplength=int(150 * self.S))
c._independent_badge = badge
self._paint_independent_badge(c, r)
meta = ' · '.join(x for x in [
@@ -3406,6 +3470,7 @@ class App:
w.bind('<ButtonRelease-1>', on_release, add='+')
except Exception:
pass
self._bind_swipe(w)
# ---- 卡片缩略图:本地 data/photos 按 商品名/SKU 查找;
# 真实接口可带 image_url,后台下载到 data/thumb_cache 再回填 ----
@@ -3677,6 +3742,12 @@ class App:
text=getattr(obj, '_meta_who', ''),
wraplength=max(int(80 * self.S),
card_w - int(16 * self.S)))
badge = getattr(obj, '_independent_badge', None)
if badge is not None:
# 「独立入库原料 12 斤 · 普通入库 20 斤」比原来长,跟着列宽折行
badge.configure(
wraplength=max(int(80 * self.S),
card_w - int(16 * self.S)))
pages = _paginate_items(items, ncols, cap)
self._page_count = len(pages)
self._page = max(0, min(self._page, len(pages) - 1))
@@ -3726,6 +3797,54 @@ class App:
self._paint_focus(str(self._focus_p.get('row_id')))
# ---------------------------------------------------------- 分页
# ---------------- 待办区左右滑动翻页(v1.0.68)
def _bind_swipe(self, w):
"""给待办卡/空白区接上左右滑动翻页(竖向拖动不参与)
现场 19 寸触摸屏点底部「上一页/下一页」要跨半个屏幕,翻一页很累。
只认「横向位移 >60px 且明显大于纵向」——点还是点(TapGate 的 12px
阈值不动),竖向 / 斜向拖动也不会误翻页。
"""
try:
w.bind('<ButtonPress-1>', self._swipe_press, add='+')
w.bind('<B1-Motion>', self._swipe_move, add='+')
w.bind('<ButtonRelease-1>', self._swipe_release, add='+')
except Exception:
pass
def _swipe_press(self, e):
try:
self._swipe = {'x': float(e.x_root), 'y': float(e.y_root),
'on': False}
except Exception:
self._swipe = None
def _swipe_move(self, e):
s = getattr(self, '_swipe', None)
if not s:
return
try:
dx = float(e.x_root) - s['x']
dy = float(e.y_root) - s['y']
except Exception:
return
if abs(dx) > self._px(30) and abs(dx) > abs(dy) * 1.5:
s['on'] = True
def _swipe_release(self, e):
s = getattr(self, '_swipe', None)
self._swipe = None
if not s or not s.get('on'):
return
try:
dx = float(e.x_root) - s['x']
except Exception:
return
if abs(dx) < self._px(60):
return
# 手指往左划 → 下一页;往右划 → 上一页
self._page_turn(-1 if dx > 0 else 1)
def _page_turn(self, d):
"""上一页/下一页:_layout_cards 的 key 里有页码,改了页它自然重排"""
n = getattr(self, '_page_count', 1)
+20
View File
@@ -43,6 +43,26 @@
· 注意:短收部分入账后,剩余行仍在待验列表里,请刷新列表后继续称;
若剩余货确定不再到,才用「偏差/短收结案」。
◆ 待办名单支持左右滑动翻页
· 在名单区域(卡片上或空白处)手指左划 = 下一页,右划 = 上一页。
· 竖向拖动、斜着划、短距离滑动都不会翻页,也不会误选中卡片。
· 底部「上一页 / 下一页」按钮和鼠标滚轮翻页照旧可用。
◆ 顶栏按工位改名(不再一律叫“入库分拣工作站”)
· 登录分拣工位后,顶栏和窗口标题显示「分拣工作站」,logo 字改成“拣”;
入库工位显示「入库工作站」。库管/调度一眼就能分清这台机是干什么的。
· 退出登录后窗口标题回到「入库分拣工作站 - 登录」。
· 程序文件名 / 安装包名不变(仍叫入库分拣工作站.exe)。
【v1.0.67 待办卡分原料/普通显示(2026-11-11)】
◆ 同一商品既有「加工原材料」又有普通订单时,卡片分开显示
· 以前只挂一个黄底标签「独立入库 · 加工原材料」,32 斤看着像全是
原料;实际可能是原料 12 斤 + 订单 20 斤合并的一组。
· 现在标签会写成「独立入库原料 12 斤 · 普通入库 20 斤」;
全原料组仍是「独立入库 · 加工原材料」;全普通组不显示。
· 混合组不会再被标成“独立入库”(避免走错单行结案),仍整组提交。
【v1.0.66 分组批量入库 + 登录页改服务器(2026-11-10)】
◆ 分组批量入库(与安卓称端同一套接口)