Compare commits
36 Commits
e34416a9b3
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| d7241d54b1 | |||
| 282da24bc4 | |||
| 5e0691ab35 | |||
| 5935024ea8 | |||
| 7304c7a8e1 | |||
| b90a4e9f8f | |||
| a3f17cbf94 | |||
| 6973e3d7f5 | |||
| 114d77ca48 | |||
| a144a35c3d | |||
| 7e12eb3ca6 | |||
| 608e3e5ec5 | |||
| d98b0aefb0 | |||
| 012626f6bd | |||
| 22cd00da42 | |||
| 3004a65b35 | |||
| f9161368e1 | |||
| 8a061f085f | |||
| b20e566a65 | |||
| 7d2e4ef57e | |||
| 4d434c9c67 | |||
| 73fd27bdf6 | |||
| 62e61a9e63 | |||
| cd9696bc1c | |||
| a01217539c | |||
| b5d4f8b27c | |||
| 26334ed072 | |||
| 9a80f0f8d6 | |||
| fc2e5b65de | |||
| e8b585e623 | |||
| ee493823bf | |||
| 5702266276 | |||
| 8b5bb6a981 | |||
| 0a36188b35 | |||
| a8a37fbc4a | |||
| 6cf66c722c |
@@ -1,55 +0,0 @@
|
|||||||
---
|
|
||||||
description: 杜康好客全局约束 — Monorepo 布局、文档优先级、2 人 OWNER 边界
|
|
||||||
alwaysApply: true
|
|
||||||
---
|
|
||||||
|
|
||||||
# 杜康好客 · 核心规则
|
|
||||||
|
|
||||||
## Monorepo 布局
|
|
||||||
|
|
||||||
- `apps/` — preV1:`h5-user`、`h5-shop`、`h5-partner`、`admin-web`
|
|
||||||
- `packages/` — `shared-types`、`domain`、`shared-ui`
|
|
||||||
- `server/dukang-api/` — NestJS 单体 API
|
|
||||||
- `pages/` — UI 原型(**只读参照**)
|
|
||||||
|
|
||||||
> V2 目标为 Taro 四端(`mini-user` 等),编码以 **当前实际目录** 为准。
|
|
||||||
|
|
||||||
## 文档
|
|
||||||
|
|
||||||
- **V3.0 业务事实源**:`杜康好客-v3-PRD.md`
|
|
||||||
- V3 实现验收:`杜康好客-v3编码手册.md`
|
|
||||||
- V2 蓝图:`杜康好客-V2编码手册.md`(与 V3 冲突时 V3 PRD 优先)
|
|
||||||
- preV1 裁剪:`杜康好客-preV1编码手册.md`
|
|
||||||
- 协作:`conventions.md` · AI 入口:`AGENTS.md`
|
|
||||||
|
|
||||||
**禁止**:编码时修改业务规则;需求变更只改 `杜康好客-v3-PRD.md`。
|
|
||||||
|
|
||||||
## 边界(2 人团队)
|
|
||||||
|
|
||||||
> **临时(2026-07)**:刘京尧任务由 `jacy-dukang` 代管,B+D 路径可改。
|
|
||||||
|
|
||||||
| 负责人 | 路径 |
|
|
||||||
|--------|------|
|
|
||||||
| jacy-dukang | `apps/*`, `packages/`, `callbacks/`, `jobs/`, `common/`, `integrations/`, 全部 `modules/*` |
|
|
||||||
| ~~刘京尧~~ | ~~`apps/h5-partner/`, `apps/h5-shop/`, `modules/{store,redeem}/`~~(暂代管) |
|
|
||||||
|
|
||||||
- 跨模块只 inject **exported Service**,禁止 `prisma` 写他人表
|
|
||||||
- `apps/*` 禁止 import `server/*` 或其他 app
|
|
||||||
- Mock 只在 `integrations/*`,不在业务 Service 散落
|
|
||||||
|
|
||||||
## 共享契约
|
|
||||||
|
|
||||||
- 枚举/DTO → `packages/shared-types`
|
|
||||||
- 纯规则 → `packages/domain`(无 IO)
|
|
||||||
|
|
||||||
## 核心业务常量
|
|
||||||
|
|
||||||
- 权益额 = `benefit_amount ?? price`
|
|
||||||
- 核销:直接核销 `0 < amount ≤ 全部 ACTIVE 权益总余额`;带单据核销 `0 < amount ≤ 该单据可用金额`;Redis 码 3 分钟
|
|
||||||
- 订单 Tab(V3.0):`待付款 | 已付款 | 已完成`
|
|
||||||
- API:`/api/v1`,响应 `{ code, message, data }`
|
|
||||||
|
|
||||||
## 提交
|
|
||||||
|
|
||||||
- Conventional Commits:`feat(trade):` 等
|
|
||||||
- 不提交 `.env`
|
|
||||||
@@ -1,33 +1,11 @@
|
|||||||
---
|
---
|
||||||
description: Git 提交与 PR 协作规范
|
description: 杜康提交 scope 与发版默认(生产)
|
||||||
alwaysApply: true
|
alwaysApply: true
|
||||||
---
|
---
|
||||||
|
|
||||||
# Git 规范
|
# Git / 发版(杜康专属)
|
||||||
|
|
||||||
## 提交格式
|
- Conventional Commits,scope = 端或模块:`feat(trade):`、`fix(redeem):`
|
||||||
|
- 只说「发布/发版」→ 生产(`main` + `deploy-prod.sh`);明确说「发测试」才 staging。流程见 `/dukang-release`
|
||||||
Conventional Commits,scope = 端或模块名:
|
- 改 API/表 → 同步 v3-PRD + v3编码手册 + `shared-types`
|
||||||
|
- Prisma 迁移须 Review
|
||||||
```
|
|
||||||
feat(trade): add order preview API
|
|
||||||
fix(redeem): validate redeem amount against balance
|
|
||||||
chore(shared-types): add OrderStatus enum
|
|
||||||
```
|
|
||||||
|
|
||||||
## 禁止提交
|
|
||||||
|
|
||||||
- `.env`、`.env.local` 等敏感配置
|
|
||||||
- `node_modules/`、`dist/`(已在 .gitignore)
|
|
||||||
|
|
||||||
## PR 与 Review
|
|
||||||
|
|
||||||
- feature 分支 + 小步 PR
|
|
||||||
- 跨模块改动需相关双 Owner Review
|
|
||||||
- Prisma 迁移必须多 Owner Review
|
|
||||||
|
|
||||||
## Agent 行为
|
|
||||||
|
|
||||||
- **仅用户明确要求时** 才执行 git commit / push
|
|
||||||
- 不 amend 已推送的 commit,不 force push main/master/dev
|
|
||||||
- 发版:`dev`→测试(staging),`main`→生产;用户只说「发布/发版」默认发**生产**(见 dukang-release skill);明确说「发测试」才发 staging
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ disable-model-invocation: true
|
|||||||
## 会话启动(按序)
|
## 会话启动(按序)
|
||||||
|
|
||||||
1. 确认阶段:**V3.0** → 读 `杜康好客-v3-PRD.md` + `@dukang-v3`;preV1 → preV1 手册;V2 蓝图 → V2 手册
|
1. 确认阶段:**V3.0** → 读 `杜康好客-v3-PRD.md` + `@dukang-v3`;preV1 → preV1 手册;V2 蓝图 → V2 手册
|
||||||
2. 读 [`AGENTS.md`](../../AGENTS.md) OWNER 表 → **只改本 OWNER 路径**
|
2. 读 [`AGENTS.md`](../../AGENTS.md) OWNER 段 + 对应 `apps/` 或 `server/dukang-api/AGENTS.md` → **只改本 OWNER 路径**
|
||||||
3. 有任务卡 ID → 配合 `dukang-task-card` skill 或查 preV1 §9 / V2 §七
|
3. 有任务卡 ID → 配合 `dukang-task-card` skill 或查 preV1 §9 / V2 §七
|
||||||
4. UI 任务 → `pages/ROUTE_MAP.md` + 对应 `pages/{端}/` 原型
|
4. UI 任务 → `pages/ROUTE_MAP.md` + 对应 `pages/{端}/` 原型
|
||||||
5. 编码前过一遍下方 Checklist
|
5. 编码前过一遍下方 Checklist
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ description: >-
|
|||||||
MOCK_SMS/MOCK_PAY/MOCK_DELIVERY flags, Seed data, and V2 upgrade path.
|
MOCK_SMS/MOCK_PAY/MOCK_DELIVERY flags, Seed data, and V2 upgrade path.
|
||||||
Use when working on Mock providers, feature flags, preV1 task cards P1-*,
|
Use when working on Mock providers, feature flags, preV1 task cards P1-*,
|
||||||
or smoke tests — not for V2 WeChat/payment production integration.
|
or smoke tests — not for V2 WeChat/payment production integration.
|
||||||
|
disable-model-invocation: true
|
||||||
---
|
---
|
||||||
|
|
||||||
# 杜康好客 · preV1 Mock Skill
|
# 杜康好客 · preV1 Mock Skill
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ description: >-
|
|||||||
杜康好客发布流程:dev→测试(staging),main→生产;同机双栈。
|
杜康好客发布流程:dev→测试(staging),main→生产;同机双栈。
|
||||||
Use when the user says 发布、上传、deploy、上线、发版、发测试、发生产,
|
Use when the user says 发布、上传、deploy、上线、发版、发测试、发生产,
|
||||||
or @杜康发布 / @dukang-release.
|
or @杜康发布 / @dukang-release.
|
||||||
|
disable-model-invocation: true
|
||||||
---
|
---
|
||||||
|
|
||||||
# 杜康发布
|
# 杜康发布
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ description: >-
|
|||||||
Executes Dukang Haoke task cards (P1-M* or M0-M6) one at a time with DoD
|
Executes Dukang Haoke task cards (P1-M* or M0-M6) one at a time with DoD
|
||||||
verification. Use when the user provides a task ID like P1-M2-002 or M2-FE-U-003,
|
verification. Use when the user provides a task ID like P1-M2-002 or M2-FE-U-003,
|
||||||
or asks to start/implement a milestone card from the coding manuals.
|
or asks to start/implement a milestone card from the coding manuals.
|
||||||
|
disable-model-invocation: true
|
||||||
---
|
---
|
||||||
|
|
||||||
# 杜康好客 · 任务卡 Skill
|
# 杜康好客 · 任务卡 Skill
|
||||||
|
|||||||
@@ -21,4 +21,8 @@ coverage/
|
|||||||
server/dukang-api/prisma/migrations/
|
server/dukang-api/prisma/migrations/
|
||||||
debug_v3.xlsx
|
debug_v3.xlsx
|
||||||
~$debug_v3.xlsx
|
~$debug_v3.xlsx
|
||||||
|
server/dukang-api/assets/fonts/*.ttf
|
||||||
|
server/dukang-api/assets/fonts/*.ttc
|
||||||
|
server/dukang-api/assets/fonts/*.otf
|
||||||
deploy/auto-release.env
|
deploy/auto-release.env
|
||||||
|
deploy/backups/
|
||||||
|
|||||||
@@ -1,133 +1,37 @@
|
|||||||
# 杜康好客 · AGENTS.md
|
# 杜康好客 · AGENTS.md
|
||||||
|
|
||||||
> AI 编码入口。人类协作者仍读 [`agent.md`](./agent.md);本文件供 Cursor / Codex / Copilot 等自动加载。
|
> AI 编码入口。人类读 [`agent.md`](./agent.md)。启动、端口、测试账号见 [`README.md`](./README.md)。
|
||||||
|
|
||||||
## 项目概览
|
杜康酒业 O2O:**购酒 → 发券 → 门店核销**。Monorepo + NestJS 单体(`/api/v1`,`{ code, message, data }`)。
|
||||||
|
|
||||||
杜康酒业 O2O 平台:**购酒 → 发券 → 门店核销**。Monorepo + 单体 NestJS(方案三:模块 OWNER)。
|
| 路径 | 说明 |
|
||||||
|
|------|------|
|
||||||
|
| `apps/` | `h5-user` · `h5-shop` · `h5-partner` · `admin-web` · `mini-user` |
|
||||||
|
| `packages/` | `shared-types`(枚举/DTO)· `domain`(纯规则,无 IO)· `shared-ui` |
|
||||||
|
| `server/dukang-api/` | 唯一 API |
|
||||||
|
| `pages/` | UI 原型,只读 |
|
||||||
|
|
||||||
| 阶段 | 手册 | 说明 |
|
前端:[`apps/AGENTS.md`](./apps/AGENTS.md)。后端模块/表 OWNER:[`server/dukang-api/AGENTS.md`](./server/dukang-api/AGENTS.md)。
|
||||||
|------|------|------|
|
|
||||||
| **V3.0 唯一需求源** | [`杜康好客-v3-PRD.md`](./杜康好客-v3-PRD.md) | 产品需求与三波交付(**只看这个**) |
|
|
||||||
| **现状对照** | [`杜康好客-v3-现状对照.md`](./杜康好客-v3-现状对照.md) | 已完成 / 冲突 / 缺口审计 |
|
|
||||||
| **V3 实现验收** | [`杜康好客-v3编码手册.md`](./杜康好客-v3编码手册.md) | 核销规则、分工、闭环 |
|
|
||||||
| ~~V2 / preV1~~ | 历史参考(**已压缩**;V2 全文见 git 2026-08-06 前) | **不再作为需求依据** |
|
|
||||||
|
|
||||||
**禁止**:臆造 PRD 未定义规则;依赖 `doc/` 下过时文档;跨 OWNER 直写他人 Prisma 表。
|
## 文档(冲突时)
|
||||||
|
|
||||||
## 启动命令
|
1. `杜康好客-v3-PRD.md` — **唯一需求事实源**(编码时禁止改业务规则;需求变更只改它)
|
||||||
|
2. `杜康好客-v3-现状对照.md` — 进度
|
||||||
```bash
|
3. `杜康好客-v3编码手册.md` — 验收、核销、分工
|
||||||
# 基础设施
|
4. `conventions.md` — 协作边界
|
||||||
cd deploy && docker compose up -d # dukang-v1:MySQL :6016 Redis :6017
|
5. V2 手册 §四–§六 — 架构/DB/API **参考**(与 V3 冲突则忽略)
|
||||||
|
|
||||||
# 依赖与数据库
|
|
||||||
pnpm install
|
|
||||||
cp server/dukang-api/.env.example server/dukang-api/.env
|
|
||||||
pnpm db:generate && pnpm db:validate
|
|
||||||
cd server/dukang-api && npx prisma db push && pnpm prisma:seed
|
|
||||||
|
|
||||||
# 开发(分终端)
|
|
||||||
pnpm dev:api # http://localhost:3010/api/v1
|
|
||||||
pnpm dev:user # :5173
|
|
||||||
pnpm dev:shop # :5174
|
|
||||||
pnpm dev:partner # :5175
|
|
||||||
pnpm dev:admin # preV1 HQ 替代(内部工具,非 V2 小程序)
|
|
||||||
|
|
||||||
# 验证
|
|
||||||
node scripts/smoke-v3.mjs
|
|
||||||
node scripts/smoke-prev1.mjs
|
|
||||||
pnpm lint && pnpm test
|
|
||||||
```
|
|
||||||
|
|
||||||
Mock 验证码:`999888`。测试账号见 [`README.md`](./README.md)。
|
|
||||||
|
|
||||||
> **端口冲突**:`h5-partner` 与 `admin-web` 同为 5175,勿同时 `dev:partner` + `dev:admin`。
|
|
||||||
|
|
||||||
## 文档优先级(冲突时)
|
|
||||||
|
|
||||||
1. `杜康好客-v3-PRD.md` — **唯一需求事实源**
|
|
||||||
2. `杜康好客-v3-现状对照.md` — 实现进度审计
|
|
||||||
3. `杜康好客-v3编码手册.md` — 实现验收、核销、分工
|
|
||||||
4. `conventions.md` — 协作与模块边界
|
|
||||||
5. V2 手册 §四 §五 §六 — 仅作架构/DB/API **参考**(与 V3 冲突时忽略)
|
|
||||||
6. `pages/{user,shop,partner,hq}/` — UI 参照
|
6. `pages/{user,shop,partner,hq}/` — UI 参照
|
||||||
|
|
||||||
> **V2 / preV1 手册不再作为需求依据。**
|
**禁止**:臆造 PRD 未定义规则;依赖 `doc/` 过时文档;`apps/*` import `server/*`;跨模块 `prisma` 写他人表。V2 / preV1 手册不再作需求依据。
|
||||||
|
|
||||||
## 团队与 OWNER 边界(2 人)
|
## OWNER(2026-07 起暂由 jacy 代管全部)
|
||||||
|
|
||||||
| 负责人 | Git 账号 | 职责 |
|
`jacy-dukang` 可改 `apps/*`、`packages/*`、全部后端模块。逻辑边界仍按 A/B/C/D,便于子 Agent 隔离。Prisma 迁移由 jacy 主导。
|
||||||
|--------|----------|------|
|
|
||||||
| **Jacy**(管理员) | `jacy-dukang` | C 端、admin-web、后端主模块、packages、Prisma 迁移主 Review |
|
|
||||||
| **刘景尧** | `刘景尧` | 合伙人 H5、门店 H5、`store` / `redeem` 模块(**暂由 jacy-dukang 代管**) |
|
|
||||||
|
|
||||||
> **临时分工(2026-07)**:刘景尧任务暂由 `jacy-dukang` 全权负责;逻辑 OWNER B+D 路径可改,Prisma 迁移由 jacy 主导。
|
- 跨模块只 inject 对方 **exported Service**
|
||||||
|
- Mock 只在 `integrations/*`;微信/配送回调只进 `callbacks/`
|
||||||
|
|
||||||
逻辑模块边界仍按 A/B/C/D 划分(便于 Agent 隔离),**当前人员合并**如下:
|
## 不可偏离
|
||||||
|
|
||||||
| 逻辑 OWNER | 负责人 | 可改路径 | 后端 Module |
|
|
||||||
|------------|--------|----------|-------------|
|
|
||||||
| **A + C + Lead + B + D** | jacy-dukang | `apps/*`, `packages/*`, `callbacks/`, `jobs/`, `common/`, `integrations/` | 全部后端模块 |
|
|
||||||
| ~~B + D~~ | ~~刘景尧~~ | — | 恢复分工前由 jacy 代管 |
|
|
||||||
|
|
||||||
**Prisma 迁移**:jacy-dukang 主导 Review;涉及 `store_*` / 核销表时仍建议刘景尧知会(恢复分工后共同 Review)。
|
|
||||||
|
|
||||||
### 跨模块规则(R1–R8 摘要)
|
|
||||||
|
|
||||||
- 只 inject 对方 Module **exports 的 Service**,禁止 `prisma.xxx` 写他人表
|
|
||||||
- `apps/*` 禁止 import `server/*` 源码;只走 HTTP + `packages/shared-types`
|
|
||||||
- 业务纯规则 → `packages/domain`;枚举/DTO → `packages/shared-types`
|
|
||||||
- 微信/配送回调入口 **仅** `callbacks/`;Mock 实现 **仅** `integrations/*`
|
|
||||||
|
|
||||||
## Cursor 规范
|
|
||||||
|
|
||||||
| 类型 | 路径 | 说明 |
|
|
||||||
|------|------|------|
|
|
||||||
| Rules | `.cursor/rules/` | 自动加载的编码规范 |
|
|
||||||
| 编码 Skill | `.cursor/skills/dukang-coding/` | @dukang-coding |
|
|
||||||
| V3.0 需求 Skill | `.cursor/skills/dukang-v3/` | @dukang-v3(PRD、Wave、REQ/ACC) |
|
|
||||||
| 需求 Skill | `.cursor/skills/dukang-project/` | @dukang-project |
|
|
||||||
| preV1 Skill | `.cursor/skills/dukang-prev1/` | Mock / Feature Flag |
|
|
||||||
| 任务卡 Skill | `.cursor/skills/dukang-task-card/` | DLV-W* / P1-* / M*-* |
|
|
||||||
| 发布 Skill | `.cursor/skills/dukang-release/` | @杜康发布 / @dukang-release |
|
|
||||||
|
|
||||||
## 子 Agent(按职责选用)
|
|
||||||
|
|
||||||
在 Cursor Agent 输入 `/` 选择:
|
|
||||||
|
|
||||||
| 子 Agent | 负责人 | 适用场景 |
|
|
||||||
|----------|--------|----------|
|
|
||||||
| `v3-delivery-lead` | jacy-dukang | V3.0 三波交付统筹、DLV 拆分、跨 Owner 协调 |
|
|
||||||
| `v3-req-reviewer` | — | V3.0 需求只读审查、REQ/ACC 缺口分析 |
|
|
||||||
| `owner-a-user-trade` | jacy-dukang | C 端、订单、支付、权益、埋点 |
|
|
||||||
| `owner-c-catalog-ops` | jacy-dukang | admin-web、开城商品、结算、运营 |
|
|
||||||
| `backend-lead` | jacy-dukang | packages、callbacks、jobs、Prisma 横切 |
|
|
||||||
| `owner-b-partner-store` | 刘景尧 | 合伙人 H5、门店 CRUD/审核 |
|
|
||||||
| `owner-d-shop-redeem` | 刘景尧 | 门店 H5、核销 |
|
|
||||||
| `boundary-reviewer` | — | PR 前只读审查跨模块违规 |
|
|
||||||
|
|
||||||
## Skills(按需 @)
|
|
||||||
|
|
||||||
| Skill | 何时用 |
|
|
||||||
|-------|--------|
|
|
||||||
| `dukang-v3` | V3.0 PRD、现状对照、Wave/REQ/ACC |
|
|
||||||
| `dukang-coding` | 实现功能、修 Bug(通用编码流程) |
|
|
||||||
| `dukang-project` | PRD/需求评审、原型对照、任务卡规划(**不用于日常编码**) |
|
|
||||||
| `dukang-prev1` | Mock 开关、preV1 裁剪、Feature Flag |
|
|
||||||
| `dukang-task-card` | 领取任务卡 `DLV-W*-*` / `P1-*` / `M*-*` 并按 DoD 交付 |
|
|
||||||
| `dukang-release`(杜康发布) | `dev_jacy`→`dev` 合并 + `deploy.sh` 发版 |
|
|
||||||
|
|
||||||
## 快速指令
|
|
||||||
|
|
||||||
- 现状审计:`@dukang-v3` + [`杜康好客-v3-现状对照.md`](./杜康好客-v3-现状对照.md)
|
|
||||||
- 实现 DLV 任务:`@dukang-coding 实现 DLV-W1-M2`
|
|
||||||
- 波次规划:`/v3-delivery-lead 拆分 Wave 2 任务`
|
|
||||||
- 需求缺口审查:`/v3-req-reviewer 审查门店提现`
|
|
||||||
- PR 前审查:`/boundary-reviewer`
|
|
||||||
- 原型参照:`pages/{user,shop,partner}/`(只读)
|
|
||||||
|
|
||||||
## 核心业务常量(不可偏离)
|
|
||||||
|
|
||||||
```
|
```
|
||||||
权益额 = benefit_amount ?? price
|
权益额 = benefit_amount ?? price
|
||||||
@@ -137,38 +41,10 @@ C 端门店仅 status=OPEN
|
|||||||
订单 Tab:待付款 | 已付款 | 已完成
|
订单 Tab:待付款 | 已付款 | 已完成
|
||||||
```
|
```
|
||||||
|
|
||||||
**iOS 微信 H5 JSSDK**:登录/OAuth 后禁止仅 SPA 跳转再调扫码;见 `packages/weixin-sdk/GOTCHAS.md`、知识库「门店端 · 踩坑」。
|
微信:iOS H5 登录后禁止仅 SPA 跳转再扫码(`packages/weixin-sdk/GOTCHAS.md`)。小程序 `open-type` 按钮祖先禁止 `stopPropagation`;weapp 标题只用 `navigationBarTitleText`。`h5-partner` 与 `admin-web` 同端口 5175,勿同时开。
|
||||||
**微信小程序 open-type**:`chooseAvatar` 等 Button 的祖先禁止 `stopPropagation`(会编成 catchtap);见知识库「C 端 · 踩坑」、`.cursor/rules/mini-user-weapp-opentype.mdc`。
|
|
||||||
**微信小程序页面标题**:weapp 只用原生 `navigationBarTitleText`,不要再画一层与导航栏重复的 `SubPageHeader` title;见 `.cursor/rules/mini-user-weapp-nav-title.mdc`。
|
|
||||||
|
|
||||||
## 环境与发版
|
## 按需加载
|
||||||
|
|
||||||
| 环境 | 分支 | 目录 | 端口 | 域名 |
|
- 编码 `/dukang-coding` · V3 需求 `/dukang-v3` · 发版 `/dukang-release`(只说「发版」= 生产)
|
||||||
|------|------|------|------|------|
|
- 子 Agent:`/owner-a-user-trade` 等(见 `.cursor/agents/`)
|
||||||
| local | `dev_jacy` | 本机 Docker 6016/6017 | API `:3010` | — |
|
- DoD:验收项满足;不跨模块直写表;类型在 `shared-types`、规则在 `domain`;相关 lint/单测过
|
||||||
| **staging 测试** | `dev` | `/opt/dukang-staging` | 8190–8194 | `*-test.dukanghaoke.com` |
|
|
||||||
| **production 生产** | `main` | `/opt/dukang` | 8090–8094 | `*.dukanghaoke.com` |
|
|
||||||
|
|
||||||
- 日常发布 → `deploy/deploy-staging.sh`(`dev`)
|
|
||||||
- 生产发布 → `deploy/deploy-prod.sh`(`main`,验收后)
|
|
||||||
- Staging:正式微信 + 全 Mock;配置见 `.env.staging.example`
|
|
||||||
- 详情:`@dukang-release` / `.cursor/skills/dukang-release/SKILL.md`
|
|
||||||
|
|
||||||
## 提交与 PR
|
|
||||||
|
|
||||||
- Conventional Commits:`feat(trade):`、`fix(redeem):`;scope = 端或模块
|
|
||||||
- 跨模块 PR → jacy-dukang + 刘景尧 共同 Review(若涉及双方模块)
|
|
||||||
- 改 API/表 → 同步 v3-PRD + v3编码手册 + `shared-types`
|
|
||||||
- 不提交 `.env`、`dist/`、`node_modules/`
|
|
||||||
|
|
||||||
## 完成定义(DoD)
|
|
||||||
|
|
||||||
- [ ] 任务卡验收项全部满足
|
|
||||||
- [ ] 未跨模块直写 Prisma 表
|
|
||||||
- [ ] 枚举/DTO 在 `shared-types`;纯规则在 `domain`
|
|
||||||
- [ ] `pnpm lint` 无新增错误;相关 domain 单测通过
|
|
||||||
|
|
||||||
## 嵌套指引
|
|
||||||
|
|
||||||
- 后端细节:[`server/dukang-api/AGENTS.md`](./server/dukang-api/AGENTS.md)
|
|
||||||
- 前端四 App:[`apps/AGENTS.md`](./apps/AGENTS.md)
|
|
||||||
|
|||||||
@@ -16,37 +16,37 @@ body,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 后台内容行:不换行 + 超出省略
|
* 后台表格:不换行、完整展示(v3.5.9 去掉省略号)
|
||||||
* 覆盖主内容区、Drawer、Modal 内的表格与描述列表
|
* 描述列表仍省略,避免详情抽屉被长字段撑破
|
||||||
*/
|
*/
|
||||||
.admin-layout .ant-table-cell,
|
.admin-layout .ant-table-cell,
|
||||||
.ant-drawer .ant-table-cell,
|
.ant-drawer .ant-table-cell,
|
||||||
.ant-modal .ant-table-cell,
|
.ant-modal .ant-table-cell {
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: visible;
|
||||||
|
text-overflow: clip;
|
||||||
|
max-width: none;
|
||||||
|
}
|
||||||
|
|
||||||
.admin-layout .ant-descriptions-item-content,
|
.admin-layout .ant-descriptions-item-content,
|
||||||
.ant-drawer .ant-descriptions-item-content,
|
.ant-drawer .ant-descriptions-item-content,
|
||||||
.ant-modal .ant-descriptions-item-content {
|
.ant-modal .ant-descriptions-item-content {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
max-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-layout .ant-descriptions-item-content,
|
|
||||||
.ant-drawer .ant-descriptions-item-content,
|
|
||||||
.ant-modal .ant-descriptions-item-content {
|
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 表头同样不换行 */
|
/* 表头不换行 */
|
||||||
.admin-layout .ant-table-thead > tr > th,
|
.admin-layout .ant-table-thead > tr > th,
|
||||||
.ant-drawer .ant-table-thead > tr > th,
|
.ant-drawer .ant-table-thead > tr > th,
|
||||||
.ant-modal .ant-table-thead > tr > th {
|
.ant-modal .ant-table-thead > tr > th {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: visible;
|
||||||
text-overflow: ellipsis;
|
text-overflow: clip;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 操作列、含交互控件的不截断 */
|
/* 操作列保持可见 */
|
||||||
.admin-layout .ant-table-cell:has(.ant-btn),
|
.admin-layout .ant-table-cell:has(.ant-btn),
|
||||||
.ant-drawer .ant-table-cell:has(.ant-btn),
|
.ant-drawer .ant-table-cell:has(.ant-btn),
|
||||||
.ant-modal .ant-table-cell:has(.ant-btn),
|
.ant-modal .ant-table-cell:has(.ant-btn),
|
||||||
@@ -71,10 +71,9 @@ body,
|
|||||||
max-width: none;
|
max-width: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 表格单元格双行信息合并为单行省略 */
|
/* 表格单元格主/副信息同一行 */
|
||||||
.admin-cell-line {
|
.admin-cell-line {
|
||||||
display: block;
|
display: inline;
|
||||||
max-width: 100%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-cell-line-secondary {
|
.admin-cell-line-secondary {
|
||||||
@@ -291,26 +290,21 @@ body:has(.big-screen-page),
|
|||||||
z-index: 1;
|
z-index: 1;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
padding: 0 8px;
|
padding: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.big-screen-list-head,
|
.big-screen-list-head,
|
||||||
.big-screen-row {
|
.big-screen-row {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 208px 1fr 160px 200px;
|
grid-template-columns: minmax(180px, 18%) minmax(0, 1fr) minmax(140px, 16%) minmax(160px, 18%);
|
||||||
align-items: center;
|
align-items: center;
|
||||||
column-gap: 16px;
|
column-gap: 16px;
|
||||||
}
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
.big-screen-list-head {
|
|
||||||
flex: 0 0 auto;
|
|
||||||
padding: 0 28px 10px 40px;
|
|
||||||
font-size: 15px;
|
|
||||||
color: rgba(170, 200, 230, 0.55);
|
|
||||||
letter-spacing: 2px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.big-screen-list-body {
|
.big-screen-list-body {
|
||||||
@@ -457,10 +451,20 @@ body:has(.big-screen-page),
|
|||||||
}
|
}
|
||||||
|
|
||||||
.big-screen-empty {
|
.big-screen-empty {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
/* 全屏高度黄金分割点(≈0.382),略偏上 */
|
||||||
|
top: 38.2%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
z-index: 2;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: rgba(255, 255, 255, 0.45);
|
color: rgba(145, 190, 230, 0.42);
|
||||||
padding: 48px 20px;
|
padding: 0 40px;
|
||||||
font-size: 18px;
|
font-size: 60px;
|
||||||
|
letter-spacing: 6px;
|
||||||
|
font-weight: 400;
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.big-screen-fx {
|
.big-screen-fx {
|
||||||
@@ -713,9 +717,8 @@ body:has(.big-screen-page),
|
|||||||
.big-screen-clock {
|
.big-screen-clock {
|
||||||
font-size: 56px;
|
font-size: 56px;
|
||||||
}
|
}
|
||||||
.big-screen-list-head,
|
|
||||||
.big-screen-row {
|
.big-screen-row {
|
||||||
grid-template-columns: 172px 1fr 120px 160px;
|
grid-template-columns: minmax(140px, 20%) minmax(0, 1fr) minmax(110px, 16%) minmax(130px, 18%);
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
.big-screen-amount--6d {
|
.big-screen-amount--6d {
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,12 +1,10 @@
|
|||||||
import { Typography } from 'antd';
|
|
||||||
|
|
||||||
type AdminCellLineProps = {
|
type AdminCellLineProps = {
|
||||||
primary?: string | null;
|
primary?: string | null;
|
||||||
secondary?: string | null;
|
secondary?: string | null;
|
||||||
separator?: string;
|
separator?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 表格单元格:主/副信息同一行展示,超出省略,hover 显示全文 */
|
/** 表格单元格:主/副信息同一行完整展示 */
|
||||||
export function AdminCellLine({
|
export function AdminCellLine({
|
||||||
primary,
|
primary,
|
||||||
secondary,
|
secondary,
|
||||||
@@ -14,14 +12,9 @@ export function AdminCellLine({
|
|||||||
}: AdminCellLineProps) {
|
}: AdminCellLineProps) {
|
||||||
const main = primary?.trim() || '—';
|
const main = primary?.trim() || '—';
|
||||||
const sub = secondary?.trim();
|
const sub = secondary?.trim();
|
||||||
const full = sub ? `${main}${separator}${sub}` : main;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Typography.Text
|
<span className="admin-cell-line">
|
||||||
className="admin-cell-line"
|
|
||||||
ellipsis={{ tooltip: full }}
|
|
||||||
style={{ maxWidth: '100%' }}
|
|
||||||
>
|
|
||||||
{main}
|
{main}
|
||||||
{sub ? (
|
{sub ? (
|
||||||
<span className="admin-cell-line-secondary">
|
<span className="admin-cell-line-secondary">
|
||||||
@@ -29,6 +22,6 @@ export function AdminCellLine({
|
|||||||
{sub}
|
{sub}
|
||||||
</span>
|
</span>
|
||||||
) : null}
|
) : null}
|
||||||
</Typography.Text>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,102 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { Button, Checkbox, Modal, Space, Typography } from 'antd';
|
||||||
|
import { HolderOutlined } from '@ant-design/icons';
|
||||||
|
import type { ListColumnSettingItem } from '../lib/list-column-prefs';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
open: boolean;
|
||||||
|
items: ListColumnSettingItem[];
|
||||||
|
saving?: boolean;
|
||||||
|
onCancel: () => void;
|
||||||
|
onReset: () => void;
|
||||||
|
onSave: (items: ListColumnSettingItem[]) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function AdminListColumnsModal({ open, items, saving, onCancel, onReset, onSave }: Props) {
|
||||||
|
const [draft, setDraft] = useState<ListColumnSettingItem[]>(items);
|
||||||
|
const [dragKey, setDragKey] = useState<string | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (open) setDraft(items);
|
||||||
|
}, [open, items]);
|
||||||
|
|
||||||
|
function move(from: number, to: number) {
|
||||||
|
if (to < 0 || to >= draft.length) return;
|
||||||
|
const next = [...draft];
|
||||||
|
const [row] = next.splice(from, 1);
|
||||||
|
next.splice(to, 0, row);
|
||||||
|
setDraft(next);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
title="列设置"
|
||||||
|
open={open}
|
||||||
|
onCancel={onCancel}
|
||||||
|
footer={
|
||||||
|
<Space style={{ width: '100%', justifyContent: 'space-between' }}>
|
||||||
|
<Button onClick={onReset}>重置默认</Button>
|
||||||
|
<Space>
|
||||||
|
<Button onClick={onCancel}>取消</Button>
|
||||||
|
<Button type="primary" loading={saving} onClick={() => onSave(draft)}>
|
||||||
|
保存
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
</Space>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Typography.Paragraph type="secondary" style={{ marginTop: 0 }}>
|
||||||
|
勾选显示列,拖拽或上下箭头调整顺序。序号与操作列固定,不在此列表中。
|
||||||
|
</Typography.Paragraph>
|
||||||
|
<div>
|
||||||
|
{draft.map((item, index) => (
|
||||||
|
<div
|
||||||
|
key={item.key}
|
||||||
|
draggable
|
||||||
|
onDragStart={() => setDragKey(item.key)}
|
||||||
|
onDragOver={(e) => e.preventDefault()}
|
||||||
|
onDrop={() => {
|
||||||
|
if (!dragKey || dragKey === item.key) return;
|
||||||
|
const from = draft.findIndex((r) => r.key === dragKey);
|
||||||
|
if (from >= 0) move(from, index);
|
||||||
|
setDragKey(null);
|
||||||
|
}}
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: 8,
|
||||||
|
padding: '6px 0',
|
||||||
|
borderBottom: '1px solid #f0f0f0',
|
||||||
|
cursor: 'move',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<HolderOutlined style={{ color: '#999' }} />
|
||||||
|
<Checkbox
|
||||||
|
checked={item.visible}
|
||||||
|
onChange={(e) => {
|
||||||
|
const next = [...draft];
|
||||||
|
next[index] = { ...item, visible: e.target.checked };
|
||||||
|
setDraft(next);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{item.title}
|
||||||
|
</Checkbox>
|
||||||
|
<span style={{ marginLeft: 'auto' }}>
|
||||||
|
<Button type="link" size="small" disabled={index === 0} onClick={() => move(index, index - 1)}>
|
||||||
|
上移
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="link"
|
||||||
|
size="small"
|
||||||
|
disabled={index === draft.length - 1}
|
||||||
|
onClick={() => move(index, index + 1)}
|
||||||
|
>
|
||||||
|
下移
|
||||||
|
</Button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -215,11 +215,10 @@ export default function CityPartnersPanel({
|
|||||||
title: '区县',
|
title: '区县',
|
||||||
dataIndex: 'districtCodes',
|
dataIndex: 'districtCodes',
|
||||||
width: 160,
|
width: 160,
|
||||||
ellipsis: true,
|
|
||||||
|
|
||||||
render: (codes: string[] | null | undefined, row) =>
|
render: (codes: string[] | null | undefined, row) =>
|
||||||
row.scopeType === CityPartnerScopeType.CITY_WIDE ? '全城' : formatDistrictLabels(codes),
|
row.scopeType === CityPartnerScopeType.CITY_WIDE ? '全城' : formatDistrictLabels(codes),
|
||||||
{ title: '公司名', dataIndex: 'companyName', ellipsis: true },
|
},
|
||||||
{ title: '公司名', dataIndex: 'companyName' },
|
{ title: '公司名', dataIndex: 'companyName' },
|
||||||
{ title: '主账号', dataIndex: 'phone', width: 120 },
|
{ title: '主账号', dataIndex: 'phone', width: 120 },
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ export default function PartnerSubAccountList({ subs, onAdd, onEdit, onDelete }:
|
|||||||
{
|
{
|
||||||
title: '权限',
|
title: '权限',
|
||||||
dataIndex: 'permissions',
|
dataIndex: 'permissions',
|
||||||
ellipsis: true,
|
|
||||||
|
|
||||||
render: (p: string[] | undefined) => formatPermissions(p),
|
render: (p: string[] | undefined) => formatPermissions(p),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,616 @@
|
|||||||
|
import { useMemo, useState } from 'react';
|
||||||
|
import {
|
||||||
|
Button, Image, Input, InputNumber, Modal, Radio, Select, Space, Switch, Table, Typography, message,
|
||||||
|
} from 'antd';
|
||||||
|
import { EditOutlined, MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
|
||||||
|
import { request } from '../lib/api';
|
||||||
|
import { PRODUCT_STATUS_LABELS } from '../lib/constants';
|
||||||
|
import OssUpload from './OssUpload';
|
||||||
|
|
||||||
|
type SpecValue = { id?: string; name: string; sortOrder?: number };
|
||||||
|
type SpecAttr = { id?: string; name: string; sortOrder?: number; values: SpecValue[] };
|
||||||
|
type SkuRow = {
|
||||||
|
id?: string;
|
||||||
|
specValueIds: string[];
|
||||||
|
skuCode?: string;
|
||||||
|
barcode69: string;
|
||||||
|
price: number;
|
||||||
|
benefitAmount?: number;
|
||||||
|
status: string;
|
||||||
|
allowOnlinePurchase: boolean;
|
||||||
|
allowCrossCityDelivery: boolean;
|
||||||
|
allowOnSitePickup: boolean;
|
||||||
|
saleUnit: 'BOTTLE' | 'BOX';
|
||||||
|
bottlesPerUnit: number;
|
||||||
|
isDefault: boolean;
|
||||||
|
sortOrder?: number;
|
||||||
|
specText?: string;
|
||||||
|
imageUrl?: string | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
function cartesian(attrs: SpecAttr[]): string[][] {
|
||||||
|
if (!attrs.length) return [[]];
|
||||||
|
return attrs.reduce<string[][]>(
|
||||||
|
(acc, attr) => {
|
||||||
|
const next: string[][] = [];
|
||||||
|
const values = attr.values.filter((v) => v.name?.trim());
|
||||||
|
for (const prev of acc) {
|
||||||
|
for (const v of values) {
|
||||||
|
const vid = v.id || `__new__:${attr.name}:${v.name}`;
|
||||||
|
next.push([...prev, vid]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return next.length ? next : acc;
|
||||||
|
},
|
||||||
|
[[]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function keyOf(ids: string[]) {
|
||||||
|
return [...ids].sort().join('_');
|
||||||
|
}
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
productId: string;
|
||||||
|
initialAttrs: SpecAttr[];
|
||||||
|
initialSkus: SkuRow[];
|
||||||
|
onSaved: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function ProductSpecsEditor({ productId, initialAttrs, initialSkus, onSaved }: Props) {
|
||||||
|
const [attrs, setAttrs] = useState<SpecAttr[]>(
|
||||||
|
initialAttrs.length
|
||||||
|
? initialAttrs
|
||||||
|
: [],
|
||||||
|
);
|
||||||
|
const [skus, setSkus] = useState<SkuRow[]>(
|
||||||
|
initialSkus.length
|
||||||
|
? initialSkus.map((s) => ({
|
||||||
|
...s,
|
||||||
|
specValueIds: s.specValueIds ?? [],
|
||||||
|
status: s.status || 'ON_SALE',
|
||||||
|
allowOnlinePurchase: s.allowOnlinePurchase !== false,
|
||||||
|
allowCrossCityDelivery: s.allowCrossCityDelivery !== false,
|
||||||
|
allowOnSitePickup: !!s.allowOnSitePickup,
|
||||||
|
saleUnit: s.saleUnit === 'BOX' ? 'BOX' : 'BOTTLE',
|
||||||
|
bottlesPerUnit: s.bottlesPerUnit || (s.saleUnit === 'BOX' ? 6 : 1),
|
||||||
|
isDefault: !!s.isDefault,
|
||||||
|
imageUrl: s.imageUrl ?? '',
|
||||||
|
}))
|
||||||
|
: [
|
||||||
|
{
|
||||||
|
specValueIds: [],
|
||||||
|
barcode69: '',
|
||||||
|
price: 0,
|
||||||
|
status: 'ON_SALE',
|
||||||
|
allowOnlinePurchase: true,
|
||||||
|
allowCrossCityDelivery: true,
|
||||||
|
allowOnSitePickup: false,
|
||||||
|
saleUnit: 'BOTTLE',
|
||||||
|
bottlesPerUnit: 1,
|
||||||
|
isDefault: true,
|
||||||
|
imageUrl: '',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
);
|
||||||
|
const [saving, setSaving] = useState(false);
|
||||||
|
const [editIndex, setEditIndex] = useState<number | null>(null);
|
||||||
|
|
||||||
|
const combos = useMemo(() => cartesian(attrs.filter((a) => a.name.trim() && a.values.some((v) => v.name.trim()))), [attrs]);
|
||||||
|
|
||||||
|
function regenerateMatrix() {
|
||||||
|
const byKey = new Map(skus.map((s) => [keyOf(s.specValueIds ?? []), s]));
|
||||||
|
const next: SkuRow[] = combos.map((ids, i) => {
|
||||||
|
const existing = byKey.get(keyOf(ids));
|
||||||
|
if (existing) return { ...existing, specValueIds: ids, sortOrder: i };
|
||||||
|
return {
|
||||||
|
specValueIds: ids,
|
||||||
|
barcode69: '',
|
||||||
|
price: skus[0]?.price ?? 0,
|
||||||
|
benefitAmount: skus[0]?.benefitAmount,
|
||||||
|
status: 'DRAFT',
|
||||||
|
allowOnlinePurchase: true,
|
||||||
|
allowCrossCityDelivery: true,
|
||||||
|
allowOnSitePickup: false,
|
||||||
|
saleUnit: 'BOTTLE',
|
||||||
|
bottlesPerUnit: 1,
|
||||||
|
isDefault: i === 0,
|
||||||
|
sortOrder: i,
|
||||||
|
imageUrl: '',
|
||||||
|
};
|
||||||
|
});
|
||||||
|
if (next.length && !next.some((s) => s.isDefault)) next[0].isDefault = true;
|
||||||
|
setSkus(next.length ? next : skus);
|
||||||
|
}
|
||||||
|
|
||||||
|
function patchSku(index: number, patch: Partial<SkuRow>) {
|
||||||
|
setSkus((prev) => {
|
||||||
|
const next = [...prev];
|
||||||
|
next[index] = { ...next[index], ...patch };
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSave() {
|
||||||
|
setSaving(true);
|
||||||
|
try {
|
||||||
|
// 1) 保存规格轴(新建值尚无 id,先提交 attrs)
|
||||||
|
const specsRes = await request<{
|
||||||
|
specAttrs: SpecAttr[];
|
||||||
|
skus: SkuRow[];
|
||||||
|
}>(`/admin/products/${productId}/specs`, {
|
||||||
|
method: 'PUT',
|
||||||
|
body: JSON.stringify({
|
||||||
|
attrs: attrs.map((a, i) => ({
|
||||||
|
id: a.id,
|
||||||
|
name: a.name.trim(),
|
||||||
|
sortOrder: i,
|
||||||
|
values: a.values
|
||||||
|
.filter((v) => v.name.trim())
|
||||||
|
.map((v, j) => ({ id: v.id, name: v.name.trim(), sortOrder: j })),
|
||||||
|
})),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
// 映射临时 id → 真实 id
|
||||||
|
const nameToId = new Map<string, string>();
|
||||||
|
for (const a of specsRes.specAttrs ?? []) {
|
||||||
|
for (const v of a.values ?? []) {
|
||||||
|
nameToId.set(`${a.name}:${v.name}`, v.id!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const resolveIds = (ids: string[]) =>
|
||||||
|
ids.map((id) => {
|
||||||
|
if (!id.startsWith('__new__:')) return id;
|
||||||
|
const [, attrName, valueName] = id.split(':');
|
||||||
|
const real = nameToId.get(`${attrName}:${valueName}`);
|
||||||
|
if (!real) throw new Error(`规格值未创建:${attrName}/${valueName}`);
|
||||||
|
return real;
|
||||||
|
});
|
||||||
|
|
||||||
|
const payloadSkus = skus.map((s, i) => ({
|
||||||
|
id: s.id,
|
||||||
|
specValueIds: resolveIds(s.specValueIds ?? []),
|
||||||
|
barcode69: s.barcode69.trim(),
|
||||||
|
price: s.price,
|
||||||
|
benefitAmount: s.benefitAmount,
|
||||||
|
status: s.status,
|
||||||
|
allowOnlinePurchase: s.allowOnlinePurchase,
|
||||||
|
allowCrossCityDelivery: s.allowCrossCityDelivery,
|
||||||
|
allowOnSitePickup: s.allowOnSitePickup,
|
||||||
|
saleUnit: s.saleUnit,
|
||||||
|
bottlesPerUnit: s.saleUnit === 'BOX' ? s.bottlesPerUnit || 6 : 1,
|
||||||
|
isDefault: !!s.isDefault,
|
||||||
|
sortOrder: i,
|
||||||
|
imageUrl: s.imageUrl?.trim() || null,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const barcodes = payloadSkus.map((row) => row.barcode69);
|
||||||
|
if (barcodes.some((b) => !b)) throw new Error('每个规格须填写独立 69 码');
|
||||||
|
if (new Set(barcodes).size !== barcodes.length) {
|
||||||
|
throw new Error('同一商品内 69 码不可重复,每个规格请填写不同 69 码');
|
||||||
|
}
|
||||||
|
|
||||||
|
await request(`/admin/products/${productId}/skus`, {
|
||||||
|
method: 'PUT',
|
||||||
|
body: JSON.stringify({ skus: payloadSkus }),
|
||||||
|
});
|
||||||
|
message.success('规格与 SKU 已保存');
|
||||||
|
onSaved();
|
||||||
|
} catch (e) {
|
||||||
|
message.error(e instanceof Error ? e.message : '保存失败');
|
||||||
|
} finally {
|
||||||
|
setSaving(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const editing = editIndex != null ? skus[editIndex] : null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Typography.Paragraph type="secondary">
|
||||||
|
SKU 码由系统自动生成(DK 开头),无需填写。每个规格必须填写<strong>互不相同</strong>的 69 码,并可单独上传主图。
|
||||||
|
点「填写」在弹窗中编辑。先配置销售规格轴(如「包装」),再生成 SKU 矩阵。
|
||||||
|
</Typography.Paragraph>
|
||||||
|
|
||||||
|
<Typography.Title level={5}>规格轴</Typography.Title>
|
||||||
|
{attrs.map((attr, ai) => (
|
||||||
|
<div key={ai} style={{ marginBottom: 12, padding: 12, border: '1px solid #f0f0f0', borderRadius: 8 }}>
|
||||||
|
<Space align="start" style={{ width: '100%' }} wrap>
|
||||||
|
<Input
|
||||||
|
style={{ width: 140 }}
|
||||||
|
placeholder="规格名"
|
||||||
|
value={attr.name}
|
||||||
|
onChange={(e) => {
|
||||||
|
const next = [...attrs];
|
||||||
|
next[ai] = { ...attr, name: e.target.value };
|
||||||
|
setAttrs(next);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
type="text"
|
||||||
|
danger
|
||||||
|
icon={<MinusCircleOutlined />}
|
||||||
|
onClick={() => setAttrs(attrs.filter((_, i) => i !== ai))}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
<div style={{ marginTop: 8 }}>
|
||||||
|
{attr.values.map((val, vi) => (
|
||||||
|
<Space key={vi} style={{ display: 'flex', marginBottom: 6 }}>
|
||||||
|
<Input
|
||||||
|
placeholder="规格值"
|
||||||
|
value={val.name}
|
||||||
|
onChange={(e) => {
|
||||||
|
const next = [...attrs];
|
||||||
|
const values = [...attr.values];
|
||||||
|
values[vi] = { ...val, name: e.target.value };
|
||||||
|
next[ai] = { ...attr, values };
|
||||||
|
setAttrs(next);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
type="text"
|
||||||
|
danger
|
||||||
|
icon={<MinusCircleOutlined />}
|
||||||
|
onClick={() => {
|
||||||
|
const next = [...attrs];
|
||||||
|
next[ai] = { ...attr, values: attr.values.filter((_, j) => j !== vi) };
|
||||||
|
setAttrs(next);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
))}
|
||||||
|
<Button
|
||||||
|
type="dashed"
|
||||||
|
size="small"
|
||||||
|
icon={<PlusOutlined />}
|
||||||
|
onClick={() => {
|
||||||
|
const next = [...attrs];
|
||||||
|
next[ai] = { ...attr, values: [...attr.values, { name: '' }] };
|
||||||
|
setAttrs(next);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
添加规格值
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
<Space style={{ marginBottom: 16 }}>
|
||||||
|
<Button
|
||||||
|
icon={<PlusOutlined />}
|
||||||
|
disabled={attrs.length >= 3}
|
||||||
|
onClick={() => setAttrs([...attrs, { name: '', values: [{ name: '' }] }])}
|
||||||
|
>
|
||||||
|
添加规格轴
|
||||||
|
</Button>
|
||||||
|
<Button onClick={regenerateMatrix}>按规格生成 SKU 矩阵</Button>
|
||||||
|
</Space>
|
||||||
|
|
||||||
|
<Typography.Title level={5}>SKU 列表</Typography.Title>
|
||||||
|
<Table
|
||||||
|
size="small"
|
||||||
|
rowKey={(_, i) => String(i)}
|
||||||
|
pagination={false}
|
||||||
|
scroll={{ x: 1240 }}
|
||||||
|
dataSource={skus}
|
||||||
|
columns={[
|
||||||
|
{
|
||||||
|
title: '规格',
|
||||||
|
width: 140,
|
||||||
|
render: (_, row) => row.specText || (row.specValueIds?.length ? row.specValueIds.join(',') : '默认'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'SKU',
|
||||||
|
width: 110,
|
||||||
|
render: (_, row) => (
|
||||||
|
<Typography.Text type="secondary">
|
||||||
|
{row.skuCode || '保存后自动生成'}
|
||||||
|
</Typography.Text>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: <span>69码 <Typography.Text type="danger">*</Typography.Text></span>,
|
||||||
|
width: 180,
|
||||||
|
render: (_, row, index) => (
|
||||||
|
<Input
|
||||||
|
placeholder="本规格独立 69 码"
|
||||||
|
value={row.barcode69}
|
||||||
|
onChange={(e) => {
|
||||||
|
const next = [...skus];
|
||||||
|
next[index] = { ...row, barcode69: e.target.value };
|
||||||
|
setSkus(next);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '售价',
|
||||||
|
width: 100,
|
||||||
|
render: (_, row, index) => (
|
||||||
|
<InputNumber
|
||||||
|
min={0}
|
||||||
|
style={{ width: '100%' }}
|
||||||
|
value={row.price}
|
||||||
|
onChange={(v) => {
|
||||||
|
const next = [...skus];
|
||||||
|
next[index] = { ...row, price: Number(v) || 0 };
|
||||||
|
setSkus(next);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '权益',
|
||||||
|
width: 100,
|
||||||
|
render: (_, row, index) => (
|
||||||
|
<InputNumber
|
||||||
|
min={0}
|
||||||
|
style={{ width: '100%' }}
|
||||||
|
value={row.benefitAmount}
|
||||||
|
onChange={(v) => {
|
||||||
|
const next = [...skus];
|
||||||
|
next[index] = { ...row, benefitAmount: v == null ? undefined : Number(v) };
|
||||||
|
setSkus(next);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '状态',
|
||||||
|
width: 110,
|
||||||
|
render: (_, row, index) => (
|
||||||
|
<Select
|
||||||
|
style={{ width: '100%' }}
|
||||||
|
value={row.status}
|
||||||
|
options={Object.entries(PRODUCT_STATUS_LABELS).map(([value, label]) => ({ value, label }))}
|
||||||
|
onChange={(status) => {
|
||||||
|
const next = [...skus];
|
||||||
|
next[index] = { ...row, status };
|
||||||
|
setSkus(next);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '单位',
|
||||||
|
width: 160,
|
||||||
|
render: (_, row, index) => (
|
||||||
|
<Space>
|
||||||
|
<Select
|
||||||
|
style={{ width: 80 }}
|
||||||
|
value={row.saleUnit}
|
||||||
|
options={[
|
||||||
|
{ value: 'BOTTLE', label: '瓶' },
|
||||||
|
{ value: 'BOX', label: '箱' },
|
||||||
|
]}
|
||||||
|
onChange={(saleUnit) => {
|
||||||
|
const next = [...skus];
|
||||||
|
next[index] = {
|
||||||
|
...row,
|
||||||
|
saleUnit,
|
||||||
|
bottlesPerUnit: saleUnit === 'BOX' ? row.bottlesPerUnit || 6 : 1,
|
||||||
|
};
|
||||||
|
setSkus(next);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{row.saleUnit === 'BOX' ? (
|
||||||
|
<InputNumber
|
||||||
|
min={1}
|
||||||
|
style={{ width: 70 }}
|
||||||
|
value={row.bottlesPerUnit}
|
||||||
|
onChange={(v) => {
|
||||||
|
const next = [...skus];
|
||||||
|
next[index] = { ...row, bottlesPerUnit: Number(v) || 6 };
|
||||||
|
setSkus(next);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '履约',
|
||||||
|
width: 200,
|
||||||
|
render: (_, row, index) => (
|
||||||
|
<Space direction="vertical" size={0}>
|
||||||
|
<Switch
|
||||||
|
checkedChildren="线上"
|
||||||
|
unCheckedChildren="线上"
|
||||||
|
checked={row.allowOnlinePurchase}
|
||||||
|
onChange={(checked) => {
|
||||||
|
const next = [...skus];
|
||||||
|
next[index] = {
|
||||||
|
...row,
|
||||||
|
allowOnlinePurchase: checked,
|
||||||
|
allowCrossCityDelivery: checked ? row.allowCrossCityDelivery : false,
|
||||||
|
};
|
||||||
|
setSkus(next);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Switch
|
||||||
|
checkedChildren="跨城"
|
||||||
|
unCheckedChildren="跨城"
|
||||||
|
disabled={!row.allowOnlinePurchase}
|
||||||
|
checked={row.allowCrossCityDelivery}
|
||||||
|
onChange={(checked) => {
|
||||||
|
const next = [...skus];
|
||||||
|
next[index] = { ...row, allowCrossCityDelivery: checked };
|
||||||
|
setSkus(next);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Switch
|
||||||
|
checkedChildren="现场"
|
||||||
|
unCheckedChildren="现场"
|
||||||
|
checked={row.allowOnSitePickup}
|
||||||
|
onChange={(checked) => {
|
||||||
|
const next = [...skus];
|
||||||
|
next[index] = { ...row, allowOnSitePickup: checked };
|
||||||
|
setSkus(next);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '默认',
|
||||||
|
width: 70,
|
||||||
|
render: (_, row, index) => (
|
||||||
|
<Radio
|
||||||
|
checked={row.isDefault}
|
||||||
|
onChange={() => {
|
||||||
|
setSkus(skus.map((s, i) => ({ ...s, isDefault: i === index })));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '主图',
|
||||||
|
width: 72,
|
||||||
|
render: (_, row) =>
|
||||||
|
row.imageUrl ? (
|
||||||
|
<Image src={row.imageUrl} width={40} height={40} style={{ objectFit: 'cover', borderRadius: 4 }} />
|
||||||
|
) : (
|
||||||
|
<Typography.Text type="secondary">无</Typography.Text>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '编辑',
|
||||||
|
width: 80,
|
||||||
|
fixed: 'right',
|
||||||
|
render: (_, row, index) => (
|
||||||
|
<Button type="link" size="small" icon={<EditOutlined />} onClick={() => setEditIndex(index)}>
|
||||||
|
填写
|
||||||
|
</Button>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Button type="primary" loading={saving} style={{ marginTop: 16 }} onClick={() => void handleSave()}>
|
||||||
|
保存规格与 SKU
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Modal
|
||||||
|
title={`编辑规格${editing?.specText ? ` · ${editing.specText}` : editing?.skuCode ? ` · ${editing.skuCode}` : ''}`}
|
||||||
|
open={editIndex != null}
|
||||||
|
onCancel={() => setEditIndex(null)}
|
||||||
|
onOk={() => setEditIndex(null)}
|
||||||
|
okText="完成"
|
||||||
|
width={560}
|
||||||
|
destroyOnClose
|
||||||
|
>
|
||||||
|
{editing && editIndex != null ? (
|
||||||
|
<Space direction="vertical" size={14} style={{ width: '100%' }}>
|
||||||
|
<div>
|
||||||
|
<Typography.Text type="secondary">SKU</Typography.Text>
|
||||||
|
<div>{editing.skuCode || '保存后自动生成'}</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Typography.Text>69 码 <Typography.Text type="danger">*</Typography.Text></Typography.Text>
|
||||||
|
<Input
|
||||||
|
placeholder="本规格独立 69 码"
|
||||||
|
value={editing.barcode69}
|
||||||
|
onChange={(e) => patchSku(editIndex, { barcode69: e.target.value })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Typography.Text>主图</Typography.Text>
|
||||||
|
<OssUpload
|
||||||
|
bizType="COVER"
|
||||||
|
value={editing.imageUrl || ''}
|
||||||
|
onChange={(url) => patchSku(editIndex, { imageUrl: url })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<Space>
|
||||||
|
<div>
|
||||||
|
<Typography.Text>售价</Typography.Text>
|
||||||
|
<InputNumber
|
||||||
|
min={0}
|
||||||
|
style={{ width: 140 }}
|
||||||
|
value={editing.price}
|
||||||
|
onChange={(v) => patchSku(editIndex, { price: Number(v) || 0 })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Typography.Text>权益</Typography.Text>
|
||||||
|
<InputNumber
|
||||||
|
min={0}
|
||||||
|
style={{ width: 140 }}
|
||||||
|
value={editing.benefitAmount}
|
||||||
|
onChange={(v) => patchSku(editIndex, { benefitAmount: v == null ? undefined : Number(v) })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Space>
|
||||||
|
<div>
|
||||||
|
<Typography.Text>状态</Typography.Text>
|
||||||
|
<Select
|
||||||
|
style={{ width: '100%' }}
|
||||||
|
value={editing.status}
|
||||||
|
options={Object.entries(PRODUCT_STATUS_LABELS).map(([value, label]) => ({ value, label }))}
|
||||||
|
onChange={(status) => patchSku(editIndex, { status })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<Space>
|
||||||
|
<Select
|
||||||
|
style={{ width: 100 }}
|
||||||
|
value={editing.saleUnit}
|
||||||
|
options={[
|
||||||
|
{ value: 'BOTTLE', label: '瓶' },
|
||||||
|
{ value: 'BOX', label: '箱' },
|
||||||
|
]}
|
||||||
|
onChange={(saleUnit) =>
|
||||||
|
patchSku(editIndex, {
|
||||||
|
saleUnit,
|
||||||
|
bottlesPerUnit: saleUnit === 'BOX' ? editing.bottlesPerUnit || 6 : 1,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
{editing.saleUnit === 'BOX' ? (
|
||||||
|
<InputNumber
|
||||||
|
min={1}
|
||||||
|
value={editing.bottlesPerUnit}
|
||||||
|
onChange={(v) => patchSku(editIndex, { bottlesPerUnit: Number(v) || 6 })}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
</Space>
|
||||||
|
<Space>
|
||||||
|
<Switch
|
||||||
|
checkedChildren="线上"
|
||||||
|
unCheckedChildren="线上"
|
||||||
|
checked={editing.allowOnlinePurchase}
|
||||||
|
onChange={(checked) =>
|
||||||
|
patchSku(editIndex, {
|
||||||
|
allowOnlinePurchase: checked,
|
||||||
|
allowCrossCityDelivery: checked ? editing.allowCrossCityDelivery : false,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<Switch
|
||||||
|
checkedChildren="跨城"
|
||||||
|
unCheckedChildren="跨城"
|
||||||
|
disabled={!editing.allowOnlinePurchase}
|
||||||
|
checked={editing.allowCrossCityDelivery}
|
||||||
|
onChange={(checked) => patchSku(editIndex, { allowCrossCityDelivery: checked })}
|
||||||
|
/>
|
||||||
|
<Switch
|
||||||
|
checkedChildren="现场"
|
||||||
|
unCheckedChildren="现场"
|
||||||
|
checked={editing.allowOnSitePickup}
|
||||||
|
onChange={(checked) => patchSku(editIndex, { allowOnSitePickup: checked })}
|
||||||
|
/>
|
||||||
|
<Switch
|
||||||
|
checkedChildren="默认"
|
||||||
|
unCheckedChildren="默认"
|
||||||
|
checked={editing.isDefault}
|
||||||
|
onChange={(checked) => {
|
||||||
|
if (!checked) return;
|
||||||
|
setSkus((prev) => prev.map((s, i) => ({ ...s, isDefault: i === editIndex })));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
</Space>
|
||||||
|
) : null}
|
||||||
|
</Modal>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -51,6 +51,7 @@ export default function ProxyOrderModal({ open, onClose, onSuccess }: ProxyOrder
|
|||||||
const [regionCodes, setRegionCodes] = useState<string[]>([]);
|
const [regionCodes, setRegionCodes] = useState<string[]>([]);
|
||||||
const [addressDetail, setAddressDetail] = useState('');
|
const [addressDetail, setAddressDetail] = useState('');
|
||||||
const [productId, setProductId] = useState<string>();
|
const [productId, setProductId] = useState<string>();
|
||||||
|
const [skuId, setSkuId] = useState<string>();
|
||||||
const [quantity, setQuantity] = useState(2);
|
const [quantity, setQuantity] = useState(2);
|
||||||
const [promoCodeId, setPromoCodeId] = useState<string>();
|
const [promoCodeId, setPromoCodeId] = useState<string>();
|
||||||
const [deliveryMode, setDeliveryMode] = useState<PartnerProxyDeliveryMode>('ADDRESS');
|
const [deliveryMode, setDeliveryMode] = useState<PartnerProxyDeliveryMode>('ADDRESS');
|
||||||
@@ -87,9 +88,37 @@ export default function ProxyOrderModal({ open, onClose, onSuccess }: ProxyOrder
|
|||||||
}, [open]);
|
}, [open]);
|
||||||
|
|
||||||
const selectedProduct = options?.products.find((p) => p.id === productId);
|
const selectedProduct = options?.products.find((p) => p.id === productId);
|
||||||
const allowOnline = selectedProduct ? selectedProduct.allowOnlinePurchase !== false : true;
|
const skuOptions = (selectedProduct?.skus ?? []).filter((s) => s.status === 'ON_SALE');
|
||||||
const allowOnSite = !!selectedProduct?.allowOnSitePickup;
|
const selectedSku =
|
||||||
const allowCrossCity = selectedProduct ? selectedProduct.allowCrossCityDelivery !== false : true;
|
skuOptions.find((s) => s.id === skuId) ||
|
||||||
|
skuOptions.find((s) => s.id === selectedProduct?.defaultSkuId) ||
|
||||||
|
skuOptions[0];
|
||||||
|
const allowOnline = selectedSku
|
||||||
|
? selectedSku.allowOnlinePurchase !== false
|
||||||
|
: selectedProduct
|
||||||
|
? selectedProduct.allowOnlinePurchase !== false
|
||||||
|
: true;
|
||||||
|
const allowOnSite = selectedSku
|
||||||
|
? !!selectedSku.allowOnSitePickup
|
||||||
|
: !!selectedProduct?.allowOnSitePickup;
|
||||||
|
const allowCrossCity = selectedSku
|
||||||
|
? selectedSku.allowCrossCityDelivery !== false
|
||||||
|
: selectedProduct
|
||||||
|
? selectedProduct.allowCrossCityDelivery !== false
|
||||||
|
: true;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!open || !selectedProduct) return;
|
||||||
|
const def =
|
||||||
|
skuOptions.find((s) => s.id === selectedProduct.defaultSkuId) ||
|
||||||
|
skuOptions.find((s) => s.isDefault) ||
|
||||||
|
skuOptions[0];
|
||||||
|
if (def && skuId !== def.id && (!skuId || !skuOptions.some((s) => s.id === skuId))) {
|
||||||
|
setSkuId(def.id);
|
||||||
|
setQuantity(def.saleUnit === 'BOX' ? 1 : Math.max(quantity, 2));
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [open, productId, selectedProduct?.id]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!open || !selectedProduct) return;
|
if (!open || !selectedProduct) return;
|
||||||
@@ -115,6 +144,7 @@ export default function ProxyOrderModal({ open, onClose, onSuccess }: ProxyOrder
|
|||||||
productId,
|
productId,
|
||||||
quantity,
|
quantity,
|
||||||
deliveryMode,
|
deliveryMode,
|
||||||
|
skuId: skuId || undefined,
|
||||||
receiverCity: deliveryMode === 'ADDRESS' ? region?.city || undefined : undefined,
|
receiverCity: deliveryMode === 'ADDRESS' ? region?.city || undefined : undefined,
|
||||||
receiverDistrict: deliveryMode === 'ADDRESS' ? region?.district || undefined : undefined,
|
receiverDistrict: deliveryMode === 'ADDRESS' ? region?.district || undefined : undefined,
|
||||||
}),
|
}),
|
||||||
@@ -124,7 +154,7 @@ export default function ProxyOrderModal({ open, onClose, onSuccess }: ProxyOrder
|
|||||||
.finally(() => setPreviewLoading(false));
|
.finally(() => setPreviewLoading(false));
|
||||||
}, 300);
|
}, 300);
|
||||||
return () => window.clearTimeout(timer);
|
return () => window.clearTimeout(timer);
|
||||||
}, [open, productId, quantity, deliveryMode, region?.city, region?.district, step]);
|
}, [open, productId, skuId, quantity, deliveryMode, region?.city, region?.district, step]);
|
||||||
|
|
||||||
useEffect(() => () => stopPoll(), []);
|
useEffect(() => () => stopPoll(), []);
|
||||||
|
|
||||||
@@ -135,6 +165,8 @@ export default function ProxyOrderModal({ open, onClose, onSuccess }: ProxyOrder
|
|||||||
setRegionCodes([]);
|
setRegionCodes([]);
|
||||||
setAddressDetail('');
|
setAddressDetail('');
|
||||||
setQuantity(2);
|
setQuantity(2);
|
||||||
|
setProductId(undefined);
|
||||||
|
setSkuId(undefined);
|
||||||
setPromoCodeId(undefined);
|
setPromoCodeId(undefined);
|
||||||
setDeliveryMode('ADDRESS');
|
setDeliveryMode('ADDRESS');
|
||||||
setAutoReceive(false);
|
setAutoReceive(false);
|
||||||
@@ -202,6 +234,7 @@ export default function ProxyOrderModal({ open, onClose, onSuccess }: ProxyOrder
|
|||||||
productId: productId!,
|
productId: productId!,
|
||||||
quantity,
|
quantity,
|
||||||
promoCodeId: promoCodeId || undefined,
|
promoCodeId: promoCodeId || undefined,
|
||||||
|
skuId: skuId || undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
setSubmitting(true);
|
setSubmitting(true);
|
||||||
@@ -317,7 +350,10 @@ export default function ProxyOrderModal({ open, onClose, onSuccess }: ProxyOrder
|
|||||||
loading={loadingOptions}
|
loading={loadingOptions}
|
||||||
placeholder="选择商品"
|
placeholder="选择商品"
|
||||||
value={productId}
|
value={productId}
|
||||||
onChange={setProductId}
|
onChange={(id) => {
|
||||||
|
setProductId(id);
|
||||||
|
setSkuId(undefined);
|
||||||
|
}}
|
||||||
options={(options?.products ?? []).map((p) => ({
|
options={(options?.products ?? []).map((p) => ({
|
||||||
value: p.id,
|
value: p.id,
|
||||||
label: `${p.name} · ${p.spec} · ¥${fmtMoney(p.price)}`,
|
label: `${p.name} · ${p.spec} · ¥${fmtMoney(p.price)}`,
|
||||||
@@ -325,7 +361,25 @@ export default function ProxyOrderModal({ open, onClose, onSuccess }: ProxyOrder
|
|||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item label="数量" required>
|
{skuOptions.length > 1 || selectedProduct?.specEnabled ? (
|
||||||
|
<Form.Item label="规格" required>
|
||||||
|
<Select
|
||||||
|
placeholder="选择规格"
|
||||||
|
value={skuId}
|
||||||
|
onChange={(id) => {
|
||||||
|
setSkuId(id);
|
||||||
|
const sku = skuOptions.find((s) => s.id === id);
|
||||||
|
if (sku?.saleUnit === 'BOX') setQuantity(1);
|
||||||
|
}}
|
||||||
|
options={skuOptions.map((s) => ({
|
||||||
|
value: s.id,
|
||||||
|
label: `${s.specText || '默认'} · ¥${fmtMoney(s.price)} · ${s.saleUnit === 'BOX' ? `${s.bottlesPerUnit}瓶/箱` : '瓶'}`,
|
||||||
|
}))}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<Form.Item label={selectedSku?.saleUnit === 'BOX' ? '数量(箱)' : '数量(瓶)'} required>
|
||||||
<InputNumber
|
<InputNumber
|
||||||
min={1}
|
min={1}
|
||||||
value={quantity}
|
value={quantity}
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ export default function RedeemRecordDetailDescriptions({ detail, maskUserPhone =
|
|||||||
cityName?: string;
|
cityName?: string;
|
||||||
address?: string;
|
address?: string;
|
||||||
partnerAccount?: { companyName?: string };
|
partnerAccount?: { companyName?: string };
|
||||||
|
primaryAccount?: {
|
||||||
|
bankAccountName?: string | null;
|
||||||
|
bankAccountNo?: string | null;
|
||||||
|
bankBranch?: string | null;
|
||||||
|
} | null;
|
||||||
}
|
}
|
||||||
| undefined;
|
| undefined;
|
||||||
const coupon = detail.coupon as { couponNo?: string; order?: { orderNo?: string } } | undefined;
|
const coupon = detail.coupon as { couponNo?: string; order?: { orderNo?: string } } | undefined;
|
||||||
@@ -46,6 +51,15 @@ export default function RedeemRecordDetailDescriptions({ detail, maskUserPhone =
|
|||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="门店地址">{store?.address ?? '—'}</Descriptions.Item>
|
<Descriptions.Item label="门店地址">{store?.address ?? '—'}</Descriptions.Item>
|
||||||
<Descriptions.Item label="合伙人">{store?.partnerAccount?.companyName ?? '—'}</Descriptions.Item>
|
<Descriptions.Item label="合伙人">{store?.partnerAccount?.companyName ?? '—'}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="收款户名">
|
||||||
|
{store?.primaryAccount?.bankAccountName || '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="收款账号">
|
||||||
|
{store?.primaryAccount?.bankAccountNo || '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="开户行">
|
||||||
|
{store?.primaryAccount?.bankBranch || '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="权益券号">{coupon?.couponNo ?? '—'}</Descriptions.Item>
|
<Descriptions.Item label="权益券号">{coupon?.couponNo ?? '—'}</Descriptions.Item>
|
||||||
<Descriptions.Item label="关联订单">{coupon?.order?.orderNo ?? '—'}</Descriptions.Item>
|
<Descriptions.Item label="关联订单">{coupon?.order?.orderNo ?? '—'}</Descriptions.Item>
|
||||||
{Array.isArray(detail.allocations) && (detail.allocations as unknown[]).length > 0 ? (
|
{Array.isArray(detail.allocations) && (detail.allocations as unknown[]).length > 0 ? (
|
||||||
|
|||||||
@@ -0,0 +1,459 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { Button, Image, Input, Modal, Space, Tag, Typography, message } from 'antd';
|
||||||
|
import type {
|
||||||
|
StorePackageAuditDetailDto,
|
||||||
|
StorePackageItemDto,
|
||||||
|
StorePackageViewDto,
|
||||||
|
} from '@dukang/shared-types';
|
||||||
|
import { normalizeStorePackageImageUrls } from '@dukang/shared-types';
|
||||||
|
import { request } from '../lib/api';
|
||||||
|
import { notifyPackageAuditChanged } from '../lib/admin-events';
|
||||||
|
import { fmtTime } from '../lib/constants';
|
||||||
|
|
||||||
|
const HQ_PACKAGE_STATUS_LABELS: Record<string, string> = {
|
||||||
|
PENDING: '待审核',
|
||||||
|
APPROVED: '已通过',
|
||||||
|
REJECTED: '已驳回',
|
||||||
|
};
|
||||||
|
|
||||||
|
function packageKey(pkg: StorePackageItemDto | StorePackageViewDto, index: number) {
|
||||||
|
const name = String(pkg.name ?? '').trim();
|
||||||
|
return name ? `name:${name}` : `idx:${index}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function imageSignature(pkg: StorePackageItemDto | StorePackageViewDto) {
|
||||||
|
return normalizeStorePackageImageUrls(pkg).join('|');
|
||||||
|
}
|
||||||
|
|
||||||
|
type FieldChange = { label: string; old: string; now: string; kind: 'text' | 'value' };
|
||||||
|
|
||||||
|
function diffText(a: string, b: string): Array<{ type: 'equal' | 'insert' | 'delete'; text: string }> {
|
||||||
|
const m = a.length;
|
||||||
|
const n = b.length;
|
||||||
|
const dp: number[][] = Array.from({ length: m + 1 }, () => new Array(n + 1).fill(0));
|
||||||
|
for (let i = m - 1; i >= 0; i--) {
|
||||||
|
for (let j = n - 1; j >= 0; j--) {
|
||||||
|
dp[i][j] = a[i] === b[j] ? dp[i + 1][j + 1] + 1 : Math.max(dp[i + 1][j], dp[i][j + 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const raw: Array<{ type: 'equal' | 'insert' | 'delete'; text: string }> = [];
|
||||||
|
let i = 0;
|
||||||
|
let j = 0;
|
||||||
|
while (i < m && j < n) {
|
||||||
|
if (a[i] === b[j]) {
|
||||||
|
raw.push({ type: 'equal', text: a[i] });
|
||||||
|
i++;
|
||||||
|
j++;
|
||||||
|
} else if (dp[i + 1][j] >= dp[i][j + 1]) {
|
||||||
|
raw.push({ type: 'delete', text: a[i] });
|
||||||
|
i++;
|
||||||
|
} else {
|
||||||
|
raw.push({ type: 'insert', text: b[j] });
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (i < m) raw.push({ type: 'delete', text: a[i++] });
|
||||||
|
while (j < n) raw.push({ type: 'insert', text: b[j++] });
|
||||||
|
const merged: Array<{ type: 'equal' | 'insert' | 'delete'; text: string }> = [];
|
||||||
|
for (const s of raw) {
|
||||||
|
const last = merged[merged.length - 1];
|
||||||
|
if (last && last.type === s.type) last.text += s.text;
|
||||||
|
else merged.push({ ...s });
|
||||||
|
}
|
||||||
|
return merged;
|
||||||
|
}
|
||||||
|
|
||||||
|
function fieldChanges(
|
||||||
|
live: StorePackageItemDto | StorePackageViewDto,
|
||||||
|
proposed: StorePackageItemDto | StorePackageViewDto,
|
||||||
|
): FieldChange[] {
|
||||||
|
const changes: FieldChange[] = [];
|
||||||
|
const text = (v: string | number | null | undefined) => (v ?? '').toString().trim();
|
||||||
|
const pushText = (label: string, oldV: string, newV: string) => {
|
||||||
|
if (oldV !== newV) changes.push({ label, old: oldV, now: newV, kind: 'text' });
|
||||||
|
};
|
||||||
|
const pushValue = (label: string, oldV: string, newV: string) => {
|
||||||
|
if (oldV !== newV) changes.push({ label, old: oldV || '(空)', now: newV || '(空)', kind: 'value' });
|
||||||
|
};
|
||||||
|
pushValue('价格', `¥${text(live.price)}`, `¥${text(proposed.price)}`);
|
||||||
|
pushText('套餐名称', text(live.name), text(proposed.name));
|
||||||
|
pushText('菜品内容', text(live.dishes), text(proposed.dishes));
|
||||||
|
pushText('可用时间', text(live.usableTime), text(proposed.usableTime));
|
||||||
|
pushText('其他说明', text(live.otherNotes), text(proposed.otherNotes));
|
||||||
|
const liveImgs = normalizeStorePackageImageUrls(live);
|
||||||
|
const proposedImgs = normalizeStorePackageImageUrls(proposed);
|
||||||
|
if (imageSignature(live) !== imageSignature(proposed)) {
|
||||||
|
changes.push({ label: '图片', old: `${liveImgs.length} 张`, now: `${proposedImgs.length} 张`, kind: 'value' });
|
||||||
|
}
|
||||||
|
return changes;
|
||||||
|
}
|
||||||
|
|
||||||
|
function diffPackages(live: StorePackageViewDto[], proposed: StorePackageItemDto[]) {
|
||||||
|
const liveMap = new Map(live.map((p, i) => [packageKey(p, i), p]));
|
||||||
|
const proposedMap = new Map(proposed.map((p, i) => [packageKey(p, i), p]));
|
||||||
|
const keys = new Set([...liveMap.keys(), ...proposedMap.keys()]);
|
||||||
|
const rows: Array<{
|
||||||
|
key: string;
|
||||||
|
change: 'added' | 'removed' | 'changed' | 'unchanged';
|
||||||
|
live?: StorePackageViewDto;
|
||||||
|
proposed?: StorePackageItemDto;
|
||||||
|
changes?: FieldChange[];
|
||||||
|
}> = [];
|
||||||
|
|
||||||
|
for (const key of keys) {
|
||||||
|
const l = liveMap.get(key);
|
||||||
|
const p = proposedMap.get(key);
|
||||||
|
if (l && !p) {
|
||||||
|
rows.push({ key, change: 'removed', live: l });
|
||||||
|
} else if (!l && p) {
|
||||||
|
rows.push({ key, change: 'added', proposed: p });
|
||||||
|
} else if (l && p) {
|
||||||
|
const changed =
|
||||||
|
l.price !== p.price ||
|
||||||
|
l.dishes !== p.dishes ||
|
||||||
|
(l.usableTime ?? '') !== (p.usableTime ?? '') ||
|
||||||
|
(l.otherNotes ?? '') !== (p.otherNotes ?? '') ||
|
||||||
|
imageSignature(l) !== imageSignature(p);
|
||||||
|
rows.push({
|
||||||
|
key,
|
||||||
|
change: changed ? 'changed' : 'unchanged',
|
||||||
|
live: l,
|
||||||
|
proposed: p,
|
||||||
|
changes: changed ? fieldChanges(l, p) : undefined,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CHANGE_LABELS = {
|
||||||
|
added: { text: '新增', color: 'green' },
|
||||||
|
removed: { text: '删除', color: 'red' },
|
||||||
|
changed: { text: '变更', color: 'orange' },
|
||||||
|
unchanged: { text: '未变', color: 'default' },
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
function TextDiff({ oldText, newText }: { oldText: string; newText: string }) {
|
||||||
|
const segs = diffText(oldText, newText);
|
||||||
|
return (
|
||||||
|
<div style={{ marginTop: 2 }}>
|
||||||
|
<div style={{ lineHeight: 1.6 }}>
|
||||||
|
<Typography.Text type="secondary">原:</Typography.Text>
|
||||||
|
{segs
|
||||||
|
.filter((s) => s.type !== 'insert')
|
||||||
|
.map((s, idx) =>
|
||||||
|
s.type === 'delete' ? (
|
||||||
|
<Typography.Text key={idx} delete style={{ color: '#cf1322' }}>
|
||||||
|
{s.text || '(空)'}
|
||||||
|
</Typography.Text>
|
||||||
|
) : (
|
||||||
|
<Typography.Text key={idx}>{s.text}</Typography.Text>
|
||||||
|
),
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div style={{ lineHeight: 1.6 }}>
|
||||||
|
<Typography.Text type="secondary">新:</Typography.Text>
|
||||||
|
{segs
|
||||||
|
.filter((s) => s.type !== 'delete')
|
||||||
|
.map((s, idx) =>
|
||||||
|
s.type === 'insert' ? (
|
||||||
|
<Typography.Text key={idx} style={{ color: '#389e0d' }}>
|
||||||
|
{s.text || '(空)'}
|
||||||
|
</Typography.Text>
|
||||||
|
) : (
|
||||||
|
<Typography.Text key={idx}>{s.text}</Typography.Text>
|
||||||
|
),
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function PackageDetailCard({
|
||||||
|
title,
|
||||||
|
pkg,
|
||||||
|
change,
|
||||||
|
changes,
|
||||||
|
imageSize = 72,
|
||||||
|
}: {
|
||||||
|
title?: string;
|
||||||
|
pkg: StorePackageItemDto | StorePackageViewDto;
|
||||||
|
change?: keyof typeof CHANGE_LABELS;
|
||||||
|
changes?: FieldChange[];
|
||||||
|
imageSize?: number;
|
||||||
|
}) {
|
||||||
|
const images = normalizeStorePackageImageUrls(pkg);
|
||||||
|
const meta = change ? CHANGE_LABELS[change] : null;
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
marginBottom: 12,
|
||||||
|
padding: 12,
|
||||||
|
border: '1px solid #f0f0f0',
|
||||||
|
borderRadius: 8,
|
||||||
|
background: '#fafafa',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Space style={{ marginBottom: 8 }} wrap>
|
||||||
|
{title ? <Typography.Text type="secondary">{title}</Typography.Text> : null}
|
||||||
|
{meta ? <Tag color={meta.color}>{meta.text}</Tag> : null}
|
||||||
|
</Space>
|
||||||
|
<div style={{ marginBottom: 8 }}>
|
||||||
|
<strong>{pkg.name}</strong>
|
||||||
|
<span style={{ marginLeft: 8 }}>¥{pkg.price}</span>
|
||||||
|
</div>
|
||||||
|
<Typography.Paragraph className="admin-package-audit-text" style={{ marginBottom: 8 }}>
|
||||||
|
{pkg.dishes || '—'}
|
||||||
|
</Typography.Paragraph>
|
||||||
|
{pkg.usableTime ? (
|
||||||
|
<Typography.Paragraph type="secondary" className="admin-package-audit-text" style={{ marginBottom: 4 }}>
|
||||||
|
可用时间:{pkg.usableTime}
|
||||||
|
</Typography.Paragraph>
|
||||||
|
) : null}
|
||||||
|
{pkg.otherNotes ? (
|
||||||
|
<Typography.Paragraph type="secondary" className="admin-package-audit-text" style={{ marginBottom: 8 }}>
|
||||||
|
其他说明:{pkg.otherNotes}
|
||||||
|
</Typography.Paragraph>
|
||||||
|
) : null}
|
||||||
|
{images.length ? (
|
||||||
|
<Image.PreviewGroup>
|
||||||
|
<Space wrap size={8}>
|
||||||
|
{images.map((url) => (
|
||||||
|
<Image key={url} src={url} width={imageSize} height={imageSize} style={{ objectFit: 'cover', borderRadius: 4 }} />
|
||||||
|
))}
|
||||||
|
</Space>
|
||||||
|
</Image.PreviewGroup>
|
||||||
|
) : (
|
||||||
|
<Typography.Text type="secondary">无套餐图片</Typography.Text>
|
||||||
|
)}
|
||||||
|
{changes && changes.length ? (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
marginTop: 8,
|
||||||
|
padding: 8,
|
||||||
|
background: '#fff7e6',
|
||||||
|
border: '1px solid #ffe7ba',
|
||||||
|
borderRadius: 6,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography.Text strong style={{ fontSize: 12 }}>
|
||||||
|
变更明细
|
||||||
|
</Typography.Text>
|
||||||
|
<ul style={{ margin: '6px 0 0', paddingLeft: 18 }}>
|
||||||
|
{changes.map((c) => (
|
||||||
|
<li key={c.label} style={{ marginBottom: 6 }}>
|
||||||
|
<Typography.Text type="secondary">{c.label}:</Typography.Text>
|
||||||
|
{c.kind === 'text' ? (
|
||||||
|
<TextDiff oldText={c.old} newText={c.now} />
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Typography.Text delete type="secondary">
|
||||||
|
{c.old}
|
||||||
|
</Typography.Text>
|
||||||
|
<Typography.Text type="secondary"> → </Typography.Text>
|
||||||
|
<Typography.Text strong>{c.now}</Typography.Text>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export type StorePackageAuditPanelProps = {
|
||||||
|
requestId: string;
|
||||||
|
/** 是否在面板顶部显示通过/驳回(抽屉 extra 另有按钮时可关) */
|
||||||
|
showActions?: boolean;
|
||||||
|
fullscreen?: boolean;
|
||||||
|
onAudited?: () => void;
|
||||||
|
onDetailLoaded?: (detail: StorePackageAuditDetailDto | null) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 套餐变更对比 + 通过/驳回(审核通知页与门店详情抽屉共用) */
|
||||||
|
export default function StorePackageAuditPanel({
|
||||||
|
requestId,
|
||||||
|
showActions = true,
|
||||||
|
fullscreen = false,
|
||||||
|
onAudited,
|
||||||
|
onDetailLoaded,
|
||||||
|
}: StorePackageAuditPanelProps) {
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [detail, setDetail] = useState<StorePackageAuditDetailDto | null>(null);
|
||||||
|
const [rejectOpen, setRejectOpen] = useState(false);
|
||||||
|
const [rejectReason, setRejectReason] = useState('');
|
||||||
|
const [auditing, setAuditing] = useState(false);
|
||||||
|
|
||||||
|
async function load() {
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const data = await request<StorePackageAuditDetailDto>(`/admin/store-package-audits/${requestId}`);
|
||||||
|
setDetail(data);
|
||||||
|
onDetailLoaded?.(data);
|
||||||
|
} catch (e) {
|
||||||
|
message.error(e instanceof Error ? e.message : '加载套餐审核详情失败');
|
||||||
|
setDetail(null);
|
||||||
|
onDetailLoaded?.(null);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
void load();
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [requestId]);
|
||||||
|
|
||||||
|
async function audit(action: 'APPROVE' | 'REJECT', reason?: string) {
|
||||||
|
if (!detail) return;
|
||||||
|
setAuditing(true);
|
||||||
|
try {
|
||||||
|
await request(`/admin/store-package-audits/${detail.id}/audit`, {
|
||||||
|
method: 'PUT',
|
||||||
|
body: JSON.stringify(action === 'REJECT' ? { action, rejectReason: reason } : { action }),
|
||||||
|
});
|
||||||
|
message.success(action === 'APPROVE' ? '套餐已通过' : '套餐已驳回');
|
||||||
|
notifyPackageAuditChanged();
|
||||||
|
onAudited?.();
|
||||||
|
await load();
|
||||||
|
} catch (e) {
|
||||||
|
message.error(e instanceof Error ? e.message : '操作失败');
|
||||||
|
} finally {
|
||||||
|
setAuditing(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loading && !detail) {
|
||||||
|
return <Typography.Text type="secondary">加载套餐变更…</Typography.Text>;
|
||||||
|
}
|
||||||
|
if (!detail) {
|
||||||
|
return <Typography.Text type="secondary">暂无套餐审核详情</Typography.Text>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const diffRows = diffPackages(detail.livePackages ?? [], detail.packages ?? []);
|
||||||
|
const changeByKey = new Map(diffRows.map((row) => [row.key, row.change]));
|
||||||
|
const changesByKey = new Map(diffRows.map((row) => [row.key, row.changes]));
|
||||||
|
const addedCount = diffRows.filter((r) => r.change === 'added').length;
|
||||||
|
const removedCount = diffRows.filter((r) => r.change === 'removed').length;
|
||||||
|
const changedCount = diffRows.filter((r) => r.change === 'changed').length;
|
||||||
|
const unchangedCount = diffRows.filter((r) => r.change === 'unchanged').length;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Space style={{ marginBottom: 12, width: '100%', justifyContent: 'space-between' }} wrap>
|
||||||
|
<Space wrap>
|
||||||
|
<Tag>{HQ_PACKAGE_STATUS_LABELS[detail.status] ?? detail.status}</Tag>
|
||||||
|
<Typography.Text type="secondary">
|
||||||
|
提交方:{detail.submitterType === 'PARTNER' ? '合伙人' : '门店'} · {fmtTime(detail.createdAt)}
|
||||||
|
</Typography.Text>
|
||||||
|
</Space>
|
||||||
|
{showActions && detail.status === 'PENDING' ? (
|
||||||
|
<Space>
|
||||||
|
<Button type="primary" loading={auditing} onClick={() => void audit('APPROVE')}>
|
||||||
|
通过套餐
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
danger
|
||||||
|
loading={auditing}
|
||||||
|
onClick={() => {
|
||||||
|
setRejectReason('');
|
||||||
|
setRejectOpen(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
驳回套餐
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
) : null}
|
||||||
|
</Space>
|
||||||
|
{detail.rejectReason ? (
|
||||||
|
<Typography.Paragraph type="danger">驳回原因:{detail.rejectReason}</Typography.Paragraph>
|
||||||
|
) : null}
|
||||||
|
<Space direction="vertical" size={4} style={{ marginBottom: 12 }}>
|
||||||
|
<Typography.Text type="secondary">
|
||||||
|
线上已审核 {detail.livePackages?.length ?? 0} 条 · 待审核 {detail.packages?.length ?? 0} 条
|
||||||
|
</Typography.Text>
|
||||||
|
<Space wrap>
|
||||||
|
<Tag color="green">新增 {addedCount}</Tag>
|
||||||
|
<Tag color="red">删除 {removedCount}</Tag>
|
||||||
|
<Tag color="orange">变更 {changedCount}</Tag>
|
||||||
|
{unchangedCount ? <Tag>未变 {unchangedCount}</Tag> : null}
|
||||||
|
</Space>
|
||||||
|
</Space>
|
||||||
|
<div className="admin-package-audit-cols">
|
||||||
|
<div className="admin-package-audit-col">
|
||||||
|
<Typography.Title level={5} style={{ marginTop: 0 }}>
|
||||||
|
线上已审核套餐
|
||||||
|
</Typography.Title>
|
||||||
|
{(detail.livePackages ?? []).length ? (
|
||||||
|
(detail.livePackages ?? []).map((pkg, index) => (
|
||||||
|
<PackageDetailCard
|
||||||
|
key={`live-${packageKey(pkg, index)}`}
|
||||||
|
title={`套餐 ${index + 1}`}
|
||||||
|
pkg={pkg}
|
||||||
|
change={changeByKey.get(packageKey(pkg, index))}
|
||||||
|
imageSize={fullscreen ? 160 : 72}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<Typography.Text type="secondary">暂无线上套餐</Typography.Text>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="admin-package-audit-col">
|
||||||
|
<Typography.Title level={5} style={{ marginTop: 0 }}>
|
||||||
|
待审核套餐
|
||||||
|
</Typography.Title>
|
||||||
|
{(detail.packages ?? []).length ? (
|
||||||
|
(detail.packages ?? []).map((pkg, index) => (
|
||||||
|
<PackageDetailCard
|
||||||
|
key={`pending-${packageKey(pkg, index)}`}
|
||||||
|
title={`套餐 ${index + 1}`}
|
||||||
|
pkg={pkg}
|
||||||
|
change={changeByKey.get(packageKey(pkg, index))}
|
||||||
|
changes={changesByKey.get(packageKey(pkg, index))}
|
||||||
|
imageSize={fullscreen ? 160 : 72}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<Typography.Text type="secondary">暂无待审核套餐</Typography.Text>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Modal
|
||||||
|
title="驳回套餐变更"
|
||||||
|
open={rejectOpen}
|
||||||
|
confirmLoading={auditing}
|
||||||
|
onCancel={() => setRejectOpen(false)}
|
||||||
|
onOk={() => {
|
||||||
|
if (!rejectReason.trim()) {
|
||||||
|
message.warning('请填写驳回原因');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
void audit('REJECT', rejectReason.trim()).then(() => setRejectOpen(false));
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Input.TextArea
|
||||||
|
rows={3}
|
||||||
|
value={rejectReason}
|
||||||
|
placeholder="驳回原因"
|
||||||
|
onChange={(e) => setRejectReason(e.target.value)}
|
||||||
|
/>
|
||||||
|
</Modal>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 供门店详情抽屉 extra 调用 */
|
||||||
|
export async function auditStorePackageRequest(
|
||||||
|
requestId: string,
|
||||||
|
action: 'APPROVE' | 'REJECT',
|
||||||
|
rejectReason?: string,
|
||||||
|
) {
|
||||||
|
await request(`/admin/store-package-audits/${requestId}/audit`, {
|
||||||
|
method: 'PUT',
|
||||||
|
body: JSON.stringify(action === 'REJECT' ? { action, rejectReason } : { action }),
|
||||||
|
});
|
||||||
|
notifyPackageAuditChanged();
|
||||||
|
}
|
||||||
@@ -20,10 +20,11 @@ import {
|
|||||||
AccountBookOutlined,
|
AccountBookOutlined,
|
||||||
ProjectOutlined,
|
ProjectOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import { hasAnySystemSettingsPermission } from '@dukang/shared-types';
|
import { hasAnySystemSettingsPermission, hasAnyStoreMenuPermission } from '@dukang/shared-types';
|
||||||
import { clearAuth, request, type HqProfile } from '../lib/api';
|
import { clearAuth, request, type HqProfile } from '../lib/api';
|
||||||
import { bindAdminEllipsisTitle } from '../lib/ellipsis-title';
|
import { bindAdminEllipsisTitle } from '../lib/ellipsis-title';
|
||||||
import { AUDIT_NOTICE_CHANGED_EVENT, PACKAGE_AUDIT_CHANGED_EVENT } from '../lib/admin-events';
|
import { AUDIT_NOTICE_CHANGED_EVENT, PACKAGE_AUDIT_CHANGED_EVENT } from '../lib/admin-events';
|
||||||
|
import { ListColumnPrefsProvider } from '../lib/ListColumnPrefsContext';
|
||||||
|
|
||||||
const { Header, Sider, Content } = Layout;
|
const { Header, Sider, Content } = Layout;
|
||||||
|
|
||||||
@@ -156,6 +157,9 @@ function menuAllowed(key: string, permissionKeys: string[]): boolean {
|
|||||||
if (key === 'tickets-group') {
|
if (key === 'tickets-group') {
|
||||||
return permissionKeys.includes('tickets') || permissionKeys.includes('tech_support');
|
return permissionKeys.includes('tickets') || permissionKeys.includes('tech_support');
|
||||||
}
|
}
|
||||||
|
if (key === 'stores-group') {
|
||||||
|
return hasAnyStoreMenuPermission(permissionKeys);
|
||||||
|
}
|
||||||
if (key === 'dev-plan-group') {
|
if (key === 'dev-plan-group') {
|
||||||
return permissionKeys.includes('dev_plan');
|
return permissionKeys.includes('dev_plan');
|
||||||
}
|
}
|
||||||
@@ -175,11 +179,11 @@ function menuAllowed(key: string, permissionKeys: string[]): boolean {
|
|||||||
'/knowledge-bases': 'knowledge_bases',
|
'/knowledge-bases': 'knowledge_bases',
|
||||||
'stores-group': 'stores',
|
'stores-group': 'stores',
|
||||||
'/stores': 'stores',
|
'/stores': 'stores',
|
||||||
'/store-package-audits': 'stores',
|
'/store-package-audits': 'store_audits',
|
||||||
'/store-ratings': 'stores',
|
'/store-ratings': 'store_ratings',
|
||||||
'/store-categories': 'stores',
|
'/store-categories': 'store_categories',
|
||||||
'/store-accounts': 'stores',
|
'/store-accounts': 'store_accounts',
|
||||||
'/store-media': 'stores',
|
'/store-media': 'store_media',
|
||||||
'partners-group': 'partners',
|
'partners-group': 'partners',
|
||||||
'/cities': 'partners',
|
'/cities': 'partners',
|
||||||
'/city-partners': 'partners',
|
'/city-partners': 'partners',
|
||||||
@@ -196,10 +200,10 @@ function menuAllowed(key: string, permissionKeys: string[]): boolean {
|
|||||||
'/benefit/ledgers': 'benefit',
|
'/benefit/ledgers': 'benefit',
|
||||||
'/redeem-records': 'benefit',
|
'/redeem-records': 'benefit',
|
||||||
'/redeem-pending': 'benefit',
|
'/redeem-pending': 'benefit',
|
||||||
'/redeem/debug': 'benefit',
|
'/redeem/debug': 'benefit_debug',
|
||||||
'deliveries-group': 'deliveries',
|
'deliveries-group': 'deliveries',
|
||||||
'/deliveries': 'deliveries',
|
'/deliveries': 'deliveries',
|
||||||
'/deliveries/xiaofeixia': 'deliveries',
|
'/deliveries/xiaofeixia': 'deliveries_debug',
|
||||||
'/tickets': 'tickets',
|
'/tickets': 'tickets',
|
||||||
'/tickets/support': 'tech_support',
|
'/tickets/support': 'tech_support',
|
||||||
'dev-plan-group': 'dev_plan',
|
'dev-plan-group': 'dev_plan',
|
||||||
@@ -413,7 +417,9 @@ export default function AdminLayout() {
|
|||||||
style={{ flex: 1, minHeight: 0, overflow: 'auto' }}
|
style={{ flex: 1, minHeight: 0, overflow: 'auto' }}
|
||||||
>
|
>
|
||||||
<Content style={{ margin: 24 }}>
|
<Content style={{ margin: 24 }}>
|
||||||
|
<ListColumnPrefsProvider initial={profile?.listColumnPrefs}>
|
||||||
<Outlet />
|
<Outlet />
|
||||||
|
</ListColumnPrefsProvider>
|
||||||
</Content>
|
</Content>
|
||||||
</div>
|
</div>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import { createContext, useCallback, useContext, useEffect, useMemo, useState, type ReactNode } from 'react';
|
||||||
|
import type { HqListColumnKey, HqListColumnPref, HqListColumnPrefsMap } from '@dukang/shared-types';
|
||||||
|
import { request } from './api';
|
||||||
|
|
||||||
|
type Ctx = {
|
||||||
|
prefs: HqListColumnPrefsMap;
|
||||||
|
ready: boolean;
|
||||||
|
setPrefs: (next: HqListColumnPrefsMap) => void;
|
||||||
|
save: (listKey: HqListColumnKey, next: HqListColumnPref | null) => Promise<void>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const ListColumnPrefsContext = createContext<Ctx>({
|
||||||
|
prefs: {},
|
||||||
|
ready: false,
|
||||||
|
setPrefs: () => {},
|
||||||
|
save: async () => {},
|
||||||
|
});
|
||||||
|
|
||||||
|
export function ListColumnPrefsProvider({
|
||||||
|
initial,
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
initial?: HqListColumnPrefsMap;
|
||||||
|
children: ReactNode;
|
||||||
|
}) {
|
||||||
|
const [prefs, setPrefs] = useState<HqListColumnPrefsMap>(initial ?? {});
|
||||||
|
const [ready] = useState(true);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (initial) setPrefs(initial);
|
||||||
|
}, [initial]);
|
||||||
|
|
||||||
|
const save = useCallback(async (listKey: HqListColumnKey, next: HqListColumnPref | null) => {
|
||||||
|
const res = await request<{ listColumnPrefs: HqListColumnPrefsMap }>(
|
||||||
|
`/admin/me/list-columns/${listKey}`,
|
||||||
|
{
|
||||||
|
method: 'PUT',
|
||||||
|
body: JSON.stringify(next ? { order: next.order, hidden: next.hidden } : { reset: true }),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
setPrefs(res.listColumnPrefs ?? {});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const value = useMemo(() => ({ prefs, ready, setPrefs, save }), [prefs, ready, save]);
|
||||||
|
return <ListColumnPrefsContext.Provider value={value}>{children}</ListColumnPrefsContext.Provider>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useListColumnPrefs() {
|
||||||
|
return useContext(ListColumnPrefsContext);
|
||||||
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import type { HqListColumnPrefsMap } from '@dukang/shared-types';
|
||||||
|
|
||||||
export const apiBase = '/api/v1';
|
export const apiBase = '/api/v1';
|
||||||
export const CLIENT_APP = 'HQ_WEB';
|
export const CLIENT_APP = 'HQ_WEB';
|
||||||
|
|
||||||
@@ -8,6 +10,9 @@ export type HqProfile = {
|
|||||||
adminRole: string;
|
adminRole: string;
|
||||||
status: string;
|
status: string;
|
||||||
permissionKeys?: string[];
|
permissionKeys?: string[];
|
||||||
|
cityIds?: string[];
|
||||||
|
cityScoped?: boolean;
|
||||||
|
listColumnPrefs?: HqListColumnPrefsMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getToken() {
|
export function getToken() {
|
||||||
@@ -87,6 +92,9 @@ export type DashboardStats = {
|
|||||||
openTickets?: number;
|
openTickets?: number;
|
||||||
pendingStoreWithdrawals?: number;
|
pendingStoreWithdrawals?: number;
|
||||||
overdueStoreWithdrawals?: number;
|
overdueStoreWithdrawals?: number;
|
||||||
|
pendingStoreOnboard?: number;
|
||||||
|
pendingStorePackageAudits?: number;
|
||||||
|
pendingStoreInfoChanges?: number;
|
||||||
ordersByStatus: Array<{ status: string; count: number }>;
|
ordersByStatus: Array<{ status: string; count: number }>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -161,6 +169,7 @@ export type AdminUserRow = {
|
|||||||
wxOpenId: string | null;
|
wxOpenId: string | null;
|
||||||
wechatVerified: boolean;
|
wechatVerified: boolean;
|
||||||
nickname: string | null;
|
nickname: string | null;
|
||||||
|
hqRemark: string | null;
|
||||||
status: number;
|
status: number;
|
||||||
sourceType: string;
|
sourceType: string;
|
||||||
sourceRefId: string | null;
|
sourceRefId: string | null;
|
||||||
@@ -195,6 +204,18 @@ export type AdminOrderRow = {
|
|||||||
quantity?: number;
|
quantity?: number;
|
||||||
receiverName: string;
|
receiverName: string;
|
||||||
receiverPhone: string;
|
receiverPhone: string;
|
||||||
|
receiverProvince?: string;
|
||||||
|
receiverCity?: string;
|
||||||
|
receiverDistrict?: string;
|
||||||
|
receiverAddress?: string;
|
||||||
|
benefitAmount?: number;
|
||||||
|
benefitCoupon?: {
|
||||||
|
couponNo?: string;
|
||||||
|
totalAmount?: number;
|
||||||
|
usedAmount?: number;
|
||||||
|
balance?: number;
|
||||||
|
status?: string;
|
||||||
|
} | null;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
cityId?: string;
|
cityId?: string;
|
||||||
city?: { id: string; name: string; code: string };
|
city?: { id: string; name: string; code: string };
|
||||||
|
|||||||
@@ -8,3 +8,19 @@ export function downloadExcelCsv(csv: string, filename: string) {
|
|||||||
a.click();
|
a.click();
|
||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Download binary file from base64 payload returned by HQ export APIs. */
|
||||||
|
export function downloadBase64File(contentBase64: string, filename: string, mimeType: string) {
|
||||||
|
const binary = atob(contentBase64);
|
||||||
|
const bytes = new Uint8Array(binary.length);
|
||||||
|
for (let i = 0; i < binary.length; i += 1) {
|
||||||
|
bytes[i] = binary.charCodeAt(i);
|
||||||
|
}
|
||||||
|
const blob = new Blob([bytes], { type: mimeType });
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.href = url;
|
||||||
|
a.download = filename;
|
||||||
|
a.click();
|
||||||
|
URL.revokeObjectURL(url);
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
import type { ColumnType } from 'antd/es/table';
|
||||||
|
import type { HqListColumnKey, HqListColumnPref } from '@dukang/shared-types';
|
||||||
|
|
||||||
|
export const SERIAL_COLUMN_KEY = '__serial';
|
||||||
|
export const ACTIONS_COLUMN_KEY = '__actions';
|
||||||
|
|
||||||
|
export function columnKey<T>(col: ColumnType<T>, index: number): string {
|
||||||
|
if (col.key != null && String(col.key).length) return String(col.key);
|
||||||
|
const dataIndex = col.dataIndex;
|
||||||
|
if (typeof dataIndex === 'string' && dataIndex) return dataIndex;
|
||||||
|
if (Array.isArray(dataIndex) && dataIndex.length) return dataIndex.map(String).join('.');
|
||||||
|
if (typeof col.title === 'string' && col.title) return col.title;
|
||||||
|
return `col-${index}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isActionsColumn<T>(col: ColumnType<T>, key: string): boolean {
|
||||||
|
if (key === ACTIONS_COLUMN_KEY || key === 'actions' || key === 'action') return true;
|
||||||
|
return col.title === '操作';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function mergeColumnOrder(defaultKeys: string[], pref?: HqListColumnPref): string[] {
|
||||||
|
const known = new Set(defaultKeys);
|
||||||
|
const ordered = (pref?.order ?? []).filter((k) => known.has(k));
|
||||||
|
for (const key of defaultKeys) {
|
||||||
|
if (ordered.includes(key)) continue;
|
||||||
|
const defaultIdx = defaultKeys.indexOf(key);
|
||||||
|
let insertAt = ordered.length;
|
||||||
|
for (let i = 0; i < ordered.length; i += 1) {
|
||||||
|
if (defaultKeys.indexOf(ordered[i]) > defaultIdx) {
|
||||||
|
insertAt = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ordered.splice(insertAt, 0, key);
|
||||||
|
}
|
||||||
|
return ordered;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function visibleColumnKeys(defaultKeys: string[], pref?: HqListColumnPref): string[] {
|
||||||
|
const hidden = new Set(pref?.hidden ?? []);
|
||||||
|
return mergeColumnOrder(defaultKeys, pref).filter((k) => !hidden.has(k));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function applyColumnPrefs<T>(
|
||||||
|
columns: ColumnType<T>[],
|
||||||
|
pref: HqListColumnPref | undefined,
|
||||||
|
): ColumnType<T>[] {
|
||||||
|
const keyed = columns.map((col, i) => {
|
||||||
|
const key = columnKey(col, i);
|
||||||
|
return { col: { ...col, key }, key, actions: isActionsColumn(col, key) };
|
||||||
|
});
|
||||||
|
const configurable = keyed.filter((c) => !c.actions);
|
||||||
|
const actions = keyed.filter((c) => c.actions);
|
||||||
|
const defaultKeys = configurable.map((c) => c.key);
|
||||||
|
const visible = new Set(visibleColumnKeys(defaultKeys, pref));
|
||||||
|
const orderedKeys = mergeColumnOrder(defaultKeys, pref).filter((k) => visible.has(k));
|
||||||
|
const byKey = new Map(configurable.map((c) => [c.key, c.col]));
|
||||||
|
return [...orderedKeys.map((k) => byKey.get(k)!).filter(Boolean), ...actions.map((c) => c.col)];
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ListColumnSettingItem = {
|
||||||
|
key: string;
|
||||||
|
title: string;
|
||||||
|
visible: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function settingItems<T>(
|
||||||
|
columns: ColumnType<T>[],
|
||||||
|
pref?: HqListColumnPref,
|
||||||
|
): ListColumnSettingItem[] {
|
||||||
|
const keyed = columns
|
||||||
|
.map((col, i) => ({ col, key: columnKey(col, i) }))
|
||||||
|
.filter(({ col, key }) => !isActionsColumn(col, key));
|
||||||
|
const hidden = new Set(pref?.hidden ?? []);
|
||||||
|
const order = mergeColumnOrder(keyed.map((c) => c.key), pref);
|
||||||
|
const byKey = new Map(keyed.map((c) => [c.key, c.col]));
|
||||||
|
return order.map((key) => {
|
||||||
|
const col = byKey.get(key);
|
||||||
|
const title = typeof col?.title === 'string' ? col.title : key;
|
||||||
|
return { key, title, visible: !hidden.has(key) };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export type { HqListColumnKey };
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
import { useMemo, useState } from 'react';
|
||||||
|
import { Button, message } from 'antd';
|
||||||
|
import { SettingOutlined } from '@ant-design/icons';
|
||||||
|
import type { ColumnsType, ColumnType } from 'antd/es/table';
|
||||||
|
import type { HqListColumnKey } from '@dukang/shared-types';
|
||||||
|
import { AdminListColumnsModal } from '../components/AdminListColumnsModal';
|
||||||
|
import { useListColumnPrefs } from './ListColumnPrefsContext';
|
||||||
|
import {
|
||||||
|
ACTIONS_COLUMN_KEY,
|
||||||
|
SERIAL_COLUMN_KEY,
|
||||||
|
applyColumnPrefs,
|
||||||
|
settingItems,
|
||||||
|
type ListColumnSettingItem,
|
||||||
|
} from './list-column-prefs';
|
||||||
|
|
||||||
|
type Options = {
|
||||||
|
page?: number;
|
||||||
|
pageSize?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function useAdminListColumns<T>(
|
||||||
|
listKey: HqListColumnKey,
|
||||||
|
allColumns: ColumnsType<T>,
|
||||||
|
options: Options = {},
|
||||||
|
) {
|
||||||
|
const { page = 1, pageSize = 20 } = options;
|
||||||
|
const { prefs, save } = useListColumnPrefs();
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const [saving, setSaving] = useState(false);
|
||||||
|
const pref = prefs[listKey];
|
||||||
|
|
||||||
|
const configured = useMemo(
|
||||||
|
() => applyColumnPrefs(allColumns as ColumnType<T>[], pref),
|
||||||
|
[allColumns, pref],
|
||||||
|
);
|
||||||
|
|
||||||
|
const items = useMemo(
|
||||||
|
() => settingItems(allColumns as ColumnType<T>[], pref),
|
||||||
|
[allColumns, pref],
|
||||||
|
);
|
||||||
|
|
||||||
|
const serialCol: ColumnType<T> = useMemo(
|
||||||
|
() => ({
|
||||||
|
key: SERIAL_COLUMN_KEY,
|
||||||
|
title: '序号',
|
||||||
|
width: 64,
|
||||||
|
fixed: 'left' as const,
|
||||||
|
render: (_: unknown, __: T, index: number) => (page - 1) * pageSize + index + 1,
|
||||||
|
}),
|
||||||
|
[page, pageSize],
|
||||||
|
);
|
||||||
|
|
||||||
|
const columns = useMemo<ColumnsType<T>>(
|
||||||
|
() => [
|
||||||
|
serialCol,
|
||||||
|
...configured.map((col) =>
|
||||||
|
col.title === '操作' || col.key === ACTIONS_COLUMN_KEY || col.key === 'actions'
|
||||||
|
? { ...col, key: col.key ?? ACTIONS_COLUMN_KEY }
|
||||||
|
: col,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
[configured, serialCol],
|
||||||
|
);
|
||||||
|
|
||||||
|
async function persist(next: ListColumnSettingItem[] | null) {
|
||||||
|
setSaving(true);
|
||||||
|
try {
|
||||||
|
if (!next) {
|
||||||
|
await save(listKey, null);
|
||||||
|
} else {
|
||||||
|
await save(listKey, {
|
||||||
|
order: next.map((i) => i.key),
|
||||||
|
hidden: next.filter((i) => !i.visible).map((i) => i.key),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
setOpen(false);
|
||||||
|
message.success(next ? '列设置已保存' : '已恢复默认列');
|
||||||
|
} catch (e) {
|
||||||
|
message.error(e instanceof Error ? e.message : '保存失败');
|
||||||
|
} finally {
|
||||||
|
setSaving(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const settingsButton = (
|
||||||
|
<Button icon={<SettingOutlined />} onClick={() => setOpen(true)}>
|
||||||
|
列设置
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
|
||||||
|
const settingsModal = (
|
||||||
|
<AdminListColumnsModal
|
||||||
|
open={open}
|
||||||
|
items={items}
|
||||||
|
saving={saving}
|
||||||
|
onCancel={() => setOpen(false)}
|
||||||
|
onReset={() => void persist(null)}
|
||||||
|
onSave={(draft) => void persist(draft)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
return { columns, settingsButton, settingsModal };
|
||||||
|
}
|
||||||
@@ -20,6 +20,8 @@ import { request } from '../lib/api';
|
|||||||
import { COUPON_STATUS_LABELS, fmtTime } from '../lib/constants';
|
import { COUPON_STATUS_LABELS, fmtTime } from '../lib/constants';
|
||||||
import RedeemRecordDetailDescriptions from '../components/RedeemRecordDetailDescriptions';
|
import RedeemRecordDetailDescriptions from '../components/RedeemRecordDetailDescriptions';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -99,7 +101,7 @@ export default function BenefitCouponsPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{ title: '券号', dataIndex: 'couponNo', width: 200, ellipsis: false },
|
{ title: '券号', dataIndex: 'couponNo', width: 200, ellipsis: false },
|
||||||
{ title: '用户', dataIndex: ['user', 'userNo'], width: 120, ellipsis: false },
|
{ title: '用户', dataIndex: ['user', 'userNo'], width: 120, ellipsis: false },
|
||||||
{ title: '手机号', dataIndex: ['user', 'phone'], width: 120, render: (v) => v || '—' },
|
{ title: '手机号', dataIndex: ['user', 'phone'], width: 120, render: (v) => v || '—' },
|
||||||
@@ -113,7 +115,7 @@ export default function BenefitCouponsPage() {
|
|||||||
{ title: '总额', dataIndex: 'totalAmount', width: 80, render: (v) => `¥${v}` },
|
{ title: '总额', dataIndex: 'totalAmount', width: 80, render: (v) => `¥${v}` },
|
||||||
{ title: '余额', dataIndex: 'balance', width: 80, render: (v) => `¥${v}` },
|
{ title: '余额', dataIndex: 'balance', width: 80, render: (v) => `¥${v}` },
|
||||||
{ title: '状态', dataIndex: 'status', width: 90, render: (s) => <Tag>{COUPON_STATUS_LABELS[s] || s}</Tag> },
|
{ title: '状态', dataIndex: 'status', width: 90, render: (s) => <Tag>{COUPON_STATUS_LABELS[s] || s}</Tag> },
|
||||||
{ title: '来源', dataIndex: 'sourceProduct', ellipsis: true },
|
{ title: '来源', dataIndex: 'sourceProduct' },
|
||||||
{ title: '创建', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
{ title: '创建', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
@@ -155,15 +157,21 @@ export default function BenefitCouponsPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('benefit-coupons', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }}>
|
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }}>
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>
|
<Typography.Title level={4} style={{ margin: 0 }}>
|
||||||
好客权益券
|
好客权益券
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
|
<Space>
|
||||||
|
{settingsButton}
|
||||||
<Button type="primary" onClick={() => setGrantOpen(true)}>
|
<Button type="primary" onClick={() => setGrantOpen(true)}>
|
||||||
手动发放
|
手动发放
|
||||||
</Button>
|
</Button>
|
||||||
|
</Space>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
|
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
|
||||||
@@ -190,7 +198,7 @@ export default function BenefitCouponsPage() {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data?.items ?? []}
|
dataSource={data?.items ?? []}
|
||||||
scroll={{ x: 1200 }}
|
scroll={{ x: 'max-content' }}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: page,
|
current: page,
|
||||||
pageSize,
|
pageSize,
|
||||||
@@ -316,7 +324,7 @@ export default function BenefitCouponsPage() {
|
|||||||
locale={{ emptyText: '暂无关联核销单' }}
|
locale={{ emptyText: '暂无关联核销单' }}
|
||||||
dataSource={detail.redeemRecords ?? []}
|
dataSource={detail.redeemRecords ?? []}
|
||||||
columns={[
|
columns={[
|
||||||
{ title: '核销号', dataIndex: 'redeemNo', ellipsis: true },
|
{ title: '核销号', dataIndex: 'redeemNo' },
|
||||||
{
|
{
|
||||||
title: '角色',
|
title: '角色',
|
||||||
dataIndex: 'role',
|
dataIndex: 'role',
|
||||||
@@ -327,7 +335,7 @@ export default function BenefitCouponsPage() {
|
|||||||
{
|
{
|
||||||
title: '门店',
|
title: '门店',
|
||||||
dataIndex: ['store', 'name'],
|
dataIndex: ['store', 'name'],
|
||||||
ellipsis: true,
|
|
||||||
render: (v: string | undefined, row: CouponRedeemRecord) =>
|
render: (v: string | undefined, row: CouponRedeemRecord) =>
|
||||||
v ? `${v}${row.store?.cityName ? `(${row.store.cityName})` : ''}` : '—',
|
v ? `${v}${row.store?.cityName ? `(${row.store.cityName})` : ''}` : '—',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import { Form, Input, Select, Button, Table, Tag, Typography } from 'antd';
|
|||||||
import type { ColumnsType } from 'antd/es/table';
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
import { LEDGER_TYPE_LABELS, fmtTime } from '../lib/constants';
|
import { LEDGER_TYPE_LABELS, fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
id: string; type: string; amount: number; balanceAfter: number; remark: string | null; createdAt: string;
|
id: string; type: string; amount: number; balanceAfter: number; remark: string | null; createdAt: string;
|
||||||
@@ -24,19 +26,23 @@ export default function BenefitLedgersPage() {
|
|||||||
[filters],
|
[filters],
|
||||||
);
|
);
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{ title: '类型', dataIndex: 'type', width: 90, render: (t) => <Tag>{LEDGER_TYPE_LABELS[t] || t}</Tag> },
|
{ title: '类型', dataIndex: 'type', width: 90, render: (t) => <Tag>{LEDGER_TYPE_LABELS[t] || t}</Tag> },
|
||||||
{ title: '用户', dataIndex: ['user', 'userNo'], width: 120, ellipsis: false },
|
{ title: '用户', dataIndex: ['user', 'userNo'], width: 120, ellipsis: false },
|
||||||
{ title: '券号', dataIndex: ['coupon', 'couponNo'], width: 200, ellipsis: false },
|
{ title: '券号', dataIndex: ['coupon', 'couponNo'], width: 200, ellipsis: false },
|
||||||
{ title: '变动', dataIndex: 'amount', width: 90, render: (v) => `${v >= 0 ? '+' : ''}${v}` },
|
{ title: '变动', dataIndex: 'amount', width: 90, render: (v) => `${v >= 0 ? '+' : ''}${v}` },
|
||||||
{ title: '余额后', dataIndex: 'balanceAfter', width: 90 },
|
{ title: '余额后', dataIndex: 'balanceAfter', width: 90 },
|
||||||
{ title: '备注', dataIndex: 'remark', ellipsis: true },
|
{ title: '备注', dataIndex: 'remark' },
|
||||||
{ title: '时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
{ title: '时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('benefit-ledgers', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Typography.Title level={4}>权益流水</Typography.Title>
|
<Typography.Title level={4}>权益流水</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
|
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
|
||||||
<Form.Item name="userId" label="用户ID"><Input allowClear /></Form.Item>
|
<Form.Item name="userId" label="用户ID"><Input allowClear /></Form.Item>
|
||||||
<Form.Item name="couponId" label="券ID"><Input allowClear /></Form.Item>
|
<Form.Item name="couponId" label="券ID"><Input allowClear /></Form.Item>
|
||||||
@@ -45,7 +51,7 @@ export default function BenefitLedgersPage() {
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item><Button type="primary" htmlType="submit">查询</Button></Form.Item>
|
<Form.Item><Button type="primary" htmlType="submit">查询</Button></Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
<Table rowKey="id" className="admin-table-nowrap" loading={loading} columns={columns} dataSource={data?.items ?? []} scroll={{ x: 1000 }}
|
<Table rowKey="id" className="admin-table-nowrap" loading={loading} columns={columns} dataSource={data?.items ?? []} scroll={{ x: 'max-content' }}
|
||||||
pagination={{ current: page, pageSize, total: data?.total ?? 0, showSizeChanger: true, onChange: (p, ps) => { setPage(p); setPageSize(ps); } }} />
|
pagination={{ current: page, pageSize, total: data?.total ?? 0, showSizeChanger: true, onChange: (p, ps) => { setPage(p); setPageSize(ps); } }} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import { useCallback, useEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
|
import { useCallback, useEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
|
import sfxTier1 from '../assets/big-screen/celebrate-t1.mp3';
|
||||||
|
import sfxTier2 from '../assets/big-screen/celebrate-t2.mp3';
|
||||||
|
import sfxTier3 from '../assets/big-screen/celebrate-t3.mp3';
|
||||||
|
|
||||||
export type BigScreenOrder = {
|
export type BigScreenOrder = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -16,102 +19,60 @@ type AmountTier = 1 | 2 | 3;
|
|||||||
|
|
||||||
const POLL_MS = 3000;
|
const POLL_MS = 3000;
|
||||||
const ROW_MS = 2500;
|
const ROW_MS = 2500;
|
||||||
|
/** 不足此条数时重复填充,保证滚动连贯 */
|
||||||
|
const MIN_SCROLL_ROWS = 10;
|
||||||
|
const FX_DURATION_MS = 10_000;
|
||||||
const WEEKDAYS = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
|
const WEEKDAYS = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
|
||||||
const TIER_DURATION: Record<AmountTier, number> = { 1: 3000, 2: 4500, 3: 6000 };
|
|
||||||
|
|
||||||
const SEED_IDS = new Set(
|
const CELEBRATE_SFX: Record<AmountTier, string> = {
|
||||||
['seed-1', 'seed-2', 'seed-3', 'seed-4', 'seed-5', 'seed-6', 'seed-7', 'seed-8'],
|
1: sfxTier1,
|
||||||
);
|
2: sfxTier2,
|
||||||
|
3: sfxTier3,
|
||||||
|
};
|
||||||
|
|
||||||
function seedPaidAt(h: number, m: number, s: number): string {
|
/** 浏览器自动播放策略:需用户手势后才能出声 */
|
||||||
const d = new Date();
|
let audioUnlocked = false;
|
||||||
d.setHours(h, m, s, 0);
|
const sharedAudio = typeof Audio !== 'undefined' ? new Audio() : null;
|
||||||
return d.toISOString();
|
|
||||||
|
function unlockCelebrateAudio() {
|
||||||
|
if (audioUnlocked || !sharedAudio) return;
|
||||||
|
sharedAudio.muted = true;
|
||||||
|
sharedAudio.src = CELEBRATE_SFX[1];
|
||||||
|
void sharedAudio
|
||||||
|
.play()
|
||||||
|
.then(() => {
|
||||||
|
sharedAudio.pause();
|
||||||
|
sharedAudio.currentTime = 0;
|
||||||
|
sharedAudio.muted = false;
|
||||||
|
audioUnlocked = true;
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
/* 等待下次手势 */
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 发布会滚动列表垫底演示数据(不参与成交动效) */
|
function playCelebrateSfx(tier: AmountTier): () => void {
|
||||||
const BIG_SCREEN_SEED_ORDERS: BigScreenOrder[] = [
|
if (!sharedAudio) return () => undefined;
|
||||||
{
|
try {
|
||||||
id: 'seed-1',
|
sharedAudio.pause();
|
||||||
orderNo: 'DK-DEMO-001',
|
sharedAudio.currentTime = 0;
|
||||||
payAmount: 1288,
|
sharedAudio.src = CELEBRATE_SFX[tier];
|
||||||
items: '杜康君酿 · 浓香型 × 6瓶',
|
sharedAudio.volume = tier === 3 ? 0.85 : tier === 2 ? 0.75 : 0.65;
|
||||||
createdAt: seedPaidAt(14, 28, 36),
|
sharedAudio.muted = false;
|
||||||
paidAt: seedPaidAt(14, 28, 36),
|
void sharedAudio.play().catch(() => {
|
||||||
userPhoneMasked: '138****8888',
|
/* 未解锁时静默失败 */
|
||||||
},
|
});
|
||||||
{
|
} catch {
|
||||||
id: 'seed-2',
|
/* ignore */
|
||||||
orderNo: 'DK-DEMO-002',
|
}
|
||||||
payAmount: 688,
|
return () => {
|
||||||
items: '杜康君酿 · 浓香型 × 2瓶',
|
try {
|
||||||
createdAt: seedPaidAt(14, 22, 18),
|
sharedAudio.pause();
|
||||||
paidAt: seedPaidAt(14, 22, 18),
|
sharedAudio.currentTime = 0;
|
||||||
userPhoneMasked: '139****6666',
|
} catch {
|
||||||
},
|
/* ignore */
|
||||||
{
|
}
|
||||||
id: 'seed-3',
|
};
|
||||||
orderNo: 'DK-DEMO-003',
|
|
||||||
payAmount: 1588,
|
|
||||||
items: '杜康典藏 · 礼盒装 × 2套',
|
|
||||||
createdAt: seedPaidAt(14, 15, 42),
|
|
||||||
paidAt: seedPaidAt(14, 15, 42),
|
|
||||||
userPhoneMasked: '136****9527',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'seed-4',
|
|
||||||
orderNo: 'DK-DEMO-004',
|
|
||||||
payAmount: 520,
|
|
||||||
items: '杜康特曲 · 500ml × 4瓶',
|
|
||||||
createdAt: seedPaidAt(14, 8, 55),
|
|
||||||
paidAt: seedPaidAt(14, 8, 55),
|
|
||||||
userPhoneMasked: '135****3210',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'seed-5',
|
|
||||||
orderNo: 'DK-DEMO-005',
|
|
||||||
payAmount: 268,
|
|
||||||
items: '杜康君酿 · 浓香型 × 1瓶',
|
|
||||||
createdAt: seedPaidAt(13, 56, 7),
|
|
||||||
paidAt: seedPaidAt(13, 56, 7),
|
|
||||||
userPhoneMasked: '137****1888',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'seed-6',
|
|
||||||
orderNo: 'DK-DEMO-006',
|
|
||||||
payAmount: 999,
|
|
||||||
items: '杜康窖藏 · 珍藏版 × 3瓶',
|
|
||||||
createdAt: seedPaidAt(13, 48, 33),
|
|
||||||
paidAt: seedPaidAt(13, 48, 33),
|
|
||||||
userPhoneMasked: '133****7788',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'seed-7',
|
|
||||||
orderNo: 'DK-DEMO-007',
|
|
||||||
payAmount: 188,
|
|
||||||
items: '杜康小酒 · 品鉴装 × 2瓶',
|
|
||||||
createdAt: seedPaidAt(13, 35, 21),
|
|
||||||
paidAt: seedPaidAt(13, 35, 21),
|
|
||||||
userPhoneMasked: '158****0099',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'seed-8',
|
|
||||||
orderNo: 'DK-DEMO-008',
|
|
||||||
payAmount: 1200,
|
|
||||||
items: '杜康君酿 · 浓香型 × 5瓶',
|
|
||||||
createdAt: seedPaidAt(13, 22, 49),
|
|
||||||
paidAt: seedPaidAt(13, 22, 49),
|
|
||||||
userPhoneMasked: '186****5566',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
function mergeDisplayItems(live: BigScreenOrder[]): BigScreenOrder[] {
|
|
||||||
if (!live.length) return [...BIG_SCREEN_SEED_ORDERS];
|
|
||||||
return [...live, ...BIG_SCREEN_SEED_ORDERS];
|
|
||||||
}
|
|
||||||
|
|
||||||
function isSeedOrder(order: BigScreenOrder): boolean {
|
|
||||||
return SEED_IDS.has(order.id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function pad(n: number) {
|
function pad(n: number) {
|
||||||
@@ -134,11 +95,20 @@ function formatOrderTime(iso: string): string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// function formatAmount(n: number): string {
|
||||||
|
// return Number(n || 0).toLocaleString('zh-CN', {
|
||||||
|
// minimumFractionDigits: 0,
|
||||||
|
// maximumFractionDigits: 0,
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
function formatAmount(n: number): string {
|
function formatAmount(n: number): string {
|
||||||
return Number(n || 0).toLocaleString('zh-CN', {
|
const num = Number(n || 0);
|
||||||
minimumFractionDigits: 0,
|
// 先保留两位小数,再分割处理
|
||||||
maximumFractionDigits: 0,
|
const fixed = num.toFixed(2);
|
||||||
});
|
const [intStr, decStr] = fixed.split('.');
|
||||||
|
const intFormatted = Number(intStr).toLocaleString('zh-CN');
|
||||||
|
return decStr === '00' ? intFormatted : `${intFormatted}.${decStr}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function amountCssClass(payAmount: number, base: string): string {
|
function amountCssClass(payAmount: number, base: string): string {
|
||||||
@@ -264,9 +234,13 @@ function CelebrateFx({ order, onDone }: { order: BigScreenOrder; onDone: () => v
|
|||||||
const [displayAmount, setDisplayAmount] = useState(tier === 3 ? 0 : order.payAmount);
|
const [displayAmount, setDisplayAmount] = useState(tier === 3 ? 0 : order.payAmount);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const duration = TIER_DURATION[tier];
|
const timer = window.setTimeout(() => onDoneRef.current(), FX_DURATION_MS);
|
||||||
const timer = window.setTimeout(() => onDoneRef.current(), duration);
|
|
||||||
return () => window.clearTimeout(timer);
|
return () => window.clearTimeout(timer);
|
||||||
|
}, [order.id]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const stop = playCelebrateSfx(tier);
|
||||||
|
return stop;
|
||||||
}, [order.id, tier]);
|
}, [order.id, tier]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -299,7 +273,6 @@ function CelebrateFx({ order, onDone }: { order: BigScreenOrder; onDone: () => v
|
|||||||
let raf = 0;
|
let raf = 0;
|
||||||
let last = performance.now();
|
let last = performance.now();
|
||||||
const started = performance.now();
|
const started = performance.now();
|
||||||
const duration = TIER_DURATION[tier];
|
|
||||||
const gravity = tier === 3 ? 0.18 : 0.14;
|
const gravity = tier === 3 ? 0.18 : 0.14;
|
||||||
const loop = (now: number) => {
|
const loop = (now: number) => {
|
||||||
const dt = Math.min(32, now - last) / 16.6;
|
const dt = Math.min(32, now - last) / 16.6;
|
||||||
@@ -310,8 +283,12 @@ function CelebrateFx({ order, onDone }: { order: BigScreenOrder; onDone: () => v
|
|||||||
p.x += p.vx * dt;
|
p.x += p.vx * dt;
|
||||||
p.y += p.vy * dt;
|
p.y += p.vy * dt;
|
||||||
p.rot += p.vr * dt;
|
p.rot += p.vr * dt;
|
||||||
p.life -= (tier === 3 ? 0.0032 : 0.005) * dt;
|
p.life -= (tier === 3 ? 0.002 : 0.003) * dt;
|
||||||
if (p.rain && (p.y > canvas.clientHeight + 30 || p.life <= 0) && now - started < duration - 400) {
|
if (
|
||||||
|
p.rain &&
|
||||||
|
(p.y > canvas.clientHeight + 30 || p.life <= 0) &&
|
||||||
|
now - started < FX_DURATION_MS - 400
|
||||||
|
) {
|
||||||
p.x = Math.random() * canvas.clientWidth;
|
p.x = Math.random() * canvas.clientWidth;
|
||||||
p.y = -16 - Math.random() * 60;
|
p.y = -16 - Math.random() * 60;
|
||||||
p.vx = (Math.random() - 0.5) * 1.4;
|
p.vx = (Math.random() - 0.5) * 1.4;
|
||||||
@@ -374,12 +351,9 @@ export default function BigScreenPage() {
|
|||||||
const queueRef = useRef<BigScreenOrder[]>([]);
|
const queueRef = useRef<BigScreenOrder[]>([]);
|
||||||
const celebratingRef = useRef(false);
|
const celebratingRef = useRef(false);
|
||||||
const viewportRef = useRef<HTMLDivElement | null>(null);
|
const viewportRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
const dayKeyRef = useRef('');
|
||||||
const [viewportH, setViewportH] = useState(0);
|
const [viewportH, setViewportH] = useState(0);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
for (const o of BIG_SCREEN_SEED_ORDERS) celebratedIdsRef.current.add(o.id);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const playNext = useCallback(() => {
|
const playNext = useCallback(() => {
|
||||||
const next = queueRef.current.shift() ?? null;
|
const next = queueRef.current.shift() ?? null;
|
||||||
celebratingRef.current = !!next;
|
celebratingRef.current = !!next;
|
||||||
@@ -404,10 +378,22 @@ export default function BigScreenPage() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const fetchData = useCallback(() => {
|
const fetchData = useCallback(() => {
|
||||||
|
const now = new Date();
|
||||||
|
const todayKey = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`;
|
||||||
|
if (dayKeyRef.current && dayKeyRef.current !== todayKey) {
|
||||||
|
seenIdsRef.current = null;
|
||||||
|
celebratedIdsRef.current = new Set();
|
||||||
|
queueRef.current = [];
|
||||||
|
celebratingRef.current = false;
|
||||||
|
setCelebrate(null);
|
||||||
|
setPaused(false);
|
||||||
|
}
|
||||||
|
dayKeyRef.current = todayKey;
|
||||||
|
|
||||||
return request<{ items: BigScreenOrder[] }>('/admin/orders/big-screen?limit=2000')
|
return request<{ items: BigScreenOrder[] }>('/admin/orders/big-screen?limit=2000')
|
||||||
.then((d) => {
|
.then((d) => {
|
||||||
const list = d.items ?? [];
|
const list = d.items ?? [];
|
||||||
setItems(mergeDisplayItems(list));
|
setItems(list);
|
||||||
setLoadError('');
|
setLoadError('');
|
||||||
const seen = seenIdsRef.current;
|
const seen = seenIdsRef.current;
|
||||||
if (!seen) {
|
if (!seen) {
|
||||||
@@ -421,7 +407,6 @@ export default function BigScreenPage() {
|
|||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
setLoadError(e instanceof Error ? e.message : '加载失败');
|
setLoadError(e instanceof Error ? e.message : '加载失败');
|
||||||
setItems(mergeDisplayItems([]));
|
|
||||||
});
|
});
|
||||||
}, [enqueueNew]);
|
}, [enqueueNew]);
|
||||||
|
|
||||||
@@ -431,6 +416,17 @@ export default function BigScreenPage() {
|
|||||||
return () => clearInterval(id);
|
return () => clearInterval(id);
|
||||||
}, [fetchData]);
|
}, [fetchData]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
unlockCelebrateAudio();
|
||||||
|
const unlock = () => unlockCelebrateAudio();
|
||||||
|
window.addEventListener('pointerdown', unlock, { once: true });
|
||||||
|
window.addEventListener('keydown', unlock, { once: true });
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('pointerdown', unlock);
|
||||||
|
window.removeEventListener('keydown', unlock);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const html = document.documentElement;
|
const html = document.documentElement;
|
||||||
const prevHtml = html.style.overflow;
|
const prevHtml = html.style.overflow;
|
||||||
@@ -457,7 +453,7 @@ export default function BigScreenPage() {
|
|||||||
if (!items.length) return [];
|
if (!items.length) return [];
|
||||||
const rowH = 80;
|
const rowH = 80;
|
||||||
const visible = Math.max(1, Math.ceil((viewportH || 480) / rowH));
|
const visible = Math.max(1, Math.ceil((viewportH || 480) / rowH));
|
||||||
const minCount = visible + 1;
|
const minCount = Math.max(MIN_SCROLL_ROWS, visible + 1);
|
||||||
const unit: BigScreenOrder[] = [];
|
const unit: BigScreenOrder[] = [];
|
||||||
while (unit.length < minCount) unit.push(...items);
|
while (unit.length < minCount) unit.push(...items);
|
||||||
return unit;
|
return unit;
|
||||||
@@ -466,8 +462,7 @@ export default function BigScreenPage() {
|
|||||||
const trackItems = useMemo(() => unitItems.concat(unitItems), [unitItems]);
|
const trackItems = useMemo(() => unitItems.concat(unitItems), [unitItems]);
|
||||||
const marqueeMs = Math.max(unitItems.length, 1) * ROW_MS;
|
const marqueeMs = Math.max(unitItems.length, 1) * ROW_MS;
|
||||||
const rolling = items.length > 0 && unitItems.length > 0;
|
const rolling = items.length > 0 && unitItems.length > 0;
|
||||||
const latestLive = items.find((o) => !isSeedOrder(o));
|
const latestId = items[0]?.id;
|
||||||
const latestId = latestLive?.id;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="big-screen-page">
|
<div className="big-screen-page">
|
||||||
@@ -496,16 +491,8 @@ export default function BigScreenPage() {
|
|||||||
<LiveClock />
|
<LiveClock />
|
||||||
|
|
||||||
<div className="big-screen-list">
|
<div className="big-screen-list">
|
||||||
<div className="big-screen-list-head">
|
|
||||||
<span>下单金额</span>
|
|
||||||
<span>下单商品</span>
|
|
||||||
<span>付款时间</span>
|
|
||||||
<span>下单人</span>
|
|
||||||
</div>
|
|
||||||
<div className="big-screen-list-body" ref={viewportRef}>
|
<div className="big-screen-list-body" ref={viewportRef}>
|
||||||
{items.length === 0 ? (
|
{items.length === 0 ? null : (
|
||||||
<div className="big-screen-empty">{loadError || '暂无订单'}</div>
|
|
||||||
) : (
|
|
||||||
<div
|
<div
|
||||||
className={`big-screen-track${rolling ? ' is-rolling' : ''}${paused ? ' is-paused' : ''}`}
|
className={`big-screen-track${rolling ? ' is-rolling' : ''}${paused ? ' is-paused' : ''}`}
|
||||||
style={rolling ? ({ ['--marquee-ms']: `${marqueeMs}ms` } as CSSProperties) : undefined}
|
style={rolling ? ({ ['--marquee-ms']: `${marqueeMs}ms` } as CSSProperties) : undefined}
|
||||||
@@ -522,6 +509,10 @@ export default function BigScreenPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{items.length === 0 ? (
|
||||||
|
<div className="big-screen-empty">{loadError || '当日暂无订单'}</div>
|
||||||
|
) : null}
|
||||||
|
|
||||||
{celebrate ? (
|
{celebrate ? (
|
||||||
<CelebrateFx
|
<CelebrateFx
|
||||||
key={celebrate.id}
|
key={celebrate.id}
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ import { ADMIN_OPTIONS_PAGE_SIZE, CITY_STATUS_LABELS, fmtTime } from '../lib/con
|
|||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
import CityPartnersPanel from '../components/CityPartnersPanel';
|
import CityPartnersPanel from '../components/CityPartnersPanel';
|
||||||
import ChinaProvinceCityCascader from '../components/ChinaProvinceCityCascader';
|
import ChinaProvinceCityCascader from '../components/ChinaProvinceCityCascader';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type WarehouseRow = {
|
type WarehouseRow = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -223,7 +225,7 @@ export default function CitiesPage() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{ title: '编码', dataIndex: 'code', width: 90 },
|
{ title: '编码', dataIndex: 'code', width: 90 },
|
||||||
{ title: '城市', dataIndex: 'name', width: 100 },
|
{ title: '城市', dataIndex: 'name', width: 100 },
|
||||||
{ title: '省份', dataIndex: 'province', width: 90 },
|
{ title: '省份', dataIndex: 'province', width: 90 },
|
||||||
@@ -261,7 +263,7 @@ export default function CitiesPage() {
|
|||||||
|
|
||||||
const warehouseColumns: ColumnsType<WarehouseRow> = [
|
const warehouseColumns: ColumnsType<WarehouseRow> = [
|
||||||
{ title: '仓库名', dataIndex: 'name' },
|
{ title: '仓库名', dataIndex: 'name' },
|
||||||
{ title: '地址', dataIndex: 'address', ellipsis: true },
|
{ title: '地址', dataIndex: 'address' },
|
||||||
{ title: '联系人', dataIndex: 'contactName', width: 90 },
|
{ title: '联系人', dataIndex: 'contactName', width: 90 },
|
||||||
{ title: '电话', dataIndex: 'contactPhone', width: 120 },
|
{ title: '电话', dataIndex: 'contactPhone', width: 120 },
|
||||||
{
|
{
|
||||||
@@ -270,7 +272,7 @@ export default function CitiesPage() {
|
|||||||
width: 100,
|
width: 100,
|
||||||
render: (v: WarehouseManagerType) => WAREHOUSE_MANAGER_LABELS[v] || v,
|
render: (v: WarehouseManagerType) => WAREHOUSE_MANAGER_LABELS[v] || v,
|
||||||
},
|
},
|
||||||
{ title: '合伙人', dataIndex: 'partnerCompanyName', ellipsis: true, render: (v) => v || '—' },
|
{ title: '合伙人', dataIndex: 'partnerCompanyName', render: (v) => v || '—' },
|
||||||
{ title: '状态', dataIndex: 'status', width: 80, render: (s) => <Tag>{s}</Tag> },
|
{ title: '状态', dataIndex: 'status', width: 80, render: (s) => <Tag>{s}</Tag> },
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
@@ -311,10 +313,14 @@ export default function CitiesPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('cities', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>城市</Typography.Title>
|
<Typography.Title level={4} style={{ margin: 0 }}>城市</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Button type="primary" onClick={openCreateModal}>新建城市</Button>
|
<Button type="primary" onClick={openCreateModal}>新建城市</Button>
|
||||||
</Space>
|
</Space>
|
||||||
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
|
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
|
||||||
@@ -325,7 +331,7 @@ export default function CitiesPage() {
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item><Button type="primary" htmlType="submit">查询</Button></Form.Item>
|
<Form.Item><Button type="primary" htmlType="submit">查询</Button></Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
<Table rowKey="id" className="admin-table-nowrap" loading={loading} columns={columns} dataSource={data?.items ?? []}
|
<Table scroll={{ x: 'max-content' }} rowKey="id" className="admin-table-nowrap" loading={loading} columns={columns} dataSource={data?.items ?? []}
|
||||||
pagination={{ current: page, pageSize, total: data?.total ?? 0, showSizeChanger: true, onChange: (p, ps) => { setPage(p); setPageSize(ps); } }} />
|
pagination={{ current: page, pageSize, total: data?.total ?? 0, showSizeChanger: true, onChange: (p, ps) => { setPage(p); setPageSize(ps); } }} />
|
||||||
|
|
||||||
<Drawer title="城市管理" width={720} open={drawerOpen} onClose={() => setDrawerOpen(false)}>
|
<Drawer title="城市管理" width={720} open={drawerOpen} onClose={() => setDrawerOpen(false)}>
|
||||||
@@ -623,9 +629,9 @@ export default function CitiesPage() {
|
|||||||
)}
|
)}
|
||||||
columns={[
|
columns={[
|
||||||
{ title: '类型', dataIndex: 'kind', width: 80 },
|
{ title: '类型', dataIndex: 'kind', width: 80 },
|
||||||
{ title: '名称', dataIndex: 'name', ellipsis: true },
|
{ title: '名称', dataIndex: 'name' },
|
||||||
{ title: '手机号', dataIndex: 'phone', width: 120 },
|
{ title: '手机号', dataIndex: 'phone', width: 120 },
|
||||||
{ title: '归属', dataIndex: 'parent', ellipsis: true },
|
{ title: '归属', dataIndex: 'parent' },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -640,13 +646,12 @@ export default function CitiesPage() {
|
|||||||
locale={{ emptyText: '无门店' }}
|
locale={{ emptyText: '无门店' }}
|
||||||
dataSource={deletePreview.stores}
|
dataSource={deletePreview.stores}
|
||||||
columns={[
|
columns={[
|
||||||
{ title: '门店名', dataIndex: 'name', ellipsis: true },
|
{ title: '门店名', dataIndex: 'name' },
|
||||||
{ title: '电话', dataIndex: 'phone', width: 120 },
|
{ title: '电话', dataIndex: 'phone', width: 120 },
|
||||||
{ title: '状态', dataIndex: 'status', width: 90 },
|
{ title: '状态', dataIndex: 'status', width: 90 },
|
||||||
{
|
{
|
||||||
title: '合伙人',
|
title: '合伙人',
|
||||||
width: 140,
|
width: 140,
|
||||||
ellipsis: true,
|
|
||||||
|
|
||||||
render: (_, r) => r.partnerAccount?.companyName || r.partnerAccount?.phone || '—',
|
render: (_, r) => r.partnerAccount?.companyName || r.partnerAccount?.phone || '—',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
|
|||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
import CityDistrictMultiSelect from '../components/CityDistrictMultiSelect';
|
import CityDistrictMultiSelect from '../components/CityDistrictMultiSelect';
|
||||||
import PartnerSubAccountList, { type PartnerSubAccountRow } from '../components/PartnerSubAccountList';
|
import PartnerSubAccountList, { type PartnerSubAccountRow } from '../components/PartnerSubAccountList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type SubRow = PartnerSubAccountRow;
|
type SubRow = PartnerSubAccountRow;
|
||||||
|
|
||||||
@@ -261,22 +263,20 @@ export default function CityPartnersPage() {
|
|||||||
setCreateMaxRate(Number(cityRes.maxPartnerCommissionRate ?? 0.05));
|
setCreateMaxRate(Number(cityRes.maxPartnerCommissionRate ?? 0.05));
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{ title: '城市', dataIndex: 'cityName', width: 90 },
|
{ title: '城市', dataIndex: 'cityName', width: 90 },
|
||||||
{
|
{
|
||||||
title: '区县',
|
title: '区县',
|
||||||
dataIndex: 'districtCodes',
|
dataIndex: 'districtCodes',
|
||||||
width: 160,
|
width: 160,
|
||||||
ellipsis: true,
|
|
||||||
|
|
||||||
render: (codes: string[] | null | undefined, row) =>
|
render: (codes: string[] | null | undefined, row) =>
|
||||||
row.scopeType === CityPartnerScopeType.CITY_WIDE ? '全城' : formatDistrictLabels(codes),
|
row.scopeType === CityPartnerScopeType.CITY_WIDE ? '全城' : formatDistrictLabels(codes),
|
||||||
{ title: '公司名', dataIndex: 'companyName', ellipsis: true, width: 140 },
|
},
|
||||||
{ title: '公司名', dataIndex: 'companyName', width: 140 },
|
{ title: '公司名', dataIndex: 'companyName', width: 140 },
|
||||||
{
|
{
|
||||||
title: '主账号姓名',
|
title: '主账号姓名',
|
||||||
dataIndex: 'name',
|
dataIndex: 'name',
|
||||||
ellipsis: true,
|
|
||||||
width: 120,
|
width: 120,
|
||||||
|
|
||||||
render: (v, row) => (
|
render: (v, row) => (
|
||||||
@@ -311,7 +311,6 @@ export default function CityPartnersPage() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '管仓仓库',
|
title: '管仓仓库',
|
||||||
ellipsis: true,
|
|
||||||
dataIndex: 'managedWarehouseName',
|
dataIndex: 'managedWarehouseName',
|
||||||
width: 110,
|
width: 110,
|
||||||
|
|
||||||
@@ -338,12 +337,16 @@ export default function CityPartnersPage() {
|
|||||||
管理
|
管理
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
const { columns, settingsButton, settingsModal } = useAdminListColumns('city-partners', baseColumns, { page, pageSize });
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('city-partners', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{settingsModal}
|
{settingsModal}
|
||||||
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
||||||
|
<Typography.Title level={4} style={{ margin: 0 }}>
|
||||||
城市合伙人
|
城市合伙人
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
{settingsButton}
|
{settingsButton}
|
||||||
@@ -427,7 +430,7 @@ export default function CityPartnersPage() {
|
|||||||
<Table
|
<Table
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
className="admin-table-nowrap"
|
className="admin-table-nowrap"
|
||||||
scroll={{ x: 1200 }}
|
loading={loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={toTableRows(data?.items ?? [])}
|
dataSource={toTableRows(data?.items ?? [])}
|
||||||
scroll={{ x: 'max-content' }}
|
scroll={{ x: 'max-content' }}
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ import {
|
|||||||
import { request, type Paginated } from '../lib/api';
|
import { request, type Paginated } from '../lib/api';
|
||||||
import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
|
import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -70,6 +72,7 @@ function FulfillmentFields({
|
|||||||
onModeChange: (mode: WarehouseFulfillmentMode) => void;
|
onModeChange: (mode: WarehouseFulfillmentMode) => void;
|
||||||
}) {
|
}) {
|
||||||
const autoShip = mode === WarehouseFulfillmentMode.API_AUTO;
|
const autoShip = mode === WarehouseFulfillmentMode.API_AUTO;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
@@ -219,7 +222,7 @@ export default function CityWarehousesPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{
|
{
|
||||||
title: '城市',
|
title: '城市',
|
||||||
width: 100,
|
width: 100,
|
||||||
@@ -229,8 +232,8 @@ export default function CityWarehousesPage() {
|
|||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{ title: '仓库', dataIndex: 'name', width: 140, ellipsis: true },
|
{ title: '仓库', dataIndex: 'name', width: 140 },
|
||||||
{ title: '地址', dataIndex: 'address', width: 180, ellipsis: true },
|
{ title: '地址', dataIndex: 'address', width: 180 },
|
||||||
{ title: '联系人', dataIndex: 'contactName', width: 90 },
|
{ title: '联系人', dataIndex: 'contactName', width: 90 },
|
||||||
{ title: '电话', dataIndex: 'contactPhone', width: 120 },
|
{ title: '电话', dataIndex: 'contactPhone', width: 120 },
|
||||||
{
|
{
|
||||||
@@ -242,7 +245,6 @@ export default function CityWarehousesPage() {
|
|||||||
title: '合伙人',
|
title: '合伙人',
|
||||||
dataIndex: 'partnerCompanyName',
|
dataIndex: 'partnerCompanyName',
|
||||||
width: 120,
|
width: 120,
|
||||||
ellipsis: true,
|
|
||||||
render: (v, row) =>
|
render: (v, row) =>
|
||||||
v && row.partnerAccountId ? (
|
v && row.partnerAccountId ? (
|
||||||
<Link to="/city-partners">{v}</Link>
|
<Link to="/city-partners">{v}</Link>
|
||||||
@@ -298,10 +300,17 @@ export default function CityWarehousesPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('city-warehouses', baseColumns, {
|
||||||
|
page,
|
||||||
|
pageSize,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>仓库</Typography.Title>
|
<Typography.Title level={4} style={{ margin: 0 }}>仓库</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -367,7 +376,7 @@ export default function CityWarehousesPage() {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data?.items ?? []}
|
dataSource={data?.items ?? []}
|
||||||
scroll={{ x: 1400 }}
|
scroll={{ x: 'max-content' }}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: page,
|
current: page,
|
||||||
pageSize,
|
pageSize,
|
||||||
|
|||||||
@@ -64,6 +64,20 @@ export default function DashboardPage() {
|
|||||||
const [profile, setProfile] = useState<HqProfile | null>(null);
|
const [profile, setProfile] = useState<HqProfile | null>(null);
|
||||||
const [deploying, setDeploying] = useState(false);
|
const [deploying, setDeploying] = useState(false);
|
||||||
const isSuperAdmin = profile?.adminRole === 'SUPER_ADMIN';
|
const isSuperAdmin = profile?.adminRole === 'SUPER_ADMIN';
|
||||||
|
const keys = profile?.permissionKeys ?? [];
|
||||||
|
const has = (k: string) => keys.includes(k);
|
||||||
|
const cityScoped = !!profile?.cityScoped;
|
||||||
|
const canUsers = has('users');
|
||||||
|
const canOrders = has('orders');
|
||||||
|
const canStores = has('stores');
|
||||||
|
const canStoreAudits = has('store_audits');
|
||||||
|
const canPartners = has('partners');
|
||||||
|
const canPromo = has('promo_codes');
|
||||||
|
const canFinance = has('finance');
|
||||||
|
const canBenefit = has('benefit');
|
||||||
|
const canDeliveries = has('deliveries');
|
||||||
|
const canTickets = has('tickets');
|
||||||
|
const permsReady = profile !== null;
|
||||||
|
|
||||||
const [filterForm] = Form.useForm<{
|
const [filterForm] = Form.useForm<{
|
||||||
range: [Dayjs, Dayjs];
|
range: [Dayjs, Dayjs];
|
||||||
@@ -115,18 +129,26 @@ export default function DashboardPage() {
|
|||||||
.catch(() => {
|
.catch(() => {
|
||||||
setVersionLoading(false);
|
setVersionLoading(false);
|
||||||
});
|
});
|
||||||
|
}, [loadVersion]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!profile) return;
|
||||||
void request<Paginated<CityOption>>(`/admin/cities?pageSize=${ADMIN_OPTIONS_PAGE_SIZE}`)
|
void request<Paginated<CityOption>>(`/admin/cities?pageSize=${ADMIN_OPTIONS_PAGE_SIZE}`)
|
||||||
.then((res) => setCities(res.items ?? []))
|
.then((res) => setCities(res.items ?? []))
|
||||||
.catch(() => setCities([]));
|
.catch(() => setCities([]));
|
||||||
|
if ((profile.permissionKeys ?? []).includes('promo_codes')) {
|
||||||
void request<Paginated<PromoOption>>(`/admin/promo-codes?pageSize=${ADMIN_OPTIONS_PAGE_SIZE}`)
|
void request<Paginated<PromoOption>>(`/admin/promo-codes?pageSize=${ADMIN_OPTIONS_PAGE_SIZE}`)
|
||||||
.then((res) => setPromos(res.items ?? []))
|
.then((res) => setPromos(res.items ?? []))
|
||||||
.catch(() => setPromos([]));
|
.catch(() => setPromos([]));
|
||||||
|
}
|
||||||
|
if ((profile.permissionKeys ?? []).includes('partners')) {
|
||||||
void request<Paginated<{ id: string; companyName?: string | null; name: string }>>(
|
void request<Paginated<{ id: string; companyName?: string | null; name: string }>>(
|
||||||
`/admin/partners?pageSize=${ADMIN_OPTIONS_PAGE_SIZE}`,
|
`/admin/partners?pageSize=${ADMIN_OPTIONS_PAGE_SIZE}`,
|
||||||
)
|
)
|
||||||
.then((res) => setPartners(res.items ?? []))
|
.then((res) => setPartners(res.items ?? []))
|
||||||
.catch(() => setPartners([]));
|
.catch(() => setPartners([]));
|
||||||
}, [loadVersion]);
|
}
|
||||||
|
}, [profile]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void loadAnalytics(filters);
|
void loadAnalytics(filters);
|
||||||
@@ -206,9 +228,19 @@ export default function DashboardPage() {
|
|||||||
|
|
||||||
const byDateOption = useMemo<EChartsOption>(() => {
|
const byDateOption = useMemo<EChartsOption>(() => {
|
||||||
const rows = analytics?.byDate ?? [];
|
const rows = analytics?.byDate ?? [];
|
||||||
|
const legend: string[] = [];
|
||||||
|
const series: EChartsOption['series'] = [];
|
||||||
|
if (canUsers) {
|
||||||
|
legend.push('新增用户');
|
||||||
|
series.push({ name: '新增用户', type: 'line', smooth: true, data: rows.map((r) => r.users) });
|
||||||
|
}
|
||||||
|
if (canOrders) {
|
||||||
|
legend.push('订单数');
|
||||||
|
series.push({ name: '订单数', type: 'line', smooth: true, data: rows.map((r) => r.orders) });
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
tooltip: { trigger: 'axis' },
|
tooltip: { trigger: 'axis' },
|
||||||
legend: { data: ['新增用户', '订单数'] },
|
legend: { data: legend },
|
||||||
grid: { left: 40, right: 20, top: 40, bottom: 40 },
|
grid: { left: 40, right: 20, top: 40, bottom: 40 },
|
||||||
xAxis: {
|
xAxis: {
|
||||||
type: 'category',
|
type: 'category',
|
||||||
@@ -216,18 +248,25 @@ export default function DashboardPage() {
|
|||||||
axisLabel: { rotate: rows.length > 14 ? 45 : 0 },
|
axisLabel: { rotate: rows.length > 14 ? 45 : 0 },
|
||||||
},
|
},
|
||||||
yAxis: { type: 'value', minInterval: 1 },
|
yAxis: { type: 'value', minInterval: 1 },
|
||||||
series: [
|
series,
|
||||||
{ name: '新增用户', type: 'line', smooth: true, data: rows.map((r) => r.users) },
|
|
||||||
{ name: '订单数', type: 'line', smooth: true, data: rows.map((r) => r.orders) },
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
}, [analytics]);
|
}, [analytics, canUsers, canOrders]);
|
||||||
|
|
||||||
const byCityOption = useMemo<EChartsOption>(() => {
|
const byCityOption = useMemo<EChartsOption>(() => {
|
||||||
const rows = analytics?.byCity ?? [];
|
const rows = analytics?.byCity ?? [];
|
||||||
|
const legend: string[] = [];
|
||||||
|
const series: EChartsOption['series'] = [];
|
||||||
|
if (canUsers) {
|
||||||
|
legend.push('用户');
|
||||||
|
series.push({ name: '用户', type: 'bar', data: rows.map((r) => r.users), barMaxWidth: 36 });
|
||||||
|
}
|
||||||
|
if (canOrders) {
|
||||||
|
legend.push('订单');
|
||||||
|
series.push({ name: '订单', type: 'bar', data: rows.map((r) => r.orders), barMaxWidth: 36 });
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
tooltip: { trigger: 'axis' },
|
tooltip: { trigger: 'axis' },
|
||||||
legend: { data: ['用户', '订单'] },
|
legend: { data: legend },
|
||||||
grid: { left: 48, right: 20, top: 40, bottom: 48 },
|
grid: { left: 48, right: 20, top: 40, bottom: 48 },
|
||||||
xAxis: {
|
xAxis: {
|
||||||
type: 'category',
|
type: 'category',
|
||||||
@@ -235,18 +274,25 @@ export default function DashboardPage() {
|
|||||||
axisLabel: { interval: 0, rotate: rows.length > 4 ? 30 : 0 },
|
axisLabel: { interval: 0, rotate: rows.length > 4 ? 30 : 0 },
|
||||||
},
|
},
|
||||||
yAxis: { type: 'value', minInterval: 1 },
|
yAxis: { type: 'value', minInterval: 1 },
|
||||||
series: [
|
series,
|
||||||
{ name: '用户', type: 'bar', data: rows.map((r) => r.users), barMaxWidth: 36 },
|
|
||||||
{ name: '订单', type: 'bar', data: rows.map((r) => r.orders), barMaxWidth: 36 },
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
}, [analytics]);
|
}, [analytics, canUsers, canOrders]);
|
||||||
|
|
||||||
const byPromoOption = useMemo<EChartsOption>(() => {
|
const byPromoOption = useMemo<EChartsOption>(() => {
|
||||||
const rows = analytics?.byPromo ?? [];
|
const rows = analytics?.byPromo ?? [];
|
||||||
|
const legend: string[] = [];
|
||||||
|
const series: EChartsOption['series'] = [];
|
||||||
|
if (canUsers) {
|
||||||
|
legend.push('用户');
|
||||||
|
series.push({ name: '用户', type: 'bar', data: rows.map((r) => r.users), barMaxWidth: 36 });
|
||||||
|
}
|
||||||
|
if (canOrders) {
|
||||||
|
legend.push('订单');
|
||||||
|
series.push({ name: '订单', type: 'bar', data: rows.map((r) => r.orders), barMaxWidth: 36 });
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
tooltip: { trigger: 'axis' },
|
tooltip: { trigger: 'axis' },
|
||||||
legend: { data: ['用户', '订单'] },
|
legend: { data: legend },
|
||||||
grid: { left: 48, right: 20, top: 40, bottom: 64 },
|
grid: { left: 48, right: 20, top: 40, bottom: 64 },
|
||||||
xAxis: {
|
xAxis: {
|
||||||
type: 'category',
|
type: 'category',
|
||||||
@@ -254,18 +300,36 @@ export default function DashboardPage() {
|
|||||||
axisLabel: { interval: 0, rotate: rows.length > 3 ? 30 : 0 },
|
axisLabel: { interval: 0, rotate: rows.length > 3 ? 30 : 0 },
|
||||||
},
|
},
|
||||||
yAxis: { type: 'value', minInterval: 1 },
|
yAxis: { type: 'value', minInterval: 1 },
|
||||||
series: [
|
series,
|
||||||
{ name: '用户', type: 'bar', data: rows.map((r) => r.users), barMaxWidth: 36 },
|
|
||||||
{ name: '订单', type: 'bar', data: rows.map((r) => r.orders), barMaxWidth: 36 },
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
}, [analytics]);
|
}, [analytics, canUsers, canOrders]);
|
||||||
|
|
||||||
const opsByDateOption = useMemo<EChartsOption>(() => {
|
const opsByDateOption = useMemo<EChartsOption>(() => {
|
||||||
const rows = analytics?.byDate ?? [];
|
const rows = analytics?.byDate ?? [];
|
||||||
|
const legend: string[] = [];
|
||||||
|
const series: NonNullable<EChartsOption['series']> = [];
|
||||||
|
if (canPartners) {
|
||||||
|
legend.push('新增合伙人');
|
||||||
|
series.push({ name: '新增合伙人', type: 'line', smooth: true, data: rows.map((r) => r.partners) });
|
||||||
|
}
|
||||||
|
if (canStores) {
|
||||||
|
legend.push('新签门店');
|
||||||
|
series.push({ name: '新签门店', type: 'line', smooth: true, data: rows.map((r) => r.stores) });
|
||||||
|
}
|
||||||
|
if (canBenefit) {
|
||||||
|
legend.push('核销笔数', '核销金额');
|
||||||
|
series.push({ name: '核销笔数', type: 'line', smooth: true, data: rows.map((r) => r.redeems) });
|
||||||
|
series.push({
|
||||||
|
name: '核销金额',
|
||||||
|
type: 'line',
|
||||||
|
smooth: true,
|
||||||
|
yAxisIndex: 1,
|
||||||
|
data: rows.map((r) => r.redeemAmount),
|
||||||
|
});
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
tooltip: { trigger: 'axis' },
|
tooltip: { trigger: 'axis' },
|
||||||
legend: { data: ['新增合伙人', '新签门店', '核销笔数', '核销金额'] },
|
legend: { data: legend },
|
||||||
grid: { left: 48, right: 48, top: 48, bottom: 40 },
|
grid: { left: 48, right: 48, top: 48, bottom: 40 },
|
||||||
xAxis: {
|
xAxis: {
|
||||||
type: 'category',
|
type: 'category',
|
||||||
@@ -276,26 +340,29 @@ export default function DashboardPage() {
|
|||||||
{ type: 'value', name: '数量', minInterval: 1 },
|
{ type: 'value', name: '数量', minInterval: 1 },
|
||||||
{ type: 'value', name: '金额', minInterval: 1 },
|
{ type: 'value', name: '金额', minInterval: 1 },
|
||||||
],
|
],
|
||||||
series: [
|
series,
|
||||||
{ name: '新增合伙人', type: 'line', smooth: true, data: rows.map((r) => r.partners) },
|
|
||||||
{ name: '新签门店', type: 'line', smooth: true, data: rows.map((r) => r.stores) },
|
|
||||||
{ name: '核销笔数', type: 'line', smooth: true, data: rows.map((r) => r.redeems) },
|
|
||||||
{
|
|
||||||
name: '核销金额',
|
|
||||||
type: 'line',
|
|
||||||
smooth: true,
|
|
||||||
yAxisIndex: 1,
|
|
||||||
data: rows.map((r) => r.redeemAmount),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
}, [analytics]);
|
}, [analytics, canPartners, canStores, canBenefit]);
|
||||||
|
|
||||||
const opsByCityOption = useMemo<EChartsOption>(() => {
|
const opsByCityOption = useMemo<EChartsOption>(() => {
|
||||||
const rows = analytics?.byCity ?? [];
|
const rows = analytics?.byCity ?? [];
|
||||||
|
const legend: string[] = [];
|
||||||
|
const series: EChartsOption['series'] = [];
|
||||||
|
if (canPartners) {
|
||||||
|
legend.push('合伙人');
|
||||||
|
series.push({ name: '合伙人', type: 'bar', data: rows.map((r) => r.partners), barMaxWidth: 28 });
|
||||||
|
}
|
||||||
|
if (canStores) {
|
||||||
|
legend.push('门店');
|
||||||
|
series.push({ name: '门店', type: 'bar', data: rows.map((r) => r.stores), barMaxWidth: 28 });
|
||||||
|
}
|
||||||
|
if (canBenefit) {
|
||||||
|
legend.push('核销笔数');
|
||||||
|
series.push({ name: '核销笔数', type: 'bar', data: rows.map((r) => r.redeems), barMaxWidth: 28 });
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
tooltip: { trigger: 'axis' },
|
tooltip: { trigger: 'axis' },
|
||||||
legend: { data: ['合伙人', '门店', '核销笔数'] },
|
legend: { data: legend },
|
||||||
grid: { left: 48, right: 20, top: 40, bottom: 48 },
|
grid: { left: 48, right: 20, top: 40, bottom: 48 },
|
||||||
xAxis: {
|
xAxis: {
|
||||||
type: 'category',
|
type: 'category',
|
||||||
@@ -303,19 +370,31 @@ export default function DashboardPage() {
|
|||||||
axisLabel: { interval: 0, rotate: rows.length > 4 ? 30 : 0 },
|
axisLabel: { interval: 0, rotate: rows.length > 4 ? 30 : 0 },
|
||||||
},
|
},
|
||||||
yAxis: { type: 'value', minInterval: 1 },
|
yAxis: { type: 'value', minInterval: 1 },
|
||||||
series: [
|
series,
|
||||||
{ name: '合伙人', type: 'bar', data: rows.map((r) => r.partners), barMaxWidth: 28 },
|
|
||||||
{ name: '门店', type: 'bar', data: rows.map((r) => r.stores), barMaxWidth: 28 },
|
|
||||||
{ name: '核销笔数', type: 'bar', data: rows.map((r) => r.redeems), barMaxWidth: 28 },
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
}, [analytics]);
|
}, [analytics, canPartners, canStores, canBenefit]);
|
||||||
|
|
||||||
const opsByPartnerOption = useMemo<EChartsOption>(() => {
|
const opsByPartnerOption = useMemo<EChartsOption>(() => {
|
||||||
const rows = analytics?.byPartner ?? [];
|
const rows = analytics?.byPartner ?? [];
|
||||||
|
const legend: string[] = [];
|
||||||
|
const series: NonNullable<EChartsOption['series']> = [];
|
||||||
|
if (canStores) {
|
||||||
|
legend.push('门店');
|
||||||
|
series.push({ name: '门店', type: 'bar', data: rows.map((r) => r.stores), barMaxWidth: 28 });
|
||||||
|
}
|
||||||
|
if (canBenefit) {
|
||||||
|
legend.push('核销笔数', '核销金额');
|
||||||
|
series.push({ name: '核销笔数', type: 'bar', data: rows.map((r) => r.redeems), barMaxWidth: 28 });
|
||||||
|
series.push({
|
||||||
|
name: '核销金额',
|
||||||
|
type: 'line',
|
||||||
|
yAxisIndex: 1,
|
||||||
|
data: rows.map((r) => r.redeemAmount),
|
||||||
|
});
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
tooltip: { trigger: 'axis' },
|
tooltip: { trigger: 'axis' },
|
||||||
legend: { data: ['门店', '核销笔数', '核销金额'] },
|
legend: { data: legend },
|
||||||
grid: { left: 48, right: 48, top: 40, bottom: 64 },
|
grid: { left: 48, right: 48, top: 40, bottom: 64 },
|
||||||
xAxis: {
|
xAxis: {
|
||||||
type: 'category',
|
type: 'category',
|
||||||
@@ -326,18 +405,9 @@ export default function DashboardPage() {
|
|||||||
{ type: 'value', name: '数量', minInterval: 1 },
|
{ type: 'value', name: '数量', minInterval: 1 },
|
||||||
{ type: 'value', name: '金额' },
|
{ type: 'value', name: '金额' },
|
||||||
],
|
],
|
||||||
series: [
|
series,
|
||||||
{ name: '门店', type: 'bar', data: rows.map((r) => r.stores), barMaxWidth: 28 },
|
|
||||||
{ name: '核销笔数', type: 'bar', data: rows.map((r) => r.redeems), barMaxWidth: 28 },
|
|
||||||
{
|
|
||||||
name: '核销金额',
|
|
||||||
type: 'line',
|
|
||||||
yAxisIndex: 1,
|
|
||||||
data: rows.map((r) => r.redeemAmount),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
}, [analytics]);
|
}, [analytics, canStores, canBenefit]);
|
||||||
|
|
||||||
const redeemByCityOption = useMemo<EChartsOption>(() => {
|
const redeemByCityOption = useMemo<EChartsOption>(() => {
|
||||||
const rows = analytics?.byCity ?? [];
|
const rows = analytics?.byCity ?? [];
|
||||||
@@ -368,7 +438,9 @@ export default function DashboardPage() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Typography.Title level={4}>数据概览</Typography.Title>
|
<Typography.Title level={4}>
|
||||||
|
{cityScoped ? '数据概览(负责城市)' : '数据概览'}
|
||||||
|
</Typography.Title>
|
||||||
|
|
||||||
{isSuperAdmin ? (
|
{isSuperAdmin ? (
|
||||||
<Card
|
<Card
|
||||||
@@ -411,46 +483,94 @@ export default function DashboardPage() {
|
|||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
<Row gutter={[16, 16]} style={{ marginBottom: 24 }}>
|
<Row gutter={[16, 16]} style={{ marginBottom: 24 }}>
|
||||||
|
{!permsReady ? (
|
||||||
|
<Col xs={24} sm={12} lg={6}>
|
||||||
|
<Card loading />
|
||||||
|
</Col>
|
||||||
|
) : null}
|
||||||
|
{permsReady && canUsers ? (
|
||||||
<Col xs={24} sm={12} lg={6}>
|
<Col xs={24} sm={12} lg={6}>
|
||||||
<Card loading={loading}>
|
<Card loading={loading}>
|
||||||
<Statistic title="有效用户" value={stats?.usersTotal ?? 0} />
|
<Statistic title="有效用户" value={stats?.usersTotal ?? 0} />
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
|
) : null}
|
||||||
|
{permsReady && canUsers ? (
|
||||||
<Col xs={24} sm={12} lg={6}>
|
<Col xs={24} sm={12} lg={6}>
|
||||||
<Card loading={loading}>
|
<Card loading={loading}>
|
||||||
<Statistic title="访客(未验手机)" value={stats?.guestUsers ?? 0} valueStyle={{ color: '#faad14' }} />
|
<Statistic title="访客(未验手机)" value={stats?.guestUsers ?? 0} valueStyle={{ color: '#faad14' }} />
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
|
) : null}
|
||||||
|
{permsReady && canUsers ? (
|
||||||
<Col xs={24} sm={12} lg={6}>
|
<Col xs={24} sm={12} lg={6}>
|
||||||
<Card loading={loading}>
|
<Card loading={loading}>
|
||||||
<Statistic title="已验手机" value={stats?.verifiedUsers ?? 0} valueStyle={{ color: '#52c41a' }} />
|
<Statistic title="已验手机" value={stats?.verifiedUsers ?? 0} valueStyle={{ color: '#52c41a' }} />
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
|
) : null}
|
||||||
|
{permsReady && canOrders ? (
|
||||||
<Col xs={24} sm={12} lg={6}>
|
<Col xs={24} sm={12} lg={6}>
|
||||||
<Card loading={loading}>
|
<Card loading={loading}>
|
||||||
<Statistic title="今日下单" value={stats?.ordersToday ?? 0} />
|
<Statistic title="今日下单" value={stats?.ordersToday ?? 0} />
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
|
) : null}
|
||||||
|
{permsReady && canStores ? (
|
||||||
<Col xs={24} sm={12} lg={6}>
|
<Col xs={24} sm={12} lg={6}>
|
||||||
<Card loading={loading}>
|
<Card loading={loading}>
|
||||||
<Statistic title="门店" value={stats?.storesTotal ?? 0} />
|
<Statistic title="门店" value={stats?.storesTotal ?? 0} />
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
|
) : null}
|
||||||
|
{permsReady && canStores ? (
|
||||||
|
<Col xs={24} sm={12} lg={6}>
|
||||||
|
<Card loading={loading} extra={<Link to="/stores?auditStatus=PENDING">去处理</Link>}>
|
||||||
|
<Statistic
|
||||||
|
title="待入驻审核"
|
||||||
|
value={stats?.pendingStoreOnboard ?? 0}
|
||||||
|
valueStyle={{ color: (stats?.pendingStoreOnboard ?? 0) > 0 ? '#fa8c16' : undefined }}
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
</Col>
|
||||||
|
) : null}
|
||||||
|
{permsReady && canStoreAudits ? (
|
||||||
|
<Col xs={24} sm={12} lg={6}>
|
||||||
|
<Card loading={loading} extra={<Link to="/store-package-audits">去处理</Link>}>
|
||||||
|
<Statistic
|
||||||
|
title="待套餐/信息审核"
|
||||||
|
value={(stats?.pendingStorePackageAudits ?? 0) + (stats?.pendingStoreInfoChanges ?? 0)}
|
||||||
|
valueStyle={{
|
||||||
|
color:
|
||||||
|
(stats?.pendingStorePackageAudits ?? 0) + (stats?.pendingStoreInfoChanges ?? 0) > 0
|
||||||
|
? '#fa8c16'
|
||||||
|
: undefined,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
</Col>
|
||||||
|
) : null}
|
||||||
|
{permsReady && canPartners ? (
|
||||||
<Col xs={24} sm={12} lg={6}>
|
<Col xs={24} sm={12} lg={6}>
|
||||||
<Card loading={loading}>
|
<Card loading={loading}>
|
||||||
<Statistic title="合伙人" value={stats?.partnersTotal ?? 0} />
|
<Statistic title="合伙人" value={stats?.partnersTotal ?? 0} />
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
|
) : null}
|
||||||
|
{permsReady && canBenefit ? (
|
||||||
<Col xs={24} sm={12} lg={6}>
|
<Col xs={24} sm={12} lg={6}>
|
||||||
<Card loading={loading}>
|
<Card loading={loading}>
|
||||||
<Statistic title="今日核销" value={stats?.redeemToday ?? 0} />
|
<Statistic title="今日核销" value={stats?.redeemToday ?? 0} />
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
|
) : null}
|
||||||
|
{permsReady && canDeliveries ? (
|
||||||
<Col xs={24} sm={12} lg={6}>
|
<Col xs={24} sm={12} lg={6}>
|
||||||
<Card loading={loading}>
|
<Card loading={loading}>
|
||||||
<Statistic title="配送单" value={stats?.deliveriesTotal ?? 0} />
|
<Statistic title="配送单" value={stats?.deliveriesTotal ?? 0} />
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
|
) : null}
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
<Card
|
<Card
|
||||||
@@ -478,14 +598,15 @@ export default function DashboardPage() {
|
|||||||
<Form.Item name="cityId" label="城市">
|
<Form.Item name="cityId" label="城市">
|
||||||
<Select
|
<Select
|
||||||
allowClear
|
allowClear
|
||||||
placeholder="全部开城"
|
placeholder={cityScoped ? '全部负责城市' : '全部开城'}
|
||||||
style={{ width: 160 }}
|
style={{ width: 160 }}
|
||||||
options={[
|
options={[
|
||||||
{ value: 'none', label: '未选城' },
|
...(cityScoped ? [] : [{ value: 'none', label: '未选城' }]),
|
||||||
...cities.map((c) => ({ value: c.id, label: c.name })),
|
...cities.map((c) => ({ value: c.id, label: c.name })),
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
{canPromo ? (
|
||||||
<Form.Item name="promoCodeId" label="推广码">
|
<Form.Item name="promoCodeId" label="推广码">
|
||||||
<Select
|
<Select
|
||||||
allowClear
|
allowClear
|
||||||
@@ -497,6 +618,8 @@ export default function DashboardPage() {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
) : null}
|
||||||
|
{canPartners ? (
|
||||||
<Form.Item name="partnerAccountId" label="合伙人">
|
<Form.Item name="partnerAccountId" label="合伙人">
|
||||||
<Select
|
<Select
|
||||||
allowClear
|
allowClear
|
||||||
@@ -508,32 +631,40 @@ export default function DashboardPage() {
|
|||||||
}))}
|
}))}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
) : null}
|
||||||
<Form.Item>
|
<Form.Item>
|
||||||
<Button type="primary" htmlType="submit">查询</Button>
|
<Button type="primary" htmlType="submit">查询</Button>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
{canUsers || canOrders ? (
|
||||||
<Card
|
<Card
|
||||||
title="用户 / 订单统计"
|
title={canUsers && canOrders ? '用户 / 订单统计' : canUsers ? '用户统计' : '订单统计'}
|
||||||
style={{ marginBottom: 24 }}
|
style={{ marginBottom: 24 }}
|
||||||
extra={
|
extra={
|
||||||
<Space>
|
<Space>
|
||||||
<Link to={`/orders?${ordersDrillQs}`}>查看订单</Link>
|
{canOrders ? <Link to={`/orders?${ordersDrillQs}`}>查看订单</Link> : null}
|
||||||
<Link to="/users">查看用户</Link>
|
{canUsers ? <Link to="/users">查看用户</Link> : null}
|
||||||
</Space>
|
</Space>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Row gutter={[16, 16]} style={{ marginBottom: 16 }}>
|
<Row gutter={[16, 16]} style={{ marginBottom: 16 }}>
|
||||||
|
{canUsers ? (
|
||||||
<Col xs={24} sm={8}>
|
<Col xs={24} sm={8}>
|
||||||
<Statistic title="区间新增用户" value={analytics?.summary.users ?? 0} />
|
<Statistic title="区间新增用户" value={analytics?.summary.users ?? 0} />
|
||||||
</Col>
|
</Col>
|
||||||
|
) : null}
|
||||||
|
{canOrders ? (
|
||||||
<Col xs={24} sm={8}>
|
<Col xs={24} sm={8}>
|
||||||
<Statistic title="区间订单数" value={analytics?.summary.orders ?? 0} />
|
<Statistic title="区间订单数" value={analytics?.summary.orders ?? 0} />
|
||||||
</Col>
|
</Col>
|
||||||
|
) : null}
|
||||||
|
{canOrders ? (
|
||||||
<Col xs={24} sm={8}>
|
<Col xs={24} sm={8}>
|
||||||
<Statistic title="区间付费用户" value={analytics?.summary.payingUsers ?? 0} />
|
<Statistic title="区间付费用户" value={analytics?.summary.payingUsers ?? 0} />
|
||||||
</Col>
|
</Col>
|
||||||
|
) : null}
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
<Row gutter={[16, 16]}>
|
<Row gutter={[16, 16]}>
|
||||||
@@ -542,7 +673,7 @@ export default function DashboardPage() {
|
|||||||
<ReactECharts option={byDateOption} style={{ height: 320 }} notMerge />
|
<ReactECharts option={byDateOption} style={{ height: 320 }} notMerge />
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
<Col xs={24} lg={12}>
|
<Col xs={24} lg={canPromo ? 12 : 24}>
|
||||||
<Card
|
<Card
|
||||||
type="inner"
|
type="inner"
|
||||||
title="按城市(点击柱联动筛选)"
|
title="按城市(点击柱联动筛选)"
|
||||||
@@ -562,6 +693,7 @@ export default function DashboardPage() {
|
|||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
|
{canPromo ? (
|
||||||
<Col xs={24} lg={12}>
|
<Col xs={24} lg={12}>
|
||||||
<Card
|
<Card
|
||||||
type="inner"
|
type="inner"
|
||||||
@@ -584,42 +716,53 @@ export default function DashboardPage() {
|
|||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
|
) : null}
|
||||||
</Row>
|
</Row>
|
||||||
</Card>
|
</Card>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{canPartners || canStores || canBenefit ? (
|
||||||
<Card
|
<Card
|
||||||
title="合伙人 / 门店 / 核销统计"
|
title={[canPartners && '合伙人', canStores && '门店', canBenefit && '核销'].filter(Boolean).join(' / ') + '统计'}
|
||||||
style={{ marginBottom: 24 }}
|
style={{ marginBottom: 24 }}
|
||||||
extra={
|
extra={
|
||||||
<Space>
|
<Space>
|
||||||
<Link to="/city-partners">查看合伙人</Link>
|
{canPartners ? <Link to="/city-partners">查看合伙人</Link> : null}
|
||||||
<Link to="/stores">查看门店</Link>
|
{canStores ? <Link to="/stores">查看门店</Link> : null}
|
||||||
<Link to="/redeem-records">查看核销</Link>
|
{canBenefit ? <Link to="/redeem-records">查看核销</Link> : null}
|
||||||
</Space>
|
</Space>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Row gutter={[16, 16]} style={{ marginBottom: 16 }}>
|
<Row gutter={[16, 16]} style={{ marginBottom: 16 }}>
|
||||||
|
{canPartners ? (
|
||||||
<Col xs={24} sm={6}>
|
<Col xs={24} sm={6}>
|
||||||
<Statistic title="区间新增合伙人" value={analytics?.summary.partners ?? 0} />
|
<Statistic title="区间新增合伙人" value={analytics?.summary.partners ?? 0} />
|
||||||
</Col>
|
</Col>
|
||||||
|
) : null}
|
||||||
|
{canStores ? (
|
||||||
<Col xs={24} sm={6}>
|
<Col xs={24} sm={6}>
|
||||||
<Statistic title="区间新签门店" value={analytics?.summary.stores ?? 0} />
|
<Statistic title="区间新签门店" value={analytics?.summary.stores ?? 0} />
|
||||||
</Col>
|
</Col>
|
||||||
|
) : null}
|
||||||
|
{canBenefit ? (
|
||||||
<Col xs={24} sm={6}>
|
<Col xs={24} sm={6}>
|
||||||
<Statistic title="区间核销笔数" value={analytics?.summary.redeems ?? 0} />
|
<Statistic title="区间核销笔数" value={analytics?.summary.redeems ?? 0} />
|
||||||
</Col>
|
</Col>
|
||||||
|
) : null}
|
||||||
|
{canBenefit ? (
|
||||||
<Col xs={24} sm={6}>
|
<Col xs={24} sm={6}>
|
||||||
<Statistic title="区间核销金额" value={analytics?.summary.redeemAmount ?? 0} precision={2} />
|
<Statistic title="区间核销金额" value={analytics?.summary.redeemAmount ?? 0} precision={2} />
|
||||||
</Col>
|
</Col>
|
||||||
|
) : null}
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
<Row gutter={[16, 16]}>
|
<Row gutter={[16, 16]}>
|
||||||
<Col xs={24}>
|
<Col xs={24}>
|
||||||
<Card type="inner" title="按日趋势(合伙人 / 门店 / 核销)" loading={analyticsLoading} size="small">
|
<Card type="inner" title="按日趋势" loading={analyticsLoading} size="small">
|
||||||
<ReactECharts option={opsByDateOption} style={{ height: 320 }} notMerge />
|
<ReactECharts option={opsByDateOption} style={{ height: 320 }} notMerge />
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
<Col xs={24} lg={12}>
|
<Col xs={24} lg={canBenefit ? 12 : 24}>
|
||||||
<Card
|
<Card
|
||||||
type="inner"
|
type="inner"
|
||||||
title="按城市(点击柱联动筛选)"
|
title="按城市(点击柱联动筛选)"
|
||||||
@@ -639,6 +782,7 @@ export default function DashboardPage() {
|
|||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
|
{canBenefit ? (
|
||||||
<Col xs={24} lg={12}>
|
<Col xs={24} lg={12}>
|
||||||
<Card
|
<Card
|
||||||
type="inner"
|
type="inner"
|
||||||
@@ -659,6 +803,8 @@ export default function DashboardPage() {
|
|||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
|
) : null}
|
||||||
|
{canPartners && (canStores || canBenefit) ? (
|
||||||
<Col xs={24}>
|
<Col xs={24}>
|
||||||
<Card
|
<Card
|
||||||
type="inner"
|
type="inner"
|
||||||
@@ -681,10 +827,14 @@ export default function DashboardPage() {
|
|||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
|
) : null}
|
||||||
</Row>
|
</Row>
|
||||||
</Card>
|
</Card>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{canFinance || canTickets ? (
|
||||||
<Row gutter={[16, 16]} style={{ marginBottom: 24 }}>
|
<Row gutter={[16, 16]} style={{ marginBottom: 24 }}>
|
||||||
|
{canFinance ? (
|
||||||
<Col xs={24} sm={12} lg={8}>
|
<Col xs={24} sm={12} lg={8}>
|
||||||
<Card
|
<Card
|
||||||
loading={loading}
|
loading={loading}
|
||||||
@@ -704,6 +854,8 @@ export default function DashboardPage() {
|
|||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
|
) : null}
|
||||||
|
{canFinance ? (
|
||||||
<Col xs={24} sm={12} lg={8}>
|
<Col xs={24} sm={12} lg={8}>
|
||||||
<Card
|
<Card
|
||||||
loading={loading}
|
loading={loading}
|
||||||
@@ -717,6 +869,8 @@ export default function DashboardPage() {
|
|||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
|
) : null}
|
||||||
|
{canFinance ? (
|
||||||
<Col xs={24} sm={12} lg={8}>
|
<Col xs={24} sm={12} lg={8}>
|
||||||
<Card
|
<Card
|
||||||
loading={loading}
|
loading={loading}
|
||||||
@@ -737,20 +891,28 @@ export default function DashboardPage() {
|
|||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
|
) : null}
|
||||||
|
{canTickets ? (
|
||||||
<Col xs={24} sm={12} lg={8}>
|
<Col xs={24} sm={12} lg={8}>
|
||||||
<Card loading={loading} title="待处理工单">
|
<Card loading={loading} title="待处理工单">
|
||||||
<Statistic value={stats?.openTickets ?? 0} suffix="个" />
|
<Statistic value={stats?.openTickets ?? 0} suffix="个" />
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
|
) : null}
|
||||||
</Row>
|
</Row>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{canUsers || canOrders ? (
|
||||||
<Row gutter={[16, 16]}>
|
<Row gutter={[16, 16]}>
|
||||||
<Col xs={24} lg={12}>
|
{canUsers ? (
|
||||||
|
<Col xs={24} lg={canOrders ? 12 : 24}>
|
||||||
<Card title="已合并访客账号" loading={loading}>
|
<Card title="已合并访客账号" loading={loading}>
|
||||||
<Statistic value={stats?.mergedUsers ?? 0} suffix="个" />
|
<Statistic value={stats?.mergedUsers ?? 0} suffix="个" />
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
<Col xs={24} lg={12}>
|
) : null}
|
||||||
|
{canOrders ? (
|
||||||
|
<Col xs={24} lg={canUsers ? 12 : 24}>
|
||||||
<Card title="订单状态分布" loading={loading}>
|
<Card title="订单状态分布" loading={loading}>
|
||||||
<Table
|
<Table
|
||||||
size="small"
|
size="small"
|
||||||
@@ -768,7 +930,9 @@ export default function DashboardPage() {
|
|||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
|
) : null}
|
||||||
</Row>
|
</Row>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import OrderTrackDrawer from '../components/OrderTrackDrawer';
|
|||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
import { ORDER_STATUS_LABELS, fmtTime } from '../lib/constants';
|
import { ORDER_STATUS_LABELS, fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -59,7 +61,7 @@ export default function DeliveriesPage() {
|
|||||||
setTrackOpen(true);
|
setTrackOpen(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{ title: '订单号', dataIndex: ['order', 'orderNo'], width: 170 },
|
{ title: '订单号', dataIndex: ['order', 'orderNo'], width: 170 },
|
||||||
{ title: 'provider', dataIndex: 'provider', width: 90 },
|
{ title: 'provider', dataIndex: 'provider', width: 90 },
|
||||||
{ title: '运单号', dataIndex: 'trackingNo', width: 140, render: (v) => v || '—' },
|
{ title: '运单号', dataIndex: 'trackingNo', width: 140, render: (v) => v || '—' },
|
||||||
@@ -83,16 +85,20 @@ export default function DeliveriesPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('deliveries', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Typography.Title level={4}>快递/配送单</Typography.Title>
|
<Typography.Title level={4}>快递/配送单</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
|
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
|
||||||
<Form.Item name="orderNo" label="订单号"><Input allowClear /></Form.Item>
|
<Form.Item name="orderNo" label="订单号"><Input allowClear /></Form.Item>
|
||||||
<Form.Item name="provider" label="provider"><Input allowClear placeholder="MOCK" /></Form.Item>
|
<Form.Item name="provider" label="provider"><Input allowClear placeholder="MOCK" /></Form.Item>
|
||||||
<Form.Item name="trackingNo" label="运单号"><Input allowClear /></Form.Item>
|
<Form.Item name="trackingNo" label="运单号"><Input allowClear /></Form.Item>
|
||||||
<Form.Item><Button type="primary" htmlType="submit">查询</Button></Form.Item>
|
<Form.Item><Button type="primary" htmlType="submit">查询</Button></Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
<Table rowKey="id" loading={loading} columns={columns} dataSource={data?.items ?? []} scroll={{ x: 1100 }}
|
<Table rowKey="id" loading={loading} columns={columns} dataSource={data?.items ?? []} scroll={{ x: 'max-content' }}
|
||||||
pagination={{ current: page, pageSize, total: data?.total ?? 0, showSizeChanger: true, onChange: (p, ps) => { setPage(p); setPageSize(ps); } }} />
|
pagination={{ current: page, pageSize, total: data?.total ?? 0, showSizeChanger: true, onChange: (p, ps) => { setPage(p); setPageSize(ps); } }} />
|
||||||
<Drawer title="配送单编辑" width={480} open={drawerOpen} onClose={() => setDrawerOpen(false)}
|
<Drawer title="配送单编辑" width={480} open={drawerOpen} onClose={() => setDrawerOpen(false)}
|
||||||
extra={
|
extra={
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';
|
|||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Form,
|
Form,
|
||||||
|
Image,
|
||||||
Input,
|
Input,
|
||||||
Modal,
|
Modal,
|
||||||
Popconfirm,
|
Popconfirm,
|
||||||
@@ -18,6 +19,7 @@ import {
|
|||||||
DEV_PLAN_TASK_TYPE_LABELS,
|
DEV_PLAN_TASK_TYPE_LABELS,
|
||||||
SUPPORT_TICKET_STATUS_LABELS,
|
SUPPORT_TICKET_STATUS_LABELS,
|
||||||
type DevPlanTaskDto,
|
type DevPlanTaskDto,
|
||||||
|
type DevPlanTaskExportFormat,
|
||||||
type DevPlanTaskStatusDto,
|
type DevPlanTaskStatusDto,
|
||||||
type DevPlanTaskTypeDto,
|
type DevPlanTaskTypeDto,
|
||||||
type DevPlanVersionDto,
|
type DevPlanVersionDto,
|
||||||
@@ -25,7 +27,11 @@ import {
|
|||||||
} from '@dukang/shared-types';
|
} from '@dukang/shared-types';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
|
import { downloadBase64File } from '../lib/exportExcel';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import OssUpload from '../components/OssUpload';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
const TYPE_OPTIONS = (Object.keys(DEV_PLAN_TASK_TYPE_LABELS) as DevPlanTaskTypeDto[]).map((v) => ({
|
const TYPE_OPTIONS = (Object.keys(DEV_PLAN_TASK_TYPE_LABELS) as DevPlanTaskTypeDto[]).map((v) => ({
|
||||||
value: v,
|
value: v,
|
||||||
@@ -56,6 +62,8 @@ export default function DevPlanTasksPage() {
|
|||||||
const [editing, setEditing] = useState<DevPlanTaskDto | null>(null);
|
const [editing, setEditing] = useState<DevPlanTaskDto | null>(null);
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
const [dispatching, setDispatching] = useState(false);
|
const [dispatching, setDispatching] = useState(false);
|
||||||
|
const [exportFormat, setExportFormat] = useState<DevPlanTaskExportFormat>('xlsx');
|
||||||
|
const [exporting, setExporting] = useState(false);
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const [dispatchForm] = Form.useForm<{ supplement?: string }>();
|
const [dispatchForm] = Form.useForm<{ supplement?: string }>();
|
||||||
const [batchForm] = Form.useForm<{ status?: DevPlanTaskStatusDto; versionId?: string }>();
|
const [batchForm] = Form.useForm<{ status?: DevPlanTaskStatusDto; versionId?: string }>();
|
||||||
@@ -88,24 +96,30 @@ export default function DevPlanTasksPage() {
|
|||||||
|
|
||||||
function openCreate() {
|
function openCreate() {
|
||||||
setEditing(null);
|
setEditing(null);
|
||||||
form.setFieldsValue({ content: '', type: 'BUG', status: 'TODO', supportTicketId: undefined });
|
form.setFieldsValue({ content: '', type: 'BUG', status: 'TODO', supportTicketId: undefined, attachmentUrls: [''] });
|
||||||
setModalOpen(true);
|
setModalOpen(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function openEdit(row: DevPlanTaskDto) {
|
function openEdit(row: DevPlanTaskDto) {
|
||||||
setEditing(row);
|
setEditing(row);
|
||||||
form.setFieldsValue({ content: row.content, type: row.type, status: row.status });
|
form.setFieldsValue({
|
||||||
|
content: row.content,
|
||||||
|
type: row.type,
|
||||||
|
status: row.status,
|
||||||
|
attachmentUrls: row.attachmentUrls?.length ? row.attachmentUrls : [''],
|
||||||
|
});
|
||||||
setModalOpen(true);
|
setModalOpen(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function save() {
|
async function save() {
|
||||||
const values = await form.validateFields();
|
const values = await form.validateFields();
|
||||||
|
const attachmentUrls = (values.attachmentUrls ?? []).map((u: string) => u?.trim()).filter(Boolean);
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
try {
|
try {
|
||||||
if (editing) {
|
if (editing) {
|
||||||
await request(`/admin/dev-plan/tasks/${editing.id}`, {
|
await request(`/admin/dev-plan/tasks/${editing.id}`, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
body: JSON.stringify(values),
|
body: JSON.stringify({ ...values, attachmentUrls }),
|
||||||
});
|
});
|
||||||
message.success('已更新');
|
message.success('已更新');
|
||||||
} else {
|
} else {
|
||||||
@@ -115,6 +129,7 @@ export default function DevPlanTasksPage() {
|
|||||||
content: values.content,
|
content: values.content,
|
||||||
type: values.type,
|
type: values.type,
|
||||||
supportTicketId: values.supportTicketId || undefined,
|
supportTicketId: values.supportTicketId || undefined,
|
||||||
|
attachmentUrls,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
message.success('已创建');
|
message.success('已创建');
|
||||||
@@ -199,7 +214,35 @@ export default function DevPlanTasksPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<DevPlanTaskDto> = [
|
async function exportTasks(scope: 'filter' | 'selected') {
|
||||||
|
setExporting(true);
|
||||||
|
try {
|
||||||
|
const result = await request<{
|
||||||
|
filename: string;
|
||||||
|
mimeType: string;
|
||||||
|
contentBase64: string;
|
||||||
|
count: number;
|
||||||
|
}>('/admin/dev-plan/tasks/export', {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({
|
||||||
|
scope,
|
||||||
|
format: exportFormat,
|
||||||
|
ids: scope === 'selected' ? selectedRowKeys : undefined,
|
||||||
|
status: filters.status || undefined,
|
||||||
|
type: filters.type || undefined,
|
||||||
|
keyword: filters.keyword || undefined,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
downloadBase64File(result.contentBase64, result.filename, result.mimeType);
|
||||||
|
message.success(`已导出 ${result.count} 条任务`);
|
||||||
|
} catch (e) {
|
||||||
|
message.error(e instanceof Error ? e.message : '导出失败');
|
||||||
|
} finally {
|
||||||
|
setExporting(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const baseColumns: ColumnsType<DevPlanTaskDto> = [
|
||||||
{ title: '任务号', dataIndex: 'taskNo', width: 160 },
|
{ title: '任务号', dataIndex: 'taskNo', width: 160 },
|
||||||
{
|
{
|
||||||
title: '类型',
|
title: '类型',
|
||||||
@@ -215,7 +258,23 @@ export default function DevPlanTasksPage() {
|
|||||||
<Tag color={STATUS_COLOR[s]}>{DEV_PLAN_TASK_STATUS_LABELS[s]}</Tag>
|
<Tag color={STATUS_COLOR[s]}>{DEV_PLAN_TASK_STATUS_LABELS[s]}</Tag>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{ title: '内容', dataIndex: 'content', ellipsis: true },
|
{ title: '内容', dataIndex: 'content' },
|
||||||
|
{
|
||||||
|
title: '附件',
|
||||||
|
width: 100,
|
||||||
|
render: (_, row) =>
|
||||||
|
row.attachmentUrls?.length ? (
|
||||||
|
<Image.PreviewGroup>
|
||||||
|
<Space size={4}>
|
||||||
|
{row.attachmentUrls.slice(0, 3).map((url) => (
|
||||||
|
<Image key={url} src={url} width={32} height={32} style={{ objectFit: 'cover' }} />
|
||||||
|
))}
|
||||||
|
</Space>
|
||||||
|
</Image.PreviewGroup>
|
||||||
|
) : (
|
||||||
|
'—'
|
||||||
|
),
|
||||||
|
},
|
||||||
{ title: '来源工单', dataIndex: 'supportTicketNo', width: 140, render: (v) => v || '—' },
|
{ title: '来源工单', dataIndex: 'supportTicketNo', width: 140, render: (v) => v || '—' },
|
||||||
{ title: '创建人', dataIndex: 'creatorName', width: 90 },
|
{ title: '创建人', dataIndex: 'creatorName', width: 90 },
|
||||||
{ title: '创建时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
{ title: '创建时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
||||||
@@ -237,13 +296,34 @@ export default function DevPlanTasksPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('dev-plan-tasks', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 16 }}>
|
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 16 }}>
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>
|
<Typography.Title level={4} style={{ margin: 0 }}>
|
||||||
开发计划 · 任务列表
|
开发计划 · 任务列表
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
<Space>
|
{settingsButton}
|
||||||
|
<Space wrap>
|
||||||
|
<Select
|
||||||
|
value={exportFormat}
|
||||||
|
style={{ width: 120 }}
|
||||||
|
onChange={setExportFormat}
|
||||||
|
options={[
|
||||||
|
{ value: 'markdown', label: 'Markdown' },
|
||||||
|
{ value: 'docx', label: 'Word' },
|
||||||
|
{ value: 'xlsx', label: 'Excel' },
|
||||||
|
{ value: 'pdf', label: 'PDF' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<Button loading={exporting} disabled={!selectedRowKeys.length} onClick={() => void exportTasks('selected')}>
|
||||||
|
导出已勾选
|
||||||
|
</Button>
|
||||||
|
<Button loading={exporting} onClick={() => void exportTasks('filter')}>
|
||||||
|
导出全部筛选
|
||||||
|
</Button>
|
||||||
<Button disabled={!selectedRowKeys.length} onClick={openBatchEdit}>
|
<Button disabled={!selectedRowKeys.length} onClick={openBatchEdit}>
|
||||||
批量编辑
|
批量编辑
|
||||||
</Button>
|
</Button>
|
||||||
@@ -287,7 +367,7 @@ export default function DevPlanTasksPage() {
|
|||||||
selectedRowKeys,
|
selectedRowKeys,
|
||||||
onChange: (keys) => setSelectedRowKeys(keys as string[]),
|
onChange: (keys) => setSelectedRowKeys(keys as string[]),
|
||||||
}}
|
}}
|
||||||
scroll={{ x: 1100 }}
|
scroll={{ x: 'max-content' }}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: page,
|
current: page,
|
||||||
pageSize,
|
pageSize,
|
||||||
@@ -333,6 +413,29 @@ export default function DevPlanTasksPage() {
|
|||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
)}
|
)}
|
||||||
|
<Form.Item label="附件图片">
|
||||||
|
<Form.List name="attachmentUrls">
|
||||||
|
{(fields, { add, remove }) => (
|
||||||
|
<>
|
||||||
|
{fields.map((field) => (
|
||||||
|
<Space key={field.key} align="start" style={{ display: 'flex', marginBottom: 8 }}>
|
||||||
|
<Form.Item {...field} style={{ flex: 1, marginBottom: 0 }}>
|
||||||
|
<OssUpload bizType="SUPPORT_TICKET_ATTACHMENT" mediaType="IMAGE" />
|
||||||
|
</Form.Item>
|
||||||
|
{fields.length > 1 ? (
|
||||||
|
<Button type="link" danger onClick={() => remove(field.name)}>
|
||||||
|
删除
|
||||||
|
</Button>
|
||||||
|
) : null}
|
||||||
|
</Space>
|
||||||
|
))}
|
||||||
|
<Button type="dashed" onClick={() => add('')} block>
|
||||||
|
添加图片
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Form.List>
|
||||||
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ import {
|
|||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const STATUS_OPTIONS = (Object.keys(DEV_PLAN_VERSION_STATUS_LABELS) as DevPlanVersionStatusDto[]).map(
|
const STATUS_OPTIONS = (Object.keys(DEV_PLAN_VERSION_STATUS_LABELS) as DevPlanVersionStatusDto[]).map(
|
||||||
@@ -119,7 +121,7 @@ export default function DevPlanVersionsPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<DevPlanVersionDto> = [
|
const baseColumns: ColumnsType<DevPlanVersionDto> = [
|
||||||
{ title: '版本号', dataIndex: 'versionNo', width: 120 },
|
{ title: '版本号', dataIndex: 'versionNo', width: 120 },
|
||||||
{
|
{
|
||||||
title: '状态',
|
title: '状态',
|
||||||
@@ -129,7 +131,7 @@ export default function DevPlanVersionsPage() {
|
|||||||
<Tag color={STATUS_COLOR[s]}>{DEV_PLAN_VERSION_STATUS_LABELS[s]}</Tag>
|
<Tag color={STATUS_COLOR[s]}>{DEV_PLAN_VERSION_STATUS_LABELS[s]}</Tag>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{ title: '内容', dataIndex: 'content', ellipsis: true, render: (v) => v || '—' },
|
{ title: '内容', dataIndex: 'content', render: (v) => v || '—' },
|
||||||
{ title: '开发起始', dataIndex: 'devStartedAt', width: 160, render: (v) => (v ? fmtTime(v) : '—') },
|
{ title: '开发起始', dataIndex: 'devStartedAt', width: 160, render: (v) => (v ? fmtTime(v) : '—') },
|
||||||
{ title: '开发完成', dataIndex: 'devCompletedAt', width: 160, render: (v) => (v ? fmtTime(v) : '—') },
|
{ title: '开发完成', dataIndex: 'devCompletedAt', width: 160, render: (v) => (v ? fmtTime(v) : '—') },
|
||||||
{ title: '上线时间', dataIndex: 'releasedAt', width: 160, render: (v) => (v ? fmtTime(v) : '—') },
|
{ title: '上线时间', dataIndex: 'releasedAt', width: 160, render: (v) => (v ? fmtTime(v) : '—') },
|
||||||
@@ -158,12 +160,16 @@ export default function DevPlanVersionsPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('dev-plan-versions', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 16 }}>
|
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 16 }}>
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>
|
<Typography.Title level={4} style={{ margin: 0 }}>
|
||||||
开发计划 · 版本列表
|
开发计划 · 版本列表
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Button type="primary" onClick={openCreate}>
|
<Button type="primary" onClick={openCreate}>
|
||||||
新建版本
|
新建版本
|
||||||
</Button>
|
</Button>
|
||||||
@@ -190,7 +196,7 @@ export default function DevPlanVersionsPage() {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data?.items ?? []}
|
dataSource={data?.items ?? []}
|
||||||
scroll={{ x: 1100 }}
|
scroll={{ x: 'max-content' }}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: page,
|
current: page,
|
||||||
pageSize,
|
pageSize,
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import { Card, Descriptions, Drawer, Select, Space, Table, Tag } from 'antd';
|
|||||||
import type { ColumnsType } from 'antd/es/table';
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -55,7 +57,7 @@ export default function DomainEventsPage() {
|
|||||||
load();
|
load();
|
||||||
}, [load]);
|
}, [load]);
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{ title: '时间', dataIndex: 'createdAt', width: 170, render: (v) => fmtTime(v) },
|
{ title: '时间', dataIndex: 'createdAt', width: 170, render: (v) => fmtTime(v) },
|
||||||
{ title: '类型', dataIndex: 'eventType', width: 130, render: (v) => <Tag>{v}</Tag> },
|
{ title: '类型', dataIndex: 'eventType', width: 130, render: (v) => <Tag>{v}</Tag> },
|
||||||
{ title: '关联', render: (_, r) => `${r.refType} #${r.refId}` },
|
{ title: '关联', render: (_, r) => `${r.refType} #${r.refId}` },
|
||||||
@@ -76,8 +78,13 @@ export default function DomainEventsPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const page = Number(params.get('page') ?? 1);
|
||||||
|
const pageSize = data?.pageSize ?? 20;
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('logs-domain-events', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card title="领域事件">
|
<Card title="领域事件" extra={settingsButton}>
|
||||||
|
{settingsModal}
|
||||||
<Space wrap style={{ marginBottom: 16 }}>
|
<Space wrap style={{ marginBottom: 16 }}>
|
||||||
<Select
|
<Select
|
||||||
style={{ width: 180 }}
|
style={{ width: 180 }}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import {
|
|||||||
} from '@dukang/shared-types';
|
} from '@dukang/shared-types';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
const TYPE_OPTIONS = Object.entries(FULFILLMENT_PROVIDER_TYPE_LABELS).map(([value, label]) => ({
|
const TYPE_OPTIONS = Object.entries(FULFILLMENT_PROVIDER_TYPE_LABELS).map(([value, label]) => ({
|
||||||
value,
|
value,
|
||||||
@@ -173,7 +175,7 @@ export default function FulfillmentProvidersPage() {
|
|||||||
void load();
|
void load();
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<FulfillmentProviderDto> = [
|
const baseColumns: ColumnsType<FulfillmentProviderDto> = [
|
||||||
{ title: '编码', dataIndex: 'code', width: 100 },
|
{ title: '编码', dataIndex: 'code', width: 100 },
|
||||||
{ title: '名称', dataIndex: 'name' },
|
{ title: '名称', dataIndex: 'name' },
|
||||||
{
|
{
|
||||||
@@ -230,13 +232,20 @@ export default function FulfillmentProvidersPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('fulfillment-providers', baseColumns, {
|
||||||
|
page: 1,
|
||||||
|
pageSize: rows.length || 20,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
||||||
<div>
|
<div>
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>
|
<Typography.Title level={4} style={{ margin: 0 }}>
|
||||||
仓配管理
|
仓配管理
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Typography.Text type="secondary">
|
<Typography.Text type="secondary">
|
||||||
注册承运商接口凭证,并配置物流对账用的银行账户、结算方式与计价标准
|
注册承运商接口凭证,并配置物流对账用的银行账户、结算方式与计价标准
|
||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
@@ -253,7 +262,7 @@ export default function FulfillmentProvidersPage() {
|
|||||||
message="小飞侠默认计价:2瓶6元,加一瓶+2元,6瓶一箱14元。财务对账见「财务 → 物流对账」。"
|
message="小飞侠默认计价:2瓶6元,加一瓶+2元,6瓶一箱14元。财务对账见「财务 → 物流对账」。"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Table rowKey="id" loading={loading} columns={columns} dataSource={rows} pagination={false} />
|
<Table scroll={{ x: 'max-content' }} rowKey="id" loading={loading} columns={columns} dataSource={rows} pagination={false} />
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
title={editRow ? '编辑承运商' : '注册承运商'}
|
title={editRow ? '编辑承运商' : '注册承运商'}
|
||||||
|
|||||||
@@ -3,9 +3,12 @@ import {
|
|||||||
Button, Drawer, Form, Input, Modal, Radio, Select, Space, Table, Tag, Typography, message,
|
Button, Drawer, Form, Input, Modal, Radio, Select, Space, Table, Tag, Typography, message,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import type { ColumnsType } from 'antd/es/table';
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
import { request, type HqProfile } from '../lib/api';
|
import { HQ_ADMIN_ROLES } from '@dukang/shared-types';
|
||||||
import { ACCOUNT_STATUS_LABELS, fmtTime } from '../lib/constants';
|
import { request, type HqProfile, type Paginated } from '../lib/api';
|
||||||
|
import { ACCOUNT_STATUS_LABELS, ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -17,14 +20,13 @@ type Row = {
|
|||||||
status: string;
|
status: string;
|
||||||
lastLoginAt: string | null;
|
lastLoginAt: string | null;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
|
cityIds?: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
const ROLE_LABELS: Record<string, string> = {
|
type CityOption = { id: string; name: string };
|
||||||
SUPER_ADMIN: '超级管理员',
|
|
||||||
OPS: '运营',
|
const ROLE_OPTIONS = HQ_ADMIN_ROLES.map((r) => ({ value: r.value, label: r.label }));
|
||||||
FINANCE: '财务',
|
const ROLE_LABELS = Object.fromEntries(HQ_ADMIN_ROLES.map((r) => [r.value, r.label]));
|
||||||
CUSTOMER_SERVICE: '客服',
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function HqAccountsPage() {
|
export default function HqAccountsPage() {
|
||||||
const [profile, setProfile] = useState<HqProfile | null>(null);
|
const [profile, setProfile] = useState<HqProfile | null>(null);
|
||||||
@@ -46,14 +48,27 @@ export default function HqAccountsPage() {
|
|||||||
const [detail, setDetail] = useState<Row | null>(null);
|
const [detail, setDetail] = useState<Row | null>(null);
|
||||||
const [drawerOpen, setDrawerOpen] = useState(false);
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
||||||
const [createOpen, setCreateOpen] = useState(false);
|
const [createOpen, setCreateOpen] = useState(false);
|
||||||
|
const [saving, setSaving] = useState(false);
|
||||||
|
const [cities, setCities] = useState<CityOption[]>([]);
|
||||||
const credentialType = Form.useWatch('credentialType', createForm) ?? 'phone';
|
const credentialType = Form.useWatch('credentialType', createForm) ?? 'phone';
|
||||||
|
const editRole = Form.useWatch('adminRole', editForm);
|
||||||
|
const createRole = Form.useWatch('adminRole', createForm);
|
||||||
const isSuperAdmin = profile?.adminRole === 'SUPER_ADMIN';
|
const isSuperAdmin = profile?.adminRole === 'SUPER_ADMIN';
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
request<HqProfile>('/admin/auth/me').then(setProfile).catch(() => {});
|
request<HqProfile>('/admin/auth/me').then(setProfile).catch(() => {});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
useEffect(() => {
|
||||||
|
if (!isSuperAdmin) return;
|
||||||
|
request<Paginated<CityOption>>(`/admin/cities?pageSize=${ADMIN_OPTIONS_PAGE_SIZE}`)
|
||||||
|
.then((res) => setCities(res.items))
|
||||||
|
.catch(() => {});
|
||||||
|
}, [isSuperAdmin]);
|
||||||
|
|
||||||
|
const cityOptions = cities.map((c) => ({ value: c.id, label: c.name }));
|
||||||
|
|
||||||
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{ title: '姓名', dataIndex: 'name' },
|
{ title: '姓名', dataIndex: 'name' },
|
||||||
{ title: '用户名', dataIndex: 'loginName', width: 120, render: (v) => v || '—' },
|
{ title: '用户名', dataIndex: 'loginName', width: 120, render: (v) => v || '—' },
|
||||||
{ title: '手机', dataIndex: 'phone', width: 130 },
|
{ title: '手机', dataIndex: 'phone', width: 130 },
|
||||||
@@ -67,7 +82,18 @@ export default function HqAccountsPage() {
|
|||||||
</Space>
|
</Space>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{ title: '角色', dataIndex: 'adminRole', width: 110, render: (r) => ROLE_LABELS[r] || r },
|
{ title: '角色', dataIndex: 'adminRole', width: 130, render: (r) => ROLE_LABELS[r] || r },
|
||||||
|
{
|
||||||
|
title: '城市',
|
||||||
|
width: 160,
|
||||||
|
render: (_, r) => {
|
||||||
|
if (!r.cityIds?.length) return <Typography.Text type="secondary">全国</Typography.Text>;
|
||||||
|
const names = r.cityIds
|
||||||
|
.map((id) => cities.find((c) => c.id === id)?.name || id)
|
||||||
|
.join('、');
|
||||||
|
return names;
|
||||||
|
},
|
||||||
|
},
|
||||||
{ title: '状态', dataIndex: 'status', width: 90, render: (s) => <Tag>{ACCOUNT_STATUS_LABELS[s] || s}</Tag> },
|
{ title: '状态', dataIndex: 'status', width: 90, render: (s) => <Tag>{ACCOUNT_STATUS_LABELS[s] || s}</Tag> },
|
||||||
{ title: '最后登录', dataIndex: 'lastLoginAt', width: 160, render: fmtTime },
|
{ title: '最后登录', dataIndex: 'lastLoginAt', width: 160, render: fmtTime },
|
||||||
{
|
{
|
||||||
@@ -81,6 +107,7 @@ export default function HqAccountsPage() {
|
|||||||
loginName: row.loginName,
|
loginName: row.loginName,
|
||||||
adminRole: row.adminRole,
|
adminRole: row.adminRole,
|
||||||
status: row.status,
|
status: row.status,
|
||||||
|
cityIds: row.cityIds ?? [],
|
||||||
});
|
});
|
||||||
setDrawerOpen(true);
|
setDrawerOpen(true);
|
||||||
}}>编辑</Button>
|
}}>编辑</Button>
|
||||||
@@ -88,16 +115,20 @@ export default function HqAccountsPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('hq-accounts', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>HQ 账户</Typography.Title>
|
<Typography.Title level={4} style={{ margin: 0 }}>HQ 账户</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
{isSuperAdmin && (
|
{isSuperAdmin && (
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
createForm.resetFields();
|
createForm.resetFields();
|
||||||
createForm.setFieldsValue({ credentialType: 'phone', adminRole: 'OPS' });
|
createForm.setFieldsValue({ credentialType: 'phone', adminRole: 'OPS', cityIds: [] });
|
||||||
setCreateOpen(true);
|
setCreateOpen(true);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -108,23 +139,31 @@ export default function HqAccountsPage() {
|
|||||||
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
|
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
|
||||||
<Form.Item name="phone" label="手机"><Input allowClear /></Form.Item>
|
<Form.Item name="phone" label="手机"><Input allowClear /></Form.Item>
|
||||||
<Form.Item name="adminRole" label="角色">
|
<Form.Item name="adminRole" label="角色">
|
||||||
<Select allowClear style={{ width: 120 }} options={Object.entries(ROLE_LABELS).map(([value, label]) => ({ value, label }))} />
|
<Select allowClear style={{ width: 160 }} options={ROLE_OPTIONS} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item><Button type="primary" htmlType="submit">查询</Button></Form.Item>
|
<Form.Item><Button type="primary" htmlType="submit">查询</Button></Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
<Table rowKey="id" loading={loading} columns={columns} dataSource={data?.items ?? []}
|
<Table scroll={{ x: 'max-content' }} rowKey="id" loading={loading} columns={columns} dataSource={data?.items ?? []}
|
||||||
pagination={{ current: page, pageSize, total: data?.total ?? 0, showSizeChanger: true, onChange: (p, ps) => { setPage(p); setPageSize(ps); } }} />
|
pagination={{ current: page, pageSize, total: data?.total ?? 0, showSizeChanger: true, onChange: (p, ps) => { setPage(p); setPageSize(ps); } }} />
|
||||||
<Drawer title="编辑 HQ 账户" width={420} open={drawerOpen} onClose={() => setDrawerOpen(false)}
|
<Drawer title="编辑 HQ 账户" width={460} open={drawerOpen} onClose={() => setDrawerOpen(false)}
|
||||||
extra={
|
extra={
|
||||||
<Button type="primary" onClick={async () => {
|
<Button type="primary" loading={saving} onClick={async () => {
|
||||||
if (!detail) return;
|
if (!detail) return;
|
||||||
|
try {
|
||||||
const v = await editForm.validateFields();
|
const v = await editForm.validateFields();
|
||||||
const payload = { ...v };
|
const payload: Record<string, unknown> = { ...v };
|
||||||
if (!payload.password) delete payload.password;
|
if (!payload.password) delete payload.password;
|
||||||
|
if (!String(payload.loginName ?? '').trim()) delete payload.loginName;
|
||||||
|
setSaving(true);
|
||||||
await request(`/admin/hq-accounts/${detail.id}`, { method: 'PUT', body: JSON.stringify(payload) });
|
await request(`/admin/hq-accounts/${detail.id}`, { method: 'PUT', body: JSON.stringify(payload) });
|
||||||
message.success('已保存');
|
message.success('已保存');
|
||||||
setDrawerOpen(false);
|
setDrawerOpen(false);
|
||||||
void reload();
|
void reload();
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof Error && e.message) message.error(e.message);
|
||||||
|
} finally {
|
||||||
|
setSaving(false);
|
||||||
|
}
|
||||||
}}>保存</Button>
|
}}>保存</Button>
|
||||||
}>
|
}>
|
||||||
<Form form={editForm} layout="vertical">
|
<Form form={editForm} layout="vertical">
|
||||||
@@ -144,7 +183,15 @@ export default function HqAccountsPage() {
|
|||||||
<Input.Password placeholder="至少 6 位" />
|
<Input.Password placeholder="至少 6 位" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="adminRole" label="角色">
|
<Form.Item name="adminRole" label="角色">
|
||||||
<Select options={Object.entries(ROLE_LABELS).map(([value, label]) => ({ value, label }))} />
|
<Select options={ROLE_OPTIONS} />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
name="cityIds"
|
||||||
|
label="负责城市"
|
||||||
|
extra={editRole === 'CITY_STORE_SERVICE' ? '城市门店服务必须至少选一个城市' : '不选表示全国可见'}
|
||||||
|
rules={editRole === 'CITY_STORE_SERVICE' ? [{ required: true, type: 'array', min: 1, message: '请至少勾选一个城市' }] : []}
|
||||||
|
>
|
||||||
|
<Select mode="multiple" allowClear showSearch optionFilterProp="label" placeholder="不选=全国" options={cityOptions} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="status" label="状态">
|
<Form.Item name="status" label="状态">
|
||||||
<Select options={Object.entries(ACCOUNT_STATUS_LABELS).map(([value, label]) => ({ value, label }))} />
|
<Select options={Object.entries(ACCOUNT_STATUS_LABELS).map(([value, label]) => ({ value, label }))} />
|
||||||
@@ -156,15 +203,19 @@ export default function HqAccountsPage() {
|
|||||||
open={createOpen}
|
open={createOpen}
|
||||||
onCancel={() => setCreateOpen(false)}
|
onCancel={() => setCreateOpen(false)}
|
||||||
onOk={async () => {
|
onOk={async () => {
|
||||||
|
try {
|
||||||
const v = await createForm.validateFields();
|
const v = await createForm.validateFields();
|
||||||
await request('/admin/hq-accounts', { method: 'POST', body: JSON.stringify(v) });
|
await request('/admin/hq-accounts', { method: 'POST', body: JSON.stringify(v) });
|
||||||
message.success('已创建');
|
message.success('已创建');
|
||||||
setCreateOpen(false);
|
setCreateOpen(false);
|
||||||
createForm.resetFields();
|
createForm.resetFields();
|
||||||
void reload();
|
void reload();
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof Error && e.message) message.error(e.message);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Form form={createForm} layout="vertical" initialValues={{ credentialType: 'phone', adminRole: 'OPS' }}>
|
<Form form={createForm} layout="vertical" initialValues={{ credentialType: 'phone', adminRole: 'OPS', cityIds: [] }}>
|
||||||
<Form.Item name="credentialType" label="创建方式">
|
<Form.Item name="credentialType" label="创建方式">
|
||||||
<Radio.Group>
|
<Radio.Group>
|
||||||
<Radio value="phone">手机号账户(短信登录)</Radio>
|
<Radio value="phone">手机号账户(短信登录)</Radio>
|
||||||
@@ -173,7 +224,15 @@ export default function HqAccountsPage() {
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="name" label="姓名" rules={[{ required: true }]}><Input /></Form.Item>
|
<Form.Item name="name" label="姓名" rules={[{ required: true }]}><Input /></Form.Item>
|
||||||
<Form.Item name="adminRole" label="角色">
|
<Form.Item name="adminRole" label="角色">
|
||||||
<Select options={Object.entries(ROLE_LABELS).map(([value, label]) => ({ value, label }))} />
|
<Select options={ROLE_OPTIONS} />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
name="cityIds"
|
||||||
|
label="负责城市"
|
||||||
|
extra={createRole === 'CITY_STORE_SERVICE' ? '城市门店服务必须至少选一个城市' : '不选表示全国可见'}
|
||||||
|
rules={createRole === 'CITY_STORE_SERVICE' ? [{ required: true, type: 'array', min: 1, message: '请至少勾选一个城市' }] : []}
|
||||||
|
>
|
||||||
|
<Select mode="multiple" allowClear showSearch optionFilterProp="label" placeholder="不选=全国" options={cityOptions} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
{credentialType === 'phone' ? (
|
{credentialType === 'phone' ? (
|
||||||
<Form.Item name="phone" label="手机号" rules={[{ required: true, message: '请输入手机号' }]}>
|
<Form.Item name="phone" label="手机号" rules={[{ required: true, message: '请输入手机号' }]}>
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import { AdminCellLine } from '../components/AdminCellLine';
|
|||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
import { HQ_OPERATION_ACTION_OPTIONS, resolveHqOperationLabel } from '../lib/hq-log';
|
import { HQ_OPERATION_ACTION_OPTIONS, resolveHqOperationLabel } from '../lib/hq-log';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -52,12 +54,11 @@ export default function HqLogsPage() {
|
|||||||
form.setFieldsValue(filters);
|
form.setFieldsValue(filters);
|
||||||
}, [form, filters]);
|
}, [form, filters]);
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{ title: '时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
{ title: '时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
||||||
{
|
{
|
||||||
title: '操作人',
|
title: '操作人',
|
||||||
width: 200,
|
width: 200,
|
||||||
ellipsis: true,
|
|
||||||
|
|
||||||
render: (_, r) => (
|
render: (_, r) => (
|
||||||
<AdminCellLine
|
<AdminCellLine
|
||||||
@@ -92,9 +93,13 @@ export default function HqLogsPage() {
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('logs-hq', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<div>
|
||||||
{settingsModal}
|
{settingsModal}
|
||||||
|
<Typography.Title level={4}>HQ 操作日志</Typography.Title>
|
||||||
{settingsButton}
|
{settingsButton}
|
||||||
<Typography.Paragraph type="secondary">
|
<Typography.Paragraph type="secondary">
|
||||||
记录总部后台写操作(开城、订单、用户、权限、合伙人等),仅追加不删除。
|
记录总部后台写操作(开城、订单、用户、权限、合伙人等),仅追加不删除。
|
||||||
@@ -150,7 +155,7 @@ export default function HqLogsPage() {
|
|||||||
rowKey="id"
|
rowKey="id"
|
||||||
loading={loading}
|
loading={loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
scroll={{ x: 900 }}
|
dataSource={data?.items ?? []}
|
||||||
scroll={{ x: 'max-content' }}
|
scroll={{ x: 'max-content' }}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: page,
|
current: page,
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
HQ_ADMIN_ROLES,
|
HQ_ADMIN_ROLES,
|
||||||
HQ_PERMISSION_CATALOG,
|
HQ_PERMISSION_CATALOG,
|
||||||
|
computeHqEffectivePermissionKeys,
|
||||||
type HqPermissionKey,
|
type HqPermissionKey,
|
||||||
} from '@dukang/shared-types';
|
} from '@dukang/shared-types';
|
||||||
import { request, type HqProfile } from '../lib/api';
|
import { request, type HqProfile } from '../lib/api';
|
||||||
@@ -27,6 +28,8 @@ type AccountPermRes = {
|
|||||||
account: AccountOption;
|
account: AccountOption;
|
||||||
permissionKeys: string[];
|
permissionKeys: string[];
|
||||||
rolePermissionKeys: string[];
|
rolePermissionKeys: string[];
|
||||||
|
grantKeys?: string[];
|
||||||
|
denyKeys?: string[];
|
||||||
userPermissionKeys: string[];
|
userPermissionKeys: string[];
|
||||||
effectivePermissionKeys: string[];
|
effectivePermissionKeys: string[];
|
||||||
};
|
};
|
||||||
@@ -46,11 +49,17 @@ function PermissionChecklist({
|
|||||||
value,
|
value,
|
||||||
onChange,
|
onChange,
|
||||||
disabled,
|
disabled,
|
||||||
|
roleKeys,
|
||||||
|
grantKeys,
|
||||||
}: {
|
}: {
|
||||||
value: string[];
|
value: string[];
|
||||||
onChange: (keys: string[]) => void;
|
onChange: (keys: string[]) => void;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
roleKeys?: string[];
|
||||||
|
grantKeys?: string[];
|
||||||
}) {
|
}) {
|
||||||
|
const roleSet = new Set(roleKeys ?? []);
|
||||||
|
const grantSet = new Set(grantKeys ?? []);
|
||||||
return (
|
return (
|
||||||
<Checkbox.Group
|
<Checkbox.Group
|
||||||
style={{ width: '100%' }}
|
style={{ width: '100%' }}
|
||||||
@@ -81,6 +90,13 @@ function PermissionChecklist({
|
|||||||
{items.map((item) => (
|
{items.map((item) => (
|
||||||
<Checkbox key={item.key} value={item.key}>
|
<Checkbox key={item.key} value={item.key}>
|
||||||
{item.label}
|
{item.label}
|
||||||
|
{roleSet.has(item.key) && !value.includes(item.key) ? (
|
||||||
|
<Tag style={{ marginLeft: 6 }} color="red">已撤销</Tag>
|
||||||
|
) : grantSet.has(item.key) ? (
|
||||||
|
<Tag style={{ marginLeft: 6 }} color="orange">追加</Tag>
|
||||||
|
) : roleSet.has(item.key) ? (
|
||||||
|
<Tag style={{ marginLeft: 6 }} color="blue">角色</Tag>
|
||||||
|
) : null}
|
||||||
</Checkbox>
|
</Checkbox>
|
||||||
))}
|
))}
|
||||||
</Space>
|
</Space>
|
||||||
@@ -88,7 +104,16 @@ function PermissionChecklist({
|
|||||||
<Row gutter={[12, 10]}>
|
<Row gutter={[12, 10]}>
|
||||||
{items.map((item) => (
|
{items.map((item) => (
|
||||||
<Col key={item.key} xs={24} sm={12} md={span}>
|
<Col key={item.key} xs={24} sm={12} md={span}>
|
||||||
<Checkbox value={item.key}>{item.label}</Checkbox>
|
<Checkbox value={item.key}>
|
||||||
|
{item.label}
|
||||||
|
{roleSet.has(item.key) && !value.includes(item.key) ? (
|
||||||
|
<Tag style={{ marginLeft: 6 }} color="red">已撤销</Tag>
|
||||||
|
) : grantSet.has(item.key) ? (
|
||||||
|
<Tag style={{ marginLeft: 6 }} color="orange">追加</Tag>
|
||||||
|
) : roleSet.has(item.key) ? (
|
||||||
|
<Tag style={{ marginLeft: 6 }} color="blue">角色</Tag>
|
||||||
|
) : null}
|
||||||
|
</Checkbox>
|
||||||
</Col>
|
</Col>
|
||||||
))}
|
))}
|
||||||
</Row>
|
</Row>
|
||||||
@@ -100,6 +125,14 @@ function PermissionChecklist({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function splitAccountOverrides(roleKeys: string[], effectiveKeys: string[]) {
|
||||||
|
const roleSet = new Set(roleKeys);
|
||||||
|
const effectiveSet = new Set(effectiveKeys);
|
||||||
|
const grantKeys = effectiveKeys.filter((k) => !roleSet.has(k));
|
||||||
|
const denyKeys = roleKeys.filter((k) => !effectiveSet.has(k));
|
||||||
|
return { grantKeys, denyKeys };
|
||||||
|
}
|
||||||
|
|
||||||
export default function HqPermissionsPage() {
|
export default function HqPermissionsPage() {
|
||||||
const [profile, setProfile] = useState<HqProfile | null>(null);
|
const [profile, setProfile] = useState<HqProfile | null>(null);
|
||||||
const [role, setRole] = useState<string>('OPS');
|
const [role, setRole] = useState<string>('OPS');
|
||||||
@@ -111,6 +144,8 @@ export default function HqPermissionsPage() {
|
|||||||
const [accountId, setAccountId] = useState<string>();
|
const [accountId, setAccountId] = useState<string>();
|
||||||
const [accountKeys, setAccountKeys] = useState<string[]>([]);
|
const [accountKeys, setAccountKeys] = useState<string[]>([]);
|
||||||
const [roleInheritedKeys, setRoleInheritedKeys] = useState<string[]>([]);
|
const [roleInheritedKeys, setRoleInheritedKeys] = useState<string[]>([]);
|
||||||
|
const [grantKeys, setGrantKeys] = useState<string[]>([]);
|
||||||
|
const [denyKeys, setDenyKeys] = useState<string[]>([]);
|
||||||
const [accountLoading, setAccountLoading] = useState(false);
|
const [accountLoading, setAccountLoading] = useState(false);
|
||||||
const [accountSaving, setAccountSaving] = useState(false);
|
const [accountSaving, setAccountSaving] = useState(false);
|
||||||
|
|
||||||
@@ -121,8 +156,8 @@ export default function HqPermissionsPage() {
|
|||||||
const selectedIsSuperAdmin = selectedAccount?.adminRole === 'SUPER_ADMIN';
|
const selectedIsSuperAdmin = selectedAccount?.adminRole === 'SUPER_ADMIN';
|
||||||
|
|
||||||
const previewEffectiveKeys = useMemo(
|
const previewEffectiveKeys = useMemo(
|
||||||
() => [...new Set([...roleInheritedKeys, ...accountKeys])],
|
() => computeHqEffectivePermissionKeys(roleInheritedKeys, grantKeys, denyKeys),
|
||||||
[roleInheritedKeys, accountKeys],
|
[roleInheritedKeys, grantKeys, denyKeys],
|
||||||
);
|
);
|
||||||
|
|
||||||
const isSuperAdmin = profile?.adminRole === 'SUPER_ADMIN';
|
const isSuperAdmin = profile?.adminRole === 'SUPER_ADMIN';
|
||||||
@@ -151,8 +186,10 @@ export default function HqPermissionsPage() {
|
|||||||
setAccountLoading(true);
|
setAccountLoading(true);
|
||||||
request<AccountPermRes>(`/admin/hq-permissions/accounts/${accountId}`)
|
request<AccountPermRes>(`/admin/hq-permissions/accounts/${accountId}`)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
setAccountKeys(res.userPermissionKeys);
|
setGrantKeys(res.grantKeys ?? res.userPermissionKeys ?? []);
|
||||||
|
setDenyKeys(res.denyKeys ?? []);
|
||||||
setRoleInheritedKeys(res.rolePermissionKeys);
|
setRoleInheritedKeys(res.rolePermissionKeys);
|
||||||
|
setAccountKeys(res.effectivePermissionKeys);
|
||||||
})
|
})
|
||||||
.finally(() => setAccountLoading(false));
|
.finally(() => setAccountLoading(false));
|
||||||
}, [isSuperAdmin, accountId]);
|
}, [isSuperAdmin, accountId]);
|
||||||
@@ -179,10 +216,12 @@ export default function HqPermissionsPage() {
|
|||||||
try {
|
try {
|
||||||
const res = await request<AccountPermRes>(`/admin/hq-permissions/accounts/${accountId}`, {
|
const res = await request<AccountPermRes>(`/admin/hq-permissions/accounts/${accountId}`, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
body: JSON.stringify({ permissionKeys: accountKeys }),
|
body: JSON.stringify({ grantKeys, denyKeys }),
|
||||||
});
|
});
|
||||||
setAccountKeys(res.userPermissionKeys);
|
setGrantKeys(res.grantKeys ?? res.userPermissionKeys ?? []);
|
||||||
|
setDenyKeys(res.denyKeys ?? []);
|
||||||
setRoleInheritedKeys(res.rolePermissionKeys);
|
setRoleInheritedKeys(res.rolePermissionKeys);
|
||||||
|
setAccountKeys(res.effectivePermissionKeys);
|
||||||
message.success('用户权限已保存');
|
message.success('用户权限已保存');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error(e instanceof Error ? e.message : '保存失败');
|
message.error(e instanceof Error ? e.message : '保存失败');
|
||||||
@@ -204,8 +243,9 @@ export default function HqPermissionsPage() {
|
|||||||
<div>
|
<div>
|
||||||
<Typography.Title level={4}>权限分配</Typography.Title>
|
<Typography.Title level={4}>权限分配</Typography.Title>
|
||||||
<Typography.Paragraph type="secondary">
|
<Typography.Paragraph type="secondary">
|
||||||
按角色配置基础权限;按用户可追加专属权限。最终生效权限 = 角色权限 ∪ 用户权限。
|
按角色配置基础权限;按用户可追加或撤销。最终生效权限 =(角色权限 ∪ 追加)− 撤销。
|
||||||
超级管理员默认拥有除「危险操作」外的全部权限;删除用户/订单/城市需在「按用户分配」中单独勾选(默认均无)。
|
超级管理员默认拥有除「危险操作」外的全部权限;删除用户/订单/城市需在「按用户分配」中单独勾选(默认均无)。
|
||||||
|
运营/财务默认可删除门店分类;城市门店服务可新增分类,不可删除。
|
||||||
「系统设置」已拆分为各配置分组;「财务」对应门店/合伙人/酒厂账单。
|
「系统设置」已拆分为各配置分组;「财务」对应门店/合伙人/酒厂账单。
|
||||||
</Typography.Paragraph>
|
</Typography.Paragraph>
|
||||||
|
|
||||||
@@ -275,45 +315,33 @@ export default function HqPermissionsPage() {
|
|||||||
<Alert type="info" showIcon message="请先选择要配置的 HQ 账户" />
|
<Alert type="info" showIcon message="请先选择要配置的 HQ 账户" />
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<div style={{ marginBottom: 12 }}>
|
|
||||||
<span style={{ marginRight: 8 }}>角色继承:</span>
|
|
||||||
{selectedIsSuperAdmin ? (
|
|
||||||
<Tag color="blue">超级管理员基础权限(不含危险操作)</Tag>
|
|
||||||
) : (
|
|
||||||
<Space wrap size={[4, 4]}>
|
|
||||||
{roleInheritedKeys.map((key) => {
|
|
||||||
const item = HQ_PERMISSION_CATALOG.find((p) => p.key === key);
|
|
||||||
return (
|
|
||||||
<Tag key={key} color="blue">
|
|
||||||
{item?.label || key}
|
|
||||||
</Tag>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
{!roleInheritedKeys.length ? (
|
|
||||||
<Typography.Text type="secondary">无</Typography.Text>
|
|
||||||
) : null}
|
|
||||||
</Space>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<Typography.Paragraph type="secondary">
|
<Typography.Paragraph type="secondary">
|
||||||
下方勾选为用户专属追加权限(保存后与角色权限合并生效)。危险操作(删除用户/订单/城市)默认不授予,需在此勾选。
|
勾选表示该账号最终拥有该权限。取消角色已有项即为撤销;勾选角色没有的项即为追加。
|
||||||
|
切换角色会清空账号级追加/撤销。
|
||||||
</Typography.Paragraph>
|
</Typography.Paragraph>
|
||||||
<PermissionChecklist value={accountKeys} onChange={setAccountKeys} />
|
<PermissionChecklist
|
||||||
|
value={accountKeys}
|
||||||
|
roleKeys={roleInheritedKeys}
|
||||||
|
grantKeys={grantKeys}
|
||||||
|
disabled={selectedIsSuperAdmin}
|
||||||
|
onChange={(nextEffective) => {
|
||||||
|
if (selectedIsSuperAdmin) return;
|
||||||
|
const next = splitAccountOverrides(roleInheritedKeys, nextEffective);
|
||||||
|
setGrantKeys(next.grantKeys);
|
||||||
|
setDenyKeys(next.denyKeys);
|
||||||
|
setAccountKeys(nextEffective);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{selectedIsSuperAdmin ? (
|
||||||
|
<Alert
|
||||||
|
type="info"
|
||||||
|
showIcon
|
||||||
|
style={{ marginTop: 12 }}
|
||||||
|
message="超级管理员基础权限不可撤销。危险操作请到下方以外的方式:当前勾选仅展示生效权限。"
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
<div style={{ marginTop: 12 }}>
|
<div style={{ marginTop: 12 }}>
|
||||||
<span style={{ marginRight: 8 }}>合并生效:</span>
|
<span style={{ marginRight: 8 }}>合并生效:</span>
|
||||||
{selectedIsSuperAdmin ? (
|
|
||||||
<Space wrap size={[4, 4]}>
|
|
||||||
<Tag>基础权限(全部)</Tag>
|
|
||||||
{accountKeys.map((key) => {
|
|
||||||
const item = HQ_PERMISSION_CATALOG.find((p) => p.key === (key as HqPermissionKey));
|
|
||||||
return (
|
|
||||||
<Tag key={key} color="orange">
|
|
||||||
{item?.label || key}
|
|
||||||
</Tag>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</Space>
|
|
||||||
) : (
|
|
||||||
<Space wrap size={[4, 4]}>
|
<Space wrap size={[4, 4]}>
|
||||||
{previewEffectiveKeys.map((key) => {
|
{previewEffectiveKeys.map((key) => {
|
||||||
const item = HQ_PERMISSION_CATALOG.find((p) => p.key === (key as HqPermissionKey));
|
const item = HQ_PERMISSION_CATALOG.find((p) => p.key === (key as HqPermissionKey));
|
||||||
@@ -324,10 +352,14 @@ export default function HqPermissionsPage() {
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</Space>
|
</Space>
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
<div style={{ marginTop: 16 }}>
|
<div style={{ marginTop: 16 }}>
|
||||||
<Button type="primary" loading={accountSaving} onClick={() => void saveAccountPermissions()}>
|
<Button
|
||||||
|
type="primary"
|
||||||
|
loading={accountSaving}
|
||||||
|
disabled={selectedIsSuperAdmin}
|
||||||
|
onClick={() => void saveAccountPermissions()}
|
||||||
|
>
|
||||||
保存用户权限
|
保存用户权限
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { useState } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
|
import { useSearchParams } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Descriptions,
|
Descriptions,
|
||||||
@@ -16,9 +17,11 @@ import {
|
|||||||
} from 'antd';
|
} from 'antd';
|
||||||
import type { ColumnsType } from 'antd/es/table';
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
import {
|
import {
|
||||||
|
INVOICE_CATEGORY_LABELS,
|
||||||
INVOICE_KIND_LABELS,
|
INVOICE_KIND_LABELS,
|
||||||
INVOICE_STATUS_LABELS,
|
INVOICE_STATUS_LABELS,
|
||||||
INVOICE_TITLE_TYPE_LABELS,
|
INVOICE_TITLE_TYPE_LABELS,
|
||||||
|
type InvoiceCategory,
|
||||||
type InvoiceKind,
|
type InvoiceKind,
|
||||||
type InvoiceStatus,
|
type InvoiceStatus,
|
||||||
type InvoiceTitleType,
|
type InvoiceTitleType,
|
||||||
@@ -27,6 +30,8 @@ import { request } from '../lib/api';
|
|||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
import { uploadFileToOss } from '../lib/upload';
|
import { uploadFileToOss } from '../lib/upload';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -34,6 +39,7 @@ type Row = {
|
|||||||
orderNo?: string;
|
orderNo?: string;
|
||||||
titleType: InvoiceTitleType;
|
titleType: InvoiceTitleType;
|
||||||
invoiceKind: InvoiceKind;
|
invoiceKind: InvoiceKind;
|
||||||
|
invoiceCategory?: InvoiceCategory;
|
||||||
titleName: string;
|
titleName: string;
|
||||||
status: InvoiceStatus;
|
status: InvoiceStatus;
|
||||||
overdue?: boolean;
|
overdue?: boolean;
|
||||||
@@ -53,6 +59,7 @@ type CreateFormValues = {
|
|||||||
orderNo: string;
|
orderNo: string;
|
||||||
titleType: InvoiceTitleType;
|
titleType: InvoiceTitleType;
|
||||||
invoiceKind: InvoiceKind;
|
invoiceKind: InvoiceKind;
|
||||||
|
invoiceCategory?: InvoiceCategory;
|
||||||
titleName: string;
|
titleName: string;
|
||||||
taxNo?: string;
|
taxNo?: string;
|
||||||
addressPhone?: string;
|
addressPhone?: string;
|
||||||
@@ -63,12 +70,22 @@ type CreateFormValues = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default function InvoicesPage() {
|
export default function InvoicesPage() {
|
||||||
const [filters, setFilters] = useState<Record<string, string>>({});
|
const [searchParams] = useSearchParams();
|
||||||
|
const initialStatus = searchParams.get('status')?.trim() || '';
|
||||||
|
const initialInvoiceNo = searchParams.get('invoiceNo')?.trim() || '';
|
||||||
|
const [filterForm] = Form.useForm();
|
||||||
|
const [filters, setFilters] = useState<Record<string, string>>(() => {
|
||||||
|
const init: Record<string, string> = {};
|
||||||
|
if (initialStatus) init.status = initialStatus;
|
||||||
|
if (initialInvoiceNo) init.invoiceNo = initialInvoiceNo;
|
||||||
|
return init;
|
||||||
|
});
|
||||||
const { data, loading, page, pageSize, setPage, setPageSize, reload } = useAdminList<Row>(
|
const { data, loading, page, pageSize, setPage, setPageSize, reload } = useAdminList<Row>(
|
||||||
'/admin/invoices',
|
'/admin/invoices',
|
||||||
() => {
|
() => {
|
||||||
const qs = new URLSearchParams();
|
const qs = new URLSearchParams();
|
||||||
if (filters.status) qs.set('status', filters.status);
|
if (filters.status) qs.set('status', filters.status);
|
||||||
|
if (filters.invoiceNo) qs.set('invoiceNo', filters.invoiceNo);
|
||||||
return qs;
|
return qs;
|
||||||
},
|
},
|
||||||
[filters],
|
[filters],
|
||||||
@@ -81,12 +98,29 @@ export default function InvoicesPage() {
|
|||||||
const [createForm] = Form.useForm<CreateFormValues>();
|
const [createForm] = Form.useForm<CreateFormValues>();
|
||||||
const invoiceKind = Form.useWatch('invoiceKind', createForm);
|
const invoiceKind = Form.useWatch('invoiceKind', createForm);
|
||||||
const titleType = Form.useWatch('titleType', createForm);
|
const titleType = Form.useWatch('titleType', createForm);
|
||||||
|
const deepLinkOpenedRef = useRef(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
filterForm.setFieldsValue({
|
||||||
|
status: filters.status || undefined,
|
||||||
|
invoiceNo: filters.invoiceNo || undefined,
|
||||||
|
});
|
||||||
|
}, [filterForm, filters.invoiceNo, filters.status]);
|
||||||
|
|
||||||
async function openDetail(id: string) {
|
async function openDetail(id: string) {
|
||||||
setDetail(await request(`/admin/invoices/${id}`));
|
setDetail(await request(`/admin/invoices/${id}`));
|
||||||
setDrawerOpen(true);
|
setDrawerOpen(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!initialInvoiceNo || deepLinkOpenedRef.current || loading) return;
|
||||||
|
const first = data?.items?.[0];
|
||||||
|
if (first && String(first.invoiceNo) === initialInvoiceNo) {
|
||||||
|
deepLinkOpenedRef.current = true;
|
||||||
|
void openDetail(first.id);
|
||||||
|
}
|
||||||
|
}, [data, initialInvoiceNo, loading]);
|
||||||
|
|
||||||
async function issueWithFile(file: File) {
|
async function issueWithFile(file: File) {
|
||||||
if (!detail) return false;
|
if (!detail) return false;
|
||||||
setUploading(true);
|
setUploading(true);
|
||||||
@@ -128,6 +162,7 @@ export default function InvoicesPage() {
|
|||||||
orderNo: values.orderNo.trim(),
|
orderNo: values.orderNo.trim(),
|
||||||
titleType: values.titleType,
|
titleType: values.titleType,
|
||||||
invoiceKind: values.invoiceKind,
|
invoiceKind: values.invoiceKind,
|
||||||
|
invoiceCategory: values.invoiceCategory,
|
||||||
titleName: values.titleName.trim(),
|
titleName: values.titleName.trim(),
|
||||||
taxNo: values.taxNo?.trim() || undefined,
|
taxNo: values.taxNo?.trim() || undefined,
|
||||||
addressPhone: values.addressPhone?.trim() || undefined,
|
addressPhone: values.addressPhone?.trim() || undefined,
|
||||||
@@ -148,7 +183,7 @@ export default function InvoicesPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{ title: '申请单号', dataIndex: 'invoiceNo', width: 180 },
|
{ title: '申请单号', dataIndex: 'invoiceNo', width: 180 },
|
||||||
{ title: '订单号', dataIndex: 'orderNo', width: 160 },
|
{ title: '订单号', dataIndex: 'orderNo', width: 160 },
|
||||||
{
|
{
|
||||||
@@ -158,10 +193,18 @@ export default function InvoicesPage() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '票种',
|
title: '票种',
|
||||||
width: 120,
|
width: 140,
|
||||||
render: (_, r) => INVOICE_KIND_LABELS[r.invoiceKind] ?? r.invoiceKind,
|
render: (_, r) => INVOICE_KIND_LABELS[r.invoiceKind] ?? r.invoiceKind,
|
||||||
},
|
},
|
||||||
{ title: '名称', dataIndex: 'titleName', ellipsis: true },
|
{
|
||||||
|
title: '类型',
|
||||||
|
width: 88,
|
||||||
|
render: (_, r) =>
|
||||||
|
r.invoiceCategory
|
||||||
|
? INVOICE_CATEGORY_LABELS[r.invoiceCategory] ?? r.invoiceCategory
|
||||||
|
: '—',
|
||||||
|
},
|
||||||
|
{ title: '名称', dataIndex: 'titleName' },
|
||||||
{
|
{
|
||||||
title: '状态',
|
title: '状态',
|
||||||
width: 110,
|
width: 110,
|
||||||
@@ -186,8 +229,11 @@ export default function InvoicesPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('invoices', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@@ -199,12 +245,14 @@ export default function InvoicesPage() {
|
|||||||
<Typography.Title level={4} style={{ margin: 0 }}>
|
<Typography.Title level={4} style={{ margin: 0 }}>
|
||||||
发票管理
|
发票管理
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
createForm.setFieldsValue({
|
createForm.setFieldsValue({
|
||||||
titleType: 'PERSONAL',
|
titleType: 'PERSONAL',
|
||||||
invoiceKind: 'NORMAL',
|
invoiceKind: 'NORMAL',
|
||||||
|
invoiceCategory: 'LIQUOR',
|
||||||
});
|
});
|
||||||
setCreateOpen(true);
|
setCreateOpen(true);
|
||||||
}}
|
}}
|
||||||
@@ -213,6 +261,7 @@ export default function InvoicesPage() {
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<Form
|
<Form
|
||||||
|
form={filterForm}
|
||||||
layout="inline"
|
layout="inline"
|
||||||
style={{ marginBottom: 16 }}
|
style={{ marginBottom: 16 }}
|
||||||
onFinish={(v) => {
|
onFinish={(v) => {
|
||||||
@@ -231,6 +280,9 @@ export default function InvoicesPage() {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<Form.Item name="invoiceNo" label="申请单号">
|
||||||
|
<Input allowClear placeholder="发票申请单号" />
|
||||||
|
</Form.Item>
|
||||||
<Button type="primary" htmlType="submit">
|
<Button type="primary" htmlType="submit">
|
||||||
筛选
|
筛选
|
||||||
</Button>
|
</Button>
|
||||||
@@ -240,7 +292,7 @@ export default function InvoicesPage() {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data?.items ?? []}
|
dataSource={data?.items ?? []}
|
||||||
scroll={{ x: 1000 }}
|
scroll={{ x: 'max-content' }}
|
||||||
rowClassName={(r) => (r.overdue ? 'ant-table-row-overdue' : '')}
|
rowClassName={(r) => (r.overdue ? 'ant-table-row-overdue' : '')}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: page,
|
current: page,
|
||||||
@@ -292,6 +344,11 @@ export default function InvoicesPage() {
|
|||||||
<Descriptions.Item label="发票类型">
|
<Descriptions.Item label="发票类型">
|
||||||
{INVOICE_KIND_LABELS[detail.invoiceKind]}
|
{INVOICE_KIND_LABELS[detail.invoiceKind]}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="类型">
|
||||||
|
{detail.invoiceCategory
|
||||||
|
? INVOICE_CATEGORY_LABELS[detail.invoiceCategory]
|
||||||
|
: '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="抬头名称">{detail.titleName}</Descriptions.Item>
|
<Descriptions.Item label="抬头名称">{detail.titleName}</Descriptions.Item>
|
||||||
<Descriptions.Item label="税号">{detail.taxNo ?? '—'}</Descriptions.Item>
|
<Descriptions.Item label="税号">{detail.taxNo ?? '—'}</Descriptions.Item>
|
||||||
<Descriptions.Item label="地址电话">{detail.addressPhone ?? '—'}</Descriptions.Item>
|
<Descriptions.Item label="地址电话">{detail.addressPhone ?? '—'}</Descriptions.Item>
|
||||||
@@ -350,6 +407,18 @@ export default function InvoicesPage() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
name="invoiceCategory"
|
||||||
|
label="类型"
|
||||||
|
rules={[{ required: true, message: '请选择类型' }]}
|
||||||
|
>
|
||||||
|
<Select
|
||||||
|
options={(Object.keys(INVOICE_CATEGORY_LABELS) as InvoiceCategory[]).map((k) => ({
|
||||||
|
value: k,
|
||||||
|
label: INVOICE_CATEGORY_LABELS[k],
|
||||||
|
}))}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="titleType"
|
name="titleType"
|
||||||
label="抬头类型"
|
label="抬头类型"
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import { request } from '../lib/api';
|
|||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
import { uploadFileToOss } from '../lib/upload';
|
import { uploadFileToOss } from '../lib/upload';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type FormValues = {
|
type FormValues = {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -124,9 +126,9 @@ export default function KnowledgeBasesPage() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const columns: ColumnsType<KnowledgeBaseDto> = [
|
const baseColumns: ColumnsType<KnowledgeBaseDto> = [
|
||||||
{ title: '名称', dataIndex: 'name' },
|
{ title: '名称', dataIndex: 'name' },
|
||||||
{ title: '说明', dataIndex: 'description', ellipsis: true },
|
{ title: '说明', dataIndex: 'description' },
|
||||||
{ title: '文档数', dataIndex: 'documentCount', width: 90 },
|
{ title: '文档数', dataIndex: 'documentCount', width: 90 },
|
||||||
{
|
{
|
||||||
title: '启用',
|
title: '启用',
|
||||||
@@ -184,7 +186,7 @@ export default function KnowledgeBasesPage() {
|
|||||||
|
|
||||||
const docColumns: ColumnsType<KnowledgeDocumentDto> = [
|
const docColumns: ColumnsType<KnowledgeDocumentDto> = [
|
||||||
{ title: '标题', dataIndex: 'title' },
|
{ title: '标题', dataIndex: 'title' },
|
||||||
{ title: '文件', dataIndex: 'fileName', ellipsis: true },
|
{ title: '文件', dataIndex: 'fileName' },
|
||||||
{
|
{
|
||||||
title: '状态',
|
title: '状态',
|
||||||
dataIndex: 'status',
|
dataIndex: 'status',
|
||||||
@@ -250,12 +252,16 @@ export default function KnowledgeBasesPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('knowledge-bases', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Space style={{ marginBottom: 16 }} wrap>
|
<Space style={{ marginBottom: 16 }} wrap>
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>
|
<Typography.Title level={4} style={{ margin: 0 }}>
|
||||||
知识库
|
知识库
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Typography.Text type="secondary">
|
<Typography.Text type="secondary">
|
||||||
支持粘贴文本或上传 .txt/.md;可绑定到企微机器人供 AI 检索
|
支持粘贴文本或上传 .txt/.md;可绑定到企微机器人供 AI 检索
|
||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import {
|
|||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type FormValues = {
|
type FormValues = {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -153,7 +155,7 @@ export default function LlmConfigsPage() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const columns: ColumnsType<LlmApiConfigDto> = [
|
const baseColumns: ColumnsType<LlmApiConfigDto> = [
|
||||||
{ title: '名称', dataIndex: 'name' },
|
{ title: '名称', dataIndex: 'name' },
|
||||||
{
|
{
|
||||||
title: '提供商',
|
title: '提供商',
|
||||||
@@ -161,7 +163,7 @@ export default function LlmConfigsPage() {
|
|||||||
width: 120,
|
width: 120,
|
||||||
render: (p: LlmProvider) => LLM_PROVIDER_LABELS[p] || p,
|
render: (p: LlmProvider) => LLM_PROVIDER_LABELS[p] || p,
|
||||||
},
|
},
|
||||||
{ title: '模型', dataIndex: 'modelName', ellipsis: true },
|
{ title: '模型', dataIndex: 'modelName' },
|
||||||
{
|
{
|
||||||
title: 'Key',
|
title: 'Key',
|
||||||
dataIndex: 'apiKeyConfigured',
|
dataIndex: 'apiKeyConfigured',
|
||||||
@@ -257,12 +259,16 @@ export default function LlmConfigsPage() {
|
|||||||
|
|
||||||
const fullEdit = !editing || editing.canEditFull;
|
const fullEdit = !editing || editing.canEditFull;
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('llm-configs', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Space style={{ marginBottom: 16 }} wrap>
|
<Space style={{ marginBottom: 16 }} wrap>
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>
|
<Typography.Title level={4} style={{ margin: 0 }}>
|
||||||
语言模型配置
|
语言模型配置
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Typography.Text type="secondary">
|
<Typography.Text type="secondary">
|
||||||
非超管仅可见自己创建的配置,且创建后只能改是否生效
|
非超管仅可见自己创建的配置,且创建后只能改是否生效
|
||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import { fmtTime } from '../lib/constants';
|
|||||||
import { downloadExcelCsv } from '../lib/exportExcel';
|
import { downloadExcelCsv } from '../lib/exportExcel';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
type BillRow = {
|
type BillRow = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -44,6 +45,13 @@ type BillRow = {
|
|||||||
settlementMethod: string;
|
settlementMethod: string;
|
||||||
status: string;
|
status: string;
|
||||||
paidAt?: string | null;
|
paidAt?: string | null;
|
||||||
|
paymentRef?: string | null;
|
||||||
|
fulfillmentProvider?: {
|
||||||
|
bankAccountName?: string | null;
|
||||||
|
bankName?: string | null;
|
||||||
|
bankBranch?: string | null;
|
||||||
|
bankAccountNo?: string | null;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
type BillItem = {
|
type BillItem = {
|
||||||
@@ -140,14 +148,30 @@ export default function LogisticsBillsPage() {
|
|||||||
}, [summaryPeriod]);
|
}, [summaryPeriod]);
|
||||||
|
|
||||||
function confirmPay(ids: string[], amountHint?: number) {
|
function confirmPay(ids: string[], amountHint?: number) {
|
||||||
|
let paymentRef = '';
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: '确认结算?',
|
title: '确认结算?',
|
||||||
content: `将确认 ${ids.length} 笔物流对账单${amountHint != null ? `,合计约 ¥${amountHint.toFixed(2)}` : ''}。充值模式将扣减余额,挂账模式标记已打款。`,
|
content: (
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
将确认 {ids.length} 笔物流对账单
|
||||||
|
{amountHint != null ? `,合计约 ¥${amountHint.toFixed(2)}` : ''}。充值模式将扣减余额,挂账模式标记已打款。
|
||||||
|
</div>
|
||||||
|
<Input
|
||||||
|
placeholder="打款凭证号(可选)"
|
||||||
|
style={{ marginTop: 8 }}
|
||||||
|
onChange={(e) => {
|
||||||
|
paymentRef = e.target.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
okText: '确认结算',
|
okText: '确认结算',
|
||||||
cancelText: '取消',
|
cancelText: '取消',
|
||||||
onOk: async () => {
|
onOk: async () => {
|
||||||
|
const body = JSON.stringify({ paymentRef: paymentRef.trim() || undefined });
|
||||||
if (ids.length === 1) {
|
if (ids.length === 1) {
|
||||||
await request(`/admin/logistics-bills/${ids[0]}/confirm`, { method: 'POST' });
|
await request(`/admin/logistics-bills/${ids[0]}/confirm`, { method: 'POST', body });
|
||||||
} else {
|
} else {
|
||||||
await request('/admin/logistics-bills/batch-confirm', {
|
await request('/admin/logistics-bills/batch-confirm', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -217,11 +241,12 @@ export default function LogisticsBillsPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const summary = data?.summary;
|
const summary = data?.summary;
|
||||||
|
const providerBank = (r: BillRow) => r.fulfillmentProvider;
|
||||||
const selectedRows = (data?.items ?? []).filter((r) => selectedKeys.includes(r.id));
|
const selectedRows = (data?.items ?? []).filter((r) => selectedKeys.includes(r.id));
|
||||||
const selectedAmount = selectedRows.reduce((s, r) => s + Number(r.logisticsAmount), 0);
|
const selectedAmount = selectedRows.reduce((s, r) => s + Number(r.logisticsAmount), 0);
|
||||||
|
|
||||||
const billColumns: ColumnsType<BillRow> = [
|
const billColumns: ColumnsType<BillRow> = [
|
||||||
{ title: '账单号', dataIndex: 'billNo', width: 170, ellipsis: true },
|
{ title: '账单号', dataIndex: 'billNo', width: 170 },
|
||||||
{
|
{
|
||||||
title: '承运商',
|
title: '承运商',
|
||||||
width: 140,
|
width: 140,
|
||||||
@@ -248,6 +273,16 @@ export default function LogisticsBillsPage() {
|
|||||||
width: 110,
|
width: 110,
|
||||||
render: (v) => `¥${Number(v).toFixed(2)}`,
|
render: (v) => `¥${Number(v).toFixed(2)}`,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '收款户名',
|
||||||
|
width: 100,
|
||||||
|
render: (_, r) => providerBank(r)?.bankAccountName || '—',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '收款账号',
|
||||||
|
width: 140,
|
||||||
|
render: (_, r) => providerBank(r)?.bankAccountNo || '—',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '状态',
|
title: '状态',
|
||||||
dataIndex: 'status',
|
dataIndex: 'status',
|
||||||
@@ -303,7 +338,6 @@ export default function LogisticsBillsPage() {
|
|||||||
{
|
{
|
||||||
title: '银行账户',
|
title: '银行账户',
|
||||||
width: 180,
|
width: 180,
|
||||||
ellipsis: true,
|
|
||||||
render: (_, r) =>
|
render: (_, r) =>
|
||||||
r.bankAccountName
|
r.bankAccountName
|
||||||
? `${r.bankAccountName} / ${r.bankName || ''} ${r.bankAccountNo || ''}`
|
? `${r.bankAccountName} / ${r.bankName || ''} ${r.bankAccountNo || ''}`
|
||||||
@@ -355,12 +389,19 @@ export default function LogisticsBillsPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('finance-logistics-bills', billColumns, {
|
||||||
|
page,
|
||||||
|
pageSize,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Space direction="vertical" size={0} style={{ marginBottom: 16 }}>
|
<Space direction="vertical" size={0} style={{ marginBottom: 16 }}>
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>
|
<Typography.Title level={4} style={{ margin: 0 }}>
|
||||||
物流对账
|
物流对账
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Typography.Text type="secondary">
|
<Typography.Text type="secondary">
|
||||||
按快递承运商汇总月度物流费;计价与银行账户在「仓配管理」配置。前期充值扣款,后期可切挂账月结。
|
按快递承运商汇总月度物流费;计价与银行账户在「仓配管理」配置。前期充值扣款,后期可切挂账月结。
|
||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
@@ -501,7 +542,7 @@ export default function LogisticsBillsPage() {
|
|||||||
<Table
|
<Table
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
loading={loading}
|
loading={loading}
|
||||||
columns={billColumns}
|
columns={columns}
|
||||||
dataSource={data?.items ?? []}
|
dataSource={data?.items ?? []}
|
||||||
rowSelection={{
|
rowSelection={{
|
||||||
selectedRowKeys: selectedKeys,
|
selectedRowKeys: selectedKeys,
|
||||||
@@ -550,7 +591,31 @@ export default function LogisticsBillsPage() {
|
|||||||
<Descriptions.Item label="结算时间">
|
<Descriptions.Item label="结算时间">
|
||||||
{detail.paidAt ? fmtTime(detail.paidAt) : '—'}
|
{detail.paidAt ? fmtTime(detail.paidAt) : '—'}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="打款凭证">
|
||||||
|
{detail.paymentRef ? String(detail.paymentRef) : '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
</Descriptions>
|
</Descriptions>
|
||||||
|
{providerBank(detail) ? (
|
||||||
|
<>
|
||||||
|
<Typography.Title level={5} style={{ marginTop: 16 }}>
|
||||||
|
收款账户
|
||||||
|
</Typography.Title>
|
||||||
|
<Descriptions column={1} size="small" bordered style={{ marginBottom: 16 }}>
|
||||||
|
<Descriptions.Item label="户名">
|
||||||
|
{providerBank(detail)?.bankAccountName || '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="开户银行">
|
||||||
|
{providerBank(detail)?.bankName || '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="开户支行">
|
||||||
|
{providerBank(detail)?.bankBranch || '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="账号">
|
||||||
|
{providerBank(detail)?.bankAccountNo || '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
</Descriptions>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
<Table
|
<Table
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
size="small"
|
size="small"
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link, useSearchParams } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
Alert,
|
Alert,
|
||||||
Button,
|
Button,
|
||||||
Checkbox,
|
Checkbox,
|
||||||
|
Col,
|
||||||
Collapse,
|
Collapse,
|
||||||
|
DatePicker,
|
||||||
Descriptions,
|
Descriptions,
|
||||||
Drawer,
|
Drawer,
|
||||||
Form,
|
Form,
|
||||||
@@ -12,6 +14,7 @@ import {
|
|||||||
InputNumber,
|
InputNumber,
|
||||||
Modal,
|
Modal,
|
||||||
Radio,
|
Radio,
|
||||||
|
Row,
|
||||||
Select,
|
Select,
|
||||||
Space,
|
Space,
|
||||||
Table,
|
Table,
|
||||||
@@ -20,7 +23,11 @@ import {
|
|||||||
message,
|
message,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import type { ColumnsType } from 'antd/es/table';
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
|
import dayjs, { type Dayjs } from 'dayjs';
|
||||||
|
import { ORDER_TYPE_LABELS } from '@dukang/shared-types';
|
||||||
import { request, type AdminOrderItem, type AdminOrderRow, type HqProfile, type Paginated } from '../lib/api';
|
import { request, type AdminOrderItem, type AdminOrderRow, type HqProfile, type Paginated } from '../lib/api';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
import { downloadBase64File } from '../lib/exportExcel';
|
||||||
import {
|
import {
|
||||||
ADMIN_OPTIONS_PAGE_SIZE,
|
ADMIN_OPTIONS_PAGE_SIZE,
|
||||||
DELIVERY_PROVIDER_LABELS,
|
DELIVERY_PROVIDER_LABELS,
|
||||||
@@ -130,6 +137,110 @@ type OrderDetail = AdminOrderRow & {
|
|||||||
|
|
||||||
type ShipMode = 'WAREHOUSE' | 'EXPRESS';
|
type ShipMode = 'WAREHOUSE' | 'EXPRESS';
|
||||||
|
|
||||||
|
type OrderExportScope = 'filter' | 'selected';
|
||||||
|
type OrderExportFormat = 'xlsx' | 'pdf';
|
||||||
|
|
||||||
|
type OrderExportFilters = {
|
||||||
|
orderNo?: string;
|
||||||
|
status?: string;
|
||||||
|
orderType?: string;
|
||||||
|
cityId?: string;
|
||||||
|
receiverPhone?: string;
|
||||||
|
fulfillmentHold?: boolean;
|
||||||
|
excludeTest?: boolean;
|
||||||
|
deliveryType?: string;
|
||||||
|
dateRange?: [Dayjs, Dayjs];
|
||||||
|
};
|
||||||
|
|
||||||
|
type OrderExportResult = {
|
||||||
|
filename: string;
|
||||||
|
mimeType: string;
|
||||||
|
contentBase64: string;
|
||||||
|
count: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
const ORDER_TYPE_OPTIONS = Object.entries(ORDER_TYPE_LABELS).map(([value, label]) => ({ value, label }));
|
||||||
|
|
||||||
|
const DELIVERY_TYPE_OPTIONS = [
|
||||||
|
{ value: 'LOCAL', label: '同城' },
|
||||||
|
{ value: 'CROSS_CITY', label: '跨城' },
|
||||||
|
{ value: 'ON_SITE_PICKUP', label: '现场提货' },
|
||||||
|
];
|
||||||
|
|
||||||
|
function isOnSitePickupOrder(row: Pick<AdminOrderRow, 'deliveryType' | 'receiverProvince' | 'receiverCity' | 'receiverAddress'>) {
|
||||||
|
return (
|
||||||
|
row.deliveryType === 'ON_SITE_PICKUP' ||
|
||||||
|
row.receiverAddress === '现场取货' ||
|
||||||
|
row.receiverAddress === '现场提货' ||
|
||||||
|
(row.receiverProvince === '现场' && row.receiverCity === '现场')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatReceiverAddress(row: AdminOrderRow) {
|
||||||
|
if (isOnSitePickupOrder(row)) return '现场取货';
|
||||||
|
const region = [row.receiverProvince, row.receiverCity, row.receiverDistrict].filter(Boolean).join('');
|
||||||
|
const detail = row.receiverAddress || '';
|
||||||
|
if (!region) return detail;
|
||||||
|
if (!detail || detail.startsWith(region)) return detail || region;
|
||||||
|
return `${region}${detail}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function datePresetRange(kind: 'day' | 'week' | 'month' | 'quarter' | 'year'): [Dayjs, Dayjs] {
|
||||||
|
const now = dayjs();
|
||||||
|
if (kind === 'day') return [now.startOf('day'), now.endOf('day')];
|
||||||
|
if (kind === 'week') {
|
||||||
|
const monday = now.startOf('day').subtract((now.day() + 6) % 7, 'day');
|
||||||
|
return [monday, monday.add(6, 'day').endOf('day')];
|
||||||
|
}
|
||||||
|
if (kind === 'month') return [now.startOf('month'), now.endOf('month')];
|
||||||
|
if (kind === 'quarter') {
|
||||||
|
const start = now.month(Math.floor(now.month() / 3) * 3).startOf('month');
|
||||||
|
return [start, start.add(2, 'month').endOf('month')];
|
||||||
|
}
|
||||||
|
return [now.startOf('year'), now.endOf('year')];
|
||||||
|
}
|
||||||
|
|
||||||
|
const DATE_PRESETS: Array<{ key: 'day' | 'week' | 'month' | 'quarter' | 'year'; label: string }> = [
|
||||||
|
{ key: 'day', label: '当日' },
|
||||||
|
{ key: 'week', label: '当周' },
|
||||||
|
{ key: 'month', label: '当月' },
|
||||||
|
{ key: 'quarter', label: '当季' },
|
||||||
|
{ key: 'year', label: '当年' },
|
||||||
|
];
|
||||||
|
|
||||||
|
function formatBenefitBrief(row: AdminOrderRow) {
|
||||||
|
const coupon = row.benefitCoupon;
|
||||||
|
if (coupon) {
|
||||||
|
return `总额¥${Number(coupon.totalAmount ?? 0).toFixed(0)} / 已用¥${Number(coupon.usedAmount ?? 0).toFixed(0)} / 余¥${Number(coupon.balance ?? 0).toFixed(0)}`;
|
||||||
|
}
|
||||||
|
if (row.benefitAmount != null) return `¥${Number(row.benefitAmount).toFixed(0)}`;
|
||||||
|
return '—';
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildExportPayload(
|
||||||
|
scope: OrderExportScope,
|
||||||
|
format: OrderExportFormat,
|
||||||
|
filters: OrderExportFilters,
|
||||||
|
selectedIds: string[],
|
||||||
|
) {
|
||||||
|
const payload: Record<string, unknown> = { scope, format };
|
||||||
|
if (scope === 'selected') {
|
||||||
|
payload.ids = selectedIds;
|
||||||
|
return payload;
|
||||||
|
}
|
||||||
|
if (filters.orderNo) payload.orderNo = filters.orderNo;
|
||||||
|
if (filters.status) payload.status = filters.status;
|
||||||
|
if (filters.orderType) payload.orderType = filters.orderType;
|
||||||
|
if (filters.cityId) payload.cityId = filters.cityId;
|
||||||
|
if (filters.receiverPhone) payload.receiverPhone = filters.receiverPhone;
|
||||||
|
if (filters.deliveryType) payload.deliveryType = filters.deliveryType;
|
||||||
|
if (filters.fulfillmentHold) payload.fulfillmentHold = true;
|
||||||
|
if (filters.excludeTest) payload.excludeTest = true;
|
||||||
|
if (filters.dateRange?.[0]) payload.createdFrom = filters.dateRange[0].format('YYYY-MM-DD');
|
||||||
|
if (filters.dateRange?.[1]) payload.createdTo = filters.dateRange[1].format('YYYY-MM-DD');
|
||||||
|
return payload;
|
||||||
|
}
|
||||||
|
|
||||||
function orderProductRows(detail: OrderDetail): AdminOrderItem[] {
|
function orderProductRows(detail: OrderDetail): AdminOrderItem[] {
|
||||||
if (detail.items?.length) return detail.items;
|
if (detail.items?.length) return detail.items;
|
||||||
if (!detail.productName) return [];
|
if (!detail.productName) return [];
|
||||||
@@ -162,6 +273,8 @@ function warehouseToDefaults(wh: WarehouseOption, base?: ShipDefaults | null): S
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function OrdersPage() {
|
export default function OrdersPage() {
|
||||||
|
const [searchParams] = useSearchParams();
|
||||||
|
const initialOrderNo = searchParams.get('orderNo')?.trim() || '';
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const [shipForm] = Form.useForm();
|
const [shipForm] = Form.useForm();
|
||||||
const [logisticsForm] = Form.useForm();
|
const [logisticsForm] = Form.useForm();
|
||||||
@@ -172,6 +285,7 @@ export default function OrdersPage() {
|
|||||||
const [pageSize, setPageSize] = useState(20);
|
const [pageSize, setPageSize] = useState(20);
|
||||||
const [detail, setDetail] = useState<OrderDetail | null>(null);
|
const [detail, setDetail] = useState<OrderDetail | null>(null);
|
||||||
const [drawerOpen, setDrawerOpen] = useState(false);
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
||||||
|
const deepLinkOpenedRef = useRef(false);
|
||||||
const [redeemDetail, setRedeemDetail] = useState<Record<string, unknown> | null>(null);
|
const [redeemDetail, setRedeemDetail] = useState<Record<string, unknown> | null>(null);
|
||||||
const [redeemDrawerOpen, setRedeemDrawerOpen] = useState(false);
|
const [redeemDrawerOpen, setRedeemDrawerOpen] = useState(false);
|
||||||
const [redeemDetailLoading, setRedeemDetailLoading] = useState(false);
|
const [redeemDetailLoading, setRedeemDetailLoading] = useState(false);
|
||||||
@@ -189,8 +303,11 @@ export default function OrdersPage() {
|
|||||||
const [warehouses, setWarehouses] = useState<WarehouseOption[]>([]);
|
const [warehouses, setWarehouses] = useState<WarehouseOption[]>([]);
|
||||||
const [proxyOpen, setProxyOpen] = useState(false);
|
const [proxyOpen, setProxyOpen] = useState(false);
|
||||||
const [trackOpen, setTrackOpen] = useState(false);
|
const [trackOpen, setTrackOpen] = useState(false);
|
||||||
|
const [exporting, setExporting] = useState(false);
|
||||||
|
const [exportFormat, setExportFormat] = useState<OrderExportFormat>('xlsx');
|
||||||
const canDeleteOrders = (profile?.permissionKeys ?? []).includes('orders_delete');
|
const canDeleteOrders = (profile?.permissionKeys ?? []).includes('orders_delete');
|
||||||
const canProxyOrder = (profile?.permissionKeys ?? []).includes('orders');
|
const canProxyOrder = (profile?.permissionKeys ?? []).includes('orders');
|
||||||
|
const canExportOrders = (profile?.permissionKeys ?? []).includes('orders');
|
||||||
|
|
||||||
const selectedOrders = useMemo(
|
const selectedOrders = useMemo(
|
||||||
() => (data?.items ?? []).filter((row) => selectedRowKeys.includes(row.id)),
|
() => (data?.items ?? []).filter((row) => selectedRowKeys.includes(row.id)),
|
||||||
@@ -201,6 +318,21 @@ export default function OrdersPage() {
|
|||||||
request<HqProfile>('/admin/auth/me').then(setProfile).catch(() => {});
|
request<HqProfile>('/admin/auth/me').then(setProfile).catch(() => {});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (initialOrderNo) {
|
||||||
|
form.setFieldsValue({ orderNo: initialOrderNo });
|
||||||
|
}
|
||||||
|
}, [form, initialOrderNo]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!initialOrderNo || deepLinkOpenedRef.current || loading) return;
|
||||||
|
const first = data?.items?.[0];
|
||||||
|
if (first && String(first.orderNo) === initialOrderNo) {
|
||||||
|
deepLinkOpenedRef.current = true;
|
||||||
|
void openDetail(first.id);
|
||||||
|
}
|
||||||
|
}, [data, initialOrderNo, loading]);
|
||||||
|
|
||||||
async function openRedeemDetail(redeemId: string) {
|
async function openRedeemDetail(redeemId: string) {
|
||||||
setRedeemDetailLoading(true);
|
setRedeemDetailLoading(true);
|
||||||
setRedeemDrawerOpen(true);
|
setRedeemDrawerOpen(true);
|
||||||
@@ -220,6 +352,7 @@ export default function OrdersPage() {
|
|||||||
try {
|
try {
|
||||||
const values = form.getFieldsValue();
|
const values = form.getFieldsValue();
|
||||||
const qs = new URLSearchParams({ page: String(page), pageSize: String(pageSize) });
|
const qs = new URLSearchParams({ page: String(page), pageSize: String(pageSize) });
|
||||||
|
if (initialOrderNo) qs.set('orderNo', initialOrderNo);
|
||||||
if (values.orderNo) qs.set('orderNo', values.orderNo);
|
if (values.orderNo) qs.set('orderNo', values.orderNo);
|
||||||
if (values.status) qs.set('status', values.status);
|
if (values.status) qs.set('status', values.status);
|
||||||
if (values.orderType) qs.set('orderType', values.orderType);
|
if (values.orderType) qs.set('orderType', values.orderType);
|
||||||
@@ -227,12 +360,15 @@ export default function OrdersPage() {
|
|||||||
if (values.receiverPhone) qs.set('receiverPhone', values.receiverPhone);
|
if (values.receiverPhone) qs.set('receiverPhone', values.receiverPhone);
|
||||||
if (values.fulfillmentHold) qs.set('fulfillmentHold', 'true');
|
if (values.fulfillmentHold) qs.set('fulfillmentHold', 'true');
|
||||||
if (values.excludeTest) qs.set('excludeTest', 'true');
|
if (values.excludeTest) qs.set('excludeTest', 'true');
|
||||||
|
if (values.deliveryType) qs.set('deliveryType', values.deliveryType);
|
||||||
|
if (values.dateRange?.[0]) qs.set('createdFrom', values.dateRange[0].format('YYYY-MM-DD'));
|
||||||
|
if (values.dateRange?.[1]) qs.set('createdTo', values.dateRange[1].format('YYYY-MM-DD'));
|
||||||
const res = await request<Paginated<AdminOrderRow>>(`/admin/orders?${qs}`);
|
const res = await request<Paginated<AdminOrderRow>>(`/admin/orders?${qs}`);
|
||||||
setData(res);
|
setData(res);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}, [form, page, pageSize]);
|
}, [form, page, pageSize, initialOrderNo]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void load();
|
void load();
|
||||||
@@ -433,79 +569,93 @@ export default function OrdersPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<AdminOrderRow> = [
|
async function submitExport(scope: OrderExportScope) {
|
||||||
{
|
const values = form.getFieldsValue() as OrderExportFilters;
|
||||||
title: '订单号',
|
if (scope === 'selected' && !selectedRowKeys.length) {
|
||||||
dataIndex: 'orderNo',
|
message.warning('请先勾选要导出的订单');
|
||||||
width: 200,
|
return;
|
||||||
render: (v, row) => (
|
}
|
||||||
<Space size={4}>
|
setExporting(true);
|
||||||
<span>{v}</span>
|
try {
|
||||||
{row.isTest ? <Tag color="orange">测试</Tag> : null}
|
const payload = buildExportPayload(scope, exportFormat, values, selectedRowKeys);
|
||||||
</Space>
|
const result = await request<OrderExportResult>('/admin/orders/export', {
|
||||||
),
|
method: 'POST',
|
||||||
},
|
body: JSON.stringify(payload),
|
||||||
{
|
});
|
||||||
title: '城市',
|
downloadBase64File(result.contentBase64, result.filename, result.mimeType);
|
||||||
width: 90,
|
message.success(`已导出 ${result.count} 条订单`);
|
||||||
render: (_, row) => row.city?.name || '—',
|
} catch (e) {
|
||||||
},
|
message.error(e instanceof Error ? e.message : '导出失败');
|
||||||
|
} finally {
|
||||||
|
setExporting(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const baseColumns: ColumnsType<AdminOrderRow> = [
|
||||||
{
|
{
|
||||||
title: '商品',
|
title: '商品',
|
||||||
width: 180,
|
width: 240,
|
||||||
ellipsis: true,
|
render: (_, row) => (
|
||||||
render: (_, row) => {
|
<div>
|
||||||
const name = row.productName || '—';
|
|
||||||
const qty = row.quantity != null ? ` ×${row.quantity}` : '';
|
|
||||||
return (
|
|
||||||
<span title={row.productSpec ? `${name}(${row.productSpec})` : name}>
|
|
||||||
{name}{qty}
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '状态',
|
|
||||||
dataIndex: 'status',
|
|
||||||
width: 140,
|
|
||||||
render: (s, row) => (
|
|
||||||
<Space size={4} wrap>
|
<Space size={4} wrap>
|
||||||
<Tag color={ORDER_STATUS_COLORS[s] || 'default'}>{ORDER_STATUS_LABELS[s] || s}</Tag>
|
<span>{row.productName || '—'}</span>
|
||||||
{row.fulfillmentHold ? <Tag color="orange">大单待确认</Tag> : null}
|
{row.isTest ? <Tag color="orange">测试</Tag> : null}
|
||||||
|
{row.fulfillmentHold ? <Tag color="orange">大单</Tag> : null}
|
||||||
{row.orderType === 'PROXY' || row.isProxyOrder ? (
|
{row.orderType === 'PROXY' || row.isProxyOrder ? (
|
||||||
<Tag color="purple" title={row.proxyPartnerName || undefined}>
|
<Tag color="purple">代下单</Tag>
|
||||||
代下单
|
|
||||||
</Tag>
|
|
||||||
) : null}
|
) : null}
|
||||||
</Space>
|
</Space>
|
||||||
|
<div>
|
||||||
|
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
|
||||||
|
{[row.productSpec, row.quantity != null ? `×${row.quantity}` : null]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' ')}
|
||||||
|
</Typography.Text>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '配送',
|
title: '状态 / 实付',
|
||||||
dataIndex: 'deliveryType',
|
width: 130,
|
||||||
width: 90,
|
render: (_, row) => (
|
||||||
render: (v) =>
|
<div>
|
||||||
v === 'ON_SITE_PICKUP' ? '现场提货' : v === 'LOCAL' ? '同城' : '跨城',
|
<Tag color={ORDER_STATUS_COLORS[row.status] || 'default'}>
|
||||||
},
|
{ORDER_STATUS_LABELS[row.status] || row.status}
|
||||||
{ title: '实付', dataIndex: 'payAmount', width: 90, render: (v) => `¥${v}` },
|
</Tag>
|
||||||
{ title: '收货人', dataIndex: 'receiverName', width: 90 },
|
<div>¥{row.payAmount}</div>
|
||||||
{ title: '手机', dataIndex: 'receiverPhone', width: 120 },
|
</div>
|
||||||
{
|
),
|
||||||
title: '用户',
|
|
||||||
dataIndex: ['user', 'userNo'],
|
|
||||||
width: 110,
|
|
||||||
render: (_, row) => row.user?.userNo || '—',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '快递',
|
title: '好客权益',
|
||||||
width: 100,
|
width: 200,
|
||||||
render: (_, row) => row.delivery?.trackingNo || row.delivery?.provider || '—',
|
render: (_, row) => formatBenefitBrief(row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '收货信息',
|
||||||
|
width: 240,
|
||||||
|
render: (_, row) => {
|
||||||
|
const address = formatReceiverAddress(row);
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
{row.receiverName || '—'} {row.receiverPhone || ''}
|
||||||
|
</div>
|
||||||
|
{address ? (
|
||||||
|
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
|
||||||
|
{address}
|
||||||
|
</Typography.Text>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '下单时间',
|
title: '下单时间',
|
||||||
dataIndex: 'createdAt',
|
dataIndex: 'createdAt',
|
||||||
width: 170,
|
width: 170,
|
||||||
render: (v) => new Date(v).toLocaleString('zh-CN'),
|
render: fmtTime,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
@@ -537,26 +687,24 @@ export default function OrdersPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('orders', baseColumns, {
|
||||||
|
page,
|
||||||
|
pageSize,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
{settingsModal}
|
||||||
|
<Space style={{ marginBottom: 20, width: '100%', justifyContent: 'space-between' }}>
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>订单监控</Typography.Title>
|
<Typography.Title level={4} style={{ margin: 0 }}>订单监控</Typography.Title>
|
||||||
<Space>
|
<Space size={12}>
|
||||||
|
{settingsButton}
|
||||||
<Button onClick={() => window.open('/orders/big-screen', 'dukang-big-screen')}>大屏</Button>
|
<Button onClick={() => window.open('/orders/big-screen', 'dukang-big-screen')}>大屏</Button>
|
||||||
{canProxyOrder ? (
|
{canProxyOrder ? (
|
||||||
<Button type="primary" onClick={() => setProxyOpen(true)}>
|
<Button type="primary" onClick={() => setProxyOpen(true)}>
|
||||||
代下单
|
代下单
|
||||||
</Button>
|
</Button>
|
||||||
) : null}
|
) : null}
|
||||||
{canDeleteOrders ? (
|
|
||||||
<Button
|
|
||||||
danger
|
|
||||||
disabled={!selectedRowKeys.length}
|
|
||||||
onClick={() => setBatchDeleteOpen(true)}
|
|
||||||
>
|
|
||||||
批量删除{selectedRowKeys.length ? ` (${selectedRowKeys.length})` : ''}
|
|
||||||
</Button>
|
|
||||||
) : null}
|
|
||||||
</Space>
|
</Space>
|
||||||
</Space>
|
</Space>
|
||||||
|
|
||||||
@@ -574,54 +722,115 @@ export default function OrdersPage() {
|
|||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={() => { setPage(1); void load(); }}>
|
<Form form={form} layout="vertical" onFinish={() => { setPage(1); void load(); }}>
|
||||||
<Form.Item name="orderNo" label="订单号">
|
<Row gutter={[16, 8]}>
|
||||||
<Input placeholder="DK..." allowClear />
|
<Col xs={24} md={14} lg={12}>
|
||||||
|
<Form.Item label="下单日期" style={{ marginBottom: 12 }}>
|
||||||
|
<Space direction="vertical" size={8} style={{ width: '100%' }}>
|
||||||
|
<Form.Item name="dateRange" noStyle>
|
||||||
|
<DatePicker.RangePicker allowClear style={{ width: '100%' }} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="status" label="状态">
|
<Space size={8} wrap>
|
||||||
<Select allowClear style={{ width: 120 }} options={Object.entries(ORDER_STATUS_LABELS).map(([value, label]) => ({ value, label }))} />
|
{DATE_PRESETS.map((preset) => (
|
||||||
|
<Button
|
||||||
|
key={preset.key}
|
||||||
|
size="small"
|
||||||
|
onClick={() => form.setFieldsValue({ dateRange: datePresetRange(preset.key) })}
|
||||||
|
>
|
||||||
|
{preset.label}
|
||||||
|
</Button>
|
||||||
|
))}
|
||||||
|
</Space>
|
||||||
|
</Space>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="orderType" label="类型">
|
</Col>
|
||||||
|
<Col xs={12} sm={6} md={5} lg={3}>
|
||||||
|
<Form.Item name="status" label="状态" style={{ marginBottom: 12 }}>
|
||||||
<Select
|
<Select
|
||||||
allowClear
|
allowClear
|
||||||
style={{ width: 120 }}
|
|
||||||
placeholder="全部"
|
placeholder="全部"
|
||||||
options={[
|
options={Object.entries(ORDER_STATUS_LABELS).map(([value, label]) => ({ value, label }))}
|
||||||
{ value: 'NORMAL', label: '普通订单' },
|
|
||||||
{ value: 'PROXY', label: '代下单' },
|
|
||||||
]}
|
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="cityId" label="城市">
|
</Col>
|
||||||
|
<Col xs={12} sm={6} md={5} lg={3}>
|
||||||
|
<Form.Item name="orderType" label="类型" style={{ marginBottom: 12 }}>
|
||||||
|
<Select allowClear placeholder="全部" options={ORDER_TYPE_OPTIONS} />
|
||||||
|
</Form.Item>
|
||||||
|
</Col>
|
||||||
|
<Col xs={12} sm={6} md={5} lg={3}>
|
||||||
|
<Form.Item name="deliveryType" label="配送" style={{ marginBottom: 12 }}>
|
||||||
|
<Select allowClear placeholder="全部" options={DELIVERY_TYPE_OPTIONS} />
|
||||||
|
</Form.Item>
|
||||||
|
</Col>
|
||||||
|
<Col xs={12} sm={6} md={5} lg={3}>
|
||||||
|
<Form.Item name="cityId" label="城市" style={{ marginBottom: 12 }}>
|
||||||
<Select
|
<Select
|
||||||
allowClear
|
allowClear
|
||||||
showSearch
|
showSearch
|
||||||
optionFilterProp="label"
|
optionFilterProp="label"
|
||||||
style={{ width: 140 }}
|
|
||||||
placeholder="全部"
|
placeholder="全部"
|
||||||
options={cities.map((c) => ({ value: c.id, label: c.name }))}
|
options={cities.map((c) => ({ value: c.id, label: c.name }))}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="receiverPhone" label="收货手机">
|
</Col>
|
||||||
<Input allowClear />
|
<Col xs={12} sm={8} md={6} lg={6}>
|
||||||
|
<Form.Item name="receiverPhone" label="收货手机" style={{ marginBottom: 12 }}>
|
||||||
|
<Input allowClear placeholder="手机号" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="fulfillmentHold" label="大单拦截" valuePropName="checked">
|
</Col>
|
||||||
<Select
|
<Col xs={12} sm={8} md={8} lg={8}>
|
||||||
allowClear
|
<Form.Item label=" " colon={false} style={{ marginBottom: 12 }}>
|
||||||
style={{ width: 140 }}
|
<Space size={16} wrap>
|
||||||
placeholder="全部"
|
<Form.Item name="fulfillmentHold" valuePropName="checked" noStyle>
|
||||||
options={[{ value: true, label: '仅待确认大单' }]}
|
<Checkbox>大单拦截</Checkbox>
|
||||||
/>
|
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="excludeTest" valuePropName="checked">
|
<Form.Item name="excludeTest" valuePropName="checked" noStyle>
|
||||||
<Checkbox>过滤测试账号</Checkbox>
|
<Checkbox>过滤测试</Checkbox>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item>
|
|
||||||
<Space>
|
|
||||||
<Button type="primary" htmlType="submit">查询</Button>
|
|
||||||
<Button onClick={() => { form.resetFields(); setPage(1); void load(); }}>重置</Button>
|
|
||||||
</Space>
|
</Space>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', margin: '8px 0 16px', gap: 12, flexWrap: 'wrap' }}>
|
||||||
|
{canExportOrders ? (
|
||||||
|
<Space size={12} wrap>
|
||||||
|
<Radio.Group
|
||||||
|
optionType="button"
|
||||||
|
buttonStyle="solid"
|
||||||
|
value={exportFormat}
|
||||||
|
onChange={(e) => setExportFormat(e.target.value)}
|
||||||
|
>
|
||||||
|
<Radio.Button value="xlsx">Excel</Radio.Button>
|
||||||
|
<Radio.Button value="pdf">PDF</Radio.Button>
|
||||||
|
</Radio.Group>
|
||||||
|
<Button
|
||||||
|
disabled={!selectedRowKeys.length}
|
||||||
|
loading={exporting}
|
||||||
|
onClick={() => void submitExport('selected')}
|
||||||
|
>
|
||||||
|
导出已勾选{selectedRowKeys.length ? `(${selectedRowKeys.length})` : ''}
|
||||||
|
</Button>
|
||||||
|
<Button loading={exporting} onClick={() => void submitExport('filter')}>
|
||||||
|
导出全部筛选
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
) : <span />}
|
||||||
|
<Space size={12} wrap>
|
||||||
|
<Button type="primary" htmlType="submit">查询</Button>
|
||||||
|
<Button onClick={() => { form.resetFields(); setPage(1); void load(); }}>重置</Button>
|
||||||
|
{canDeleteOrders ? (
|
||||||
|
<Button
|
||||||
|
danger
|
||||||
|
disabled={!selectedRowKeys.length}
|
||||||
|
onClick={() => setBatchDeleteOpen(true)}
|
||||||
|
>
|
||||||
|
批量删除{selectedRowKeys.length ? `(${selectedRowKeys.length})` : ''}
|
||||||
|
</Button>
|
||||||
|
) : null}
|
||||||
|
</Space>
|
||||||
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
||||||
<Table
|
<Table
|
||||||
@@ -629,16 +838,18 @@ export default function OrdersPage() {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data?.items ?? []}
|
dataSource={data?.items ?? []}
|
||||||
scroll={{ x: 1500 }}
|
scroll={{ x: 'max-content' }}
|
||||||
rowSelection={canDeleteOrders ? {
|
rowSelection={{
|
||||||
selectedRowKeys,
|
selectedRowKeys,
|
||||||
|
preserveSelectedRowKeys: true,
|
||||||
onChange: (keys) => setSelectedRowKeys(keys as string[]),
|
onChange: (keys) => setSelectedRowKeys(keys as string[]),
|
||||||
} : undefined}
|
}}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: page,
|
current: page,
|
||||||
pageSize,
|
pageSize,
|
||||||
total: data?.total ?? 0,
|
total: data?.total ?? 0,
|
||||||
showSizeChanger: true,
|
showSizeChanger: true,
|
||||||
|
showTotal: (total) => `共 ${total} 条`,
|
||||||
onChange: (p, ps) => {
|
onChange: (p, ps) => {
|
||||||
setPage(p);
|
setPage(p);
|
||||||
setPageSize(ps);
|
setPageSize(ps);
|
||||||
@@ -811,7 +1022,7 @@ export default function OrdersPage() {
|
|||||||
locale={{ emptyText: '暂无关联核销单' }}
|
locale={{ emptyText: '暂无关联核销单' }}
|
||||||
dataSource={detail.redeemRecords ?? []}
|
dataSource={detail.redeemRecords ?? []}
|
||||||
columns={[
|
columns={[
|
||||||
{ title: '核销号', dataIndex: 'redeemNo', width: 160, ellipsis: true },
|
{ title: '核销号', dataIndex: 'redeemNo', width: 160 },
|
||||||
{
|
{
|
||||||
title: '角色',
|
title: '角色',
|
||||||
dataIndex: 'role',
|
dataIndex: 'role',
|
||||||
@@ -822,7 +1033,6 @@ export default function OrdersPage() {
|
|||||||
{
|
{
|
||||||
title: '门店',
|
title: '门店',
|
||||||
dataIndex: ['store', 'name'],
|
dataIndex: ['store', 'name'],
|
||||||
ellipsis: true,
|
|
||||||
render: (v: string | undefined, row) =>
|
render: (v: string | undefined, row) =>
|
||||||
v ? `${v}${row.store?.cityName ? `(${row.store.cityName})` : ''}` : '—',
|
v ? `${v}${row.store?.cityName ? `(${row.store.cityName})` : ''}` : '—',
|
||||||
},
|
},
|
||||||
@@ -938,7 +1148,6 @@ export default function OrdersPage() {
|
|||||||
{
|
{
|
||||||
title: '备注',
|
title: '备注',
|
||||||
dataIndex: 'remark',
|
dataIndex: 'remark',
|
||||||
ellipsis: true,
|
|
||||||
render: (v) => v || '—',
|
render: (v) => v || '—',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1233,7 +1442,6 @@ export default function OrdersPage() {
|
|||||||
{
|
{
|
||||||
title: '商品',
|
title: '商品',
|
||||||
width: 160,
|
width: 160,
|
||||||
ellipsis: true,
|
|
||||||
render: (_, row) =>
|
render: (_, row) =>
|
||||||
row.productName
|
row.productName
|
||||||
? `${row.productName}${row.quantity != null ? ` ×${row.quantity}` : ''}`
|
? `${row.productName}${row.quantity != null ? ` ×${row.quantity}` : ''}`
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import { PARTNER_PERMISSION_KEYS, PARTNER_PERMISSION_LABELS, PARTNER_STAFF_ROLE_
|
|||||||
import { request, type Paginated } from '../lib/api';
|
import { request, type Paginated } from '../lib/api';
|
||||||
import { AdminCellLine } from '../components/AdminCellLine';
|
import { AdminCellLine } from '../components/AdminCellLine';
|
||||||
import { ACCOUNT_STATUS_LABELS, ADMIN_OPTIONS_PAGE_SIZE, ORDER_STATUS_LABELS, PARTNER_BILL_STATUS_LABELS, fmtTime } from '../lib/constants';
|
import { ACCOUNT_STATUS_LABELS, ADMIN_OPTIONS_PAGE_SIZE, ORDER_STATUS_LABELS, PARTNER_BILL_STATUS_LABELS, fmtTime } from '../lib/constants';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type PartnerOption = { id: string; companyName: string };
|
type PartnerOption = { id: string; companyName: string };
|
||||||
type ParentAccount = { id: string; name: string; phone: string };
|
type ParentAccount = { id: string; name: string; phone: string };
|
||||||
@@ -169,11 +171,10 @@ export default function PartnerAccountsPage() {
|
|||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<AccountTreeRow> = [
|
const baseColumns: ColumnsType<AccountTreeRow> = [
|
||||||
{
|
{
|
||||||
title: '姓名 / 类型',
|
title: '姓名 / 类型',
|
||||||
width: 200,
|
width: 200,
|
||||||
ellipsis: true,
|
|
||||||
render: (_, row) => (
|
render: (_, row) => (
|
||||||
<AdminCellLine
|
<AdminCellLine
|
||||||
primary={row.name}
|
primary={row.name}
|
||||||
@@ -189,7 +190,6 @@ export default function PartnerAccountsPage() {
|
|||||||
{
|
{
|
||||||
title: '开城合伙人',
|
title: '开城合伙人',
|
||||||
width: 140,
|
width: 140,
|
||||||
ellipsis: true,
|
|
||||||
render: (_, row) => row.companyName || row.parent?.name || '—',
|
render: (_, row) => row.companyName || row.parent?.name || '—',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -254,11 +254,18 @@ export default function PartnerAccountsPage() {
|
|||||||
{ title: '下单', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
{ title: '下单', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('partner-accounts', baseColumns, {
|
||||||
|
page: 1,
|
||||||
|
pageSize: treeData.length || 20,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
||||||
<div>
|
<div>
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>合伙人子账号</Typography.Title>
|
<Typography.Title level={4} style={{ margin: 0 }}>合伙人子账号</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Typography.Text type="secondary">
|
<Typography.Text type="secondary">
|
||||||
主账号在「开城合伙人」创建;此处仅管理子账号树与权限
|
主账号在「开城合伙人」创建;此处仅管理子账号树与权限
|
||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
@@ -305,7 +312,7 @@ export default function PartnerAccountsPage() {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={treeData}
|
dataSource={treeData}
|
||||||
scroll={{ x: 1200 }}
|
scroll={{ x: 'max-content' }}
|
||||||
pagination={false}
|
pagination={false}
|
||||||
expandable={{
|
expandable={{
|
||||||
expandedRowKeys,
|
expandedRowKeys,
|
||||||
@@ -399,7 +406,7 @@ export default function PartnerAccountsPage() {
|
|||||||
label: `账单 (${detail.bills?.length ?? 0})`,
|
label: `账单 (${detail.bills?.length ?? 0})`,
|
||||||
children: (
|
children: (
|
||||||
<Table rowKey="id" className="admin-table-nowrap" size="small" columns={billColumns}
|
<Table rowKey="id" className="admin-table-nowrap" size="small" columns={billColumns}
|
||||||
dataSource={detail.bills ?? []} pagination={false} scroll={{ x: 700 }} />
|
dataSource={detail.bills ?? []} pagination={false} scroll={{ x: 'max-content' }} />
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -407,7 +414,7 @@ export default function PartnerAccountsPage() {
|
|||||||
label: `名下订单 (${detail.orders?.length ?? 0})`,
|
label: `名下订单 (${detail.orders?.length ?? 0})`,
|
||||||
children: (
|
children: (
|
||||||
<Table rowKey="id" className="admin-table-nowrap" size="small" columns={orderColumns}
|
<Table rowKey="id" className="admin-table-nowrap" size="small" columns={orderColumns}
|
||||||
dataSource={detail.orders ?? []} pagination={false} scroll={{ x: 650 }} />
|
dataSource={detail.orders ?? []} pagination={false} scroll={{ x: 'max-content' }} />
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
]} />
|
]} />
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import {
|
|||||||
Button,
|
Button,
|
||||||
Card,
|
Card,
|
||||||
DatePicker,
|
DatePicker,
|
||||||
|
Descriptions,
|
||||||
|
Drawer,
|
||||||
Form,
|
Form,
|
||||||
Input,
|
Input,
|
||||||
Modal,
|
Modal,
|
||||||
@@ -20,6 +22,8 @@ import { request, type Paginated } from '../lib/api';
|
|||||||
import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
|
import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
|
||||||
import { downloadExcelCsv } from '../lib/exportExcel';
|
import { downloadExcelCsv } from '../lib/exportExcel';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -31,8 +35,22 @@ type Row = {
|
|||||||
periodStart: string;
|
periodStart: string;
|
||||||
periodEnd: string;
|
periodEnd: string;
|
||||||
rejectReason?: string | null;
|
rejectReason?: string | null;
|
||||||
partner?: { companyName?: string; phone?: string };
|
paymentRef?: string | null;
|
||||||
partnerAccount?: { companyName?: string; phone?: string };
|
paidAt?: string | null;
|
||||||
|
partner?: {
|
||||||
|
companyName?: string;
|
||||||
|
phone?: string;
|
||||||
|
bankAccountName?: string | null;
|
||||||
|
bankAccountNo?: string | null;
|
||||||
|
bankBranch?: string | null;
|
||||||
|
};
|
||||||
|
partnerAccount?: {
|
||||||
|
companyName?: string;
|
||||||
|
phone?: string;
|
||||||
|
bankAccountName?: string | null;
|
||||||
|
bankAccountNo?: string | null;
|
||||||
|
bankBranch?: string | null;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
type PartnerOption = { id: string; companyName: string; phone?: string };
|
type PartnerOption = { id: string; companyName: string; phone?: string };
|
||||||
@@ -77,6 +95,8 @@ export default function PartnerBillsPage() {
|
|||||||
const [rejectForm] = Form.useForm();
|
const [rejectForm] = Form.useForm();
|
||||||
const [rejecting, setRejecting] = useState(false);
|
const [rejecting, setRejecting] = useState(false);
|
||||||
const [selectedKeys, setSelectedKeys] = useState<React.Key[]>([]);
|
const [selectedKeys, setSelectedKeys] = useState<React.Key[]>([]);
|
||||||
|
const [detail, setDetail] = useState<Row | null>(null);
|
||||||
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void request<Paginated<PartnerOption>>(`/admin/partners?pageSize=${ADMIN_OPTIONS_PAGE_SIZE}`)
|
void request<Paginated<PartnerOption>>(`/admin/partners?pageSize=${ADMIN_OPTIONS_PAGE_SIZE}`)
|
||||||
@@ -127,17 +147,30 @@ export default function PartnerBillsPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function markPaid(ids: string[], amountHint?: number) {
|
function markPaid(ids: string[], amountHint?: number) {
|
||||||
|
let paymentRef = '';
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: '确认打款?',
|
title: '确认打款?',
|
||||||
content: `将标记 ${ids.length} 笔账单为已打款${amountHint != null ? `,合计约 ¥${amountHint.toFixed(2)}` : ''}。`,
|
content: (
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
将标记 {ids.length} 笔账单为已打款
|
||||||
|
{amountHint != null ? `,合计约 ¥${amountHint.toFixed(2)}` : ''}。
|
||||||
|
</div>
|
||||||
|
<Input
|
||||||
|
placeholder="打款凭证号(可选)"
|
||||||
|
style={{ marginTop: 8 }}
|
||||||
|
onChange={(e) => {
|
||||||
|
paymentRef = e.target.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
okText: '确认打款',
|
okText: '确认打款',
|
||||||
cancelText: '取消',
|
cancelText: '取消',
|
||||||
onOk: async () => {
|
onOk: async () => {
|
||||||
|
const body = JSON.stringify({ paymentRef: paymentRef.trim() || undefined });
|
||||||
if (ids.length === 1) {
|
if (ids.length === 1) {
|
||||||
await request(`/admin/partner-bills/${ids[0]}/mark-paid`, {
|
await request(`/admin/partner-bills/${ids[0]}/mark-paid`, { method: 'POST', body });
|
||||||
method: 'POST',
|
|
||||||
body: JSON.stringify({ paymentRef: `PAY-${Date.now()}` }),
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
await request('/admin/partner-bills/batch-mark-paid', {
|
await request('/admin/partner-bills/batch-mark-paid', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -182,6 +215,12 @@ export default function PartnerBillsPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function openDetail(id: string) {
|
||||||
|
const d = await request<Row>(`/admin/partner-bills/${id}`);
|
||||||
|
setDetail(d);
|
||||||
|
setDrawerOpen(true);
|
||||||
|
}
|
||||||
|
|
||||||
async function exportExcel() {
|
async function exportExcel() {
|
||||||
setExporting(true);
|
setExporting(true);
|
||||||
try {
|
try {
|
||||||
@@ -201,17 +240,17 @@ export default function PartnerBillsPage() {
|
|||||||
|
|
||||||
const summary = data?.summary;
|
const summary = data?.summary;
|
||||||
const partnerName = (r: Row) => r.partner?.companyName || r.partnerAccount?.companyName || '—';
|
const partnerName = (r: Row) => r.partner?.companyName || r.partnerAccount?.companyName || '—';
|
||||||
|
const partnerBank = (r: Row) => r.partnerAccount ?? r.partner;
|
||||||
const selectedRows = (data?.items ?? []).filter((r) => selectedKeys.includes(r.id));
|
const selectedRows = (data?.items ?? []).filter((r) => selectedKeys.includes(r.id));
|
||||||
const canSend = selectedRows.filter((r) => r.status === 'PENDING_REVIEW' || r.status === 'REJECTED');
|
const canSend = selectedRows.filter((r) => r.status === 'PENDING_REVIEW' || r.status === 'REJECTED');
|
||||||
const canPay = selectedRows.filter((r) => r.status === 'UNPAID');
|
const canPay = selectedRows.filter((r) => r.status === 'UNPAID');
|
||||||
const payAmount = canPay.reduce((s, r) => s + Number(r.totalAmount), 0);
|
const payAmount = canPay.reduce((s, r) => s + Number(r.totalAmount), 0);
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{ title: '账单号', dataIndex: 'billNo', width: 180, ellipsis: true },
|
{ title: '账单号', dataIndex: 'billNo', width: 180 },
|
||||||
{
|
{
|
||||||
title: '合伙人',
|
title: '合伙人',
|
||||||
width: 160,
|
width: 160,
|
||||||
ellipsis: true,
|
|
||||||
|
|
||||||
render: (_, r) => partnerName(r),
|
render: (_, r) => partnerName(r),
|
||||||
},
|
},
|
||||||
@@ -238,6 +277,16 @@ export default function PartnerBillsPage() {
|
|||||||
dataIndex: 'totalAmount',
|
dataIndex: 'totalAmount',
|
||||||
width: 110,
|
width: 110,
|
||||||
render: (v) => `¥${Number(v).toFixed(2)}`,
|
render: (v) => `¥${Number(v).toFixed(2)}`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '收款户名',
|
||||||
|
width: 100,
|
||||||
|
|
||||||
|
render: (_, r) => partnerBank(r)?.bankAccountName || '—',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '收款账号',
|
||||||
|
width: 140,
|
||||||
|
|
||||||
render: (_, r) => partnerBank(r)?.bankAccountNo || '—',
|
render: (_, r) => partnerBank(r)?.bankAccountNo || '—',
|
||||||
},
|
},
|
||||||
@@ -259,6 +308,9 @@ export default function PartnerBillsPage() {
|
|||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
width: 220,
|
width: 220,
|
||||||
|
fixed: 'right',
|
||||||
|
render: (_, row) => (
|
||||||
|
<Space size={0} wrap>
|
||||||
<Button type="link" size="small" onClick={() => void openDetail(row.id)}>
|
<Button type="link" size="small" onClick={() => void openDetail(row.id)}>
|
||||||
明细
|
明细
|
||||||
</Button>
|
</Button>
|
||||||
@@ -284,12 +336,16 @@ export default function PartnerBillsPage() {
|
|||||||
)}
|
)}
|
||||||
</Space>
|
</Space>
|
||||||
),
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
const { columns, settingsButton, settingsModal } = useAdminListColumns('finance-partner-bills', baseColumns, { page, pageSize });
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('finance-partner-bills', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{settingsModal}
|
{settingsModal}
|
||||||
<Space direction="vertical" size={0} style={{ marginBottom: 16 }}>
|
<Space direction="vertical" size={0} style={{ marginBottom: 16 }}>
|
||||||
|
<Typography.Title level={4} style={{ margin: 0 }}>
|
||||||
合伙人账单
|
合伙人账单
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
{settingsButton}
|
{settingsButton}
|
||||||
@@ -395,7 +451,7 @@ export default function PartnerBillsPage() {
|
|||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data?.items ?? []}
|
dataSource={data?.items ?? []}
|
||||||
rowSelection={{
|
rowSelection={{
|
||||||
scroll={{ x: 1280 }}
|
selectedRowKeys: selectedKeys,
|
||||||
onChange: setSelectedKeys,
|
onChange: setSelectedKeys,
|
||||||
}}
|
}}
|
||||||
scroll={{ x: 'max-content' }}
|
scroll={{ x: 'max-content' }}
|
||||||
@@ -465,6 +521,59 @@ export default function PartnerBillsPage() {
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Button type="primary" danger htmlType="submit" block loading={rejecting}>
|
<Button type="primary" danger htmlType="submit" block loading={rejecting}>
|
||||||
确认驳回
|
确认驳回
|
||||||
|
</Button>
|
||||||
|
</Form>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
|
<Drawer
|
||||||
|
title="合伙人账单明细"
|
||||||
|
open={drawerOpen}
|
||||||
|
onClose={() => setDrawerOpen(false)}
|
||||||
|
width={560}
|
||||||
|
>
|
||||||
|
{detail && (
|
||||||
|
<>
|
||||||
|
<Descriptions column={1} size="small" bordered>
|
||||||
|
<Descriptions.Item label="账单号">{detail.billNo}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="合伙人">{partnerName(detail)}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="账期">
|
||||||
|
{String(detail.periodStart).slice(0, 10)} ~ {String(detail.periodEnd).slice(0, 10)}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="订单佣金">
|
||||||
|
¥{Number(detail.orderCommission).toFixed(2)}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="核销佣金">
|
||||||
|
¥{Number(detail.redeemCommission).toFixed(2)}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="应付合计">
|
||||||
|
¥{Number(detail.totalAmount).toFixed(2)}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="状态">
|
||||||
|
<Tag color={STATUS_COLORS[detail.status] || 'default'}>
|
||||||
|
{STATUS_LABELS[detail.status] || detail.status}
|
||||||
|
</Tag>
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="打款时间">
|
||||||
|
{detail.paidAt ? fmtTime(detail.paidAt) : '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="打款凭证">
|
||||||
|
{detail.paymentRef ? String(detail.paymentRef) : '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
</Descriptions>
|
||||||
|
<Typography.Title level={5} style={{ marginTop: 16 }}>
|
||||||
|
收款账户
|
||||||
|
</Typography.Title>
|
||||||
|
<Descriptions column={1} size="small" bordered>
|
||||||
|
<Descriptions.Item label="户名">
|
||||||
|
{partnerBank(detail)?.bankAccountName || '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="账号">
|
||||||
|
{partnerBank(detail)?.bankAccountNo || '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="开户行">
|
||||||
|
{partnerBank(detail)?.bankBranch || '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
</Descriptions>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Drawer>
|
</Drawer>
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import { request } from '../lib/api';
|
|||||||
import { AdminCellLine } from '../components/AdminCellLine';
|
import { AdminCellLine } from '../components/AdminCellLine';
|
||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -71,12 +73,11 @@ export default function PartnerLogsPage() {
|
|||||||
form.setFieldsValue(filters);
|
form.setFieldsValue(filters);
|
||||||
}, [form, filters]);
|
}, [form, filters]);
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{ title: '时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
{ title: '时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
||||||
{
|
{
|
||||||
title: '合伙人',
|
title: '合伙人',
|
||||||
width: 180,
|
width: 180,
|
||||||
ellipsis: true,
|
|
||||||
|
|
||||||
render: (_, r) => (
|
render: (_, r) => (
|
||||||
r.isSubAccount ? (
|
r.isSubAccount ? (
|
||||||
@@ -88,7 +89,6 @@ export default function PartnerLogsPage() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '账号',
|
title: '账号',
|
||||||
ellipsis: true,
|
|
||||||
width: 150,
|
width: 150,
|
||||||
|
|
||||||
render: (_, r) => (
|
render: (_, r) => (
|
||||||
@@ -116,7 +116,6 @@ export default function PartnerLogsPage() {
|
|||||||
width: 120,
|
width: 120,
|
||||||
render: (_, r) => (r.refType && r.refId ? `${r.refType}#${r.refId}` : '—'),
|
render: (_, r) => (r.refType && r.refId ? `${r.refType}#${r.refId}` : '—'),
|
||||||
},
|
},
|
||||||
ellipsis: true,
|
|
||||||
{
|
{
|
||||||
title: '摘要',
|
title: '摘要',
|
||||||
|
|
||||||
@@ -137,11 +136,15 @@ export default function PartnerLogsPage() {
|
|||||||
详情
|
详情
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
const { columns, settingsButton, settingsModal } = useAdminListColumns('logs-partners', baseColumns, { page, pageSize });
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('logs-partners', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{settingsModal}
|
{settingsModal}
|
||||||
|
<Typography.Title level={4} style={{ marginBottom: 16 }}>
|
||||||
合伙人日志
|
合伙人日志
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
{settingsButton}
|
{settingsButton}
|
||||||
@@ -216,7 +219,7 @@ export default function PartnerLogsPage() {
|
|||||||
showSizeChanger: true,
|
showSizeChanger: true,
|
||||||
onChange: (p, ps) => {
|
onChange: (p, ps) => {
|
||||||
setPage(p);
|
setPage(p);
|
||||||
scroll={{ x: 1100 }}
|
setPageSize(ps);
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
scroll={{ x: 'max-content' }}
|
scroll={{ x: 'max-content' }}
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ import { districtCodeLabel, formatDistrictLabels } from '../lib/china-region';
|
|||||||
import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
|
import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
import CityDistrictMultiSelect from '../components/CityDistrictMultiSelect';
|
import CityDistrictMultiSelect from '../components/CityDistrictMultiSelect';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -173,17 +175,16 @@ export default function PartnersPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{ title: '城市', dataIndex: 'cityName', width: 100 },
|
{ title: '城市', dataIndex: 'cityName', width: 100 },
|
||||||
{
|
{
|
||||||
title: '区县',
|
title: '区县',
|
||||||
dataIndex: 'districtCodes',
|
dataIndex: 'districtCodes',
|
||||||
width: 160,
|
width: 160,
|
||||||
ellipsis: true,
|
|
||||||
|
|
||||||
render: (codes: string[] | null | undefined, row) =>
|
render: (codes: string[] | null | undefined, row) =>
|
||||||
row.scopeType === CityPartnerScopeType.CITY_WIDE ? '全城' : formatDistrictLabels(codes),
|
row.scopeType === CityPartnerScopeType.CITY_WIDE ? '全城' : formatDistrictLabels(codes),
|
||||||
{ title: '公司名', dataIndex: 'companyName', ellipsis: true },
|
},
|
||||||
{ title: '公司名', dataIndex: 'companyName' },
|
{ title: '公司名', dataIndex: 'companyName' },
|
||||||
{ title: '主账号', dataIndex: 'phone', width: 130 },
|
{ title: '主账号', dataIndex: 'phone', width: 130 },
|
||||||
{
|
{
|
||||||
@@ -205,10 +206,14 @@ export default function PartnersPage() {
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('partners', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<div>
|
||||||
{settingsModal}
|
{settingsModal}
|
||||||
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
||||||
|
<Typography.Title level={4} style={{ margin: 0 }}>开城合伙人</Typography.Title>
|
||||||
{settingsButton}
|
{settingsButton}
|
||||||
<Button type="primary" onClick={() => { setCreateOpen(true); createForm.resetFields(); setCreateScopeType(CityPartnerScopeType.CITY_WIDE); }}>
|
<Button type="primary" onClick={() => { setCreateOpen(true); createForm.resetFields(); setCreateScopeType(CityPartnerScopeType.CITY_WIDE); }}>
|
||||||
新建城市合伙人
|
新建城市合伙人
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ import {
|
|||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
const STATUS_COLOR: Record<RedeemPendingStatus, string> = {
|
const STATUS_COLOR: Record<RedeemPendingStatus, string> = {
|
||||||
PENDING: 'orange',
|
PENDING: 'orange',
|
||||||
@@ -94,13 +96,12 @@ export default function PendingRedeemPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<RedeemPendingItem> = [
|
const baseColumns: ColumnsType<RedeemPendingItem> = [
|
||||||
{ title: '待处理单号', dataIndex: 'pendingNo', width: 170 },
|
{ title: '待处理单号', dataIndex: 'pendingNo', width: 170 },
|
||||||
{
|
{
|
||||||
title: '核销码 ID',
|
title: '核销码 ID',
|
||||||
dataIndex: 'redeemToken',
|
dataIndex: 'redeemToken',
|
||||||
width: 160,
|
width: 160,
|
||||||
ellipsis: true,
|
|
||||||
|
|
||||||
render: (v: string) => <Typography.Text copyable={{ text: v }}>{v.slice(0, 8)}…</Typography.Text>,
|
render: (v: string) => <Typography.Text copyable={{ text: v }}>{v.slice(0, 8)}…</Typography.Text>,
|
||||||
},
|
},
|
||||||
@@ -132,9 +133,13 @@ export default function PendingRedeemPage() {
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('redeem-pending', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<div>
|
||||||
{settingsModal}
|
{settingsModal}
|
||||||
|
<Typography.Title level={4}>待处理核销(弱网兜底)</Typography.Title>
|
||||||
{settingsButton}
|
{settingsButton}
|
||||||
<Form
|
<Form
|
||||||
form={form}
|
form={form}
|
||||||
@@ -175,7 +180,7 @@ export default function PendingRedeemPage() {
|
|||||||
rowKey="id"
|
rowKey="id"
|
||||||
loading={loading}
|
loading={loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
scroll={{ x: 1100 }}
|
dataSource={data?.items ?? []}
|
||||||
scroll={{ x: 'max-content' }}
|
scroll={{ x: 'max-content' }}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: page,
|
current: page,
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import { useAdminList } from '../lib/useAdminList';
|
|||||||
import DetailImageUrlList from '../components/DetailImageUrlList';
|
import DetailImageUrlList from '../components/DetailImageUrlList';
|
||||||
import type { ProductDetailTemplateDto } from '../lib/product-detail-templates';
|
import type { ProductDetailTemplateDto } from '../lib/product-detail-templates';
|
||||||
import { TEMPLATE_MAX_DETAIL_IMAGES } from '../lib/product-detail-templates';
|
import { TEMPLATE_MAX_DETAIL_IMAGES } from '../lib/product-detail-templates';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type Row = ProductDetailTemplateDto;
|
type Row = ProductDetailTemplateDto;
|
||||||
|
|
||||||
@@ -136,10 +138,10 @@ export default function ProductDetailTemplatesPage() {
|
|||||||
const [drawerOpen, setDrawerOpen] = useState(false);
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
||||||
const [createOpen, setCreateOpen] = useState(false);
|
const [createOpen, setCreateOpen] = useState(false);
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{ title: '编码', dataIndex: 'code', width: 120 },
|
{ title: '编码', dataIndex: 'code', width: 120 },
|
||||||
{ title: '名称', dataIndex: 'name', width: 120 },
|
{ title: '名称', dataIndex: 'name', width: 120 },
|
||||||
{ title: '说明', dataIndex: 'description', width: 200, ellipsis: true },
|
{ title: '说明', dataIndex: 'description', width: 200 },
|
||||||
{ title: '香型', dataIndex: 'aromaType', width: 90, render: (v) => (v ? AROMA_TYPE_LABELS[v] || v : '—') },
|
{ title: '香型', dataIndex: 'aromaType', width: 90, render: (v) => (v ? AROMA_TYPE_LABELS[v] || v : '—') },
|
||||||
{ title: '详情图', dataIndex: 'detailImageUrls', width: 80, render: (v: string[] | undefined) => v?.length ?? 0 },
|
{ title: '详情图', dataIndex: 'detailImageUrls', width: 80, render: (v: string[] | undefined) => v?.length ?? 0 },
|
||||||
{ title: '排序', dataIndex: 'sortOrder', width: 60 },
|
{ title: '排序', dataIndex: 'sortOrder', width: 60 },
|
||||||
@@ -158,10 +160,17 @@ export default function ProductDetailTemplatesPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('product-detail-templates', baseColumns, {
|
||||||
|
page,
|
||||||
|
pageSize,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>商品详情模板</Typography.Title>
|
<Typography.Title level={4} style={{ margin: 0 }}>商品详情模板</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Button type="primary" onClick={() => setCreateOpen(true)}>新建模板</Button>
|
<Button type="primary" onClick={() => setCreateOpen(true)}>新建模板</Button>
|
||||||
</Space>
|
</Space>
|
||||||
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
|
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
|
||||||
@@ -175,7 +184,7 @@ export default function ProductDetailTemplatesPage() {
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item><Button type="primary" htmlType="submit">查询</Button></Form.Item>
|
<Form.Item><Button type="primary" htmlType="submit">查询</Button></Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
<Table rowKey="id" className="admin-table-nowrap" loading={loading} columns={columns} dataSource={data?.items ?? []} scroll={{ x: 1100 }}
|
<Table rowKey="id" className="admin-table-nowrap" loading={loading} columns={columns} dataSource={data?.items ?? []} scroll={{ x: 'max-content' }}
|
||||||
pagination={{ current: page, pageSize, total: data?.total ?? 0, showSizeChanger: true, onChange: (p, ps) => { setPage(p); setPageSize(ps); } }} />
|
pagination={{ current: page, pageSize, total: data?.total ?? 0, showSizeChanger: true, onChange: (p, ps) => { setPage(p); setPageSize(ps); } }} />
|
||||||
<Drawer title="编辑详情模板" width={640} open={drawerOpen} onClose={() => setDrawerOpen(false)}
|
<Drawer title="编辑详情模板" width={640} open={drawerOpen} onClose={() => setDrawerOpen(false)}
|
||||||
extra={detail && (
|
extra={detail && (
|
||||||
|
|||||||
@@ -12,7 +12,10 @@ import OssUpload from '../components/OssUpload';
|
|||||||
import MultiImageUpload from '../components/MultiImageUpload';
|
import MultiImageUpload from '../components/MultiImageUpload';
|
||||||
import DetailImageUrlList from '../components/DetailImageUrlList';
|
import DetailImageUrlList from '../components/DetailImageUrlList';
|
||||||
import ProductDetailTemplatePicker from '../components/ProductDetailTemplatePicker';
|
import ProductDetailTemplatePicker from '../components/ProductDetailTemplatePicker';
|
||||||
|
import ProductSpecsEditor from '../components/ProductSpecsEditor';
|
||||||
import type { FormInstance } from 'antd/es/form';
|
import type { FormInstance } from 'antd/es/form';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type ProductDetailContentDto = {
|
type ProductDetailContentDto = {
|
||||||
storyTitle?: string;
|
storyTitle?: string;
|
||||||
@@ -20,6 +23,22 @@ type ProductDetailContentDto = {
|
|||||||
features?: Array<{ icon: string; title: string; desc: string }>;
|
features?: Array<{ icon: string; title: string; desc: string }>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type SkuListRow = {
|
||||||
|
id: string;
|
||||||
|
skuCode: string;
|
||||||
|
barcode69: string;
|
||||||
|
specText: string;
|
||||||
|
price: number;
|
||||||
|
benefitAmount: number;
|
||||||
|
status: string;
|
||||||
|
isDefault?: boolean;
|
||||||
|
allowOnSitePickup?: boolean;
|
||||||
|
allowOnlinePurchase?: boolean;
|
||||||
|
allowCrossCityDelivery?: boolean;
|
||||||
|
soldBottles?: number;
|
||||||
|
virtual?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
id: string;
|
id: string;
|
||||||
skuCode: string;
|
skuCode: string;
|
||||||
@@ -29,9 +48,15 @@ type Row = {
|
|||||||
aromaType: string;
|
aromaType: string;
|
||||||
spec: string;
|
spec: string;
|
||||||
price: number;
|
price: number;
|
||||||
|
priceMin?: number;
|
||||||
|
priceMax?: number;
|
||||||
|
soldBottles?: number;
|
||||||
benefitAmount: number;
|
benefitAmount: number;
|
||||||
status: string;
|
status: string;
|
||||||
sortOrder: number;
|
sortOrder: number;
|
||||||
|
skuCount?: number;
|
||||||
|
specEnabled?: boolean;
|
||||||
|
skus?: SkuListRow[];
|
||||||
allowOnSitePickup?: boolean;
|
allowOnSitePickup?: boolean;
|
||||||
allowOnlinePurchase?: boolean;
|
allowOnlinePurchase?: boolean;
|
||||||
allowCrossCityDelivery?: boolean;
|
allowCrossCityDelivery?: boolean;
|
||||||
@@ -213,7 +238,33 @@ function VisibilityWhitelistFields({ form }: { form: FormInstance }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function BaseInfoFields({ mode, form }: { mode: 'create' | 'edit'; form: FormInstance }) {
|
function FulfillmentTags(row: {
|
||||||
|
allowOnlinePurchase?: boolean;
|
||||||
|
allowCrossCityDelivery?: boolean;
|
||||||
|
allowOnSitePickup?: boolean;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<Space size={[0, 4]} wrap>
|
||||||
|
{row.allowOnlinePurchase !== false ? <Tag color="blue">线上</Tag> : null}
|
||||||
|
{row.allowOnlinePurchase !== false && row.allowCrossCityDelivery !== false ? (
|
||||||
|
<Tag color="cyan">跨城</Tag>
|
||||||
|
) : null}
|
||||||
|
{row.allowOnSitePickup ? <Tag color="green">现场</Tag> : null}
|
||||||
|
{row.allowOnlinePurchase === false && !row.allowOnSitePickup ? <Tag>无</Tag> : null}
|
||||||
|
</Space>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function BaseInfoFields({
|
||||||
|
mode,
|
||||||
|
form,
|
||||||
|
hideFulfillment,
|
||||||
|
}: {
|
||||||
|
mode: 'create' | 'edit';
|
||||||
|
form: FormInstance;
|
||||||
|
/** 多规格商品:履约只在规格 SKU 上编辑 */
|
||||||
|
hideFulfillment?: boolean;
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{mode === 'create' && (
|
{mode === 'create' && (
|
||||||
@@ -221,8 +272,13 @@ function BaseInfoFields({ mode, form }: { mode: 'create' | 'edit'; form: FormIns
|
|||||||
<Form.Item label="SKU">
|
<Form.Item label="SKU">
|
||||||
<Input disabled placeholder="保存后自动生成" />
|
<Input disabled placeholder="保存后自动生成" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="barcode69" label="69码" rules={[{ required: true }]}>
|
<Form.Item
|
||||||
<Input />
|
name="barcode69"
|
||||||
|
label="69码"
|
||||||
|
rules={[{ required: true, message: '请填写默认规格 69 码' }]}
|
||||||
|
extra="默认规格的 69 码;若有多种规格,保存后请到「规格与 SKU」为每个规格分别填写不同 69 码"
|
||||||
|
>
|
||||||
|
<Input placeholder="默认规格 69 码" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="aromaType" label="香型" rules={[{ required: true }]}>
|
<Form.Item name="aromaType" label="香型" rules={[{ required: true }]}>
|
||||||
<Select options={Object.entries(AROMA_TYPE_LABELS).map(([value, label]) => ({ value, label }))} />
|
<Select options={Object.entries(AROMA_TYPE_LABELS).map(([value, label]) => ({ value, label }))} />
|
||||||
@@ -250,6 +306,12 @@ function BaseInfoFields({ mode, form }: { mode: 'create' | 'edit'; form: FormIns
|
|||||||
<Form.Item name="sortOrder" label="排序">
|
<Form.Item name="sortOrder" label="排序">
|
||||||
<InputNumber min={0} style={{ width: '100%' }} />
|
<InputNumber min={0} style={{ width: '100%' }} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
{hideFulfillment ? (
|
||||||
|
<Typography.Paragraph type="secondary" style={{ marginBottom: 16 }}>
|
||||||
|
该商品有多种规格,履约(线上 / 跨城 / 现场)请到「规格与 SKU」中按规格设置。
|
||||||
|
</Typography.Paragraph>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="allowOnlinePurchase"
|
name="allowOnlinePurchase"
|
||||||
label="允许线上购买"
|
label="允许线上购买"
|
||||||
@@ -283,6 +345,8 @@ function BaseInfoFields({ mode, form }: { mode: 'create' | 'edit'; form: FormIns
|
|||||||
<Form.Item name="allowOnSitePickup" label="允许现场取货" valuePropName="checked">
|
<Form.Item name="allowOnSitePickup" label="允许现场取货" valuePropName="checked">
|
||||||
<Switch checkedChildren="开" unCheckedChildren="关" />
|
<Switch checkedChildren="开" unCheckedChildren="关" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<VisibilityWhitelistFields form={form} />
|
<VisibilityWhitelistFields form={form} />
|
||||||
<Form.Item name="coverUrl" label="封面">
|
<Form.Item name="coverUrl" label="封面">
|
||||||
<OssUpload bizType="COVER" mediaType="IMAGE" />
|
<OssUpload bizType="COVER" mediaType="IMAGE" />
|
||||||
@@ -325,13 +389,36 @@ export default function ProductsPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = useMemo(() => [
|
const baseColumns: ColumnsType<Row> = useMemo(() => [
|
||||||
{ title: 'SKU', dataIndex: 'skuCode', width: 90 },
|
|
||||||
{ title: '商品名', dataIndex: 'name', width: 180, ellipsis: true },
|
|
||||||
{ title: '香型', dataIndex: 'aromaType', width: 80, render: (v) => AROMA_TYPE_LABELS[v] || v },
|
{ title: '香型', dataIndex: 'aromaType', width: 80, render: (v) => AROMA_TYPE_LABELS[v] || v },
|
||||||
{ title: '规格', dataIndex: 'spec', width: 120, ellipsis: true },
|
{ title: '品名', dataIndex: 'name', width: 200 },
|
||||||
{ title: '售价', dataIndex: 'price', width: 80, render: (v) => `¥${v}` },
|
{
|
||||||
{ title: '权益额', dataIndex: 'benefitAmount', width: 80, render: (v) => `¥${v}` },
|
title: '累计销售',
|
||||||
|
dataIndex: 'soldBottles',
|
||||||
|
width: 110,
|
||||||
|
render: (v: number | undefined) => `累计 ${v ?? 0} 瓶`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '售价',
|
||||||
|
key: 'priceRange',
|
||||||
|
width: 120,
|
||||||
|
render: (_, row) => {
|
||||||
|
const min = row.priceMin ?? row.price;
|
||||||
|
const max = row.priceMax ?? row.price;
|
||||||
|
if (min === max) return `¥${min}`;
|
||||||
|
return `¥${min} ~ ¥${max}`;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '规格数',
|
||||||
|
dataIndex: 'skuCount',
|
||||||
|
width: 80,
|
||||||
|
render: (v: number | undefined, row) => {
|
||||||
|
const real = v ?? 0;
|
||||||
|
if (real > 0) return real;
|
||||||
|
return row.skus?.some((s) => s.virtual) ? 1 : 0;
|
||||||
|
},
|
||||||
|
},
|
||||||
{ title: '状态', dataIndex: 'status', width: 80, render: (s) => (
|
{ title: '状态', dataIndex: 'status', width: 80, render: (s) => (
|
||||||
<Tag color={s === 'ON_SALE' ? 'green' : undefined}>{PRODUCT_STATUS_LABELS[s] || s}</Tag>
|
<Tag color={s === 'ON_SALE' ? 'green' : undefined}>{PRODUCT_STATUS_LABELS[s] || s}</Tag>
|
||||||
) },
|
) },
|
||||||
@@ -342,23 +429,7 @@ export default function ProductsPage() {
|
|||||||
render: (v: boolean) =>
|
render: (v: boolean) =>
|
||||||
v ? <Tag color="orange">限测</Tag> : <Tag>公开</Tag>,
|
v ? <Tag color="orange">限测</Tag> : <Tag>公开</Tag>,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: '履约',
|
|
||||||
key: 'fulfillment',
|
|
||||||
width: 160,
|
|
||||||
render: (_, row) => (
|
|
||||||
<Space size={[0, 4]} wrap>
|
|
||||||
{row.allowOnlinePurchase !== false ? <Tag color="blue">线上</Tag> : null}
|
|
||||||
{row.allowOnlinePurchase !== false && row.allowCrossCityDelivery !== false ? (
|
|
||||||
<Tag color="cyan">跨城</Tag>
|
|
||||||
) : null}
|
|
||||||
{row.allowOnSitePickup ? <Tag color="green">现场</Tag> : null}
|
|
||||||
{row.allowOnlinePurchase === false && !row.allowOnSitePickup ? <Tag>无</Tag> : null}
|
|
||||||
</Space>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{ title: '排序', dataIndex: 'sortOrder', width: 60 },
|
{ title: '排序', dataIndex: 'sortOrder', width: 60 },
|
||||||
{ title: '创建', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
|
||||||
{
|
{
|
||||||
title: '操作', width: 120,
|
title: '操作', width: 120,
|
||||||
render: (_, row) => (
|
render: (_, row) => (
|
||||||
@@ -371,7 +442,7 @@ export default function ProductsPage() {
|
|||||||
}}>编辑</Button>
|
}}>编辑</Button>
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
title="确认删除该商品?"
|
title="确认删除该商品?"
|
||||||
description={`将永久删除「${row.name}」(${row.skuCode}),此操作不可恢复。`}
|
description={`将永久删除「${row.name}」,此操作不可恢复。`}
|
||||||
okText="确认删除"
|
okText="确认删除"
|
||||||
cancelText="取消"
|
cancelText="取消"
|
||||||
okButtonProps={{ danger: true }}
|
okButtonProps={{ danger: true }}
|
||||||
@@ -384,14 +455,62 @@ export default function ProductsPage() {
|
|||||||
},
|
},
|
||||||
], [detail, editForm]);
|
], [detail, editForm]);
|
||||||
|
|
||||||
|
const skuColumns: ColumnsType<SkuListRow> = useMemo(() => [
|
||||||
|
{
|
||||||
|
title: '规格',
|
||||||
|
dataIndex: 'specText',
|
||||||
|
width: 140,
|
||||||
|
render: (v: string, row) => (
|
||||||
|
<Space size={4}>
|
||||||
|
<span>{v || '默认'}</span>
|
||||||
|
{row.isDefault ? <Tag color="blue">默认</Tag> : null}
|
||||||
|
{row.virtual ? <Tag>未建SKU</Tag> : null}
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{ title: 'SKU', dataIndex: 'skuCode', width: 110 },
|
||||||
|
{ title: '69码', dataIndex: 'barcode69', width: 160 },
|
||||||
|
{ title: '售价', dataIndex: 'price', width: 90, render: (v) => `¥${v}` },
|
||||||
|
{ title: '权益额', dataIndex: 'benefitAmount', width: 90, render: (v) => `¥${v}` },
|
||||||
|
{
|
||||||
|
title: '累计销售',
|
||||||
|
dataIndex: 'soldBottles',
|
||||||
|
width: 100,
|
||||||
|
render: (v: number | undefined) => `${v ?? 0} 瓶`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '履约',
|
||||||
|
key: 'fulfillment',
|
||||||
|
width: 160,
|
||||||
|
render: (_, row) => <FulfillmentTags {...row} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '状态',
|
||||||
|
dataIndex: 'status',
|
||||||
|
width: 90,
|
||||||
|
render: (s) => (
|
||||||
|
<Tag color={s === 'ON_SALE' ? 'green' : undefined}>{PRODUCT_STATUS_LABELS[s] || s}</Tag>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
], []);
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('products', baseColumns, {
|
||||||
|
page,
|
||||||
|
pageSize,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>商品管理</Typography.Title>
|
<Typography.Title level={4} style={{ margin: 0 }}>商品管理</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Button type="primary" onClick={() => setCreateOpen(true)}>新建商品</Button>
|
<Button type="primary" onClick={() => setCreateOpen(true)}>新建商品</Button>
|
||||||
</Space>
|
</Space>
|
||||||
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
|
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
|
||||||
<Form.Item name="name" label="名称"><Input allowClear /></Form.Item>
|
<Form.Item name="name" label="名称">
|
||||||
|
<Input allowClear placeholder="名称 / SKU / 69 码" style={{ width: 200 }} />
|
||||||
|
</Form.Item>
|
||||||
<Form.Item name="status" label="状态">
|
<Form.Item name="status" label="状态">
|
||||||
<Select allowClear style={{ width: 110 }} options={Object.entries(PRODUCT_STATUS_LABELS).map(([value, label]) => ({ value, label }))} />
|
<Select allowClear style={{ width: 110 }} options={Object.entries(PRODUCT_STATUS_LABELS).map(([value, label]) => ({ value, label }))} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
@@ -400,17 +519,46 @@ export default function ProductsPage() {
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item><Button type="primary" htmlType="submit">查询</Button></Form.Item>
|
<Form.Item><Button type="primary" htmlType="submit">查询</Button></Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
<Table rowKey="id" className="admin-table-nowrap" loading={loading} columns={columns} dataSource={data?.items ?? []} scroll={{ x: 1320 }}
|
<Table
|
||||||
pagination={{ current: page, pageSize, total: data?.total ?? 0, showSizeChanger: true, onChange: (p, ps) => { setPage(p); setPageSize(ps); } }} />
|
rowKey="id"
|
||||||
<Drawer title="编辑商品" width={720} open={drawerOpen} onClose={() => setDrawerOpen(false)}
|
className="admin-table-nowrap"
|
||||||
|
loading={loading}
|
||||||
|
columns={columns}
|
||||||
|
dataSource={data?.items ?? []}
|
||||||
|
scroll={{ x: 'max-content' }}
|
||||||
|
expandable={{
|
||||||
|
rowExpandable: () => true,
|
||||||
|
expandedRowRender: (row) => (
|
||||||
|
<div style={{ margin: '-8px -8px -8px 24px', padding: 12, background: '#f5f5f5', borderRadius: 6 }}>
|
||||||
|
<Table
|
||||||
|
size="small"
|
||||||
|
rowKey="id"
|
||||||
|
pagination={false}
|
||||||
|
columns={skuColumns}
|
||||||
|
dataSource={row.skus ?? []}
|
||||||
|
scroll={{ x: 'max-content' }}
|
||||||
|
style={{ background: 'transparent' }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
}}
|
||||||
|
pagination={{ current: page, pageSize, total: data?.total ?? 0, showSizeChanger: true, onChange: (p, ps) => { setPage(p); setPageSize(ps); } }}
|
||||||
|
/>
|
||||||
|
<Drawer title="编辑商品" width={1100} open={drawerOpen} onClose={() => setDrawerOpen(false)}
|
||||||
extra={detail && (
|
extra={detail && (
|
||||||
<Button type="primary" onClick={async () => {
|
<Button type="primary" onClick={async () => {
|
||||||
const v = await editForm.validateFields();
|
const v = await editForm.validateFields();
|
||||||
if (!v.allowOnlinePurchase && !v.allowOnSitePickup) {
|
const multiSku = Array.isArray(detail.skus) && (detail.skus as unknown[]).length > 1;
|
||||||
|
if (!multiSku && !v.allowOnlinePurchase && !v.allowOnSitePickup) {
|
||||||
message.error('请至少勾选「允许线上购买」或「允许现场取货」之一');
|
message.error('请至少勾选「允许线上购买」或「允许现场取货」之一');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const payload = buildProductPayload(v);
|
const payload = buildProductPayload(v);
|
||||||
|
if (multiSku) {
|
||||||
|
delete (payload as { allowOnlinePurchase?: boolean }).allowOnlinePurchase;
|
||||||
|
delete (payload as { allowCrossCityDelivery?: boolean }).allowCrossCityDelivery;
|
||||||
|
delete (payload as { allowOnSitePickup?: boolean }).allowOnSitePickup;
|
||||||
|
}
|
||||||
await request(`/admin/products/${detail.id}`, { method: 'PUT', body: JSON.stringify(payload) });
|
await request(`/admin/products/${detail.id}`, { method: 'PUT', body: JSON.stringify(payload) });
|
||||||
message.success('已保存');
|
message.success('已保存');
|
||||||
setDrawerOpen(false);
|
setDrawerOpen(false);
|
||||||
@@ -420,13 +568,24 @@ export default function ProductsPage() {
|
|||||||
{detail && (
|
{detail && (
|
||||||
<>
|
<>
|
||||||
<Descriptions column={1} bordered size="small" style={{ marginBottom: 16 }}>
|
<Descriptions column={1} bordered size="small" style={{ marginBottom: 16 }}>
|
||||||
<Descriptions.Item label="SKU">{String(detail.skuCode)}</Descriptions.Item>
|
<Descriptions.Item label="默认 SKU">{String(detail.skuCode)}(系统生成)</Descriptions.Item>
|
||||||
<Descriptions.Item label="69码">{String(detail.barcode69)}</Descriptions.Item>
|
<Descriptions.Item label="默认 69 码">{String(detail.barcode69)}</Descriptions.Item>
|
||||||
<Descriptions.Item label="香型">{AROMA_TYPE_LABELS[String(detail.aromaType)] || String(detail.aromaType)}</Descriptions.Item>
|
<Descriptions.Item label="香型">{AROMA_TYPE_LABELS[String(detail.aromaType)] || String(detail.aromaType)}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="创建时间">{fmtTime(String(detail.createdAt ?? ''))}</Descriptions.Item>
|
||||||
</Descriptions>
|
</Descriptions>
|
||||||
<Form form={editForm} layout="vertical">
|
<Form form={editForm} layout="vertical">
|
||||||
<Tabs items={[
|
<Tabs items={[
|
||||||
{ key: 'base', label: '基础信息', children: <BaseInfoFields mode="edit" form={editForm} /> },
|
{
|
||||||
|
key: 'base',
|
||||||
|
label: '基础信息',
|
||||||
|
children: (
|
||||||
|
<BaseInfoFields
|
||||||
|
mode="edit"
|
||||||
|
form={editForm}
|
||||||
|
hideFulfillment={Array.isArray(detail.skus) && (detail.skus as unknown[]).length > 1}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: 'detail',
|
key: 'detail',
|
||||||
label: '详情页',
|
label: '详情页',
|
||||||
@@ -437,6 +596,23 @@ export default function ProductsPage() {
|
|||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'specs',
|
||||||
|
label: '规格与 SKU',
|
||||||
|
children: (
|
||||||
|
<ProductSpecsEditor
|
||||||
|
productId={String(detail.id)}
|
||||||
|
initialAttrs={(detail.specAttrs as never) ?? []}
|
||||||
|
initialSkus={(detail.skus as never) ?? []}
|
||||||
|
onSaved={async () => {
|
||||||
|
const d = await request<Record<string, unknown>>(`/admin/products/${detail.id}`);
|
||||||
|
setDetail(d);
|
||||||
|
editForm.setFieldsValue(mapDetailToForm(d));
|
||||||
|
void reload();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
]} />
|
]} />
|
||||||
</Form>
|
</Form>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import {
|
|||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type Row = PromoCodeItem;
|
type Row = PromoCodeItem;
|
||||||
|
|
||||||
@@ -74,8 +76,8 @@ export default function PromoCodesPage() {
|
|||||||
void loadScenes();
|
void loadScenes();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{ title: '名称', dataIndex: 'name', width: 160, ellipsis: true },
|
{ title: '名称', dataIndex: 'name', width: 160 },
|
||||||
{ title: '码值', dataIndex: 'code', width: 110 },
|
{ title: '码值', dataIndex: 'code', width: 110 },
|
||||||
{
|
{
|
||||||
title: '场景',
|
title: '场景',
|
||||||
@@ -160,10 +162,14 @@ export default function PromoCodesPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('promo-codes', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }}>
|
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }}>
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>推广码管理</Typography.Title>
|
<Typography.Title level={4} style={{ margin: 0 }}>推广码管理</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Button type="primary" onClick={() => setCreateOpen(true)}>创建推广码</Button>
|
<Button type="primary" onClick={() => setCreateOpen(true)}>创建推广码</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -194,7 +200,7 @@ export default function PromoCodesPage() {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data?.items ?? []}
|
dataSource={data?.items ?? []}
|
||||||
scroll={{ x: 1200 }}
|
scroll={{ x: 'max-content' }}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: page,
|
current: page,
|
||||||
pageSize,
|
pageSize,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { useState } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
|
import { useSearchParams } from 'react-router-dom';
|
||||||
import { Button, Checkbox, Drawer, Form, Input, Select, Table, Tag, Typography } from 'antd';
|
import { Button, Checkbox, Drawer, Form, Input, Select, Table, Tag, Typography } from 'antd';
|
||||||
import type { ColumnsType } from 'antd/es/table';
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
import { REDEEM_CHANNEL_LABELS, type RedeemChannel } from '@dukang/shared-types';
|
import { REDEEM_CHANNEL_LABELS, type RedeemChannel } from '@dukang/shared-types';
|
||||||
@@ -6,6 +7,8 @@ import RedeemRecordDetailDescriptions from '../components/RedeemRecordDetailDesc
|
|||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -26,8 +29,14 @@ function maskPhone(phone: string | null | undefined) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function RedeemRecordsPage() {
|
export default function RedeemRecordsPage() {
|
||||||
|
const [searchParams] = useSearchParams();
|
||||||
|
const initialRedeemNo = searchParams.get('redeemNo')?.trim() || '';
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const [filters, setFilters] = useState<Record<string, string | boolean>>({});
|
const [filters, setFilters] = useState<Record<string, string | boolean>>(() => {
|
||||||
|
const init: Record<string, string | boolean> = {};
|
||||||
|
if (initialRedeemNo) init.redeemNo = initialRedeemNo;
|
||||||
|
return init;
|
||||||
|
});
|
||||||
const { data, loading, page, pageSize, setPage, setPageSize } = useAdminList<Row>(
|
const { data, loading, page, pageSize, setPage, setPageSize } = useAdminList<Row>(
|
||||||
'/admin/redeem-records',
|
'/admin/redeem-records',
|
||||||
() => {
|
() => {
|
||||||
@@ -43,6 +52,11 @@ export default function RedeemRecordsPage() {
|
|||||||
const [detail, setDetail] = useState<Record<string, unknown> | null>(null);
|
const [detail, setDetail] = useState<Record<string, unknown> | null>(null);
|
||||||
const [drawerOpen, setDrawerOpen] = useState(false);
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
||||||
const [detailLoading, setDetailLoading] = useState(false);
|
const [detailLoading, setDetailLoading] = useState(false);
|
||||||
|
const deepLinkOpenedRef = useRef(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (initialRedeemNo) form.setFieldsValue({ redeemNo: initialRedeemNo });
|
||||||
|
}, [form, initialRedeemNo]);
|
||||||
|
|
||||||
async function openDetail(id: string) {
|
async function openDetail(id: string) {
|
||||||
setDetailLoading(true);
|
setDetailLoading(true);
|
||||||
@@ -54,7 +68,16 @@ export default function RedeemRecordsPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
useEffect(() => {
|
||||||
|
if (!initialRedeemNo || deepLinkOpenedRef.current || loading) return;
|
||||||
|
const first = data?.items?.[0];
|
||||||
|
if (first && String(first.redeemNo) === initialRedeemNo) {
|
||||||
|
deepLinkOpenedRef.current = true;
|
||||||
|
void openDetail(first.id);
|
||||||
|
}
|
||||||
|
}, [data, initialRedeemNo, loading]);
|
||||||
|
|
||||||
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{
|
{
|
||||||
title: '核销号',
|
title: '核销号',
|
||||||
dataIndex: 'redeemNo',
|
dataIndex: 'redeemNo',
|
||||||
@@ -112,9 +135,13 @@ export default function RedeemRecordsPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('redeem-records', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Typography.Title level={4}>核销记录</Typography.Title>
|
<Typography.Title level={4}>核销记录</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Form
|
<Form
|
||||||
form={form}
|
form={form}
|
||||||
layout="inline"
|
layout="inline"
|
||||||
@@ -154,7 +181,7 @@ export default function RedeemRecordsPage() {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data?.items ?? []}
|
dataSource={data?.items ?? []}
|
||||||
scroll={{ x: 1300 }}
|
scroll={{ x: 'max-content' }}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: page,
|
current: page,
|
||||||
pageSize,
|
pageSize,
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import {
|
|||||||
fmtTime,
|
fmtTime,
|
||||||
} from '../lib/constants';
|
} from '../lib/constants';
|
||||||
import OssUpload from '../components/OssUpload';
|
import OssUpload from '../components/OssUpload';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -58,7 +60,7 @@ export default function ResourcesPage() {
|
|||||||
void reload();
|
void reload();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{ title: 'ID', dataIndex: 'id', width: 80 },
|
{ title: 'ID', dataIndex: 'id', width: 80 },
|
||||||
{
|
{
|
||||||
title: '归属',
|
title: '归属',
|
||||||
@@ -84,8 +86,8 @@ export default function ResourcesPage() {
|
|||||||
</a>
|
</a>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{ title: 'URL', dataIndex: 'url', ellipsis: true },
|
{ title: 'URL', dataIndex: 'url' },
|
||||||
{ title: 'OSS Key', dataIndex: 'ossKey', ellipsis: true, width: 160 },
|
{ title: 'OSS Key', dataIndex: 'ossKey', width: 160 },
|
||||||
{ title: '排序', dataIndex: 'sortOrder', width: 60 },
|
{ title: '排序', dataIndex: 'sortOrder', width: 60 },
|
||||||
{
|
{
|
||||||
title: '状态',
|
title: '状态',
|
||||||
@@ -114,12 +116,16 @@ export default function ResourcesPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('resources', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>
|
<Typography.Title level={4} style={{ margin: 0 }}>
|
||||||
OSS 资源库
|
OSS 资源库
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Button type="primary" onClick={() => setCreateOpen(true)}>
|
<Button type="primary" onClick={() => setCreateOpen(true)}>
|
||||||
登记资源
|
登记资源
|
||||||
</Button>
|
</Button>
|
||||||
@@ -170,7 +176,7 @@ export default function ResourcesPage() {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data?.items ?? []}
|
dataSource={data?.items ?? []}
|
||||||
scroll={{ x: 1200 }}
|
scroll={{ x: 'max-content' }}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: page,
|
current: page,
|
||||||
pageSize,
|
pageSize,
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import type { ColumnsType } from 'antd/es/table';
|
|||||||
import { request, type Paginated } from '../lib/api';
|
import { request, type Paginated } from '../lib/api';
|
||||||
import { ACCOUNT_STATUS_LABELS, ADMIN_OPTIONS_PAGE_SIZE, STORE_STATUS_LABELS, fmtTime } from '../lib/constants';
|
import { ACCOUNT_STATUS_LABELS, ADMIN_OPTIONS_PAGE_SIZE, STORE_STATUS_LABELS, fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type StoreBrief = { id: string; name: string; status: string; cityName?: string };
|
type StoreBrief = { id: string; name: string; status: string; cityName?: string };
|
||||||
|
|
||||||
@@ -74,7 +76,7 @@ export default function StoreAccountsPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{
|
{
|
||||||
title: '姓名',
|
title: '姓名',
|
||||||
dataIndex: 'name',
|
dataIndex: 'name',
|
||||||
@@ -138,11 +140,15 @@ export default function StoreAccountsPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('store-accounts', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
||||||
<Space direction="vertical" size={0}>
|
<Space direction="vertical" size={0}>
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>门店账户</Typography.Title>
|
<Typography.Title level={4} style={{ margin: 0 }}>门店账户</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Typography.Text type="secondary">
|
<Typography.Text type="secondary">
|
||||||
主账号可绑定多家门店;收款信息挂在主账号;「新建账户」用于补录无主账号门店
|
主账号可绑定多家门店;收款信息挂在主账号;「新建账户」用于补录无主账号门店
|
||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
@@ -185,7 +191,7 @@ export default function StoreAccountsPage() {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data?.items ?? []}
|
dataSource={data?.items ?? []}
|
||||||
scroll={{ x: 1100 }}
|
scroll={{ x: 'max-content' }}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: page,
|
current: page,
|
||||||
pageSize,
|
pageSize,
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ import { request, type Paginated } from '../lib/api';
|
|||||||
import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
|
import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
|
||||||
import { downloadExcelCsv } from '../lib/exportExcel';
|
import { downloadExcelCsv } from '../lib/exportExcel';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
kind: StoreSettlementKind;
|
kind: StoreSettlementKind;
|
||||||
@@ -44,6 +46,11 @@ type Row = {
|
|||||||
settlementRate?: number | null;
|
settlementRate?: number | null;
|
||||||
payoutCount?: number | null;
|
payoutCount?: number | null;
|
||||||
store?: { id: string; name: string; cityName: string; phone?: string | null };
|
store?: { id: string; name: string; cityName: string; phone?: string | null };
|
||||||
|
bankAccount?: {
|
||||||
|
bankAccountName?: string | null;
|
||||||
|
bankAccountNo?: string | null;
|
||||||
|
bankBranch?: string | null;
|
||||||
|
} | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
type StoreOption = { id: string; name: string; phone: string };
|
type StoreOption = { id: string; name: string; phone: string };
|
||||||
@@ -55,6 +62,11 @@ const STATUS_COLORS: Record<string, string> = {
|
|||||||
REJECTED: 'red',
|
REJECTED: 'red',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function settlementStatusColor(kind: StoreSettlementKind, status: string) {
|
||||||
|
if (status === 'PAID') return kind === 'WITHDRAW' ? 'cyan' : 'green';
|
||||||
|
return STATUS_COLORS[status] || 'default';
|
||||||
|
}
|
||||||
|
|
||||||
const KIND_COLORS: Record<StoreSettlementKind, string> = {
|
const KIND_COLORS: Record<StoreSettlementKind, string> = {
|
||||||
T1_BILL: 'blue',
|
T1_BILL: 'blue',
|
||||||
WITHDRAW: 'purple',
|
WITHDRAW: 'purple',
|
||||||
@@ -64,10 +76,13 @@ export default function StoreBillsPage() {
|
|||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const initialKind = searchParams.get('kind') === 'WITHDRAW' ? 'WITHDRAW' : '';
|
const initialKind = searchParams.get('kind') === 'WITHDRAW' ? 'WITHDRAW' : '';
|
||||||
const initialStoreId = searchParams.get('storeId') || '';
|
const initialStoreId = searchParams.get('storeId') || '';
|
||||||
|
const initialStatus =
|
||||||
|
searchParams.get('status')?.trim() ||
|
||||||
|
(initialKind === 'WITHDRAW' ? 'PENDING_REVIEW' : '');
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const [filters, setFilters] = useState<Record<string, string>>({
|
const [filters, setFilters] = useState<Record<string, string>>({
|
||||||
kind: initialKind,
|
kind: initialKind,
|
||||||
status: initialKind === 'WITHDRAW' ? 'PENDING_REVIEW' : '',
|
status: initialStatus,
|
||||||
storeId: initialStoreId,
|
storeId: initialStoreId,
|
||||||
});
|
});
|
||||||
const [stores, setStores] = useState<StoreOption[]>([]);
|
const [stores, setStores] = useState<StoreOption[]>([]);
|
||||||
@@ -115,14 +130,30 @@ export default function StoreBillsPage() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
function confirmPay(ids: string[], amountHint?: number) {
|
function confirmPay(ids: string[], amountHint?: number) {
|
||||||
|
let paymentRef = '';
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: '确认打款?',
|
title: '确认打款?',
|
||||||
content: `将确认 ${ids.length} 笔 T+1 门店对账单${amountHint != null ? `,合计约 ¥${amountHint.toFixed(2)}` : ''}。此操作不可撤销。`,
|
content: (
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
将确认 {ids.length} 笔 T+1 门店对账单
|
||||||
|
{amountHint != null ? `,合计约 ¥${amountHint.toFixed(2)}` : ''}。此操作不可撤销。
|
||||||
|
</div>
|
||||||
|
<Input
|
||||||
|
placeholder="打款凭证号(可选)"
|
||||||
|
style={{ marginTop: 8 }}
|
||||||
|
onChange={(e) => {
|
||||||
|
paymentRef = e.target.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
okText: '确认打款',
|
okText: '确认打款',
|
||||||
cancelText: '取消',
|
cancelText: '取消',
|
||||||
onOk: async () => {
|
onOk: async () => {
|
||||||
|
const body = JSON.stringify({ paymentRef: paymentRef.trim() || undefined });
|
||||||
if (ids.length === 1) {
|
if (ids.length === 1) {
|
||||||
await request(`/admin/store-bills/${ids[0]}/confirm`, { method: 'POST' });
|
await request(`/admin/store-bills/${ids[0]}/confirm`, { method: 'POST', body });
|
||||||
} else {
|
} else {
|
||||||
setBatchLoading(true);
|
setBatchLoading(true);
|
||||||
try {
|
try {
|
||||||
@@ -238,20 +269,21 @@ export default function StoreBillsPage() {
|
|||||||
);
|
);
|
||||||
const selectedAmount = selectedRows.reduce((s, r) => s + Number(r.amount), 0);
|
const selectedAmount = selectedRows.reduce((s, r) => s + Number(r.amount), 0);
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{
|
{
|
||||||
title: '类型',
|
title: '类型',
|
||||||
dataIndex: 'kind',
|
dataIndex: 'kind',
|
||||||
width: 100,
|
width: 100,
|
||||||
render: (k: StoreSettlementKind) => (
|
render: (k: StoreSettlementKind) => (
|
||||||
<Tag color={KIND_COLORS[k]}>{STORE_SETTLEMENT_KIND_LABELS[k] ?? k}</Tag>
|
<Tag color={KIND_COLORS[k]} style={{ minWidth: 72, textAlign: 'center' }}>
|
||||||
|
{STORE_SETTLEMENT_KIND_LABELS[k] ?? k}
|
||||||
|
</Tag>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '单号',
|
title: '单号',
|
||||||
dataIndex: 'billNo',
|
dataIndex: 'billNo',
|
||||||
width: 180,
|
width: 180,
|
||||||
ellipsis: true,
|
|
||||||
|
|
||||||
render: (v, row) => (
|
render: (v, row) => (
|
||||||
<Space>
|
<Space>
|
||||||
@@ -265,9 +297,21 @@ export default function StoreBillsPage() {
|
|||||||
dataIndex: 'date',
|
dataIndex: 'date',
|
||||||
width: 160,
|
width: 160,
|
||||||
render: (v, row) => (row.kind === 'T1_BILL' ? String(v || '').slice(0, 10) : fmtTime(v)),
|
render: (v, row) => (row.kind === 'T1_BILL' ? String(v || '').slice(0, 10) : fmtTime(v)),
|
||||||
{ title: '门店', dataIndex: ['store', 'name'], width: 140, ellipsis: true },
|
},
|
||||||
{ title: '门店', dataIndex: ['store', 'name'], width: 140 },
|
{ title: '门店', dataIndex: ['store', 'name'], width: 140 },
|
||||||
{ title: '登录手机', dataIndex: ['store', 'phone'], width: 120, render: (v) => v || '—' },
|
{ title: '登录手机', dataIndex: ['store', 'phone'], width: 120, render: (v) => v || '—' },
|
||||||
|
{ title: '城市', dataIndex: ['store', 'cityName'], width: 90 },
|
||||||
|
{
|
||||||
|
title: '收款户名',
|
||||||
|
width: 100,
|
||||||
|
|
||||||
|
render: (_, row) =>
|
||||||
|
row.kind === 'T1_BILL' ? row.bankAccount?.bankAccountName || '—' : '—',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '收款账号',
|
||||||
|
width: 140,
|
||||||
|
|
||||||
render: (_, row) =>
|
render: (_, row) =>
|
||||||
row.kind === 'T1_BILL' ? row.bankAccount?.bankAccountNo || '—' : '—',
|
row.kind === 'T1_BILL' ? row.bankAccount?.bankAccountNo || '—' : '—',
|
||||||
},
|
},
|
||||||
@@ -285,7 +329,9 @@ export default function StoreBillsPage() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '状态',
|
title: '状态',
|
||||||
<Tag color={STATUS_COLORS[s] || 'default'}>{storeSettlementStatusLabel(row.kind, s)}</Tag>
|
dataIndex: 'status',
|
||||||
|
width: 100,
|
||||||
|
render: (s: string, row) => (
|
||||||
<Tag color={settlementStatusColor(row.kind, s)}>
|
<Tag color={settlementStatusColor(row.kind, s)}>
|
||||||
{storeSettlementStatusLabel(row.kind, s)}
|
{storeSettlementStatusLabel(row.kind, s)}
|
||||||
</Tag>
|
</Tag>
|
||||||
@@ -329,14 +375,19 @@ export default function StoreBillsPage() {
|
|||||||
bankAccountName?: string;
|
bankAccountName?: string;
|
||||||
bankAccountNo?: string;
|
bankAccountNo?: string;
|
||||||
bankBranch?: string;
|
bankBranch?: string;
|
||||||
|
}
|
||||||
|
| undefined;
|
||||||
|
|
||||||
const { columns, settingsButton, settingsModal } = useAdminListColumns('finance-store-bills', baseColumns, { page, pageSize });
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('finance-store-bills', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{settingsModal}
|
{settingsModal}
|
||||||
<Space direction="vertical" size={0} style={{ marginBottom: 16 }}>
|
<Space direction="vertical" size={0} style={{ marginBottom: 16 }}>
|
||||||
|
<Typography.Title level={4} style={{ margin: 0 }}>
|
||||||
门店账单
|
门店账单
|
||||||
含 T+1 自动出账与门店手动提现;按类型筛选,详情与审核动作沿用原接口
|
</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Typography.Text type="secondary">
|
<Typography.Text type="secondary">
|
||||||
含 T+1 自动出账与门店手动提现;按类型筛选,详情与审核动作沿用原接口。
|
含 T+1 自动出账与门店手动提现;按类型筛选,详情与审核动作沿用原接口。
|
||||||
「已打款」= T+1 出账终态,「已结算」= 手动提现终态。
|
「已打款」= T+1 出账终态,「已结算」= 手动提现终态。
|
||||||
@@ -465,7 +516,7 @@ export default function StoreBillsPage() {
|
|||||||
selectedRowKeys: selectedKeys,
|
selectedRowKeys: selectedKeys,
|
||||||
onChange: setSelectedKeys,
|
onChange: setSelectedKeys,
|
||||||
getCheckboxProps: (r) => ({
|
getCheckboxProps: (r) => ({
|
||||||
scroll={{ x: 1300 }}
|
disabled: !(r.kind === 'T1_BILL' && r.status === 'UNPAID'),
|
||||||
}),
|
}),
|
||||||
}}
|
}}
|
||||||
scroll={{ x: 'max-content' }}
|
scroll={{ x: 'max-content' }}
|
||||||
@@ -500,7 +551,32 @@ export default function StoreBillsPage() {
|
|||||||
<Descriptions.Item label="状态">
|
<Descriptions.Item label="状态">
|
||||||
{storeSettlementStatusLabel('T1_BILL', String(detail.status))}
|
{storeSettlementStatusLabel('T1_BILL', String(detail.status))}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="打款时间">
|
||||||
|
{detail.paidAt ? fmtTime(String(detail.paidAt)) : '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="打款凭证">
|
<Descriptions.Item label="打款凭证">
|
||||||
|
{detail.paymentRef ? String(detail.paymentRef) : '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
</Descriptions>
|
||||||
|
{(detail.storeAccount as {
|
||||||
|
bankAccountName?: string;
|
||||||
|
bankAccountNo?: string;
|
||||||
|
bankBranch?: string;
|
||||||
|
} | null) ? (
|
||||||
|
<>
|
||||||
|
<Typography.Title level={5} style={{ marginTop: 16 }}>
|
||||||
|
收款账户
|
||||||
|
</Typography.Title>
|
||||||
|
<Descriptions column={1} size="small" bordered>
|
||||||
|
<Descriptions.Item label="户名">
|
||||||
|
{(detail.storeAccount as { bankAccountName?: string }).bankAccountName || '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="账号">
|
||||||
|
{(detail.storeAccount as { bankAccountNo?: string }).bankAccountNo || '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="开户行">
|
||||||
|
{(detail.storeAccount as { bankBranch?: string }).bankBranch || '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
</Descriptions>
|
</Descriptions>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ import {
|
|||||||
Button, Form, Input, InputNumber, Modal, Popconfirm, Select, Space, Table, Tag, Typography, message,
|
Button, Form, Input, InputNumber, Modal, Popconfirm, Select, Space, Table, Tag, Typography, message,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import type { ColumnsType } from 'antd/es/table';
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
import { request } from '../lib/api';
|
import { request, type HqProfile } from '../lib/api';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type CategoryNode = {
|
type CategoryNode = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -38,7 +40,9 @@ export default function StoreCategoriesPage() {
|
|||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [modalOpen, setModalOpen] = useState(false);
|
const [modalOpen, setModalOpen] = useState(false);
|
||||||
const [editing, setEditing] = useState<FlatRow | null>(null);
|
const [editing, setEditing] = useState<FlatRow | null>(null);
|
||||||
|
const [profile, setProfile] = useState<HqProfile | null>(null);
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
|
const canDelete = (profile?.permissionKeys ?? []).includes('store_categories_delete');
|
||||||
|
|
||||||
const rows = useMemo(() => flattenTree(tree), [tree]);
|
const rows = useMemo(() => flattenTree(tree), [tree]);
|
||||||
const rootOptions = useMemo(
|
const rootOptions = useMemo(
|
||||||
@@ -60,6 +64,7 @@ export default function StoreCategoriesPage() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void reload();
|
void reload();
|
||||||
|
request<HqProfile>('/admin/auth/me').then(setProfile).catch(() => {});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
function openCreate(parentId?: string) {
|
function openCreate(parentId?: string) {
|
||||||
@@ -112,7 +117,7 @@ export default function StoreCategoriesPage() {
|
|||||||
void reload();
|
void reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<FlatRow> = [
|
const baseColumns: ColumnsType<FlatRow> = [
|
||||||
{
|
{
|
||||||
title: '层级',
|
title: '层级',
|
||||||
dataIndex: 'level',
|
dataIndex: 'level',
|
||||||
@@ -141,13 +146,14 @@ export default function StoreCategoriesPage() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
width: 220,
|
width: canDelete ? 220 : 160,
|
||||||
render: (_, row) => (
|
render: (_, row) => (
|
||||||
<Space wrap>
|
<Space wrap>
|
||||||
<Button type="link" size="small" onClick={() => openEdit(row)}>编辑</Button>
|
<Button type="link" size="small" onClick={() => openEdit(row)}>编辑</Button>
|
||||||
{row.level === 1 ? (
|
{row.level === 1 ? (
|
||||||
<Button type="link" size="small" onClick={() => openCreate(row.id)}>加二级</Button>
|
<Button type="link" size="small" onClick={() => openCreate(row.id)}>加二级</Button>
|
||||||
) : null}
|
) : null}
|
||||||
|
{canDelete ? (
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
title={row.level === 1 ? '删除一级分类?若有门店占用将改为停用' : '删除该分类?若有门店占用将改为停用'}
|
title={row.level === 1 ? '删除一级分类?若有门店占用将改为停用' : '删除该分类?若有门店占用将改为停用'}
|
||||||
onConfirm={async () => {
|
onConfirm={async () => {
|
||||||
@@ -158,19 +164,28 @@ export default function StoreCategoriesPage() {
|
|||||||
>
|
>
|
||||||
<Button type="link" size="small" danger>删除</Button>
|
<Button type="link" size="small" danger>删除</Button>
|
||||||
</Popconfirm>
|
</Popconfirm>
|
||||||
|
) : null}
|
||||||
</Space>
|
</Space>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('store-categories', baseColumns, {
|
||||||
|
page: 1,
|
||||||
|
pageSize: rows.length || 20,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
||||||
<Space direction="vertical" size={0}>
|
<Space direction="vertical" size={0}>
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>门店分类</Typography.Title>
|
<Typography.Title level={4} style={{ margin: 0 }}>门店分类</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Typography.Text type="secondary">两级分类:一级(餐饮/住宿/娱乐)→ 二级业态,供合伙人开店选择</Typography.Text>
|
<Typography.Text type="secondary">两级分类:一级(餐饮/住宿/娱乐)→ 二级业态,供合伙人开店选择</Typography.Text>
|
||||||
</Space>
|
</Space>
|
||||||
<Space>
|
<Space>
|
||||||
|
{canDelete ? (
|
||||||
<Button
|
<Button
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
await request('/admin/store-categories/ensure-defaults', { method: 'POST' });
|
await request('/admin/store-categories/ensure-defaults', { method: 'POST' });
|
||||||
@@ -180,6 +195,7 @@ export default function StoreCategoriesPage() {
|
|||||||
>
|
>
|
||||||
同步默认分类
|
同步默认分类
|
||||||
</Button>
|
</Button>
|
||||||
|
) : null}
|
||||||
<Button type="primary" onClick={() => openCreate()}>新增一级</Button>
|
<Button type="primary" onClick={() => openCreate()}>新增一级</Button>
|
||||||
</Space>
|
</Space>
|
||||||
</Space>
|
</Space>
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import { request } from '../lib/api';
|
|||||||
import { AdminCellLine } from '../components/AdminCellLine';
|
import { AdminCellLine } from '../components/AdminCellLine';
|
||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -80,14 +82,14 @@ export default function StoreLogsPage() {
|
|||||||
form.setFieldsValue(filters);
|
form.setFieldsValue(filters);
|
||||||
}, [form, filters]);
|
}, [form, filters]);
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{ title: '时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
{ title: '时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
||||||
{
|
{
|
||||||
title: '门店', width: 180, ellipsis: true,
|
title: '门店', width: 180,
|
||||||
render: (_, r) => <AdminCellLine primary={r.storeName} secondary={r.storeId} />,
|
render: (_, r) => <AdminCellLine primary={r.storeName} secondary={r.storeId} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '账号', width: 150, ellipsis: true,
|
title: '账号', width: 150,
|
||||||
render: (_, r) => (
|
render: (_, r) => (
|
||||||
<AdminCellLine
|
<AdminCellLine
|
||||||
primary={r.accountName}
|
primary={r.accountName}
|
||||||
@@ -111,7 +113,7 @@ export default function StoreLogsPage() {
|
|||||||
render: (_, r) => (r.refType && r.refId ? `${r.refType}#${r.refId}` : '—'),
|
render: (_, r) => (r.refType && r.refId ? `${r.refType}#${r.refId}` : '—'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '摘要', ellipsis: true,
|
title: '摘要',
|
||||||
render: (_, r) => summarizeExtra(r.extraJson),
|
render: (_, r) => summarizeExtra(r.extraJson),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -127,9 +129,13 @@ export default function StoreLogsPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('logs-stores', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Typography.Title level={4}>商户日志</Typography.Title>
|
<Typography.Title level={4}>商户日志</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Typography.Paragraph type="secondary" style={{ marginTop: -8 }}>
|
<Typography.Paragraph type="secondary" style={{ marginTop: -8 }}>
|
||||||
门店登录、微信授权、核销、打款与营业状态等操作记录;历史核销/打款数据来自业务表归档。
|
门店登录、微信授权、核销、打款与营业状态等操作记录;历史核销/打款数据来自业务表归档。
|
||||||
</Typography.Paragraph>
|
</Typography.Paragraph>
|
||||||
@@ -164,7 +170,7 @@ export default function StoreLogsPage() {
|
|||||||
<Form.Item><Button type="primary" htmlType="submit">筛选</Button></Form.Item>
|
<Form.Item><Button type="primary" htmlType="submit">筛选</Button></Form.Item>
|
||||||
<Form.Item><Button onClick={() => { form.resetFields(); setFilters({}); setCategory(''); setSearchParams({}); setPage(1); }}>重置</Button></Form.Item>
|
<Form.Item><Button onClick={() => { form.resetFields(); setFilters({}); setCategory(''); setSearchParams({}); setPage(1); }}>重置</Button></Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
<Table rowKey="id" loading={loading} columns={columns} dataSource={data?.items ?? []} scroll={{ x: 1200 }}
|
<Table rowKey="id" loading={loading} columns={columns} dataSource={data?.items ?? []} scroll={{ x: 'max-content' }}
|
||||||
pagination={{ current: page, pageSize, total: data?.total ?? 0, showSizeChanger: true, onChange: (p, ps) => { setPage(p); setPageSize(ps); } }} />
|
pagination={{ current: page, pageSize, total: data?.total ?? 0, showSizeChanger: true, onChange: (p, ps) => { setPage(p); setPageSize(ps); } }} />
|
||||||
<Drawer title="商户日志详情" width={560} open={drawerOpen} onClose={() => setDrawerOpen(false)}>
|
<Drawer title="商户日志详情" width={560} open={drawerOpen} onClose={() => setDrawerOpen(false)}>
|
||||||
{detail && (
|
{detail && (
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import { request, type Paginated } from '../lib/api';
|
|||||||
import { ADMIN_OPTIONS_PAGE_SIZE, MEDIA_TYPE_LABELS, fmtTime } from '../lib/constants';
|
import { ADMIN_OPTIONS_PAGE_SIZE, MEDIA_TYPE_LABELS, fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
import OssUpload from '../components/OssUpload';
|
import OssUpload from '../components/OssUpload';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
id: string; mediaType: string; url: string; sortOrder: number; createdAt: string;
|
id: string; mediaType: string; url: string; sortOrder: number; createdAt: string;
|
||||||
@@ -40,7 +42,7 @@ export default function StoreMediaPage() {
|
|||||||
setStores(res.items);
|
setStores(res.items);
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{ title: '门店', dataIndex: ['store', 'name'], width: 140 },
|
{ title: '门店', dataIndex: ['store', 'name'], width: 140 },
|
||||||
{ title: '类型', dataIndex: 'mediaType', width: 80, render: (t) => <Tag>{MEDIA_TYPE_LABELS[t] || t}</Tag> },
|
{ title: '类型', dataIndex: 'mediaType', width: 80, render: (t) => <Tag>{MEDIA_TYPE_LABELS[t] || t}</Tag> },
|
||||||
{
|
{
|
||||||
@@ -49,7 +51,7 @@ export default function StoreMediaPage() {
|
|||||||
? <Image src={url} width={60} height={40} style={{ objectFit: 'cover' }} />
|
? <Image src={url} width={60} height={40} style={{ objectFit: 'cover' }} />
|
||||||
: <a href={url} target="_blank" rel="noreferrer">视频</a>,
|
: <a href={url} target="_blank" rel="noreferrer">视频</a>,
|
||||||
},
|
},
|
||||||
{ title: 'URL', dataIndex: 'url', ellipsis: true },
|
{ title: 'URL', dataIndex: 'url' },
|
||||||
{ title: '排序', dataIndex: 'sortOrder', width: 70 },
|
{ title: '排序', dataIndex: 'sortOrder', width: 70 },
|
||||||
{ title: '创建', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
{ title: '创建', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
||||||
{
|
{
|
||||||
@@ -73,10 +75,14 @@ export default function StoreMediaPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('store-media', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>门店资源</Typography.Title>
|
<Typography.Title level={4} style={{ margin: 0 }}>门店资源</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Button type="primary" onClick={() => { void loadStores(); setCreateOpen(true); }}>新增资源</Button>
|
<Button type="primary" onClick={() => { void loadStores(); setCreateOpen(true); }}>新增资源</Button>
|
||||||
</Space>
|
</Space>
|
||||||
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
|
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
|
||||||
@@ -86,7 +92,7 @@ export default function StoreMediaPage() {
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item><Button type="primary" htmlType="submit">查询</Button></Form.Item>
|
<Form.Item><Button type="primary" htmlType="submit">查询</Button></Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
<Table rowKey="id" className="admin-table-nowrap" loading={loading} columns={columns} dataSource={data?.items ?? []} scroll={{ x: 900 }}
|
<Table rowKey="id" className="admin-table-nowrap" loading={loading} columns={columns} dataSource={data?.items ?? []} scroll={{ x: 'max-content' }}
|
||||||
pagination={{ current: page, pageSize, total: data?.total ?? 0, showSizeChanger: true, onChange: (p, ps) => { setPage(p); setPageSize(ps); } }} />
|
pagination={{ current: page, pageSize, total: data?.total ?? 0, showSizeChanger: true, onChange: (p, ps) => { setPage(p); setPageSize(ps); } }} />
|
||||||
<Modal title="新增门店资源" open={createOpen} onCancel={() => setCreateOpen(false)} onOk={async () => {
|
<Modal title="新增门店资源" open={createOpen} onCancel={() => setCreateOpen(false)} onOk={async () => {
|
||||||
const v = await createForm.validateFields();
|
const v = await createForm.validateFields();
|
||||||
|
|||||||
@@ -20,20 +20,19 @@ import type {
|
|||||||
StoreInfoChangeFieldDiff,
|
StoreInfoChangeFieldDiff,
|
||||||
StoreInfoChangeRequestDto,
|
StoreInfoChangeRequestDto,
|
||||||
StoreInfoChangeStatus,
|
StoreInfoChangeStatus,
|
||||||
StorePackageAuditDetailDto,
|
|
||||||
StorePackageAuditSummaryDto,
|
StorePackageAuditSummaryDto,
|
||||||
StorePackageChangeRequestDto,
|
StorePackageChangeRequestDto,
|
||||||
StorePackageChangeStatus,
|
StorePackageChangeStatus,
|
||||||
StorePackageItemDto,
|
|
||||||
StorePackageViewDto,
|
|
||||||
} from '@dukang/shared-types';
|
} from '@dukang/shared-types';
|
||||||
import {
|
import {
|
||||||
STORE_INFO_CHANGE_STATUS_LABELS,
|
STORE_INFO_CHANGE_STATUS_LABELS,
|
||||||
normalizeStorePackageImageUrls,
|
STORE_INFO_CHANGEABLE_FIELD_LABELS,
|
||||||
} from '@dukang/shared-types';
|
} from '@dukang/shared-types';
|
||||||
import { request, type Paginated } from '../lib/api';
|
import { request, type Paginated } from '../lib/api';
|
||||||
import { notifyPackageAuditChanged } from '../lib/admin-events';
|
import { notifyPackageAuditChanged } from '../lib/admin-events';
|
||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
|
import StorePackageAuditPanel from '../components/StorePackageAuditPanel';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
const HQ_PACKAGE_STATUS_LABELS: Record<StorePackageChangeStatus, string> = {
|
const HQ_PACKAGE_STATUS_LABELS: Record<StorePackageChangeStatus, string> = {
|
||||||
PENDING: '待审核',
|
PENDING: '待审核',
|
||||||
@@ -41,293 +40,80 @@ const HQ_PACKAGE_STATUS_LABELS: Record<StorePackageChangeStatus, string> = {
|
|||||||
REJECTED: '已驳回',
|
REJECTED: '已驳回',
|
||||||
};
|
};
|
||||||
|
|
||||||
function packageKey(pkg: StorePackageItemDto | StorePackageViewDto, index: number) {
|
|
||||||
const name = String(pkg.name ?? '').trim();
|
|
||||||
return name ? `name:${name}` : `idx:${index}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function imageSignature(pkg: StorePackageItemDto | StorePackageViewDto) {
|
|
||||||
return normalizeStorePackageImageUrls(pkg).join('|');
|
|
||||||
}
|
|
||||||
|
|
||||||
type FieldChange = { label: string; old: string; now: string; kind: 'text' | 'value' };
|
|
||||||
|
|
||||||
/** 文本逐字差异:LCS 比对,产出 equal / delete / insert 段落,用于高亮具体变了哪些字 */
|
|
||||||
function diffText(a: string, b: string): Array<{ type: 'equal' | 'insert' | 'delete'; text: string }> {
|
|
||||||
const m = a.length;
|
|
||||||
const n = b.length;
|
|
||||||
const dp: number[][] = Array.from({ length: m + 1 }, () => new Array(n + 1).fill(0));
|
|
||||||
for (let i = m - 1; i >= 0; i--) {
|
|
||||||
for (let j = n - 1; j >= 0; j--) {
|
|
||||||
dp[i][j] = a[i] === b[j] ? dp[i + 1][j + 1] + 1 : Math.max(dp[i + 1][j], dp[i][j + 1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const raw: Array<{ type: 'equal' | 'insert' | 'delete'; text: string }> = [];
|
|
||||||
let i = 0;
|
|
||||||
let j = 0;
|
|
||||||
while (i < m && j < n) {
|
|
||||||
if (a[i] === b[j]) {
|
|
||||||
raw.push({ type: 'equal', text: a[i] });
|
|
||||||
i++;
|
|
||||||
j++;
|
|
||||||
} else if (dp[i + 1][j] >= dp[i][j + 1]) {
|
|
||||||
raw.push({ type: 'delete', text: a[i] });
|
|
||||||
i++;
|
|
||||||
} else {
|
|
||||||
raw.push({ type: 'insert', text: b[j] });
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (i < m) raw.push({ type: 'delete', text: a[i++] });
|
|
||||||
while (j < n) raw.push({ type: 'insert', text: b[j++] });
|
|
||||||
const merged: Array<{ type: 'equal' | 'insert' | 'delete'; text: string }> = [];
|
|
||||||
for (const s of raw) {
|
|
||||||
const last = merged[merged.length - 1];
|
|
||||||
if (last && last.type === s.type) last.text += s.text;
|
|
||||||
else merged.push({ ...s });
|
|
||||||
}
|
|
||||||
return merged;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 逐字段比较套餐内容,返回发生变化的字段明细(用于“变动的地方详细列出”) */
|
|
||||||
function fieldChanges(
|
|
||||||
live: StorePackageItemDto | StorePackageViewDto,
|
|
||||||
proposed: StorePackageItemDto | StorePackageViewDto,
|
|
||||||
): FieldChange[] {
|
|
||||||
const changes: FieldChange[] = [];
|
|
||||||
const text = (v: string | number | null | undefined) => (v ?? '').toString().trim();
|
|
||||||
const pushText = (label: string, oldV: string, newV: string) => {
|
|
||||||
if (oldV !== newV) changes.push({ label, old: oldV, now: newV, kind: 'text' });
|
|
||||||
};
|
|
||||||
const pushValue = (label: string, oldV: string, newV: string) => {
|
|
||||||
if (oldV !== newV) changes.push({ label, old: oldV || '(空)', now: newV || '(空)', kind: 'value' });
|
|
||||||
};
|
|
||||||
pushValue('价格', `¥${text(live.price)}`, `¥${text(proposed.price)}`);
|
|
||||||
pushText('套餐名称', text(live.name), text(proposed.name));
|
|
||||||
pushText('菜品内容', text(live.dishes), text(proposed.dishes));
|
|
||||||
pushText('可用时间', text(live.usableTime), text(proposed.usableTime));
|
|
||||||
pushText('其他说明', text(live.otherNotes), text(proposed.otherNotes));
|
|
||||||
const liveImgs = normalizeStorePackageImageUrls(live);
|
|
||||||
const proposedImgs = normalizeStorePackageImageUrls(proposed);
|
|
||||||
if (imageSignature(live) !== imageSignature(proposed)) {
|
|
||||||
changes.push({ label: '图片', old: `${liveImgs.length} 张`, now: `${proposedImgs.length} 张`, kind: 'value' });
|
|
||||||
}
|
|
||||||
return changes;
|
|
||||||
}
|
|
||||||
|
|
||||||
function diffPackages(live: StorePackageViewDto[], proposed: StorePackageItemDto[]) {
|
|
||||||
const liveMap = new Map(live.map((p, i) => [packageKey(p, i), p]));
|
|
||||||
const proposedMap = new Map(proposed.map((p, i) => [packageKey(p, i), p]));
|
|
||||||
const keys = new Set([...liveMap.keys(), ...proposedMap.keys()]);
|
|
||||||
const rows: Array<{
|
|
||||||
key: string;
|
|
||||||
change: 'added' | 'removed' | 'changed' | 'unchanged';
|
|
||||||
live?: StorePackageViewDto;
|
|
||||||
proposed?: StorePackageItemDto;
|
|
||||||
changes?: FieldChange[];
|
|
||||||
}> = [];
|
|
||||||
|
|
||||||
for (const key of keys) {
|
|
||||||
const l = liveMap.get(key);
|
|
||||||
const p = proposedMap.get(key);
|
|
||||||
if (l && !p) {
|
|
||||||
rows.push({ key, change: 'removed', live: l });
|
|
||||||
} else if (!l && p) {
|
|
||||||
rows.push({ key, change: 'added', proposed: p });
|
|
||||||
} else if (l && p) {
|
|
||||||
const changed =
|
|
||||||
l.price !== p.price ||
|
|
||||||
l.dishes !== p.dishes ||
|
|
||||||
(l.usableTime ?? '') !== (p.usableTime ?? '') ||
|
|
||||||
(l.otherNotes ?? '') !== (p.otherNotes ?? '') ||
|
|
||||||
imageSignature(l) !== imageSignature(p);
|
|
||||||
rows.push({
|
|
||||||
key,
|
|
||||||
change: changed ? 'changed' : 'unchanged',
|
|
||||||
live: l,
|
|
||||||
proposed: p,
|
|
||||||
changes: changed ? fieldChanges(l, p) : undefined,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
const CHANGE_LABELS = {
|
|
||||||
added: { text: '新增', color: 'green' },
|
|
||||||
removed: { text: '删除', color: 'red' },
|
|
||||||
changed: { text: '变更', color: 'orange' },
|
|
||||||
unchanged: { text: '未变', color: 'default' },
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
/** 文本逐字差异渲染:原行红色删除线标出被删的字,新行绿色标出新增的字 */
|
|
||||||
function TextDiff({ oldText, newText }: { oldText: string; newText: string }) {
|
|
||||||
const segs = diffText(oldText, newText);
|
|
||||||
return (
|
|
||||||
<div style={{ marginTop: 2 }}>
|
|
||||||
<div style={{ lineHeight: 1.6 }}>
|
|
||||||
<Typography.Text type="secondary">原:</Typography.Text>
|
|
||||||
{segs
|
|
||||||
.filter((s) => s.type !== 'insert')
|
|
||||||
.map((s, idx) =>
|
|
||||||
s.type === 'delete' ? (
|
|
||||||
<Typography.Text key={idx} delete style={{ color: '#cf1322' }}>
|
|
||||||
{s.text || '(空)'}
|
|
||||||
</Typography.Text>
|
|
||||||
) : (
|
|
||||||
<Typography.Text key={idx}>{s.text}</Typography.Text>
|
|
||||||
),
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div style={{ lineHeight: 1.6 }}>
|
|
||||||
<Typography.Text type="secondary">新:</Typography.Text>
|
|
||||||
{segs
|
|
||||||
.filter((s) => s.type !== 'delete')
|
|
||||||
.map((s, idx) =>
|
|
||||||
s.type === 'insert' ? (
|
|
||||||
<Typography.Text key={idx} style={{ color: '#389e0d' }}>
|
|
||||||
{s.text || '(空)'}
|
|
||||||
</Typography.Text>
|
|
||||||
) : (
|
|
||||||
<Typography.Text key={idx}>{s.text}</Typography.Text>
|
|
||||||
),
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function PackageDetailCard({
|
|
||||||
title,
|
|
||||||
pkg,
|
|
||||||
change,
|
|
||||||
changes,
|
|
||||||
}: {
|
|
||||||
title?: string;
|
|
||||||
pkg: StorePackageItemDto | StorePackageViewDto;
|
|
||||||
change?: keyof typeof CHANGE_LABELS;
|
|
||||||
changes?: FieldChange[];
|
|
||||||
}) {
|
|
||||||
const images = normalizeStorePackageImageUrls(pkg);
|
|
||||||
const meta = change ? CHANGE_LABELS[change] : null;
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
marginBottom: 12,
|
|
||||||
padding: 12,
|
|
||||||
border: '1px solid #f0f0f0',
|
|
||||||
borderRadius: 8,
|
|
||||||
background: '#fafafa',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Space style={{ marginBottom: 8 }} wrap>
|
|
||||||
{title ? (
|
|
||||||
<Typography.Text type="secondary">{title}</Typography.Text>
|
|
||||||
) : null}
|
|
||||||
{meta ? <Tag color={meta.color}>{meta.text}</Tag> : null}
|
|
||||||
</Space>
|
|
||||||
<div style={{ marginBottom: 8 }}>
|
|
||||||
<strong>{pkg.name}</strong>
|
|
||||||
<span style={{ marginLeft: 8 }}>¥{pkg.price}</span>
|
|
||||||
</div>
|
|
||||||
<Typography.Paragraph className="admin-package-audit-text" style={{ marginBottom: 8 }}>
|
|
||||||
{pkg.dishes || '—'}
|
|
||||||
</Typography.Paragraph>
|
|
||||||
{pkg.usableTime ? (
|
|
||||||
<Typography.Paragraph
|
|
||||||
type="secondary"
|
|
||||||
className="admin-package-audit-text"
|
|
||||||
style={{ marginBottom: 4 }}
|
|
||||||
>
|
|
||||||
可用时间:{pkg.usableTime}
|
|
||||||
</Typography.Paragraph>
|
|
||||||
) : null}
|
|
||||||
{pkg.otherNotes ? (
|
|
||||||
<Typography.Paragraph
|
|
||||||
type="secondary"
|
|
||||||
className="admin-package-audit-text"
|
|
||||||
style={{ marginBottom: 8 }}
|
|
||||||
>
|
|
||||||
其他说明:{pkg.otherNotes}
|
|
||||||
</Typography.Paragraph>
|
|
||||||
) : null}
|
|
||||||
{images.length ? (
|
|
||||||
<Image.PreviewGroup>
|
|
||||||
<Space wrap size={8}>
|
|
||||||
{images.map((url) => (
|
|
||||||
<Image
|
|
||||||
key={url}
|
|
||||||
src={url}
|
|
||||||
width={72}
|
|
||||||
height={72}
|
|
||||||
style={{ objectFit: 'cover', borderRadius: 4 }}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</Space>
|
|
||||||
</Image.PreviewGroup>
|
|
||||||
) : (
|
|
||||||
<Typography.Text type="secondary">无套餐图片</Typography.Text>
|
|
||||||
)}
|
|
||||||
{changes && changes.length ? (
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
marginTop: 8,
|
|
||||||
padding: 8,
|
|
||||||
background: '#fff7e6',
|
|
||||||
border: '1px solid #ffe7ba',
|
|
||||||
borderRadius: 6,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography.Text strong style={{ fontSize: 12 }}>
|
|
||||||
变更明细
|
|
||||||
</Typography.Text>
|
|
||||||
<ul style={{ margin: '6px 0 0', paddingLeft: 18 }}>
|
|
||||||
{changes.map((c) => (
|
|
||||||
<li key={c.label} style={{ marginBottom: 6 }}>
|
|
||||||
<Typography.Text type="secondary">{c.label}:</Typography.Text>
|
|
||||||
{c.kind === 'text' ? (
|
|
||||||
<TextDiff oldText={c.old} newText={c.now} />
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<Typography.Text delete type="secondary">
|
|
||||||
{c.old}
|
|
||||||
</Typography.Text>
|
|
||||||
<Typography.Text type="secondary"> → </Typography.Text>
|
|
||||||
<Typography.Text strong>{c.now}</Typography.Text>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const INFO_CHANGE_FIELD_LABELS: Record<string, string> = {
|
|
||||||
name: '门店名称',
|
|
||||||
contactPhone: '联系电话',
|
|
||||||
address: '详细地址',
|
|
||||||
intro: '门店简介',
|
|
||||||
benefitUsageRule: '权益券使用规则',
|
|
||||||
latitude: '纬度',
|
|
||||||
longitude: '经度',
|
|
||||||
openTime: '营业开始',
|
|
||||||
closeTime: '营业结束',
|
|
||||||
openTime2: '第二段开始',
|
|
||||||
closeTime2: '第二段结束',
|
|
||||||
avgPrice: '人均费用',
|
|
||||||
};
|
|
||||||
|
|
||||||
function fmtFieldValue(field: string, v: unknown): string {
|
function fmtFieldValue(field: string, v: unknown): string {
|
||||||
if (v == null || String(v).trim() === '') return '(空)';
|
if (v == null || String(v).trim() === '') return '(空)';
|
||||||
if (field === 'avgPrice' || field === 'latitude' || field === 'longitude') {
|
if (field === 'avgPrice' || field === 'latitude' || field === 'longitude') {
|
||||||
return String(v);
|
return String(v);
|
||||||
}
|
}
|
||||||
|
if (field === 'envPhotoUrls' && Array.isArray(v)) {
|
||||||
|
return `${v.length} 张`;
|
||||||
|
}
|
||||||
|
if (field === 'coverUrl') return '见对比图';
|
||||||
return String(v);
|
return String(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function InfoChangeImageDiff({
|
||||||
|
field,
|
||||||
|
live,
|
||||||
|
proposed,
|
||||||
|
imageSize = 72,
|
||||||
|
}: {
|
||||||
|
field: string;
|
||||||
|
live: unknown;
|
||||||
|
proposed: unknown;
|
||||||
|
imageSize?: number;
|
||||||
|
}) {
|
||||||
|
const liveUrls =
|
||||||
|
field === 'coverUrl'
|
||||||
|
? [String(live || '').trim()].filter(Boolean)
|
||||||
|
: Array.isArray(live)
|
||||||
|
? live.map((u) => String(u || '').trim()).filter(Boolean)
|
||||||
|
: [];
|
||||||
|
const proposedUrls =
|
||||||
|
field === 'coverUrl'
|
||||||
|
? [String(proposed || '').trim()].filter(Boolean)
|
||||||
|
: Array.isArray(proposed)
|
||||||
|
? proposed.map((u) => String(u || '').trim()).filter(Boolean)
|
||||||
|
: [];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div style={{ display: 'flex', gap: 16, flexWrap: 'wrap' }}>
|
||||||
|
<div>
|
||||||
|
<Typography.Text type="secondary" style={{ display: 'block', marginBottom: 6 }}>
|
||||||
|
变更前
|
||||||
|
</Typography.Text>
|
||||||
|
{liveUrls.length ? (
|
||||||
|
<Image.PreviewGroup>
|
||||||
|
<Space wrap size={8}>
|
||||||
|
{liveUrls.map((url) => (
|
||||||
|
<Image key={`live-${url}`} src={url} width={imageSize} height={imageSize} style={{ objectFit: 'cover', borderRadius: 4 }} />
|
||||||
|
))}
|
||||||
|
</Space>
|
||||||
|
</Image.PreviewGroup>
|
||||||
|
) : (
|
||||||
|
<Typography.Text type="secondary">(空)</Typography.Text>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Typography.Text type="secondary" style={{ display: 'block', marginBottom: 6 }}>
|
||||||
|
变更后
|
||||||
|
</Typography.Text>
|
||||||
|
{proposedUrls.length ? (
|
||||||
|
<Image.PreviewGroup>
|
||||||
|
<Space wrap size={8}>
|
||||||
|
{proposedUrls.map((url) => (
|
||||||
|
<Image key={`new-${url}`} src={url} width={imageSize} height={imageSize} style={{ objectFit: 'cover', borderRadius: 4 }} />
|
||||||
|
))}
|
||||||
|
</Space>
|
||||||
|
</Image.PreviewGroup>
|
||||||
|
) : (
|
||||||
|
<Typography.Text type="secondary">(空)</Typography.Text>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function InfoChangeAuditPanel({
|
function InfoChangeAuditPanel({
|
||||||
initialRequestId,
|
initialRequestId,
|
||||||
}: {
|
}: {
|
||||||
@@ -345,6 +131,7 @@ function InfoChangeAuditPanel({
|
|||||||
const [rejectOpen, setRejectOpen] = useState(false);
|
const [rejectOpen, setRejectOpen] = useState(false);
|
||||||
const [rejectReason, setRejectReason] = useState('');
|
const [rejectReason, setRejectReason] = useState('');
|
||||||
const [activeId, setActiveId] = useState<string | null>(null);
|
const [activeId, setActiveId] = useState<string | null>(null);
|
||||||
|
const [infoFullscreen, setInfoFullscreen] = useState(false);
|
||||||
|
|
||||||
async function reload(nextPage = page, nextStatus = status) {
|
async function reload(nextPage = page, nextStatus = status) {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@@ -425,7 +212,7 @@ function InfoChangeAuditPanel({
|
|||||||
render: (_, row) =>
|
render: (_, row) =>
|
||||||
row.changedFields?.length
|
row.changedFields?.length
|
||||||
? row.changedFields.map((f) => (
|
? row.changedFields.map((f) => (
|
||||||
<Tag key={f}>{INFO_CHANGE_FIELD_LABELS[f] ?? f}</Tag>
|
<Tag key={f}>{STORE_INFO_CHANGEABLE_FIELD_LABELS[f as keyof typeof STORE_INFO_CHANGEABLE_FIELD_LABELS] ?? f}</Tag>
|
||||||
))
|
))
|
||||||
: '—',
|
: '—',
|
||||||
},
|
},
|
||||||
@@ -503,12 +290,19 @@ function InfoChangeAuditPanel({
|
|||||||
|
|
||||||
<Drawer
|
<Drawer
|
||||||
title={detail ? `${detail.storeName || detail.storeId} · 信息变更` : '信息变更详情'}
|
title={detail ? `${detail.storeName || detail.storeId} · 信息变更` : '信息变更详情'}
|
||||||
width={680}
|
width={infoFullscreen ? '100%' : 680}
|
||||||
open={detailOpen}
|
open={detailOpen}
|
||||||
onClose={() => setDetailOpen(false)}
|
onClose={() => {
|
||||||
|
setDetailOpen(false);
|
||||||
|
setInfoFullscreen(false);
|
||||||
|
}}
|
||||||
extra={
|
extra={
|
||||||
detail?.status === 'PENDING' ? (
|
|
||||||
<Space>
|
<Space>
|
||||||
|
<Button onClick={() => setInfoFullscreen((v) => !v)}>
|
||||||
|
{infoFullscreen ? '退出全屏' : '全屏查看'}
|
||||||
|
</Button>
|
||||||
|
{detail?.status === 'PENDING' ? (
|
||||||
|
<>
|
||||||
<Button onClick={() => void audit(detail.id, 'APPROVE')}>通过</Button>
|
<Button onClick={() => void audit(detail.id, 'APPROVE')}>通过</Button>
|
||||||
<Button
|
<Button
|
||||||
danger
|
danger
|
||||||
@@ -520,8 +314,9 @@ function InfoChangeAuditPanel({
|
|||||||
>
|
>
|
||||||
驳回
|
驳回
|
||||||
</Button>
|
</Button>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
</Space>
|
</Space>
|
||||||
) : null
|
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{detailLoading ? (
|
{detailLoading ? (
|
||||||
@@ -542,8 +337,16 @@ function InfoChangeAuditPanel({
|
|||||||
{detail.diffs.map((d) => (
|
{detail.diffs.map((d) => (
|
||||||
<Descriptions.Item
|
<Descriptions.Item
|
||||||
key={d.field}
|
key={d.field}
|
||||||
label={INFO_CHANGE_FIELD_LABELS[d.field] ?? d.field}
|
label={STORE_INFO_CHANGEABLE_FIELD_LABELS[d.field] ?? d.field}
|
||||||
>
|
>
|
||||||
|
{d.field === 'coverUrl' || d.field === 'envPhotoUrls' ? (
|
||||||
|
<InfoChangeImageDiff
|
||||||
|
field={d.field}
|
||||||
|
live={d.live}
|
||||||
|
proposed={d.proposed}
|
||||||
|
imageSize={infoFullscreen ? 160 : 72}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
<span>
|
<span>
|
||||||
<Typography.Text delete type="secondary">
|
<Typography.Text delete type="secondary">
|
||||||
{fmtFieldValue(d.field, d.live)}
|
{fmtFieldValue(d.field, d.live)}
|
||||||
@@ -553,6 +356,7 @@ function InfoChangeAuditPanel({
|
|||||||
{fmtFieldValue(d.field, d.proposed)}
|
{fmtFieldValue(d.field, d.proposed)}
|
||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
</span>
|
</span>
|
||||||
|
)}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
))}
|
))}
|
||||||
</Descriptions>
|
</Descriptions>
|
||||||
@@ -599,8 +403,9 @@ export default function StorePackageAuditsPage() {
|
|||||||
const [rejectReason, setRejectReason] = useState('');
|
const [rejectReason, setRejectReason] = useState('');
|
||||||
const [activeId, setActiveId] = useState<string | null>(null);
|
const [activeId, setActiveId] = useState<string | null>(null);
|
||||||
const [detailOpen, setDetailOpen] = useState(false);
|
const [detailOpen, setDetailOpen] = useState(false);
|
||||||
const [detailLoading, setDetailLoading] = useState(false);
|
const [activeRequestId, setActiveRequestId] = useState<string | null>(null);
|
||||||
const [detail, setDetail] = useState<StorePackageAuditDetailDto | null>(null);
|
const [drawerTitle, setDrawerTitle] = useState('套餐变更详情');
|
||||||
|
const [packageFullscreen, setPackageFullscreen] = useState(false);
|
||||||
|
|
||||||
async function reload(nextPage = page, nextStatus = status) {
|
async function reload(nextPage = page, nextStatus = status) {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@@ -629,30 +434,23 @@ export default function StorePackageAuditsPage() {
|
|||||||
void reload(1, status);
|
void reload(1, status);
|
||||||
}, [status]);
|
}, [status]);
|
||||||
|
|
||||||
// 从门店详情 / 门店列表跳转过来时,带 requestId 自动打开审核(对比)抽屉
|
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const initialTab = searchParams.get('tab') === 'info' ? 'info' : 'package';
|
const initialTab = searchParams.get('tab') === 'info' ? 'info' : 'package';
|
||||||
const [activeTab, setActiveTab] = useState<string>(initialTab);
|
const [activeTab, setActiveTab] = useState<string>(initialTab);
|
||||||
const infoRequestId = searchParams.get('infoRequestId');
|
const infoRequestId = searchParams.get('infoRequestId');
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const rid = searchParams.get('requestId');
|
const rid = searchParams.get('requestId');
|
||||||
if (rid) void openDetail(rid);
|
if (rid) {
|
||||||
|
setActiveRequestId(rid);
|
||||||
|
setDetailOpen(true);
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
async function openDetail(id: string) {
|
function openDetail(id: string) {
|
||||||
|
setActiveRequestId(id);
|
||||||
|
setDrawerTitle('套餐变更详情');
|
||||||
setDetailOpen(true);
|
setDetailOpen(true);
|
||||||
setDetailLoading(true);
|
|
||||||
setDetail(null);
|
|
||||||
try {
|
|
||||||
const data = await request<StorePackageAuditDetailDto>(`/admin/store-package-audits/${id}`);
|
|
||||||
setDetail(data);
|
|
||||||
} catch (e) {
|
|
||||||
message.error(e instanceof Error ? e.message : '加载详情失败');
|
|
||||||
setDetailOpen(false);
|
|
||||||
} finally {
|
|
||||||
setDetailLoading(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function audit(id: string, action: 'APPROVE' | 'REJECT', reason?: string) {
|
async function audit(id: string, action: 'APPROVE' | 'REJECT', reason?: string) {
|
||||||
@@ -672,15 +470,7 @@ export default function StorePackageAuditsPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const diffRows = detail ? diffPackages(detail.livePackages ?? [], detail.packages ?? []) : [];
|
const baseColumns: ColumnsType<StorePackageChangeRequestDto> = [
|
||||||
const changeByKey = new Map(diffRows.map((row) => [row.key, row.change]));
|
|
||||||
const changesByKey = new Map(diffRows.map((row) => [row.key, row.changes]));
|
|
||||||
const addedCount = diffRows.filter((r) => r.change === 'added').length;
|
|
||||||
const removedCount = diffRows.filter((r) => r.change === 'removed').length;
|
|
||||||
const changedCount = diffRows.filter((r) => r.change === 'changed').length;
|
|
||||||
const unchangedCount = diffRows.filter((r) => r.change === 'unchanged').length;
|
|
||||||
|
|
||||||
const columns: ColumnsType<StorePackageChangeRequestDto> = [
|
|
||||||
{ title: '门店', dataIndex: 'storeName', render: (_, row) => row.storeName || row.storeId },
|
{ title: '门店', dataIndex: 'storeName', render: (_, row) => row.storeName || row.storeId },
|
||||||
{
|
{
|
||||||
title: '状态',
|
title: '状态',
|
||||||
@@ -702,7 +492,7 @@ export default function StorePackageAuditsPage() {
|
|||||||
title: '操作',
|
title: '操作',
|
||||||
render: (_, row) => (
|
render: (_, row) => (
|
||||||
<Space>
|
<Space>
|
||||||
<Button type="link" onClick={() => void openDetail(row.id)}>
|
<Button type="link" onClick={() => openDetail(row.id)}>
|
||||||
查看变更
|
查看变更
|
||||||
</Button>
|
</Button>
|
||||||
{row.status === 'PENDING' ? (
|
{row.status === 'PENDING' ? (
|
||||||
@@ -730,9 +520,16 @@ export default function StorePackageAuditsPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('store-package-audits', baseColumns, {
|
||||||
|
page,
|
||||||
|
pageSize: 20,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Typography.Title level={4}>审核通知</Typography.Title>
|
<Typography.Title level={4}>审核通知</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Tabs
|
<Tabs
|
||||||
activeKey={activeTab}
|
activeKey={activeTab}
|
||||||
onChange={setActiveTab}
|
onChange={setActiveTab}
|
||||||
@@ -781,90 +578,32 @@ export default function StorePackageAuditsPage() {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<Drawer
|
<Drawer
|
||||||
title={detail ? `${detail.storeName || detail.storeId} · 套餐变更` : '套餐变更详情'}
|
title={drawerTitle}
|
||||||
width={880}
|
width={packageFullscreen ? '100%' : 880}
|
||||||
open={detailOpen}
|
open={detailOpen}
|
||||||
onClose={() => setDetailOpen(false)}
|
onClose={() => {
|
||||||
extra={
|
setDetailOpen(false);
|
||||||
detail?.status === 'PENDING' ? (
|
setPackageFullscreen(false);
|
||||||
<Space>
|
|
||||||
<Button onClick={() => void audit(detail.id, 'APPROVE')}>通过</Button>
|
|
||||||
<Button
|
|
||||||
danger
|
|
||||||
onClick={() => {
|
|
||||||
setActiveId(detail.id);
|
|
||||||
setRejectReason('');
|
|
||||||
setRejectOpen(true);
|
|
||||||
}}
|
}}
|
||||||
>
|
destroyOnClose
|
||||||
驳回
|
extra={
|
||||||
|
<Button onClick={() => setPackageFullscreen((v) => !v)}>
|
||||||
|
{packageFullscreen ? '退出全屏' : '全屏查看'}
|
||||||
</Button>
|
</Button>
|
||||||
</Space>
|
|
||||||
) : null
|
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{detailLoading ? (
|
{activeRequestId ? (
|
||||||
<Typography.Text type="secondary">加载中…</Typography.Text>
|
<StorePackageAuditPanel
|
||||||
) : detail ? (
|
requestId={activeRequestId}
|
||||||
<>
|
fullscreen={packageFullscreen}
|
||||||
<Space style={{ marginBottom: 16 }} wrap>
|
onAudited={() => {
|
||||||
<Tag>{HQ_PACKAGE_STATUS_LABELS[detail.status]}</Tag>
|
setDetailOpen(false);
|
||||||
<Typography.Text type="secondary">
|
void reload(page, status);
|
||||||
提交方:{detail.submitterType === 'PARTNER' ? '合伙人' : '门店'} · {fmtTime(detail.createdAt)}
|
}}
|
||||||
</Typography.Text>
|
onDetailLoaded={(d) => {
|
||||||
</Space>
|
if (d) setDrawerTitle(`${d.storeName || d.storeId} · 套餐变更`);
|
||||||
{detail.rejectReason ? (
|
}}
|
||||||
<Typography.Paragraph type="danger">驳回原因:{detail.rejectReason}</Typography.Paragraph>
|
|
||||||
) : null}
|
|
||||||
<Space direction="vertical" size={4} style={{ marginBottom: 12 }}>
|
|
||||||
<Typography.Text type="secondary">
|
|
||||||
线上已审核 {detail.livePackages?.length ?? 0} 条 · 待审核 {detail.packages?.length ?? 0} 条
|
|
||||||
</Typography.Text>
|
|
||||||
<Space wrap>
|
|
||||||
<Tag color="green">新增 {addedCount}</Tag>
|
|
||||||
<Tag color="red">删除 {removedCount}</Tag>
|
|
||||||
<Tag color="orange">变更 {changedCount}</Tag>
|
|
||||||
{unchangedCount ? <Tag>未变 {unchangedCount}</Tag> : null}
|
|
||||||
</Space>
|
|
||||||
</Space>
|
|
||||||
<div className="admin-package-audit-cols">
|
|
||||||
<div className="admin-package-audit-col">
|
|
||||||
<Typography.Title level={5} style={{ marginTop: 0 }}>
|
|
||||||
线上已审核套餐
|
|
||||||
</Typography.Title>
|
|
||||||
{(detail.livePackages ?? []).length ? (
|
|
||||||
(detail.livePackages ?? []).map((pkg, index) => (
|
|
||||||
<PackageDetailCard
|
|
||||||
key={`live-${packageKey(pkg, index)}`}
|
|
||||||
title={`套餐 ${index + 1}`}
|
|
||||||
pkg={pkg}
|
|
||||||
change={changeByKey.get(packageKey(pkg, index))}
|
|
||||||
/>
|
/>
|
||||||
))
|
|
||||||
) : (
|
|
||||||
<Typography.Text type="secondary">暂无线上套餐</Typography.Text>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div className="admin-package-audit-col">
|
|
||||||
<Typography.Title level={5} style={{ marginTop: 0 }}>
|
|
||||||
待审核套餐
|
|
||||||
</Typography.Title>
|
|
||||||
{(detail.packages ?? []).length ? (
|
|
||||||
(detail.packages ?? []).map((pkg, index) => (
|
|
||||||
<PackageDetailCard
|
|
||||||
key={`pending-${packageKey(pkg, index)}`}
|
|
||||||
title={`套餐 ${index + 1}`}
|
|
||||||
pkg={pkg}
|
|
||||||
change={changeByKey.get(packageKey(pkg, index))}
|
|
||||||
changes={changesByKey.get(packageKey(pkg, index))}
|
|
||||||
/>
|
|
||||||
))
|
|
||||||
) : (
|
|
||||||
<Typography.Text type="secondary">暂无待审核套餐</Typography.Text>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
) : null}
|
) : null}
|
||||||
</Drawer>
|
</Drawer>
|
||||||
|
|
||||||
@@ -892,3 +631,4 @@ export default function StorePackageAuditsPage() {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import { useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Button, Form, Input, Table, Typography } from 'antd';
|
import { Button, Form, Input, Select, Table, Typography } from 'antd';
|
||||||
import type { ColumnsType } from 'antd/es/table';
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
import { useSearchParams } from 'react-router-dom';
|
import { useSearchParams } from 'react-router-dom';
|
||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime, ADMIN_OPTIONS_PAGE_SIZE } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { request, type Paginated } from '../lib/api';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -20,22 +23,30 @@ export default function StoreRatingsPage() {
|
|||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const initialStoreId = searchParams.get('storeId') || '';
|
const initialStoreId = searchParams.get('storeId') || '';
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
|
const [cities, setCities] = useState<{ id: string; name: string }[]>([]);
|
||||||
const [filters, setFilters] = useState<Record<string, string>>({
|
const [filters, setFilters] = useState<Record<string, string>>({
|
||||||
...(initialStoreId ? { storeId: initialStoreId } : {}),
|
...(initialStoreId ? { storeId: initialStoreId } : {}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
request<Paginated<{ id: string; name: string }>>(`/admin/cities?pageSize=${ADMIN_OPTIONS_PAGE_SIZE}`)
|
||||||
|
.then((res) => setCities(res.items))
|
||||||
|
.catch(() => {});
|
||||||
|
}, []);
|
||||||
|
|
||||||
const { data, loading, page, pageSize, setPage, setPageSize } = useAdminList<Row>(
|
const { data, loading, page, pageSize, setPage, setPageSize } = useAdminList<Row>(
|
||||||
'/admin/store-ratings',
|
'/admin/store-ratings',
|
||||||
() => {
|
() => {
|
||||||
const qs = new URLSearchParams();
|
const qs = new URLSearchParams();
|
||||||
if (filters.storeId) qs.set('storeId', filters.storeId);
|
if (filters.storeId) qs.set('storeId', filters.storeId);
|
||||||
|
if (filters.cityId) qs.set('cityId', filters.cityId);
|
||||||
if (filters.redeemNo) qs.set('redeemNo', filters.redeemNo);
|
if (filters.redeemNo) qs.set('redeemNo', filters.redeemNo);
|
||||||
return qs;
|
return qs;
|
||||||
},
|
},
|
||||||
[filters],
|
[filters],
|
||||||
);
|
);
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{ title: '核销号', dataIndex: 'redeemNo', width: 180 },
|
{ title: '核销号', dataIndex: 'redeemNo', width: 180 },
|
||||||
{
|
{
|
||||||
title: '门店',
|
title: '门店',
|
||||||
@@ -53,11 +64,15 @@ export default function StoreRatingsPage() {
|
|||||||
{ title: '评价时间', dataIndex: 'createdAt', width: 170, render: fmtTime },
|
{ title: '评价时间', dataIndex: 'createdAt', width: 170, render: fmtTime },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('store-ratings', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Typography.Title level={4} style={{ marginTop: 0 }}>
|
<Typography.Title level={4} style={{ marginTop: 0 }}>
|
||||||
门店评价
|
门店评价
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Form
|
<Form
|
||||||
form={form}
|
form={form}
|
||||||
layout="inline"
|
layout="inline"
|
||||||
@@ -66,11 +81,22 @@ export default function StoreRatingsPage() {
|
|||||||
onFinish={(v) => {
|
onFinish={(v) => {
|
||||||
setFilters({
|
setFilters({
|
||||||
storeId: v.storeId || '',
|
storeId: v.storeId || '',
|
||||||
|
cityId: v.cityId || '',
|
||||||
redeemNo: v.redeemNo || '',
|
redeemNo: v.redeemNo || '',
|
||||||
});
|
});
|
||||||
setPage(1);
|
setPage(1);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<Form.Item name="cityId" label="城市">
|
||||||
|
<Select
|
||||||
|
allowClear
|
||||||
|
showSearch
|
||||||
|
optionFilterProp="label"
|
||||||
|
style={{ width: 140 }}
|
||||||
|
placeholder="全部"
|
||||||
|
options={cities.map((c) => ({ value: c.id, label: c.name }))}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
<Form.Item name="storeId" label="门店ID">
|
<Form.Item name="storeId" label="门店ID">
|
||||||
<Input allowClear placeholder="storeId" />
|
<Input allowClear placeholder="storeId" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ import { STORE_WITHDRAW_STATUS_LABELS, type StoreWithdrawStatus } from '@dukang/
|
|||||||
import { request, type Paginated } from '../lib/api';
|
import { request, type Paginated } from '../lib/api';
|
||||||
import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
|
import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -147,7 +149,7 @@ export default function StoreWithdrawalsPage() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{
|
{
|
||||||
title: '提现单号',
|
title: '提现单号',
|
||||||
dataIndex: 'withdrawNo',
|
dataIndex: 'withdrawNo',
|
||||||
@@ -229,11 +231,15 @@ export default function StoreWithdrawalsPage() {
|
|||||||
}
|
}
|
||||||
| undefined;
|
| undefined;
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('finance-store-withdrawals', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Typography.Title level={4} style={{ marginTop: 0 }}>
|
<Typography.Title level={4} style={{ marginTop: 0 }}>
|
||||||
门店提现审
|
门店提现审
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
{overdueSummary ? (
|
{overdueSummary ? (
|
||||||
<Typography.Paragraph type="secondary">
|
<Typography.Paragraph type="secondary">
|
||||||
待审 {overdueSummary.pendingCount} 笔
|
待审 {overdueSummary.pendingCount} 笔
|
||||||
@@ -299,7 +305,7 @@ export default function StoreWithdrawalsPage() {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data?.items ?? []}
|
dataSource={data?.items ?? []}
|
||||||
scroll={{ x: 1100 }}
|
scroll={{ x: 'max-content' }}
|
||||||
rowClassName={(row) => (row.overdue ? 'ant-table-row-selected' : '')}
|
rowClassName={(row) => (row.overdue ? 'ant-table-row-selected' : '')}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: page,
|
current: page,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { useEffect, useMemo, useRef, useState } from 'react';
|
|||||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
Alert,
|
Alert,
|
||||||
|
Badge,
|
||||||
Button,
|
Button,
|
||||||
Checkbox,
|
Checkbox,
|
||||||
Descriptions,
|
Descriptions,
|
||||||
@@ -38,6 +39,7 @@ import {
|
|||||||
type StoreCreateForm,
|
type StoreCreateForm,
|
||||||
} from '../lib/storeCreate';
|
} from '../lib/storeCreate';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
import { resolveRegionBinding } from '../lib/china-region';
|
import { resolveRegionBinding } from '../lib/china-region';
|
||||||
import ChinaRegionCascader from '../components/ChinaRegionCascader';
|
import ChinaRegionCascader from '../components/ChinaRegionCascader';
|
||||||
import OssUpload from '../components/OssUpload';
|
import OssUpload from '../components/OssUpload';
|
||||||
@@ -46,6 +48,9 @@ import TencentLocPickerModal from '../components/TencentLocPickerModal';
|
|||||||
import AdminStorePackagesSection, {
|
import AdminStorePackagesSection, {
|
||||||
type AdminStorePackagesHandle,
|
type AdminStorePackagesHandle,
|
||||||
} from '../components/AdminStorePackagesSection';
|
} from '../components/AdminStorePackagesSection';
|
||||||
|
import StorePackageAuditPanel, {
|
||||||
|
auditStorePackageRequest,
|
||||||
|
} from '../components/StorePackageAuditPanel';
|
||||||
|
|
||||||
const CREATE_STEPS = [
|
const CREATE_STEPS = [
|
||||||
{ title: '基本信息' },
|
{ title: '基本信息' },
|
||||||
@@ -194,6 +199,9 @@ type StoreRow = {
|
|||||||
pendingPackageAuditId?: string | null;
|
pendingPackageAuditId?: string | null;
|
||||||
/** 该门店当前待审核信息变更的 requestId(无则为空) */
|
/** 该门店当前待审核信息变更的 requestId(无则为空) */
|
||||||
pendingInfoChangeId?: string | null;
|
pendingInfoChangeId?: string | null;
|
||||||
|
/** 累计核销好客权益(券面额合计) */
|
||||||
|
totalRedeemedBenefitAmount?: number;
|
||||||
|
contactPhone?: string | null;
|
||||||
isTest?: boolean;
|
isTest?: boolean;
|
||||||
cityRef?: { name: string; code: string };
|
cityRef?: { name: string; code: string };
|
||||||
partner?: { id?: string; companyName?: string | null; name?: string | null; phone?: string | null };
|
partner?: { id?: string; companyName?: string | null; name?: string | null; phone?: string | null };
|
||||||
@@ -242,6 +250,8 @@ export default function StoresPage() {
|
|||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const initialCityId = searchParams.get('cityId') ?? '';
|
const initialCityId = searchParams.get('cityId') ?? '';
|
||||||
const initialPartnerId = searchParams.get('partnerId') ?? '';
|
const initialPartnerId = searchParams.get('partnerId') ?? '';
|
||||||
|
const initialAuditStatus = searchParams.get('auditStatus') ?? '';
|
||||||
|
const initialStoreId = searchParams.get('storeId') ?? '';
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const [editForm] = Form.useForm();
|
const [editForm] = Form.useForm();
|
||||||
const [createForm] = Form.useForm<StoreCreateForm>();
|
const [createForm] = Form.useForm<StoreCreateForm>();
|
||||||
@@ -249,6 +259,7 @@ export default function StoresPage() {
|
|||||||
const init: Record<string, string | boolean> = {};
|
const init: Record<string, string | boolean> = {};
|
||||||
if (initialCityId) init.cityId = initialCityId;
|
if (initialCityId) init.cityId = initialCityId;
|
||||||
if (initialPartnerId) init.partnerId = initialPartnerId;
|
if (initialPartnerId) init.partnerId = initialPartnerId;
|
||||||
|
if (initialAuditStatus) init.auditStatus = initialAuditStatus;
|
||||||
return init;
|
return init;
|
||||||
});
|
});
|
||||||
const { data, loading, page, pageSize, setPage, setPageSize, reload } = useAdminList<StoreRow>(
|
const { data, loading, page, pageSize, setPage, setPageSize, reload } = useAdminList<StoreRow>(
|
||||||
@@ -270,7 +281,11 @@ export default function StoresPage() {
|
|||||||
const [filterPartners, setFilterPartners] = useState<PartnerOption[]>([]);
|
const [filterPartners, setFilterPartners] = useState<PartnerOption[]>([]);
|
||||||
const [detail, setDetail] = useState<Record<string, unknown> | null>(null);
|
const [detail, setDetail] = useState<Record<string, unknown> | null>(null);
|
||||||
const [drawerOpen, setDrawerOpen] = useState(false);
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
||||||
|
const [detailTab, setDetailTab] = useState('basic');
|
||||||
const packagesRef = useRef<AdminStorePackagesHandle>(null);
|
const packagesRef = useRef<AdminStorePackagesHandle>(null);
|
||||||
|
const [packageRejectOpen, setPackageRejectOpen] = useState(false);
|
||||||
|
const [packageRejectReason, setPackageRejectReason] = useState('');
|
||||||
|
const [packageAuditing, setPackageAuditing] = useState(false);
|
||||||
const [rejectOpen, setRejectOpen] = useState(false);
|
const [rejectOpen, setRejectOpen] = useState(false);
|
||||||
const [rejectReason, setRejectReason] = useState('');
|
const [rejectReason, setRejectReason] = useState('');
|
||||||
const [auditing, setAuditing] = useState(false);
|
const [auditing, setAuditing] = useState(false);
|
||||||
@@ -286,6 +301,7 @@ export default function StoresPage() {
|
|||||||
const [optionsLoading, setOptionsLoading] = useState(false);
|
const [optionsLoading, setOptionsLoading] = useState(false);
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
const [phoneMismatch, setPhoneMismatch] = useState<string | null>(null);
|
const [phoneMismatch, setPhoneMismatch] = useState<string | null>(null);
|
||||||
|
const deepLinkStoreOpenedRef = useRef(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void request<Paginated<CityOption>>(`/admin/cities?pageSize=${ADMIN_OPTIONS_PAGE_SIZE}`)
|
void request<Paginated<CityOption>>(`/admin/cities?pageSize=${ADMIN_OPTIONS_PAGE_SIZE}`)
|
||||||
@@ -296,6 +312,12 @@ export default function StoresPage() {
|
|||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (initialAuditStatus) {
|
||||||
|
form.setFieldsValue({ auditStatus: initialAuditStatus });
|
||||||
|
}
|
||||||
|
}, [form, initialAuditStatus]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const cityId = searchParams.get('cityId') ?? '';
|
const cityId = searchParams.get('cityId') ?? '';
|
||||||
const partnerId = searchParams.get('partnerId') ?? '';
|
const partnerId = searchParams.get('partnerId') ?? '';
|
||||||
@@ -348,13 +370,18 @@ export default function StoresPage() {
|
|||||||
.map((n) => ({ value: n.id, label: n.name }));
|
.map((n) => ({ value: n.id, label: n.name }));
|
||||||
}, [categoryTree, editCategoryParentId]);
|
}, [categoryTree, editCategoryParentId]);
|
||||||
|
|
||||||
async function openStoreDetail(row: StoreRow) {
|
async function openStoreDetail(row: StoreRow, opts?: { tab?: string }) {
|
||||||
const [d, cats] = await Promise.all([
|
const [d, cats] = await Promise.all([
|
||||||
request<Record<string, unknown>>(`/admin/stores/${row.id}`),
|
request<Record<string, unknown>>(`/admin/stores/${row.id}`),
|
||||||
request<CategoryNode[]>('/admin/store-categories').catch(() => [] as CategoryNode[]),
|
request<CategoryNode[]>('/admin/store-categories').catch(() => [] as CategoryNode[]),
|
||||||
]);
|
]);
|
||||||
setCategoryTree(Array.isArray(cats) ? cats : []);
|
setCategoryTree(Array.isArray(cats) ? cats : []);
|
||||||
setDetail(d);
|
setDetail({
|
||||||
|
...d,
|
||||||
|
pendingPackageAuditId: row.pendingPackageAuditId ?? d.pendingPackageAuditId,
|
||||||
|
pendingInfoChangeId: row.pendingInfoChangeId ?? d.pendingInfoChangeId,
|
||||||
|
});
|
||||||
|
setDetailTab(opts?.tab || 'basic');
|
||||||
const category = d.category && typeof d.category === 'object'
|
const category = d.category && typeof d.category === 'object'
|
||||||
? (d.category as { id?: string; parentId?: string | null })
|
? (d.category as { id?: string; parentId?: string | null })
|
||||||
: null;
|
: null;
|
||||||
@@ -441,6 +468,19 @@ export default function StoresPage() {
|
|||||||
setDrawerOpen(true);
|
setDrawerOpen(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!initialStoreId || deepLinkStoreOpenedRef.current || loading) return;
|
||||||
|
const row = data?.items?.find((s) => String(s.id) === initialStoreId);
|
||||||
|
if (row) {
|
||||||
|
deepLinkStoreOpenedRef.current = true;
|
||||||
|
void openStoreDetail(row);
|
||||||
|
} else if (data && (data.items?.length ?? 0) >= 0) {
|
||||||
|
// 列表无该店时仍尝试直拉详情
|
||||||
|
deepLinkStoreOpenedRef.current = true;
|
||||||
|
void openStoreDetail({ id: initialStoreId } as StoreRow);
|
||||||
|
}
|
||||||
|
}, [data, initialStoreId, loading]);
|
||||||
|
|
||||||
async function saveStoreDetail() {
|
async function saveStoreDetail() {
|
||||||
if (!detail) return;
|
if (!detail) return;
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
@@ -684,47 +724,60 @@ export default function StoresPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<StoreRow> = [
|
const baseColumns: ColumnsType<StoreRow> = [
|
||||||
{
|
{
|
||||||
|
key: 'coverUrl',
|
||||||
title: '封面', dataIndex: 'coverUrl', width: 72,
|
title: '封面', dataIndex: 'coverUrl', width: 72,
|
||||||
render: (url) => url ? <Image src={url} width={48} height={48} style={{ objectFit: 'cover', borderRadius: 4 }} /> : '—',
|
render: (url) => url ? <Image src={url} width={48} height={48} style={{ objectFit: 'cover', borderRadius: 4 }} /> : '—',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
key: 'name',
|
||||||
title: '门店名',
|
title: '门店名',
|
||||||
dataIndex: 'name',
|
dataIndex: 'name',
|
||||||
width: 180,
|
width: 180,
|
||||||
ellipsis: { showTitle: false },
|
|
||||||
render: (v: string, row) => {
|
render: (v: string, row) => {
|
||||||
const name = v || '—';
|
const name = v || '—';
|
||||||
return (
|
return (
|
||||||
<Space size={4} style={{ maxWidth: '100%' }} wrap={false}>
|
<Space size={4} wrap={false}>
|
||||||
<Typography.Text ellipsis={{ tooltip: name }} style={{ maxWidth: row.isTest ? 110 : 160 }}>
|
<span>{name}</span>
|
||||||
{name}
|
|
||||||
</Typography.Text>
|
|
||||||
{row.isTest ? <Tag color="orange">测试</Tag> : null}
|
{row.isTest ? <Tag color="orange">测试</Tag> : null}
|
||||||
</Space>
|
</Space>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
key: 'category',
|
||||||
title: '分类',
|
title: '分类',
|
||||||
width: 100,
|
width: 100,
|
||||||
ellipsis: true,
|
|
||||||
render: (_, row) => row.category?.name || '—',
|
render: (_, row) => row.category?.name || '—',
|
||||||
},
|
},
|
||||||
{ title: '城市', dataIndex: 'cityName', width: 80, ellipsis: true },
|
{ key: 'cityName', title: '城市', dataIndex: 'cityName', width: 80 },
|
||||||
{ title: '登录号', dataIndex: 'phone', width: 120 },
|
{ key: 'phone', title: '登录号', dataIndex: 'phone', width: 120 },
|
||||||
{
|
{
|
||||||
|
key: 'contactPhone',
|
||||||
title: '联系电话',
|
title: '联系电话',
|
||||||
dataIndex: 'contactPhone',
|
dataIndex: 'contactPhone',
|
||||||
width: 120,
|
width: 120,
|
||||||
render: (v: string | null | undefined, row) => v || row.phone,
|
render: (v: string | null | undefined, row) => v || row.phone,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
key: 'status',
|
||||||
title: '营业状态', dataIndex: 'status', width: 90,
|
title: '营业状态', dataIndex: 'status', width: 90,
|
||||||
render: (s) => <Tag>{STORE_STATUS_LABELS[s] || s}</Tag>,
|
render: (s) => <Tag>{STORE_STATUS_LABELS[s] || s}</Tag>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
key: 'totalRedeemedBenefitAmount',
|
||||||
|
title: '累计核销好客权益',
|
||||||
|
dataIndex: 'totalRedeemedBenefitAmount',
|
||||||
|
width: 150,
|
||||||
|
align: 'right',
|
||||||
|
render: (v: number | undefined) => {
|
||||||
|
const n = Number(v ?? 0);
|
||||||
|
return n > 0 ? `¥${n.toFixed(2)}` : '—';
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'auditStatus',
|
||||||
title: '审核', dataIndex: 'auditStatus', width: 100,
|
title: '审核', dataIndex: 'auditStatus', width: 100,
|
||||||
render: (s, row) => {
|
render: (s, row) => {
|
||||||
const status = s || 'APPROVED';
|
const status = s || 'APPROVED';
|
||||||
@@ -733,7 +786,7 @@ export default function StoresPage() {
|
|||||||
<Space direction="vertical" size={0} style={{ maxWidth: '100%' }}>
|
<Space direction="vertical" size={0} style={{ maxWidth: '100%' }}>
|
||||||
<Tag color={color}>{STORE_AUDIT_STATUS_LABELS[status] || status}</Tag>
|
<Tag color={color}>{STORE_AUDIT_STATUS_LABELS[status] || status}</Tag>
|
||||||
{status === 'REJECTED' && row.rejectReason ? (
|
{status === 'REJECTED' && row.rejectReason ? (
|
||||||
<Typography.Text type="secondary" style={{ fontSize: 12, maxWidth: 88 }} ellipsis={{ tooltip: row.rejectReason }}>
|
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
|
||||||
{row.rejectReason}
|
{row.rejectReason}
|
||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
) : null}
|
) : null}
|
||||||
@@ -742,32 +795,29 @@ export default function StoresPage() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
key: 'partner',
|
||||||
title: '开城合伙人',
|
title: '开城合伙人',
|
||||||
dataIndex: 'partner',
|
dataIndex: 'partner',
|
||||||
width: 140,
|
width: 140,
|
||||||
ellipsis: { showTitle: false },
|
|
||||||
render: (partner: StoreRow['partner']) => {
|
render: (partner: StoreRow['partner']) => {
|
||||||
if (!partner) return '—';
|
if (!partner) return '—';
|
||||||
const label = partnerOptionLabel({ id: partner.id ?? '', ...partner });
|
return partnerOptionLabel({ id: partner.id ?? '', ...partner });
|
||||||
return (
|
|
||||||
<Typography.Text ellipsis={{ tooltip: label }} style={{ maxWidth: 124 }}>
|
|
||||||
{label}
|
|
||||||
</Typography.Text>
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
key: 'visibilityWhitelistEnabled',
|
||||||
title: '可见',
|
title: '可见',
|
||||||
dataIndex: 'visibilityWhitelistEnabled',
|
dataIndex: 'visibilityWhitelistEnabled',
|
||||||
width: 90,
|
width: 90,
|
||||||
render: (v) =>
|
render: (v) =>
|
||||||
v ? <Tag color="orange">限测</Tag> : <Tag>公开</Tag>,
|
v ? <Tag color="orange">限测</Tag> : <Tag>公开</Tag>,
|
||||||
},
|
},
|
||||||
{ title: '介绍', dataIndex: 'intro', width: 160, ellipsis: true, render: (v) => v || '—' },
|
{ key: 'intro', title: '介绍', dataIndex: 'intro', width: 160, render: (v) => v || '—' },
|
||||||
{ title: '排序', dataIndex: 'sortOrder', width: 70 },
|
{ key: 'sortOrder', title: '排序', dataIndex: 'sortOrder', width: 70 },
|
||||||
{ title: '店长', dataIndex: ['account', 'name'], width: 90, ellipsis: true, render: (v) => v || '—' },
|
{ key: 'accountName', title: '店长', dataIndex: ['account', 'name'], width: 90, render: (v) => v || '—' },
|
||||||
{ title: '创建', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
{ key: 'createdAt', title: '创建', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
||||||
{
|
{
|
||||||
|
key: 'actions',
|
||||||
title: '操作',
|
title: '操作',
|
||||||
width: 280,
|
width: 280,
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
@@ -776,22 +826,13 @@ export default function StoresPage() {
|
|||||||
<Button type="link" size="small" onClick={() => void openStoreDetail(row)}>详情</Button>
|
<Button type="link" size="small" onClick={() => void openStoreDetail(row)}>详情</Button>
|
||||||
<Button type="link" size="small" onClick={() => navigate(`/store-ratings?storeId=${row.id}`)}>评价</Button>
|
<Button type="link" size="small" onClick={() => navigate(`/store-ratings?storeId=${row.id}`)}>评价</Button>
|
||||||
{row.pendingPackageAuditId ? (
|
{row.pendingPackageAuditId ? (
|
||||||
<>
|
|
||||||
<Button
|
<Button
|
||||||
type="link"
|
type="link"
|
||||||
size="small"
|
size="small"
|
||||||
onClick={() => navigate(`/store-package-audits?requestId=${row.pendingPackageAuditId}`)}
|
onClick={() => void openStoreDetail(row, { tab: 'packages' })}
|
||||||
>
|
>
|
||||||
审核套餐
|
审核套餐
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
|
||||||
type="link"
|
|
||||||
size="small"
|
|
||||||
onClick={() => navigate(`/store-package-audits?requestId=${row.pendingPackageAuditId}`)}
|
|
||||||
>
|
|
||||||
对比
|
|
||||||
</Button>
|
|
||||||
</>
|
|
||||||
) : null}
|
) : null}
|
||||||
{row.pendingInfoChangeId ? (
|
{row.pendingInfoChangeId ? (
|
||||||
<>
|
<>
|
||||||
@@ -823,15 +864,24 @@ export default function StoresPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('stores', baseColumns, {
|
||||||
|
page,
|
||||||
|
pageSize,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
||||||
<Space direction="vertical" size={0}>
|
<Space direction="vertical" size={0}>
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>门店</Typography.Title>
|
<Typography.Title level={4} style={{ margin: 0 }}>门店</Typography.Title>
|
||||||
<Typography.Text type="secondary">共 {data?.total ?? 0} 家门店(含合伙人录入)</Typography.Text>
|
<Typography.Text type="secondary">共 {data?.total ?? 0} 家门店(含合伙人录入)</Typography.Text>
|
||||||
</Space>
|
</Space>
|
||||||
|
<Space>
|
||||||
|
{settingsButton}
|
||||||
<Button type="primary" onClick={openCreateModal}>新建门店</Button>
|
<Button type="primary" onClick={openCreateModal}>新建门店</Button>
|
||||||
</Space>
|
</Space>
|
||||||
|
</Space>
|
||||||
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
|
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
|
||||||
<Form.Item name="name" label="名称"><Input allowClear /></Form.Item>
|
<Form.Item name="name" label="名称"><Input allowClear /></Form.Item>
|
||||||
<Form.Item name="phone" label="电话"><Input allowClear /></Form.Item>
|
<Form.Item name="phone" label="电话"><Input allowClear /></Form.Item>
|
||||||
@@ -891,7 +941,7 @@ export default function StoresPage() {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data?.items ?? []}
|
dataSource={data?.items ?? []}
|
||||||
scroll={{ x: 1720 }}
|
scroll={{ x: 'max-content' }}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: page,
|
current: page,
|
||||||
pageSize,
|
pageSize,
|
||||||
@@ -903,7 +953,7 @@ export default function StoresPage() {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Drawer title="门店详情" width={760} open={drawerOpen} onClose={() => setDrawerOpen(false)}
|
<Drawer title="门店详情" width={880} open={drawerOpen} onClose={() => setDrawerOpen(false)}
|
||||||
extra={detail && (
|
extra={detail && (
|
||||||
<Space wrap>
|
<Space wrap>
|
||||||
{String(detail.auditStatus || '') === 'PENDING' || String(detail.auditStatus || '') === 'REJECTED' ? (
|
{String(detail.auditStatus || '') === 'PENDING' || String(detail.auditStatus || '') === 'REJECTED' ? (
|
||||||
@@ -940,6 +990,41 @@ export default function StoresPage() {
|
|||||||
</Button>
|
</Button>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
|
{detail.pendingPackageAuditId ? (
|
||||||
|
<>
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
ghost
|
||||||
|
loading={packageAuditing}
|
||||||
|
onClick={async () => {
|
||||||
|
setPackageAuditing(true);
|
||||||
|
try {
|
||||||
|
await auditStorePackageRequest(String(detail.pendingPackageAuditId), 'APPROVE');
|
||||||
|
message.success('套餐已通过');
|
||||||
|
setDetail({ ...detail, pendingPackageAuditId: null });
|
||||||
|
void reload();
|
||||||
|
} catch (e) {
|
||||||
|
message.error(e instanceof Error ? e.message : '套餐审核失败');
|
||||||
|
} finally {
|
||||||
|
setPackageAuditing(false);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
通过套餐
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
danger
|
||||||
|
ghost
|
||||||
|
loading={packageAuditing}
|
||||||
|
onClick={() => {
|
||||||
|
setPackageRejectReason('');
|
||||||
|
setPackageRejectOpen(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
驳回套餐
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
<Select value={String(detail.status)} style={{ width: 120 }}
|
<Select value={String(detail.status)} style={{ width: 120 }}
|
||||||
options={Object.entries(STORE_STATUS_LABELS).map(([value, label]) => ({ value, label }))}
|
options={Object.entries(STORE_STATUS_LABELS).map(([value, label]) => ({ value, label }))}
|
||||||
onChange={async (status) => {
|
onChange={async (status) => {
|
||||||
@@ -954,6 +1039,8 @@ export default function StoresPage() {
|
|||||||
{detail && (
|
{detail && (
|
||||||
<Form form={editForm} layout="vertical">
|
<Form form={editForm} layout="vertical">
|
||||||
<Tabs
|
<Tabs
|
||||||
|
activeKey={detailTab}
|
||||||
|
onChange={setDetailTab}
|
||||||
destroyInactiveTabPane={false}
|
destroyInactiveTabPane={false}
|
||||||
items={[
|
items={[
|
||||||
{
|
{
|
||||||
@@ -1202,15 +1289,76 @@ export default function StoresPage() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'packages',
|
key: 'packages',
|
||||||
label: '套餐',
|
label: detail.pendingPackageAuditId ? (
|
||||||
|
<Badge dot offset={[4, 0]}>
|
||||||
|
套餐
|
||||||
|
</Badge>
|
||||||
|
) : (
|
||||||
|
'套餐'
|
||||||
|
),
|
||||||
forceRender: true,
|
forceRender: true,
|
||||||
children: <AdminStorePackagesSection ref={packagesRef} storeId={String(detail.id)} />,
|
children: (
|
||||||
|
<>
|
||||||
|
{detail.pendingPackageAuditId ? (
|
||||||
|
<div style={{ marginBottom: 24 }}>
|
||||||
|
<Typography.Title level={5} style={{ marginTop: 0 }}>
|
||||||
|
待审核套餐变更
|
||||||
|
</Typography.Title>
|
||||||
|
<StorePackageAuditPanel
|
||||||
|
requestId={String(detail.pendingPackageAuditId)}
|
||||||
|
showActions
|
||||||
|
onAudited={() => {
|
||||||
|
setDetail({ ...detail, pendingPackageAuditId: null });
|
||||||
|
void reload();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
<AdminStorePackagesSection ref={packagesRef} storeId={String(detail.id)} />
|
||||||
|
</>
|
||||||
|
),
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Form>
|
</Form>
|
||||||
)}
|
)}
|
||||||
</Drawer>
|
</Drawer>
|
||||||
|
<Modal
|
||||||
|
title="驳回套餐变更"
|
||||||
|
open={packageRejectOpen}
|
||||||
|
confirmLoading={packageAuditing}
|
||||||
|
onCancel={() => setPackageRejectOpen(false)}
|
||||||
|
onOk={async () => {
|
||||||
|
if (!detail?.pendingPackageAuditId) return;
|
||||||
|
if (!packageRejectReason.trim()) {
|
||||||
|
message.warning('请填写驳回原因');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setPackageAuditing(true);
|
||||||
|
try {
|
||||||
|
await auditStorePackageRequest(
|
||||||
|
String(detail.pendingPackageAuditId),
|
||||||
|
'REJECT',
|
||||||
|
packageRejectReason.trim(),
|
||||||
|
);
|
||||||
|
message.success('套餐已驳回');
|
||||||
|
setPackageRejectOpen(false);
|
||||||
|
setDetail({ ...detail, pendingPackageAuditId: null });
|
||||||
|
void reload();
|
||||||
|
} catch (e) {
|
||||||
|
message.error(e instanceof Error ? e.message : '套餐驳回失败');
|
||||||
|
} finally {
|
||||||
|
setPackageAuditing(false);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Input.TextArea
|
||||||
|
rows={3}
|
||||||
|
value={packageRejectReason}
|
||||||
|
placeholder="驳回原因"
|
||||||
|
onChange={(e) => setPackageRejectReason(e.target.value)}
|
||||||
|
/>
|
||||||
|
</Modal>
|
||||||
<Modal
|
<Modal
|
||||||
title="新建门店"
|
title="新建门店"
|
||||||
open={createOpen}
|
open={createOpen}
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ import { request, type HqProfile } from '../lib/api';
|
|||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
import OssUpload from '../components/OssUpload';
|
import OssUpload from '../components/OssUpload';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
const DISPATCH_WECOM_STORAGE_KEY = 'support_ticket_dispatch_wecom';
|
const DISPATCH_WECOM_STORAGE_KEY = 'support_ticket_dispatch_wecom';
|
||||||
const DEFAULT_DISPATCH_SUPPLEMENT = '请按以下任务进入开发流程';
|
const DEFAULT_DISPATCH_SUPPLEMENT = '请按以下任务进入开发流程';
|
||||||
@@ -218,8 +220,13 @@ export default function SupportTicketsPage() {
|
|||||||
|
|
||||||
setReviewOpen(false);
|
setReviewOpen(false);
|
||||||
const summary = [detail!.title, detail!.content].filter(Boolean).join('\n').slice(0, 500);
|
const summary = [detail!.title, detail!.content].filter(Boolean).join('\n').slice(0, 500);
|
||||||
|
const ticketUrls = (detail!.attachmentUrls ?? []).filter(Boolean);
|
||||||
tasksForm.setFieldsValue({
|
tasksForm.setFieldsValue({
|
||||||
tasks: [{ content: summary || detail!.title, type: mapSupportTicketTypeToDevPlanTask(detail!.ticketType) }],
|
tasks: [{
|
||||||
|
content: summary || detail!.title,
|
||||||
|
type: mapSupportTicketTypeToDevPlanTask(detail!.ticketType),
|
||||||
|
attachmentUrls: ticketUrls,
|
||||||
|
}],
|
||||||
dispatchToWecom: localStorage.getItem(DISPATCH_WECOM_STORAGE_KEY) !== 'false',
|
dispatchToWecom: localStorage.getItem(DISPATCH_WECOM_STORAGE_KEY) !== 'false',
|
||||||
dispatchSupplement: DEFAULT_DISPATCH_SUPPLEMENT,
|
dispatchSupplement: DEFAULT_DISPATCH_SUPPLEMENT,
|
||||||
});
|
});
|
||||||
@@ -364,7 +371,11 @@ export default function SupportTicketsPage() {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
decision: 'APPROVE',
|
decision: 'APPROVE',
|
||||||
note: note?.trim() || undefined,
|
note: note?.trim() || undefined,
|
||||||
tasks: values.tasks.map((t) => ({ content: t.content.trim(), type: t.type })),
|
tasks: values.tasks.map((t) => ({
|
||||||
|
content: t.content.trim(),
|
||||||
|
type: t.type,
|
||||||
|
attachmentUrls: t.attachmentUrls?.length ? t.attachmentUrls : detail!.attachmentUrls,
|
||||||
|
})),
|
||||||
dispatchToWecom: !!values.dispatchToWecom,
|
dispatchToWecom: !!values.dispatchToWecom,
|
||||||
dispatchSupplement: values.dispatchSupplement?.trim() || undefined,
|
dispatchSupplement: values.dispatchSupplement?.trim() || undefined,
|
||||||
}),
|
}),
|
||||||
@@ -461,7 +472,7 @@ export default function SupportTicketsPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<TicketRow> = [
|
const baseColumns: ColumnsType<TicketRow> = [
|
||||||
{ title: '工单号', dataIndex: 'ticketNo', width: 180 },
|
{ title: '工单号', dataIndex: 'ticketNo', width: 180 },
|
||||||
{
|
{
|
||||||
title: '类型',
|
title: '类型',
|
||||||
@@ -494,7 +505,7 @@ export default function SupportTicketsPage() {
|
|||||||
</Space>
|
</Space>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{ title: '标题', dataIndex: 'title', ellipsis: true },
|
{ title: '标题', dataIndex: 'title' },
|
||||||
{ title: '创建人', dataIndex: 'creatorName', width: 100 },
|
{ title: '创建人', dataIndex: 'creatorName', width: 100 },
|
||||||
{ title: '时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
{ title: '时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
||||||
{
|
{
|
||||||
@@ -537,8 +548,11 @@ export default function SupportTicketsPage() {
|
|||||||
return null;
|
return null;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('support-tickets', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@@ -550,6 +564,7 @@ export default function SupportTicketsPage() {
|
|||||||
<Typography.Title level={4} style={{ margin: 0 }}>
|
<Typography.Title level={4} style={{ margin: 0 }}>
|
||||||
技术支持
|
技术支持
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Space>
|
<Space>
|
||||||
{isSuperAdmin ? (
|
{isSuperAdmin ? (
|
||||||
<>
|
<>
|
||||||
@@ -610,7 +625,7 @@ export default function SupportTicketsPage() {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data?.items ?? []}
|
dataSource={data?.items ?? []}
|
||||||
scroll={{ x: 900 }}
|
scroll={{ x: 'max-content' }}
|
||||||
rowSelection={
|
rowSelection={
|
||||||
isSuperAdmin
|
isSuperAdmin
|
||||||
? {
|
? {
|
||||||
|
|||||||
@@ -249,15 +249,53 @@ export default function SystemSettingsPage() {
|
|||||||
|
|
||||||
const collapseItems = useMemo(() => {
|
const collapseItems = useMemo(() => {
|
||||||
if (!meta) return [];
|
if (!meta) return [];
|
||||||
return meta.groups.map((group) => ({
|
const SHARE_SUBGROUP_LABELS: Record<string, string> = {
|
||||||
key: group.key,
|
global: '全局',
|
||||||
label: group.label,
|
home: '首页',
|
||||||
|
stores: '门店列表',
|
||||||
|
storeDetail: '门店详情',
|
||||||
|
benefit: '权益页',
|
||||||
|
mine: '我的',
|
||||||
|
productDetail: '商品详情',
|
||||||
|
orderDetail: '订单详情',
|
||||||
|
};
|
||||||
|
const SHARE_SUBGROUP_ORDER = [
|
||||||
|
'global',
|
||||||
|
'home',
|
||||||
|
'stores',
|
||||||
|
'storeDetail',
|
||||||
|
'benefit',
|
||||||
|
'mine',
|
||||||
|
'productDetail',
|
||||||
|
'orderDetail',
|
||||||
|
];
|
||||||
|
|
||||||
|
return meta.groups.map((group) => {
|
||||||
|
const fields = meta.fields.filter((f) => f.group === group.key);
|
||||||
|
const hasSubgroups = fields.some((f) => f.subgroup);
|
||||||
|
|
||||||
|
let children: ReactNode;
|
||||||
|
if (group.key === 'wechat_mini_share' && hasSubgroups) {
|
||||||
|
const bySub = new Map<string, SystemConfigFieldMeta[]>();
|
||||||
|
for (const f of fields) {
|
||||||
|
const sk = f.subgroup || 'global';
|
||||||
|
if (!bySub.has(sk)) bySub.set(sk, []);
|
||||||
|
bySub.get(sk)!.push(f);
|
||||||
|
}
|
||||||
|
const orderedKeys = [
|
||||||
|
...SHARE_SUBGROUP_ORDER.filter((k) => bySub.has(k)),
|
||||||
|
...[...bySub.keys()].filter((k) => !SHARE_SUBGROUP_ORDER.includes(k)),
|
||||||
|
];
|
||||||
|
children = (
|
||||||
|
<Collapse
|
||||||
|
defaultActiveKey={[]}
|
||||||
|
items={orderedKeys.map((sk) => ({
|
||||||
|
key: sk,
|
||||||
|
label: SHARE_SUBGROUP_LABELS[sk] || sk,
|
||||||
forceRender: true,
|
forceRender: true,
|
||||||
children: (
|
children: (
|
||||||
<div style={{ maxWidth: 720 }}>
|
<div style={{ maxWidth: 720 }}>
|
||||||
{meta.fields
|
{(bySub.get(sk) ?? []).map((f) =>
|
||||||
.filter((f) => f.group === group.key)
|
|
||||||
.map((f) =>
|
|
||||||
renderField(
|
renderField(
|
||||||
f,
|
f,
|
||||||
meta.configuredSecrets,
|
meta.configuredSecrets,
|
||||||
@@ -268,7 +306,32 @@ export default function SystemSettingsPage() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
}));
|
}))}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
children = (
|
||||||
|
<div style={{ maxWidth: 720 }}>
|
||||||
|
{fields.map((f) =>
|
||||||
|
renderField(
|
||||||
|
f,
|
||||||
|
meta.configuredSecrets,
|
||||||
|
f.key === 'MOCK_SMS' && mockSmsEnabled ? (
|
||||||
|
<MockSmsCodePanel codes={meta.mockSmsCodes ?? []} loading={loading} />
|
||||||
|
) : undefined,
|
||||||
|
),
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
key: group.key,
|
||||||
|
label: group.label,
|
||||||
|
forceRender: true,
|
||||||
|
children,
|
||||||
|
};
|
||||||
|
});
|
||||||
}, [meta, mockSmsEnabled, loading]);
|
}, [meta, mockSmsEnabled, loading]);
|
||||||
|
|
||||||
async function onSave() {
|
async function onSave() {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import {
|
|||||||
import type { ColumnsType } from 'antd/es/table';
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
import { request, type Paginated } from '../lib/api';
|
import { request, type Paginated } from '../lib/api';
|
||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
const MOCK_KEYS = ['MOCK_SMS', 'MOCK_WECHAT', 'MOCK_PAY'] as const;
|
const MOCK_KEYS = ['MOCK_SMS', 'MOCK_WECHAT', 'MOCK_PAY'] as const;
|
||||||
|
|
||||||
@@ -257,7 +258,6 @@ export default function TestWhitelistPage() {
|
|||||||
{
|
{
|
||||||
title: '备注',
|
title: '备注',
|
||||||
dataIndex: 'note',
|
dataIndex: 'note',
|
||||||
ellipsis: true,
|
|
||||||
render: (v) => v || '—',
|
render: (v) => v || '—',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -334,7 +334,7 @@ export default function TestWhitelistPage() {
|
|||||||
if (accountType === 'partner') {
|
if (accountType === 'partner') {
|
||||||
return [
|
return [
|
||||||
{ title: '姓名', dataIndex: 'name', width: 100 },
|
{ title: '姓名', dataIndex: 'name', width: 100 },
|
||||||
{ title: '公司', dataIndex: 'companyName', ellipsis: true, render: (v) => (v as string) || '—' },
|
{ title: '公司', dataIndex: 'companyName', render: (v) => (v as string) || '—' },
|
||||||
{ title: '手机', dataIndex: 'phone', width: 120 },
|
{ title: '手机', dataIndex: 'phone', width: 120 },
|
||||||
{
|
{
|
||||||
title: '标记',
|
title: '标记',
|
||||||
@@ -347,7 +347,7 @@ export default function TestWhitelistPage() {
|
|||||||
}
|
}
|
||||||
if (accountType === 'store') {
|
if (accountType === 'store') {
|
||||||
return [
|
return [
|
||||||
{ title: '门店名', dataIndex: 'name', width: 160, ellipsis: true },
|
{ title: '门店名', dataIndex: 'name', width: 160 },
|
||||||
{ title: '城市', dataIndex: 'cityName', width: 90 },
|
{ title: '城市', dataIndex: 'cityName', width: 90 },
|
||||||
{ title: '电话', dataIndex: 'phone', width: 120 },
|
{ title: '电话', dataIndex: 'phone', width: 120 },
|
||||||
{ title: '状态', dataIndex: 'status', width: 90 },
|
{ title: '状态', dataIndex: 'status', width: 90 },
|
||||||
@@ -386,11 +386,18 @@ export default function TestWhitelistPage() {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('test-whitelist', phoneColumns, {
|
||||||
|
page: phonePage,
|
||||||
|
pageSize: phonePageSize,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Typography.Title level={4} style={{ marginTop: 0 }}>
|
<Typography.Title level={4} style={{ marginTop: 0 }}>
|
||||||
白名单管理
|
白名单管理
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
|
|
||||||
<Card size="small" loading={mockLoading} style={{ marginBottom: 16 }}>
|
<Card size="small" loading={mockLoading} style={{ marginBottom: 16 }}>
|
||||||
<Typography.Text type="secondary" style={{ display: 'block', marginBottom: 12 }}>
|
<Typography.Text type="secondary" style={{ display: 'block', marginBottom: 12 }}>
|
||||||
@@ -472,7 +479,7 @@ export default function TestWhitelistPage() {
|
|||||||
<Table
|
<Table
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
loading={phonesLoading}
|
loading={phonesLoading}
|
||||||
columns={phoneColumns}
|
columns={columns}
|
||||||
dataSource={phones?.items ?? []}
|
dataSource={phones?.items ?? []}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: phonePage,
|
current: phonePage,
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import type { ColumnsType } from 'antd/es/table';
|
|||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -69,7 +71,7 @@ export default function ThirdPartyLogsPage() {
|
|||||||
const [detail, setDetail] = useState<Record<string, unknown> | null>(null);
|
const [detail, setDetail] = useState<Record<string, unknown> | null>(null);
|
||||||
const [drawerOpen, setDrawerOpen] = useState(false);
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{ title: '时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
{ title: '时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
||||||
{ title: 'Provider', dataIndex: 'provider', width: 120 },
|
{ title: 'Provider', dataIndex: 'provider', width: 120 },
|
||||||
{ title: '场景', dataIndex: 'scene', width: 120 },
|
{ title: '场景', dataIndex: 'scene', width: 120 },
|
||||||
@@ -87,12 +89,10 @@ export default function ThirdPartyLogsPage() {
|
|||||||
{
|
{
|
||||||
title: '错误信息',
|
title: '错误信息',
|
||||||
dataIndex: 'errorMessage',
|
dataIndex: 'errorMessage',
|
||||||
ellipsis: true,
|
|
||||||
render: (v: string | null | undefined) => v || '—',
|
render: (v: string | null | undefined) => v || '—',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '请求摘要',
|
title: '请求摘要',
|
||||||
ellipsis: true,
|
|
||||||
render: (_, r) => summarizeJson(r.requestBody),
|
render: (_, r) => summarizeJson(r.requestBody),
|
||||||
},
|
},
|
||||||
{ title: '外部单号', dataIndex: 'externalNo', width: 140, render: (v) => v || '—' },
|
{ title: '外部单号', dataIndex: 'externalNo', width: 140, render: (v) => v || '—' },
|
||||||
@@ -114,9 +114,16 @@ export default function ThirdPartyLogsPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('logs-third-party', baseColumns, {
|
||||||
|
page,
|
||||||
|
pageSize,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Typography.Title level={4}>第三方日志</Typography.Title>
|
<Typography.Title level={4}>第三方日志</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Form
|
<Form
|
||||||
layout="inline"
|
layout="inline"
|
||||||
style={{ marginBottom: 16 }}
|
style={{ marginBottom: 16 }}
|
||||||
@@ -143,7 +150,7 @@ export default function ThirdPartyLogsPage() {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data?.items ?? []}
|
dataSource={data?.items ?? []}
|
||||||
scroll={{ x: 1200 }}
|
scroll={{ x: 'max-content' }}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: page,
|
current: page,
|
||||||
pageSize,
|
pageSize,
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import {
|
|||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -115,7 +117,7 @@ export default function TicketsPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{ title: '工单号', dataIndex: 'ticketNo', width: 180 },
|
{ title: '工单号', dataIndex: 'ticketNo', width: 180 },
|
||||||
{
|
{
|
||||||
title: '类型',
|
title: '类型',
|
||||||
@@ -132,7 +134,7 @@ export default function TicketsPage() {
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
{ title: '关联', width: 140, render: (_, r) => `${r.refType}#${r.refId}` },
|
{ title: '关联', width: 140, render: (_, r) => `${r.refType}#${r.refId}` },
|
||||||
{ title: '备注', dataIndex: 'remark', ellipsis: true },
|
{ title: '备注', dataIndex: 'remark' },
|
||||||
{ title: '时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
{ title: '时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
@@ -154,8 +156,11 @@ export default function TicketsPage() {
|
|||||||
|
|
||||||
const evidenceUrls = detail?.extraJson?.evidenceUrls ?? [];
|
const evidenceUrls = detail?.extraJson?.evidenceUrls ?? [];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('tickets', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@@ -167,6 +172,7 @@ export default function TicketsPage() {
|
|||||||
<Typography.Title level={4} style={{ margin: 0 }}>
|
<Typography.Title level={4} style={{ margin: 0 }}>
|
||||||
工单中心
|
工单中心
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Button type="primary" onClick={() => setCreateOpen(true)}>
|
<Button type="primary" onClick={() => setCreateOpen(true)}>
|
||||||
创建工单
|
创建工单
|
||||||
</Button>
|
</Button>
|
||||||
@@ -205,7 +211,7 @@ export default function TicketsPage() {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data?.items ?? []}
|
dataSource={data?.items ?? []}
|
||||||
scroll={{ x: 900 }}
|
scroll={{ x: 'max-content' }}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: page,
|
current: page,
|
||||||
pageSize,
|
pageSize,
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import { request } from '../lib/api';
|
|||||||
import { AdminCellLine } from '../components/AdminCellLine';
|
import { AdminCellLine } from '../components/AdminCellLine';
|
||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -61,10 +63,10 @@ export default function UserLogsPage() {
|
|||||||
form.setFieldsValue(filters);
|
form.setFieldsValue(filters);
|
||||||
}, [form, filters]);
|
}, [form, filters]);
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{ title: '时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
{ title: '时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
||||||
{
|
{
|
||||||
title: '用户', width: 180, ellipsis: true,
|
title: '用户', width: 180,
|
||||||
render: (_, r) => (
|
render: (_, r) => (
|
||||||
<AdminCellLine
|
<AdminCellLine
|
||||||
primary={r.nickname || r.userNo}
|
primary={r.nickname || r.userNo}
|
||||||
@@ -84,7 +86,7 @@ export default function UserLogsPage() {
|
|||||||
render: (_, r) => (r.refType && r.refId ? `${r.refType}#${r.refId}` : '—'),
|
render: (_, r) => (r.refType && r.refId ? `${r.refType}#${r.refId}` : '—'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '摘要', ellipsis: true,
|
title: '摘要',
|
||||||
render: (_, r) => summarizeExtra(r.extraJson),
|
render: (_, r) => summarizeExtra(r.extraJson),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -98,9 +100,13 @@ export default function UserLogsPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('logs-users', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Typography.Title level={4}>用户日志</Typography.Title>
|
<Typography.Title level={4}>用户日志</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Segmented
|
<Segmented
|
||||||
style={{ marginBottom: 16 }}
|
style={{ marginBottom: 16 }}
|
||||||
options={USER_LOG_CATEGORY_OPTIONS.map((o) => ({ value: o.value, label: o.label }))}
|
options={USER_LOG_CATEGORY_OPTIONS.map((o) => ({ value: o.value, label: o.label }))}
|
||||||
@@ -131,7 +137,7 @@ export default function UserLogsPage() {
|
|||||||
<Form.Item><Button type="primary" htmlType="submit">筛选</Button></Form.Item>
|
<Form.Item><Button type="primary" htmlType="submit">筛选</Button></Form.Item>
|
||||||
<Form.Item><Button onClick={() => { form.resetFields(); setFilters({}); setCategory(''); setSearchParams({}); setPage(1); }}>重置</Button></Form.Item>
|
<Form.Item><Button onClick={() => { form.resetFields(); setFilters({}); setCategory(''); setSearchParams({}); setPage(1); }}>重置</Button></Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
<Table rowKey="id" loading={loading} columns={columns} dataSource={data?.items ?? []} scroll={{ x: 1000 }}
|
<Table rowKey="id" loading={loading} columns={columns} dataSource={data?.items ?? []} scroll={{ x: 'max-content' }}
|
||||||
pagination={{ current: page, pageSize, total: data?.total ?? 0, showSizeChanger: true, onChange: (p, ps) => { setPage(p); setPageSize(ps); } }} />
|
pagination={{ current: page, pageSize, total: data?.total ?? 0, showSizeChanger: true, onChange: (p, ps) => { setPage(p); setPageSize(ps); } }} />
|
||||||
<Drawer title="日志详情" width={520} open={drawerOpen} onClose={() => setDrawerOpen(false)}>
|
<Drawer title="日志详情" width={520} open={drawerOpen} onClose={() => setDrawerOpen(false)}>
|
||||||
{detail && (
|
{detail && (
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useCallback, useEffect, useState } from 'react';
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import { Link, useLocation, useNavigate } from 'react-router-dom';
|
import { Link, useLocation, useNavigate } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
Alert,
|
Alert,
|
||||||
@@ -19,6 +19,7 @@ import {
|
|||||||
import type { ColumnsType } from 'antd/es/table';
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
import { USER_SOURCE_TYPE_LABELS, resolveUserLogCategory, type UserSourceType } from '@dukang/shared-types';
|
import { USER_SOURCE_TYPE_LABELS, resolveUserLogCategory, type UserSourceType } from '@dukang/shared-types';
|
||||||
import { request, type AdminUserRow, type HqProfile, type Paginated } from '../lib/api';
|
import { request, type AdminUserRow, type HqProfile, type Paginated } from '../lib/api';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
import { ORDER_STATUS_LABELS, fmtTime, maskPhone } from '../lib/constants';
|
import { ORDER_STATUS_LABELS, fmtTime, maskPhone } from '../lib/constants';
|
||||||
|
|
||||||
type UserOrderRow = {
|
type UserOrderRow = {
|
||||||
@@ -30,6 +31,77 @@ type UserOrderRow = {
|
|||||||
createdAt: string;
|
createdAt: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function HqRemarkCell({
|
||||||
|
id,
|
||||||
|
hqRemark,
|
||||||
|
onSaved,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
hqRemark: string | null;
|
||||||
|
onSaved: (id: string, hqRemark: string | null) => void;
|
||||||
|
}) {
|
||||||
|
const [editing, setEditing] = useState(false);
|
||||||
|
const [value, setValue] = useState(hqRemark ?? '');
|
||||||
|
const savingRef = useRef(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!editing) setValue(hqRemark ?? '');
|
||||||
|
}, [hqRemark, editing]);
|
||||||
|
|
||||||
|
async function commit() {
|
||||||
|
if (savingRef.current) return;
|
||||||
|
const next = value.trim() || null;
|
||||||
|
const prev = hqRemark?.trim() || null;
|
||||||
|
setEditing(false);
|
||||||
|
if (next === prev) return;
|
||||||
|
savingRef.current = true;
|
||||||
|
try {
|
||||||
|
const res = await request<{ id: string; hqRemark: string | null }>(`/admin/users/${id}`, {
|
||||||
|
method: 'PUT',
|
||||||
|
body: JSON.stringify({ hqRemark: next ?? '' }),
|
||||||
|
});
|
||||||
|
onSaved(id, res.hqRemark);
|
||||||
|
message.success('备注已保存');
|
||||||
|
} catch (e) {
|
||||||
|
message.error(e instanceof Error ? e.message : '保存失败');
|
||||||
|
setValue(hqRemark ?? '');
|
||||||
|
} finally {
|
||||||
|
savingRef.current = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (editing) {
|
||||||
|
return (
|
||||||
|
<Input
|
||||||
|
size="small"
|
||||||
|
autoFocus
|
||||||
|
maxLength={128}
|
||||||
|
value={value}
|
||||||
|
onChange={(e) => setValue(e.target.value)}
|
||||||
|
onBlur={() => void commit()}
|
||||||
|
onPressEnter={() => void commit()}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === 'Escape') void commit();
|
||||||
|
}}
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
title="双击修改备注,离开后保存"
|
||||||
|
onDoubleClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
setEditing(true);
|
||||||
|
}}
|
||||||
|
style={{ cursor: 'text', display: 'inline-block', minWidth: 48 }}
|
||||||
|
>
|
||||||
|
{hqRemark || '—'}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/** 好客权益金额展示:0 与空值统一显示占位,避免整列都是 ¥0.00 干扰 */
|
/** 好客权益金额展示:0 与空值统一显示占位,避免整列都是 ¥0.00 干扰 */
|
||||||
function fmtBenefit(v: number | null | undefined) {
|
function fmtBenefit(v: number | null | undefined) {
|
||||||
const n = Number(v ?? 0);
|
const n = Number(v ?? 0);
|
||||||
@@ -244,7 +316,7 @@ export default function UsersPage() {
|
|||||||
{ title: '下单时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
{ title: '下单时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
||||||
];
|
];
|
||||||
|
|
||||||
const columns: ColumnsType<AdminUserRow> = [
|
const baseColumns: ColumnsType<AdminUserRow> = [
|
||||||
{
|
{
|
||||||
title: '用户编号',
|
title: '用户编号',
|
||||||
dataIndex: 'userNo',
|
dataIndex: 'userNo',
|
||||||
@@ -256,12 +328,36 @@ export default function UsersPage() {
|
|||||||
</Space>
|
</Space>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{ title: '昵称', dataIndex: 'nickname', width: 100 },
|
{
|
||||||
|
title: '昵称',
|
||||||
|
dataIndex: 'nickname',
|
||||||
|
width: 140,
|
||||||
|
render: (v: string | null) => v || '—',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '备注',
|
||||||
|
dataIndex: 'hqRemark',
|
||||||
|
width: 160,
|
||||||
|
render: (v: string | null, row) => (
|
||||||
|
<HqRemarkCell
|
||||||
|
id={row.id}
|
||||||
|
hqRemark={v}
|
||||||
|
onSaved={(id, hqRemark) => {
|
||||||
|
setData((prev) =>
|
||||||
|
prev
|
||||||
|
? { ...prev, items: prev.items.map((u) => (u.id === id ? { ...u, hqRemark } : u)) }
|
||||||
|
: prev,
|
||||||
|
);
|
||||||
|
setDetail((d) => (d && d.id === id ? { ...d, hqRemark } : d));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '手机',
|
title: '手机',
|
||||||
dataIndex: 'phone',
|
dataIndex: 'phone',
|
||||||
width: 120,
|
width: 120,
|
||||||
render: (v) => maskPhone(v),
|
render: (v) => v || '—',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '验手机',
|
title: '验手机',
|
||||||
@@ -289,7 +385,6 @@ export default function UsersPage() {
|
|||||||
title: '来源 ID',
|
title: '来源 ID',
|
||||||
dataIndex: 'sourceRefId',
|
dataIndex: 'sourceRefId',
|
||||||
width: 100,
|
width: 100,
|
||||||
ellipsis: true,
|
|
||||||
render: (v, row) => {
|
render: (v, row) => {
|
||||||
if (!v) return '—';
|
if (!v) return '—';
|
||||||
if (row.sourceType === 'PROMO_CODE') {
|
if (row.sourceType === 'PROMO_CODE') {
|
||||||
@@ -306,13 +401,11 @@ export default function UsersPage() {
|
|||||||
title: '来源标签',
|
title: '来源标签',
|
||||||
dataIndex: 'sourceLabel',
|
dataIndex: 'sourceLabel',
|
||||||
width: 120,
|
width: 120,
|
||||||
ellipsis: true,
|
|
||||||
render: (v) => v || '—',
|
render: (v) => v || '—',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'deviceKey',
|
title: 'deviceKey',
|
||||||
dataIndex: 'deviceKey',
|
dataIndex: 'deviceKey',
|
||||||
ellipsis: true,
|
|
||||||
render: (v) => v || '—',
|
render: (v) => v || '—',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -377,10 +470,18 @@ export default function UsersPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('users', baseColumns, {
|
||||||
|
page,
|
||||||
|
pageSize,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
<Space style={{ marginBottom: 16, width: '100%', justifyContent: 'space-between' }}>
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>用户监控</Typography.Title>
|
<Typography.Title level={4} style={{ margin: 0 }}>用户监控</Typography.Title>
|
||||||
|
<Space>
|
||||||
|
{settingsButton}
|
||||||
{canDeleteUsers ? (
|
{canDeleteUsers ? (
|
||||||
<Button
|
<Button
|
||||||
danger
|
danger
|
||||||
@@ -391,6 +492,7 @@ export default function UsersPage() {
|
|||||||
</Button>
|
</Button>
|
||||||
) : null}
|
) : null}
|
||||||
</Space>
|
</Space>
|
||||||
|
</Space>
|
||||||
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={() => { setPage(1); void load(); }}>
|
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={() => { setPage(1); void load(); }}>
|
||||||
<Form.Item name="phone" label="手机号">
|
<Form.Item name="phone" label="手机号">
|
||||||
<Input placeholder="模糊搜索" allowClear />
|
<Input placeholder="模糊搜索" allowClear />
|
||||||
@@ -429,7 +531,7 @@ export default function UsersPage() {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data?.items ?? []}
|
dataSource={data?.items ?? []}
|
||||||
scroll={{ x: 1830 }}
|
scroll={{ x: 'max-content' }}
|
||||||
rowSelection={canDeleteUsers ? {
|
rowSelection={canDeleteUsers ? {
|
||||||
selectedRowKeys,
|
selectedRowKeys,
|
||||||
preserveSelectedRowKeys: true,
|
preserveSelectedRowKeys: true,
|
||||||
@@ -462,6 +564,7 @@ export default function UsersPage() {
|
|||||||
<Descriptions.Item label="ID">{detail.id}</Descriptions.Item>
|
<Descriptions.Item label="ID">{detail.id}</Descriptions.Item>
|
||||||
<Descriptions.Item label="用户编号">{detail.userNo}</Descriptions.Item>
|
<Descriptions.Item label="用户编号">{detail.userNo}</Descriptions.Item>
|
||||||
<Descriptions.Item label="昵称">{detail.nickname || '—'}</Descriptions.Item>
|
<Descriptions.Item label="昵称">{detail.nickname || '—'}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="备注">{detail.hqRemark || '—'}</Descriptions.Item>
|
||||||
<Descriptions.Item label="手机号">{maskPhone(detail.phone)}</Descriptions.Item>
|
<Descriptions.Item label="手机号">{maskPhone(detail.phone)}</Descriptions.Item>
|
||||||
<Descriptions.Item label="验手机时间">
|
<Descriptions.Item label="验手机时间">
|
||||||
{detail.phoneVerifiedAt ? new Date(detail.phoneVerifiedAt).toLocaleString('zh-CN') : '未验证'}
|
{detail.phoneVerifiedAt ? new Date(detail.phoneVerifiedAt).toLocaleString('zh-CN') : '未验证'}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import { request } from '../lib/api';
|
|||||||
import { AdminCellLine } from '../components/AdminCellLine';
|
import { AdminCellLine } from '../components/AdminCellLine';
|
||||||
import { fmtTime, maskPhone } from '../lib/constants';
|
import { fmtTime, maskPhone } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type ActorType = 'USER' | 'STORE' | 'PARTNER' | 'HQ';
|
type ActorType = 'USER' | 'STORE' | 'PARTNER' | 'HQ';
|
||||||
|
|
||||||
@@ -90,12 +92,11 @@ export default function WechatBindingsPage() {
|
|||||||
setDrawerOpen(true);
|
setDrawerOpen(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<GroupRow> = [
|
const baseColumns: ColumnsType<GroupRow> = [
|
||||||
{
|
{
|
||||||
title: 'unionId',
|
title: 'unionId',
|
||||||
dataIndex: 'unionId',
|
dataIndex: 'unionId',
|
||||||
width: 180,
|
width: 180,
|
||||||
ellipsis: true,
|
|
||||||
|
|
||||||
render: (v) => v || <Tag>无 unionId</Tag>,
|
render: (v) => v || <Tag>无 unionId</Tag>,
|
||||||
},
|
},
|
||||||
@@ -123,7 +124,6 @@ export default function WechatBindingsPage() {
|
|||||||
render: (v) => maskPhone(v),
|
render: (v) => maskPhone(v),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ellipsis: true,
|
|
||||||
title: '身份摘要',
|
title: '身份摘要',
|
||||||
|
|
||||||
render: (_, r) => (
|
render: (_, r) => (
|
||||||
@@ -160,7 +160,6 @@ export default function WechatBindingsPage() {
|
|||||||
width: 120,
|
width: 120,
|
||||||
render: (t: ActorType) => <Tag color={ACTOR_TYPE_COLORS[t]}>{ACTOR_TYPE_LABELS[t]}</Tag>,
|
render: (t: ActorType) => <Tag color={ACTOR_TYPE_COLORS[t]}>{ACTOR_TYPE_LABELS[t]}</Tag>,
|
||||||
},
|
},
|
||||||
ellipsis: true,
|
|
||||||
{
|
{
|
||||||
title: '账号',
|
title: '账号',
|
||||||
|
|
||||||
@@ -172,14 +171,12 @@ export default function WechatBindingsPage() {
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ellipsis: true,
|
|
||||||
title: '归属',
|
title: '归属',
|
||||||
dataIndex: 'refLabel',
|
dataIndex: 'refLabel',
|
||||||
width: 160,
|
width: 160,
|
||||||
|
|
||||||
render: (v, r) => (v ? `${v}${r.refId ? ` #${r.refId}` : ''}` : '—'),
|
render: (v, r) => (v ? `${v}${r.refId ? ` #${r.refId}` : ''}` : '—'),
|
||||||
},
|
},
|
||||||
ellipsis: true,
|
|
||||||
{
|
{
|
||||||
title: 'wxOpenId',
|
title: 'wxOpenId',
|
||||||
dataIndex: 'wxOpenId',
|
dataIndex: 'wxOpenId',
|
||||||
@@ -205,9 +202,13 @@ export default function WechatBindingsPage() {
|
|||||||
{
|
{
|
||||||
title: '状态',
|
title: '状态',
|
||||||
dataIndex: 'status',
|
dataIndex: 'status',
|
||||||
|
width: 90,
|
||||||
|
render: (v) => String(v),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const { columns, settingsButton, settingsModal } = useAdminListColumns('wechat-bindings', baseColumns, { page, pageSize });
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('wechat-bindings', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{settingsModal}
|
{settingsModal}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import { useAdminList } from '../lib/useAdminList';
|
|||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
import type { WecomBotLogDto } from '@dukang/shared-types';
|
import type { WecomBotLogDto } from '@dukang/shared-types';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
export default function WecomBotLogsPage() {
|
export default function WecomBotLogsPage() {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
@@ -24,12 +26,12 @@ export default function WecomBotLogsPage() {
|
|||||||
[filters],
|
[filters],
|
||||||
);
|
);
|
||||||
|
|
||||||
const columns: ColumnsType<WecomBotLogDto> = [
|
const baseColumns: ColumnsType<WecomBotLogDto> = [
|
||||||
{ title: '时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
{ title: '时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
||||||
{ title: '机器人', dataIndex: 'botName', width: 120, ellipsis: true, render: (v, r) => v || r.botKey || '—' },
|
{ title: '机器人', dataIndex: 'botName', width: 120, render: (v, r) => v || r.botKey || '—' },
|
||||||
{ title: '企微用户', dataIndex: 'wecomUserId', width: 120, ellipsis: true },
|
{ title: '企微用户', dataIndex: 'wecomUserId', width: 120 },
|
||||||
{ title: '动作', dataIndex: 'action', width: 160, ellipsis: true },
|
{ title: '动作', dataIndex: 'action', width: 160 },
|
||||||
{ title: '权限', dataIndex: 'permission', width: 140, ellipsis: true, render: (v) => v || '—' },
|
{ title: '权限', dataIndex: 'permission', width: 140, render: (v) => v || '—' },
|
||||||
{
|
{
|
||||||
title: '结果',
|
title: '结果',
|
||||||
dataIndex: 'success',
|
dataIndex: 'success',
|
||||||
@@ -37,7 +39,7 @@ export default function WecomBotLogsPage() {
|
|||||||
render: (v: boolean) => <Tag color={v ? 'green' : 'red'}>{v ? '成功' : '失败'}</Tag>,
|
render: (v: boolean) => <Tag color={v ? 'green' : 'red'}>{v ? '成功' : '失败'}</Tag>,
|
||||||
},
|
},
|
||||||
{ title: '耗时(ms)', dataIndex: 'latencyMs', width: 90, render: (v) => v ?? '—' },
|
{ title: '耗时(ms)', dataIndex: 'latencyMs', width: 90, render: (v) => v ?? '—' },
|
||||||
{ title: '输入摘要', dataIndex: 'inputSummary', ellipsis: true },
|
{ title: '输入摘要', dataIndex: 'inputSummary' },
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
width: 80,
|
width: 80,
|
||||||
@@ -49,9 +51,13 @@ export default function WecomBotLogsPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('logs-wecom-bots', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Typography.Title level={4}>企微机器人日志</Typography.Title>
|
<Typography.Title level={4}>企微机器人日志</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Typography.Paragraph type="secondary">
|
<Typography.Paragraph type="secondary">
|
||||||
记录机器人在企微内的查询与审批操作,含权限点、耗时与成败。
|
记录机器人在企微内的查询与审批操作,含权限点、耗时与成败。
|
||||||
</Typography.Paragraph>
|
</Typography.Paragraph>
|
||||||
@@ -96,7 +102,7 @@ export default function WecomBotLogsPage() {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data?.items ?? []}
|
dataSource={data?.items ?? []}
|
||||||
scroll={{ x: 1100 }}
|
scroll={{ x: 'max-content' }}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: page,
|
current: page,
|
||||||
pageSize,
|
pageSize,
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ import { request } from '../lib/api';
|
|||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
import OssUpload from '../components/OssUpload';
|
import OssUpload from '../components/OssUpload';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type FormValues = {
|
type FormValues = {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -280,7 +282,7 @@ export default function WecomBotsPage() {
|
|||||||
|
|
||||||
const runtimeMap = new Map((runtime?.bots ?? []).map((b) => [b.id, b]));
|
const runtimeMap = new Map((runtime?.bots ?? []).map((b) => [b.id, b]));
|
||||||
|
|
||||||
const columns: ColumnsType<WecomBotDto> = [
|
const baseColumns: ColumnsType<WecomBotDto> = [
|
||||||
{
|
{
|
||||||
title: '头像',
|
title: '头像',
|
||||||
dataIndex: 'avatarUrl',
|
dataIndex: 'avatarUrl',
|
||||||
@@ -291,18 +293,17 @@ export default function WecomBotsPage() {
|
|||||||
</Avatar>
|
</Avatar>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{ title: '名称', dataIndex: 'name', width: 140, ellipsis: true },
|
{ title: '名称', dataIndex: 'name', width: 140 },
|
||||||
{
|
{
|
||||||
title: '角色',
|
title: '角色',
|
||||||
dataIndex: 'role',
|
dataIndex: 'role',
|
||||||
width: 120,
|
width: 120,
|
||||||
render: (r: WecomBotRole) => WECOM_BOT_ROLE_LABELS[r] || r,
|
render: (r: WecomBotRole) => WECOM_BOT_ROLE_LABELS[r] || r,
|
||||||
},
|
},
|
||||||
{ title: 'BotID', dataIndex: 'botId', width: 160, ellipsis: true },
|
{ title: 'BotID', dataIndex: 'botId', width: 160 },
|
||||||
{
|
{
|
||||||
title: '权限',
|
title: '权限',
|
||||||
dataIndex: 'permissions',
|
dataIndex: 'permissions',
|
||||||
ellipsis: true,
|
|
||||||
render: (perms: WecomBotPermission[]) =>
|
render: (perms: WecomBotPermission[]) =>
|
||||||
perms.map((p) => (
|
perms.map((p) => (
|
||||||
<Tag key={p} style={{ marginBottom: 2 }}>
|
<Tag key={p} style={{ marginBottom: 2 }}>
|
||||||
@@ -367,13 +368,20 @@ export default function WecomBotsPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('wecom-bots', baseColumns, {
|
||||||
|
page,
|
||||||
|
pageSize,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<Space style={{ width: '100%', justifyContent: 'space-between', marginBottom: 16 }} wrap>
|
<Space style={{ width: '100%', justifyContent: 'space-between', marginBottom: 16 }} wrap>
|
||||||
<div>
|
<div>
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>
|
<Typography.Title level={4} style={{ margin: 0 }}>
|
||||||
企微机器人
|
企微机器人
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Typography.Text type="secondary">
|
<Typography.Text type="secondary">
|
||||||
并列创建多个智能机器人,配置 BotID / Secret / 权限 / 角色 / 头像。总开关在「系统设置 → 功能开关」。
|
并列创建多个智能机器人,配置 BotID / Secret / 权限 / 角色 / 头像。总开关在「系统设置 → 功能开关」。
|
||||||
{runtime ? ` 当前总开关:${runtime.masterEnabled ? '开' : '关'}` : ''}
|
{runtime ? ` 当前总开关:${runtime.masterEnabled ? '开' : '关'}` : ''}
|
||||||
@@ -428,7 +436,7 @@ export default function WecomBotsPage() {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data?.items ?? []}
|
dataSource={data?.items ?? []}
|
||||||
scroll={{ x: 1200 }}
|
scroll={{ x: 'max-content' }}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: page,
|
current: page,
|
||||||
pageSize,
|
pageSize,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useState } from 'react';
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
Avatar,
|
Avatar,
|
||||||
Button,
|
Button,
|
||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
Space,
|
Space,
|
||||||
Switch,
|
Switch,
|
||||||
Table,
|
Table,
|
||||||
|
Tabs,
|
||||||
Tag,
|
Tag,
|
||||||
Typography,
|
Typography,
|
||||||
message,
|
message,
|
||||||
@@ -21,13 +22,20 @@ import type { ColumnsType } from 'antd/es/table';
|
|||||||
import {
|
import {
|
||||||
WECOM_PUSH_CONDITION_GROUPS,
|
WECOM_PUSH_CONDITION_GROUPS,
|
||||||
WECOM_PUSH_CONDITION_LABELS,
|
WECOM_PUSH_CONDITION_LABELS,
|
||||||
|
WECOM_TEMPLATE_EVENT_KEYS,
|
||||||
|
WECOM_TEMPLATE_EVENT_LABELS,
|
||||||
|
WECOM_TEMPLATE_PLACEHOLDERS,
|
||||||
type WecomMessagePushDto,
|
type WecomMessagePushDto,
|
||||||
type WecomPushCondition,
|
type WecomPushCondition,
|
||||||
|
type WecomPushTemplateDto,
|
||||||
|
type WecomTemplateEventKey,
|
||||||
} from '@dukang/shared-types';
|
} from '@dukang/shared-types';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
import OssUpload from '../components/OssUpload';
|
import OssUpload from '../components/OssUpload';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type FormValues = {
|
type FormValues = {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -78,7 +86,7 @@ function WecomPushConditionPicker({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function WecomMessagePushesPage() {
|
function PushRoutesTab() {
|
||||||
const [filterForm] = Form.useForm();
|
const [filterForm] = Form.useForm();
|
||||||
const [form] = Form.useForm<FormValues>();
|
const [form] = Form.useForm<FormValues>();
|
||||||
const [filters, setFilters] = useState<Record<string, string>>({});
|
const [filters, setFilters] = useState<Record<string, string>>({});
|
||||||
@@ -187,7 +195,7 @@ export default function WecomMessagePushesPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<WecomMessagePushDto> = [
|
const baseColumns: ColumnsType<WecomMessagePushDto> = [
|
||||||
{
|
{
|
||||||
title: '名称',
|
title: '名称',
|
||||||
dataIndex: 'name',
|
dataIndex: 'name',
|
||||||
@@ -201,7 +209,6 @@ export default function WecomMessagePushesPage() {
|
|||||||
{
|
{
|
||||||
title: 'Webhook',
|
title: 'Webhook',
|
||||||
dataIndex: 'webhookUrlMasked',
|
dataIndex: 'webhookUrlMasked',
|
||||||
ellipsis: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '推送条件',
|
title: '推送条件',
|
||||||
@@ -256,12 +263,16 @@ export default function WecomMessagePushesPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('wecom-pushes', baseColumns, {
|
||||||
|
page,
|
||||||
|
pageSize,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<>
|
||||||
<Typography.Title level={4}>企微机器人 · 消息推送</Typography.Title>
|
{settingsModal}
|
||||||
<Typography.Paragraph type="secondary">
|
<Typography.Paragraph type="secondary">
|
||||||
配置群机器人 Webhook 多实例,按推送条件分发运营告警、技术支持工单、开发任务派发等消息。运行时不再读取
|
配置群机器人 Webhook:按推送条件订阅业务通知 / 告警。运行时不再读取 .env 中的 Webhook URL。
|
||||||
.env 中的 Webhook URL。
|
|
||||||
</Typography.Paragraph>
|
</Typography.Paragraph>
|
||||||
|
|
||||||
<Form
|
<Form
|
||||||
@@ -300,6 +311,7 @@ export default function WecomMessagePushesPage() {
|
|||||||
<Button type="primary" onClick={openCreate}>
|
<Button type="primary" onClick={openCreate}>
|
||||||
新建推送
|
新建推送
|
||||||
</Button>
|
</Button>
|
||||||
|
{settingsButton}
|
||||||
</Space>
|
</Space>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
@@ -332,10 +344,10 @@ export default function WecomMessagePushesPage() {
|
|||||||
>
|
>
|
||||||
<Form form={form} layout="vertical">
|
<Form form={form} layout="vertical">
|
||||||
<Form.Item name="name" label="名称" rules={[{ required: true, message: '请填写名称' }]}>
|
<Form.Item name="name" label="名称" rules={[{ required: true, message: '请填写名称' }]}>
|
||||||
<Input placeholder="如:运营告警" />
|
<Input placeholder="如:业务待办通知群" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="avatarUrl" label="头像(HQ 列表展示)">
|
<Form.Item name="avatarUrl" label="头像(HQ 列表展示)">
|
||||||
<OssUpload />
|
<OssUpload bizType="WECOM_BOT_AVATAR" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="webhookUrl"
|
name="webhookUrl"
|
||||||
@@ -400,6 +412,208 @@ export default function WecomMessagePushesPage() {
|
|||||||
</Descriptions>
|
</Descriptions>
|
||||||
) : null}
|
) : null}
|
||||||
</Modal>
|
</Modal>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function TemplatesTab() {
|
||||||
|
const [templates, setTemplates] = useState<WecomPushTemplateDto[]>([]);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [eventKey, setEventKey] = useState<WecomTemplateEventKey>('order.paid');
|
||||||
|
const [form] = Form.useForm<{ title: string; body: string; handleLabel: string }>();
|
||||||
|
const [saving, setSaving] = useState(false);
|
||||||
|
const [testing, setTesting] = useState(false);
|
||||||
|
const [preview, setPreview] = useState('');
|
||||||
|
|
||||||
|
const load = useCallback(async () => {
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const list = await request<WecomPushTemplateDto[]>('/admin/wecom-push-templates');
|
||||||
|
setTemplates(list);
|
||||||
|
setEventKey((prev) => {
|
||||||
|
const current = list.find((t) => t.eventKey === prev) ?? list[0];
|
||||||
|
if (current) {
|
||||||
|
form.setFieldsValue({
|
||||||
|
title: current.title,
|
||||||
|
body: current.body,
|
||||||
|
handleLabel: current.handleLabel,
|
||||||
|
});
|
||||||
|
return current.eventKey;
|
||||||
|
}
|
||||||
|
return prev;
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
message.error(e instanceof Error ? e.message : '加载模板失败');
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}, [form]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
void load();
|
||||||
|
}, [load]);
|
||||||
|
|
||||||
|
function selectEvent(key: WecomTemplateEventKey) {
|
||||||
|
setEventKey(key);
|
||||||
|
const row = templates.find((t) => t.eventKey === key);
|
||||||
|
if (row) {
|
||||||
|
form.setFieldsValue({
|
||||||
|
title: row.title,
|
||||||
|
body: row.body,
|
||||||
|
handleLabel: row.handleLabel,
|
||||||
|
});
|
||||||
|
setPreview('');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function save() {
|
||||||
|
const values = await form.validateFields();
|
||||||
|
setSaving(true);
|
||||||
|
try {
|
||||||
|
const updated = await request<WecomPushTemplateDto>(
|
||||||
|
`/admin/wecom-push-templates/${eventKey}`,
|
||||||
|
{
|
||||||
|
method: 'PUT',
|
||||||
|
body: JSON.stringify(values),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
message.success('模板已保存');
|
||||||
|
setTemplates((prev) => prev.map((t) => (t.eventKey === eventKey ? updated : t)));
|
||||||
|
} catch (e) {
|
||||||
|
message.error(e instanceof Error ? e.message : '保存失败');
|
||||||
|
} finally {
|
||||||
|
setSaving(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function reset() {
|
||||||
|
setSaving(true);
|
||||||
|
try {
|
||||||
|
const updated = await request<WecomPushTemplateDto>(
|
||||||
|
`/admin/wecom-push-templates/${eventKey}/reset`,
|
||||||
|
{ method: 'POST', body: '{}' },
|
||||||
|
);
|
||||||
|
message.success('已恢复默认文案');
|
||||||
|
form.setFieldsValue({
|
||||||
|
title: updated.title,
|
||||||
|
body: updated.body,
|
||||||
|
handleLabel: updated.handleLabel,
|
||||||
|
});
|
||||||
|
setTemplates((prev) => prev.map((t) => (t.eventKey === eventKey ? updated : t)));
|
||||||
|
setPreview('');
|
||||||
|
} catch (e) {
|
||||||
|
message.error(e instanceof Error ? e.message : '恢复失败');
|
||||||
|
} finally {
|
||||||
|
setSaving(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function testSend() {
|
||||||
|
setTesting(true);
|
||||||
|
try {
|
||||||
|
const res = await request<{ ok: boolean; message: string; preview: string }>(
|
||||||
|
`/admin/wecom-push-templates/${eventKey}/test`,
|
||||||
|
{ method: 'POST', body: '{}' },
|
||||||
|
);
|
||||||
|
setPreview(res.preview || '');
|
||||||
|
message.success(res.message || '已发送');
|
||||||
|
} catch (e) {
|
||||||
|
message.error(e instanceof Error ? e.message : '测试失败');
|
||||||
|
} finally {
|
||||||
|
setTesting(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const placeholders = WECOM_TEMPLATE_PLACEHOLDERS[eventKey] ?? [];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Typography.Paragraph type="secondary">
|
||||||
|
每种业务事件全站一份文案,使用 {'{{orderNo}}'} 等形式占位。快链由系统注入 {'{{handleUrl}}'}
|
||||||
|
;须在「推送路由」中勾选对应条件并配置 Webhook 才会发出。
|
||||||
|
</Typography.Paragraph>
|
||||||
|
|
||||||
|
<Space align="start" style={{ width: '100%' }} size={24} wrap>
|
||||||
|
<div style={{ minWidth: 200 }}>
|
||||||
|
<Typography.Text strong>事件</Typography.Text>
|
||||||
|
<div style={{ marginTop: 8 }}>
|
||||||
|
{WECOM_TEMPLATE_EVENT_KEYS.map((k) => (
|
||||||
|
<div key={k} style={{ marginBottom: 4 }}>
|
||||||
|
<Button
|
||||||
|
type={k === eventKey ? 'primary' : 'text'}
|
||||||
|
size="small"
|
||||||
|
onClick={() => selectEvent(k)}
|
||||||
|
block
|
||||||
|
style={{ textAlign: 'left' }}
|
||||||
|
>
|
||||||
|
{WECOM_TEMPLATE_EVENT_LABELS[k]}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style={{ flex: 1, minWidth: 360 }}>
|
||||||
|
<Form form={form} layout="vertical" disabled={loading}>
|
||||||
|
<Form.Item name="title" label="标题(管理用)" rules={[{ required: true }]}>
|
||||||
|
<Input />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
name="body"
|
||||||
|
label="正文(企微 markdown)"
|
||||||
|
rules={[{ required: true }]}
|
||||||
|
extra={`可用占位符:${placeholders.map((p) => `{{${p}}}`).join(' ')}`}
|
||||||
|
>
|
||||||
|
<Input.TextArea rows={12} style={{ fontFamily: 'monospace' }} />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item name="handleLabel" label="快链按钮文案" rules={[{ required: true }]}>
|
||||||
|
<Input placeholder="去处理" />
|
||||||
|
</Form.Item>
|
||||||
|
<Space wrap>
|
||||||
|
<Button type="primary" loading={saving} onClick={() => void save()}>
|
||||||
|
保存
|
||||||
|
</Button>
|
||||||
|
<Popconfirm title="恢复代码默认文案?将覆盖当前编辑" onConfirm={() => void reset()}>
|
||||||
|
<Button loading={saving}>恢复默认</Button>
|
||||||
|
</Popconfirm>
|
||||||
|
<Button loading={testing} onClick={() => void testSend()}>
|
||||||
|
用示例数据测试推送
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
</Form>
|
||||||
|
|
||||||
|
{preview ? (
|
||||||
|
<div style={{ marginTop: 16 }}>
|
||||||
|
<Typography.Text strong>预览</Typography.Text>
|
||||||
|
<pre
|
||||||
|
style={{
|
||||||
|
marginTop: 8,
|
||||||
|
padding: 12,
|
||||||
|
background: '#f5f5f5',
|
||||||
|
whiteSpace: 'pre-wrap',
|
||||||
|
borderRadius: 8,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{preview}
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
</Space>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function WecomMessagePushesPage() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Typography.Title level={4}>企微机器人 · 消息推送</Typography.Title>
|
||||||
|
<Tabs
|
||||||
|
items={[
|
||||||
|
{ key: 'routes', label: '推送路由', children: <PushRoutesTab /> },
|
||||||
|
{ key: 'templates', label: '通知模板', children: <TemplatesTab /> },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ import { fmtTime } from '../lib/constants';
|
|||||||
import { downloadExcelCsv } from '../lib/exportExcel';
|
import { downloadExcelCsv } from '../lib/exportExcel';
|
||||||
import { request, type HqProfile } from '../lib/api';
|
import { request, type HqProfile } from '../lib/api';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -37,6 +39,13 @@ type Row = {
|
|||||||
wineryAmount: number;
|
wineryAmount: number;
|
||||||
status: string;
|
status: string;
|
||||||
paidAt?: string | null;
|
paidAt?: string | null;
|
||||||
|
paymentRef?: string | null;
|
||||||
|
wineryBank?: {
|
||||||
|
bankAccountName?: string | null;
|
||||||
|
bankName?: string | null;
|
||||||
|
bankBranch?: string | null;
|
||||||
|
bankAccountNo?: string | null;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
type BillItem = {
|
type BillItem = {
|
||||||
@@ -127,14 +136,30 @@ export default function WineryBillsPage() {
|
|||||||
(profile?.permissionKeys ?? []).includes('system_settings_winery_bank');
|
(profile?.permissionKeys ?? []).includes('system_settings_winery_bank');
|
||||||
|
|
||||||
function confirmPay(ids: string[], amountHint?: number) {
|
function confirmPay(ids: string[], amountHint?: number) {
|
||||||
|
let paymentRef = '';
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: '确认打款?',
|
title: '确认打款?',
|
||||||
content: `将确认 ${ids.length} 笔酒厂对账单${amountHint != null ? `,合计约 ¥${amountHint.toFixed(2)}` : ''}。此操作不可撤销。`,
|
content: (
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
将确认 {ids.length} 笔酒厂对账单
|
||||||
|
{amountHint != null ? `,合计约 ¥${amountHint.toFixed(2)}` : ''}。此操作不可撤销。
|
||||||
|
</div>
|
||||||
|
<Input
|
||||||
|
placeholder="打款凭证号(可选)"
|
||||||
|
style={{ marginTop: 8 }}
|
||||||
|
onChange={(e) => {
|
||||||
|
paymentRef = e.target.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
okText: '确认打款',
|
okText: '确认打款',
|
||||||
cancelText: '取消',
|
cancelText: '取消',
|
||||||
onOk: async () => {
|
onOk: async () => {
|
||||||
|
const body = JSON.stringify({ paymentRef: paymentRef.trim() || undefined });
|
||||||
if (ids.length === 1) {
|
if (ids.length === 1) {
|
||||||
await request(`/admin/winery-bills/${ids[0]}/confirm`, { method: 'POST' });
|
await request(`/admin/winery-bills/${ids[0]}/confirm`, { method: 'POST', body });
|
||||||
} else {
|
} else {
|
||||||
await request('/admin/winery-bills/batch-confirm', {
|
await request('/admin/winery-bills/batch-confirm', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -212,8 +237,8 @@ export default function WineryBillsPage() {
|
|||||||
const selectedRows = (data?.items ?? []).filter((r) => selectedKeys.includes(r.id));
|
const selectedRows = (data?.items ?? []).filter((r) => selectedKeys.includes(r.id));
|
||||||
const selectedAmount = selectedRows.reduce((s, r) => s + Number(r.wineryAmount), 0);
|
const selectedAmount = selectedRows.reduce((s, r) => s + Number(r.wineryAmount), 0);
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const baseColumns: ColumnsType<Row> = [
|
||||||
{ title: '账单号', dataIndex: 'billNo', width: 170, ellipsis: true },
|
{ title: '账单号', dataIndex: 'billNo', width: 170 },
|
||||||
{
|
{
|
||||||
title: '账单日',
|
title: '账单日',
|
||||||
dataIndex: 'billDate',
|
dataIndex: 'billDate',
|
||||||
@@ -267,8 +292,11 @@ export default function WineryBillsPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('finance-winery-bills', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
{settingsModal}
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@@ -282,6 +310,7 @@ export default function WineryBillsPage() {
|
|||||||
<Typography.Title level={4} style={{ margin: 0 }}>
|
<Typography.Title level={4} style={{ margin: 0 }}>
|
||||||
酒厂对账单
|
酒厂对账单
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
|
{settingsButton}
|
||||||
<Typography.Text type="secondary">
|
<Typography.Text type="secondary">
|
||||||
T+3:每日 8:00 汇总 3 天前(自然日)已完成的同城/跨城订单(实付 × {ratePct}%);未打款红色、已打款绿色、应付为 0
|
T+3:每日 8:00 汇总 3 天前(自然日)已完成的同城/跨城订单(实付 × {ratePct}%);未打款红色、已打款绿色、应付为 0
|
||||||
无需打款(灰),可展开订单明细
|
无需打款(灰),可展开订单明细
|
||||||
@@ -375,7 +404,7 @@ export default function WineryBillsPage() {
|
|||||||
onChange: setSelectedKeys,
|
onChange: setSelectedKeys,
|
||||||
getCheckboxProps: (r) => ({ disabled: !canConfirmWineryPay(r) }),
|
getCheckboxProps: (r) => ({ disabled: !canConfirmWineryPay(r) }),
|
||||||
}}
|
}}
|
||||||
scroll={{ x: 1100 }}
|
scroll={{ x: 'max-content' }}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: page,
|
current: page,
|
||||||
pageSize,
|
pageSize,
|
||||||
@@ -399,7 +428,31 @@ export default function WineryBillsPage() {
|
|||||||
{displayWineryStatus(detail.status, detail.wineryAmount).label}
|
{displayWineryStatus(detail.status, detail.wineryAmount).label}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="打款时间">{detail.paidAt ? fmtTime(detail.paidAt) : '—'}</Descriptions.Item>
|
<Descriptions.Item label="打款时间">{detail.paidAt ? fmtTime(detail.paidAt) : '—'}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="打款凭证">
|
||||||
|
{detail.paymentRef ? String(detail.paymentRef) : '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
</Descriptions>
|
</Descriptions>
|
||||||
|
{detail.wineryBank ? (
|
||||||
|
<>
|
||||||
|
<Typography.Title level={5} style={{ marginTop: 16 }}>
|
||||||
|
收款账户(酒厂)
|
||||||
|
</Typography.Title>
|
||||||
|
<Descriptions column={1} size="small" bordered>
|
||||||
|
<Descriptions.Item label="户名">
|
||||||
|
{detail.wineryBank.bankAccountName || '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="开户银行">
|
||||||
|
{detail.wineryBank.bankName || '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="开户支行">
|
||||||
|
{detail.wineryBank.bankBranch || '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="账号">
|
||||||
|
{detail.wineryBank.bankAccountNo || '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
</Descriptions>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
<Typography.Title level={5} style={{ marginTop: 16 }}>
|
<Typography.Title level={5} style={{ marginTop: 16 }}>
|
||||||
订单明细
|
订单明细
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
@@ -409,7 +462,7 @@ export default function WineryBillsPage() {
|
|||||||
pagination={false}
|
pagination={false}
|
||||||
dataSource={detail.items ?? []}
|
dataSource={detail.items ?? []}
|
||||||
columns={[
|
columns={[
|
||||||
{ title: '订单号', dataIndex: 'orderNo', ellipsis: true },
|
{ title: '订单号', dataIndex: 'orderNo' },
|
||||||
{
|
{
|
||||||
title: '配送',
|
title: '配送',
|
||||||
dataIndex: 'deliveryType',
|
dataIndex: 'deliveryType',
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import {
|
|||||||
import { fmtTime } from '../../lib/constants';
|
import { fmtTime } from '../../lib/constants';
|
||||||
import { useAdminList } from '../../lib/useAdminList';
|
import { useAdminList } from '../../lib/useAdminList';
|
||||||
import type { PromoCodeDetailContext } from './PromoCodeDetailLayout';
|
import type { PromoCodeDetailContext } from './PromoCodeDetailLayout';
|
||||||
|
import { useAdminListColumns } from '../../lib/useAdminListColumns';
|
||||||
|
|
||||||
|
|
||||||
export default function PromoCodeUsersPage() {
|
export default function PromoCodeUsersPage() {
|
||||||
const { id = '' } = useParams();
|
const { id = '' } = useParams();
|
||||||
@@ -21,7 +23,7 @@ export default function PromoCodeUsersPage() {
|
|||||||
[id],
|
[id],
|
||||||
);
|
);
|
||||||
|
|
||||||
const columns: ColumnsType<PromoCodeAttributedUser> = [
|
const baseColumns: ColumnsType<PromoCodeAttributedUser> = [
|
||||||
{ title: '用户编号', dataIndex: 'userNo', width: 120 },
|
{ title: '用户编号', dataIndex: 'userNo', width: 120 },
|
||||||
{ title: '昵称', dataIndex: 'nickname', width: 100, render: (v) => v || '—' },
|
{ title: '昵称', dataIndex: 'nickname', width: 100, render: (v) => v || '—' },
|
||||||
{ title: '手机', dataIndex: 'phone', width: 120, render: (v) => v || '—' },
|
{ title: '手机', dataIndex: 'phone', width: 120, render: (v) => v || '—' },
|
||||||
@@ -69,6 +71,8 @@ export default function PromoCodeUsersPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { columns, settingsButton, settingsModal } = useAdminListColumns('promo-code-users', baseColumns, { page, pageSize });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Table
|
<Table
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
@@ -76,7 +80,7 @@ export default function PromoCodeUsersPage() {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data?.items ?? []}
|
dataSource={data?.items ?? []}
|
||||||
scroll={{ x: 1100 }}
|
scroll={{ x: 'max-content' }}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: page,
|
current: page,
|
||||||
pageSize,
|
pageSize,
|
||||||
|
|||||||
Vendored
+6
@@ -0,0 +1,6 @@
|
|||||||
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
|
declare module '*.mp3' {
|
||||||
|
const src: string;
|
||||||
|
export default src;
|
||||||
|
}
|
||||||
@@ -17,6 +17,11 @@ type Props = {
|
|||||||
accept?: string;
|
accept?: string;
|
||||||
/** 计量单位文案,如「张」「个」 */
|
/** 计量单位文案,如「张」「个」 */
|
||||||
unit?: string;
|
unit?: string;
|
||||||
|
/**
|
||||||
|
* stack:缩略图 + 下方独立上传按钮(合同等)
|
||||||
|
* grid:九宫格,末尾「+」格上传,无独立大按钮(环境图)
|
||||||
|
*/
|
||||||
|
variant?: 'stack' | 'grid';
|
||||||
};
|
};
|
||||||
|
|
||||||
function isCancelError(msg: string): boolean {
|
function isCancelError(msg: string): boolean {
|
||||||
@@ -42,6 +47,7 @@ export default function MultiOssUploadField({
|
|||||||
label,
|
label,
|
||||||
accept = 'image/*',
|
accept = 'image/*',
|
||||||
unit = '张',
|
unit = '张',
|
||||||
|
variant = 'stack',
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
const pickingRef = useRef(false);
|
const pickingRef = useRef(false);
|
||||||
@@ -53,6 +59,7 @@ export default function MultiOssUploadField({
|
|||||||
const onChangeRef = useRef(onChange);
|
const onChangeRef = useRef(onChange);
|
||||||
const remaining = Math.max(0, maxCount - urls.length);
|
const remaining = Math.max(0, maxCount - urls.length);
|
||||||
const inWechat = isWechatEnv();
|
const inWechat = isWechatEnv();
|
||||||
|
const isGrid = variant === 'grid';
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
urlsRef.current = urls;
|
urlsRef.current = urls;
|
||||||
@@ -126,30 +133,18 @@ export default function MultiOssUploadField({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openPicker() {
|
||||||
|
if (inWechat) void pickWechat();
|
||||||
|
else inputRef.current?.click();
|
||||||
|
}
|
||||||
|
|
||||||
function removeAt(index: number) {
|
function removeAt(index: number) {
|
||||||
if (disabled) return;
|
if (disabled) return;
|
||||||
onChange?.(urls.filter((_, i) => i !== index));
|
onChange?.(urls.filter((_, i) => i !== index));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
const thumb = (url: string, index: number) => (
|
||||||
<div className="partner-oss-upload">
|
<div key={`${url}-${index}`} className={isGrid ? 'partner-upload-grid-thumb' : undefined} style={isGrid ? undefined : { position: 'relative', width: 88, height: 88 }}>
|
||||||
<input
|
|
||||||
ref={inputRef}
|
|
||||||
type="file"
|
|
||||||
accept={accept}
|
|
||||||
multiple
|
|
||||||
className="partner-oss-upload-input"
|
|
||||||
disabled={disabled || uploading || remaining <= 0}
|
|
||||||
onChange={(e) => {
|
|
||||||
const list = Array.from(e.target.files ?? []);
|
|
||||||
if (list.length) void uploadFiles(list);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{urls.length > 0 ? (
|
|
||||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 8, marginBottom: 8 }}>
|
|
||||||
{urls.map((url, index) => (
|
|
||||||
<div key={`${url}-${index}`} style={{ position: 'relative', width: 88, height: 88 }}>
|
|
||||||
{isPdf(url) ? (
|
{isPdf(url) ? (
|
||||||
<a
|
<a
|
||||||
href={url}
|
href={url}
|
||||||
@@ -157,8 +152,8 @@ export default function MultiOssUploadField({
|
|||||||
rel="noreferrer"
|
rel="noreferrer"
|
||||||
style={{
|
style={{
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
width: 88,
|
width: isGrid ? '100%' : 88,
|
||||||
height: 88,
|
height: isGrid ? '100%' : 88,
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
@@ -178,7 +173,13 @@ export default function MultiOssUploadField({
|
|||||||
<img
|
<img
|
||||||
src={url}
|
src={url}
|
||||||
alt=""
|
alt=""
|
||||||
style={{ width: 88, height: 88, objectFit: 'cover', borderRadius: 8 }}
|
style={{
|
||||||
|
width: isGrid ? '100%' : 88,
|
||||||
|
height: isGrid ? '100%' : 88,
|
||||||
|
objectFit: 'cover',
|
||||||
|
borderRadius: isGrid ? 12 : 8,
|
||||||
|
display: 'block',
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{!disabled ? (
|
{!disabled ? (
|
||||||
@@ -202,18 +203,52 @@ export default function MultiOssUploadField({
|
|||||||
</button>
|
</button>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
))}
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="partner-oss-upload">
|
||||||
|
<input
|
||||||
|
ref={inputRef}
|
||||||
|
type="file"
|
||||||
|
accept={accept}
|
||||||
|
multiple
|
||||||
|
className="partner-oss-upload-input"
|
||||||
|
disabled={disabled || uploading || remaining <= 0}
|
||||||
|
onChange={(e) => {
|
||||||
|
const list = Array.from(e.target.files ?? []);
|
||||||
|
if (list.length) void uploadFiles(list);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{isGrid ? (
|
||||||
|
<div className="partner-upload-grid">
|
||||||
|
{urls.map((url, index) => thumb(url, index))}
|
||||||
|
{remaining > 0 && !disabled ? (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="partner-upload-dashed partner-upload-dashed--compact"
|
||||||
|
disabled={uploading}
|
||||||
|
onClick={openPicker}
|
||||||
|
aria-label={uploading ? '上传中' : `添加${unit}(${urls.length}/${maxCount})`}
|
||||||
|
>
|
||||||
|
<span className="material-symbols-outlined text-primary" style={{ fontSize: 28 }}>
|
||||||
|
{uploading ? 'hourglass_top' : 'add'}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
{urls.length > 0 ? (
|
||||||
|
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 8, marginBottom: 8 }}>
|
||||||
|
{urls.map((url, index) => thumb(url, index))}
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="partner-upload-dashed partner-upload-dashed--compact"
|
className="partner-upload-dashed partner-upload-dashed--compact"
|
||||||
disabled={disabled || uploading || remaining <= 0}
|
disabled={disabled || uploading || remaining <= 0}
|
||||||
onClick={() => {
|
onClick={openPicker}
|
||||||
if (inWechat) void pickWechat();
|
|
||||||
else inputRef.current?.click();
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<span className="material-symbols-outlined text-primary" style={{ fontSize: 28 }}>
|
<span className="material-symbols-outlined text-primary" style={{ fontSize: 28 }}>
|
||||||
{uploading ? 'hourglass_top' : 'add_a_photo'}
|
{uploading ? 'hourglass_top' : 'add_a_photo'}
|
||||||
@@ -226,6 +261,8 @@ export default function MultiOssUploadField({
|
|||||||
: label ?? `批量上传(${urls.length}/${maxCount})`}
|
: label ?? `批量上传(${urls.length}/${maxCount})`}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
{error ? (
|
{error ? (
|
||||||
<p className="partner-form-error" role="alert">
|
<p className="partner-form-error" role="alert">
|
||||||
{error}
|
{error}
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ export default function ProxyOrderPage() {
|
|||||||
const [regionCodes, setRegionCodes] = useState<string[]>(draft0.regionCodes);
|
const [regionCodes, setRegionCodes] = useState<string[]>(draft0.regionCodes);
|
||||||
const [addressDetail, setAddressDetail] = useState(draft0.addressDetail);
|
const [addressDetail, setAddressDetail] = useState(draft0.addressDetail);
|
||||||
const [productId, setProductId] = useState(draft0.productId);
|
const [productId, setProductId] = useState(draft0.productId);
|
||||||
|
const [skuId, setSkuId] = useState('');
|
||||||
const [quantity, setQuantity] = useState(draft0.quantity);
|
const [quantity, setQuantity] = useState(draft0.quantity);
|
||||||
const [promoCodeId, setPromoCodeId] = useState(draft0.promoCodeId);
|
const [promoCodeId, setPromoCodeId] = useState(draft0.promoCodeId);
|
||||||
const [deliveryMode, setDeliveryMode] = useState<PartnerProxyDeliveryMode>(draft0.deliveryMode);
|
const [deliveryMode, setDeliveryMode] = useState<PartnerProxyDeliveryMode>(draft0.deliveryMode);
|
||||||
@@ -156,9 +157,37 @@ export default function ProxyOrderPage() {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const selectedProduct = options?.products.find((p) => p.id === productId);
|
const selectedProduct = options?.products.find((p) => p.id === productId);
|
||||||
const allowOnline = selectedProduct ? selectedProduct.allowOnlinePurchase !== false : true;
|
const skuOptions = (selectedProduct?.skus ?? []).filter((s) => s.status === 'ON_SALE');
|
||||||
const allowOnSite = !!selectedProduct?.allowOnSitePickup;
|
const selectedSku =
|
||||||
const allowCrossCity = selectedProduct ? selectedProduct.allowCrossCityDelivery !== false : true;
|
skuOptions.find((s) => s.id === skuId) ||
|
||||||
|
skuOptions.find((s) => s.id === selectedProduct?.defaultSkuId) ||
|
||||||
|
skuOptions[0];
|
||||||
|
const allowOnline = selectedSku
|
||||||
|
? selectedSku.allowOnlinePurchase !== false
|
||||||
|
: selectedProduct
|
||||||
|
? selectedProduct.allowOnlinePurchase !== false
|
||||||
|
: true;
|
||||||
|
const allowOnSite = selectedSku
|
||||||
|
? !!selectedSku.allowOnSitePickup
|
||||||
|
: !!selectedProduct?.allowOnSitePickup;
|
||||||
|
const allowCrossCity = selectedSku
|
||||||
|
? selectedSku.allowCrossCityDelivery !== false
|
||||||
|
: selectedProduct
|
||||||
|
? selectedProduct.allowCrossCityDelivery !== false
|
||||||
|
: true;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!selectedProduct) return;
|
||||||
|
const def =
|
||||||
|
skuOptions.find((s) => s.id === selectedProduct.defaultSkuId) ||
|
||||||
|
skuOptions.find((s) => s.isDefault) ||
|
||||||
|
skuOptions[0];
|
||||||
|
if (def && (!skuId || !skuOptions.some((s) => s.id === skuId))) {
|
||||||
|
setSkuId(def.id);
|
||||||
|
if (def.saleUnit === 'BOX') setQuantity(1);
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [productId, selectedProduct?.id, options]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!selectedProduct) return;
|
if (!selectedProduct) return;
|
||||||
@@ -184,6 +213,7 @@ export default function ProxyOrderPage() {
|
|||||||
productId,
|
productId,
|
||||||
quantity,
|
quantity,
|
||||||
deliveryMode,
|
deliveryMode,
|
||||||
|
skuId: skuId || undefined,
|
||||||
receiverCity: deliveryMode === 'ADDRESS' ? region?.city || undefined : undefined,
|
receiverCity: deliveryMode === 'ADDRESS' ? region?.city || undefined : undefined,
|
||||||
receiverDistrict: deliveryMode === 'ADDRESS' ? region?.district || undefined : undefined,
|
receiverDistrict: deliveryMode === 'ADDRESS' ? region?.district || undefined : undefined,
|
||||||
}),
|
}),
|
||||||
@@ -200,7 +230,7 @@ export default function ProxyOrderPage() {
|
|||||||
.finally(() => setPreviewLoading(false));
|
.finally(() => setPreviewLoading(false));
|
||||||
}, 300);
|
}, 300);
|
||||||
return () => clearTimeout(timer);
|
return () => clearTimeout(timer);
|
||||||
}, [productId, quantity, deliveryMode, region?.city, region?.district]);
|
}, [productId, skuId, quantity, deliveryMode, region?.city, region?.district]);
|
||||||
|
|
||||||
function validateForm(): string | null {
|
function validateForm(): string | null {
|
||||||
if (!/^1\d{10}$/.test(phone.trim())) return '请输入有效手机号';
|
if (!/^1\d{10}$/.test(phone.trim())) return '请输入有效手机号';
|
||||||
@@ -359,6 +389,7 @@ export default function ProxyOrderPage() {
|
|||||||
productId,
|
productId,
|
||||||
quantity,
|
quantity,
|
||||||
promoCodeId: promoCodeId || undefined,
|
promoCodeId: promoCodeId || undefined,
|
||||||
|
skuId: skuId || undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
setSubmitting(true);
|
setSubmitting(true);
|
||||||
@@ -524,8 +555,35 @@ export default function ProxyOrderPage() {
|
|||||||
</button>
|
</button>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
{skuOptions.length > 1 || selectedProduct?.specEnabled ? (
|
||||||
<section className="partner-form-section">
|
<section className="partner-form-section">
|
||||||
<label className="partner-form-label">数量</label>
|
<label className="partner-form-label">规格</label>
|
||||||
|
<div className="partner-input-wrap">
|
||||||
|
<select
|
||||||
|
className="partner-input"
|
||||||
|
value={skuId}
|
||||||
|
onChange={(e) => {
|
||||||
|
const id = e.target.value;
|
||||||
|
setSkuId(id);
|
||||||
|
const sku = skuOptions.find((s) => s.id === id);
|
||||||
|
if (sku?.saleUnit === 'BOX') setQuantity(1);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{skuOptions.map((s) => (
|
||||||
|
<option key={s.id} value={s.id}>
|
||||||
|
{s.specText || '默认'} · ¥{fmtMoney(s.price)} ·{' '}
|
||||||
|
{s.saleUnit === 'BOX' ? `${s.bottlesPerUnit}瓶/箱` : '瓶'}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<section className="partner-form-section">
|
||||||
|
<label className="partner-form-label">
|
||||||
|
{selectedSku?.saleUnit === 'BOX' ? '数量(箱)' : '数量(瓶)'}
|
||||||
|
</label>
|
||||||
<div className="partner-input-wrap">
|
<div className="partner-input-wrap">
|
||||||
<input
|
<input
|
||||||
className="partner-input"
|
className="partner-input"
|
||||||
|
|||||||
@@ -1007,9 +1007,9 @@ export default function StoreCreatePage() {
|
|||||||
<MultiOssUploadField
|
<MultiOssUploadField
|
||||||
bizType="STORE_ENV"
|
bizType="STORE_ENV"
|
||||||
maxCount={20}
|
maxCount={20}
|
||||||
|
variant="grid"
|
||||||
value={form.envPhotoUrls.map((u) => u.trim()).filter(Boolean)}
|
value={form.envPhotoUrls.map((u) => u.trim()).filter(Boolean)}
|
||||||
onChange={(urls) => setForm((prev) => ({ ...prev, envPhotoUrls: urls.length ? urls : [''] }))}
|
onChange={(urls) => setForm((prev) => ({ ...prev, envPhotoUrls: urls.length ? urls : [''] }))}
|
||||||
label={`批量上传(${form.envPhotoUrls.map((u) => u.trim()).filter(Boolean).length}/20)`}
|
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ export default function StoreDetailPage() {
|
|||||||
const [status, setStatus] = useState<StoreStatusValue>('OPEN');
|
const [status, setStatus] = useState<StoreStatusValue>('OPEN');
|
||||||
const [statusSaving, setStatusSaving] = useState(false);
|
const [statusSaving, setStatusSaving] = useState(false);
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
const [mediaSaving, setMediaSaving] = useState(false);
|
|
||||||
const [mapPickerOpen, setMapPickerOpen] = useState(false);
|
const [mapPickerOpen, setMapPickerOpen] = useState(false);
|
||||||
const [actionError, setActionError] = useState('');
|
const [actionError, setActionError] = useState('');
|
||||||
const [closeConfirmOpen, setCloseConfirmOpen] = useState(false);
|
const [closeConfirmOpen, setCloseConfirmOpen] = useState(false);
|
||||||
@@ -159,18 +158,91 @@ export default function StoreDetailPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveBasic() {
|
function mediaChanged(): boolean {
|
||||||
|
if (!store) return false;
|
||||||
|
const nextCover = coverUrl.trim();
|
||||||
|
const origCover = String(store.coverUrl || '').trim();
|
||||||
|
if (nextCover !== origCover) return true;
|
||||||
|
const nextEnv = uniqueEnvUrls(envPhotoUrls);
|
||||||
|
const origEnv = uniqueEnvUrls(
|
||||||
|
Array.isArray(store.media)
|
||||||
|
? (store.media as Array<{ url?: string; bizType?: string }>)
|
||||||
|
.filter((m) => m.bizType === 'ENV')
|
||||||
|
.map((m) => String(m.url || ''))
|
||||||
|
: [],
|
||||||
|
);
|
||||||
|
if (nextEnv.length !== origEnv.length) return true;
|
||||||
|
return nextEnv.some((u, i) => u !== origEnv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function basicChanged(): boolean {
|
||||||
|
if (!store) return false;
|
||||||
|
const liveContact = String(store.contactPhone || store.phone || '').trim();
|
||||||
|
const liveIntro = String(store.intro || '').trim();
|
||||||
|
const liveRuleRaw = String(store.benefitUsageRule || '').trim();
|
||||||
|
const liveRule = liveRuleRaw && !/^null$/i.test(liveRuleRaw) ? liveRuleRaw : '';
|
||||||
|
const liveLat =
|
||||||
|
store.latitude != null && store.latitude !== '' ? String(store.latitude) : '';
|
||||||
|
const liveLng =
|
||||||
|
store.longitude != null && store.longitude !== '' ? String(store.longitude) : '';
|
||||||
|
return (
|
||||||
|
form.name.trim() !== String(store.name || '').trim() ||
|
||||||
|
form.contactPhone.trim() !== liveContact ||
|
||||||
|
form.address.trim() !== String(store.address || '').trim() ||
|
||||||
|
form.intro.trim() !== liveIntro ||
|
||||||
|
form.benefitUsageRule.trim() !== liveRule ||
|
||||||
|
form.latitude.trim() !== liveLat ||
|
||||||
|
form.longitude.trim() !== liveLng
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function saveChanges() {
|
||||||
if (!id || saving || status === 'CLOSED') return;
|
if (!id || saving || status === 'CLOSED') return;
|
||||||
const auditStatus = String(store?.auditStatus || 'APPROVED').toUpperCase();
|
const auditStatus = String(store?.auditStatus || 'APPROVED').toUpperCase();
|
||||||
if (auditStatus === 'PENDING') {
|
if (auditStatus === 'PENDING') {
|
||||||
setActionError('门店审核中,暂不可修改资料');
|
setActionError('门店审核中,暂不可修改资料');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const wantMedia = mediaChanged();
|
||||||
|
const wantBasic = basicChanged();
|
||||||
|
if (!wantMedia && !wantBasic) {
|
||||||
|
setActionError('没有检测到需要变更的字段');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const nextCover = coverUrl.trim();
|
||||||
|
const nextEnv = uniqueEnvUrls(envPhotoUrls);
|
||||||
|
if (wantMedia) {
|
||||||
|
if (!nextCover) {
|
||||||
|
setActionError('请上传门头照');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (nextEnv.length < MIN_ENV_PHOTO_COUNT) {
|
||||||
|
setActionError(`请上传至少 ${MIN_ENV_PHOTO_COUNT} 张环境照片`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
setActionError('');
|
setActionError('');
|
||||||
try {
|
try {
|
||||||
// v3.5.1 #5:基本信息变更走「提交变更」审核流,由总部审核通过后覆盖门店
|
// 入驻被驳回:直写 media/basic 并重提门店审核;已通过门店:统一走信息变更审核
|
||||||
await submitStoreInfoChangeRequest(id, {
|
if (auditStatus === 'REJECTED') {
|
||||||
|
if (wantMedia) {
|
||||||
|
const data = await request<Record<string, unknown>>('PARTNER_H5', `/partner/stores/${id}/media`, {
|
||||||
|
method: 'PUT',
|
||||||
|
body: JSON.stringify({
|
||||||
|
coverUrl: nextCover,
|
||||||
|
envPhotoUrls: nextEnv,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
applyStore(data);
|
||||||
|
}
|
||||||
|
if (wantBasic) {
|
||||||
|
const data = await request<Record<string, unknown>>('PARTNER_H5', `/partner/stores/${id}/basic`, {
|
||||||
|
method: 'PUT',
|
||||||
|
body: JSON.stringify({
|
||||||
name: form.name.trim(),
|
name: form.name.trim(),
|
||||||
contactPhone: form.contactPhone.trim(),
|
contactPhone: form.contactPhone.trim(),
|
||||||
address: form.address.trim(),
|
address: form.address.trim(),
|
||||||
@@ -182,9 +254,37 @@ export default function StoreDetailPage() {
|
|||||||
longitude: Number(form.longitude),
|
longitude: Number(form.longitude),
|
||||||
}
|
}
|
||||||
: {}),
|
: {}),
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
applyStore(data);
|
||||||
|
}
|
||||||
|
toastSuccess('已重新提交审核');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const fields: Record<string, unknown> = {};
|
||||||
|
if (wantBasic) {
|
||||||
|
fields.name = form.name.trim();
|
||||||
|
fields.contactPhone = form.contactPhone.trim();
|
||||||
|
fields.address = form.address.trim();
|
||||||
|
fields.intro = form.intro.trim();
|
||||||
|
fields.benefitUsageRule = form.benefitUsageRule.trim() || null;
|
||||||
|
if (form.latitude.trim() && form.longitude.trim()) {
|
||||||
|
fields.latitude = Number(form.latitude);
|
||||||
|
fields.longitude = Number(form.longitude);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (wantMedia) {
|
||||||
|
fields.coverUrl = nextCover;
|
||||||
|
fields.envPhotoUrls = nextEnv;
|
||||||
|
}
|
||||||
|
await submitStoreInfoChangeRequest(id, fields);
|
||||||
setPendingInfoChange(true);
|
setPendingInfoChange(true);
|
||||||
toastSuccess('变更已提交,等待总部审核');
|
toastSuccess(
|
||||||
|
wantMedia
|
||||||
|
? '变更已提交(含门头照/环境图),总部审核通过后生效'
|
||||||
|
: '变更已提交,等待总部审核',
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setActionError(e instanceof Error ? e.message : '提交失败');
|
setActionError(e instanceof Error ? e.message : '提交失败');
|
||||||
} finally {
|
} finally {
|
||||||
@@ -192,42 +292,6 @@ export default function StoreDetailPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveMedia() {
|
|
||||||
if (!id || mediaSaving || status === 'CLOSED') return;
|
|
||||||
const auditStatus = String(store?.auditStatus || 'APPROVED').toUpperCase();
|
|
||||||
if (auditStatus === 'PENDING') {
|
|
||||||
setActionError('门店审核中,暂不可修改资料');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const nextCover = coverUrl.trim();
|
|
||||||
const nextEnv = uniqueEnvUrls(envPhotoUrls);
|
|
||||||
if (!nextCover) {
|
|
||||||
setActionError('请上传门头照');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (nextEnv.length < MIN_ENV_PHOTO_COUNT) {
|
|
||||||
setActionError(`请上传至少 ${MIN_ENV_PHOTO_COUNT} 张环境照片`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setMediaSaving(true);
|
|
||||||
setActionError('');
|
|
||||||
try {
|
|
||||||
const data = await request<Record<string, unknown>>('PARTNER_H5', `/partner/stores/${id}/media`, {
|
|
||||||
method: 'PUT',
|
|
||||||
body: JSON.stringify({
|
|
||||||
coverUrl: nextCover,
|
|
||||||
envPhotoUrls: nextEnv,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
applyStore(data);
|
|
||||||
toastSuccess(auditStatus === 'REJECTED' ? '照片已更新并重新提交审核' : '照片已更新');
|
|
||||||
} catch (e) {
|
|
||||||
setActionError(e instanceof Error ? e.message : '照片更新失败');
|
|
||||||
} finally {
|
|
||||||
setMediaSaving(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (loadError) {
|
if (loadError) {
|
||||||
return (
|
return (
|
||||||
<div className="partner-detail-page partner-home--flush-top">
|
<div className="partner-detail-page partner-home--flush-top">
|
||||||
@@ -445,27 +509,13 @@ export default function StoreDetailPage() {
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{canMutate && !readOnly ? (
|
{canMutate && !readOnly ? (
|
||||||
<>
|
|
||||||
<MultiOssUploadField
|
<MultiOssUploadField
|
||||||
bizType="STORE_ENV"
|
bizType="STORE_ENV"
|
||||||
maxCount={20}
|
maxCount={20}
|
||||||
|
variant="grid"
|
||||||
value={uniqueEnvUrls(envPhotoUrls)}
|
value={uniqueEnvUrls(envPhotoUrls)}
|
||||||
onChange={(urls) => setEnvPhotoUrls(urls.length ? urls : [''])}
|
onChange={(urls) => setEnvPhotoUrls(urls.length ? urls : [''])}
|
||||||
label={`批量上传环境照(${uniqueEnvUrls(envPhotoUrls).length}/20)`}
|
|
||||||
/>
|
/>
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="partner-btn-outline"
|
|
||||||
style={{ width: '100%', marginTop: 16 }}
|
|
||||||
disabled={mediaSaving}
|
|
||||||
onClick={() => void saveMedia()}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-outlined" style={{ fontSize: 18, verticalAlign: 'middle', marginRight: 4 }}>
|
|
||||||
upload
|
|
||||||
</span>
|
|
||||||
{mediaSaving ? '上传中…' : '重新上传照片'}
|
|
||||||
</button>
|
|
||||||
</>
|
|
||||||
) : envPhotos.length > 0 ? (
|
) : envPhotos.length > 0 ? (
|
||||||
<div className="partner-photo-grid">
|
<div className="partner-photo-grid">
|
||||||
{envPhotos.map((url, index) => (
|
{envPhotos.map((url, index) => (
|
||||||
@@ -495,7 +545,7 @@ export default function StoreDetailPage() {
|
|||||||
<footer className="partner-save-footer">
|
<footer className="partner-save-footer">
|
||||||
<button type="button" className="partner-save-cancel" onClick={() => navigate('/stores')}>返回</button>
|
<button type="button" className="partner-save-cancel" onClick={() => navigate('/stores')}>返回</button>
|
||||||
{canMutate && (
|
{canMutate && (
|
||||||
<button type="button" className="partner-save-submit" onClick={() => void saveBasic()} disabled={readOnly || saving}>
|
<button type="button" className="partner-save-submit" onClick={() => void saveChanges()} disabled={readOnly || saving}>
|
||||||
<span className="material-symbols-outlined">send</span>
|
<span className="material-symbols-outlined">send</span>
|
||||||
{saving ? '提交中…' : '提交变更'}
|
{saving ? '提交中…' : '提交变更'}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -1622,10 +1622,19 @@ nav.app-tabbar .app-tabbar-label {
|
|||||||
gap: 8px;
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.partner-upload-grid-thumb {
|
||||||
|
position: relative;
|
||||||
|
aspect-ratio: 1;
|
||||||
|
width: 100%;
|
||||||
|
border-radius: 12px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
.partner-upload-grid .partner-upload-dashed {
|
.partner-upload-grid .partner-upload-dashed {
|
||||||
aspect-ratio: 1;
|
aspect-ratio: 1;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.partner-upload-dashed--compact {
|
.partner-upload-dashed--compact {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useRef, useState } from 'react';
|
import { useRef, useState } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
|
import { toastError, toastSuccess } from '../lib/toast';
|
||||||
import { uploadRedeemPendingPhoto } from '../lib/upload';
|
import { uploadRedeemPendingPhoto } from '../lib/upload';
|
||||||
import { isWechatEnv, weixinSdk } from '../lib/weixin';
|
import { isWechatEnv, weixinSdk } from '../lib/weixin';
|
||||||
import type { RedeemPendingSubmitResult } from '@dukang/shared-types';
|
import type { RedeemPendingSubmitResult } from '@dukang/shared-types';
|
||||||
@@ -18,25 +19,22 @@ export default function WeakNetFallbackPanel({ redeemToken, failCount }: Props)
|
|||||||
const [previewUrl, setPreviewUrl] = useState('');
|
const [previewUrl, setPreviewUrl] = useState('');
|
||||||
const [photoResourceId, setPhotoResourceId] = useState('');
|
const [photoResourceId, setPhotoResourceId] = useState('');
|
||||||
const [result, setResult] = useState<RedeemPendingSubmitResult | null>(null);
|
const [result, setResult] = useState<RedeemPendingSubmitResult | null>(null);
|
||||||
const [msg, setMsg] = useState('');
|
|
||||||
const [showAlbumFallback, setShowAlbumFallback] = useState(false);
|
const [showAlbumFallback, setShowAlbumFallback] = useState(false);
|
||||||
|
|
||||||
async function handleFile(file: File) {
|
async function handleFile(file: File) {
|
||||||
setUploading(true);
|
setUploading(true);
|
||||||
setMsg('');
|
|
||||||
try {
|
try {
|
||||||
const registered = await uploadRedeemPendingPhoto(file);
|
const registered = await uploadRedeemPendingPhoto(file);
|
||||||
setPhotoResourceId(registered.id);
|
setPhotoResourceId(registered.id);
|
||||||
setPreviewUrl(registered.url);
|
setPreviewUrl(registered.url);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setMsg(e instanceof Error ? e.message : '上传失败');
|
toastError(e instanceof Error ? e.message : '上传失败');
|
||||||
} finally {
|
} finally {
|
||||||
setUploading(false);
|
setUploading(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function pickPhoto() {
|
async function pickPhoto() {
|
||||||
setMsg('');
|
|
||||||
if (isWechatEnv()) {
|
if (isWechatEnv()) {
|
||||||
try {
|
try {
|
||||||
setUploading(true);
|
setUploading(true);
|
||||||
@@ -51,7 +49,7 @@ export default function WeakNetFallbackPanel({ redeemToken, failCount }: Props)
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
const text = e instanceof Error ? e.message : '选图失败';
|
const text = e instanceof Error ? e.message : '选图失败';
|
||||||
if (!/cancel/i.test(text)) {
|
if (!/cancel/i.test(text)) {
|
||||||
setMsg(`${text},可改从系统相册选择`);
|
toastError(`${text},可改从系统相册选择`);
|
||||||
setShowAlbumFallback(true);
|
setShowAlbumFallback(true);
|
||||||
inputRef.current?.click();
|
inputRef.current?.click();
|
||||||
}
|
}
|
||||||
@@ -65,11 +63,10 @@ export default function WeakNetFallbackPanel({ redeemToken, failCount }: Props)
|
|||||||
|
|
||||||
async function submitPending() {
|
async function submitPending() {
|
||||||
if (!photoResourceId) {
|
if (!photoResourceId) {
|
||||||
setMsg('请先拍摄或上传核销码照片');
|
toastError('请先拍摄或上传核销码照片');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setSubmitting(true);
|
setSubmitting(true);
|
||||||
setMsg('');
|
|
||||||
try {
|
try {
|
||||||
const res = await request<RedeemPendingSubmitResult>('SHOP_H5', '/shop/redeem/pending', {
|
const res = await request<RedeemPendingSubmitResult>('SHOP_H5', '/shop/redeem/pending', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -81,7 +78,7 @@ export default function WeakNetFallbackPanel({ redeemToken, failCount }: Props)
|
|||||||
});
|
});
|
||||||
setResult(res);
|
setResult(res);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setMsg(e instanceof Error ? e.message : '提交失败');
|
toastError(e instanceof Error ? e.message : '提交失败');
|
||||||
} finally {
|
} finally {
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
}
|
}
|
||||||
@@ -89,8 +86,8 @@ export default function WeakNetFallbackPanel({ redeemToken, failCount }: Props)
|
|||||||
|
|
||||||
function copyText(text: string) {
|
function copyText(text: string) {
|
||||||
void navigator.clipboard?.writeText(text).then(
|
void navigator.clipboard?.writeText(text).then(
|
||||||
() => setMsg('已复制'),
|
() => toastSuccess('已复制'),
|
||||||
() => setMsg('复制失败,请手动长按复制'),
|
() => toastError('复制失败,请手动长按复制'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,8 +166,6 @@ export default function WeakNetFallbackPanel({ redeemToken, failCount }: Props)
|
|||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{msg && <p className="shop-redeem-error" style={{ marginTop: 12 }}>{msg}</p>}
|
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import { createContext, useCallback, useContext, useEffect, useRef, useState, type ReactNode } from 'react';
|
||||||
|
import { registerShopToastListener, type ShopToastVariant } from '../lib/toast';
|
||||||
|
|
||||||
|
type ShopToastContextValue = {
|
||||||
|
showToast: (message: string, variant?: ShopToastVariant) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
const ShopToastContext = createContext<ShopToastContextValue | null>(null);
|
||||||
|
|
||||||
|
export function ShopToastProvider({ children }: { children: ReactNode }) {
|
||||||
|
const [toast, setToast] = useState('');
|
||||||
|
const [variant, setVariant] = useState<ShopToastVariant>('error');
|
||||||
|
const timerRef = useRef<number | null>(null);
|
||||||
|
|
||||||
|
const showToast = useCallback((message: string, nextVariant: ShopToastVariant = 'error') => {
|
||||||
|
if (timerRef.current) window.clearTimeout(timerRef.current);
|
||||||
|
setVariant(nextVariant);
|
||||||
|
setToast(message);
|
||||||
|
timerRef.current = window.setTimeout(() => {
|
||||||
|
setToast('');
|
||||||
|
timerRef.current = null;
|
||||||
|
}, nextVariant === 'error' ? 2800 : 2000);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
registerShopToastListener(showToast);
|
||||||
|
return () => {
|
||||||
|
registerShopToastListener(null);
|
||||||
|
if (timerRef.current) window.clearTimeout(timerRef.current);
|
||||||
|
};
|
||||||
|
}, [showToast]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ShopToastContext.Provider value={{ showToast }}>
|
||||||
|
{children}
|
||||||
|
{toast ? (
|
||||||
|
<div
|
||||||
|
className={`shop-float-toast${variant === 'error' ? ' shop-float-toast--error' : ''}`}
|
||||||
|
role="alert"
|
||||||
|
aria-live="assertive"
|
||||||
|
>
|
||||||
|
{toast}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</ShopToastContext.Provider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useShopToast(): ShopToastContextValue {
|
||||||
|
const ctx = useContext(ShopToastContext);
|
||||||
|
if (!ctx) throw new Error('useShopToast 必须在 ShopToastProvider 内使用');
|
||||||
|
return ctx;
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
/** 把接口里的金额(number / 数字字符串 / Prisma Decimal 残影)转成有限数字 */
|
||||||
|
export function toMoneyNumber(value: unknown): number {
|
||||||
|
if (typeof value === 'number') return Number.isFinite(value) ? value : 0;
|
||||||
|
if (typeof value === 'string' && value.trim()) {
|
||||||
|
const n = Number(value);
|
||||||
|
return Number.isFinite(n) ? n : 0;
|
||||||
|
}
|
||||||
|
if (value && typeof value === 'object') {
|
||||||
|
const o = value as { toNumber?: () => number; toString?: () => string; d?: unknown };
|
||||||
|
if (typeof o.toNumber === 'function') {
|
||||||
|
const n = Number(o.toNumber());
|
||||||
|
if (Number.isFinite(n)) return n;
|
||||||
|
}
|
||||||
|
if (typeof o.toString === 'function' && o.toString !== Object.prototype.toString) {
|
||||||
|
const n = Number(o.toString());
|
||||||
|
if (Number.isFinite(n)) return n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function formatMoney(n: number) {
|
||||||
|
return toMoneyNumber(n).toLocaleString('zh-CN', {
|
||||||
|
minimumFractionDigits: 2,
|
||||||
|
maximumFractionDigits: 2,
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
export type ShopToastVariant = 'success' | 'error';
|
||||||
|
|
||||||
|
type ShopToastListener = (message: string, variant: ShopToastVariant) => void;
|
||||||
|
|
||||||
|
let listener: ShopToastListener | null = null;
|
||||||
|
|
||||||
|
export function registerShopToastListener(fn: ShopToastListener | null) {
|
||||||
|
listener = fn;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function showShopToast(message: string, variant: ShopToastVariant = 'error') {
|
||||||
|
const text = message.trim();
|
||||||
|
if (!text || !listener) return;
|
||||||
|
listener(text, variant);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toastError(message: string) {
|
||||||
|
showShopToast(message, 'error');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toastSuccess(message: string) {
|
||||||
|
showShopToast(message, 'success');
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import ReactDOM from 'react-dom/client';
|
|||||||
import { BrowserRouter } from 'react-router-dom';
|
import { BrowserRouter } from 'react-router-dom';
|
||||||
import { getRouterBasename } from '@dukang/weixin-sdk';
|
import { getRouterBasename } from '@dukang/weixin-sdk';
|
||||||
import { StoreSessionProvider } from './contexts/StoreSessionContext';
|
import { StoreSessionProvider } from './contexts/StoreSessionContext';
|
||||||
|
import { ShopToastProvider } from './contexts/ShopToastContext';
|
||||||
import { installClientErrorReporting } from '@dukang/client-logging';
|
import { installClientErrorReporting } from '@dukang/client-logging';
|
||||||
import App from './App';
|
import App from './App';
|
||||||
import { apiBase } from './lib/api';
|
import { apiBase } from './lib/api';
|
||||||
@@ -19,7 +20,9 @@ ReactDOM.createRoot(document.getElementById('root')!).render(
|
|||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<BrowserRouter basename={getRouterBasename()}>
|
<BrowserRouter basename={getRouterBasename()}>
|
||||||
<StoreSessionProvider>
|
<StoreSessionProvider>
|
||||||
|
<ShopToastProvider>
|
||||||
<App />
|
<App />
|
||||||
|
</ShopToastProvider>
|
||||||
</StoreSessionProvider>
|
</StoreSessionProvider>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
</React.StrictMode>,
|
</React.StrictMode>,
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { isIosDevice, isScanPermissionWarmupError } from '@dukang/weixin-sdk';
|
|||||||
import { useStoreSession } from '../contexts/StoreSessionContext';
|
import { useStoreSession } from '../contexts/StoreSessionContext';
|
||||||
|
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
|
import { formatMoney, toMoneyNumber } from '../lib/money';
|
||||||
|
|
||||||
import { parseRedeemTokenFromScan } from '../lib/redeem-scan';
|
import { parseRedeemTokenFromScan } from '../lib/redeem-scan';
|
||||||
|
|
||||||
@@ -46,14 +47,6 @@ import { trackStore } from '../lib/analytics';
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function formatMoney(n: number) {
|
|
||||||
|
|
||||||
return n.toLocaleString('zh-CN', { minimumFractionDigits: 0, maximumFractionDigits: 2 });
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function formatScanError(e: unknown, opts?: { afterAuth?: boolean }): string {
|
function formatScanError(e: unknown, opts?: { afterAuth?: boolean }): string {
|
||||||
|
|
||||||
const msg = e instanceof Error ? e.message : '扫码失败,请重试';
|
const msg = e instanceof Error ? e.message : '扫码失败,请重试';
|
||||||
@@ -470,13 +463,13 @@ export default function HomePage() {
|
|||||||
|
|
||||||
<div className="shop-home-stat">
|
<div className="shop-home-stat">
|
||||||
|
|
||||||
<p className="shop-home-stat-label">今日到账金额</p>
|
<p className="shop-home-stat-label">今日核销金额</p>
|
||||||
|
|
||||||
<p className="shop-home-stat-value">
|
<p className="shop-home-stat-value">
|
||||||
|
|
||||||
<span style={{ fontSize: 18 }}>¥</span>
|
<span style={{ fontSize: 18 }}>¥</span>
|
||||||
|
|
||||||
{formatMoney(Number(dash?.todayAmount || 0))}
|
{formatMoney(toMoneyNumber(dash?.todayAmount))}
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@@ -596,7 +589,7 @@ export default function HomePage() {
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p className="shop-home-record-amount">¥{formatMoney(Number(r.amount))}</p>
|
<p className="shop-home-record-amount">¥{formatMoney(toMoneyNumber(r.amount))}</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';
|
|||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import type { RedeemPhoneDirectPrepareResult } from '@dukang/shared-types';
|
import type { RedeemPhoneDirectPrepareResult } from '@dukang/shared-types';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
|
import { toastError, toastSuccess } from '../lib/toast';
|
||||||
import { useStorePageView } from '../lib/usePageView';
|
import { useStorePageView } from '../lib/usePageView';
|
||||||
|
|
||||||
function formatAmount(n: number) {
|
function formatAmount(n: number) {
|
||||||
@@ -17,7 +18,6 @@ export default function PhoneRedeemPage() {
|
|||||||
const [prepared, setPrepared] = useState<RedeemPhoneDirectPrepareResult | null>(null);
|
const [prepared, setPrepared] = useState<RedeemPhoneDirectPrepareResult | null>(null);
|
||||||
const [storeName, setStoreName] = useState('');
|
const [storeName, setStoreName] = useState('');
|
||||||
const [storeClosed, setStoreClosed] = useState(false);
|
const [storeClosed, setStoreClosed] = useState(false);
|
||||||
const [msg, setMsg] = useState('');
|
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [confirmCooldown, setConfirmCooldown] = useState(0);
|
const [confirmCooldown, setConfirmCooldown] = useState(0);
|
||||||
const [showOpenModal, setShowOpenModal] = useState(false);
|
const [showOpenModal, setShowOpenModal] = useState(false);
|
||||||
@@ -41,11 +41,10 @@ export default function PhoneRedeemPage() {
|
|||||||
async function prepareDirectRedeem() {
|
async function prepareDirectRedeem() {
|
||||||
const value = Number(amount);
|
const value = Number(amount);
|
||||||
if (!Number.isFinite(value) || value <= 0) {
|
if (!Number.isFinite(value) || value <= 0) {
|
||||||
setMsg('请输入有效核销金额');
|
toastError('请输入有效核销金额');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setMsg('');
|
|
||||||
try {
|
try {
|
||||||
const result = await request<RedeemPhoneDirectPrepareResult>('SHOP_H5', '/shop/redeem/phone/prepare-direct', {
|
const result = await request<RedeemPhoneDirectPrepareResult>('SHOP_H5', '/shop/redeem/phone/prepare-direct', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -54,10 +53,10 @@ export default function PhoneRedeemPage() {
|
|||||||
setPrepared(result);
|
setPrepared(result);
|
||||||
setConfirmCode('');
|
setConfirmCode('');
|
||||||
setConfirmCooldown(60);
|
setConfirmCooldown(60);
|
||||||
setMsg(`验证码已发送至 ${result.maskedPhone},验证成功后将直接核销`);
|
toastSuccess(`验证码已发送至 ${result.maskedPhone},验证成功后将直接核销`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setPrepared(null);
|
setPrepared(null);
|
||||||
setMsg(e instanceof Error ? e.message : '发送验证码失败');
|
toastError(e instanceof Error ? e.message : '发送验证码失败');
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@@ -65,7 +64,7 @@ export default function PhoneRedeemPage() {
|
|||||||
|
|
||||||
async function sendConfirmSms() {
|
async function sendConfirmSms() {
|
||||||
if (!/^1\d{10}$/.test(phone.trim())) {
|
if (!/^1\d{10}$/.test(phone.trim())) {
|
||||||
setMsg('请输入正确的手机号');
|
toastError('请输入正确的手机号');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (storeClosed) {
|
if (storeClosed) {
|
||||||
@@ -88,7 +87,7 @@ export default function PhoneRedeemPage() {
|
|||||||
await prepareDirectRedeem();
|
await prepareDirectRedeem();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setShowOpenModal(false);
|
setShowOpenModal(false);
|
||||||
setMsg(e instanceof Error ? e.message : '开启营业失败');
|
toastError(e instanceof Error ? e.message : '开启营业失败');
|
||||||
} finally {
|
} finally {
|
||||||
setOpening(false);
|
setOpening(false);
|
||||||
}
|
}
|
||||||
@@ -96,15 +95,14 @@ export default function PhoneRedeemPage() {
|
|||||||
|
|
||||||
async function confirmRedeem() {
|
async function confirmRedeem() {
|
||||||
if (!prepared) {
|
if (!prepared) {
|
||||||
setMsg('请先发送核销验证码');
|
toastError('请先发送核销验证码');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!confirmCode.trim()) {
|
if (!confirmCode.trim()) {
|
||||||
setMsg('请输入确认验证码');
|
toastError('请输入确认验证码');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setMsg('');
|
|
||||||
try {
|
try {
|
||||||
const result = await request<Record<string, unknown>>('SHOP_H5', '/shop/redeem/phone/confirm', {
|
const result = await request<Record<string, unknown>>('SHOP_H5', '/shop/redeem/phone/confirm', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -118,7 +116,7 @@ export default function PhoneRedeemPage() {
|
|||||||
state: { result, storeName, user: prepared.user },
|
state: { result, storeName, user: prepared.user },
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setMsg(e instanceof Error ? e.message : '核销失败');
|
toastError(e instanceof Error ? e.message : '核销失败');
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@@ -225,8 +223,6 @@ export default function PhoneRedeemPage() {
|
|||||||
>
|
>
|
||||||
{loading ? '正在核销…' : `确认核销 ¥${formatAmount(amountValue || 0)}`}
|
{loading ? '正在核销…' : `确认核销 ¥${formatAmount(amountValue || 0)}`}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{msg && <p className="shop-redeem-error">{msg}</p>}
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -2,15 +2,12 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
|
|||||||
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
||||||
import { REDEEM_CHANNEL_LABELS, type RedeemChannel, type RedeemStatsDto } from '@dukang/shared-types';
|
import { REDEEM_CHANNEL_LABELS, type RedeemChannel, type RedeemStatsDto } from '@dukang/shared-types';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
|
import { formatMoney, toMoneyNumber } from '../lib/money';
|
||||||
import { useStorePageView } from '../lib/usePageView';
|
import { useStorePageView } from '../lib/usePageView';
|
||||||
|
|
||||||
type RangeKey = 'today' | '7d' | '30d';
|
type RangeKey = 'today' | '7d' | '30d';
|
||||||
type StatusFilter = 'all' | 'pending' | 'paid';
|
type StatusFilter = 'all' | 'pending' | 'paid';
|
||||||
|
|
||||||
function formatMoney(n: number) {
|
|
||||||
return n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
||||||
}
|
|
||||||
|
|
||||||
function inRange(dateStr: string, range: RangeKey) {
|
function inRange(dateStr: string, range: RangeKey) {
|
||||||
const d = new Date(dateStr);
|
const d = new Date(dateStr);
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
@@ -85,8 +82,8 @@ export default function RecordsPage() {
|
|||||||
}, [records, range, statusFilter]);
|
}, [records, range, statusFilter]);
|
||||||
|
|
||||||
const summary = useMemo(() => {
|
const summary = useMemo(() => {
|
||||||
const totalAmount = filtered.reduce((s, r) => s + Number(r.amount || 0), 0);
|
const totalAmount = filtered.reduce((s, r) => s + toMoneyNumber(r.amount), 0);
|
||||||
const totalSettle = filtered.reduce((s, r) => s + Number(r.settleAmount || 0), 0);
|
const totalSettle = filtered.reduce((s, r) => s + toMoneyNumber(r.settleAmount), 0);
|
||||||
const rate = totalAmount > 0 ? Math.round((totalSettle / totalAmount) * 100) : 60;
|
const rate = totalAmount > 0 ? Math.round((totalSettle / totalAmount) * 100) : 60;
|
||||||
return { totalAmount, totalSettle, rate };
|
return { totalAmount, totalSettle, rate };
|
||||||
}, [filtered]);
|
}, [filtered]);
|
||||||
@@ -181,8 +178,8 @@ export default function RecordsPage() {
|
|||||||
) : (
|
) : (
|
||||||
<div className="shop-records-list">
|
<div className="shop-records-list">
|
||||||
{filtered.map((r) => {
|
{filtered.map((r) => {
|
||||||
const amount = Number(r.amount || 0);
|
const amount = toMoneyNumber(r.amount);
|
||||||
const settle = Number(r.settleAmount || 0);
|
const settle = toMoneyNumber(r.settleAmount);
|
||||||
const payout = r.payout as { paidAt?: string | null; status?: string } | undefined;
|
const payout = r.payout as { paidAt?: string | null; status?: string } | undefined;
|
||||||
const paid = Boolean(payout?.paidAt) || payout?.status === 'PAID' || Boolean(r.paidAt);
|
const paid = Boolean(payout?.paidAt) || payout?.status === 'PAID' || Boolean(r.paidAt);
|
||||||
const paidAt = payout?.paidAt || (typeof r.paidAt === 'string' ? r.paidAt : null);
|
const paidAt = payout?.paidAt || (typeof r.paidAt === 'string' ? r.paidAt : null);
|
||||||
@@ -199,9 +196,7 @@ export default function RecordsPage() {
|
|||||||
</div>
|
</div>
|
||||||
<p className="shop-record-time">
|
<p className="shop-record-time">
|
||||||
核销时间:{' '}
|
核销时间:{' '}
|
||||||
{new Date(String(r.createdAt))
|
{new Date(String(r.createdAt)).toLocaleString('zh-CN', { hour12: false })}
|
||||||
.toLocaleString('zh-CN', { hour12: false })
|
|
||||||
.slice(0, 16)}
|
|
||||||
</p>
|
</p>
|
||||||
<p className="shop-record-channel">
|
<p className="shop-record-channel">
|
||||||
<span
|
<span
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { useNavigate, useSearchParams } from 'react-router-dom';
|
|||||||
import WeakNetFallbackPanel from '../components/WeakNetFallbackPanel';
|
import WeakNetFallbackPanel from '../components/WeakNetFallbackPanel';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
import { reportRedeemFailure } from '../lib/redeem-failure';
|
import { reportRedeemFailure } from '../lib/redeem-failure';
|
||||||
|
import { toastError } from '../lib/toast';
|
||||||
import { useStorePageView } from '../lib/usePageView';
|
import { useStorePageView } from '../lib/usePageView';
|
||||||
|
|
||||||
function formatAmount(n: number) {
|
function formatAmount(n: number) {
|
||||||
@@ -22,7 +23,6 @@ export default function RedeemConfirmPage() {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const [token, setToken] = useState('');
|
const [token, setToken] = useState('');
|
||||||
const [msg, setMsg] = useState('');
|
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [storeName, setStoreName] = useState('');
|
const [storeName, setStoreName] = useState('');
|
||||||
const [preview, setPreview] = useState<Preview | null>(null);
|
const [preview, setPreview] = useState<Preview | null>(null);
|
||||||
@@ -61,10 +61,9 @@ export default function RedeemConfirmPage() {
|
|||||||
body: JSON.stringify({ token }),
|
body: JSON.stringify({ token }),
|
||||||
});
|
});
|
||||||
setPreview(p);
|
setPreview(p);
|
||||||
setMsg('');
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setPreview(null);
|
setPreview(null);
|
||||||
setMsg(e instanceof Error ? e.message : '无法预览核销码');
|
toastError(e instanceof Error ? e.message : '无法预览核销码');
|
||||||
const report = await reportRedeemFailure(token, 'preview', e);
|
const report = await reportRedeemFailure(token, 'preview', e);
|
||||||
if (report?.thresholdReached) {
|
if (report?.thresholdReached) {
|
||||||
setFailCount(report.failCount);
|
setFailCount(report.failCount);
|
||||||
@@ -82,11 +81,10 @@ export default function RedeemConfirmPage() {
|
|||||||
|
|
||||||
async function doConfirm() {
|
async function doConfirm() {
|
||||||
if (!token.trim()) {
|
if (!token.trim()) {
|
||||||
setMsg('请先扫码获取核销码');
|
toastError('请先扫码获取核销码');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setMsg('');
|
|
||||||
try {
|
try {
|
||||||
const result = await request<Record<string, unknown>>('SHOP_H5', '/shop/redeem/confirm', {
|
const result = await request<Record<string, unknown>>('SHOP_H5', '/shop/redeem/confirm', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -95,7 +93,7 @@ export default function RedeemConfirmPage() {
|
|||||||
sessionStorage.setItem('lastRedeemResult', JSON.stringify(result));
|
sessionStorage.setItem('lastRedeemResult', JSON.stringify(result));
|
||||||
navigate('/redeem/success', { state: { result, storeName, user: preview?.user } });
|
navigate('/redeem/success', { state: { result, storeName, user: preview?.user } });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setMsg(e instanceof Error ? e.message : '核销失败');
|
toastError(e instanceof Error ? e.message : '核销失败');
|
||||||
const report = await reportRedeemFailure(token, 'confirm', e);
|
const report = await reportRedeemFailure(token, 'confirm', e);
|
||||||
if (report?.thresholdReached) {
|
if (report?.thresholdReached) {
|
||||||
setFailCount(report.failCount);
|
setFailCount(report.failCount);
|
||||||
@@ -126,13 +124,12 @@ export default function RedeemConfirmPage() {
|
|||||||
});
|
});
|
||||||
setStoreClosed(false);
|
setStoreClosed(false);
|
||||||
setShowOpenModal(false);
|
setShowOpenModal(false);
|
||||||
setMsg('');
|
|
||||||
// 开张后重新拉取预览(门店已 OPEN,后端不再拦截),再继续核销
|
// 开张后重新拉取预览(门店已 OPEN,后端不再拦截),再继续核销
|
||||||
await loadPreview();
|
await loadPreview();
|
||||||
await doConfirm();
|
await doConfirm();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setShowOpenModal(false);
|
setShowOpenModal(false);
|
||||||
setMsg(e instanceof Error ? e.message : '开启营业失败');
|
toastError(e instanceof Error ? e.message : '开启营业失败');
|
||||||
} finally {
|
} finally {
|
||||||
setOpening(false);
|
setOpening(false);
|
||||||
}
|
}
|
||||||
@@ -217,8 +214,6 @@ export default function RedeemConfirmPage() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{msg && <p className="shop-redeem-error">{msg}</p>}
|
|
||||||
|
|
||||||
{!showWeakNet && (
|
{!showWeakNet && (
|
||||||
<>
|
<>
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
import { useEffect, useMemo } from 'react';
|
import { useEffect, useMemo } from 'react';
|
||||||
import { useLocation, useNavigate } from 'react-router-dom';
|
import { useLocation, useNavigate } from 'react-router-dom';
|
||||||
import { notifyRedeemSuccess } from '../lib/useRedeemSuccessBus';
|
import { notifyRedeemSuccess } from '../lib/useRedeemSuccessBus';
|
||||||
|
import { formatMoney, toMoneyNumber } from '../lib/money';
|
||||||
function formatAmount(n: number) {
|
|
||||||
return n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function RedeemSuccessPage() {
|
export default function RedeemSuccessPage() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -24,7 +21,7 @@ export default function RedeemSuccessPage() {
|
|||||||
const storeName = (location.state as { storeName?: string })?.storeName || '当前门店';
|
const storeName = (location.state as { storeName?: string })?.storeName || '当前门店';
|
||||||
const user = (location.state as { user?: { nickname?: string; phone?: string; userNo?: string } })?.user;
|
const user = (location.state as { user?: { nickname?: string; phone?: string; userNo?: string } })?.user;
|
||||||
const userLabel = user?.nickname || user?.phone || '—';
|
const userLabel = user?.nickname || user?.phone || '—';
|
||||||
const amount = Number(result?.amount ?? 0);
|
const amount = toMoneyNumber(result?.amount);
|
||||||
const redeemNo = String(result?.redeemNo || '—');
|
const redeemNo = String(result?.redeemNo || '—');
|
||||||
const createdAt = result?.createdAt
|
const createdAt = result?.createdAt
|
||||||
? new Date(String(result.createdAt)).toLocaleString('zh-CN')
|
? new Date(String(result.createdAt)).toLocaleString('zh-CN')
|
||||||
@@ -52,7 +49,7 @@ export default function RedeemSuccessPage() {
|
|||||||
<span className="material-symbols-outlined">check_circle</span>
|
<span className="material-symbols-outlined">check_circle</span>
|
||||||
</div>
|
</div>
|
||||||
<h2 className="shop-success-title">核销成功</h2>
|
<h2 className="shop-success-title">核销成功</h2>
|
||||||
<p className="shop-success-amount">¥ {formatAmount(amount)}</p>
|
<p className="shop-success-amount">¥ {formatMoney(amount)}</p>
|
||||||
<p className="shop-success-sub">已入账到余额</p>
|
<p className="shop-success-sub">已入账到余额</p>
|
||||||
<p className="shop-success-note">核销成功,账单通知已发送至老板手机</p>
|
<p className="shop-success-note">核销成功,账单通知已发送至老板手机</p>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -8,15 +8,12 @@ import {
|
|||||||
} from '@dukang/shared-types';
|
} from '@dukang/shared-types';
|
||||||
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
|
import { formatMoney, toMoneyNumber } from '../lib/money';
|
||||||
import { useStorePageView } from '../lib/usePageView';
|
import { useStorePageView } from '../lib/usePageView';
|
||||||
import { useRedeemSuccessListener } from '../lib/useRedeemSuccessBus';
|
import { useRedeemSuccessListener } from '../lib/useRedeemSuccessBus';
|
||||||
|
|
||||||
type StatusFilter = 'all' | StoreWithdrawStatus;
|
type StatusFilter = 'all' | StoreWithdrawStatus;
|
||||||
|
|
||||||
function formatMoney(n: number) {
|
|
||||||
return n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function WithdrawPage() {
|
export default function WithdrawPage() {
|
||||||
useStorePageView('store_withdraw_view');
|
useStorePageView('store_withdraw_view');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -113,13 +110,13 @@ export default function WithdrawPage() {
|
|||||||
<div>
|
<div>
|
||||||
<p className="shop-records-summary-label">可提未出账余额</p>
|
<p className="shop-records-summary-label">可提未出账余额</p>
|
||||||
<p className="shop-records-summary-value">
|
<p className="shop-records-summary-value">
|
||||||
¥ {formatMoney(summary?.availableAmount ?? 0)}
|
¥ {formatMoney(toMoneyNumber(summary?.availableAmount))}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p className="shop-records-summary-label">今日剩余额度</p>
|
<p className="shop-records-summary-label">今日剩余额度</p>
|
||||||
<p className="shop-records-summary-value">
|
<p className="shop-records-summary-value">
|
||||||
¥ {formatMoney(summary?.remainingDailyLimit ?? 0)}
|
¥ {formatMoney(toMoneyNumber(summary?.remainingDailyLimit))}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -209,7 +206,7 @@ export default function WithdrawPage() {
|
|||||||
<div className="shop-record-amounts">
|
<div className="shop-record-amounts">
|
||||||
<div>
|
<div>
|
||||||
<p className="shop-record-amount-label">提现金额</p>
|
<p className="shop-record-amount-label">提现金额</p>
|
||||||
<p className="shop-record-amount-value red">¥{formatMoney(Number(r.amount))}</p>
|
<p className="shop-record-amount-value red">¥{formatMoney(toMoneyNumber(r.amount))}</p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p className="shop-record-amount-label">明细笔数</p>
|
<p className="shop-record-amount-label">明细笔数</p>
|
||||||
|
|||||||
@@ -3190,3 +3190,26 @@ header:has(> .app-page-title:only-child),
|
|||||||
box-shadow: none !important;
|
box-shadow: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.shop-float-toast {
|
||||||
|
position: fixed;
|
||||||
|
top: 28%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
z-index: 10020;
|
||||||
|
max-width: min(320px, calc(100vw - 40px));
|
||||||
|
padding: 12px 20px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: rgba(0, 0, 0, 0.78);
|
||||||
|
color: #fff;
|
||||||
|
font-size: 15px;
|
||||||
|
line-height: 1.5;
|
||||||
|
text-align: center;
|
||||||
|
pointer-events: none;
|
||||||
|
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-float-toast--error {
|
||||||
|
background: rgba(166, 29, 36, 0.92);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@dukang/mini-user",
|
"name": "@dukang/mini-user",
|
||||||
"version": "3.4.15",
|
"version": "3.5.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "杜康好客 · C 端用户微信小程序(Taro)",
|
"description": "杜康好客 · C 端用户微信小程序(Taro)",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -54,3 +54,71 @@ body::-webkit-scrollbar,
|
|||||||
padding-bottom: 0 !important;
|
padding-bottom: 0 !important;
|
||||||
bottom: 0 !important;
|
bottom: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.benefit-figure {
|
||||||
|
display: inline-flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
line-height: 1;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.benefit-figure-prefix,
|
||||||
|
.benefit-figure-value {
|
||||||
|
line-height: 1;
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: inherit;
|
||||||
|
font-weight: inherit;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.benefit-figure-icon {
|
||||||
|
display: block;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.benefit-figure--sm {
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.benefit-figure--sm .benefit-figure-icon {
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.benefit-figure--md .benefit-figure-icon {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.benefit-figure--lg .benefit-figure-icon {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.benefit-figure--xl {
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.benefit-figure--xl .benefit-figure-icon {
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mu-float-toast {
|
||||||
|
position: fixed;
|
||||||
|
top: 28%;
|
||||||
|
left: 10%;
|
||||||
|
right: 10%;
|
||||||
|
z-index: 10020;
|
||||||
|
padding: 12px 20px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: rgba(0, 0, 0, 0.78);
|
||||||
|
color: #fff;
|
||||||
|
font-size: 15px;
|
||||||
|
line-height: 1.5;
|
||||||
|
text-align: center;
|
||||||
|
pointer-events: none;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 69 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user