Files

121 lines
3.8 KiB
Python
Raw Permalink 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.
# -*- coding: utf-8 -*-
"""v1.0.31 界面图(1440×900,现场 19 寸):
① 按客户分组(每一组一条标题,客户 chips 可切)
② 只看某一个客户
③ 识别后出现的确认条(不弹窗,列表跳到那一行并高亮)
"""
import json
import os
import sys
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, ROOT)
os.chdir(ROOT)
import tkinter as tk
from PIL import ImageGrab
import ui.app as A
W, H = 1440, 900
OUT = os.path.join('docs', 'design')
os.makedirs(OUT, exist_ok=True)
cfg = json.load(open('config.json', encoding='utf-8'))
cfg.setdefault('server', {})['mock'] = True
cfg.setdefault('flow', {})['confirm_before_submit'] = True
cfg['ui'] = {'mode': 'window', 'width': W, 'height': H,
'borderless': True, 'todo_group': 'customer'}
A.load_config = lambda *a, **k: cfg
DATA = [
('荣县分公司', '叶菜', '藕', '散装', 14.60, '斤'),
('荣县分公司', '叶菜', '大白菜', '散装', 61.04, '斤'),
('荣县分公司', '根茎', '圆萝卜', '散装', 2.00, '斤'),
('市邮政', '叶菜', '小白菜', '散装', 18.50, '斤'),
('市邮政', '根茎', '马铃薯', '散装', 50.00, '斤'),
('市邮政', '水果', '红富士苹果', '80#', 100.00, '斤'),
('富顺分公司', '叶菜', '四季豆', '散装', 26.00, '斤'),
('富顺分公司', '叶菜', '莴笋', '散装', 20.00, '斤'),
('富顺分公司', '水果', '冰糖橙', '散装', 30.00, '斤'),
('大安分公司', '根茎', '胡萝卜', '散装', 12.00, '斤'),
('大安分公司', '水果', '水果黄瓜', '散装', 4.00, '斤'),
('大安分公司', '菌菇', '香菇', '一级', 2.00, '包'),
]
rows = []
for i, (cust, cat, name, spec, qty, unit) in enumerate(DATA):
rows.append({'id': 'pk-%03d' % i, 'pick_code': 'PK202611050%02d' % (i // 4),
'order_code': 'DD20261105%03d' % i, 'sort_order': i + 1,
'sku_code': 'SKU%04d' % (2100 + i), 'item_name': name,
'spec': spec, 'category_name': cat, 'unit': unit,
'customer_name': cust, 'company_name': cust,
'required_qty': qty, 'remaining_qty': qty,
'requires_photo': False})
def grab(win, name):
# 必须先把窗口顶到最前:ImageGrab 抓的是屏幕像素,窗口在后台时
# 抓到的就是别人(浏览器)的画面
try:
win.attributes('-topmost', True)
win.lift()
win.focus_force()
except Exception:
pass
win.update_idletasks()
win.update()
import time as _t
_t.sleep(0.35)
win.update()
x, y = win.winfo_rootx(), win.winfo_rooty()
w, h = win.winfo_width(), win.winfo_height()
ImageGrab.grab((x, y, x + w, y + h)).save(os.path.join(OUT, name))
print(name, w, 'x', h)
root = tk.Tk()
app = A.App(root)
def step1():
for w in root.winfo_children():
w.destroy()
app.engine.station = 'picking'
app._build()
app.ready = True
app.engine.rows = rows
app.lbl_weight.configure(text='7.30')
app.lbl_jin.configure(text='14.6 斤')
app._fill_todo(rows)
root.after(600, step2)
def step2():
grab(root, 'group-customer-1440x900.png')
app._set_group_pick('荣县分公司')
root.after(500, step3)
def step3():
grab(root, 'group-picked-1440x900.png')
app._set_group_pick(None)
payload = {
'mode': 'weigh', 'row_id': 'pk-000', 'row': rows[0],
'detected': '藕', 'conf': 91, 'weight': 7.30, 'business': 14.6,
'unit': '斤', 'qty_editable': False, 'candidates': ['pk-000'],
'warn': '', 'snapshot': None, 'auto': True,
'rows': rows, 'station': 'picking',
}
app._on_focus(payload)
root.after(700, step4)
def step4():
grab(root, 'focus-bar-1440x900.png')
root.destroy()
root.after(900, step1)
root.mainloop()