From cf674d9fd07e7a8e401fb564580b719ed8d61727 Mon Sep 17 00:00:00 2001 From: liufumingren Date: Fri, 16 Oct 2026 05:18:47 +0800 Subject: [PATCH] =?UTF-8?q?feat(setting.warehouse):=20=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=87=BA=E5=BA=93=E8=A7=84=E5=88=99=E6=94=B9=E4=B8=BA=E6=95=B0?= =?UTF-8?q?=E7=BB=84=E7=BB=93=E6=9E=84=E5=B9=B6=E6=96=B0=E5=A2=9E=E9=A1=B6?= =?UTF-8?q?=E5=B1=82=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 auto_outbound_enabled 顶层开关,auto_outbound_rules 改为规则数组(多条为「或」,规则内条件为「与」) - 移除 auto_outbound_rules 旧的 normalize 逻辑:不再按旧对象结构补齐子项,否则数组会被改写为对象并被 schema 回退成 [],导致用户配置保存时被静默清空 - 表单字段定义同步为 array 类型,更新各项 label/描述与默认值 --- src/api/setting.warehouse/settingwarehouse.ts | 80 ++++++------------- .../newview/pages/WarehouseSettingsForm.vue | 28 ++++--- 2 files changed, 42 insertions(+), 66 deletions(-) diff --git a/src/api/setting.warehouse/settingwarehouse.ts b/src/api/setting.warehouse/settingwarehouse.ts index 2db83c7c..beaff0a5 100644 --- a/src/api/setting.warehouse/settingwarehouse.ts +++ b/src/api/setting.warehouse/settingwarehouse.ts @@ -5,50 +5,48 @@ const v = '1.0' /** HH:mm(24 小时制、两位补零) */ const HH_MM_PATTERN = /^([01]\d|2[0-3]):[0-5]\d$/ -/** 自动出库规则配置(subject_config.auto_outbound_rules) */ -export type SettingWarehouseAutoOutboundRules = { - enabled?: boolean - require_recheck?: boolean +/** + * 自动出库单条规则(subject_config.auto_outbound_rules 的数组项)。 + * 规则内所有条件为「与」关系;多条规则之间为「或」关系(任一命中即自动出库)。 + * 固定前置条件(不可配置):已复核 recheck_status=fin + 已分配储位 storage_status=fin。 + */ +export type SettingWarehouseAutoOutboundRule = { + /** 是否要求已打包(pack_status=fin),默认 true */ require_pack?: boolean + /** 是否要求已称重(wms_order_express.weighing_weight>0),默认 true */ require_weigh?: boolean + /** 是否要求已同步(sync_status=fin),默认 true */ require_sync?: boolean - require_print?: boolean - require_pick?: boolean - /** 是否不出库当天订单(默认 true):开启后,当天放开时间前、「允许当天出库最后时间」之后复核的订单不自动出库 */ + /** 是否不出库当天复核的订单(默认 true):按订单复核时间所在日计算,需等到该日的「放行时间」才自动出库 */ exclude_same_day_outbound?: boolean - /** 允许当天出库最后时间,格式 HH:mm,默认 06:00;复核时间早于该时间的订单不受「不出库当天订单」的影响 */ + /** 允许当天出库最后时间,格式 HH:mm,默认 06:00(当天内 00:00~23:59),不能大于放行时间 */ same_day_outbound_deadline_time?: string - /** 当天放开时间,格式 HH:mm,默认 22:00;开启「不出库当天订单」时,当天到达该时间后不再限制当天复核订单的自动出库 */ + /** 放行时间,格式 HH:mm,默认 22:00;支持跨天 00:00~47:59(24:00 之后表示次日,如 27:00 = 次日 03:00) */ same_day_outbound_release_time?: string } -/** auto_outbound_rules 中的布尔(flag)子项 */ +/** 自动出库规则(subject_config.auto_outbound_rules):数组,空数组表示不自动出库任何订单 */ +export type SettingWarehouseAutoOutboundRules = SettingWarehouseAutoOutboundRule[] + +/** 规则中的布尔(flag)子项 */ export const AUTO_OUTBOUND_RULE_FLAG_KEYS = [ - 'enabled', - 'require_recheck', 'require_pack', 'require_weigh', 'require_sync', - 'require_print', - 'require_pick', 'exclude_same_day_outbound' ] as const -/** auto_outbound_rules 中的 HH:mm 时间子项(缺省/空值回退默认,非空值原样保留交由后端校验) */ +/** 规则中的 HH:mm 时间子项(缺省/空值回退默认,非空值原样保留交由后端校验) */ export const AUTO_OUTBOUND_RULE_TIME_KEYS = [ 'same_day_outbound_deadline_time', 'same_day_outbound_release_time' ] as const -/** 文档默认:auto_outbound_rules 各子项默认值 */ -export const DEFAULT_AUTO_OUTBOUND_RULES: Required = { - enabled: false, - require_recheck: true, +/** 新建规则时的默认值(与后端 normalizeAutoOutboundRule 口径一致) */ +export const DEFAULT_AUTO_OUTBOUND_RULE: Required = { require_pack: true, require_weigh: true, require_sync: true, - require_print: true, - require_pick: true, exclude_same_day_outbound: true, same_day_outbound_deadline_time: '06:00', same_day_outbound_release_time: '22:00' @@ -142,6 +140,9 @@ export const DEFAULT_WAREHOUSE_SENDER_FIELDS: Required) } - : ({} as Record) - - // 兼容历史字段名:allow_same_day_outbound(旧,「允许当天出库」)= !exclude_same_day_outbound(新,「不出库当天订单」) - if (!('exclude_same_day_outbound' in rules) && 'allow_same_day_outbound' in rules) { - const legacyAllow = rules.allow_same_day_outbound - rules.exclude_same_day_outbound = !( - legacyAllow === true || legacyAllow === 1 || legacyAllow === '1' - ) - } - - // 按白名单保留 flag 与 HH:mm 时间子项:不能只按「值是否为 boolean」过滤, - // 否则 same_day_outbound_deadline_time / same_day_outbound_release_time(字符串) - // 会在读取与保存时被静默丢弃。 - const normalizedRules: Record = { ...DEFAULT_AUTO_OUTBOUND_RULES } - for (const key of AUTO_OUTBOUND_RULE_FLAG_KEYS) { - const value = rules[key] - normalizedRules[key] = - value === true || value === 1 || value === '1' - ? true - : value === false || value === 0 || value === '0' - ? false - : DEFAULT_AUTO_OUTBOUND_RULES[key] - } - for (const key of AUTO_OUTBOUND_RULE_TIME_KEYS) { - const value = rules[key] - const text = value === undefined || value === null ? '' : String(value).trim() - normalizedRules[key] = text !== '' ? text : DEFAULT_AUTO_OUTBOUND_RULES[key] - } - base.auto_outbound_rules = normalizedRules as SettingWarehouseAutoOutboundRules + // 自动出库:auto_outbound_enabled(flag,顶层开关)+ auto_outbound_rules(规则数组) + // 不要再在这里按旧「对象结构」(enabled/require_recheck/require_print/require_pick)补齐子项—— + // 那会把数组改写成对象,随后 applySchemaToSubjectConfig 按 meta 的 array 类型又回退成 [], + // 导致用户在页面上配置的规则保存时被静默清空。子项集合一律以 getFieldMeta 的 item_keys 为准。 for (const key of WAREHOUSE_SENDER_FIELD_KEYS) { if (typeof base[key] !== 'string') { diff --git a/src/views/system/setting/basicManagement/newview/pages/WarehouseSettingsForm.vue b/src/views/system/setting/basicManagement/newview/pages/WarehouseSettingsForm.vue index 416d8859..2f8f6837 100644 --- a/src/views/system/setting/basicManagement/newview/pages/WarehouseSettingsForm.vue +++ b/src/views/system/setting/basicManagement/newview/pages/WarehouseSettingsForm.vue @@ -295,22 +295,26 @@ const FALLBACK_FIELDS: NormalizedField[] = [ { key: 'town_name', label: '默认发件镇/街道', type: 'string', maxLength: 50 }, { key: 'address', label: '默认发件详细地址', type: 'string', maxLength: 200 }, { key: 'receiver_address', label: '仓库收货地址', type: 'string', maxLength: 500, description: '退货/退件收件地址,一行文本' }, + { + key: 'auto_outbound_enabled', + label: '启用自动出库', + type: 'boolean', + default: false, + description: '默认关闭;开启后按「自动出库规则」扫描订单并自动标记出库' + }, { key: 'auto_outbound_rules', label: '自动出库规则', - type: 'object', - description: '全部条件满足时自动标记待出库。', + type: 'array', + default: [], + description: '多条规则之间为「或」关系,任一命中即自动出库;规则内条件为「与」关系。空数组表示不自动出库。固定前置条件:已复核 + 已分配储位。', itemFields: [ - { key: 'enabled', label: '启用自动出库', type: 'boolean', description: '默认关闭' }, - { key: 'require_recheck', label: '要求已复核', type: 'boolean', description: 'recheck_status=fin,默认开启' }, - { key: 'require_pack', label: '要求已打包', type: 'boolean', description: 'pack_status=fin,默认开启' }, - { key: 'require_weigh', label: '要求已称重', type: 'boolean', description: 'weighing_weight>0,默认开启' }, - { key: 'require_sync', label: '要求已同步', type: 'boolean', description: 'sync_status=fin,默认开启' }, - { key: 'require_print', label: '要求已打印', type: 'boolean', description: 'print_status=fin,默认开启' }, - { key: 'require_pick', label: '要求已拣货', type: 'boolean', description: 'pick_status=fin,默认开启' }, - { key: 'exclude_same_day_outbound', label: '不出库当天订单', type: 'boolean', defaultValue: true, description: '开启后,在当天放开时间前、「允许当天出库最后时间」之后复核的订单不自动出库,到达当天放开时间后恢复;默认开启' }, - { key: 'same_day_outbound_deadline_time', label: '允许当天出库最后时间', type: 'string', maxLength: 5, defaultValue: '06:00', description: '格式 HH:mm,默认 06:00;复核时间早于该时间的订单不受「不出库当天订单」的影响' }, - { key: 'same_day_outbound_release_time', label: '当天放开时间', type: 'string', maxLength: 5, defaultValue: '22:00', description: '格式 HH:mm,默认 22:00;开启「不出库当天订单」时,当天到达该时间后不再限制当天复核订单的自动出库' } + { key: 'require_pack', label: '要求已打包', type: 'boolean', defaultValue: true, description: 'pack_status=fin,默认开启' }, + { key: 'require_weigh', label: '要求已称重', type: 'boolean', defaultValue: true, description: 'weighing_weight>0,默认开启' }, + { key: 'require_sync', label: '要求已同步', type: 'boolean', defaultValue: true, description: 'sync_status=fin,默认开启' }, + { key: 'exclude_same_day_outbound', label: '不出库当天订单', type: 'boolean', defaultValue: true, description: '开启后,按订单复核时间所在日计算:复核时间在「允许当天出库最后时间」之后的订单,需等到该日的「放行时间」才自动出库;默认开启' }, + { key: 'same_day_outbound_deadline_time', label: '允许当天出库最后时间', type: 'string', maxLength: 5, defaultValue: '06:00', description: '格式 HH:mm,默认 06:00,范围 00:00-23:59;不能大于放行时间。当天不出库请设为 00:00' }, + { key: 'same_day_outbound_release_time', label: '放行时间', type: 'string', maxLength: 5, defaultValue: '22:00', description: '格式 HH:mm,默认 22:00,支持跨天 00:00-47:59(24:00 之后表示次日,如 27:00 = 次日 03:00)。常用:23:59 = 当天不放、过零点出库' } ] }, {