From 1d29952e2291d521a4042e32fac68e2274e02b48 Mon Sep 17 00:00:00 2001 From: yin <3313488199@qq.com> Date: Wed, 9 Sep 2026 18:02:17 +0800 Subject: [PATCH] 1 --- .env.development | 4 + .env.production | 3 + docs/前端独立部署-接口落实任务清单.md | 2 +- docs/前端独立部署-操作与部署说明.md | 20 +- env.d.ts | 6 + index.html | 3 +- out.txt | 1 - src/api/setting.warehouse/settingwarehouse.ts | 11 +- src/components/ScanBox/index.vue | 67 ++++-- src/main.ts | 49 ++++- src/permission.ts | 23 +- src/stores/modules/frontBrand.ts | 91 ++++++-- src/utils/get-page-title.js | 10 - src/views/login/index.vue | 2 +- .../waveOrder/GroupWaveBatchListPanel.vue | 27 +-- .../waveOrder/SandanWaveBatchListPanel.vue | 27 +-- .../order/waveOrder/config/wave-config.ts | 25 +-- .../newview/pages/FrontConfigForm.vue | 199 +++++++++++++----- 18 files changed, 357 insertions(+), 213 deletions(-) delete mode 100644 out.txt delete mode 100644 src/utils/get-page-title.js diff --git a/.env.development b/.env.development index 9dac3a9f..97fa6c42 100644 --- a/.env.development +++ b/.env.development @@ -9,3 +9,7 @@ VITE_FILE_SERVER_BASE = 'https://ye4s.file.gzxunren.com' VITE_APP_IM_WS_URL=wss://your-im-server.com/ws VITE_APP_IM_API_URL=https://your-im-server.com/api + +# frontConfig.getByDomain 品牌豁免域名(逗号分隔,可多个;留空=不豁免,便于本地调试品牌配置) +# 注意:主域名被豁免后访问主域名将不拉取品牌(显示默认「天豹云仓」);要在 localhost 验证品牌标题请勿把 localhost 加入豁免 +VITE_FRONT_CONFIG_EXEMPT_HOSTS = 'wms.wms.gztbyc.com' diff --git a/.env.production b/.env.production index c77b0b16..52fe9228 100644 --- a/.env.production +++ b/.env.production @@ -9,3 +9,6 @@ VITE_FILE_SERVER_BASE = 'https://ye4s.file.gzxunren.com' VITE_APP_IM_WS_URL=wss://your-im-server.com/ws VITE_APP_IM_API_URL=https://your-im-server.com/api + +# frontConfig.getByDomain 品牌豁免域名(逗号分隔,可多个;主域名不拉取/不使用品牌配置) +VITE_FRONT_CONFIG_EXEMPT_HOSTS = 'wms.wms.gztbyc.com' diff --git a/docs/前端独立部署-接口落实任务清单.md b/docs/前端独立部署-接口落实任务清单.md index c947d40c..e856da05 100644 --- a/docs/前端独立部署-接口落实任务清单.md +++ b/docs/前端独立部署-接口落实任务清单.md @@ -121,4 +121,4 @@ - `saveFrontConfig`:只受理品牌字段,`domain`/证书字段传了也会被白名单忽略;`theme` 须合法 JSON 对象或 JSON 字符串。 - `getByDomain`:仅返回公开品牌字段,绝不返回证书/同步内部字段;未登记域名返回 404 + 60s 空缓存防穿透。 - 证书 PEM/私钥:禁止出现在前端响应/日志;前端只需展示由 `getFrontConfig` 返回的 `cert_expire_at/sync_status` 等。 -- 主题结构:已确定 4 个约定默认字段(`siteName` 网页名称 / `mainLogoUrl` 主页面 Logo / `loginLogoUrl` 登录页 Logo / `loginText` 登录页文字),**允许留空**(留空不写入 `theme` → 前端用系统默认值:站点默认标题“天豹云仓”、登录标语默认“现代化仓储管理系统 - 助力企业高效运营”等);其余 theme 键仍作动态 CSS 变量(`--`)应用,约定 4 键不映射 CSS 变量。 +- 主题结构:`theme` 仅作动态 CSS 变量容器(顶层标量键→`--`,文案类不再放主题)。网页名称/Logo 等业务语义由品牌顶层字段承担:网页名称=`title`、主页面/登录页 Logo=`logo_url`(`getByDomain` 读取、`saveFrontConfig` 保存)。历史 theme 中曾约定的 siteName/mainLogoUrl/loginLogoUrl/loginText 不再展示/编辑,保存时透传保留。 diff --git a/docs/前端独立部署-操作与部署说明.md b/docs/前端独立部署-操作与部署说明.md index 564d5339..0061295e 100644 --- a/docs/前端独立部署-操作与部署说明.md +++ b/docs/前端独立部署-操作与部署说明.md @@ -18,8 +18,8 @@ 3 访问 https://<自持域名>/... │ ▼ 免鉴权 frontConfig.getByDomain(domain) ← 按 hostname 拉品牌 - 应用:网页名称/登录页 Logo·文字/主页面 Logo(theme 4 约定字段)、 - 品牌 Logo/背景/favicon、document.title、其余 theme 键→CSS 变量 + 应用:网页名称(title)/主页面·登录页 Logo(logo_url)/背景/favicon、 + document.title、其余 theme 键→CSS 变量(theme 不再承载业务键) ``` - 品牌与「域名+证书」**分开保存**;变更域名必须走 `saveFrontCert`(重新校验证书)。 @@ -35,15 +35,11 @@ - 字段: - 站点标题 `title`(≤100) - Logo `logo_url`、favicon `favicon_url`、登录背景 `login_bg_url`(各 ≤255) - - 主题 `theme`:分两组编辑,保存时组装为 JSON 对象 - - 约定 4 个默认字段(页面按语义消费,均**允许留空**): - - 网页名称 `siteName`(对应系统默认标题“天豹云仓”,留空=用默认) - - 主页面 Logo `mainLogoUrl`(顶栏 Logo,留空=用默认图片) - - 登录页 Logo `loginLogoUrl`(登录页 Logo,留空=用品牌 `logo_url`) - - 登录页文字 `loginText`(登录页标语,留空默认“现代化仓储管理系统 - 助力企业高效运营”) - - 约定键留空时**不写入** `theme`,前端使用系统默认值/默认文案 - - 自定义键值:主题键即前端 CSS 变量名,值支持文本或 JSON(对象/数组/数字/布尔);应用时顶层标量键写入 `--`(约定 4 字段不映射 CSS 变量) -- 品牌字段留空即清空该字段;主题约定键留空=用默认,自定义键删空全部行=清空该部分。 + - 主题 `theme`:仅承载“自定义 CSS 变量”键值,保存时组装为 JSON 对象 + - 每个键即前端 CSS 变量名(如 `primary`→`--primary`),值支持文本或 JSON(对象/数组/数字/布尔);应用时顶层标量键写入 `--` + - 网页名称/Logo 等业务字段一律使用上方品牌顶层字段配置:网页名称=`title`、主页面/登录页 Logo=`logo_url`、登录背景=`login_bg_url`、favicon=`favicon_url`(`getByDomain` 读取、`saveFrontConfig` 保存) + - 历史 theme 中曾约定过的 `siteName/mainLogoUrl/loginLogoUrl/loginText` 不再展示与编辑,保存时原样透传保留(不丢失历史数据) +- 品牌字段留空即清空该字段;主题自定义键删空全部行=清空主题。 - 点击「保存品牌配置」→ 成功后自动刷新回显。 - 说明:此处不受理 `domain`/证书字段(后端白名单忽略)。 @@ -111,7 +107,7 @@ 1. 把本系统部署(或已有部署)解析到自持域名:`<自持域名> -> 部署 IP/负载`,并配置 HTTPS(证书由后端部署链路提供,前端不需持证)。 2. 浏览器访问 `https://<自持域名>`:前端入口自动按 `location.hostname` 调 `frontConfig.getByDomain` 应用品牌。 - - 生效项:网页名称(登录页标题与 document.title)、主页面 Logo(顶栏)、登录页 Logo/登录页文字(theme 4 约定字段,空=默认)、品牌 Logo/背景、favicon、其余 `theme` 键→CSS 变量(`--`)。 + - 生效项:网页名称=`title`(登录页标题与 document.title)、主页面/登录页 Logo=`logo_url`、登录背景、favicon;其余 `theme` 键→CSS 变量(`--`)。登录页文字无独立配置字段,用默认标语“现代化仓储管理系统 - 助力企业高效运营”。 3. 未登记域名 / 直连主域名:接口返回 404 / `configured=false` → 前端静默使用系统默认品牌(无报错)。 4. 本地联调建议:改 hosts 把自持域名指向本机测试环境即可看到品牌效果;确认无旧品牌残留可清理站点数据后刷新。 5. **多仓库同一部署的域名解析(A6)**:一套前端部署可同时服务多个仓库—— diff --git a/env.d.ts b/env.d.ts index d41af3a9..69837c77 100644 --- a/env.d.ts +++ b/env.d.ts @@ -1,4 +1,10 @@ /// + +interface ImportMetaEnv { + /** frontConfig.getByDomain 品牌豁免域名(逗号分隔多个;显式置空=不豁免,未配置回退主域名 wms.wms.gztbyc.com) */ + readonly VITE_FRONT_CONFIG_EXEMPT_HOSTS?: string +} + declare module '@/utils/auth' { export function getToken(): string | undefined export function setToken(token: string): void diff --git a/index.html b/index.html index 9e5fc8f0..461361f1 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,8 @@ - Vite App + + 加载中...
diff --git a/out.txt b/out.txt deleted file mode 100644 index e5e9b692..00000000 --- a/out.txt +++ /dev/null @@ -1 +0,0 @@ -[{"id": "text_1750000000001", "top": 6, "bold": true, "left": 0, "name": "出库单", "type": "text", "title": "出库单", "width": 148, "custom": true, "height": 10, "italic": false, "rotate": 0, "content": "出 库 单", "autoWrap": true, "fontSize": "18", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "center", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 10}, {"id": "line_1750000000002", "top": 18, "left": 10, "type": "line", "width": 128, "height": 0.5}, {"id": "text_1750000000003", "top": 21, "bold": false, "left": 10, "name": "发货单号", "type": "text", "title": "发货单号", "width": 26, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "发货单号:", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "144_1750000000004", "top": 21, "bold": false, "left": 36, "type": "text", "title": "出库单号", "width": 46, "height": 7, "italic": false, "rotate": 0, "content": "出库单号", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "delivery_order_code", "lineHeight": 6}, {"id": "text_1750000000005", "top": 21, "bold": false, "left": 84, "name": "波次号", "type": "text", "title": "波次号", "width": 20, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "波次号:", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "147_1750000000006", "top": 21, "bold": false, "left": 104, "type": "text", "title": "波次号", "width": 34, "height": 7, "italic": false, "rotate": 0, "content": "波次号", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "wave_no", "lineHeight": 6}, {"id": "text_1750000000007", "top": 29, "bold": false, "left": 10, "name": "创建时间", "type": "text", "title": "创建时间", "width": 26, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "创建时间:", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "157_1750000000008", "top": 29, "bold": false, "left": 36, "type": "text", "title": "创建时间", "width": 46, "height": 7, "italic": false, "rotate": 0, "content": "创建时间", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "create_at", "lineHeight": 6}, {"id": "text_1750000000009", "top": 29, "bold": false, "left": 84, "name": "快递公司", "type": "text", "title": "快递公司", "width": 26, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "快递公司:", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "154_1750000000010", "top": 29, "bold": false, "left": 110, "type": "text", "title": "物流公司", "width": 28, "height": 7, "italic": false, "rotate": 0, "content": "物流公司", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "logistics_name", "lineHeight": 6}, {"id": "text_1750000000011", "top": 37, "bold": false, "left": 10, "name": "运单号", "type": "text", "title": "运单号", "width": 20, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "运单号:", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "155_1750000000012", "top": 37, "bold": false, "left": 30, "type": "text", "title": "快递单号", "width": 78, "height": 7, "italic": false, "rotate": 0, "content": "快递单号", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "express_code", "lineHeight": 6}, {"id": "qrcode_1750000000013", "top": 4, "bold": false, "left": 120, "type": "qrcode", "title": "运单号", "width": 24, "height": 24, "italic": false, "rotate": 0, "content": "运单号", "autoWrap": true, "fontSize": "8", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "center", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "express_code", "lineHeight": 6}, {"id": "line_1750000000014", "top": 46, "left": 10, "type": "line", "width": 128, "height": 0.5}, {"id": "text_1750000000015", "top": 49, "bold": true, "left": 10, "name": "收件人信息", "type": "text", "title": "收件人信息", "width": 128, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "收件人信息", "autoWrap": true, "fontSize": "11", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "text_1750000000016", "top": 57, "bold": false, "left": 10, "name": "收件人", "type": "text", "title": "收件人", "width": 20, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "收件人:", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "148_1750000000017", "top": 57, "bold": false, "left": 30, "type": "text", "title": "收件人", "width": 38, "height": 7, "italic": false, "rotate": 0, "content": "收件人", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "name", "lineHeight": 6}, {"id": "text_1750000000018", "top": 57, "bold": false, "left": 70, "name": "电话", "type": "text", "title": "电话", "width": 14, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "电话:", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "149_1750000000019", "top": 57, "bold": false, "left": 84, "type": "text", "title": "手机号", "width": 54, "height": 7, "italic": false, "rotate": 0, "content": "手机号", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "mobile", "lineHeight": 6}, {"id": "text_1750000000020", "top": 65, "bold": false, "left": 10, "name": "地址", "type": "text", "title": "地址", "width": 14, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "地址:", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "150_1750000000021", "top": 65, "bold": false, "left": 24, "type": "text", "title": "省", "width": 18, "height": 7, "italic": false, "rotate": 0, "content": "省", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "province", "lineHeight": 6}, {"id": "151_1750000000022", "top": 65, "bold": false, "left": 42, "type": "text", "title": "市", "width": 18, "height": 7, "italic": false, "rotate": 0, "content": "市", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "city", "lineHeight": 6}, {"id": "152_1750000000023", "top": 65, "bold": false, "left": 60, "type": "text", "title": "区", "width": 18, "height": 7, "italic": false, "rotate": 0, "content": "区", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "area", "lineHeight": 6}, {"id": "153_1750000000024", "top": 65, "bold": false, "left": 78, "type": "text", "title": "详细地址", "width": 60, "height": 7, "italic": false, "rotate": 0, "content": "详细地址", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "detail_address", "lineHeight": 6}, {"id": "line_1750000000025", "top": 74, "left": 10, "type": "line", "width": 128, "height": 0.5}, {"id": "table_1750000000026", "top": 77, "left": 10, "name": "table", "rows": [{"id": "159_1750000000027", "bold": false, "type": "text", "title": "商品编码", "width": 22, "height": 6, "italic": false, "rotate": 0, "content": "商品编码", "autoWrap": true, "fontSize": "9", "textAlign": "left", "underline": false, "field_code": "item_code", "lineHeight": 6}, {"id": "160_1750000000028", "bold": false, "type": "text", "title": "商品名称", "width": 40, "height": 6, "italic": false, "rotate": 0, "content": "商品名称", "autoWrap": true, "fontSize": "9", "textAlign": "left", "underline": false, "field_code": "item_name", "lineHeight": 6}, {"id": "161_1750000000029", "bold": false, "type": "text", "title": "数量", "width": 18, "height": 6, "italic": false, "rotate": 0, "content": "数量", "autoWrap": true, "fontSize": "9", "textAlign": "left", "underline": false, "field_code": "plan_qty", "lineHeight": 6}, {"id": "162_1750000000030", "bold": false, "type": "text", "title": "单价", "width": 20, "height": 6, "italic": false, "rotate": 0, "content": "单价", "autoWrap": true, "fontSize": "9", "textAlign": "left", "underline": false, "field_code": "actual_price", "lineHeight": 6}, {"id": "163_1750000000031", "bold": false, "type": "text", "title": "备注", "width": 28, "height": 6, "italic": false, "rotate": 0, "content": "备注", "autoWrap": true, "fontSize": "9", "textAlign": "left", "underline": false, "field_code": "detail_remark", "lineHeight": 6}], "type": "table", "width": 128, "height": 75, "createdAt": "2026-06-14T00:00:00.000Z", "rowHeight": 6, "updatedAt": "2026-06-14T00:00:00.000Z", "headerHeight": 6}, {"id": "line_1750000000032", "top": 154, "left": 10, "type": "line", "width": 128, "height": 0.5}, {"id": "text_1750000000033", "top": 158, "bold": false, "left": 10, "name": "备注", "type": "text", "title": "备注", "width": 14, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "备注:", "autoWrap": true, "fontSize": "9", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "158_1750000000034", "top": 158, "bold": false, "left": 24, "type": "text", "title": "备注", "width": 114, "height": 7, "italic": false, "rotate": 0, "content": "备注", "autoWrap": true, "fontSize": "9", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "remark", "lineHeight": 6}, {"id": "text_printtime_label", "top": 166, "bold": false, "left": 10, "name": "打印时间", "type": "text", "title": "打印时间", "width": 26, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "打印时间:", "autoWrap": true, "fontSize": "9", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "164_printtime", "top": 166, "bold": false, "left": 36, "type": "text", "title": "打印时间", "width": 102, "height": 7, "italic": false, "rotate": 0, "content": "打印时间", "autoWrap": true, "fontSize": "9", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "print_time", "lineHeight": 6}] \ No newline at end of file diff --git a/src/api/setting.warehouse/settingwarehouse.ts b/src/api/setting.warehouse/settingwarehouse.ts index 15579a01..7a0313f5 100644 --- a/src/api/setting.warehouse/settingwarehouse.ts +++ b/src/api/setting.warehouse/settingwarehouse.ts @@ -286,7 +286,9 @@ export function settingWarehouseSaveSettings( } as any) } -/** 前端独立部署配置记录(getFrontConfig / saveFrontConfig / saveFrontCert 响应,一仓一行) */ +/** 前端独立部署配置记录(getFrontConfig / saveFrontConfig / saveFrontCert 响应,一仓一行,共 15 字段) + * 证书内容已改为直接入库:响应返回 cert_pem/key_pem(PEM 原文)供 settings 页回显, + * 不再返回 cert_path/key_path(路径字段仅由后端定时任务部署后回填,不出现在响应中)。 */ export type SettingWarehouseFrontConfig = { warehouse_id?: number domain?: string @@ -295,8 +297,11 @@ export type SettingWarehouseFrontConfig = { favicon_url?: string login_bg_url?: string theme?: Record | string | null - cert_path?: string - key_path?: string + /** 证书 PEM 原文(读 cert_pem 列;未配置为空字符串;仅 settings 页回显,公共接口 frontConfig.getByDomain 不返回) */ + cert_pem?: string + /** 私钥 PEM 原文(读 cert_key 列;未配置为空字符串;仅 settings 页回显,公共接口 frontConfig.getByDomain 不返回) */ + key_pem?: string + /** 证书到期时间(saveFrontCert 上传后按证书 validTo 权威写入;未上传为 null) */ cert_expire_at?: string | null sync_status?: number sync_attempts?: number diff --git a/src/components/ScanBox/index.vue b/src/components/ScanBox/index.vue index d12eaf55..8f3ed835 100644 --- a/src/components/ScanBox/index.vue +++ b/src/components/ScanBox/index.vue @@ -105,6 +105,7 @@ class="value-input" @change="handleCustomChange" @blur="normalizeTextValue(field)" + @paste="handleTextPaste($event, field)" /> @@ -676,6 +677,7 @@ class="compact-value-input" @change="handleCompactChange" @blur="normalizeTextValue(field)" + @paste="handleTextPaste($event, field)" /> @@ -1094,6 +1098,19 @@ function handleTextOperatorChange(field: any) { handleOperatorChange(field) } +/** 多值文本规整统一入口:换行/制表/中文标点 → 半角逗号;contains 额外剔除内部空白 */ +function normalizeMultiValueRaw(operator: string, rawValue: any): string { + if (rawValue === undefined || rawValue === null || rawValue === '') return '' + let normalized = normalizeMultiValueText(String(rawValue)) + if (operator === 'contains') { + normalized = normalized + .replace(/\s+/g, '') + .replace(/,+/g, ',') + .replace(/^,|,$/g, '') + } + return normalized +} + function normalizeTextValue(field: any) { const operator = customConditions[field.value].operator const value = customConditions[field.value].value @@ -1102,14 +1119,7 @@ function normalizeTextValue(field: any) { return } - let normalizedValue = normalizeMultiValueText(String(value)) - if (operator === 'contains') { - normalizedValue = normalizedValue - .replace(/\s+/g, '') - .replace(/,+/g, ',') - .replace(/^,|,$/g, '') - } - + const normalizedValue = normalizeMultiValueRaw(operator, value) if (normalizedValue !== value) { customConditions[field.value].value = normalizedValue handleCustomChange() @@ -1138,6 +1148,25 @@ function handleMultiValuePaste(event: ClipboardEvent, field: any) { }) } +/** 单行文本框粘贴换行兜底:浏览器对 (非 textarea)粘贴会直接丢弃换行,把多单号粘连成一行 + * (如 SYS..A\nSYS..B -> SYS..ASYS..B)。此处粘贴时拦截,抢在浏览器剥换行前把换行/制表转成逗号, + * 保证后续 contains/in/notin 可按逗号正确拆分传参 */ +function handleTextPaste(event: ClipboardEvent, field: any) { + const pasted = event.clipboardData?.getData('text') || '' + if (!pasted || !/[\r\n\t]/.test(pasted)) return + + event.preventDefault() + const normalizedPaste = normalizeMultiValueText(pasted) + if (!normalizedPaste) return + + const current = String(customConditions[field.value].value || '').trim() + customConditions[field.value].value = current + ? `${current.replace(/,+$/g, '')},${normalizedPaste}` + : normalizedPaste + + handleCustomChange() +} + const defaultDayStart = new Date(2000, 0, 1, 0, 0, 0) const defaultDayEnd = new Date(2000, 0, 1, 23, 59, 59) @@ -1399,11 +1428,13 @@ function buildAndEmitCustomCondition() { let conditionValue = condition.value - // 处理多值操作符:contains / in / notin 逗号分隔 -> 数组 - if (['contains', 'in', 'notin'].includes(op) && typeof conditionValue === 'string' && conditionValue) { - const values = conditionValue.split(',').map((v: string) => v.trim()).filter(Boolean) - if (values.length > 0) { - conditionValue = values + // 多值操作符 contains/in/notin:换行等分隔符先统一为逗号,再按逗号拆分为数组后传参 + if (['contains', 'in', 'notin'].includes(op)) { + const normalized = normalizeMultiValueRaw(op, conditionValue) + if (normalized) { + conditionValue = normalized.split(',').map((v: string) => v.trim()).filter(Boolean) + } else { + conditionValue = '' } } @@ -1572,9 +1603,13 @@ function buildConditionsObject() { let conditionValue = condition.value - if (['contains', 'in', 'notin'].includes(op) && typeof conditionValue === 'string' && conditionValue) { - const values = conditionValue.split(',').map((v: string) => v.trim()).filter(Boolean) - if (values.length > 0) conditionValue = values + if (['contains', 'in', 'notin'].includes(op)) { + const normalized = normalizeMultiValueRaw(op, conditionValue) + if (normalized) { + conditionValue = normalized.split(',').map((v: string) => v.trim()).filter(Boolean) + } else { + conditionValue = '' + } } const rangeMeta = resolveRangeConditionMeta(field, op) diff --git a/src/main.ts b/src/main.ts index 73edac7c..2185419f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,4 +1,4 @@ -import { createApp } from 'vue' +import { createApp, watch } from 'vue' import { createPinia } from 'pinia' import ElementPlus from 'element-plus' import 'element-plus/dist/index.css' @@ -9,6 +9,7 @@ import router from './router' import './permission' // permission control import SvgIcon from '@/components/SvgIcon/index.vue' import i18n, { loadServerMessages } from '@/lang/index' +import getPageTitle from '@/utils/get-page-title' import '@/styles/index.scss' // global css import { getToken } from '@/utils/auth' @@ -49,8 +50,52 @@ usePrinterComponentStore(pinia).bindRuntimeEvents() app.mount('#app') +// ── 页面/浏览器标题(document.title)统一在此设置 ── +// 使用显式 pinia 的 frontBrand store 引用(与品牌加载同源),避免组件/守卫上下文取到不一致实例。 +// 品牌加载完成前只显示“页面名”(不拼站点,不闪现默认“天豹云仓”);加载完成后: +// 成功→“页面名 - 品牌名”;失败/豁免→“页面名 - 天豹云仓”;/login 用纯站点名。 +const frontBrandStore = useFrontBrandStore(pinia) + +function resolveRoutePageTitle(route: { name?: unknown; meta?: Record }): string { + const tryMenuKey = (raw: unknown) => { + if (raw === undefined || raw === null || raw === '') return '' + const key = String(raw).replace(/_Child$/, '') + const path = `menu.${key}` + return i18n.global.te(path) ? String(i18n.global.t(path)) : '' + } + const fromName = tryMenuKey(route.name) + if (fromName) return fromName + const fromMeta = tryMenuKey(route.meta?.title) + if (fromMeta) return fromMeta + const metaTitle = route.meta?.title + return metaTitle != null && metaTitle !== '' ? String(metaTitle) : route.name != null ? String(route.name) : '' +} + +function applyDocumentTitle(route?: typeof router.currentRoute.value): void { + const target = route || router.currentRoute.value + if (!target || !target.path) return + const page = resolveRoutePageTitle(target) + if (!frontBrandStore.loaded) { + // 品牌加载中:仅页面名(/login 用中性“加载中...”),不显示默认站点名 + document.title = target.path.startsWith('/login') ? '加载中...' : page || '加载中...' + return + } + const site = frontBrandStore.siteTitle || '天豹云仓' + if (target.path.startsWith('/login')) { + document.title = site + return + } + document.title = getPageTitle(page, site) +} +applyDocumentTitle() +watch( + [() => frontBrandStore.loaded, () => frontBrandStore.siteTitle, () => router.currentRoute.value.path], + () => applyDocumentTitle() +) +router.afterEach((to) => applyDocumentTitle(to)) + // 前端独立部署品牌:登录前按当前访问域名拉取(免鉴权),成功后应用 favicon / 登录页标题品牌;失败静默走默认品牌 -useFrontBrandStore(pinia).loadBrandByDomain() +frontBrandStore.loadBrandByDomain() // 整页刷新(F5 / 顶部刷新)后的“一次自动连接”兜底: // 等路由守卫初始化(getInfo)完成、拿到登录上下文后再执行一次; diff --git a/src/permission.ts b/src/permission.ts index 40872cc8..475ebaa7 100644 --- a/src/permission.ts +++ b/src/permission.ts @@ -7,9 +7,6 @@ import NProgress from 'nprogress' import 'nprogress/nprogress.css' import { getToken } from '@/utils/auth' import { usePrinterComponentStore } from '@/stores/modules/printerComponent' -import { useFrontBrandStore } from '@/stores/modules/frontBrand' -import getPageTitle from '@/utils/get-page-title' -import i18n from '@/lang' import type { RouteRecordRaw } from 'vue-router' type RouteLogNode = { @@ -33,23 +30,6 @@ function formatRoutesForLog(routes: readonly RouteRecordRaw[]): RouteLogNode[] { NProgress.configure({ showSpinner: false }) -/** 与侧边栏 / 标签一致:优先按路由 name、再按 meta.title 匹配 menu.* 文案 */ -function resolveRouteDocumentTitle(route: typeof router.currentRoute.value) { - const tryMenuKey = (raw: unknown) => { - if (raw === undefined || raw === null || raw === '') return '' - const key = String(raw).replace(/_Child$/, '') - const path = `menu.${key}` - return i18n.global.te(path) ? String(i18n.global.t(path)) : '' - } - - const metaTitle = route.meta?.title as string | undefined - const fromName = tryMenuKey(route.name) - if (fromName) return fromName - const fromMetaAsKey = tryMenuKey(metaTitle) - if (fromMetaAsKey) return fromMetaAsKey - return metaTitle || (route.name != null ? String(route.name) : '') -} - const whiteList = ['/login','/redirect','/admin/land'] // no redirect whitelist /** 登录后“一次连接”:先加载用户偏好(含打印组件分用户+仓库配置),再自动连接一次 */ @@ -74,8 +54,7 @@ function maybeRetryPrintConnectionsAfterRefresh() { router.beforeEach(async (to, from) => { NProgress.start() // console.log("路由表",router.getRoutes()); - // 前端独立部署:页面标题前缀使用域名品牌站点标题(无则系统默认) - document.title = getPageTitle(resolveRouteDocumentTitle(to), useFrontBrandStore().siteTitle) + // 页面/浏览器标题统一由 App.vue(组件读 frontBrand store)设置,此处不再设置 const hasToken = getToken() diff --git a/src/stores/modules/frontBrand.ts b/src/stores/modules/frontBrand.ts index 19a9a2ae..d0508644 100644 --- a/src/stores/modules/frontBrand.ts +++ b/src/stores/modules/frontBrand.ts @@ -8,6 +8,39 @@ function isOkCode(code: unknown): boolean { return code === 200 || code === 1 || code === 0 } +/** 豁免域名兜底(未配置 VITE_FRONT_CONFIG_EXEMPT_HOSTS 时保持主域名豁免的历史默认行为) */ +const DEFAULT_FRONT_BRAND_EXEMPT_HOSTS = 'wms.wms.gztbyc.com' + +/** + * 解析豁免域名集合(主域名/自有默认站):命中后不拉取、不使用 frontConfig.getByDomain 品牌配置。 + * 来源 .env 的 VITE_FRONT_CONFIG_EXEMPT_HOSTS(逗号分隔,可分别配置开发/生产环境的豁免域名): + * - 显式置空(= 空值)→ 不豁免任何域名; + * - 未配置(undefined)→ 回退默认主域名 wms.wms.gztbyc.com。 + */ +function resolveFrontBrandExemptHosts(): Set { + const raw = import.meta.env.VITE_FRONT_CONFIG_EXEMPT_HOSTS + const source = raw === undefined || raw === null ? DEFAULT_FRONT_BRAND_EXEMPT_HOSTS : String(raw) + return new Set( + source + .split(',') + .map((s) => s.trim().toLowerCase()) + .filter(Boolean) + ) +} + +/** 豁免域名集合(按 import.meta.env 编译期静态替换) */ +const FRONT_BRAND_EXEMPT_HOSTS = resolveFrontBrandExemptHosts() + +/** 归一化访问域名:去协议/路径/端口、转小写,用于豁免判定与请求域名 */ +function normalizeFrontHost(raw?: string): string { + let host = (raw || '').trim().replace(/^https?:\/\//, '') + const slashIdx = host.indexOf('/') + if (slashIdx >= 0) host = host.slice(0, slashIdx) + const colonIdx = host.indexOf(':') + if (colonIdx >= 0) host = host.slice(0, colonIdx) + return host.toLowerCase() +} + /** * 前端独立部署品牌(frontConfig.getByDomain 消费端) * @@ -21,7 +54,8 @@ export const useFrontBrandStore = defineStore('frontBrand', () => { /** 品牌配置;null=使用系统默认品牌 */ const brand = ref(null) - /** theme 约定 4 字段键(文案/资源类,不映射 CSS 变量):网页名称/主页面 logo/登录页 logo/登录页文字 */ + /** 历史 theme 约定键(曾承载 网页名称/主页面logo/登录页logo/登录页文字):现由品牌顶层字段(title/logo_url 等)配置, + * 不再从 theme 语义消费;此处仅用于 applyThemeCssVars 排除,避免历史残留污染自定义 CSS 变量 */ const FRONT_THEME_DEFAULT_KEYS = ['siteName', 'mainLogoUrl', 'loginLogoUrl', 'loginText'] as const /** theme 归一化为对象(支持对象或 JSON 字符串) */ @@ -41,20 +75,20 @@ export const useFrontBrandStore = defineStore('frontBrand', () => { return {} }) - /** 网页名称:theme.siteName,缺省回退品牌 title,再回退系统默认标题(settings.title,默认“天豹云仓”) */ - const siteName = computed(() => { - const name = String(themeObj.value.siteName ?? '').trim() || brand.value?.title?.trim() || '' - return name || defaultSettings.title || '天豹云仓' - }) - /** 登录页文字(slogan):theme.loginText(空→调用方用默认文案) */ - const themeLoginText = computed(() => String(themeObj.value.loginText ?? '').trim()) - /** 登录页 logo:theme.loginLogoUrl,缺省回退品牌 logo_url */ - const themeLoginLogoUrl = computed(() => String(themeObj.value.loginLogoUrl ?? '').trim() || brand.value?.logo_url?.trim() || '') - /** 主页面/顶栏 logo:theme.mainLogoUrl(空→调用方用默认图片) */ - const themeMainLogoUrl = computed(() => String(themeObj.value.mainLogoUrl ?? '').trim()) + /** 网页名称:品牌顶层 title,缺省回退系统默认标题(settings.title,默认“天豹云仓”)。不再从 theme 约定 siteName */ + const siteName = computed(() => brand.value?.title?.trim() || defaultSettings.title || '天豹云仓') + /** 登录页文字(slogan):无独立配置字段时为默认文案(登录页用默认标语)。不再从 theme 约定 loginText */ + const themeLoginText = computed(() => '') + /** 登录页 logo:品牌顶层 logo_url(空→调用方用默认图片)。不再从 theme 约定 loginLogoUrl */ + const themeLoginLogoUrl = computed(() => brand.value?.logo_url?.trim() || '') + /** 主页面/顶栏 logo:品牌顶层 logo_url(空→调用方用默认图片)。不再从 theme 约定 mainLogoUrl */ + const themeMainLogoUrl = computed(() => brand.value?.logo_url?.trim() || '') /** 站点标题/网页名称(theme.siteName 或品牌 title,最后回退系统默认标题 settings.title) */ const siteTitle = computed(() => siteName.value) + + // 浏览器标题(document.title)由 App.vue 组件统一设置(组件注入 store 可靠),此处不做标题写入 + /** 品牌 Logo(空串→调用方回退默认 Logo) */ const logoUrl = computed(() => brand.value?.logo_url?.trim() || '') /** 登录页背景图(空串→调用方用默认背景) */ @@ -65,9 +99,16 @@ export const useFrontBrandStore = defineStore('frontBrand', () => { /** 按当前访问域名拉取品牌并应用全局(favicon / 登录页标题 / theme CSS 变量) */ async function loadBrandByDomain(domain?: string): Promise { if (loaded.value) return + const host = normalizeFrontHost(domain ?? window.location.hostname) + // 主域名豁免:不拉取、不应用 getByDomain 品牌配置,直接保持系统默认品牌(默认标题/默认 logo/无主题 CSS 变量) + if (!host || FRONT_BRAND_EXEMPT_HOSTS.has(host)) { + brand.value = null + loaded.value = true + applyThemeCssVars(null) + applyBrandGlobals() + return + } try { - const rawHost = domain ?? window.location.hostname - const host = (rawHost || '').trim().replace(/^https?:\/\//, '') if (host) { const res: any = await frontConfigGetByDomain({ domain: host }) const data = res?.data && typeof res.data === 'object' ? res.data : res @@ -83,6 +124,23 @@ export const useFrontBrandStore = defineStore('frontBrand', () => { // 无论成功/失败都应用主题:无 theme/brand=null 时清除上一次已应用的 CSS 变量,避免换域名后残留旧主题 applyThemeCssVars(brand.value?.theme) applyBrandGlobals() + // 浏览器标题由 App.vue 监听 frontBrand.loaded/siteTitle 统一设置:成功→品牌名;失败/豁免→默认“天豹云仓”。 + // 追加兜底:品牌加载成功后短时轮询修正标题站点名(应对运行环境存在重复模块/其它写入把标题写成默认的情况), + // 保证最终标题稳定为品牌名。 + if (brand.value) { + let guardTries = 0 + const guardTimer = window.setInterval(() => { + const site = siteTitle.value || '天豹云仓' + const cur = document.title || '' + if (cur !== site && !cur.endsWith(` - ${site}`)) { + const sep = cur.lastIndexOf(' - ') + document.title = sep > 0 ? `${cur.slice(0, sep)} - ${site}` : site + } + if (++guardTries >= 12 || document.title === site || document.title.endsWith(` - ${site}`)) { + window.clearInterval(guardTimer) + } + }, 200) + } } } @@ -129,10 +187,7 @@ export const useFrontBrandStore = defineStore('frontBrand', () => { const icon = document.querySelector('link[rel~="icon"]') if (icon) icon.href = b.favicon_url.trim() } - // 登录页标题:已登录系统内的路由标题由 permission 守卫按 siteTitle 维护 - if (siteName.value && /\/login(\/|$|\?)/.test(window.location.pathname)) { - document.title = siteName.value - } + // 浏览器标题(document.title)由 App.vue 组件统一设置,此处仅处理 favicon } return { diff --git a/src/utils/get-page-title.js b/src/utils/get-page-title.js deleted file mode 100644 index 5bf3eb0f..00000000 --- a/src/utils/get-page-title.js +++ /dev/null @@ -1,10 +0,0 @@ -import defaultSettings from '@/settings' - -const title = defaultSettings.title || '天豹云仓' - -export default function getPageTitle(pageTitle) { - if (pageTitle) { - return `${pageTitle} - ${title}` - } - return `${title}` -} diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 6b10804d..5cdc9160 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -256,7 +256,7 @@ const userStore = useUserStore() // ── 前端独立部署品牌(frontConfig.getByDomain):按域名替换 Logo / 标题 / 背景 ── const frontBrand = useFrontBrandStore() const brand = computed(() => frontBrand.brand) -// 主题约定:网页名称(theme.siteName||brand.title)、登录页 logo(theme.loginLogoUrl||品牌 logo)、登录页文字(theme.loginText) +// 网页名称=品牌顶层 title(站点标题)、登录页 logo=品牌顶层 logo_url;登录页文字无独立配置字段时用默认标语(saveFrontConfig 顶层品牌字段配置) const brandName = computed(() => frontBrand.siteTitle) const brandLogo = computed(() => frontBrand.themeLoginLogoUrl || '../../../public/logo/1.png') const loginDesc = computed(() => frontBrand.themeLoginText || '现代化仓储管理系统 - 助力企业高效运营') diff --git a/src/views/order/waveOrder/GroupWaveBatchListPanel.vue b/src/views/order/waveOrder/GroupWaveBatchListPanel.vue index 5af373a9..4cddd77f 100644 --- a/src/views/order/waveOrder/GroupWaveBatchListPanel.vue +++ b/src/views/order/waveOrder/GroupWaveBatchListPanel.vue @@ -1544,36 +1544,17 @@ async function loadWaveStoreOptions() { } } -/** order.wave.batchList where:需透传操作符的模糊文本字段(波次号/创建人/快递;其余字段保持等值/区间等标量语义) */ -const WAVE_OPERATOR_FUZZY_FIELDS = new Set(['wave_no', 'creator', 'logistics_name']) -/** 多值文本操作符(与全站列表页约定一致):contains/in/notin 的 value 以数组下发,其余为字符串 */ -const WAVE_OPERATOR_MULTI_VALUE = new Set(['contains', 'in', 'notin']) - function buildWhereConditions(rawConditions: Record) { const where: Record = {} Object.keys(rawConditions || {}).forEach((key) => { const condition = rawConditions[key] if (condition && typeof condition === 'object' && 'operator' in condition) { - const rawValue = condition.value - if (rawValue === undefined || rawValue === null || rawValue === '' || (Array.isArray(rawValue) && rawValue.length === 0)) { + const value = condition.value + if (value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0)) { return } - // 模糊文本字段:操作符经 where 下发后端({ operator, value }),contains/in/notin 多值以数组传递 - if (WAVE_OPERATOR_FUZZY_FIELDS.has(key)) { - const operator = String(condition.operator || 'like') - const text = (Array.isArray(rawValue) ? rawValue.join(',') : String(rawValue)).trim() - if (!text) return - if (WAVE_OPERATOR_MULTI_VALUE.has(operator)) { - const values = text.split(',').map((v: string) => v.trim()).filter(Boolean) - if (!values.length) return - where[key] = { operator, value: values } - } else { - where[key] = { operator, value: text } - } - return - } - // 其余字段(select 等值、min/max 区间等):保持标量值透传 - where[key] = rawValue + // order.wave.batchList where 为标量白名单:等值/模糊字段直接透传 value(store_id 支持数组 in) + where[key] = value return } if (condition !== undefined && condition !== null && condition !== '') { diff --git a/src/views/order/waveOrder/SandanWaveBatchListPanel.vue b/src/views/order/waveOrder/SandanWaveBatchListPanel.vue index 2c221749..08714984 100644 --- a/src/views/order/waveOrder/SandanWaveBatchListPanel.vue +++ b/src/views/order/waveOrder/SandanWaveBatchListPanel.vue @@ -982,36 +982,17 @@ async function loadWaveStoreOptions() { } } -/** order.wave.batchList where:需透传操作符的模糊文本字段(波次号/创建人/快递;其余字段保持等值/区间等标量语义) */ -const WAVE_OPERATOR_FUZZY_FIELDS = new Set(['wave_no', 'creator', 'logistics_name']) -/** 多值文本操作符(与全站列表页约定一致):contains/in/notin 的 value 以数组下发,其余为字符串 */ -const WAVE_OPERATOR_MULTI_VALUE = new Set(['contains', 'in', 'notin']) - function buildWhereConditions(rawConditions: Record) { const where: Record = {} Object.keys(rawConditions || {}).forEach((key) => { const condition = rawConditions[key] if (condition && typeof condition === 'object' && 'operator' in condition) { - const rawValue = condition.value - if (rawValue === undefined || rawValue === null || rawValue === '' || (Array.isArray(rawValue) && rawValue.length === 0)) { + const value = condition.value + if (value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0)) { return } - // 模糊文本字段:操作符经 where 下发后端({ operator, value }),contains/in/notin 多值以数组传递 - if (WAVE_OPERATOR_FUZZY_FIELDS.has(key)) { - const operator = String(condition.operator || 'like') - const text = (Array.isArray(rawValue) ? rawValue.join(',') : String(rawValue)).trim() - if (!text) return - if (WAVE_OPERATOR_MULTI_VALUE.has(operator)) { - const values = text.split(',').map((v: string) => v.trim()).filter(Boolean) - if (!values.length) return - where[key] = { operator, value: values } - } else { - where[key] = { operator, value: text } - } - return - } - // 其余字段(select 等值、min/max 区间等):保持标量值透传 - where[key] = rawValue + // order.wave.batchList where 为标量白名单:等值/模糊字段直接透传 value(store_id 支持数组 in) + where[key] = value return } if (condition !== undefined && condition !== null && condition !== '') { diff --git a/src/views/order/waveOrder/config/wave-config.ts b/src/views/order/waveOrder/config/wave-config.ts index 651d7573..9b23e3ab 100644 --- a/src/views/order/waveOrder/config/wave-config.ts +++ b/src/views/order/waveOrder/config/wave-config.ts @@ -9,7 +9,6 @@ export const WAVE_PAGE_CONFIG = { import { buyerMessageHasFilterOptions, - ORDER_BULK_SEARCH_OPERATORS, scanBasicField, scanWorkflowField, type ToolbarButtonConfig, @@ -104,13 +103,7 @@ export const waveUpperTableDefaults = { /** 左侧筛选可用字段(对标待处理订单 ScanBox 分组排序) */ export const waveAvailableFields = [ // ===== 波次信息 ===== - waveScanBasicField({ - label: '波次号', - value: 'wave_no', - type: 'text', - operators: ORDER_BULK_SEARCH_OPERATORS, - defaultOperator: 'like' - }), + waveScanBasicField({ label: '波次号', value: 'wave_no', type: 'text' }), waveScanBasicField({ label: '货主', value: 'store_id', @@ -215,20 +208,8 @@ export const waveAvailableFields = [ { label: 'PDA策略', value: 2 } ] }), group: WAVE_SCAN_OTHER_GROUP }, - { ...waveScanBasicField({ - label: '快递', - value: 'logistics_name', - type: 'text', - operators: ORDER_BULK_SEARCH_OPERATORS, - defaultOperator: 'like' - }), group: WAVE_SCAN_OTHER_GROUP }, - { ...waveScanBasicField({ - label: '创建人', - value: 'creator', - type: 'text', - operators: ORDER_BULK_SEARCH_OPERATORS, - defaultOperator: 'like' - }), group: WAVE_SCAN_OTHER_GROUP }, + { ...waveScanBasicField({ label: '快递', value: 'logistics_name', type: 'text' }), group: WAVE_SCAN_OTHER_GROUP }, + { ...waveScanBasicField({ label: '创建人', value: 'creator', type: 'text' }), group: WAVE_SCAN_OTHER_GROUP }, ] /** 抓取散单候选:左侧筛选可用字段 */ diff --git a/src/views/system/setting/basicManagement/newview/pages/FrontConfigForm.vue b/src/views/system/setting/basicManagement/newview/pages/FrontConfigForm.vue index b746f1d3..ab833742 100644 --- a/src/views/system/setting/basicManagement/newview/pages/FrontConfigForm.vue +++ b/src/views/system/setting/basicManagement/newview/pages/FrontConfigForm.vue @@ -1,7 +1,7 @@ + + {{ frontMeta.warehouse_id ?? '—' }} {{ frontMeta.domain || '—' }} {{ frontCertStatus.text }} + {{ formatFrontDateTime(frontMeta.cert_expire_at) }} + + 已配置(见下方回显) + 未配置 + + {{ formatFrontDateTime(frontMeta.updated_at) }} {{ frontSyncStatusText }} - {{ frontMeta.last_synced_at || '—' }} · 尝试 {{ frontMeta.sync_attempts ?? 0 }} 次 + {{ frontMeta.sync_attempts ?? 0 }} 次 + {{ formatFrontDateTime(frontMeta.last_synced_at) }} + {{ frontMeta.last_sync_error || '—' }} @@ -62,27 +72,6 @@
-
-
- 网页名称 - -
-
- 主页面 Logo - -
-
- 登录页 Logo - -
-
- 登录页文字 - -
-
-
以上 4 个为约定主题字段,均可留空:留空不写入主题、使用系统默认值。
- - 自定义主题键值(映射 CSS 变量 --<key>)
@@ -91,6 +80,7 @@
新增自定义键
+
主题仅承载 CSS 变量自定义键(保存后应用为 --<key>);网页名称/Logo/favicon/登录背景等品牌字段见上方表单(getFrontConfig/saveFrontConfig 顶层字段),不再写入主题。
@@ -115,6 +105,52 @@ 上传成功后自动写入证书到期时间、重置同步状态并重新加载配置 + + + 证书内容回显(cert_pem / key_pem) +
+ + + +
+ 已配置 + 未配置 + 复制证书 +
+ +
+ +
+ 已配置 + 未配置 + 复制私钥 +
+ +
+
+
@@ -133,21 +169,24 @@ defineOptions({ name: 'FrontConfigForm' }) const okCode = (code: unknown) => code === 1 || code === 200 || code === 0 -/** getFrontConfig 响应:仓库前端部署元信息(品牌 + 证书/同步内部字段,仅用于本页回显) */ +/** getFrontConfig 响应:仓库前端部署元信息(品牌 + 证书/同步内部字段,仅用于本页回显) + * 最新接口返回 cert_pem/key_pem(PEM 原文),不再返回 cert_path/key_path。 */ type FrontConfigMeta = { + warehouse_id?: number domain?: string title?: string logo_url?: string favicon_url?: string login_bg_url?: string theme?: Record | string | null - cert_path?: string - key_path?: string + cert_pem?: string + key_pem?: string cert_expire_at?: string | null sync_status?: number sync_attempts?: number last_sync_error?: string last_synced_at?: string | null + updated_at?: string | null [key: string]: unknown } @@ -156,15 +195,15 @@ const frontPageLoading = ref(false) const frontSaving = ref(false) const frontCertSaving = ref(false) const frontMeta = reactive({}) +/** 证书回显折叠面板展开项(有证书时默认展开 cert_pem/key_pem) */ +const frontCertEchoOpen = ref([]) const frontForm = reactive({ title: '', logo_url: '', favicon_url: '', login_bg_url: '' }) -/** 主题约定 4 字段(文案/资源类,允许空;空=不写入主题、使用默认) */ -const FRONT_THEME_FIXED_KEYS = ['siteName', 'mainLogoUrl', 'loginLogoUrl', 'loginText'] as const -const frontThemeDefault = reactive>({ - siteName: '', - mainLogoUrl: '', - loginLogoUrl: '', - loginText: '' -}) +/** 历史遗留 theme 约定键(曾承载 网页名称/主页面Logo/登录页Logo/登录页文字)。 + * 现已改由品牌顶层字段(saveFrontConfig:title/logo_url 等)配置,theme 不再约定这些业务键。 + * 加载时隐藏不展示、保存时原样保留,避免历史数据丢失。 */ +const FRONT_THEME_LEGACY_KEYS = ['siteName', 'mainLogoUrl', 'loginLogoUrl', 'loginText'] as const +/** 历史遗留 theme 键原值(只读保留:不展示、不编辑,保存时透传回写) */ +const frontThemeLegacy = reactive>({}) const frontThemeRows = ref>([]) const frontCert = reactive({ domain: '', pem: '', key: '' }) @@ -179,12 +218,43 @@ const frontSyncStatusText = computed(() => { /** 同步是否失败(用于同步失败告警) */ const frontSyncFailed = computed(() => Number(frontMeta.sync_status) === 2) +/** 是否已配置证书(cert_pem 非空,用于回显区展示) */ +const frontHasCert = computed(() => Boolean(frontMeta.cert_pem && String(frontMeta.cert_pem).trim())) +/** 是否回显私钥(key_pem 非空) */ +const frontHasKey = computed(() => Boolean(frontMeta.key_pem && String(frontMeta.key_pem).trim())) + +/** 复制接口回显的证书/私钥内容到剪贴板 */ +async function copyFrontText(text: unknown) { + const value = String(text ?? '').trim() + if (!value) { + ElMessage.warning('无内容可复制') + return + } + try { + await navigator.clipboard.writeText(value) + ElMessage.success('已复制到剪贴板') + } catch { + ElMessage.warning('复制失败,请手动全选复制') + } +} + function fmtFrontDate(ts: number): string { const d = new Date(ts) const p = (n: number) => String(n).padStart(2, '0') return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())}` } +/** 格式化接口返回的时间字段(ISO/秒/毫秒时间戳 → 本地 YYYY-MM-DD HH:mm:ss),空值/非法返回 '—' */ +function formatFrontDateTime(value: unknown): string { + const raw = String(value ?? '').trim() + if (!raw) return '—' + const ts = Date.parse(raw) + if (Number.isNaN(ts)) return '—' + const d = new Date(ts) + const p = (n: number) => String(n).padStart(2, '0') + return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())}` +} + /** 证书状态:none=未上传,success=正常,warning=30 天内到期,danger=已过期 */ const frontCertStatus = computed<{ level: 'success' | 'warning' | 'danger' | 'info' | 'none' @@ -262,6 +332,9 @@ async function loadFrontConfig() { const cfg = unwrapSettingWarehousePayload(res as Record) Object.keys(frontMeta).forEach((k) => delete frontMeta[k]) Object.assign(frontMeta, cfg) + // 有证书内容时默认展开证书/私钥回显面板(无则收起,字段仍以「未配置」占位展示) + frontCertEchoOpen.value = + cfg.cert_pem || cfg.key_pem ? ['cert_pem', 'key_pem'] : [] frontForm.title = String(cfg.title ?? '') frontForm.logo_url = String(cfg.logo_url ?? '') frontForm.favicon_url = String(cfg.favicon_url ?? '') @@ -279,16 +352,14 @@ async function loadFrontConfig() { } } const src = themeObj - // 约定 4 字段单独编辑(允许空),其余键进入自定义 CSS 变量区 - FRONT_THEME_FIXED_KEYS.forEach((k) => { - frontThemeDefault[k] = '' - }) + // 历史遗留约定键:只读保留(隐藏不展示);其余键进入自定义 CSS 变量区编辑 + Object.keys(frontThemeLegacy).forEach((k) => delete frontThemeLegacy[k]) frontThemeRows.value = [] if (src) { Object.keys(src).forEach((k) => { const value = src[k] - if (FRONT_THEME_FIXED_KEYS.includes(k as (typeof FRONT_THEME_FIXED_KEYS)[number])) { - frontThemeDefault[k] = stringifyFrontThemeValue(value) + if (FRONT_THEME_LEGACY_KEYS.includes(k as (typeof FRONT_THEME_LEGACY_KEYS)[number])) { + frontThemeLegacy[k] = value } else if (value !== undefined && value !== null && String(value).trim() !== '') { frontThemeRows.value.push({ key: k, value: stringifyFrontThemeValue(value) }) } @@ -304,16 +375,13 @@ async function loadFrontConfig() { async function saveFrontConfig() { frontSaving.value = true try { - const themeObj: Record = {} - // 约定 4 字段允许空:空值不写入主题(前端用默认文案/图片) - FRONT_THEME_FIXED_KEYS.forEach((k) => { - const val = String(frontThemeDefault[k] ?? '').trim() - if (val) themeObj[k] = val - }) + const themeObj: Record = { ...frontThemeLegacy } frontThemeRows.value.forEach((row) => { const key = row.key.trim() const valueText = row.value.trim() if (!key || !valueText) return + // 历史遗留约定键不可通过自定义区再次写入(已由顶层品牌字段承担) + if (FRONT_THEME_LEGACY_KEYS.includes(key as (typeof FRONT_THEME_LEGACY_KEYS)[number])) return themeObj[key] = parseFrontThemeValue(valueText) }) const res = await settingWarehouseSaveFrontConfig({ @@ -450,17 +518,6 @@ loadFrontConfig() flex: 0 0 180px; } - &__label { - flex: 0 0 180px; - font-size: 13px; - color: #606266; - text-align: right; - padding-right: 4px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - } - &__value { flex: 1; min-width: 200px; @@ -475,4 +532,30 @@ loadFrontConfig() margin-left: 0; margin-top: 6px; } + +.front-cert-echo { + max-width: 720px; + + &__alert { + margin-bottom: 12px; + } + + &__collapse { + margin-bottom: 8px; + } + + &__bar { + display: flex; + align-items: center; + justify-content: space-between; + gap: 8px; + margin-bottom: 6px; + } + + &__pem { + :deep(.el-textarea__inner) { + font-family: var(--el-font-family-mono), Consolas, Menlo, monospace; + } + } +}