diff --git a/README.md b/README.md index 76dbc46..94bd364 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,7 @@ cookies 保存到 `session.json`(与 exe 同目录)。登录成功后自动 | 寄达地区划代码 | 直接决定寄达地,勾选强制覆盖后优先级最高 | | 寄件人姓名 | 强制覆盖客户资料中的寄件人 | | 寄件地址 | 强制覆盖客户资料中的寄件地址 | +| 长 / 宽 / 高 | 有值即强制覆盖提交表单中的包裹尺寸 | ### 5. 开始处理 @@ -136,6 +137,7 @@ cookies 保存到 `session.json`(与 exe 同目录)。登录成功后自动 "字段名": {"value": "值", "force": false} ``` `force: true` 时覆盖 API 获取值。GUI 中通过复选框控制,点击"开始处理"时自动保存到配置文件。 +长、宽、高在 GUI 中填写后会自动保存为强制固定值;留空时不覆盖 Excel 或系统已有值。 ### defaults 字段的默认值(中文名,自动翻译为系统编码)。 diff --git a/config.json b/config.json index 71a8a7b..7dc482c 100644 --- a/config.json +++ b/config.json @@ -20,7 +20,10 @@ "寄达地": {"value": "", "force": false}, "寄达地区划": {"value": "", "force": false}, "产品名称": {"value": "", "force": false}, - "内件品名": {"value": "", "force": false} + "内件品名": {"value": "", "force": false}, + "长": {"value": "", "force": false}, + "宽": {"value": "", "force": false}, + "高": {"value": "", "force": false} }, "defaults": { "电商平台": "无", @@ -34,4 +37,4 @@ "代收标志": "不代收", "投递方式": "普通投递" } -} \ No newline at end of file +} diff --git a/field_mapping.py b/field_mapping.py index f3aff05..c403ca8 100644 --- a/field_mapping.py +++ b/field_mapping.py @@ -29,6 +29,9 @@ BUILTIN_FIELD_MAP: dict[str, str] = { "寄件人固话": "senderFixtel", # ── 货物 ── "重量": "realWeight", + "长": "length", + "宽": "width", + "高": "height", "内件品名": "reserved5", # ── 电商 / 支付 ── "电商平台": "ecommerceNo", diff --git a/main.py b/main.py index 881f629..0ebf212 100644 --- a/main.py +++ b/main.py @@ -125,6 +125,9 @@ class App: self.fv_sender_addr = StringVar() self.fv_transport_type = StringVar() self.fv_weight = StringVar() + self.fv_length = StringVar() + self.fv_width = StringVar() + self.fv_height = StringVar() # 搜索基础设施(懒加载) self._search_bridge = None @@ -244,7 +247,19 @@ class App: Entry(r1, textvariable=self.fv_weight, width=10).pack(side="left", padx=5) Label(r1, text="(有值即强制覆盖)", fg="gray", font=("", 8)).pack(side="left") - # Row 2: 寄达地 | 寄达地区划代码 + # Row 2: 长 | 宽 | 高 + r_dimensions = Frame(fixed_frame) + r_dimensions.pack(fill=X, pady=2) + for label, variable in ( + ("长:", self.fv_length), + ("宽:", self.fv_width), + ("高:", self.fv_height), + ): + Label(r_dimensions, text=label, width=5, anchor="e").pack(side="left") + Entry(r_dimensions, textvariable=variable, width=10).pack(side="left", padx=5) + Label(r_dimensions, text="(有值即强制覆盖)", fg="gray", font=("", 8)).pack(side="left") + + # Row 3: 寄达地 | 寄达地区划代码 r2 = Frame(fixed_frame) r2.pack(fill=X, pady=2) Label(r2, text="寄达地:", width=10, anchor="e").pack(side="left") @@ -256,7 +271,7 @@ class App: self.fv_district_combo.pack(side="left", padx=5) Checkbutton(r2, text="强制覆盖", variable=self.fv_force_district).pack(side="left", padx=2) - # Row 3: 寄件人姓名 | 寄件地址 + # Row 4: 寄件人姓名 | 寄件地址 r3 = Frame(fixed_frame) r3.pack(fill=X, pady=2) Label(r3, text="寄件人姓名:", width=10, anchor="e").pack(side="left") @@ -380,6 +395,9 @@ class App: self.fv_sender_name.set(fv.get("寄件人", {}).get("value", "")) self.fv_sender_addr.set(fv.get("寄件地址", {}).get("value", "")) self.fv_weight.set(fv.get("重量", {}).get("value", "")) + self.fv_length.set(fv.get("长", {}).get("value", "")) + self.fv_width.set(fv.get("宽", {}).get("value", "")) + self.fv_height.set(fv.get("高", {}).get("value", "")) # 加载区划代码下拉选项 dc = self.config.get("district_codes", {}) @@ -418,6 +436,9 @@ class App: sender_val = self.fv_sender_name.get().strip() addr_val = self.fv_sender_addr.get().strip() weight_val = self.fv_weight.get().strip() + length_val = self.fv_length.get().strip() + width_val = self.fv_width.get().strip() + height_val = self.fv_height.get().strip() # 区划代码:Combobox 显示中文名,实际存 propertyCode dist_name = self.fv_district_code.get() dist_code = self._district_codes.get(dist_name, dist_name) if self._district_codes else dist_name @@ -430,6 +451,9 @@ class App: "寄件人": {"value": sender_val, "force": bool(sender_val)}, "寄件地址": {"value": addr_val, "force": bool(addr_val)}, "重量": {"value": weight_val, "force": bool(weight_val)}, + "长": {"value": length_val, "force": bool(length_val)}, + "宽": {"value": width_val, "force": bool(width_val)}, + "高": {"value": height_val, "force": bool(height_val)}, } self.config["fixed_values"] = new_fixed @@ -934,6 +958,9 @@ class App: self.fv_sender_addr.set("") self.fv_transport_type.set("") self.fv_weight.set("") + self.fv_length.set("") + self.fv_width.set("") + self.fv_height.set("") self._product_cached_choice = None self._product_cached_detail = None self._customer_cached_choice = None