v1.1.0: 版本更新 - 增强规格解析能力、修复条码映射功能、改进特殊条码处理
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
|
||||
import os
|
||||
import tkinter as tk
|
||||
from tkinter import messagebox, ttk
|
||||
from tkinter import messagebox, ttk, simpledialog
|
||||
from datetime import datetime
|
||||
|
||||
def create_custom_dialog(title="提示", message="", result_file=None, time_info=None,
|
||||
@@ -363,6 +363,45 @@ def create_barcode_mapping_dialog(parent=None, on_save=None, current_mappings=No
|
||||
remove_special_btn = tk.Button(special_btn_frame, text="删除特殊处理", command=remove_special)
|
||||
remove_special_btn.pack(side=tk.LEFT, padx=5)
|
||||
|
||||
# 添加映射到特殊处理的功能
|
||||
def add_mapping_to_special():
|
||||
selected = special_tree.selection()
|
||||
if not selected:
|
||||
messagebox.showwarning("未选择", "请先选择要添加映射的特殊处理条目")
|
||||
return
|
||||
|
||||
# 获取选中项
|
||||
item = special_tree.item(selected[0])
|
||||
barcode = item['values'][0]
|
||||
|
||||
# 弹出对话框输入映射目标
|
||||
target_barcode = tk.simpledialog.askstring("添加映射", f"为条码 {barcode} 添加映射目标条码:")
|
||||
if not target_barcode:
|
||||
return
|
||||
|
||||
# 更新特殊处理列表中的项
|
||||
for i, (b, mult, unit, price, spec, desc) in enumerate(special_list):
|
||||
if b == barcode:
|
||||
# 如果描述中已有映射信息,更新它
|
||||
if "映射到:" in desc:
|
||||
desc = desc.split("映射到:")[0].strip()
|
||||
|
||||
# 添加映射信息到描述
|
||||
new_desc = f"{desc} 映射到: {target_barcode}"
|
||||
special_list[i] = (b, mult, unit, price, spec, new_desc)
|
||||
|
||||
# 更新显示
|
||||
special_tree.item(selected[0], values=(b, mult, unit, price, spec, new_desc))
|
||||
|
||||
# 标记该条码有映射
|
||||
special_tree.item(selected[0], tags=("mapped",))
|
||||
special_tree.tag_configure("mapped", foreground="blue")
|
||||
|
||||
break
|
||||
|
||||
map_special_btn = tk.Button(special_btn_frame, text="添加条码映射", command=add_mapping_to_special)
|
||||
map_special_btn.pack(side=tk.LEFT, padx=5)
|
||||
|
||||
# 底部按钮区域
|
||||
bottom_frame = tk.Frame(dialog)
|
||||
bottom_frame.pack(fill=tk.X, padx=10, pady=10)
|
||||
@@ -380,7 +419,9 @@ def create_barcode_mapping_dialog(parent=None, on_save=None, current_mappings=No
|
||||
|
||||
# 添加特殊处理
|
||||
for barcode, multiplier, unit, price, spec, desc in special_list:
|
||||
mappings[barcode] = {}
|
||||
# 检查该条码是否已存在
|
||||
if barcode not in mappings:
|
||||
mappings[barcode] = {}
|
||||
|
||||
if multiplier:
|
||||
try:
|
||||
@@ -411,7 +452,19 @@ def create_barcode_mapping_dialog(parent=None, on_save=None, current_mappings=No
|
||||
if spec:
|
||||
mappings[barcode]['specification'] = spec
|
||||
|
||||
if desc:
|
||||
# 检查描述中是否包含映射信息
|
||||
if desc and "映射到:" in desc:
|
||||
parts = desc.split("映射到:")
|
||||
base_desc = parts[0].strip()
|
||||
target_barcode = parts[1].strip()
|
||||
|
||||
# 设置基本描述
|
||||
if base_desc:
|
||||
mappings[barcode]['description'] = base_desc
|
||||
|
||||
# 设置映射目标
|
||||
mappings[barcode]['map_to'] = target_barcode
|
||||
elif desc:
|
||||
mappings[barcode]['description'] = desc
|
||||
|
||||
# 调用保存回调
|
||||
|
||||
Reference in New Issue
Block a user