1
This commit is contained in:
parent
f7dbc127cc
commit
90bd48b2f9
123
docs/前端独立部署-接口落实任务清单.md
Normal file
123
docs/前端独立部署-接口落实任务清单.md
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
# 前端独立部署 4 接口 · 项目落实任务清单
|
||||||
|
|
||||||
|
> 关联接口(`pending-updates.json` 2026-09-08 added):
|
||||||
|
> `frontConfig.getByDomain`、`setting.warehouse.getFrontConfig`、`setting.warehouse.saveFrontConfig`、`setting.warehouse.saveFrontCert`
|
||||||
|
> 目标:按后端「SaaS 仓库前端独立部署 + 按域名品牌化」设计把 4 接口在本项目全部落实。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. 接口矩阵与角色
|
||||||
|
|
||||||
|
| 接口 | 角色 | 鉴权 | 状态 |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `setting.warehouse.getFrontConfig` | 仓库侧配置回显 | 登录 + 仓库主体 | ✅ 已接入 |
|
||||||
|
| `setting.warehouse.saveFrontConfig` | 仓库侧保存品牌 | 登录 + 仓库主体 | ✅ 已接入 |
|
||||||
|
| `setting.warehouse.saveFrontCert` | 仓库侧上传域名+证书 | 登录 + 仓库主体 | ✅ 已接入 |
|
||||||
|
| `frontConfig.getByDomain` | 公网按域名拉品牌 | 免登录/免鉴权 | ❌ 未接入(消费端缺口) |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. 现状盘点
|
||||||
|
|
||||||
|
### 2.1 已完成
|
||||||
|
- **API 封装**
|
||||||
|
- `src/api/frontconfig/frontConfig.ts`(新目录,`frontConfigGetByDomain` + `FrontConfigPublicItem`)
|
||||||
|
- `src/api/setting.warehouse/settingwarehouse.ts` 新增 3 个封装与 `SettingWarehouseFrontConfig` 等类型
|
||||||
|
- **配置管理页面(基础设置)**:`src/views/system/setting/basicManagement/newview/pages/WarehouseSettingsForm.vue`
|
||||||
|
- 底部「前端独立部署」区块:品牌表单(title/logo/favicon/login_bg + 主题键值编辑)+ 保存品牌配置(`saveFrontConfig`)
|
||||||
|
- 自持域名&证书表单(domain/pem/key)+ 上传证书(`saveFrontCert`)
|
||||||
|
- 加载即 `getFrontConfig` 回显;meta 展示 `domain / cert_expire_at / sync_status`
|
||||||
|
- 已通过 type-check / build。
|
||||||
|
|
||||||
|
### 2.2 未落实 / 缺口
|
||||||
|
- `frontConfig.getByDomain` 的**消费端**完全没有(登录页/入口仍用静态品牌,`index.html` 的 favicon/title 固定)。
|
||||||
|
- 配置页**同步状态展示不完整**:`last_sync_error / sync_attempts / last_synced_at` 未回显、无证书到期提醒。
|
||||||
|
- 缺少“按域名品牌”的全局承载层(品牌状态/store、动态 favicon & `document.title` 应用点)。
|
||||||
|
- 缺少端到端验收步骤与登记核对项。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. 任务清单
|
||||||
|
|
||||||
|
> 分级:P0=核心闭环必须;P1=建议;P2=可选优化。括号为建议涉及文件(最终以实现为准)。
|
||||||
|
|
||||||
|
### 模块 A:品牌消费端(frontConfig.getByDomain)【P0 · 主要缺口】
|
||||||
|
| # | 任务 | 涉及文件 | 说明 / 验收 |
|
||||||
|
|---|---|---|---|
|
||||||
|
| A1 | 新建「前端品牌」store(或 composable) | `src/stores/modules/frontBrand.ts`(新建) | 保存 getByDomain 结果:`{ domain,title,logo_url,login_bg_url,favicon_url,theme, configured }`;提供 `loadBrandByDomain()`:取 `location.hostname` → `frontConfigGetByDomain({domain})`;404/异常/空结果时置默认(不报错) |
|
||||||
|
| A2 | 登录前/入口初始化触发加载 | `src/main.ts` 或 `src/permission.ts` 或 `src/views/login/index.vue` | 免鉴权时机(登录页挂载 / 路由守卫放行白名单段);成功才应用品牌,失败静默走默认;可加本地短缓存避免每次刷新请求 |
|
||||||
|
| A3 | 登录页品牌化 | `src/views/login/index.vue` | 左侧品牌图/标题/Logo 用 store 值替换静态资源;登录背景图用 `login_bg_url` |
|
||||||
|
| A4 | 全局 favicon / document.title 动态化 | `index.html`、`src/permission.ts`、布局入口 | 有 `favicon_url` 时替换 `<link rel="icon">`;`document.title`(页面标题前缀)用 `title` 覆盖默认系统名;无则维持现状 |
|
||||||
|
| A5 | theme 应用(CSS 变量级联) | 主题相关(settings/样式入口) | 若返回 `theme` 对象有既定 CSS 变量约定则写入 `:root`/`html`;暂无字段约定时仅记录、不强行映射(与后端确认字段后补) |
|
||||||
|
| A6 | 多仓库同部署的域名解析说明 | ✅ 已落地:并入 `docs/前端独立部署-操作与部署说明.md` §5 第 5 点 | 同一部署访问不同仓库自持域名 → 后端按 hostname 区分返回;前端无需感知 |
|
||||||
|
|
||||||
|
> ✅ **进度(2026-09-08):A1 ~ A6 已全部落地**
|
||||||
|
> - A1 `src/stores/modules/frontBrand.ts`(新增 Pinia store):`loadBrandByDomain()` 按 `location.hostname` 拉品牌,404/异常/`configured=false` 静默回退默认;`loaded` 幂等;`applyBrandGlobals()` 应用 favicon、登录页标题
|
||||||
|
> - A2 触发:`src/main.ts` `app.mount` 后调用 `useFrontBrandStore(pinia).loadBrandByDomain()`(免鉴权)
|
||||||
|
> - A4 全局标题/favicon:`src/utils/get-page-title.ts` 支持第二参 `baseTitle`;`src/permission.ts` 路由守卫标题前缀用 `frontBrand.siteTitle`;favicon `<link rel=icon>` 动态替换(仅当品牌有效)
|
||||||
|
> - A3 登录页品牌化:`src/views/login/index.vue` Logo(`:src=brandLogo`)、站点标题(`brand-name` h1,仅品牌 title 存在时显示)、登录背景(`:style=loginBgStyle` 用 `login_bg_url`)
|
||||||
|
> - A5 theme→CSS 变量:`src/stores/modules/frontBrand.ts` `applyThemeCssVars(theme)` 将 theme 顶层键写入 `--<key>` 至 `<html>`(仅标量值;非法键/嵌套对象忽略;键需 `[A-Za-z_][A-Za-z0-9_-]*`);brand 为空/换品牌时清除已应用变量(无残留)。约定:theme 键即 CSS 变量名(如 `primary`→`--primary`,`bgColor`→`--bgColor`)
|
||||||
|
> - 验证:type-check 通过
|
||||||
|
|
||||||
|
### 模块 B:配置管理页完善(基础设置)【P1】
|
||||||
|
| # | 任务 | 涉及文件 | 说明 / 验收 |
|
||||||
|
|---|---|---|---|
|
||||||
|
| B1 | 同步状态详情回显 | `.../newview/pages/WarehouseSettingsForm.vue` | meta 区补充 `sync_attempts / last_sync_error / last_synced_at`;`sync_status=2` 时红色展示 `last_sync_error` 文案 |
|
||||||
|
| B2 | 证书到期提醒 | 同上 | `cert_expire_at` 距当前 <30 天(或已过期)时给出 `el-alert`/tag 提醒;未上传显示“未上传” |
|
||||||
|
| B3 | 保存/上传后处理核对 | ✅ 已落地:`WarehouseSettingsForm.vue` 品牌/证书按钮区补语义提示文案(品牌留空即清空、主题删空即清空、保存/上传成功后自动重新加载),实现已符合(空值清空 + 成功后 loadFrontConfig) |
|
||||||
|
| B4 | 接口登记核对 | `workflows/api-doc-agent/config/接口.md` | 4 个 method 应 `启用=是、占位=否`(api-list-update 已自动同步;人工复核一次) |
|
||||||
|
|
||||||
|
> ✅ **进度(2026-09-08):B1 ~ B4 已全部落地**
|
||||||
|
> - B1 同步状态详情:`WarehouseSettingsForm.vue` meta 区新增「同步详情」列(`last_synced_at` · 尝试 `sync_attempts` 次);`sync_status=2` 时顶部红 `el-alert` 展示 `last_sync_error`
|
||||||
|
> - B2 证书状态:meta「证书状态」列按 `cert_expire_at` 显示 tag(未上传→灰、正常→绿、≤30 天→黄「剩 N 天」、过期→红);过期/临期在配置区顶部显示 `el-alert` 提醒
|
||||||
|
> - B4 接口登记核对:`workflows/api-doc-agent/config/接口.md` 人工复核通过 —— 4 个 method(frontConfig.getByDomain / setting.warehouse.getFrontConfig / saveFrontConfig / saveFrontCert)均 `启用=是、占位=否`,归属路径正确
|
||||||
|
> - 验证:type-check 通过
|
||||||
|
|
||||||
|
### 模块 C:文档与端到端验收【P1】
|
||||||
|
| # | 任务 | 说明 / 验收 |
|
||||||
|
|---|---|---|
|
||||||
|
| C1 | 端到端验收用例 | ① 仓库设置保存 title/logo → `frontConfig.getByDomain(该域名)` 返回新值;② 上传证书成功 → `domain` 生效、`sync_status=0`;③ 未登记域名访问 getByDomain → 404/`configured=false` → 前端默认品牌;④ 品牌字段留空保存 → 返回空串清空;⑤ theme 键值保存后回显一致(对象结构);⑥ 换域名后无旧品牌残留(后端已清缓存,前端无本地旧值) |
|
||||||
|
| C2 | 操作/部署说明(可选) | ✅ 已落地:`docs/前端独立部署-操作与部署说明.md`(登记流程 / 证书格式与 SAN / 错误码对照 / 前端部署验证 / 代码落点) |
|
||||||
|
|
||||||
|
> ✅ **进度(2026-09-08):C1、C2 已落地**(C1 清单见下;C2 操作/部署说明见 `docs/前端独立部署-操作与部署说明.md`)
|
||||||
|
>
|
||||||
|
> **C1 端到端验收清单(可执行)**
|
||||||
|
>
|
||||||
|
> 0. 环境准备:在仓库设置登记自持域名并保存品牌;浏览器访问对应域名(或临时改 hosts 把域名指向该部署)。
|
||||||
|
>
|
||||||
|
> | # | 操作 | 预期结果 |
|
||||||
|
> |---|---|---|
|
||||||
|
> | ① | 仓库设置保存 title/logo_url/login_bg_url/favicon_url/theme | `getFrontConfig` 回显与保存一致;theme 键值回显一致(对象结构) |
|
||||||
|
> | ② | 用登记域名访问登录页(无缓存/新会话) | 登录页显示品牌 Logo/标题/背景;`<link rel=icon>` href 变为 favicon_url;`document.title` 使用品牌 title;theme 标量键已作为 `--<key>` 写入 `<html>`(DevTools 验证) |
|
||||||
|
> | ③ | 未登记域名 / 主域名访问 | `getByDomain` 404/`configured=false` → 登录页保持系统默认品牌与主题(无报错) |
|
||||||
|
> | ④ | 上传证书(domain+pem+key) | `getFrontConfig` 返回 `domain` 生效、`cert_expire_at` 有值、`sync_status=0`;配置页“证书状态”为绿/黄并显示有效期 |
|
||||||
|
> | ⑤ | 将证书改成即将过期/过期的时间(或造数) | 配置页顶部出现对应 warning/error `el-alert`;证书状态 tag 变黄/红 |
|
||||||
|
> | ⑥ | 触发同步失败(如证书不可用) | 配置页顶部红 alert 显示 `last_sync_error`;“同步详情”展示尝试次数与最近同步 |
|
||||||
|
> | ⑦ | 切换/清除域名配置后刷新 | 前端无旧品牌残留:favicon/标题/主题 CSS 变量恢复默认 |
|
||||||
|
>
|
||||||
|
> **getByDomain 请求示意(免鉴权公共接口)**
|
||||||
|
>
|
||||||
|
> ```bash
|
||||||
|
> POST /system
|
||||||
|
> {"method":"frontConfig.getByDomain","v":"1.0","data":{"domain":"<自持域名>"}}
|
||||||
|
> # 命中:code=200 + domain/title/logo_url/login_bg_url/favicon_url/theme
|
||||||
|
> # 未登记:404 / configured=false
|
||||||
|
> ```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. 建议执行顺序
|
||||||
|
1. **A1 + A2**:建 store 并接入入口加载(形成闭环主干)
|
||||||
|
2. **A3 + A4**:登录页品牌化 + favicon/title 动态化(可直观验证)
|
||||||
|
3. **B1 + B2**:配置页同步状态与到期提醒(让后台能自助排查)
|
||||||
|
4. **A5 / B4 / C1**:theme 映射(需确认字段)、登记核对、验收回归
|
||||||
|
5. **C2**:部署/操作文档(收尾)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5. 风险与边界(后端约束提醒)
|
||||||
|
- `saveFrontCert`:`domain` 全局唯一(占用→409);pem/key 成对必填;证书须可解析、未过期、SAN/CN 覆盖 domain,任一失败统一「证书不合法」(400) —— 前端不要过度拆解错误。
|
||||||
|
- `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 变量(`--<key>`)应用,约定 4 键不映射 CSS 变量。
|
||||||
135
docs/前端独立部署-操作与部署说明.md
Normal file
135
docs/前端独立部署-操作与部署说明.md
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
# 前端独立部署 · 操作与部署说明(C2)
|
||||||
|
|
||||||
|
> 适用:仓库「自持域名 + 品牌化」的配置与部署运维。关联任务清单 `docs/前端独立部署-接口落实任务清单.md`。
|
||||||
|
> 关联接口:`setting.warehouse.getFrontConfig / saveFrontConfig / saveFrontCert`(仓库侧管理)、`frontConfig.getByDomain`(公网品牌拉取)。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. 使用链路(速览)
|
||||||
|
|
||||||
|
```
|
||||||
|
仓库侧(本系统 · 基础设置) 后端 部署后的浏览器
|
||||||
|
──────────────────────────────────────────────────────────────────────────────
|
||||||
|
1 保存品牌 title/logo/favicon/login_bg/theme → wms_warehouse_front_config
|
||||||
|
2 上传域名 domain + 证书 pem/key(saveFrontCert)
|
||||||
|
→ 校验证书/写 cert_expire_at
|
||||||
|
→ 定时任务部署证书并回填 cert_path/key_path
|
||||||
|
→ Redis 缓存 front:config:domain:{domain}
|
||||||
|
3 访问 https://<自持域名>/... │
|
||||||
|
▼
|
||||||
|
免鉴权 frontConfig.getByDomain(domain) ← 按 hostname 拉品牌
|
||||||
|
应用:网页名称/登录页 Logo·文字/主页面 Logo(theme 4 约定字段)、
|
||||||
|
品牌 Logo/背景/favicon、document.title、其余 theme 键→CSS 变量
|
||||||
|
```
|
||||||
|
|
||||||
|
- 品牌与「域名+证书」**分开保存**;变更域名必须走 `saveFrontCert`(重新校验证书)。
|
||||||
|
- 证书的部署落地由**后端定时任务**完成,前端不处理 PEM/私钥明文。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. 仓库侧操作(网页后台)
|
||||||
|
|
||||||
|
入口:**系统设置 → 基础设置(仓库设置)→ 底部「前端独立部署」**(`basicManagement/newview` 的 `WarehouseSettingsForm`)。
|
||||||
|
|
||||||
|
### 2.1 保存品牌配置(saveFrontConfig)
|
||||||
|
- 字段:
|
||||||
|
- 站点标题 `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(对象/数组/数字/布尔);应用时顶层标量键写入 `--<key>`(约定 4 字段不映射 CSS 变量)
|
||||||
|
- 品牌字段留空即清空该字段;主题约定键留空=用默认,自定义键删空全部行=清空该部分。
|
||||||
|
- 点击「保存品牌配置」→ 成功后自动刷新回显。
|
||||||
|
- 说明:此处不受理 `domain`/证书字段(后端白名单忽略)。
|
||||||
|
|
||||||
|
### 2.2 上传自持域名与证书(saveFrontCert)
|
||||||
|
1. 填写 自持域名 `domain`(≤100,全局唯一)。
|
||||||
|
2. 粘贴 证书 PEM `pem`(≤65536)。
|
||||||
|
3. 粘贴 私钥 PEM `key`(≤65536)。
|
||||||
|
4. 点击「上传证书」。
|
||||||
|
|
||||||
|
成功后自动:
|
||||||
|
- 写入 `cert_expire_at`(以证书 validTo 为准);
|
||||||
|
- 重置同步状态 `sync_status=0`(页面「同步详情」可看尝试次数/最近同步);
|
||||||
|
- 清空旧/新域名的公共缓存(后端处理)。
|
||||||
|
|
||||||
|
页面 meta 会展示:证书状态(未上传/正常/临期/过期)、同步状态与失败原因,便于自助排查。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. 证书准备(PEM 与 SAN)
|
||||||
|
|
||||||
|
- 证书 `pem`:X.509 证书的 PEM 文本,形如
|
||||||
|
```
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
...
|
||||||
|
-----END CERTIFICATE-----
|
||||||
|
```
|
||||||
|
- 私钥 `key`:证书对应私钥的 PEM 文本,形如
|
||||||
|
```
|
||||||
|
-----BEGIN PRIVATE KEY----- (或 -----BEGIN RSA PRIVATE KEY-----)
|
||||||
|
...
|
||||||
|
-----END PRIVATE KEY-----
|
||||||
|
```
|
||||||
|
- 必须满足:
|
||||||
|
- 证书可解析、当前已生效、未过期;
|
||||||
|
- 私钥与证书成对(后端按 SPKI 公钥指纹比对);
|
||||||
|
- 证书 `SAN DNS` / `CN` 覆盖所填 `domain`(支持精确匹配与 `*.example.com` 通配)。
|
||||||
|
- 生成(示意,正式环境请用 CA 签发):
|
||||||
|
```bash
|
||||||
|
# 自签测试证书(SAN 包含 domain)
|
||||||
|
openssl req -x509 -newkey rsa:2048 -nodes -days 365 \
|
||||||
|
-keyout key.pem -out cert.pem \
|
||||||
|
-subj "/CN=self.example.com" \
|
||||||
|
-addext "subjectAltName=DNS:self.example.com,DNS:*.example.com"
|
||||||
|
# 分别把 cert.pem、key.pem 内容填入页面
|
||||||
|
```
|
||||||
|
- 提示:同一证书可在 SAN 里放多个域名;换域名/加域名都需重新走 `saveFrontCert`。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. 常见错误对照
|
||||||
|
|
||||||
|
| 现象 / 返回 | 原因 | 处理 |
|
||||||
|
|---|---|---|
|
||||||
|
| 400「证书不合法」(统一文案,不返回细节) | 证书无法解析 / 未生效或已过期 / 私钥与证书不匹配 / SAN 或 CN 未覆盖 domain | 检查 PEM 完整性与配对、有效期、SAN 是否包含 domain;用 `openssl x509 -in cert.pem -noout -text` 核对 |
|
||||||
|
| 409 | 该 `domain` 已被其他仓库占用 | 换未占用域名,或联系占用方释放 |
|
||||||
|
| 400「domain 长度不能超过 100 字符」 | domain 超长 | 缩短域名 |
|
||||||
|
| 400「pem/key 内容长度不能超过 65536 字符」 | 证书/私钥文本过大 | 检查是否误粘贴多个证书 |
|
||||||
|
| 保存品牌后 `getByDomain` 仍返回旧值 | 缓存 600s 内 | 等缓存过期或由后端保存时清缓存(saveFrontConfig/saveFrontCert 已清旧域名缓存) |
|
||||||
|
| 上传成功但 `sync_status=1/2` | 证书部署/同步中或失败 | 看「同步详情」`last_sync_error`,按需重新上传 |
|
||||||
|
| 域名已生效但 `cert_expire_at` 为空 | 证书未上传(仅登记 domain?) | 补传证书(saveFrontCert) |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5. 前端侧部署与验证
|
||||||
|
|
||||||
|
1. 把本系统部署(或已有部署)解析到自持域名:`<自持域名> -> 部署 IP/负载`,并配置 HTTPS(证书由后端部署链路提供,前端不需持证)。
|
||||||
|
2. 浏览器访问 `https://<自持域名>`:前端入口自动按 `location.hostname` 调 `frontConfig.getByDomain` 应用品牌。
|
||||||
|
- 生效项:网页名称(登录页标题与 document.title)、主页面 Logo(顶栏)、登录页 Logo/登录页文字(theme 4 约定字段,空=默认)、品牌 Logo/背景、favicon、其余 `theme` 键→CSS 变量(`--<key>`)。
|
||||||
|
3. 未登记域名 / 直连主域名:接口返回 404 / `configured=false` → 前端静默使用系统默认品牌(无报错)。
|
||||||
|
4. 本地联调建议:改 hosts 把自持域名指向本机测试环境即可看到品牌效果;确认无旧品牌残留可清理站点数据后刷新。
|
||||||
|
5. **多仓库同一部署的域名解析(A6)**:一套前端部署可同时服务多个仓库——
|
||||||
|
- 各仓库在各自基础设置里登记自己的 `domain`(一仓一行、`domain` 全局唯一),并各自保存品牌/证书;
|
||||||
|
- 后端按访问 hostname 从 `wms_warehouse_front_config` 及缓存 `front:config:domain:{domain}` 返回对应仓库的公开品牌;
|
||||||
|
- 前端仅按 `location.hostname` 调 `frontConfig.getByDomain`,对“多仓库同部署”无感知;
|
||||||
|
- `saveFrontConfig`/`saveFrontCert` 保存成功后后端会自动清理新旧域名缓存,因此换域名/改品牌基本即时生效(600s 缓存窗口内读到旧值属正常,无需前端处理);
|
||||||
|
- 访问主域名或未登记域名 → 返回 404 / `configured=false` → 前端走系统默认品牌。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 6. 前端已落点速查(代码)
|
||||||
|
|
||||||
|
| 层 | 文件/位置 |
|
||||||
|
|---|---|
|
||||||
|
| API 封装 | `src/api/frontconfig/frontConfig.ts`;`src/api/setting.warehouse/settingwarehouse.ts`(3 个管理接口) |
|
||||||
|
| 配置管理 | `src/views/system/setting/basicManagement/newview/pages/WarehouseSettingsForm.vue`「前端独立部署」区块 |
|
||||||
|
| 品牌 store | `src/stores/modules/frontBrand.ts`(loadBrandByDomain / applyThemeCssVars / applyBrandGlobals) |
|
||||||
|
| 入口触发 | `src/main.ts` |
|
||||||
|
| 登录页品牌 | `src/views/login/index.vue` |
|
||||||
|
| 标题/favicon | `src/permission.ts` + `src/utils/get-page-title.ts` |
|
||||||
47
src/api/frontconfig/frontConfig.ts
Normal file
47
src/api/frontconfig/frontConfig.ts
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
const v = '1.0'
|
||||||
|
|
||||||
|
/** frontConfig.getByDomain 响应:仓库前端公开品牌配置(不含证书/同步等内部字段) */
|
||||||
|
export type FrontConfigPublicItem = {
|
||||||
|
/** 仓库自持域名 */
|
||||||
|
domain?: string
|
||||||
|
/** 站点标题(未配置为空字符串) */
|
||||||
|
title?: string
|
||||||
|
/** Logo 地址(未配置为空字符串) */
|
||||||
|
logo_url?: string
|
||||||
|
/** 登录页背景图地址(未配置为空字符串) */
|
||||||
|
login_bg_url?: string
|
||||||
|
/** 站点 favicon 图标地址(未配置为空字符串) */
|
||||||
|
favicon_url?: string
|
||||||
|
/** 主题配置对象(未配置为 null) */
|
||||||
|
theme?: Record<string, unknown> | null
|
||||||
|
/** 未登记域名时为 false(并返回 404) */
|
||||||
|
configured?: boolean
|
||||||
|
[key: string]: unknown
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按域名拉取仓库前端公开配置(公共接口:免登录、免鉴权、免权限)。
|
||||||
|
* Redis 缓存 front:config:domain:{domain},命中 TTL 600s;未登记域名写空缓存 60s 防穿透并返回 404。
|
||||||
|
*/
|
||||||
|
export function frontConfigGetByDomain(data: {
|
||||||
|
/** 待查询域名(必填,≤100 字符) */
|
||||||
|
domain: string
|
||||||
|
}): Promise<FrontConfigPublicItem & { code?: number; message?: string }> {
|
||||||
|
return request({
|
||||||
|
url: '/system',
|
||||||
|
method: 'post',
|
||||||
|
params: {
|
||||||
|
method: 'frontConfig.getByDomain',
|
||||||
|
v,
|
||||||
|
timestamp: new Date().getTime()
|
||||||
|
},
|
||||||
|
data,
|
||||||
|
isSystemApi: true
|
||||||
|
} as any)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const frontConfig = {
|
||||||
|
getByDomain: frontConfigGetByDomain
|
||||||
|
}
|
||||||
@ -2,11 +2,14 @@ import request from '@/utils/request'
|
|||||||
|
|
||||||
const v = '1.0'
|
const v = '1.0'
|
||||||
|
|
||||||
import type { WaveBatchListParams, WaveBatchListResponse, WaveBatchListWhere, WaveListPagination } from '@/api/order/order'
|
import type { WaveBatchListParams, WaveBatchListResponse, WaveBatchListSort, WaveBatchListWhere, WaveListPagination } from '@/api/order/order'
|
||||||
|
|
||||||
export type { WaveBatchListParams, WaveBatchListResponse, WaveBatchListWhere, WaveListPagination }
|
export type { WaveBatchListParams, WaveBatchListResponse, WaveBatchListSort, WaveBatchListWhere, WaveListPagination }
|
||||||
export { unwrapWaveBatchListResponse } from '@/api/order/order'
|
export { unwrapWaveBatchListResponse } from '@/api/order/order'
|
||||||
|
|
||||||
|
/** order.wave 系列 RPC 列表统一排序结构(对齐 stock.warehouse.list / order.wave.batchList) */
|
||||||
|
export type WaveListRpcSort = WaveBatchListSort
|
||||||
|
|
||||||
export type WavePickTaskListParams = {
|
export type WavePickTaskListParams = {
|
||||||
warehouse_id: number
|
warehouse_id: number
|
||||||
pagination?: {
|
pagination?: {
|
||||||
@ -31,6 +34,8 @@ export type WavePickTaskListParams = {
|
|||||||
/** 人员名称(operator_name 操作人/pick_user_name/review_user_name/claim_operator)与关联波次号 wave_no 通过 where 传 { operator, value },由后端按 operator 处理(默认模糊 like) */
|
/** 人员名称(operator_name 操作人/pick_user_name/review_user_name/claim_operator)与关联波次号 wave_no 通过 where 传 { operator, value },由后端按 operator 处理(默认模糊 like) */
|
||||||
where?: Record<string, any>
|
where?: Record<string, any>
|
||||||
strategy_id?: number
|
strategy_id?: number
|
||||||
|
/** 后端排序:sortField 取列 prop(如 order_count),结构对齐 stock.warehouse.list */
|
||||||
|
sort?: WaveListRpcSort
|
||||||
}
|
}
|
||||||
|
|
||||||
/** order.wave.wavePickTaskList 列表项(与 wms_wave_pick_task 主表字段对齐) */
|
/** order.wave.wavePickTaskList 列表项(与 wms_wave_pick_task 主表字段对齐) */
|
||||||
@ -215,6 +220,8 @@ export type WaveStrategyListParams = {
|
|||||||
calculateNextFetchOrderCount?: number
|
calculateNextFetchOrderCount?: number
|
||||||
/** 0-不启用(默认),1-启用调试输出,返回每条策略的 next_fetch_order_list */
|
/** 0-不启用(默认),1-启用调试输出,返回每条策略的 next_fetch_order_list */
|
||||||
debug?: number
|
debug?: number
|
||||||
|
/** 后端排序:sortField 取列 prop(如 matched_order_count_filtered),结构对齐 stock.warehouse.list */
|
||||||
|
sort?: WaveListRpcSort
|
||||||
}
|
}
|
||||||
|
|
||||||
export type WaveStrategyRecord = Record<string, unknown> & {
|
export type WaveStrategyRecord = Record<string, unknown> & {
|
||||||
@ -262,6 +269,8 @@ export type WaveStrategyListResponse = {
|
|||||||
hasPrevious?: boolean
|
hasPrevious?: boolean
|
||||||
hasNext?: boolean
|
hasNext?: boolean
|
||||||
}
|
}
|
||||||
|
/** 查询汇总信息对象(成功路径恒存在;含当前查询条件下全部策略命中的去重订单总数) */
|
||||||
|
info?: Record<string, unknown>
|
||||||
}
|
}
|
||||||
|
|
||||||
export type WaveStrategyCreateParams = {
|
export type WaveStrategyCreateParams = {
|
||||||
|
|||||||
@ -11,11 +11,12 @@ export type WaveBatchListWhere = {
|
|||||||
| string
|
| string
|
||||||
| Array<number | string>
|
| Array<number | string>
|
||||||
| { operator?: string; value: number | string | Array<number | string> }
|
| { operator?: string; value: number | string | Array<number | string> }
|
||||||
wave_no?: string
|
/** 文本模糊字段:支持标量或 { operator, value } 标准结构(操作符由后端解析,默认模糊 like;contains/in/notin 的 value 为数组) */
|
||||||
|
wave_no?: string | { operator?: string; value: string | string[] }
|
||||||
wave_type?: number
|
wave_type?: number
|
||||||
wave_status?: number
|
wave_status?: number
|
||||||
creator?: string
|
creator?: string | { operator?: string; value: string | string[] }
|
||||||
logistics_name?: string
|
logistics_name?: string | { operator?: string; value: string | string[] }
|
||||||
item_part_type?: number
|
item_part_type?: number
|
||||||
item_part?: string
|
item_part?: string
|
||||||
item_snapshot_key?: string
|
item_snapshot_key?: string
|
||||||
@ -39,6 +40,12 @@ export type WaveBatchListWhere = {
|
|||||||
review_assignment_status?: 'unreviewed' | 'partially_reviewed' | 'reviewed'
|
review_assignment_status?: 'unreviewed' | 'partially_reviewed' | 'reviewed'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** order.wave.batchList 排序(对齐 stock.warehouse.list 等 RPC 列表接口) */
|
||||||
|
export type WaveBatchListSort = {
|
||||||
|
sortField?: string
|
||||||
|
sortOrder?: 'asc' | 'desc' | 'ASC' | 'DESC'
|
||||||
|
}
|
||||||
|
|
||||||
export type WaveBatchListParams = {
|
export type WaveBatchListParams = {
|
||||||
pagination?: {
|
pagination?: {
|
||||||
page?: number
|
page?: number
|
||||||
@ -48,6 +55,8 @@ export type WaveBatchListParams = {
|
|||||||
only_todo?: number | boolean | string
|
only_todo?: number | boolean | string
|
||||||
/** 白名单见 WaveBatchListWhere;与列表页动态 where 构建兼容 */
|
/** 白名单见 WaveBatchListWhere;与列表页动态 where 构建兼容 */
|
||||||
where?: WaveBatchListWhere | Record<string, any>
|
where?: WaveBatchListWhere | Record<string, any>
|
||||||
|
/** 后端排序:sortField 取列 prop(如 total_orders / order_count / processed_orders / unreviewed_order_count) */
|
||||||
|
sort?: WaveBatchListSort
|
||||||
}
|
}
|
||||||
|
|
||||||
export type WaveListPagination = {
|
export type WaveListPagination = {
|
||||||
|
|||||||
@ -286,8 +286,108 @@ export function settingWarehouseSaveSettings(
|
|||||||
} as any)
|
} as any)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 前端独立部署配置记录(getFrontConfig / saveFrontConfig / saveFrontCert 响应,一仓一行) */
|
||||||
|
export type SettingWarehouseFrontConfig = {
|
||||||
|
warehouse_id?: number
|
||||||
|
domain?: string
|
||||||
|
title?: string
|
||||||
|
logo_url?: string
|
||||||
|
favicon_url?: string
|
||||||
|
login_bg_url?: string
|
||||||
|
theme?: Record<string, unknown> | string | null
|
||||||
|
cert_path?: string
|
||||||
|
key_path?: 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
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SettingWarehouseSaveFrontConfigParams = {
|
||||||
|
/** 站点标题(≤100,空值清空) */
|
||||||
|
title?: string
|
||||||
|
/** Logo 地址(≤255,空值清空) */
|
||||||
|
logo_url?: string
|
||||||
|
/** 站点 favicon 地址(≤255,空值清空) */
|
||||||
|
favicon_url?: string
|
||||||
|
/** 登录页背景图地址(≤255,空值清空) */
|
||||||
|
login_bg_url?: string
|
||||||
|
/** 主题配置(合法 JSON 对象或 JSON 字符串;空值清空) */
|
||||||
|
theme?: Record<string, unknown> | string | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SettingWarehouseSaveFrontCertParams = {
|
||||||
|
/** 仓库自持域名(必填 ≤100,全局唯一) */
|
||||||
|
domain: string
|
||||||
|
/** 证书 PEM 文本(必填 ≤65536,须可解析 X.509、未过期且 SAN/CN 覆盖 domain) */
|
||||||
|
pem: string
|
||||||
|
/** 私钥 PEM 文本(必填 ≤65536,须与 pem 成对,SPKI 公钥指纹比对) */
|
||||||
|
key: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询当前仓库前端独立部署配置(settings 页回显;无记录返回默认空配置) */
|
||||||
|
export function settingWarehouseGetFrontConfig(): Promise<
|
||||||
|
{ code?: number; message?: string; data?: SettingWarehouseFrontConfig } & Record<string, unknown>
|
||||||
|
> {
|
||||||
|
return request({
|
||||||
|
url: '/system',
|
||||||
|
method: 'post',
|
||||||
|
params: {
|
||||||
|
method: 'setting.warehouse.getFrontConfig',
|
||||||
|
v,
|
||||||
|
timestamp: new Date().getTime()
|
||||||
|
},
|
||||||
|
data: {},
|
||||||
|
isSystemApi: true
|
||||||
|
} as any)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 保存当前仓库前端独立部署品牌配置(仅受理 title/logo/favicon/login_bg/theme,空值清空;domain/证书字段不受理) */
|
||||||
|
export function settingWarehouseSaveFrontConfig(
|
||||||
|
data: SettingWarehouseSaveFrontConfigParams = {}
|
||||||
|
): Promise<
|
||||||
|
{ code?: number; message?: string; data?: SettingWarehouseFrontConfig } & Record<string, unknown>
|
||||||
|
> {
|
||||||
|
return request({
|
||||||
|
url: '/system',
|
||||||
|
method: 'post',
|
||||||
|
params: {
|
||||||
|
method: 'setting.warehouse.saveFrontConfig',
|
||||||
|
v,
|
||||||
|
timestamp: new Date().getTime()
|
||||||
|
},
|
||||||
|
data,
|
||||||
|
isSystemApi: true
|
||||||
|
} as any)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 上传当前仓库前端独立部署证书(domain + pem/key 成对必填;通过后回填 cert_expire_at) */
|
||||||
|
export function settingWarehouseSaveFrontCert(
|
||||||
|
data: SettingWarehouseSaveFrontCertParams
|
||||||
|
): Promise<
|
||||||
|
{ code?: number; message?: string; data?: SettingWarehouseFrontConfig } & Record<string, unknown>
|
||||||
|
> {
|
||||||
|
return request({
|
||||||
|
url: '/system',
|
||||||
|
method: 'post',
|
||||||
|
params: {
|
||||||
|
method: 'setting.warehouse.saveFrontCert',
|
||||||
|
v,
|
||||||
|
timestamp: new Date().getTime()
|
||||||
|
},
|
||||||
|
data,
|
||||||
|
isSystemApi: true
|
||||||
|
} as any)
|
||||||
|
}
|
||||||
|
|
||||||
export const settingWarehouse = {
|
export const settingWarehouse = {
|
||||||
getSettings: settingWarehouseGetSettings,
|
getSettings: settingWarehouseGetSettings,
|
||||||
getFieldMeta: settingWarehouseGetFieldMeta,
|
getFieldMeta: settingWarehouseGetFieldMeta,
|
||||||
saveSettings: settingWarehouseSaveSettings
|
saveSettings: settingWarehouseSaveSettings,
|
||||||
|
getFrontConfig: settingWarehouseGetFrontConfig,
|
||||||
|
saveFrontConfig: settingWarehouseSaveFrontConfig,
|
||||||
|
saveFrontCert: settingWarehouseSaveFrontCert
|
||||||
}
|
}
|
||||||
|
|||||||
@ -586,31 +586,47 @@ export type BindReceivingParams = {
|
|||||||
receiving_ids: number[]
|
receiving_ids: number[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export type BindReceivingSuccessItem = {
|
export type BindReceivingBoundItem = {
|
||||||
receiving_id?: number
|
receiving_id?: number
|
||||||
receiving_number?: string
|
receiving_number?: string
|
||||||
|
/** CREATED 绑定:本次新建绑定行时为 true */
|
||||||
|
created?: boolean
|
||||||
|
/** COMPLETED 绑定:软删除恢复时为 true */
|
||||||
|
restored?: boolean
|
||||||
|
/** COMPLETED 绑定:入库进度同步结果(stored_total / matched_item_count / unmatched_items) */
|
||||||
|
storage_sync?: {
|
||||||
|
stored_total?: number
|
||||||
|
matched_item_count?: number
|
||||||
|
unmatched_items?: Array<Record<string, unknown>>
|
||||||
|
[key: string]: unknown
|
||||||
|
}
|
||||||
[key: string]: unknown
|
[key: string]: unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
export type BindReceivingFailedItem = {
|
export type BindReceivingSkippedItem = {
|
||||||
receiving_id?: number
|
receiving_id?: number
|
||||||
|
receiving_number?: string
|
||||||
|
/** 可能值:ALREADY_BOUND(绑定已存在,COMPLETED 幂等跳过进度同步)、BINDING_WRITE_FAILED(CREATED 写入绑定失败) */
|
||||||
error_code?: string
|
error_code?: string
|
||||||
message?: string
|
message?: string
|
||||||
[key: string]: unknown
|
[key: string]: unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
export type BindReceivingResponse = {
|
export type BindReceivingResponse = {
|
||||||
|
flag?: string
|
||||||
code?: number
|
code?: number
|
||||||
message?: string
|
message?: string
|
||||||
success?: BindReceivingSuccessItem[]
|
/** 绑定/进度同步成功列表 */
|
||||||
failed?: BindReceivingFailedItem[]
|
bound?: BindReceivingBoundItem[]
|
||||||
success_count?: number
|
/** 跳过列表(含 ALREADY_BOUND 等) */
|
||||||
failed_count?: number
|
skipped?: BindReceivingSkippedItem[]
|
||||||
|
/** 汇总统计 */
|
||||||
|
summary?: Record<string, unknown>
|
||||||
|
timestamp?: number
|
||||||
data?: {
|
data?: {
|
||||||
success?: BindReceivingSuccessItem[]
|
bound?: BindReceivingBoundItem[]
|
||||||
failed?: BindReceivingFailedItem[]
|
skipped?: BindReceivingSkippedItem[]
|
||||||
success_count?: number
|
summary?: Record<string, unknown>
|
||||||
failed_count?: number
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -628,6 +644,63 @@ export function bindReceiving(data: BindReceivingParams): Promise<BindReceivingR
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type UnbindReceivingParams = {
|
||||||
|
/** 入库单ID */
|
||||||
|
entry_order_id: number
|
||||||
|
/** 要解除绑定的收货单ID列表 */
|
||||||
|
receiving_ids: number[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export type UnbindReceivingSuccessItem = {
|
||||||
|
receiving_id?: number
|
||||||
|
/** 本次软删除/释放的收货明细ID列表 */
|
||||||
|
released_detail_ids?: number[]
|
||||||
|
released_detail_count?: number
|
||||||
|
/** 本次回滚的 stored_quantity 总量 */
|
||||||
|
rolled_back_quantity?: number
|
||||||
|
message?: string
|
||||||
|
[key: string]: unknown
|
||||||
|
}
|
||||||
|
|
||||||
|
export type UnbindReceivingFailedItem = {
|
||||||
|
receiving_id?: number
|
||||||
|
/** 可能值:BINDING_NOT_FOUND / ENTRY_ORDER_NOT_FOUND / ENTRY_ORDER_STATUS_INVALID / UNBIND_ERROR */
|
||||||
|
error_code?: string
|
||||||
|
message?: string
|
||||||
|
[key: string]: unknown
|
||||||
|
}
|
||||||
|
|
||||||
|
export type UnbindReceivingResponse = {
|
||||||
|
flag?: string
|
||||||
|
code?: number
|
||||||
|
message?: string
|
||||||
|
success?: UnbindReceivingSuccessItem[]
|
||||||
|
failed?: UnbindReceivingFailedItem[]
|
||||||
|
success_count?: number
|
||||||
|
failed_count?: number
|
||||||
|
timestamp?: number
|
||||||
|
data?: {
|
||||||
|
success?: UnbindReceivingSuccessItem[]
|
||||||
|
failed?: UnbindReceivingFailedItem[]
|
||||||
|
success_count?: number
|
||||||
|
failed_count?: number
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 解除入库单与收货单的主表绑定关系,并按数量台账回滚该收货单的入库进度(仅 CREATED/PENDING 可解绑) */
|
||||||
|
export function unbindReceiving(data: UnbindReceivingParams): Promise<UnbindReceivingResponse> {
|
||||||
|
return request({
|
||||||
|
url: '/system',
|
||||||
|
method: 'post',
|
||||||
|
params: {
|
||||||
|
method: 'storage.entry.unbindReceiving',
|
||||||
|
v,
|
||||||
|
timestamp: new Date().getTime(),
|
||||||
|
},
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/** storage.entry.reviewEntry 参数 */
|
/** storage.entry.reviewEntry 参数 */
|
||||||
export type ReviewEntryParams = {
|
export type ReviewEntryParams = {
|
||||||
/** 入库单ID */
|
/** 入库单ID */
|
||||||
|
|||||||
@ -650,7 +650,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- 文本类型(默认) -->
|
<!-- 文本类型(默认) -->
|
||||||
<div v-else class="compact-field-item">
|
<div v-else class="compact-field-item">
|
||||||
<div v-if="getOperators(field).length > 1" class="compact-field-control">
|
<div
|
||||||
|
v-if="getOperators(field).length > 1"
|
||||||
|
class="compact-field-control"
|
||||||
|
:class="{ 'compact-field-control--stacked': isMultiValueTextOperator(resolveFieldOperator(field)) }"
|
||||||
|
>
|
||||||
<el-select
|
<el-select
|
||||||
v-model="customConditions[field.value].operator"
|
v-model="customConditions[field.value].operator"
|
||||||
size="small"
|
size="small"
|
||||||
@ -666,11 +670,12 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
<el-input
|
<el-input
|
||||||
v-model="customConditions[field.value].value"
|
v-model="customConditions[field.value].value"
|
||||||
:placeholder="field.label"
|
:placeholder="isMultiValueTextOperator(resolveFieldOperator(field)) ? getTextPlaceholder(field) : field.label"
|
||||||
size="small"
|
size="small"
|
||||||
clearable
|
clearable
|
||||||
class="compact-value-input"
|
class="compact-value-input"
|
||||||
@change="handleCompactChange"
|
@change="handleCompactChange"
|
||||||
|
@blur="normalizeTextValue(field)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<el-input
|
<el-input
|
||||||
@ -2115,6 +2120,21 @@ defineExpose({ getConditions, reset, clear, getFieldDraft, setFieldCondition, su
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 紧凑模式多值文本操作符(包含/IN/NOT IN):操作符在上,输入框整行全宽,与标准模式对齐 */
|
||||||
|
.compact-field-control--stacked {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.compact-field-control--stacked .compact-operator-select {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.compact-field-control--stacked .compact-value-input {
|
||||||
|
flex: none;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
/* 紧凑模式数字区间输入 */
|
/* 紧凑模式数字区间输入 */
|
||||||
.compact-range-input {
|
.compact-range-input {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="navbar">
|
<div class="navbar">
|
||||||
<img src="/logo/1.png" alt="logo" class="logo">
|
<img :src="mainLogo" alt="logo" class="logo">
|
||||||
<breadcrumb v-if="layoutMode !== 'top-bottom'" class="breadcrumb-container" />
|
<breadcrumb v-if="layoutMode !== 'top-bottom'" class="breadcrumb-container" />
|
||||||
|
|
||||||
<div v-if="layoutMode === 'top-bottom'" class="top-menu-wrapper">
|
<div v-if="layoutMode === 'top-bottom'" class="top-menu-wrapper">
|
||||||
@ -94,6 +94,7 @@ import { computed, onMounted, onUnmounted, ref } from 'vue'
|
|||||||
import { useAppStore } from '@/stores/modules/app'
|
import { useAppStore } from '@/stores/modules/app'
|
||||||
import { useUserStore } from '@/stores/modules/user'
|
import { useUserStore } from '@/stores/modules/user'
|
||||||
import { useSettingsStore } from '@/stores/modules/settings'
|
import { useSettingsStore } from '@/stores/modules/settings'
|
||||||
|
import { useFrontBrandStore } from '@/stores/modules/frontBrand'
|
||||||
import { useAiStore } from '@/stores/modules/ai'
|
import { useAiStore } from '@/stores/modules/ai'
|
||||||
import { useRouter, useRoute } from 'vue-router'
|
import { useRouter, useRoute } from 'vue-router'
|
||||||
import Breadcrumb from '@/components/Breadcrumb/index.vue'
|
import Breadcrumb from '@/components/Breadcrumb/index.vue'
|
||||||
@ -115,6 +116,10 @@ const route = useRoute()
|
|||||||
const sidebar = computed(() => appStore.sidebar)
|
const sidebar = computed(() => appStore.sidebar)
|
||||||
const user = computed(() => userStore.user)
|
const user = computed(() => userStore.user)
|
||||||
const avatar = computed(() => userStore.avatar)
|
const avatar = computed(() => userStore.avatar)
|
||||||
|
|
||||||
|
// 主页面/顶栏 logo:优先主题约定 mainLogoUrl(theme.mainLogoUrl),缺省用默认图片
|
||||||
|
const frontBrandStore = useFrontBrandStore()
|
||||||
|
const mainLogo = computed(() => frontBrandStore.themeMainLogoUrl || '/logo/1.png')
|
||||||
const device = computed(() => appStore.device)
|
const device = computed(() => appStore.device)
|
||||||
const layoutMode = computed(() => settingsStore.layoutMode)
|
const layoutMode = computed(() => settingsStore.layoutMode)
|
||||||
|
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import '@/styles/index.scss' // global css
|
|||||||
import { getToken } from '@/utils/auth'
|
import { getToken } from '@/utils/auth'
|
||||||
import { initPrinterRuntime } from '@/core/printerRuntime'
|
import { initPrinterRuntime } from '@/core/printerRuntime'
|
||||||
import { usePrinterComponentStore } from '@/stores/modules/printerComponent'
|
import { usePrinterComponentStore } from '@/stores/modules/printerComponent'
|
||||||
|
import { useFrontBrandStore } from '@/stores/modules/frontBrand'
|
||||||
|
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
|
|
||||||
@ -48,6 +49,9 @@ usePrinterComponentStore(pinia).bindRuntimeEvents()
|
|||||||
|
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
|
||||||
|
// 前端独立部署品牌:登录前按当前访问域名拉取(免鉴权),成功后应用 favicon / 登录页标题品牌;失败静默走默认品牌
|
||||||
|
useFrontBrandStore(pinia).loadBrandByDomain()
|
||||||
|
|
||||||
// 整页刷新(F5 / 顶部刷新)后的“一次自动连接”兜底:
|
// 整页刷新(F5 / 顶部刷新)后的“一次自动连接”兜底:
|
||||||
// 等路由守卫初始化(getInfo)完成、拿到登录上下文后再执行一次;
|
// 等路由守卫初始化(getInfo)完成、拿到登录上下文后再执行一次;
|
||||||
// 与“失败自动重连”主开关无关(主开关只控制断线后的持续重试)。
|
// 与“失败自动重连”主开关无关(主开关只控制断线后的持续重试)。
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import NProgress from 'nprogress'
|
|||||||
import 'nprogress/nprogress.css'
|
import 'nprogress/nprogress.css'
|
||||||
import { getToken } from '@/utils/auth'
|
import { getToken } from '@/utils/auth'
|
||||||
import { usePrinterComponentStore } from '@/stores/modules/printerComponent'
|
import { usePrinterComponentStore } from '@/stores/modules/printerComponent'
|
||||||
|
import { useFrontBrandStore } from '@/stores/modules/frontBrand'
|
||||||
import getPageTitle from '@/utils/get-page-title'
|
import getPageTitle from '@/utils/get-page-title'
|
||||||
import i18n from '@/lang'
|
import i18n from '@/lang'
|
||||||
import type { RouteRecordRaw } from 'vue-router'
|
import type { RouteRecordRaw } from 'vue-router'
|
||||||
@ -73,7 +74,8 @@ function maybeRetryPrintConnectionsAfterRefresh() {
|
|||||||
router.beforeEach(async (to, from) => {
|
router.beforeEach(async (to, from) => {
|
||||||
NProgress.start()
|
NProgress.start()
|
||||||
// console.log("路由表",router.getRoutes());
|
// console.log("路由表",router.getRoutes());
|
||||||
document.title = getPageTitle(resolveRouteDocumentTitle(to))
|
// 前端独立部署:页面标题前缀使用域名品牌站点标题(无则系统默认)
|
||||||
|
document.title = getPageTitle(resolveRouteDocumentTitle(to), useFrontBrandStore().siteTitle)
|
||||||
|
|
||||||
const hasToken = getToken()
|
const hasToken = getToken()
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
export default {
|
export default {
|
||||||
title: 'Vue Admin Template',
|
title: '天豹云仓',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {boolean} true | false
|
* @type {boolean} true | false
|
||||||
|
|||||||
154
src/stores/modules/frontBrand.ts
Normal file
154
src/stores/modules/frontBrand.ts
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
import { defineStore } from 'pinia'
|
||||||
|
import { computed, ref } from 'vue'
|
||||||
|
import { frontConfigGetByDomain, type FrontConfigPublicItem } from '@/api/frontconfig/frontConfig'
|
||||||
|
import defaultSettings from '@/settings'
|
||||||
|
|
||||||
|
/** 判定接口业务成功(与全站 okCode 约定一致) */
|
||||||
|
function isOkCode(code: unknown): boolean {
|
||||||
|
return code === 200 || code === 1 || code === 0
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前端独立部署品牌(frontConfig.getByDomain 消费端)
|
||||||
|
*
|
||||||
|
* 设计:前端被部署到仓库「自持域名」时,登录前按 location.hostname 拉取该仓库公开品牌
|
||||||
|
* (title/logo/login_bg/favicon/theme)。未登记域名(404/configured=false)或网络异常时静默回退默认品牌。
|
||||||
|
* 免鉴权、免权限;main.ts 入口加载一次(loaded 幂等),失败不阻塞应用。
|
||||||
|
*/
|
||||||
|
export const useFrontBrandStore = defineStore('frontBrand', () => {
|
||||||
|
/** 是否已尝试加载(成功或失败都置 true,避免每次刷新重复请求) */
|
||||||
|
const loaded = ref(false)
|
||||||
|
/** 品牌配置;null=使用系统默认品牌 */
|
||||||
|
const brand = ref<FrontConfigPublicItem | null>(null)
|
||||||
|
|
||||||
|
/** theme 约定 4 字段键(文案/资源类,不映射 CSS 变量):网页名称/主页面 logo/登录页 logo/登录页文字 */
|
||||||
|
const FRONT_THEME_DEFAULT_KEYS = ['siteName', 'mainLogoUrl', 'loginLogoUrl', 'loginText'] as const
|
||||||
|
|
||||||
|
/** theme 归一化为对象(支持对象或 JSON 字符串) */
|
||||||
|
const themeObj = computed<Record<string, unknown>>(() => {
|
||||||
|
const theme: unknown = brand.value?.theme
|
||||||
|
if (theme && typeof theme === 'object' && !Array.isArray(theme)) return theme as Record<string, unknown>
|
||||||
|
if (typeof theme === 'string' && theme.trim()) {
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(theme)
|
||||||
|
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
||||||
|
return parsed as Record<string, unknown>
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
/* 忽略无法解析的主题字符串 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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())
|
||||||
|
|
||||||
|
/** 站点标题/网页名称(theme.siteName 或品牌 title,最后回退系统默认标题 settings.title) */
|
||||||
|
const siteTitle = computed(() => siteName.value)
|
||||||
|
/** 品牌 Logo(空串→调用方回退默认 Logo) */
|
||||||
|
const logoUrl = computed(() => brand.value?.logo_url?.trim() || '')
|
||||||
|
/** 登录页背景图(空串→调用方用默认背景) */
|
||||||
|
const loginBgUrl = computed(() => brand.value?.login_bg_url?.trim() || '')
|
||||||
|
/** favicon 图标(空串→调用方用默认) */
|
||||||
|
const faviconUrl = computed(() => brand.value?.favicon_url?.trim() || '')
|
||||||
|
|
||||||
|
/** 按当前访问域名拉取品牌并应用全局(favicon / 登录页标题 / theme CSS 变量) */
|
||||||
|
async function loadBrandByDomain(domain?: string): Promise<void> {
|
||||||
|
if (loaded.value) 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
|
||||||
|
// 未登记域名返回 404 / configured=false → 走默认品牌
|
||||||
|
const valid = isOkCode(res?.code) && data?.configured !== false
|
||||||
|
brand.value = valid ? (data as FrontConfigPublicItem) : null
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('[frontBrand] 拉取域名品牌失败,使用默认品牌', e)
|
||||||
|
brand.value = null
|
||||||
|
} finally {
|
||||||
|
loaded.value = true
|
||||||
|
// 无论成功/失败都应用主题:无 theme/brand=null 时清除上一次已应用的 CSS 变量,避免换域名后残留旧主题
|
||||||
|
applyThemeCssVars(brand.value?.theme)
|
||||||
|
applyBrandGlobals()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 已应用到 <html> 的 CSS 变量列表(用于换品牌/无品牌时清理) */
|
||||||
|
let appliedCssVars: string[] = []
|
||||||
|
|
||||||
|
function isPlainCssValue(v: unknown): v is string | number {
|
||||||
|
return typeof v === 'string' || typeof v === 'number'
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearAppliedThemeCssVars(): void {
|
||||||
|
if (!document?.documentElement) return
|
||||||
|
const style = document.documentElement.style
|
||||||
|
appliedCssVars.forEach((key) => style.removeProperty(key))
|
||||||
|
appliedCssVars = []
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 把品牌 theme 映射为 CSS 变量并应用到 <html>(A5)。
|
||||||
|
* 约定:theme 顶层键 → CSS 变量 `--<key>`,值为标量(字符串/数字)时写入;
|
||||||
|
* 键需符合 [A-Za-z_][A-Za-z0-9_-]*,非法键/嵌套对象忽略。null/undefined 清除已应用变量。
|
||||||
|
*/
|
||||||
|
function applyThemeCssVars(theme: unknown): void {
|
||||||
|
if (!document?.documentElement) return
|
||||||
|
clearAppliedThemeCssVars()
|
||||||
|
if (!theme || typeof theme !== 'object' || Array.isArray(theme)) return
|
||||||
|
const style = document.documentElement.style
|
||||||
|
Object.entries(theme as Record<string, unknown>).forEach(([key, value]) => {
|
||||||
|
if (!/^[A-Za-z_][A-Za-z0-9_-]*$/.test(key)) return
|
||||||
|
// 文案/资源类约定键不映射 CSS 变量(由页面按语义消费)
|
||||||
|
if (FRONT_THEME_DEFAULT_KEYS.includes(key as (typeof FRONT_THEME_DEFAULT_KEYS)[number])) return
|
||||||
|
if (!isPlainCssValue(value)) return
|
||||||
|
const cssVar = `--${key}`
|
||||||
|
style.setProperty(cssVar, String(value))
|
||||||
|
appliedCssVars.push(cssVar)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 应用全局品牌元素:favicon;登录页(未登录首屏)标题 */
|
||||||
|
function applyBrandGlobals(): void {
|
||||||
|
const b = brand.value
|
||||||
|
if (!b) return
|
||||||
|
if (b.favicon_url?.trim()) {
|
||||||
|
const icon = document.querySelector<HTMLLinkElement>('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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
loaded,
|
||||||
|
brand,
|
||||||
|
themeObj,
|
||||||
|
siteName,
|
||||||
|
siteTitle,
|
||||||
|
themeLoginText,
|
||||||
|
themeLoginLogoUrl,
|
||||||
|
themeMainLogoUrl,
|
||||||
|
logoUrl,
|
||||||
|
loginBgUrl,
|
||||||
|
faviconUrl,
|
||||||
|
loadBrandByDomain,
|
||||||
|
applyThemeCssVars,
|
||||||
|
applyBrandGlobals
|
||||||
|
}
|
||||||
|
})
|
||||||
@ -1,6 +1,6 @@
|
|||||||
import defaultSettings from '@/settings'
|
import defaultSettings from '@/settings'
|
||||||
|
|
||||||
const title = defaultSettings.title || 'Vue Admin Template'
|
const title = defaultSettings.title || '天豹云仓'
|
||||||
|
|
||||||
export default function getPageTitle(pageTitle) {
|
export default function getPageTitle(pageTitle) {
|
||||||
if (pageTitle) {
|
if (pageTitle) {
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
import defaultSettings from '@/settings'
|
import defaultSettings from '@/settings'
|
||||||
|
|
||||||
const title = defaultSettings.title || 'Vue Admin Template'
|
const title = defaultSettings.title || '天豹云仓'
|
||||||
|
|
||||||
export default function getPageTitle(pageTitle:any) {
|
export default function getPageTitle(pageTitle:any, baseTitle?: string) {
|
||||||
|
const base = (baseTitle && String(baseTitle).trim()) || title
|
||||||
if (pageTitle) {
|
if (pageTitle) {
|
||||||
return `${pageTitle} - ${title}`
|
return `${pageTitle} - ${base}`
|
||||||
}
|
}
|
||||||
return `${title}`
|
return `${base}`
|
||||||
}
|
}
|
||||||
|
|||||||
@ -140,7 +140,7 @@
|
|||||||
import { ref, reactive, onMounted } from 'vue'
|
import { ref, reactive, onMounted } from 'vue'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { Search, Refresh } from '@element-plus/icons-vue'
|
import { Search, Refresh } from '@element-plus/icons-vue'
|
||||||
import { storeWarehouseWarehouseList } from '@/api/storeWarehouse.warehouse/storeWarehouse'
|
import { storeWarehouseWarehouseList } from '@/api/storewarehouse.warehouse/storeWarehouse'
|
||||||
import ScanBox from '@/components/ScanBox/index.vue'
|
import ScanBox from '@/components/ScanBox/index.vue'
|
||||||
import UpperTable from '@/components/UpperTable/index.vue'
|
import UpperTable from '@/components/UpperTable/index.vue'
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="login-container">
|
<div class="login-container" :style="loginBgStyle">
|
||||||
<div class="login-card">
|
<div class="login-card">
|
||||||
<!-- 左侧品牌区 -->
|
<!-- 左侧品牌区 -->
|
||||||
<div class="login-left-panel">
|
<div class="login-left-panel">
|
||||||
<div class="brand-info">
|
<div class="brand-info">
|
||||||
<!-- <svg-icon icon-class="dashboard" class="brand-logo" /> -->
|
<!-- <svg-icon icon-class="dashboard" class="brand-logo" /> -->
|
||||||
<img src="../../../public/logo/1.png" style="width:160px;height: 65px;">
|
<img :src="brandLogo" style="width:160px;height: 65px;" alt="logo">
|
||||||
<!-- <h1 class="brand-name">天豹云仓</h1> -->
|
<!-- <h1 class="brand-name">天豹云仓</h1> -->
|
||||||
<p class="brand-desc">现代化仓储管理系统 - 助力企业高效运营</p>
|
<h1 v-if="brandName" class="brand-name">{{ brandName }}</h1>
|
||||||
|
<p class="brand-desc">{{ loginDesc }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -235,12 +236,13 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, watch, onUnmounted } from 'vue'
|
import { ref, reactive, computed, watch, onMounted, onUnmounted } from 'vue'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import { ElMessage, type FormInstance } from 'element-plus'
|
import { ElMessage, type FormInstance } from 'element-plus'
|
||||||
import { Loading, CircleCheck, RefreshRight } from '@element-plus/icons-vue'
|
import { Loading, CircleCheck, RefreshRight } from '@element-plus/icons-vue'
|
||||||
import { useUserStore } from '@/stores/modules/user'
|
import { useUserStore } from '@/stores/modules/user'
|
||||||
import * as userApi from '@/api/user/user'
|
import * as userApi from '@/api/user/user'
|
||||||
|
import { useFrontBrandStore } from '@/stores/modules/frontBrand'
|
||||||
import { setToken } from '@/utils/auth'
|
import { setToken } from '@/utils/auth'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import LangSelect from '@/components/LangSelect/index.vue'
|
import LangSelect from '@/components/LangSelect/index.vue'
|
||||||
@ -251,6 +253,28 @@ const route = useRoute()
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
|
|
||||||
|
// ── 前端独立部署品牌(frontConfig.getByDomain):按域名替换 Logo / 标题 / 背景 ──
|
||||||
|
const frontBrand = useFrontBrandStore()
|
||||||
|
const brand = computed(() => frontBrand.brand)
|
||||||
|
// 主题约定:网页名称(theme.siteName||brand.title)、登录页 logo(theme.loginLogoUrl||品牌 logo)、登录页文字(theme.loginText)
|
||||||
|
const brandName = computed(() => frontBrand.siteTitle)
|
||||||
|
const brandLogo = computed(() => frontBrand.themeLoginLogoUrl || '../../../public/logo/1.png')
|
||||||
|
const loginDesc = computed(() => frontBrand.themeLoginText || '现代化仓储管理系统 - 助力企业高效运营')
|
||||||
|
const loginBgStyle = computed(() =>
|
||||||
|
brand.value?.login_bg_url?.trim()
|
||||||
|
? {
|
||||||
|
backgroundImage: `url(${brand.value.login_bg_url.trim()})`,
|
||||||
|
backgroundSize: 'cover',
|
||||||
|
backgroundPosition: 'center'
|
||||||
|
}
|
||||||
|
: undefined
|
||||||
|
)
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
// 登录前免鉴权拉取域名品牌(main 已触发时内部幂等跳过)
|
||||||
|
frontBrand.loadBrandByDomain()
|
||||||
|
})
|
||||||
|
|
||||||
// ---- 表单 refs ----
|
// ---- 表单 refs ----
|
||||||
const loginFormRef = ref<FormInstance>()
|
const loginFormRef = ref<FormInstance>()
|
||||||
const registerFormRef = ref<FormInstance>()
|
const registerFormRef = ref<FormInstance>()
|
||||||
|
|||||||
@ -64,6 +64,7 @@
|
|||||||
@page-change="handlePageChange"
|
@page-change="handlePageChange"
|
||||||
@page-size-change="handlePageSizeChange"
|
@page-size-change="handlePageSizeChange"
|
||||||
@refresh="loadData"
|
@refresh="loadData"
|
||||||
|
@sort-change="handleSortChange"
|
||||||
@selection-change="handleSelectionChange"
|
@selection-change="handleSelectionChange"
|
||||||
>
|
>
|
||||||
<template #column-wave_id="{ row }">
|
<template #column-wave_id="{ row }">
|
||||||
@ -950,7 +951,7 @@ import {
|
|||||||
} from '@/api/order.wave/orderwave'
|
} from '@/api/order.wave/orderwave'
|
||||||
import { batchQuickRecheckByWave } from '@/api/order.recheckorder/recheckOrder'
|
import { batchQuickRecheckByWave } from '@/api/order.recheckorder/recheckOrder'
|
||||||
import { markWavePrintStatus } from '@/api/print/print'
|
import { markWavePrintStatus } from '@/api/print/print'
|
||||||
import { orderWaveBatchList, unwrapWaveBatchListResponse } from '@/api/order/order'
|
import { orderWaveBatchList, unwrapWaveBatchListResponse, type WaveBatchListSort } from '@/api/order/order'
|
||||||
import type {
|
import type {
|
||||||
WaveBatchAutoGroupingResponse,
|
WaveBatchAutoGroupingResponse,
|
||||||
WaveBatchAllocateExpressTaskProgressResponse,
|
WaveBatchAllocateExpressTaskProgressResponse,
|
||||||
@ -1119,6 +1120,7 @@ const batchCancelTaskProgress = reactive({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||||
|
const currentSort = reactive({ prop: '', order: '' })
|
||||||
const groupOrderPagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
const groupOrderPagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||||
const singleOrderDialogVisible = ref(false)
|
const singleOrderDialogVisible = ref(false)
|
||||||
const singleOrderActiveTab = ref<'fallback-orders' | 'strategy-api'>('fallback-orders')
|
const singleOrderActiveTab = ref<'fallback-orders' | 'strategy-api'>('fallback-orders')
|
||||||
@ -1454,13 +1456,20 @@ async function loadData() {
|
|||||||
if (where.wave_type === undefined || where.wave_type === null || where.wave_type === '') {
|
if (where.wave_type === undefined || where.wave_type === null || where.wave_type === '') {
|
||||||
where.wave_type = currentWaveType.value
|
where.wave_type = currentWaveType.value
|
||||||
}
|
}
|
||||||
|
const sort: WaveBatchListSort | undefined = currentSort.prop
|
||||||
|
? {
|
||||||
|
sortField: currentSort.prop,
|
||||||
|
sortOrder: currentSort.order === 'ascending' ? 'ASC' : 'DESC'
|
||||||
|
}
|
||||||
|
: undefined
|
||||||
const res = await orderWaveBatchList({
|
const res = await orderWaveBatchList({
|
||||||
pagination: {
|
pagination: {
|
||||||
page: pagination.currentPage,
|
page: pagination.currentPage,
|
||||||
pageSize: pagination.pageSize
|
pageSize: pagination.pageSize
|
||||||
},
|
},
|
||||||
...(onlyTodoWaves.value ? { only_todo: 1 } : {}),
|
...(onlyTodoWaves.value ? { only_todo: 1 } : {}),
|
||||||
where
|
where,
|
||||||
|
sort
|
||||||
})
|
})
|
||||||
if (!res || !okCode(res.code)) {
|
if (!res || !okCode(res.code)) {
|
||||||
throw new Error(res?.message || '获取波次列表失败')
|
throw new Error(res?.message || '获取波次列表失败')
|
||||||
@ -1501,6 +1510,13 @@ function handlePageSizeChange(size: number) {
|
|||||||
loadData()
|
loadData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleSortChange({ prop, order }: any) {
|
||||||
|
currentSort.prop = prop
|
||||||
|
currentSort.order = order
|
||||||
|
pagination.currentPage = 1
|
||||||
|
loadData()
|
||||||
|
}
|
||||||
|
|
||||||
function handleSourceFilterChange() {
|
function handleSourceFilterChange() {
|
||||||
pagination.currentPage = 1
|
pagination.currentPage = 1
|
||||||
void loadData()
|
void loadData()
|
||||||
@ -1528,16 +1544,36 @@ 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<string, any>) {
|
function buildWhereConditions(rawConditions: Record<string, any>) {
|
||||||
const where: Record<string, any> = {}
|
const where: Record<string, any> = {}
|
||||||
Object.keys(rawConditions || {}).forEach((key) => {
|
Object.keys(rawConditions || {}).forEach((key) => {
|
||||||
const condition = rawConditions[key]
|
const condition = rawConditions[key]
|
||||||
if (condition && typeof condition === 'object' && 'operator' in condition) {
|
if (condition && typeof condition === 'object' && 'operator' in condition) {
|
||||||
const value = condition.value
|
const rawValue = condition.value
|
||||||
if (value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0)) {
|
if (rawValue === undefined || rawValue === null || rawValue === '' || (Array.isArray(rawValue) && rawValue.length === 0)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
where[key] = value
|
// 模糊文本字段:操作符经 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
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (condition !== undefined && condition !== null && condition !== '') {
|
if (condition !== undefined && condition !== null && condition !== '') {
|
||||||
|
|||||||
@ -64,6 +64,7 @@
|
|||||||
@page-change="handlePageChange"
|
@page-change="handlePageChange"
|
||||||
@page-size-change="handlePageSizeChange"
|
@page-size-change="handlePageSizeChange"
|
||||||
@refresh="loadData"
|
@refresh="loadData"
|
||||||
|
@sort-change="handleSortChange"
|
||||||
@selection-change="handleSelectionChange"
|
@selection-change="handleSelectionChange"
|
||||||
>
|
>
|
||||||
<template #column-wave_id="{ row }">
|
<template #column-wave_id="{ row }">
|
||||||
@ -537,7 +538,7 @@ import {
|
|||||||
} from '@/api/order.wave/orderwave'
|
} from '@/api/order.wave/orderwave'
|
||||||
import { batchQuickRecheckByWave } from '@/api/order.recheckorder/recheckOrder'
|
import { batchQuickRecheckByWave } from '@/api/order.recheckorder/recheckOrder'
|
||||||
import { markWavePrintStatus } from '@/api/print/print'
|
import { markWavePrintStatus } from '@/api/print/print'
|
||||||
import { orderWaveBatchList, unwrapWaveBatchListResponse } from '@/api/order/order'
|
import { orderWaveBatchList, unwrapWaveBatchListResponse, type WaveBatchListSort } from '@/api/order/order'
|
||||||
import type {
|
import type {
|
||||||
WaveBatchAutoGroupingResponse,
|
WaveBatchAutoGroupingResponse,
|
||||||
WaveBatchAllocateExpressTaskProgressResponse,
|
WaveBatchAllocateExpressTaskProgressResponse,
|
||||||
@ -690,6 +691,7 @@ const batchCancelTaskProgress = reactive({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||||
|
const currentSort = reactive({ prop: '', order: '' })
|
||||||
const groupOrderPagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
const groupOrderPagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||||
const presetTree = ref<any[]>([])
|
const presetTree = ref<any[]>([])
|
||||||
const availableFieldsRef = reactive(JSON.parse(JSON.stringify(waveAvailableFields)))
|
const availableFieldsRef = reactive(JSON.parse(JSON.stringify(waveAvailableFields)))
|
||||||
@ -892,13 +894,20 @@ async function loadData() {
|
|||||||
if (where.wave_type === undefined || where.wave_type === null || where.wave_type === '') {
|
if (where.wave_type === undefined || where.wave_type === null || where.wave_type === '') {
|
||||||
where.wave_type = currentWaveType.value
|
where.wave_type = currentWaveType.value
|
||||||
}
|
}
|
||||||
|
const sort: WaveBatchListSort | undefined = currentSort.prop
|
||||||
|
? {
|
||||||
|
sortField: currentSort.prop,
|
||||||
|
sortOrder: currentSort.order === 'ascending' ? 'ASC' : 'DESC'
|
||||||
|
}
|
||||||
|
: undefined
|
||||||
const res = await orderWaveBatchList({
|
const res = await orderWaveBatchList({
|
||||||
pagination: {
|
pagination: {
|
||||||
page: pagination.currentPage,
|
page: pagination.currentPage,
|
||||||
pageSize: pagination.pageSize
|
pageSize: pagination.pageSize
|
||||||
},
|
},
|
||||||
...(onlyTodoWaves.value ? { only_todo: 1 } : {}),
|
...(onlyTodoWaves.value ? { only_todo: 1 } : {}),
|
||||||
where
|
where,
|
||||||
|
sort
|
||||||
})
|
})
|
||||||
if (!res || !okCode(res.code)) {
|
if (!res || !okCode(res.code)) {
|
||||||
throw new Error(res?.message || '获取波次列表失败')
|
throw new Error(res?.message || '获取波次列表失败')
|
||||||
@ -939,6 +948,13 @@ function handlePageSizeChange(size: number) {
|
|||||||
loadData()
|
loadData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleSortChange({ prop, order }: any) {
|
||||||
|
currentSort.prop = prop
|
||||||
|
currentSort.order = order
|
||||||
|
pagination.currentPage = 1
|
||||||
|
loadData()
|
||||||
|
}
|
||||||
|
|
||||||
function handleSourceFilterChange() {
|
function handleSourceFilterChange() {
|
||||||
pagination.currentPage = 1
|
pagination.currentPage = 1
|
||||||
void loadData()
|
void loadData()
|
||||||
@ -966,16 +982,36 @@ 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<string, any>) {
|
function buildWhereConditions(rawConditions: Record<string, any>) {
|
||||||
const where: Record<string, any> = {}
|
const where: Record<string, any> = {}
|
||||||
Object.keys(rawConditions || {}).forEach((key) => {
|
Object.keys(rawConditions || {}).forEach((key) => {
|
||||||
const condition = rawConditions[key]
|
const condition = rawConditions[key]
|
||||||
if (condition && typeof condition === 'object' && 'operator' in condition) {
|
if (condition && typeof condition === 'object' && 'operator' in condition) {
|
||||||
const value = condition.value
|
const rawValue = condition.value
|
||||||
if (value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0)) {
|
if (rawValue === undefined || rawValue === null || rawValue === '' || (Array.isArray(rawValue) && rawValue.length === 0)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
where[key] = value
|
// 模糊文本字段:操作符经 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
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (condition !== undefined && condition !== null && condition !== '') {
|
if (condition !== undefined && condition !== null && condition !== '') {
|
||||||
|
|||||||
@ -55,6 +55,7 @@
|
|||||||
@page-change="handlePageChange"
|
@page-change="handlePageChange"
|
||||||
@page-size-change="handlePageSizeChange"
|
@page-size-change="handlePageSizeChange"
|
||||||
@refresh="loadData"
|
@refresh="loadData"
|
||||||
|
@sort-change="handleSortChange"
|
||||||
@selection-change="handleSelectionChange"
|
@selection-change="handleSelectionChange"
|
||||||
>
|
>
|
||||||
<template #pagination-info-extra>
|
<template #pagination-info-extra>
|
||||||
@ -273,6 +274,7 @@ import {
|
|||||||
orderWaveWavePickTaskCancelSelf,
|
orderWaveWavePickTaskCancelSelf,
|
||||||
orderWaveWavePickTaskList,
|
orderWaveWavePickTaskList,
|
||||||
unwrapWavePickTaskListResponse,
|
unwrapWavePickTaskListResponse,
|
||||||
|
type WaveListRpcSort,
|
||||||
type WavePickTaskListItem
|
type WavePickTaskListItem
|
||||||
} from '@/api/order.wave/orderwave'
|
} from '@/api/order.wave/orderwave'
|
||||||
import {
|
import {
|
||||||
@ -350,6 +352,7 @@ const pagination = reactive({
|
|||||||
pageSize: pickTaskWavePaginationDefaults.initialPageSize,
|
pageSize: pickTaskWavePaginationDefaults.initialPageSize,
|
||||||
total: 0
|
total: 0
|
||||||
})
|
})
|
||||||
|
const currentSort = reactive({ prop: '', order: '' })
|
||||||
|
|
||||||
const warehouseId = computed(() => Number(userStore.user?.warehouse_id ?? userStore.user?.store_id ?? 0))
|
const warehouseId = computed(() => Number(userStore.user?.warehouse_id ?? userStore.user?.store_id ?? 0))
|
||||||
|
|
||||||
@ -845,6 +848,12 @@ async function loadData() {
|
|||||||
const reviewUserName = toWhereTextValue(resolveScanFilterValue(flat, ['review_user_name', 'recheck_user_name'], rawConditions), reviewUserNameOp)
|
const reviewUserName = toWhereTextValue(resolveScanFilterValue(flat, ['review_user_name', 'recheck_user_name'], rawConditions), reviewUserNameOp)
|
||||||
/** 波次号:固定仅模糊查询(like),value 为字符串 */
|
/** 波次号:固定仅模糊查询(like),value 为字符串 */
|
||||||
const waveNo = toWhereTextValue(resolveScanFilterValue(flat, ['wave_no'], rawConditions), waveNoOp)
|
const waveNo = toWhereTextValue(resolveScanFilterValue(flat, ['wave_no'], rawConditions), waveNoOp)
|
||||||
|
const sort: WaveListRpcSort | undefined = currentSort.prop
|
||||||
|
? {
|
||||||
|
sortField: currentSort.prop,
|
||||||
|
sortOrder: currentSort.order === 'ascending' ? 'ASC' : 'DESC'
|
||||||
|
}
|
||||||
|
: undefined
|
||||||
const res = await orderWaveWavePickTaskList({
|
const res = await orderWaveWavePickTaskList({
|
||||||
warehouse_id: wid,
|
warehouse_id: wid,
|
||||||
page_no: pagination.currentPage,
|
page_no: pagination.currentPage,
|
||||||
@ -871,7 +880,8 @@ async function loadData() {
|
|||||||
review_user_name: reviewUserName ? { operator: reviewUserNameOp, value: reviewUserName } : undefined,
|
review_user_name: reviewUserName ? { operator: reviewUserNameOp, value: reviewUserName } : undefined,
|
||||||
claim_operator: claimOperatorName ? { operator: claimOperatorNameOp, value: claimOperatorName } : undefined,
|
claim_operator: claimOperatorName ? { operator: claimOperatorNameOp, value: claimOperatorName } : undefined,
|
||||||
wave_no: waveNo ? { operator: waveNoOp, value: waveNo } : undefined
|
wave_no: waveNo ? { operator: waveNoOp, value: waveNo } : undefined
|
||||||
}
|
},
|
||||||
|
sort
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!res || !okCode(res.code)) {
|
if (!res || !okCode(res.code)) {
|
||||||
@ -1015,6 +1025,13 @@ function handlePageChange(page: number) {
|
|||||||
void loadData()
|
void loadData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleSortChange({ prop, order }: any) {
|
||||||
|
currentSort.prop = prop
|
||||||
|
currentSort.order = order
|
||||||
|
pagination.currentPage = 1
|
||||||
|
void loadData()
|
||||||
|
}
|
||||||
|
|
||||||
function handlePageSizeChange(size: number) {
|
function handlePageSizeChange(size: number) {
|
||||||
pagination.pageSize = size
|
pagination.pageSize = size
|
||||||
pagination.currentPage = 1
|
pagination.currentPage = 1
|
||||||
|
|||||||
@ -58,6 +58,7 @@
|
|||||||
@page-change="handlePageChange"
|
@page-change="handlePageChange"
|
||||||
@page-size-change="handlePageSizeChange"
|
@page-size-change="handlePageSizeChange"
|
||||||
@refresh="loadData"
|
@refresh="loadData"
|
||||||
|
@sort-change="handleSortChange"
|
||||||
>
|
>
|
||||||
<template #column-strategy_type="{ row }">
|
<template #column-strategy_type="{ row }">
|
||||||
<span v-if="row.strategy_type != null" :class="getStatusTextClass(row.strategy_type == 2 ? 'warning' : 'primary')">
|
<span v-if="row.strategy_type != null" :class="getStatusTextClass(row.strategy_type == 2 ? 'warning' : 'primary')">
|
||||||
@ -393,7 +394,8 @@ import type {
|
|||||||
WaveStrategyListParams,
|
WaveStrategyListParams,
|
||||||
WaveStrategyListResponse,
|
WaveStrategyListResponse,
|
||||||
WaveStrategyMutationResponse,
|
WaveStrategyMutationResponse,
|
||||||
WaveStrategyUpdateParams
|
WaveStrategyUpdateParams,
|
||||||
|
WaveListRpcSort
|
||||||
} from '@/api/order.wave/orderwave'
|
} from '@/api/order.wave/orderwave'
|
||||||
import pcasCodeData from 'china-division/dist/pcas-code.json'
|
import pcasCodeData from 'china-division/dist/pcas-code.json'
|
||||||
|
|
||||||
@ -411,6 +413,7 @@ const queryTime = ref(0)
|
|||||||
const tableSize = ref('small')
|
const tableSize = ref('small')
|
||||||
const list = ref<any[]>([])
|
const list = ref<any[]>([])
|
||||||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||||
|
const currentSort = reactive({ prop: '', order: '' })
|
||||||
|
|
||||||
const showWaveStrategyNextFetchOrderCount = ref(false)
|
const showWaveStrategyNextFetchOrderCount = ref(false)
|
||||||
const waveStrategyFetchSubmittingId = ref<number | null>(null)
|
const waveStrategyFetchSubmittingId = ref<number | null>(null)
|
||||||
@ -573,6 +576,12 @@ function buildWaveStrategyListApiParams(): WaveStrategyListParams {
|
|||||||
if (strategyTypeRaw !== undefined && strategyTypeRaw !== null && strategyTypeRaw !== '') {
|
if (strategyTypeRaw !== undefined && strategyTypeRaw !== null && strategyTypeRaw !== '') {
|
||||||
params.strategy_type = Number(strategyTypeRaw)
|
params.strategy_type = Number(strategyTypeRaw)
|
||||||
}
|
}
|
||||||
|
if (currentSort.prop) {
|
||||||
|
params.sort = {
|
||||||
|
sortField: currentSort.prop,
|
||||||
|
sortOrder: currentSort.order === 'ascending' ? 'ASC' : 'DESC'
|
||||||
|
}
|
||||||
|
}
|
||||||
return params
|
return params
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -612,6 +621,13 @@ function handlePageChange(page: number) {
|
|||||||
void loadData()
|
void loadData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleSortChange({ prop, order }: any) {
|
||||||
|
currentSort.prop = prop
|
||||||
|
currentSort.order = order
|
||||||
|
pagination.currentPage = 1
|
||||||
|
void loadData()
|
||||||
|
}
|
||||||
|
|
||||||
function handlePageSizeChange(size: number) {
|
function handlePageSizeChange(size: number) {
|
||||||
pagination.pageSize = size
|
pagination.pageSize = size
|
||||||
pagination.currentPage = 1
|
pagination.currentPage = 1
|
||||||
|
|||||||
@ -9,6 +9,7 @@ export const WAVE_PAGE_CONFIG = {
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
buyerMessageHasFilterOptions,
|
buyerMessageHasFilterOptions,
|
||||||
|
ORDER_BULK_SEARCH_OPERATORS,
|
||||||
scanBasicField,
|
scanBasicField,
|
||||||
scanWorkflowField,
|
scanWorkflowField,
|
||||||
type ToolbarButtonConfig,
|
type ToolbarButtonConfig,
|
||||||
@ -103,7 +104,13 @@ export const waveUpperTableDefaults = {
|
|||||||
/** 左侧筛选可用字段(对标待处理订单 ScanBox 分组排序) */
|
/** 左侧筛选可用字段(对标待处理订单 ScanBox 分组排序) */
|
||||||
export const waveAvailableFields = [
|
export const waveAvailableFields = [
|
||||||
// ===== 波次信息 =====
|
// ===== 波次信息 =====
|
||||||
waveScanBasicField({ label: '波次号', value: 'wave_no', type: 'text' }),
|
waveScanBasicField({
|
||||||
|
label: '波次号',
|
||||||
|
value: 'wave_no',
|
||||||
|
type: 'text',
|
||||||
|
operators: ORDER_BULK_SEARCH_OPERATORS,
|
||||||
|
defaultOperator: 'like'
|
||||||
|
}),
|
||||||
waveScanBasicField({
|
waveScanBasicField({
|
||||||
label: '货主',
|
label: '货主',
|
||||||
value: 'store_id',
|
value: 'store_id',
|
||||||
@ -208,8 +215,20 @@ export const waveAvailableFields = [
|
|||||||
{ label: 'PDA策略', value: 2 }
|
{ label: 'PDA策略', value: 2 }
|
||||||
]
|
]
|
||||||
}), group: WAVE_SCAN_OTHER_GROUP },
|
}), group: WAVE_SCAN_OTHER_GROUP },
|
||||||
{ ...waveScanBasicField({ label: '快递', value: 'logistics_name', type: 'text' }), group: WAVE_SCAN_OTHER_GROUP },
|
{ ...waveScanBasicField({
|
||||||
{ ...waveScanBasicField({ label: '创建人', value: 'creator', type: 'text' }), group: WAVE_SCAN_OTHER_GROUP },
|
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 },
|
||||||
]
|
]
|
||||||
|
|
||||||
/** 抓取散单候选:左侧筛选可用字段 */
|
/** 抓取散单候选:左侧筛选可用字段 */
|
||||||
@ -336,7 +355,7 @@ export const waveStrategyColumns = [
|
|||||||
{ prop: 'id', label: 'ID', width: 72, align: 'center', fixed: 'left' },
|
{ prop: 'id', label: 'ID', width: 72, align: 'center', fixed: 'left' },
|
||||||
{ prop: 'strategy_name', label: '策略名称', minWidth: 160, fixed: 'left' },
|
{ prop: 'strategy_name', label: '策略名称', minWidth: 160, fixed: 'left' },
|
||||||
{ prop: 'wave_prefix', label: '波次前缀', width: 100, align: 'center' },
|
{ prop: 'wave_prefix', label: '波次前缀', width: 100, align: 'center' },
|
||||||
{ prop: 'matched_order_count_filtered', label: '匹配订单数', width: 110, align: 'center' },
|
{ prop: 'matched_order_count_filtered', label: '匹配订单数', width: 110, align: 'center', sortable: true },
|
||||||
{ prop: 'next_fetch_order_count', label: '下一波抓取数量', width: 130, align: 'center' },
|
{ prop: 'next_fetch_order_count', label: '下一波抓取数量', width: 130, align: 'center' },
|
||||||
{ prop: 'strategy_type', label: '策略类型', width: 90, align: 'center' },
|
{ prop: 'strategy_type', label: '策略类型', width: 90, align: 'center' },
|
||||||
{ prop: 'status', label: '状态', width: 80, align: 'center' },
|
{ prop: 'status', label: '状态', width: 80, align: 'center' },
|
||||||
@ -367,9 +386,9 @@ export const waveBatchColumns = applyWaveListCopyActions([
|
|||||||
{ prop: 'store_name', label: '货主', minWidth: 120 },
|
{ prop: 'store_name', label: '货主', minWidth: 120 },
|
||||||
{ prop: 'wave_type', label: '波次类型', minWidth: 96 },
|
{ prop: 'wave_type', label: '波次类型', minWidth: 96 },
|
||||||
{ prop: 'wave_status', label: '波次状态', minWidth: 110 },
|
{ prop: 'wave_status', label: '波次状态', minWidth: 110 },
|
||||||
{ prop: 'total_orders', label: '总订单数', minWidth: 110 },
|
{ prop: 'total_orders', label: '总订单数', minWidth: 110, sortable: true },
|
||||||
{ prop: 'order_count', label: '订单数量', minWidth: 100 },
|
{ prop: 'order_count', label: '订单数量', minWidth: 100, sortable: true },
|
||||||
{ prop: 'processed_orders', label: '已处理订单', minWidth: 108 },
|
{ prop: 'processed_orders', label: '已处理订单', minWidth: 108, sortable: true },
|
||||||
// { prop: 'item_detail_machine', label: '商品结构', minWidth: 320 },
|
// { prop: 'item_detail_machine', label: '商品结构', minWidth: 320 },
|
||||||
// { prop: 'item_part_type', label: '商品类型', minWidth: 120 },
|
// { prop: 'item_part_type', label: '商品类型', minWidth: 120 },
|
||||||
// { prop: 'item_part', label: '商品部位', minWidth: 220 },
|
// { prop: 'item_part', label: '商品部位', minWidth: 220 },
|
||||||
@ -381,7 +400,7 @@ export const waveBatchColumns = applyWaveListCopyActions([
|
|||||||
{ prop: 'print_assignment_status', label: '打印状态', minWidth: 110 },
|
{ prop: 'print_assignment_status', label: '打印状态', minWidth: 110 },
|
||||||
{ prop: 'pick_assignment_status', label: '拣货状态', minWidth: 110 },
|
{ prop: 'pick_assignment_status', label: '拣货状态', minWidth: 110 },
|
||||||
{ prop: 'review_assignment_status', label: '复核状态', minWidth: 110 },
|
{ prop: 'review_assignment_status', label: '复核状态', minWidth: 110 },
|
||||||
{ prop: 'unreviewed_order_count', label: '未复核数', minWidth: 96 },
|
{ prop: 'unreviewed_order_count', label: '未复核数', minWidth: 96, sortable: true },
|
||||||
{ prop: 'logistics_name', label: '快递', minWidth: 120 },
|
{ prop: 'logistics_name', label: '快递', minWidth: 120 },
|
||||||
{ prop: 'creator', label: '创建人', minWidth: 100 },
|
{ prop: 'creator', label: '创建人', minWidth: 100 },
|
||||||
{ prop: 'warehouse_id', label: '仓库ID', minWidth: 110 },
|
{ prop: 'warehouse_id', label: '仓库ID', minWidth: 110 },
|
||||||
@ -1108,7 +1127,7 @@ export const pickTaskWaveColumns = applyWaveListCopyActions([
|
|||||||
{ prop: 'source', label: '来源', width: 90 },
|
{ prop: 'source', label: '来源', width: 90 },
|
||||||
{ prop: 'warehouse_id', label: '仓库ID', width: 90, align: 'center' },
|
{ prop: 'warehouse_id', label: '仓库ID', width: 90, align: 'center' },
|
||||||
{ prop: 'wave_count', label: '波次数', width: 90 },
|
{ prop: 'wave_count', label: '波次数', width: 90 },
|
||||||
{ prop: 'order_count', label: '订单数', width: 90 },
|
{ prop: 'order_count', label: '订单数', width: 90, sortable: true },
|
||||||
{ prop: 'box_count', label: '箱数', width: 110 },
|
{ prop: 'box_count', label: '箱数', width: 110 },
|
||||||
{ prop: 'operator_name', label: '操作人', minWidth: 120 },
|
{ prop: 'operator_name', label: '操作人', minWidth: 120 },
|
||||||
{ prop: 'pick_user_name', label: '拣货员', minWidth: 120 },
|
{ prop: 'pick_user_name', label: '拣货员', minWidth: 120 },
|
||||||
|
|||||||
@ -799,14 +799,14 @@ async function handleBindSubmit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const payload = unwrapBindReceivingPayload(res)
|
const payload = unwrapBindReceivingPayload(res)
|
||||||
const successCount = payload.success_count ?? payload.success?.length ?? receivingIds.length
|
const successCount = payload.bound?.length ?? receivingIds.length
|
||||||
const failed = payload.failed ?? []
|
const skipped = payload.skipped ?? []
|
||||||
const failedCount = payload.failed_count ?? failed.length
|
const failedCount = skipped.length
|
||||||
|
|
||||||
if (failedCount > 0) {
|
if (failedCount > 0) {
|
||||||
const firstErr = failed[0]?.message || failed[0]?.error_code || '部分收货单绑定失败'
|
const firstErr = skipped[0]?.message || skipped[0]?.error_code || '部分收货单绑定失败'
|
||||||
if (successCount > 0) {
|
if (successCount > 0) {
|
||||||
ElMessage.warning(`成功 ${successCount} 条,失败 ${failedCount} 条:${firstErr}`)
|
ElMessage.warning(`成功 ${successCount} 条,跳过 ${failedCount} 条:${firstErr}`)
|
||||||
visible.value = false
|
visible.value = false
|
||||||
emit('success')
|
emit('success')
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -0,0 +1,629 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog
|
||||||
|
v-model="visible"
|
||||||
|
title="解除收货单绑定"
|
||||||
|
width="780px"
|
||||||
|
class="entry-unbind-dialog"
|
||||||
|
align-center
|
||||||
|
append-to-body
|
||||||
|
destroy-on-close
|
||||||
|
@closed="handleClosed"
|
||||||
|
>
|
||||||
|
<div class="unbind-content">
|
||||||
|
<!-- 入库单摘要(对应接口入参 entry_order_id 的主表信息) -->
|
||||||
|
<div v-if="entryOrderCode" class="entry-order-summary">
|
||||||
|
<span class="summary-inline">
|
||||||
|
<span class="summary-label">入库单号</span>
|
||||||
|
<span class="summary-value">{{ entryOrderCode }}</span>
|
||||||
|
</span>
|
||||||
|
<span v-if="entryOrderId" class="summary-inline">
|
||||||
|
<span class="summary-label">入库单ID</span>
|
||||||
|
<span class="summary-value">{{ entryOrderId }}</span>
|
||||||
|
</span>
|
||||||
|
<span v-if="entryStoreName" class="summary-inline">
|
||||||
|
<span class="summary-label">货主</span>
|
||||||
|
<span class="summary-value">{{ entryStoreName }}</span>
|
||||||
|
</span>
|
||||||
|
<span v-if="entryOrderStatusLabel" class="summary-inline">
|
||||||
|
<span class="summary-label">订单状态</span>
|
||||||
|
<el-tag size="small" :type="entryOrderStatusTag">{{ entryOrderStatusLabel }}</el-tag>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-alert type="warning" :closable="false" show-icon class="unbind-tip">
|
||||||
|
<template #title>
|
||||||
|
解除绑定将释放所选收货单与本入库单的主表关联,并按数量台账<b>回滚其已入库进度</b>;仅「已创建 / 待入库」状态的入库单可解绑。
|
||||||
|
</template>
|
||||||
|
</el-alert>
|
||||||
|
|
||||||
|
<!-- 表单:入参 entry_order_id(只读) + receiving_ids(勾选收货单) -->
|
||||||
|
<el-form :model="form" label-width="120px" size="small" class="unbind-form">
|
||||||
|
<el-form-item label="入库单ID">
|
||||||
|
<el-input
|
||||||
|
:model-value="form.entry_order_id ? String(form.entry_order_id) : '—'"
|
||||||
|
disabled
|
||||||
|
placeholder="--"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item
|
||||||
|
:label="'待解绑收货单' + (selectedRows.length ? `(${selectedRows.length})` : '')"
|
||||||
|
>
|
||||||
|
<div v-loading="bindingsLoading" class="receiving-table-wrap">
|
||||||
|
<el-table
|
||||||
|
ref="receivingTableRef"
|
||||||
|
:data="bindingRows"
|
||||||
|
border
|
||||||
|
stripe
|
||||||
|
size="small"
|
||||||
|
max-height="240"
|
||||||
|
row-key="rowKey"
|
||||||
|
empty-text="该入库单暂无可解绑的收货单"
|
||||||
|
:row-class-name="receivingRowClassName"
|
||||||
|
@selection-change="handleSelectionChange"
|
||||||
|
>
|
||||||
|
<el-table-column type="selection" width="40" align="center" fixed="left" />
|
||||||
|
<el-table-column
|
||||||
|
v-for="col in entryReceivingBindingColumns"
|
||||||
|
:key="col.prop"
|
||||||
|
:prop="col.prop"
|
||||||
|
:label="col.label"
|
||||||
|
:width="col.width"
|
||||||
|
:min-width="col.minWidth"
|
||||||
|
show-overflow-tooltip
|
||||||
|
>
|
||||||
|
<template #default="{ row: cellRow }">
|
||||||
|
<template v-if="col.prop === 'created_at'">
|
||||||
|
{{ cellRow.created_at }}
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
{{ formatCell(cellRow[col.prop]) }}
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
<div class="form-item-tip">
|
||||||
|
勾选已绑定的收货单,确认后将调用接口解除绑定并回滚入库进度。
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<!-- 解绑结果明细(存在失败或部分成功时展示) -->
|
||||||
|
<div v-if="resultVisible" class="unbind-result">
|
||||||
|
<div
|
||||||
|
class="result-summary"
|
||||||
|
:class="resultSummaryClass"
|
||||||
|
>
|
||||||
|
{{ resultSummaryText }}
|
||||||
|
</div>
|
||||||
|
<div v-if="resultFailedRows.length" class="result-block">
|
||||||
|
<div class="result-block-title result-block-title--danger">失败明细({{ resultFailedRows.length }})</div>
|
||||||
|
<div v-for="item in resultFailedRows" :key="'f-' + item.receiving_id" class="result-row">
|
||||||
|
<span class="result-receiving">{{ item.receiving_number || ('收货单#' + item.receiving_id) }}</span>
|
||||||
|
<el-tag size="small" type="danger">{{ item.error_code_label }}</el-tag>
|
||||||
|
<span class="result-message">{{ item.message || '解绑失败' }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="resultSuccessRows.length" class="result-block">
|
||||||
|
<div class="result-block-title result-block-title--success">成功明细({{ resultSuccessRows.length }})</div>
|
||||||
|
<div v-for="item in resultSuccessRows" :key="'s-' + item.receiving_id" class="result-row">
|
||||||
|
<span class="result-receiving">{{ item.receiving_number || ('收货单#' + item.receiving_id) }}</span>
|
||||||
|
<el-tag size="small" type="success">已解绑</el-tag>
|
||||||
|
<span class="result-message">
|
||||||
|
释放明细 {{ item.released_detail_count ?? 0 }} 条,回滚入库 {{ formatRollback(item.rolled_back_quantity) }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<el-button size="small" :disabled="unbindSubmitting" @click="visible = false">
|
||||||
|
{{ resultVisible ? '关闭' : '取消' }}
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="!resultVisible"
|
||||||
|
size="small"
|
||||||
|
type="danger"
|
||||||
|
:loading="unbindSubmitting"
|
||||||
|
:disabled="!canSubmitUnbind"
|
||||||
|
@click="handleUnbindSubmit"
|
||||||
|
>
|
||||||
|
确认解绑
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, nextTick, reactive, ref, watch } from 'vue'
|
||||||
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
|
import type { TableInstance } from 'element-plus'
|
||||||
|
import { getEntryDetail, unbindReceiving } from '@/api/storage.entry/entry'
|
||||||
|
import type {
|
||||||
|
EntryOrderReceivingBinding,
|
||||||
|
UnbindReceivingFailedItem,
|
||||||
|
UnbindReceivingResponse,
|
||||||
|
UnbindReceivingSuccessItem,
|
||||||
|
} from '@/api/storage.entry/entry'
|
||||||
|
import { formatDateTime } from '@/views/storage/receiving/receiving-config'
|
||||||
|
import {
|
||||||
|
entryReceivingBindingColumns,
|
||||||
|
formatEntryOrderStatus,
|
||||||
|
formatReceivingOrderStatusLabel,
|
||||||
|
formatUnbindErrorCode,
|
||||||
|
getEntryOrderStatusTagType,
|
||||||
|
} from '../entry-config'
|
||||||
|
|
||||||
|
export type EntryOrderUnbindRow = {
|
||||||
|
id?: number | string
|
||||||
|
entry_order_code?: string
|
||||||
|
entry_number?: string
|
||||||
|
order_code?: string
|
||||||
|
store_id?: number | string
|
||||||
|
store_name?: string
|
||||||
|
order_status?: string
|
||||||
|
receivingBindings?: unknown[]
|
||||||
|
[key: string]: unknown
|
||||||
|
}
|
||||||
|
|
||||||
|
type BindingRow = {
|
||||||
|
rowKey: string
|
||||||
|
receiving_id?: number
|
||||||
|
receiving_number: string
|
||||||
|
status_label: string
|
||||||
|
storage_status_label: string
|
||||||
|
created_at: string
|
||||||
|
}
|
||||||
|
|
||||||
|
type ResultFailedRow = {
|
||||||
|
receiving_id?: number
|
||||||
|
receiving_number: string
|
||||||
|
error_code?: string
|
||||||
|
error_code_label: string
|
||||||
|
message?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
type ResultSuccessRow = {
|
||||||
|
receiving_id?: number
|
||||||
|
receiving_number: string
|
||||||
|
released_detail_count?: number
|
||||||
|
released_detail_ids?: number[]
|
||||||
|
rolled_back_quantity?: number
|
||||||
|
message?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
modelValue: boolean
|
||||||
|
row: EntryOrderUnbindRow | null
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
'update:modelValue': [value: boolean]
|
||||||
|
closed: []
|
||||||
|
success: []
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const visible = computed({
|
||||||
|
get: () => props.modelValue,
|
||||||
|
set: (value: boolean) => emit('update:modelValue', value),
|
||||||
|
})
|
||||||
|
|
||||||
|
const form = reactive<{ entry_order_id?: number | null }>({ entry_order_id: null })
|
||||||
|
|
||||||
|
const receivingTableRef = ref<TableInstance | null>(null)
|
||||||
|
const bindingsLoading = ref(false)
|
||||||
|
const unbindSubmitting = ref(false)
|
||||||
|
const bindingRows = ref<BindingRow[]>([])
|
||||||
|
const selectedRows = ref<BindingRow[]>([])
|
||||||
|
const resultVisible = ref(false)
|
||||||
|
const resultSuccessRows = ref<ResultSuccessRow[]>([])
|
||||||
|
const resultFailedRows = ref<ResultFailedRow[]>([])
|
||||||
|
|
||||||
|
const entryOrderId = computed(() => {
|
||||||
|
const id = Number(props.row?.id)
|
||||||
|
return Number.isFinite(id) && id > 0 ? id : null
|
||||||
|
})
|
||||||
|
|
||||||
|
const entryOrderCode = computed(() => {
|
||||||
|
const row = props.row
|
||||||
|
if (!row) return ''
|
||||||
|
const code = row.entry_order_code || row.entry_number || row.order_code
|
||||||
|
if (code !== null && code !== undefined && String(code).trim()) {
|
||||||
|
return String(code).trim()
|
||||||
|
}
|
||||||
|
if (row.id !== null && row.id !== undefined && String(row.id).trim()) {
|
||||||
|
return String(row.id).trim()
|
||||||
|
}
|
||||||
|
return ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const entryStoreName = computed(() => {
|
||||||
|
const name = props.row?.store_name
|
||||||
|
return name !== null && name !== undefined && String(name).trim() ? String(name).trim() : ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const entryOrderStatusLabel = computed(() => {
|
||||||
|
const status = props.row?.order_status
|
||||||
|
if (status === null || status === undefined || status === '') return ''
|
||||||
|
return formatEntryOrderStatus(status)
|
||||||
|
})
|
||||||
|
|
||||||
|
const entryOrderStatusTag = computed(() => getEntryOrderStatusTagType(props.row?.order_status))
|
||||||
|
|
||||||
|
const canSubmitUnbind = computed(
|
||||||
|
() => !!entryOrderId.value && selectedRows.value.length > 0 && !unbindSubmitting.value && !bindingsLoading.value
|
||||||
|
)
|
||||||
|
|
||||||
|
const resultSummaryText = computed(() => {
|
||||||
|
return `处理完成:成功解绑 ${resultSuccessRows.value.length} 条,失败 ${resultFailedRows.value.length} 条`
|
||||||
|
})
|
||||||
|
|
||||||
|
const resultSummaryClass = computed(() =>
|
||||||
|
resultFailedRows.value.length ? 'result-summary--warning' : 'result-summary--success'
|
||||||
|
)
|
||||||
|
|
||||||
|
function isApiSuccess(res: { code?: number; flag?: string } | null | undefined): boolean {
|
||||||
|
if (!res) return false
|
||||||
|
if (res.code === 200 || res.code === 1) return true
|
||||||
|
return res.flag === 'success'
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatCell(value: unknown): string {
|
||||||
|
if (value === null || value === undefined || value === '') return '—'
|
||||||
|
return String(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatRollback(value: unknown): string {
|
||||||
|
if (value === null || value === undefined || value === '') return '—'
|
||||||
|
return String(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function receivingRowClassName({ row }: { row: BindingRow }): string {
|
||||||
|
return row.receiving_id ? '' : 'disabled-row'
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapBindingRow(binding: EntryOrderReceivingBinding, index: number): BindingRow {
|
||||||
|
const receiving = (binding.receiving ?? {}) as Record<string, unknown>
|
||||||
|
const receivingId = Number(binding.receiving_id ?? receiving.id)
|
||||||
|
const status = receiving.status ?? receiving.storage_status
|
||||||
|
return {
|
||||||
|
rowKey: `recv-${binding.id ?? receivingId ?? index}`,
|
||||||
|
receiving_id: Number.isFinite(receivingId) && receivingId > 0 ? receivingId : undefined,
|
||||||
|
receiving_number: pickText(receiving, ['receiving_number'], `#${binding.receiving_id ?? index + 1}`),
|
||||||
|
status_label: formatReceivingOrderStatusLabel(status) || '—',
|
||||||
|
storage_status_label: formatReceivingOrderStatusLabel(receiving.storage_status) || '—',
|
||||||
|
created_at: receiving.created_at ? formatDateTime(String(receiving.created_at)) : '—',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function pickText(row: Record<string, unknown>, keys: string[], fallback = '—'): string {
|
||||||
|
for (const key of keys) {
|
||||||
|
const val = row[key]
|
||||||
|
if (val !== null && val !== undefined && val !== '') return String(val)
|
||||||
|
}
|
||||||
|
return fallback
|
||||||
|
}
|
||||||
|
|
||||||
|
function numberByReceivingId(map: Map<number, string>, id?: number): string {
|
||||||
|
if (id === undefined || id === null) return ''
|
||||||
|
return map.get(Number(id)) ?? ''
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadBoundReceivings() {
|
||||||
|
bindingRows.value = []
|
||||||
|
selectedRows.value = []
|
||||||
|
resultVisible.value = false
|
||||||
|
resultSuccessRows.value = []
|
||||||
|
resultFailedRows.value = []
|
||||||
|
|
||||||
|
if (!entryOrderId.value) return
|
||||||
|
|
||||||
|
bindingsLoading.value = true
|
||||||
|
try {
|
||||||
|
// 优先取详情接口最新的绑定关系,失败则回退列表行自带的 receivingBindings
|
||||||
|
let bindings: EntryOrderReceivingBinding[] = []
|
||||||
|
try {
|
||||||
|
const res = await getEntryDetail({ id: entryOrderId.value })
|
||||||
|
if (!isApiSuccess(res)) throw new Error(res?.message || '获取入库单详情失败')
|
||||||
|
const entryOrder = res.entryOrder ?? res.data?.entryOrder
|
||||||
|
const data = res.data && typeof res.data === 'object' ? (res.data as Record<string, unknown>) : {}
|
||||||
|
bindings = (Array.isArray(data.receivingBindings)
|
||||||
|
? data.receivingBindings
|
||||||
|
: Array.isArray(entryOrder?.receivingBindings)
|
||||||
|
? entryOrder.receivingBindings
|
||||||
|
: []) as EntryOrderReceivingBinding[]
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('获取详情绑定关系失败,回退列表行数据:', error)
|
||||||
|
const fallback = Array.isArray(props.row?.receivingBindings)
|
||||||
|
? (props.row?.receivingBindings as EntryOrderReceivingBinding[])
|
||||||
|
: []
|
||||||
|
bindings = fallback
|
||||||
|
}
|
||||||
|
|
||||||
|
bindingRows.value = bindings.map(mapBindingRow)
|
||||||
|
if (!bindingRows.value.length) {
|
||||||
|
ElMessage.info('该入库单暂无可解绑的收货单')
|
||||||
|
}
|
||||||
|
await nextTick()
|
||||||
|
receivingTableRef.value?.clearSelection()
|
||||||
|
} finally {
|
||||||
|
bindingsLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSelectionChange(rows: BindingRow[]) {
|
||||||
|
selectedRows.value = rows || []
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleClosed() {
|
||||||
|
bindingRows.value = []
|
||||||
|
selectedRows.value = []
|
||||||
|
resultVisible.value = false
|
||||||
|
resultSuccessRows.value = []
|
||||||
|
resultFailedRows.value = []
|
||||||
|
unbindSubmitting.value = false
|
||||||
|
form.entry_order_id = null
|
||||||
|
emit('closed')
|
||||||
|
}
|
||||||
|
|
||||||
|
function unwrapUnbindPayload(res: UnbindReceivingResponse): UnbindReceivingResponse {
|
||||||
|
if (res.data && typeof res.data === 'object') {
|
||||||
|
return { ...res, ...res.data }
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleUnbindSubmit() {
|
||||||
|
if (!entryOrderId.value) {
|
||||||
|
ElMessage.warning('缺少入库单信息,无法解绑')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const receivingIds = selectedRows.value
|
||||||
|
.map((row) => Number(row.receiving_id))
|
||||||
|
.filter((id) => Number.isFinite(id) && id > 0)
|
||||||
|
|
||||||
|
if (!receivingIds.length) {
|
||||||
|
ElMessage.warning('请至少勾选一条已绑定的收货单')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectedText = selectedRows.value.map((r) => r.receiving_number).join('、')
|
||||||
|
try {
|
||||||
|
await ElMessageBox.confirm(
|
||||||
|
`确认解除「${entryOrderCode.value}」与以下 ${receivingIds.length} 个收货单的绑定关系?\n${selectedText}\n\n解除后将回滚对应收货单已入库的进度,请谨慎操作。`,
|
||||||
|
'确认解除绑定',
|
||||||
|
{
|
||||||
|
type: 'warning',
|
||||||
|
confirmButtonText: '确认解绑',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
confirmButtonClass: 'el-button--danger',
|
||||||
|
dangerouslyUseHTMLString: false,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} catch {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
unbindSubmitting.value = true
|
||||||
|
try {
|
||||||
|
const res = await unbindReceiving({
|
||||||
|
entry_order_id: entryOrderId.value,
|
||||||
|
receiving_ids: receivingIds,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!isApiSuccess(res)) {
|
||||||
|
ElMessage.error(res?.message || '解除绑定失败')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const payload = unwrapUnbindPayload(res)
|
||||||
|
const successList = Array.isArray(payload.success) ? payload.success : []
|
||||||
|
const failedList = Array.isArray(payload.failed) ? payload.failed : []
|
||||||
|
|
||||||
|
// 用 receiving_id 回填收货单号便于结果展示
|
||||||
|
const numberMap = new Map<number, string>()
|
||||||
|
bindingRows.value.forEach((r) => {
|
||||||
|
if (r.receiving_id) numberMap.set(Number(r.receiving_id), r.receiving_number)
|
||||||
|
})
|
||||||
|
|
||||||
|
resultSuccessRows.value = successList.map((item: UnbindReceivingSuccessItem) => ({
|
||||||
|
receiving_id: item.receiving_id,
|
||||||
|
receiving_number: numberByReceivingId(numberMap, item.receiving_id),
|
||||||
|
released_detail_count: item.released_detail_count,
|
||||||
|
released_detail_ids: item.released_detail_ids,
|
||||||
|
rolled_back_quantity: item.rolled_back_quantity,
|
||||||
|
message: item.message,
|
||||||
|
}))
|
||||||
|
|
||||||
|
resultFailedRows.value = failedList.map((item: UnbindReceivingFailedItem) => ({
|
||||||
|
receiving_id: item.receiving_id,
|
||||||
|
receiving_number: numberByReceivingId(numberMap, item.receiving_id),
|
||||||
|
error_code: item.error_code,
|
||||||
|
error_code_label: formatUnbindErrorCode(item.error_code) || '解绑失败',
|
||||||
|
message: item.message,
|
||||||
|
}))
|
||||||
|
|
||||||
|
const successCount = resultSuccessRows.value.length
|
||||||
|
const failedCount = resultFailedRows.value.length
|
||||||
|
|
||||||
|
if (failedCount === 0) {
|
||||||
|
ElMessage.success(`已成功解绑 ${successCount} 个收货单`)
|
||||||
|
visible.value = false
|
||||||
|
emit('success')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 有失败:展示明细,部分成功时也允许父级刷新
|
||||||
|
resultVisible.value = true
|
||||||
|
const firstErr = resultFailedRows.value[0]
|
||||||
|
const firstErrText = firstErr?.message || firstErr?.error_code_label || '解绑失败'
|
||||||
|
if (successCount > 0) {
|
||||||
|
ElMessage.warning(`成功 ${successCount} 条,失败 ${failedCount} 条:${firstErrText}`)
|
||||||
|
emit('success')
|
||||||
|
} else {
|
||||||
|
ElMessage.error(firstErrText)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('解除绑定失败:', error)
|
||||||
|
ElMessage.error('解除绑定失败')
|
||||||
|
} finally {
|
||||||
|
unbindSubmitting.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => [props.modelValue, props.row?.id, props.row?.order_status] as const,
|
||||||
|
([open]) => {
|
||||||
|
if (!open) return
|
||||||
|
form.entry_order_id = entryOrderId.value
|
||||||
|
void loadBoundReceivings()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.unbind-content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.entry-order-summary {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px 20px;
|
||||||
|
padding: 6px 10px;
|
||||||
|
background: #f5f7fa;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-inline {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-label {
|
||||||
|
color: #909399;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-value {
|
||||||
|
color: #303133;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
|
.unbind-tip {
|
||||||
|
:deep(.el-alert__title) {
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
b {
|
||||||
|
color: #e6a23c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.unbind-form {
|
||||||
|
padding-top: 2px;
|
||||||
|
|
||||||
|
:deep(.el-form-item__label) {
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.receiving-table-wrap {
|
||||||
|
width: 100%;
|
||||||
|
border: 1px solid #dcdfe6;
|
||||||
|
border-radius: 4px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-item-tip {
|
||||||
|
margin-top: 4px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #909399;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.unbind-result {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 10px;
|
||||||
|
border: 1px solid #ebeef5;
|
||||||
|
border-radius: 4px;
|
||||||
|
background: #fafafa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-summary {
|
||||||
|
padding: 6px 10px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
|
||||||
|
&--success {
|
||||||
|
background: #f0f9eb;
|
||||||
|
color: #67c23a;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--warning {
|
||||||
|
background: #fdf6ec;
|
||||||
|
color: #e6a23c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-block {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-block-title {
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
margin-bottom: 2px;
|
||||||
|
|
||||||
|
&--danger {
|
||||||
|
color: #f56c6c;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--success {
|
||||||
|
color: #67c23a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.6;
|
||||||
|
|
||||||
|
.result-receiving {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
min-width: 120px;
|
||||||
|
color: #303133;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-message {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
color: #606266;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-table .disabled-row) {
|
||||||
|
opacity: 0.4;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -385,6 +385,37 @@ export function canBindEntryOrder(status: unknown): boolean {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 是否允许解除收货单绑定(storage.entry.unbindReceiving,仅 CREATED/PENDING 状态且存在绑定关系) */
|
||||||
|
export function canUnbindEntryOrder(row: {
|
||||||
|
order_status?: unknown
|
||||||
|
hasReceiving?: unknown
|
||||||
|
receivingBindings?: unknown
|
||||||
|
} | null | undefined): boolean {
|
||||||
|
if (!row) return false
|
||||||
|
const status = row.order_status
|
||||||
|
if (status === null || status === undefined || status === '') return false
|
||||||
|
const normalized = String(status).trim()
|
||||||
|
const upper = normalized.toUpperCase()
|
||||||
|
const statusAllowed = upper === 'CREATED' || upper === 'PENDING' || normalized === '已创建' || normalized === '待入库'
|
||||||
|
if (!statusAllowed) return false
|
||||||
|
if (row.hasReceiving === true) return true
|
||||||
|
if (Array.isArray(row.receivingBindings) && row.receivingBindings.length > 0) return true
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
/** storage.entry.unbindReceiving 失败错误码中文文案 */
|
||||||
|
export function formatUnbindErrorCode(code: unknown): string {
|
||||||
|
if (code === null || code === undefined || code === '') return ''
|
||||||
|
const key = String(code).trim().toUpperCase()
|
||||||
|
const map: Record<string, string> = {
|
||||||
|
BINDING_NOT_FOUND: '未找到绑定关系',
|
||||||
|
ENTRY_ORDER_NOT_FOUND: '入库单不存在',
|
||||||
|
ENTRY_ORDER_STATUS_INVALID: '当前入库单状态不允许解绑',
|
||||||
|
UNBIND_ERROR: '解绑失败',
|
||||||
|
}
|
||||||
|
return map[key] || String(code)
|
||||||
|
}
|
||||||
|
|
||||||
/** 是否允许开始入库(状态为 CREATED 且已绑定收货单) */
|
/** 是否允许开始入库(状态为 CREATED 且已绑定收货单) */
|
||||||
export function canStartReceiving(status: unknown, hasReceiving: unknown, receivingBindings: unknown): boolean {
|
export function canStartReceiving(status: unknown, hasReceiving: unknown, receivingBindings: unknown): boolean {
|
||||||
if (status === null || status === undefined) return false
|
if (status === null || status === undefined) return false
|
||||||
|
|||||||
@ -153,6 +153,15 @@
|
|||||||
>
|
>
|
||||||
绑定
|
绑定
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="canUnbindEntryOrder(row)"
|
||||||
|
link
|
||||||
|
type="danger"
|
||||||
|
size="small"
|
||||||
|
@click.stop="openUnbindDialog(row)"
|
||||||
|
>
|
||||||
|
解绑
|
||||||
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #empty>
|
<template #empty>
|
||||||
@ -208,6 +217,13 @@
|
|||||||
@success="handleBindDialogSuccess"
|
@success="handleBindDialogSuccess"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<UnbindReceivingToEntryDialog
|
||||||
|
v-model="unbindDialogVisible"
|
||||||
|
:row="unbindTargetRow"
|
||||||
|
@closed="handleUnbindDialogClosed"
|
||||||
|
@success="handleUnbindDialogSuccess"
|
||||||
|
/>
|
||||||
|
|
||||||
<!-- 收货绑定详情弹窗 -->
|
<!-- 收货绑定详情弹窗 -->
|
||||||
<ReceivingBindingDetailDialog
|
<ReceivingBindingDetailDialog
|
||||||
v-model:visible="receivingBindingsDialogVisible"
|
v-model:visible="receivingBindingsDialogVisible"
|
||||||
@ -360,6 +376,7 @@ import {
|
|||||||
isPendingEntryOrderStatus,
|
isPendingEntryOrderStatus,
|
||||||
canQuickInbound,
|
canQuickInbound,
|
||||||
canBindEntryOrder,
|
canBindEntryOrder,
|
||||||
|
canUnbindEntryOrder,
|
||||||
canStartReceiving,
|
canStartReceiving,
|
||||||
finalizeEntryListWhere,
|
finalizeEntryListWhere,
|
||||||
formatEntryHasReceiving,
|
formatEntryHasReceiving,
|
||||||
@ -374,6 +391,7 @@ import entrydetail from './component/entrydetail.vue'
|
|||||||
import log from './component/log.vue'
|
import log from './component/log.vue'
|
||||||
import entryoperate from './component/entryoperate.vue'
|
import entryoperate from './component/entryoperate.vue'
|
||||||
import BindReceivingToEntryDialog from './component/BindReceivingToEntryDialog.vue'
|
import BindReceivingToEntryDialog from './component/BindReceivingToEntryDialog.vue'
|
||||||
|
import UnbindReceivingToEntryDialog from './component/UnbindReceivingToEntryDialog.vue'
|
||||||
import ReceivingBindingDetailDialog from './component/ReceivingBindingDetailDialog.vue'
|
import ReceivingBindingDetailDialog from './component/ReceivingBindingDetailDialog.vue'
|
||||||
import DirectInboundLogs from './component/DirectInboundLogs.vue'
|
import DirectInboundLogs from './component/DirectInboundLogs.vue'
|
||||||
import EntryBindingRelations from './component/EntryBindingRelations.vue'
|
import EntryBindingRelations from './component/EntryBindingRelations.vue'
|
||||||
@ -581,6 +599,9 @@ const selectedRow = computed(() => {
|
|||||||
const bindDialogVisible = ref(false)
|
const bindDialogVisible = ref(false)
|
||||||
const bindTargetRow = ref<any>(null)
|
const bindTargetRow = ref<any>(null)
|
||||||
|
|
||||||
|
const unbindDialogVisible = ref(false)
|
||||||
|
const unbindTargetRow = ref<any>(null)
|
||||||
|
|
||||||
// 收货绑定详情弹窗
|
// 收货绑定详情弹窗
|
||||||
const receivingBindingsDialogVisible = ref(false)
|
const receivingBindingsDialogVisible = ref(false)
|
||||||
const receivingBindingsDialogData = ref<any[]>([])
|
const receivingBindingsDialogData = ref<any[]>([])
|
||||||
@ -642,6 +663,23 @@ async function handleBindDialogSuccess() {
|
|||||||
entryDetailRefreshTick.value += 1
|
entryDetailRefreshTick.value += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openUnbindDialog(row: any) {
|
||||||
|
if (!canUnbindEntryOrder(row)) return
|
||||||
|
unbindTargetRow.value = row
|
||||||
|
unbindDialogVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleUnbindDialogClosed() {
|
||||||
|
unbindTargetRow.value = null
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleUnbindDialogSuccess() {
|
||||||
|
unbindDialogVisible.value = false
|
||||||
|
unbindTargetRow.value = null
|
||||||
|
await loadData()
|
||||||
|
entryDetailRefreshTick.value += 1
|
||||||
|
}
|
||||||
|
|
||||||
function translateField(fieldValue: string, value: any) {
|
function translateField(fieldValue: string, value: any) {
|
||||||
return translateEntryField(fieldValue, value)
|
return translateEntryField(fieldValue, value)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -192,7 +192,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, onMounted, computed } from 'vue'
|
import { ref, reactive, onMounted, computed } from 'vue'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { storeWarehouseWarehouseList } from '@/api/storeWarehouse.warehouse/storeWarehouse'
|
import { storeWarehouseWarehouseList } from '@/api/storewarehouse.warehouse/storeWarehouse'
|
||||||
import { storeWarehouseUnbind, storeWarehouseRename, storeWarehouseConfirmSign } from '@/api/storewarehouse.store/storeWarehouse'
|
import { storeWarehouseUnbind, storeWarehouseRename, storeWarehouseConfirmSign } from '@/api/storewarehouse.store/storeWarehouse'
|
||||||
import ScanBox from '@/components/ScanBox/index.vue'
|
import ScanBox from '@/components/ScanBox/index.vue'
|
||||||
import UpperTable from '@/components/UpperTable/index.vue'
|
import UpperTable from '@/components/UpperTable/index.vue'
|
||||||
|
|||||||
@ -237,6 +237,105 @@
|
|||||||
<el-empty v-else description="暂无可编辑字段,请检查接口返回" />
|
<el-empty v-else description="暂无可编辑字段,请检查接口返回" />
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="front-config-section" v-loading="frontPageLoading">
|
||||||
|
<el-divider content-position="left" class="front-config-divider">前端独立部署(品牌配置)</el-divider>
|
||||||
|
<el-alert
|
||||||
|
v-if="frontCertStatus.level === 'danger' || frontCertStatus.level === 'warning'"
|
||||||
|
:type="frontCertStatus.level"
|
||||||
|
:title="frontCertStatus.title"
|
||||||
|
:description="frontCertStatus.desc"
|
||||||
|
show-icon
|
||||||
|
:closable="false"
|
||||||
|
class="mb-16 front-config-alert"
|
||||||
|
/>
|
||||||
|
<el-alert
|
||||||
|
v-if="frontSyncFailed"
|
||||||
|
type="error"
|
||||||
|
title="证书部署同步失败"
|
||||||
|
:description="frontMeta.last_sync_error || '同步失败,请重新上传证书或稍后重试'"
|
||||||
|
show-icon
|
||||||
|
:closable="false"
|
||||||
|
class="mb-16 front-config-alert"
|
||||||
|
/>
|
||||||
|
<el-descriptions v-if="frontMeta.domain" :column="4" border size="small" class="front-config-meta">
|
||||||
|
<el-descriptions-item label="自持域名">{{ frontMeta.domain || '—' }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="证书状态">
|
||||||
|
<el-tag :type="frontCertTagType" size="small" effect="plain">{{ frontCertStatus.text }}</el-tag>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="同步状态">{{ frontSyncStatusText }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="同步详情">{{ frontMeta.last_synced_at || '—' }} · 尝试 {{ frontMeta.sync_attempts ?? 0 }} 次</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
<el-form label-width="140px" label-position="right" class="front-config-form">
|
||||||
|
<el-form-item label="站点标题">
|
||||||
|
<el-input v-model="frontForm.title" maxlength="100" clearable placeholder="站点标题(留空表示清空)" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="Logo 地址">
|
||||||
|
<el-input v-model="frontForm.logo_url" maxlength="255" clearable placeholder="Logo 图片 URL(留空清空)" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="favicon 地址">
|
||||||
|
<el-input v-model="frontForm.favicon_url" maxlength="255" clearable placeholder="favicon 图标 URL(留空清空)" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="登录页背景图">
|
||||||
|
<el-input v-model="frontForm.login_bg_url" maxlength="255" clearable placeholder="登录页背景图 URL(留空清空)" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="主题配置">
|
||||||
|
<div class="front-theme-editor">
|
||||||
|
<div class="front-theme-default">
|
||||||
|
<div class="front-theme-row">
|
||||||
|
<span class="front-theme-row__label">网页名称</span>
|
||||||
|
<el-input v-model="frontThemeDefault.siteName" class="front-theme-row__value" placeholder="如:XX云仓(留空使用系统默认:天豹云仓)" clearable maxlength="100" />
|
||||||
|
</div>
|
||||||
|
<div class="front-theme-row">
|
||||||
|
<span class="front-theme-row__label">主页面 Logo</span>
|
||||||
|
<el-input v-model="frontThemeDefault.mainLogoUrl" class="front-theme-row__value" placeholder="主页面/顶栏 Logo 图片 URL(可留空)" clearable maxlength="255" />
|
||||||
|
</div>
|
||||||
|
<div class="front-theme-row">
|
||||||
|
<span class="front-theme-row__label">登录页 Logo</span>
|
||||||
|
<el-input v-model="frontThemeDefault.loginLogoUrl" class="front-theme-row__value" placeholder="登录页 Logo 图片 URL(留空用品牌 Logo)" clearable maxlength="255" />
|
||||||
|
</div>
|
||||||
|
<div class="front-theme-row">
|
||||||
|
<span class="front-theme-row__label">登录页文字</span>
|
||||||
|
<el-input v-model="frontThemeDefault.loginText" class="front-theme-row__value" placeholder="登录页标语(留空默认:现代化仓储管理系统 - 助力企业高效运营)" clearable maxlength="200" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="front-config-hint front-theme-hint">以上 4 个为约定主题字段,均可留空:留空不写入主题、使用系统默认值。</div>
|
||||||
|
|
||||||
|
<el-divider content-position="left" class="front-config-divider">自定义主题键值(映射 CSS 变量 --<key>)</el-divider>
|
||||||
|
<div v-for="(row, idx) in frontThemeRows" :key="`front-theme-${idx}`" class="front-theme-row">
|
||||||
|
<el-input v-model="row.key" class="front-theme-row__key" placeholder="键(如 primary)" maxlength="60" />
|
||||||
|
<el-input v-model="row.value" class="front-theme-row__value" placeholder="值:文本,或 JSON 对象/数组/数字/布尔" />
|
||||||
|
<el-button type="danger" plain size="small" @click="removeFrontThemeRow(idx)">删除</el-button>
|
||||||
|
</div>
|
||||||
|
<div class="front-theme-actions">
|
||||||
|
<el-button type="primary" plain size="small" @click="addFrontThemeRow">新增自定义键</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" :loading="frontSaving" @click="saveFrontConfig">保存品牌配置</el-button>
|
||||||
|
<el-button :disabled="frontPageLoading" @click="loadFrontConfig">重新加载</el-button>
|
||||||
|
<span class="front-config-hint">品牌字段留空即清空;主题删空全部键后保存即清空主题;保存成功后自动重新加载</span>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-divider content-position="left" class="front-config-divider">前端独立部署(自持域名 & 证书)</el-divider>
|
||||||
|
<el-form label-width="140px" label-position="right" class="front-config-form">
|
||||||
|
<el-form-item label="自持域名">
|
||||||
|
<el-input v-model="frontCert.domain" maxlength="100" clearable placeholder="如 self.example.com(全局唯一)" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="证书 PEM">
|
||||||
|
<el-input v-model="frontCert.pem" type="textarea" :rows="4" placeholder="-----BEGIN CERTIFICATE-----..." />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="私钥 PEM">
|
||||||
|
<el-input v-model="frontCert.key" type="textarea" :rows="4" placeholder="-----BEGIN PRIVATE KEY-----..." />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="warning" :loading="frontCertSaving" @click="submitFrontCert">上传证书</el-button>
|
||||||
|
<span class="front-config-hint">上传成功后自动写入证书到期时间、重置同步状态并重新加载配置</span>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -248,6 +347,9 @@ import {
|
|||||||
settingWarehouseGetSettings,
|
settingWarehouseGetSettings,
|
||||||
settingWarehouseGetFieldMeta,
|
settingWarehouseGetFieldMeta,
|
||||||
settingWarehouseSaveSettings,
|
settingWarehouseSaveSettings,
|
||||||
|
settingWarehouseGetFrontConfig,
|
||||||
|
settingWarehouseSaveFrontConfig,
|
||||||
|
settingWarehouseSaveFrontCert,
|
||||||
unwrapSettingWarehousePayload,
|
unwrapSettingWarehousePayload,
|
||||||
buildSaveSettingsRequest,
|
buildSaveSettingsRequest,
|
||||||
normalizeGetSettingsPayload,
|
normalizeGetSettingsPayload,
|
||||||
@ -620,6 +722,218 @@ const displayFields = computed(() =>
|
|||||||
useMetaForm.value && normalizedFields.value.length ? normalizedFields.value : FALLBACK_FIELDS
|
useMetaForm.value && normalizedFields.value.length ? normalizedFields.value : FALLBACK_FIELDS
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ── 前端独立部署(品牌 & 域名证书):getFrontConfig / saveFrontConfig / saveFrontCert ──
|
||||||
|
const frontPageLoading = ref(false)
|
||||||
|
const frontSaving = ref(false)
|
||||||
|
const frontCertSaving = ref(false)
|
||||||
|
const frontMeta = reactive<Record<string, any>>({})
|
||||||
|
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<Record<string, string>>({
|
||||||
|
siteName: '',
|
||||||
|
mainLogoUrl: '',
|
||||||
|
loginLogoUrl: '',
|
||||||
|
loginText: ''
|
||||||
|
})
|
||||||
|
const frontThemeRows = ref<Array<{ key: string; value: string }>>([])
|
||||||
|
const frontCert = reactive({ domain: '', pem: '', key: '' })
|
||||||
|
|
||||||
|
const frontSyncStatusText = computed(() => {
|
||||||
|
const s = Number(frontMeta.sync_status)
|
||||||
|
if (s === 0) return '待同步'
|
||||||
|
if (s === 1) return '同步成功'
|
||||||
|
if (s === 2) return '同步失败'
|
||||||
|
return frontMeta.sync_status ?? '—'
|
||||||
|
})
|
||||||
|
|
||||||
|
/** 同步是否失败(用于同步失败告警) */
|
||||||
|
const frontSyncFailed = computed(() => Number(frontMeta.sync_status) === 2)
|
||||||
|
|
||||||
|
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())}`
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 证书状态:none=未上传,success=正常,warning=30 天内到期,danger=已过期 */
|
||||||
|
const frontCertStatus = computed<{
|
||||||
|
level: 'success' | 'warning' | 'danger' | 'info' | 'none'
|
||||||
|
text: string
|
||||||
|
title: string
|
||||||
|
desc: string
|
||||||
|
}>(() => {
|
||||||
|
const raw = String(frontMeta.cert_expire_at ?? '').trim()
|
||||||
|
if (!raw) return { level: 'none', text: '未上传', title: '', desc: '' }
|
||||||
|
const ts = Date.parse(raw)
|
||||||
|
if (Number.isNaN(ts)) return { level: 'info', text: raw, title: '', desc: '' }
|
||||||
|
const days = Math.ceil((ts - Date.now()) / 86400000)
|
||||||
|
const when = fmtFrontDate(ts)
|
||||||
|
if (days < 0) {
|
||||||
|
return {
|
||||||
|
level: 'danger',
|
||||||
|
text: `${when} 已过期`,
|
||||||
|
title: 'HTTPS 证书已过期',
|
||||||
|
desc: `证书已于 ${when} 过期(${-days} 天),自持域名将无法正常访问,请重新上传证书。`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (days <= 30) {
|
||||||
|
return {
|
||||||
|
level: 'warning',
|
||||||
|
text: `${when} 到期(剩 ${days} 天)`,
|
||||||
|
title: 'HTTPS 证书即将到期',
|
||||||
|
desc: `证书将于 ${when} 到期,剩余 ${days} 天,请及时更新证书。`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { level: 'success', text: `有效期至 ${when}`, title: '', desc: '' }
|
||||||
|
})
|
||||||
|
|
||||||
|
/** 证书 tag 类型(none/info 一律用 info 灰) */
|
||||||
|
const frontCertTagType = computed<'success' | 'warning' | 'danger' | 'info'>(() => {
|
||||||
|
const level = frontCertStatus.value.level
|
||||||
|
return level === 'success' || level === 'warning' || level === 'danger' ? level : 'info'
|
||||||
|
})
|
||||||
|
|
||||||
|
function stringifyFrontThemeValue(v: unknown): string {
|
||||||
|
if (v === null || v === undefined) return ''
|
||||||
|
if (typeof v === 'string') return v
|
||||||
|
try {
|
||||||
|
return JSON.stringify(v)
|
||||||
|
} catch {
|
||||||
|
return String(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseFrontThemeValue(text: string): unknown {
|
||||||
|
const t = text.trim()
|
||||||
|
if (!t) return ''
|
||||||
|
try {
|
||||||
|
return JSON.parse(t)
|
||||||
|
} catch {
|
||||||
|
return t
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addFrontThemeRow() {
|
||||||
|
frontThemeRows.value.push({ key: '', value: '' })
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeFrontThemeRow(index: number) {
|
||||||
|
frontThemeRows.value.splice(index, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadFrontConfig() {
|
||||||
|
frontPageLoading.value = true
|
||||||
|
try {
|
||||||
|
const res = await settingWarehouseGetFrontConfig()
|
||||||
|
if (!res || !okCode(res.code)) {
|
||||||
|
ElMessage.error(res?.message || '获取前端部署配置失败')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const cfg = unwrapSettingWarehousePayload(res as Record<string, unknown>)
|
||||||
|
Object.keys(frontMeta).forEach((k) => delete frontMeta[k])
|
||||||
|
Object.assign(frontMeta, cfg)
|
||||||
|
frontForm.title = String(cfg.title ?? '')
|
||||||
|
frontForm.logo_url = String(cfg.logo_url ?? '')
|
||||||
|
frontForm.favicon_url = String(cfg.favicon_url ?? '')
|
||||||
|
frontForm.login_bg_url = String(cfg.login_bg_url ?? '')
|
||||||
|
// theme:与 getFrontConfig 响应参数一致,按对象键逐项展开编辑
|
||||||
|
let themeObj: Record<string, unknown> | null = null
|
||||||
|
if (cfg.theme && typeof cfg.theme === 'object' && !Array.isArray(cfg.theme)) {
|
||||||
|
themeObj = cfg.theme as Record<string, unknown>
|
||||||
|
} else if (typeof cfg.theme === 'string' && cfg.theme.trim()) {
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(cfg.theme)
|
||||||
|
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) themeObj = parsed as Record<string, unknown>
|
||||||
|
} catch {
|
||||||
|
// 忽略无法解析的主题字符串
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const src = themeObj
|
||||||
|
// 约定 4 字段单独编辑(允许空),其余键进入自定义 CSS 变量区
|
||||||
|
FRONT_THEME_FIXED_KEYS.forEach((k) => {
|
||||||
|
frontThemeDefault[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)
|
||||||
|
} else if (value !== undefined && value !== null && String(value).trim() !== '') {
|
||||||
|
frontThemeRows.value.push({ key: k, value: stringifyFrontThemeValue(value) })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} catch (e: unknown) {
|
||||||
|
ElMessage.error(e instanceof Error ? e.message : '获取前端部署配置失败')
|
||||||
|
} finally {
|
||||||
|
frontPageLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function saveFrontConfig() {
|
||||||
|
frontSaving.value = true
|
||||||
|
try {
|
||||||
|
const themeObj: Record<string, unknown> = {}
|
||||||
|
// 约定 4 字段允许空:空值不写入主题(前端用默认文案/图片)
|
||||||
|
FRONT_THEME_FIXED_KEYS.forEach((k) => {
|
||||||
|
const val = String(frontThemeDefault[k] ?? '').trim()
|
||||||
|
if (val) themeObj[k] = val
|
||||||
|
})
|
||||||
|
frontThemeRows.value.forEach((row) => {
|
||||||
|
const key = row.key.trim()
|
||||||
|
const valueText = row.value.trim()
|
||||||
|
if (!key || !valueText) return
|
||||||
|
themeObj[key] = parseFrontThemeValue(valueText)
|
||||||
|
})
|
||||||
|
const res = await settingWarehouseSaveFrontConfig({
|
||||||
|
title: frontForm.title.trim(),
|
||||||
|
logo_url: frontForm.logo_url.trim(),
|
||||||
|
favicon_url: frontForm.favicon_url.trim(),
|
||||||
|
login_bg_url: frontForm.login_bg_url.trim(),
|
||||||
|
theme: themeObj
|
||||||
|
})
|
||||||
|
if (!res || !okCode(res.code)) {
|
||||||
|
ElMessage.error(res?.message || '保存品牌配置失败')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ElMessage.success('品牌配置已保存')
|
||||||
|
await loadFrontConfig()
|
||||||
|
} catch (e: unknown) {
|
||||||
|
ElMessage.error(e instanceof Error ? e.message : '保存品牌配置失败')
|
||||||
|
} finally {
|
||||||
|
frontSaving.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitFrontCert() {
|
||||||
|
const domain = frontCert.domain.trim()
|
||||||
|
const pem = frontCert.pem.trim()
|
||||||
|
const key = frontCert.key.trim()
|
||||||
|
if (!domain || !pem || !key) {
|
||||||
|
ElMessage.warning('域名、证书 PEM、私钥 PEM 均必填')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
frontCertSaving.value = true
|
||||||
|
try {
|
||||||
|
const res = await settingWarehouseSaveFrontCert({ domain, pem, key })
|
||||||
|
if (!res || !okCode(res.code)) {
|
||||||
|
ElMessage.error(res?.message || '证书上传失败')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ElMessage.success('证书已上传并生效')
|
||||||
|
frontCert.domain = ''
|
||||||
|
frontCert.pem = ''
|
||||||
|
frontCert.key = ''
|
||||||
|
await loadFrontConfig()
|
||||||
|
} catch (e: unknown) {
|
||||||
|
ElMessage.error(e instanceof Error ? e.message : '证书上传失败')
|
||||||
|
} finally {
|
||||||
|
frontCertSaving.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function loadAll() {
|
async function loadAll() {
|
||||||
loadError.value = ''
|
loadError.value = ''
|
||||||
pageLoading.value = true
|
pageLoading.value = true
|
||||||
@ -673,16 +987,13 @@ async function handleSave() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadAll()
|
loadAll()
|
||||||
|
loadFrontConfig()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.warehouse-settings-form {
|
.warehouse-settings-form {
|
||||||
padding: 12px;
|
padding: 12px 16px 24px;
|
||||||
height: 100%;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
overflow: auto;
|
|
||||||
background: #fff;
|
background: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -876,4 +1187,75 @@ loadAll()
|
|||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.front-config-section {
|
||||||
|
margin-top: 24px;
|
||||||
|
border-top: 1px dashed #e4e7ed;
|
||||||
|
padding-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.front-config-divider {
|
||||||
|
margin: 12px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.front-config-meta {
|
||||||
|
margin-bottom: 12px;
|
||||||
|
max-width: 720px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.front-config-alert {
|
||||||
|
margin: 0 0 12px;
|
||||||
|
max-width: 720px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.front-config-form {
|
||||||
|
max-width: 720px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.front-config-hint {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #909399;
|
||||||
|
margin-left: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.front-theme-editor {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 560px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.front-theme-row {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
|
||||||
|
&__key {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.front-theme-actions {
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.front-theme-hint {
|
||||||
|
margin-left: 0;
|
||||||
|
margin-top: 6px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user