From b32bc4ec7e3812c6ee899efb1c2518a301b8ef0e Mon Sep 17 00:00:00 2001 From: liufumingren Date: Wed, 23 Sep 2026 02:22:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E4=BB=93=E5=BA=93=E8=AE=BE=E7=BD=AE=E8=87=AA=E5=8A=A8=E5=87=BA?= =?UTF-8?q?=E5=BA=93=E8=A7=84=E5=88=99=E4=B8=8D=E5=86=8D=E4=B8=A2=E5=A4=B1?= =?UTF-8?q?=E3=80=8C=E5=87=BA=E5=BA=93=E5=BD=93=E5=A4=A9=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E3=80=8D=E7=9A=84=E6=97=B6=E9=97=B4=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit normalizeWarehouseSubjectConfig 原先按「值是否为 boolean」过滤 auto_outbound_rules 子项, 字符串子项 same_day_outbound_deadline_time / same_day_outbound_release_time(HH:mm) 在读取(getSettings)与保存(saveSettings)时都被静默丢弃;改为按 flag 与 HH:mm 时间 白名单逐项归一化,并补全页面兜底字段与输入长度限制。 --- src/api/setting.warehouse/settingwarehouse.ts | 64 +++++++++++++++---- .../newview/pages/WarehouseSettingsForm.vue | 7 +- 2 files changed, 59 insertions(+), 12 deletions(-) diff --git a/src/api/setting.warehouse/settingwarehouse.ts b/src/api/setting.warehouse/settingwarehouse.ts index ae8dac77..ec19ad56 100644 --- a/src/api/setting.warehouse/settingwarehouse.ts +++ b/src/api/setting.warehouse/settingwarehouse.ts @@ -2,6 +2,9 @@ import request from '@/utils/request' 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 @@ -11,8 +14,32 @@ export type SettingWarehouseAutoOutboundRules = { require_sync?: boolean require_print?: boolean require_pick?: boolean + /** 是否允许当天复核的订单当天自动出库,默认 false */ + allow_same_day_outbound?: boolean + /** 允许当天出库最后时间,格式 HH:mm,默认 06:00;复核时间早于该时间的订单不受「出库当天订单」关闭的影响 */ + same_day_outbound_deadline_time?: string + /** 当天放开时间,格式 HH:mm,默认 22:00;未开启「出库当天订单」时,当天到达该时间后不再限制当天复核订单的自动出库 */ + same_day_outbound_release_time?: string } +/** auto_outbound_rules 中的布尔(flag)子项 */ +export const AUTO_OUTBOUND_RULE_FLAG_KEYS = [ + 'enabled', + 'require_recheck', + 'require_pack', + 'require_weigh', + 'require_sync', + 'require_print', + 'require_pick', + 'allow_same_day_outbound' +] as const + +/** auto_outbound_rules 中的 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, @@ -21,7 +48,10 @@ export const DEFAULT_AUTO_OUTBOUND_RULES: Required) } : ({} as Record) - base.auto_outbound_rules = { - ...DEFAULT_AUTO_OUTBOUND_RULES, - ...Object.fromEntries( - Object.entries(rules).filter(([, v]) => typeof v === 'boolean') - ) - } as SettingWarehouseAutoOutboundRules + // 按白名单保留 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 for (const key of WAREHOUSE_SENDER_FIELD_KEYS) { if (typeof base[key] !== 'string') { @@ -220,11 +263,10 @@ export function normalizeWarehouseSubjectConfig( } // 开始自动分配时间 / 截单时间(HH:mm,非法回退默认 08:00 / 18:00) - const HHmmPattern = /^([01]\d|2[0-3]):[0-5]\d$/ const allocTime = String(base.allocate_start_time ?? '') - base.allocate_start_time = HHmmPattern.test(allocTime) ? allocTime : '08:00' + base.allocate_start_time = HH_MM_PATTERN.test(allocTime) ? allocTime : '08:00' const cutoffTime = String(base.cutoff_order_time ?? '') - base.cutoff_order_time = HHmmPattern.test(cutoffTime) ? cutoffTime : '18:00' + base.cutoff_order_time = HH_MM_PATTERN.test(cutoffTime) ? cutoffTime : '18:00' // 收货未入库提醒(enabled flag 兼容 boolean / 数字 / 字符串;notice_time 非法回退 08:30; // min_hours 默认 24;max_hours 默认 48 且必须大于 min_hours) @@ -239,7 +281,7 @@ export function normalizeWarehouseSubjectConfig( noticeEnabled === true || noticeEnabled === 1 || noticeEnabled === '1' const noticeTime = String(notice.notice_time ?? '') - notice.notice_time = HHmmPattern.test(noticeTime) + notice.notice_time = HH_MM_PATTERN.test(noticeTime) ? noticeTime : DEFAULT_RECEIVING_PENDING_INBOUND_NOTICE.notice_time diff --git a/src/views/system/setting/basicManagement/newview/pages/WarehouseSettingsForm.vue b/src/views/system/setting/basicManagement/newview/pages/WarehouseSettingsForm.vue index bce19ee7..7116c879 100644 --- a/src/views/system/setting/basicManagement/newview/pages/WarehouseSettingsForm.vue +++ b/src/views/system/setting/basicManagement/newview/pages/WarehouseSettingsForm.vue @@ -209,6 +209,8 @@ :model-value="String(getObjectFieldValue(field.key, itemKey.key) ?? '')" size="small" style="width:200px" + :maxlength="itemKey.maxLength" + placeholder="请输入" @update:model-value="onObjectFieldChange(field.key, itemKey.key, $event)" /> {{ itemKey.description }} @@ -318,7 +320,10 @@ const FALLBACK_FIELDS: NormalizedField[] = [ { 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: 'require_pick', label: '要求已拣货', type: 'boolean', description: 'pick_status=fin,默认开启' }, + { key: 'allow_same_day_outbound', label: '出库当天订单', type: 'boolean', 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;未开启「出库当天订单」时,当天到达该时间后不再限制当天复核订单的自动出库' } ] }, {