Compare commits
35 Commits
669610a84a
...
iteration/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a62b8930d4 | ||
|
|
e41adb4505 | ||
|
|
2c8de04041 | ||
|
|
98a4be8719 | ||
|
|
f5730089a1 | ||
|
|
ecce4f6e7b | ||
|
|
c706f543a4 | ||
|
|
d82e716d33 | ||
|
|
22e796ba23 | ||
|
|
6dedd9f852 | ||
|
|
7f3ff10fda | ||
|
|
eeeab03295 | ||
|
|
0d77a7d55b | ||
|
|
16effb69f3 | ||
|
|
c31183205d | ||
|
|
b2a76adc9a | ||
|
|
52268859aa | ||
|
|
f1006187f6 | ||
|
|
944f17ec3f | ||
|
|
633c88d0aa | ||
|
|
f61a3f84b6 | ||
|
|
327516dd40 | ||
|
|
2f23aeaaba | ||
|
|
2c64957e55 | ||
|
|
1a5f3d1e7d | ||
|
|
d02ce01f6a | ||
|
|
aec2a27a65 | ||
|
|
f896cad34f | ||
|
|
7a74bec337 | ||
|
|
5364916b1d | ||
|
|
6655638116 | ||
|
|
e79d599da1 | ||
|
|
015f990fb6 | ||
|
|
063337e6a3 | ||
|
|
c26d36154c |
@@ -3,7 +3,6 @@ name: 构建并部署前端到测试环境
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- iteration/august
|
||||
- dev
|
||||
- test
|
||||
# 如果不再需要 main 分支触发构建,可以把下面这行删掉;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
| 页面/操作 | URL | 权限名称 | 权限编码 |
|
||||
| --- | --- | --- | --- |
|
||||
| 预警列表 | `/package-management/traffic-alerts` | `recordsView` | `package_traffic_alert:records_view` |
|
||||
| 预警详情 | `/package-management/traffic-alerts/detail/:id` | `recordDetail` | `package_traffic_alert:record_detail` |
|
||||
| 点击套餐名称进入预警详情 | `/package-management/traffic-alerts/detail/:id` | `recordDetail` | `package_traffic_alert:record_detail` |
|
||||
| 导出预警记录 | — | `export` | `package_traffic_alert:export` |
|
||||
| 导出任务页面 | `/asset-management/export-task-management/export-package-traffic-alert` | `page` | `export_task:package_traffic_alert_page` |
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
| 删除 | `delete` | `business_user_group:delete` |
|
||||
| 成员管理 | `members` | `business_user_group:members` |
|
||||
|
||||
## 店铺管理:业务负责人导入
|
||||
## 店铺管理:批量换绑业务员
|
||||
|
||||
页面 URL:`/shop-management/business-owner-import`
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ The admin frontend SHALL provide a bulk purchase form that binds one uploaded ba
|
||||
|
||||
#### Scenario: Hide voucher upload for wallet payment
|
||||
|
||||
- **GIVEN** 用户选择代理钱包支付
|
||||
- **GIVEN** 用户选择代理预存款支付
|
||||
- **WHEN** 页面渲染或提交批量订购表单
|
||||
- **THEN** 页面 MUST NOT submit a voucher file
|
||||
- **AND** 页面 MUST clear or ignore a voucher selected before switching to wallet payment
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
- [x] 2.1 新增批量订购入口和表单,支持选择代理商、支付方式和 Excel 文件。
|
||||
- [x] 2.2 提供前端静态 Excel 模板下载,并限制上传文件类型和必要的文件状态。
|
||||
- [x] 2.3 线下支付时显示整批支付凭证上传,钱包支付时隐藏或清理凭证字段。
|
||||
- [x] 2.3 线下支付时显示整批支付凭证上传,预存款支付时隐藏或清理凭证字段。
|
||||
- [x] 2.4 复用订单列表已有 `VoucherUpload` 组件展示凭证上传进度,上传未完成时禁止创建任务。
|
||||
- [x] 2.5 创建请求携带 `shop_id`、`payment_method`、`file`、必要的 `voucher_file` 和 `request_id`。
|
||||
- [x] 2.6 防止重复点击和重复提交,创建成功后保存 `task_id` 并进入任务详情。
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
- src/views/shop-management/business-user-groups/index.vue(新增页面)
|
||||
- src/views/shop-management/list/index.vue
|
||||
- src/router/routes/asyncRoutes.ts、src/router/routesAlias.ts、src/locales/langs/{zh,en}.json
|
||||
- src/template/业务负责人导入模板.csv(前端自带模板)
|
||||
- src/template/批量换绑业务员模板.csv(前端自带模板)
|
||||
- API contracts: 11 个端点(7 个业务用户组 + 店铺筛选/字段 + 批量交接 + 导入三步)
|
||||
- Dependencies:
|
||||
- docs/产品迭代8月份/业务用户组.md(7 个组端点 OpenAPI)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
## Context
|
||||
|
||||
现有前端没有运营商通道阈值命中记录页面或对应 API 类型。后端已提供只读分页查询接口,页面需忠实呈现不可变的命中时快照和周期恢复状态。
|
||||
|
||||
## Goals / Non-Goals
|
||||
|
||||
- Goals: 提供受限于平台账号的筛选、分页和证据查询;不丢失空值的历史语义。
|
||||
- Non-Goals: 修改通道阈值、发起停复机、导出记录、查看卡片详情,或查询上游响应。
|
||||
|
||||
## Decisions
|
||||
|
||||
- Decision: 在系统管理路径下新增独立隐藏查询页,由运营商管理页提供入口;路由使用 `allowedUserTypes: [1, 2]`,页面自身也在请求前检查平台账号。
|
||||
- Rationale: 接口只允许超级管理员和平台账号。前端隐藏/保护页面入口,后端仍是最终授权及卡数据范围过滤边界。
|
||||
- Decision: 精确 ID 筛选使用数值输入,计费周期起点使用日期时间选择器,判定时间使用日期时间范围选择器;时间序列化为带时区 RFC3339 秒级字符串。
|
||||
- Rationale: 与接口的精确匹配和闭区间语义一致,避免按日期截断或丢失时区。
|
||||
- Decision: 页面仅展示响应快照,不再查询通道配置或根据当前阈值重算历史值。
|
||||
- Rationale: 命中值冻结于判定时;历史缺失值必须保留接口规定的空值含义。
|
||||
|
||||
## Risks / Trade-offs
|
||||
|
||||
- 查询页不依赖后端菜单节点;前端入口仅对平台账号显示,页面路由限制用户类型,API 仍执行最终授权和数据范围过滤。
|
||||
- 表格包含多列证据字段,采用现有可横向滚动的管理台表格以保持信息完整。
|
||||
@@ -0,0 +1,24 @@
|
||||
# Change: 新增运营商通道阈值命中记录查询
|
||||
|
||||
## Why
|
||||
|
||||
达量停机与周期恢复需要可追溯的数字证据。运营人员需要查询每次停机判定时冻结的累计流量、实际阈值、计费周期、触发来源,以及周期解锁和复机结果;通道阈值后续变更不能影响历史记录。
|
||||
|
||||
## What Changes
|
||||
|
||||
- 在运营商管理页提供“通道阈值命中记录”入口,打开独立只读查询页并接入 `GET /api/admin/carrier-traffic-threshold-hits`。
|
||||
- 支持按运营商通道 ID、IoT 卡 ID、计费周期起点精确匹配,并按判定时间闭区间筛选。
|
||||
- 展示命中时的流量和阈值快照、判定/触发信息、锁状态、解锁时间、复机结果及安全失败原因。
|
||||
- 仅超级管理员与平台账号可访问;数据范围过滤及越权资源不可区分由后端强制执行,前端不替代后端授权。
|
||||
- 对接口定义的空历史值使用明确的“无”或“未处理/历史记录”展示,不发起额外的通道阈值或上游接口查询。
|
||||
|
||||
## Impact
|
||||
|
||||
- Affected specs: `carrier-traffic-threshold-hits`
|
||||
- Affected code:
|
||||
- `src/api/modules/carrierTrafficThresholdHit.ts`
|
||||
- `src/types/api/carrierTrafficThresholdHit.ts`
|
||||
- `src/views/system/carrier-traffic-threshold-hits/index.vue`
|
||||
- `src/router/routesAlias.ts`, `src/router/routes/staticRoutes.ts`, `src/views/system/carrier-management/index.vue`
|
||||
- `src/locales/langs/zh.json`, `src/locales/langs/en.json`
|
||||
- Breaking changes: 无;仅新增只读查询接口消费与页面入口。
|
||||
@@ -0,0 +1,35 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Carrier Traffic Threshold Hit Record Query
|
||||
|
||||
The admin frontend SHALL provide a read-only paginated view of carrier traffic threshold hit records using `GET /api/admin/carrier-traffic-threshold-hits`.
|
||||
|
||||
#### Scenario: Restrict page access to platform accounts
|
||||
|
||||
- **GIVEN** a user is not a super administrator or platform account
|
||||
- **WHEN** the user navigates to the carrier traffic threshold hit page
|
||||
- **THEN** the frontend MUST deny access and MUST NOT issue the hit-record query
|
||||
- **AND** backend authorization and card data-scope filtering MUST remain authoritative
|
||||
|
||||
#### Scenario: Filter hit records
|
||||
|
||||
- **GIVEN** an authorized platform user opens the hit-record page
|
||||
- **WHEN** the user searches by optional carrier ID, card ID, billing period start, or judged-at time range
|
||||
- **THEN** the frontend MUST send `carrier_id`, `card_id`, `period_start`, `start_time`, and `end_time` only when provided
|
||||
- **AND** period and judged-at timestamps MUST be timezone-qualified RFC3339 values with second precision
|
||||
- **AND** `start_time` and `end_time` MUST represent the API's inclusive time interval
|
||||
|
||||
#### Scenario: Display immutable hit evidence and recovery result
|
||||
|
||||
- **GIVEN** the query returns threshold-hit records
|
||||
- **WHEN** the frontend renders the table
|
||||
- **THEN** it MUST display record/card/carrier IDs, hit traffic, frozen threshold value and unit, billing period start, judged time, trigger source, lock status, unlock time, resume result, failure reason, and creation time
|
||||
- **AND** it MUST NOT recompute hit traffic or threshold from current channel configuration
|
||||
- **AND** it MUST display nullable historical traffic/threshold values as “无”, blank resume results as “未处理或历史记录”, and missing unlock/failure details as “无”
|
||||
|
||||
#### Scenario: Preserve server ordering and pagination
|
||||
|
||||
- **GIVEN** the user queries hit records
|
||||
- **WHEN** the frontend loads or changes the page
|
||||
- **THEN** it MUST send `page` and `page_size` (never exceeding 100)
|
||||
- **AND** it MUST render the server-provided page, size, total, and item order without client-side re-sorting
|
||||
@@ -0,0 +1,10 @@
|
||||
## 1. API Contract
|
||||
|
||||
- [x] 1.1 增加命中记录查询参数、记录项及分页响应类型。
|
||||
- [x] 1.2 增加 `GET /api/admin/carrier-traffic-threshold-hits` 服务方法并统一导出。
|
||||
|
||||
## 2. Admin UI
|
||||
|
||||
- [x] 2.1 新增超级管理员/平台账号可访问的隐藏路由、运营商管理页入口及中英文标题。
|
||||
- [x] 2.2 实现筛选、分页和命中/周期恢复快照表格,按接口约定展示空值。
|
||||
- [x] 2.3 运行 OpenSpec 校验、ESLint 与生产构建。
|
||||
23
openspec/changes/add-iot-card-recall-line-input/proposal.md
Normal file
23
openspec/changes/add-iot-card-recall-line-input/proposal.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# Change: 批量回收支持一行一个 ICCID
|
||||
|
||||
用户已确认并完成实施;验证结果见 `tasks.md`。
|
||||
|
||||
## Why
|
||||
|
||||
IoT 卡管理的批量回收目前只能从表格勾选 ICCID、输入号段范围或使用筛选条件。已有卡号清单的用户需要直接粘贴每行一个 ICCID,并复用现有 ICCID 列表的回收接口。
|
||||
|
||||
## What Changes
|
||||
|
||||
- 在“批量回收”弹窗的选卡方式中增加“一行一个ICCID”,选择后显示带标签和输入提示的多行文本框,沿用现有 Element Plus 表单样式。
|
||||
- 按换行拆分输入,去除每行首尾空白并忽略空行;ICCID 始终按字符串处理,不作数字转换。不增加额外的卡号长度或格式限制。
|
||||
- 提交时仍调用 `POST /api/admin/iot-cards/standalone/recall`,使用 `selection_type: "list"` 和 `iccids: string[]`,不向接口发送新的选卡方式或文本框字段。
|
||||
- 没有有效输入时展示校验提示,不提交请求;切换方式后按当前方式构建参数,关闭再打开时清空手工输入。
|
||||
- 取消批量回收入口必须勾选表格的限制。有勾选时仍默认“ICCID列表”,无勾选时默认“一行一个ICCID”;原有列表模式仍校验必须有勾选项。
|
||||
- 保持号段范围、筛选条件、权限、备注、结果展示和刷新逻辑不变;不修改其他批量操作。
|
||||
|
||||
## Impact
|
||||
|
||||
- Affected specs: `iot-card-management`
|
||||
- Affected code: `src/views/asset-management/iot-card-management/index.vue`
|
||||
- Backend impact: 无;复用 `CardService.recallStandaloneCards` 及其现有列表请求结构。
|
||||
- Related changes: `update-batch-range-count-hints-formatting`(保留其号段数量提示)。
|
||||
@@ -0,0 +1,55 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: IoT Card Batch Recall Line Input
|
||||
|
||||
The IoT card batch recall dialog SHALL offer “一行一个ICCID” as an additional frontend-only selection mode alongside the existing ICCID list, range and filter modes.
|
||||
|
||||
The new mode MUST show a labeled multiline input with a hint to enter one ICCID per line. It MUST split LF and CRLF line endings, trim each line, ignore empty lines and preserve each ICCID as a string without numeric conversion or additional length or format restrictions.
|
||||
|
||||
Submitting this mode MUST call the existing `POST /api/admin/iot-cards/standalone/recall` endpoint with `selection_type: "list"`, the entered values in `iccids`, and the existing optional remark. It MUST NOT include selected table rows, range fields, filter fields or frontend-only fields in that request.
|
||||
|
||||
#### Scenario: Submit a pasted ICCID list
|
||||
|
||||
- **GIVEN** 用户选择“一行一个ICCID”并输入多个 ICCID,行首尾存在空白且内容中包含空行
|
||||
- **WHEN** 用户点击“确认回收”
|
||||
- **THEN** 系统 MUST 去除首尾空白和空行,将剩余各行作为字符串放入 `iccids`
|
||||
- **AND** 系统 MUST 使用原有列表模式的接口和 `selection_type: "list"` 提交
|
||||
- **AND** 系统 MUST 沿用现有成功数、失败项及列表刷新流程
|
||||
|
||||
#### Scenario: Reject empty manual input
|
||||
|
||||
- **GIVEN** 用户选择“一行一个ICCID”
|
||||
- **WHEN** 输入为空或仅包含空白和空行并尝试提交
|
||||
- **THEN** 系统 MUST 显示请输入 ICCID 的校验提示
|
||||
- **AND** 系统 MUST NOT 发送回收请求
|
||||
|
||||
#### Scenario: Keep each selection mode isolated
|
||||
|
||||
- **GIVEN** 用户在逐行输入与现有列表、号段或筛选方式之间切换
|
||||
- **WHEN** 用户提交当前选择方式
|
||||
- **THEN** 系统 MUST 仅根据当前方式构建请求参数
|
||||
- **AND** 原有列表、号段和筛选方式 MUST 保持既有行为及号段数量提示
|
||||
|
||||
### Requirement: IoT Card Batch Recall Manual Input Entry
|
||||
|
||||
The batch recall action SHALL remain permission-controlled and be available without selected table rows so users can enter ICCIDs directly. When opening the dialog, it MUST default to the existing list mode if rows are selected and to line input mode otherwise. The existing list mode MUST still reject submission without selected cards. Manual input MUST be cleared when the dialog is reopened.
|
||||
|
||||
#### Scenario: Open batch recall without selected rows
|
||||
|
||||
- **GIVEN** 用户拥有 `iot_card:batch_recycle` 权限且未勾选表格行
|
||||
- **WHEN** 用户点击“批量回收”
|
||||
- **THEN** 系统 MUST 打开弹窗并默认选择“一行一个ICCID”
|
||||
- **AND** 用户 MUST 能直接粘贴卡号,而无需先勾选无关卡片
|
||||
|
||||
#### Scenario: Preserve the selected-row workflow
|
||||
|
||||
- **GIVEN** 用户已在表格勾选卡片
|
||||
- **WHEN** 用户打开“批量回收”弹窗
|
||||
- **THEN** 系统 MUST 默认选择现有“ICCID列表”方式
|
||||
- **AND** 用户按列表方式提交时 MUST 继续使用已勾选卡片的 ICCID
|
||||
|
||||
#### Scenario: Clear manual input when reopening
|
||||
|
||||
- **GIVEN** 用户在“一行一个ICCID”方式下输入过卡号并关闭弹窗
|
||||
- **WHEN** 用户再次打开“批量回收”弹窗
|
||||
- **THEN** 手工输入框 MUST 为空,不得沿用上一次回收的输入
|
||||
31
openspec/changes/add-iot-card-recall-line-input/tasks.md
Normal file
31
openspec/changes/add-iot-card-recall-line-input/tasks.md
Normal file
@@ -0,0 +1,31 @@
|
||||
## 1. Specification
|
||||
|
||||
- [x] 1.1 核对批量回收入口、选卡方式和现有列表模式接口。
|
||||
- [x] 1.2 明确逐行输入、空值校验、接口复用和既有模式兼容场景。
|
||||
- [x] 1.3 获得用户对提案的确认后开始实施(用户回复“执行”)。
|
||||
|
||||
## 2. Implementation
|
||||
|
||||
- [x] 2.1 新增仅用于前端的逐行输入选项和多行文本框,保留后端选卡方式枚举。
|
||||
- [x] 2.2 实现按行解析、非空校验及 `selection_type: "list"` 的请求参数构建。
|
||||
- [x] 2.3 调整无勾选时的入口和默认方式,并确保弹窗重开清空输入。
|
||||
- [x] 2.4 保持既有列表、号段、筛选、权限及操作结果流程不变。
|
||||
|
||||
## 3. Validation
|
||||
|
||||
- [x] 3.1 运行 `openspec validate add-iot-card-recall-line-input --strict`(通过)。
|
||||
- [x] 3.2 检查多行输入(LF / CRLF)、首尾空白、空行、全空输入和长 ICCID 字符串处理。
|
||||
- [x] 3.3 检查模式切换、无勾选打开、有勾选默认列表、关闭重开及接口参数隔离。
|
||||
- [x] 3.4 运行相关文件代码检查和项目类型检查,记录结果。
|
||||
|
||||
## 4. Verification results
|
||||
|
||||
- `node --test scripts/tests/iotCardRecallLineInput.test.mjs`:11 项通过;执行真实 Vue 组件 setup、校验规则和提交函数,并使用 mock 请求验证原有回收 API 的路径及参数,无真实回收操作。
|
||||
- `node --import ./scripts/tests/register-esbuild.mjs --test scripts/tests/*.test.mjs`:项目全部 141 项测试通过(PowerShell 中先枚举测试文件再传入)。
|
||||
- `pnpm exec eslint src/views/asset-management/iot-card-management/index.vue scripts/tests/iotCardRecallLineInput.test.mjs`:通过。
|
||||
- `pnpm exec prettier --check src/views/asset-management/iot-card-management/index.vue scripts/tests/iotCardRecallLineInput.test.mjs`:通过。
|
||||
- `node scripts/check-encoding.mjs src/views/asset-management/iot-card-management/index.vue scripts/tests/iotCardRecallLineInput.test.mjs`:通过。
|
||||
- `pnpm exec vue-tsc --noEmit`:通过。
|
||||
- `node scripts/tests/verifyBuild.mjs`:生产构建通过,输出到临时目录并保留生成声明文件;其他页面仍有 `searchForm` 常量赋值、循环依赖及大 chunk 警告,本次未修改这些页面。
|
||||
- `openspec validate add-iot-card-recall-line-input --strict`、`git diff --check`:通过。
|
||||
- 验证范围:本地自动化及构建检查,未执行真实后端回收或浏览器人工验收。工作区另有 `src/types/components.d.ts` 的生成变动,本次未回退或覆盖。
|
||||
33
openspec/changes/add-self-service-password-change/design.md
Normal file
33
openspec/changes/add-self-service-password-change/design.md
Normal file
@@ -0,0 +1,33 @@
|
||||
## Context
|
||||
|
||||
头像菜单位于 `src/components/core/layouts/art-header-bar/index.vue`,当前“个人中心”通过路由跳转,“锁定屏幕”通过事件打开。`AuthService.changePassword` 已封装 `PUT /api/auth/password`,但当前 TypeScript 参数 `ChangePasswordParams` 使用 `oldPassword`、`newPassword`、`confirmPassword`,与 OpenAPI 的 `old_password`、`new_password` 不一致。HTTP 层只序列化 JSON,不会将 camelCase 自动转换成 snake_case。
|
||||
|
||||
## Goals / Non-Goals
|
||||
|
||||
- Goals: 提供头像菜单入口和简单的自助修改密码流程;遵循给定 OpenAPI 请求契约;不增加权限编码或权限判断。
|
||||
- Non-Goals: 修改后端接口、增加路由、改变锁屏行为、增加权限管理配置。
|
||||
|
||||
## Decisions
|
||||
|
||||
- Decision: 使用头像菜单中的对话框承载表单,不为此功能新增页面路由。入口依次位于个人中心、修改密码、锁定屏幕。
|
||||
- Decision: 表单收集当前密码、新密码和确认密码;确认密码仅用于客户端一致性校验,提交时仅构造 `{ old_password, new_password }`。
|
||||
- Decision: 将 API DTO 类型调整为精确表达 OpenAPI 的 snake_case 字段,避免依赖 HTTP 层不存在的字段转换。
|
||||
- Decision: 所有已登录用户均可见并可操作该入口,不使用 RBAC、按钮权限或菜单权限配置进行隐藏/拦截;API 请求仍携带现有 Bearer Token。
|
||||
- Decision: 接口成功时清空敏感表单数据、提示成功,再调用 `userStore.clearLocalState()` 清除旧 token 并跳转登录页;接口失败时展示错误反馈,不记录密码值。
|
||||
|
||||
## Risks / Trade-offs
|
||||
|
||||
- 当前类型与接口字段不一致,直接复用旧 camelCase 参数会发送错误字段;以 DTO 对齐及请求验证覆盖此风险。
|
||||
- 密码策略细节未在给定 OpenAPI 中定义;本次不自行新增密码复杂度规则,沿用后端校验结果并反馈错误。
|
||||
|
||||
## Migration Plan
|
||||
|
||||
无需数据迁移或后端变更。前端发布后,已登录用户可从头像菜单使用入口;回滚时可移除菜单项及对话框实现。
|
||||
|
||||
## Open Questions
|
||||
|
||||
- None.
|
||||
|
||||
## Session Handling
|
||||
|
||||
After a successful password change, clear the current client authentication state with `userStore.clearLocalState()` and redirect to the login route. Do not attempt the logout API after changing the password because the old token may already be invalid.
|
||||
@@ -0,0 +1,21 @@
|
||||
# Change: 添加自助修改密码功能
|
||||
|
||||
## Why
|
||||
|
||||
当前头像菜单提供个人中心和锁定屏幕入口,但用户无法从该处修改自己的登录密码。认证服务已提供 `PUT /api/auth/password`,需要补齐可发现的前端入口和修改流程。
|
||||
|
||||
## What Changes
|
||||
|
||||
- 在头像菜单的“个人中心”和“锁定屏幕”之间增加“修改密码”入口。
|
||||
- 点击后打开修改密码表单,提交当前密码和新密码至 `PUT /api/auth/password`。
|
||||
- 按 OpenAPI 使用 `old_password`、`new_password` 请求字段;确认密码(如表单提供)只在前端校验,不发送给接口。
|
||||
- 修改密码入口面向所有已登录用户,不新增权限编码、路由权限或按钮权限。
|
||||
- 修改成功后清理本地认证状态并跳转登录页,要求用户使用新密码重新登录。
|
||||
- 为新增文案提供中英文国际化。
|
||||
|
||||
## Impact
|
||||
|
||||
- Affected specs: `admin-authentication`
|
||||
- Affected code: `src/components/core/layouts/art-header-bar/index.vue`、`src/components/core/layouts/art-header-bar/ChangePasswordDialog.vue`、`src/components/core/layouts/art-header-bar/style.scss`、`src/api/modules/auth.ts`、`src/types/api/auth.ts`、`src/locales/langs/zh.json`、`src/locales/langs/en.json`
|
||||
- API: 已有 `PUT /api/auth/password`;请求体按 OpenAPI 发送 `old_password` 和 `new_password`,使用当前登录 Bearer Token。
|
||||
- Authorization: 不新增前端权限配置;接口仍按认证 API 的 Bearer 认证要求调用。
|
||||
@@ -0,0 +1,33 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Self-Service Password Change Entry
|
||||
|
||||
The authenticated admin interface SHALL provide a password-change entry in the avatar menu between “个人中心” and “锁定屏幕”. The entry SHALL be available to every authenticated user without a frontend route, button, or menu permission check.
|
||||
|
||||
#### Scenario: User opens password-change form from avatar menu
|
||||
|
||||
- **GIVEN** the user is authenticated in the admin interface
|
||||
- **WHEN** the user opens the avatar menu
|
||||
- **THEN** the menu shows “个人中心”, “修改密码”, and “锁定屏幕” in that order
|
||||
- **AND** selecting “修改密码” opens the password-change form
|
||||
- **AND** the entry is not hidden or disabled based on a permission code
|
||||
|
||||
### Requirement: Change Current User Password
|
||||
|
||||
The password-change form SHALL collect the current password and new password, and SHALL submit them through `PUT /api/auth/password` using the current Bearer token. The request body MUST contain exactly the API fields `old_password` and `new_password`; any confirmation value used for client-side validation MUST NOT be sent. Password values MUST NOT be written to application logs.
|
||||
|
||||
#### Scenario: Password change succeeds
|
||||
|
||||
- **GIVEN** the user has entered a current password and matching new-password values
|
||||
- **WHEN** the user submits the form and the API returns success
|
||||
- **THEN** the frontend sends `old_password` and `new_password` to `PUT /api/auth/password`
|
||||
- **AND** the frontend displays success feedback and clears the password form values
|
||||
- **AND** the frontend clears the local authentication state and redirects the user to the login page
|
||||
- **AND** the user must authenticate again with the new password
|
||||
|
||||
#### Scenario: Password change is rejected
|
||||
|
||||
- **GIVEN** the user submits the password-change form
|
||||
- **WHEN** the API rejects the request
|
||||
- **THEN** the frontend displays error feedback and does not report success
|
||||
- **AND** the frontend does not log any password value
|
||||
13
openspec/changes/add-self-service-password-change/tasks.md
Normal file
13
openspec/changes/add-self-service-password-change/tasks.md
Normal file
@@ -0,0 +1,13 @@
|
||||
## 1. 头像菜单与修改密码表单
|
||||
|
||||
- [x] 1.1 在头像菜单“个人中心”和“锁定屏幕”之间添加“修改密码”入口,不设置权限判断。
|
||||
- [x] 1.2 实现修改密码表单,收集当前密码、新密码及确认密码,并在前端校验必填项与两次新密码一致。
|
||||
- [x] 1.3 调用认证 API;请求仅包含 `old_password` 和 `new_password`,成功后清空表单并提示结果,失败时显示错误反馈。
|
||||
- [x] 1.4 添加中英文菜单、表单、校验及结果提示文案。
|
||||
|
||||
## 2. API 契约与验证
|
||||
|
||||
- [x] 2.1 对齐 `ChangePasswordParams` 与 `AuthService.changePassword` 的请求 DTO,确保网络请求字段为 OpenAPI 定义的 snake_case,且不发送确认密码。
|
||||
- [x] 2.2 验证菜单顺序、表单校验、成功与失败反馈,以及入口不依赖任何权限编码。
|
||||
- [x] 2.3 运行相关类型检查和构建,处理本次改动引入的问题。
|
||||
- [x] 2.4 密码修改成功后清理本地认证状态并跳转登录页。
|
||||
@@ -10,7 +10,9 @@
|
||||
- 成员管理弹窗展示当前成员及成员关系信息。
|
||||
- 候选账号展示 `add`、`already_member`、`move` 操作提示。
|
||||
- 停用组允许查询和移除,但新增/迁移由后端拒绝并提示。
|
||||
- 用户组列表/详情使用实时成员数。
|
||||
- 用户组列表使用接口返回的实时成员数。
|
||||
- 当前成员和候选账号展示当前所属组名称、编码、启用状态,不展示内部组 ID。
|
||||
- 店铺列表和详情展示业务用户组编码、名称、启用状态和业务线,不展示内部组 ID。
|
||||
|
||||
## Impact
|
||||
|
||||
|
||||
@@ -1,5 +1,32 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Business User Group Metadata Visibility
|
||||
|
||||
The frontend SHALL display business user group metadata returned by shop and membership APIs while omitting internal group IDs from these views.
|
||||
|
||||
#### Scenario: Show business group fields for shops
|
||||
|
||||
- **WHEN** an administrator views the shop list or shop details
|
||||
- **THEN** the frontend displays the business group code, name, enabled state, and business line returned by the API
|
||||
- **AND** the frontend does not display the business group ID
|
||||
|
||||
#### Scenario: Show current group fields for members and candidates
|
||||
|
||||
- **WHEN** an administrator views current members or candidate accounts in the group drawer
|
||||
- **THEN** the frontend displays each account's current group code, name, and enabled state
|
||||
- **AND** displays "未分组" when the account has no current group
|
||||
- **AND** the frontend does not display the current group ID
|
||||
|
||||
#### Scenario: Show current member count
|
||||
|
||||
- **WHEN** an administrator views the business user group list
|
||||
- **THEN** the frontend displays the `member_count` returned for each group
|
||||
|
||||
#### Scenario: Keep member selection and username visible
|
||||
|
||||
- **WHEN** an administrator scrolls horizontally in either member or candidate table
|
||||
- **THEN** the selection checkbox and username columns remain fixed on the left
|
||||
|
||||
### Requirement: Incremental Business User Group Membership
|
||||
|
||||
The frontend SHALL use the member query, candidate query, incremental POST add/move, and scoped DELETE remove contracts from the modification document.
|
||||
|
||||
@@ -12,3 +12,10 @@
|
||||
## 3. Verification
|
||||
|
||||
- [ ] 3.1 运行类型检查、lint、编码检查、构建和 OpenSpec 校验。
|
||||
|
||||
## 4. Metadata Display
|
||||
|
||||
- [x] 4.1 在店铺列表和详情中展示业务用户组编码、名称、启用状态及业务线,不展示组 ID。
|
||||
- [x] 4.2 在成员与候选账号表中展示当前组编码、名称及启用状态,不展示组 ID。
|
||||
- [x] 4.3 在业务用户组列表中展示接口返回的成员数。
|
||||
- [x] 4.4 成员和候选账号表横向滚动时固定勾选框与用户名列在左侧。
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#### Scenario: 任务列表展示扩展字段
|
||||
|
||||
- **GIVEN** 用户进入业务负责人导入任务列表
|
||||
- **GIVEN** 用户进入批量换绑业务员任务列表
|
||||
- **WHEN** 列表加载完成
|
||||
- **THEN** 前端 MUST 展示任务编号、文件名、创建人、开始/完成时间与状态中文名
|
||||
- **AND** 原有状态/总数/成功/失败/创建时间展示 MUST 保留
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
# 十月第 1 批后台适配设计
|
||||
|
||||
## Context
|
||||
|
||||
本仓库为 Vue 3/TypeScript 后台,HTTP 服务使用 `BaseService` 与 Axios,页面已有业务权限、状态映射、详情组件、异步导入导出任务。原范围排除 C 端;2026-10-14 用户追加代理扫码注册页及同一注册接口的密码校验,其余 C 端接口和页面仍排除。后台本人改密虽然使用 `/api/auth/password`,仍属于本次后台适配。
|
||||
|
||||
本设计依据十月第 1 批说明、用户最新确认和当前代码。用户确认不提供最新 OpenAPI;2026-10-14 修正为新密码允许特殊符号,恢复四类至少三类。实施已获批准,结果详见实施记录,没有调用真实后台写接口。
|
||||
|
||||
### 代码证据与修改路径
|
||||
|
||||
| 依据/代码证据 | 当前差异 | 修改路径 |
|
||||
| --- | --- | --- |
|
||||
| M3;`src/types/api/order.ts`、`src/api/modules/order.ts` | 详情与列表共用 `Order`,缺三项支付信息与支付记录 | `Order` 补公共字段,另建 `OrderDetail` 与支付记录类型,详情服务改用详情类型 |
|
||||
| M8;`employeeCollectionDisplay.ts`、核销申请列表/详情 | 状态仅 0~3,可重提仅状态 2;提交状态只读名称 | 补终态 4、状态值映射与恢复/重提判断,覆盖账单关联申请 |
|
||||
| M14;退款/充值/提现类型与状态映射 | 缺退款 7、充值 7、提现 5;旧重提及补发条件不认识终态 | 各业务独立扩展类型、筛选、标签和可执行操作 |
|
||||
| M14;后台代理注册查询类型/详情 | 筛选仅 0~2,恢复操作仅看 `recoverable` | 补状态 3,并在业务终态下优先隐藏恢复 |
|
||||
| M1;账号、客户账号、店铺、企业表单及本人改密弹窗 | 仍使用 8~32 或 6~20;旧密码也有长度规则 | 新密码使用专用校验,旧密码只保留必要输入校验 |
|
||||
| M1;`AccountService.updateAccountPassword` | 独立改密发送 `{ password }`,说明要求 `{ new_password }` | 按第 1 批说明修正独立改密请求,不误改其他接口字段 |
|
||||
| M12;换货创建/确认完成、`apiError.ts` | 无 1202 定制反馈;错误归一化不暴露业务 data,换货 catch 可能输出错误对象 | 在换货操作定向提取 code/msg/message/data.phone,只在提示中展示号码,不记录完整错误对象 |
|
||||
| M16;预警规则与记录类型/页面 | 规则依赖已删除的 `real_data_mb`;记录未定义三项 MB 字段 | 只移除规则响应引用,补记录快照并明确 MB 单位 |
|
||||
| M2;业务员导入页 | 仍写「业务员登录账号」且未注明只填手机号 | 同步说明及已有前端模板,保留逐行失败明细 |
|
||||
| M23;设备导入任务页 | IMEI 被列为可选,已支持 `failed_items` | 改说明,复用失败明细,不改 Excel 模板结构 |
|
||||
|
||||
## Goals / Non-goals
|
||||
|
||||
- Goals:让后台显示、筛选、请求字段和可执行操作符合本批次说明;保留既有权限、表单内容、财务快照和导入导出流程。
|
||||
- Non-goals:除代理扫码注册密码规则外的 C 端适配、后台接口实现、新审批机制、新页面架构、自动解绑手机号、前端重算预警或余额、替换设备导入模板、引入测试框架。
|
||||
|
||||
## Decisions
|
||||
|
||||
### 1. 订单详情类型与支付状态隔离
|
||||
|
||||
公共 `Order` 接收三项字符串字段,列表与创建响应仍使用公共类型;详情增加独立 `payments` 数组。支付记录状态 0~3 与订单 `PaymentStatus` 的 1~4 含义不同,使用独立枚举/映射,不能复用。
|
||||
|
||||
支付记录使用后端顺序,不自行筛掉失败或待支付记录;金额用已有分转元格式化,`paid_at`、`expire_at` 空值显示 `-`。渠道码映射 `wechat` 为微信直连 v3、`wechat_v2` 为微信直连 v2、`fuiou` 为富友;支付方式微信/支付宝与技术渠道分开展示,未知非空渠道保留原值。公共字段为空串显示 `-`,不能据此虚构支付信息。
|
||||
|
||||
### 2. 业务终态优先于恢复标志
|
||||
|
||||
六个业务各自定义终态,禁止跨业务共用数值。恢复入口使用「不是本业务审批提交失败终态 + 后端允许恢复 + 原权限允许」共同判断;即使陈旧响应仍返回 `recoverable=true`,终态也不得显示恢复按钮。
|
||||
|
||||
「提交结果未知」不能只凭提交状态转换成业务失败,保留原后端恢复资格判断,不扩大恢复权限。终态下隐藏恢复/补发和不适用的审批操作,查看详情、凭证等只读操作保留。
|
||||
|
||||
重新发起复用既有表单和文档规定的接口:核销/退款/提现使用原业务重提接口,线下充值创建新单,提现资料提交新版本。代理注册仅提示申请人重新扫码,后台不调用 `/api/c/v1`、不补建后台代注册接口。涉及预占/冻结金额时重新加载账单或佣金概览,前端不乐观加减财务数据。
|
||||
|
||||
核销审批提交状态使用 `approval_submission_status` 的 0 待提交、1 提交中、2 已提交、3 提交失败、4 结果未知。名称字段存在时可使用后端名称,但字段为空时需按真实数值回退,0 不能因 falsy 判断显示成缺失。
|
||||
|
||||
### 3. 新密码校验专用化
|
||||
|
||||
使用新登录密码专用工具,避免影响通用校验与其他密码。按最新修正,长度 8~12,允许英文字母、数字及所有可打印半角 ASCII 符号,四类至少三类;空白、中文、emoji、控制字符和非 ASCII 字符拒绝。不静默 trim。
|
||||
|
||||
字符范围为 ASCII `0x21~0x7E`,按大写、小写、数字和标点四类计数,至少三类。`Admin@12345`、`ABC1234!`、`abc1234!`、`Abcdefg!` 均有效;`abcd1234`、`ABCDEF!!` 仅两类无效。
|
||||
|
||||
顶栏 `z-index:100`、侧栏 `z-index:101` 导致嵌在顶栏内的改密遮罩被侧栏压住。仅给改密弹窗加 `append-to-body`,不全局提高顶栏层级或修改所有弹窗;由 Element Plus 管理完整遮罩、焦点和关闭行为。
|
||||
|
||||
新密码和确认密码统一长度限制、规则说明与一致性校验;本人改密 `old_password` 不设新规则的 `maxlength` 或类别限制,旧登录表单不收紧。账号编辑目前没有密码输入则不新增;若既有调用传递可选 `password`,仅非空新值需要校验,未修改密码时不发送空串。
|
||||
|
||||
后台七个契约:
|
||||
|
||||
| 场景 | 接口 | 新密码字段 |
|
||||
| --- | --- | --- |
|
||||
| 本人修改 | `PUT /api/auth/password` | `new_password` |
|
||||
| 创建账号(含店铺/企业下的客户账号) | `POST /api/admin/accounts` | `password` |
|
||||
| 修改账号 | `PUT /api/admin/accounts/{id}` | 可选 `password` |
|
||||
| 独立修改账号密码 | `PUT /api/admin/accounts/{id}/password` | `new_password` |
|
||||
| 创建店铺初始账号 | `POST /api/admin/shops` | `init_password` |
|
||||
| 创建企业 | `POST /api/admin/enterprises` | `password` |
|
||||
| 修改企业密码 | `PUT /api/admin/enterprises/{id}/password` | `password` |
|
||||
|
||||
用户明确追加的公开代理注册使用原 `POST /api/c/v1/agent-distribution-registrations` 和 `password` 字段。表单复用 `createNewLoginPasswordRule()`,注册服务发送前复用 `getNewLoginPasswordError()`;保留其他入参和 `withToken: false`。页面将输入上限改为 12,完整规则独立显示在输入框下,并关联 `aria-describedby`,避免移动端 placeholder 截断规则。强度反馈仅按共享校验判定合格/未合格,空格和中文不能被计作有效特殊符号;长错误文案参与正常布局,不覆盖下一个表单项。
|
||||
|
||||
用户进一步追加注册失败反馈:仅 `registerAgent` 请求设 `errorMessageMode: 'none'`,页面处理非零业务响应与 HTTP 异常。1050/1001 不暴露企业微信模板配置细节,统一「注册失败, 请联系管理员」,其余错误保留具体业务原因或正常网络降级;不记录密码或完整错误对象。提交进行中阻止再次提交,失败保留表单。公共 HTTP、短信与其他服务的错误提示保持原状。
|
||||
|
||||
公共表头 Sortable 报错作为既有列设置功能的生命周期修复:改用 `useDraggable(..., { immediate: false })` 和真实 `HTMLElement` ref,仅在列设置 Popover 已打开且进入后,目标仍连接文档时启动;关闭、卸载及 KeepAlive 停用销毁实例,晚到回调不得重新启动。列排序仍通过原 `columns` model 写回,勾选状态和其他表头功能不变。
|
||||
|
||||
错误消息兼容项目既有 `msg` 与说明中的 `message`,优先展示后端提供的可读字段级原因;不改变 401 等既有统一处理,不重复弹错、不输出密码值。
|
||||
|
||||
### 4. 换货 1202 定向错误处理
|
||||
|
||||
创建换货和确认完成同时覆盖 HTTP 200 的非零业务码与 Axios HTTP 错误响应,不假定只有一种承载形式。在受影响的两个服务调用范围关闭重复默认提示,局部共享处理器处理 1202,其余错误仍按既有统一错误分类/文案展示。
|
||||
|
||||
1202 弹窗原样使用业务 `msg`,不拼接号码或固定替换文案。只有响应明确带有效字符串 `data.phone` 时才允许带参跳转;`data=null` 的已换货等拒绝仅显示后端文案和「知道了」。只以文本渲染,不拼成 HTML。
|
||||
|
||||
手机号冲突且具备原关联页面查看权限时提供跳转;无权限或新资产标识缺失时仅提示,不扩大权限。禁止自动解绑。完整号码不额外写日志或本地存储;用户主动跳转的 query 参数是已明确授权的例外。
|
||||
|
||||
创建失败保留资产/原因等字段;完成失败重新加载换货单,保持后端「已发货待确认」事实,不乐观标记完成。解除后由用户再次提交。取消只关闭提示,不当作解绑或换货成功。
|
||||
|
||||
用户追加快捷定位:创建换货冻结当前新资产上下文,确认完成使用原单新资产标识;手机号只能取当前错误响应 `data.phone`,不得根据历史数组推断其他 1202 是手机号冲突。主动跳转通过 `asset_identifier` 和 `phone` query 传递目标。关联页按 1 页/20 条加载,仅选中精确匹配有效行,继续原原因和二次确认。
|
||||
|
||||
通过 ArtTable 透传清空/勾选方法,数据更新后 nextTick 完成实际选择。缓存重入和路由参数变更重置查询,请求序号防止过期响应覆盖;手工筛选/翻页、解绑后刷新清除旧选择。批量结果保持后端布尔契约,仅展示中文「解绑成功/解绑失败」。原查看与批量解绑权限不变。
|
||||
|
||||
### 5. 预警只展示快照,不重算阈值
|
||||
|
||||
删除 `PackageTrafficAlertRuleItem.real_data_mb` 与规则行/详情/列设置依赖。来自 `/api/admin/packages` 的套餐选项 `real_data_mb` 保留,套餐选择与规则参数校验不变。
|
||||
|
||||
记录列表/详情接收后端 `threshold_mb`、`used_mb`、`limit_mb`,用 MB 显示两位小数;0 显示 `0.00`,缺失/null 显示 `-`。标签分别为阈值流量、已用流量(含加油包)、总流量(含加油包)。不使用当前套餐额度重新计算历史 `threshold_mb`,不把新字段作为新的请求入参或筛选项。
|
||||
|
||||
### 6. 导入说明与后端结果保持一致
|
||||
|
||||
CSV 只同步新表头和手机号说明,不为旧表头做客户端转换、不将用户名转为手机号。发现内置模板时同步,否则仅改当前说明,任务明细保留原后端原因。
|
||||
|
||||
设备导入保持原下载文件与列序,将说明中的 IMEI 移到必填列;只把空值规则交给后端逐行处理,不为单行缺失拦截整个文件,不添加格式或去重限制。
|
||||
|
||||
## Risks / Trade-offs
|
||||
|
||||
- 无最新 OpenAPI:按用户确认,以第 1 批说明实施,不要求补文件;联调发现真实接口与说明不符时先反馈,不自行猜测或声称已通过联调。
|
||||
- 密码口径以最新修正为准:允许半角特殊符号并按四类至少三类校验;如后端字符集合仍有不同约束,联调时反馈用户。
|
||||
- 恢复旧规范与新业务终态冲突:文档注明差异,实施时优先按本批次终态处理,结果未知继续守原恢复规则。
|
||||
- 改错密码/流量范围:专用新密码工具和独立规则/套餐类型限制修改范围,回归旧密码、操作密码、WiFi 密码、套餐额度。
|
||||
- 换货错误提示重复或泄漏号码:两个请求定向接管提示,共享处理器保留其他错误行为,删除受影响分支的完整错误输出。
|
||||
- 财务状态不同步:重提和失败后重新拉取后端数据,不修改本地冻结金额来模拟后端效果。
|
||||
- 仓库未配置可直接运行的单测脚本:先检查现有测试方式,以针对性逻辑检查、类型检查、编码检查和人工联调为验收,不自动引入新框架。
|
||||
|
||||
## Migration plan
|
||||
|
||||
提案获批后,依据第 1 批说明和用户最新确认,依任务清单按公共类型/规则、各页面、联调顺序实施;前端与对应测试后端一起验收。无数据库迁移、权限迁移、历史导出重生成或自动数据修复。
|
||||
|
||||
回退只回退本次业务代码,不触及原有提案和用户改动;后端若仍保留新校验及终态,旧前端将重新出现展示与提交问题,因此上线/回退需确认前后端契约匹配。
|
||||
|
||||
## 已确认事项
|
||||
|
||||
1. 没有最新 `admin-openapi.yaml`,不要求提供,以第 1 批说明实施。
|
||||
2. 新密码 8~12 位,大写、小写、数字、半角特殊符号至少三类,禁止空白和中文。
|
||||
3. 用户明确追加的代理扫码注册密码规则纳入;其他 `/api/c/v1` 和 C 端页面排除。后台代理注册失败仍仅展示重新扫码申请指引,不代发 C 端申请。
|
||||
|
||||
当前没有待确认的需求问题。用户已批准实施,后台代码已适配;真实后端联调项继续在任务清单保留未完成状态。
|
||||
@@ -0,0 +1,123 @@
|
||||
# 后台实施记录
|
||||
|
||||
后台代码已按第 1 批对接说明及用户确认适配。2026-10-14 用户明确追加代理扫码注册页及原注册接口的密码校验,其他 C 端仍不修改。真实后端联调尚未完成,未部署、提交或调用真实写接口。
|
||||
|
||||
## 结果与证据
|
||||
|
||||
| 证据 | 已确认结果 | 实现路径 |
|
||||
| --- | --- | --- |
|
||||
| 规则测试与本地订单详情 | 支付摘要、独立支付单状态、失败记录、空时间与金额展示正常 | `src/types/api/order.ts`、订单列表/详情、`orderPayment.ts` |
|
||||
| 规则测试与模拟核销/代理注册详情 | 终态优先于陈旧恢复标志,核销可重提、代理注册提示重新扫码 | 核销展示工具、退款常量、注册状态辅助函数及相应页面 |
|
||||
| 规则测试与模拟改密弹窗 | 按 2026-10-14 修正允许特殊符号且四类至少三类;旧密码不受新长度限制,错误说明不重叠 | `loginPassword.ts`、后台密码表单、本人改密弹窗与双语文案 |
|
||||
| 规则测试与原模拟换货确认完成 | 1202 按最新规则原样展示 `msg`,有效响应手机号才提供跳转;原待确认状态保持,不自动解绑 | `exchangeError.ts`、换货页面与服务 |
|
||||
| 数值测试与模拟预警规则/详情 | 规则额度移除,MB 快照两位小数,零和缺失区分,套餐商品额度保留 | 预警类型、规则页、记录列表/详情及 `trafficAlert.ts` |
|
||||
| 模板和源码回归检查 | 新四列表头与手机号说明,设备 IMEI 必填说明、原 Excel 模板和行级失败反馈保持 | `shopBusinessOwnerImport.ts`、导入页面 |
|
||||
|
||||
ui-ux-pro-max 用于检查标签含义、错误反馈和长文案换行;保留现有 Element Plus 样式,未引入新 UI 依赖或改版。docs-generator 用于区分实施结果、可复现检查和未完成的真实联调,任务清单没有将后端验收提前标为完成。
|
||||
|
||||
## 复现本地验证
|
||||
|
||||
在项目根目录执行:
|
||||
|
||||
```powershell
|
||||
# 63 项规则及已有回归测试;加载入口兼容 pnpm 的 esbuild 隔离布局。
|
||||
node --import ./scripts/tests/register-esbuild.mjs --test --test-reporter=spec scripts/tests/*.test.mjs
|
||||
npx --no-install vue-tsc --noEmit
|
||||
|
||||
# 生产构建输出到临时目录,关闭自动声明生成并校验原声明内容未被覆盖。
|
||||
node scripts/tests/verifyBuild.mjs
|
||||
openspec validate update-october-batch-one-admin-integration --strict --no-interactive
|
||||
```
|
||||
|
||||
受影响文件 ESLint、Prettier 和 UTF-8 检查通过。生产构建存在原有搜索表单常量赋值、审计/认证循环分块和大 chunk 警告,未扩大本次修改去重构这些模块。
|
||||
|
||||
### 本地页面检查
|
||||
|
||||
```powershell
|
||||
node scripts/tests/verifyBuild.mjs --serve
|
||||
```
|
||||
|
||||
访问 `http://127.0.0.1:5190`。该预览拦截全部 `/api/` 请求且禁用真实代理,测试数据为模拟值;登录和写请求不会到真实后台。模拟账号为超级管理员,仅用于本地验收,输入满足登录页既有规则的任意测试账号密码即可。
|
||||
|
||||
已检查订单详情、核销失败详情、代理注册失败详情、预警详情/规则页、改密弹窗和换货完成 1202 提示;页面检查未产生 JS 错误。改密弹窗额外检查 375px 视口。
|
||||
|
||||
模板下载从统一 UTF-8 BOM 文本生成新 CSV,原 GBK 静态文件不再被此页面引用,没有改写用户已有模板资产。设备 Excel 模板没有修改。`src/types/components.d.ts` 与实施前内容 SHA-256 一致;已有开发服务器的自动生成曾补入本次新 Alert 声明,已改显式组件导入并只撤回该自动新增行,用户原差异保留。
|
||||
|
||||
## 待真实联调
|
||||
|
||||
1. 六类审批失败终态真实数据、权限矩阵、未知结果恢复、核销预占释放和提现重新冻结。
|
||||
2. 真实支付摘要与多次支付历史、换货解除关联后成功重试及其他错误响应。
|
||||
3. CSV 表头/手机号错误、逐行部分成功,以及设备 IMEI 空白/全部失败。
|
||||
4. 新建与历史订单、IoT 卡、设备、预警导出文件列。
|
||||
|
||||
这些项目继续保留在任务清单,用户验收及部署后再归档。
|
||||
|
||||
## 用户追加:换货冲突快捷解绑
|
||||
|
||||
已在用户明确要求下补充以下行为:
|
||||
|
||||
- 创建换货捕获提交时新资产上下文,确认完成使用换货单的新资产标识,不使用旧资产。按用户最新修正,跳转手机号只取当前 1202 `data.phone`,缺失时不再回退历史手机号数组。
|
||||
- 用户点击跳转后,路由带 `asset_identifier` 和 `phone`,目标页从 1 页/20 条精确查询。只实际勾选匹配两项条件且有效的记录,不全选历史失效记录。
|
||||
- 表格勾选方法由已有 ArtTable 透传;手工取消后不立即重新勾选,重置、筛选、翻页及解绑后刷新清空旧选择;缓存重入或路由参数变化重新取目标,过期响应不能覆盖新查询。
|
||||
- 批量解绑仍使用 `phone_asset_association:unbind_batch` 和原原因/二次确认表单;结果列展示「解绑成功/解绑失败」,资产类型同时显示中文,不修改后端布尔值契约。
|
||||
|
||||
原说明要求号码不额外记录或持久化;用户追加明确要求两项路由参数,因此用户主动跳转时允许号码进入该 URL 查询参数,不额外记录日志或写入本地存储。
|
||||
|
||||
新增三项自动测试,全套 66 项通过,类型检查、受影响文件 lint、编码和严格规范校验通过,生产构建通过(原有警告仍在)。本地模拟确认了完整的 1202 弹窗 → 带参跳转 → 筛选并勾选有效记录 → 手工取消禁用按钮 → 原确认表单 → 中文成功结果链路,没有调用真实后台解绑接口。
|
||||
|
||||
### 用户修正:区分共用的 1202 错误码
|
||||
|
||||
同为 1202 的「已完成过换货」响应 `data=null`,只弹出后端 `msg` 和「知道了」,不出现关联管理按钮;带有效 `data.phone` 的绑定冲突才保留原权限内的去解绑入口。两种弹窗正文都使用原始 `msg`,不再拼接手机号或固定指引。新增回归覆盖 HTTP/业务承载、null/空白/非字符串号码及资产历史数组不得绕过门槛,全套测试增至 67 项。
|
||||
|
||||
该修正的 67 项自动回归、类型检查、lint、格式、编码及严格规范校验通过。重新做浏览器检查时本地会话回到了资产首页,未完成两种新弹窗的视觉验证;未将此项标为已通过,也未操作真实换货或解绑数据。
|
||||
|
||||
## 2026-10-14:允许特殊符号与改密遮罩覆盖侧栏
|
||||
|
||||
最新密码规则恢复为 8~12 位,大写、小写、数字、半角特殊符号至少三类,禁止空白和中文等非法字符。`Admin@12345`、`ABC1234!`、`abc1234!`、`Abcdefg!` 可通过;仅两类、超长/过短、空白、中文、emoji 和控制字符拒绝。共享规则和双语文案已同步所有后台新密码表单及账号服务,不改旧密码输入、登录、C 端、操作密码或 WiFi 密码。
|
||||
|
||||
侧栏未变暗的原因是顶栏堆叠上下文(100)低于侧栏(101),改密弹窗此前在顶栏内部。加 `append-to-body` 后,DOM 检查确认实际遮罩父元素是 BODY、不在顶栏中;菜单位置命中遮罩而非菜单。1920px 和 375px 截图检查通过,整页包括侧栏一起变暗,未改变全局 z-index。
|
||||
|
||||
全套 68 项 Node 测试、类型检查、受影响文件 ESLint、该弹窗 Stylelint、格式、UTF-8 和规范校验通过。模拟页面中 `Admin@12345` 通过表单校验并发出本地 `PUT /api/auth/password` 请求,无表单规则错误。没有修改真实账号密码;工作区同时出现的设备 Excel 模板及其临时文件属于用户其他工作,未触及。
|
||||
|
||||
## 2026-10-14:全后台新密码入口复核
|
||||
|
||||
用户要求所有修改密码入口使用相同规则。全量搜索密码输入、独立校验、动态输入弹窗及密码服务调用后,确认既有后台入口均已引用 `loginPassword.ts`;共享规则修改会同时生效,不只影响顶栏弹窗。本次没有发现需要补改的后台密码表单,也不新建账号改密入口。
|
||||
|
||||
| 后台入口 | 表单文件 | 已核对字段 |
|
||||
| --- | --- | --- |
|
||||
| 本人修改密码 | `src/components/core/layouts/art-header-bar/ChangePasswordDialog.vue` | `new_password`、`confirm_password` |
|
||||
| 平台账号创建 | `src/views/account-management/account/index.vue` | `password` |
|
||||
| 店铺/企业下客户账号创建 | `src/views/common/account-list.vue` | `password` |
|
||||
| 店铺初始账号创建 | `src/views/shop-management/list/index.vue` | `init_password` |
|
||||
| 企业创建及企业修改密码 | `src/views/account-management/enterprise-customer/index.vue` | 两个表单各自的 `password` |
|
||||
|
||||
新增源码契约回归,逐项确认上述七个新密码输入使用共享提示、12 位输入上限、无 `.trim` 的绑定,以及共享校验与必填规则,没有叠加旧长度或字符正则。账号服务的可选密码修改与独立改密仍使用共享规则。仓库中未被这些表单调用的通用密码工具不改变;登录/旧密码、操作密码、WiFi/锁屏密码和公开扫码注册页继续排除。
|
||||
|
||||
可复现检查仍使用上面的 Node 测试命令;全套增至 69 项并通过,类型、测试文件 ESLint/格式、编码及 OpenSpec 严格校验通过。此轮为源码及自动回归核对,没有修改真实账号密码或新增权限编码。docs-generator 用于明确列出实际覆盖入口,并区分源码核对与真实后端联调。
|
||||
|
||||
## 2026-10-14:用户追加代理扫码注册密码规则
|
||||
|
||||
原扫码页按此前排除 C 端的范围保留了 8~32 位校验。用户现在明确要求该页及同一注册接口的 `password` 使用 8~12 位、四类至少三类、禁止空格和中文,本轮只将这项纳入,不扩大到其他 C 端功能。
|
||||
|
||||
| 证据 | 已确认结果 | 实现路径 |
|
||||
| --- | --- | --- |
|
||||
| 表单源码契约回归与共享规则测试 | 扫码页复用同一规则,输入上限 12,无 `.trim`,完整规则可见;强度反馈不把空格/中文算作有效符号 | `src/views/agent-registration/index.vue`、`loginPassword.ts` |
|
||||
| 注册服务桩测试 | 有效三类组合原样发送;过短/超长/两类/空格/中文阻止请求;原注册路径、其他字段、免 Token 和短信调用不变 | `src/api/modules/agentDistribution.ts`、`scripts/tests/octoberBatchOne.test.mjs` |
|
||||
|
||||
ui-ux-pro-max 影响本次提示处理:保留既有页面与 Element Plus 样式,完整规则独立显示并关联输入框,使用文字反馈而不只用颜色,长校验错误参与正常布局。docs-generator 用于明确记录这次范围例外和未完成的浏览器验收。
|
||||
|
||||
全套 71 项自动测试、类型检查、受影响文件 ESLint/Stylelint、格式、UTF-8、OpenSpec 严格校验及生产构建通过。当前 CUA 浏览器列表为空,IAB 和 Chrome 均返回不可用,未完成移动端视觉检查,不将其标为通过。没有发送真实短信、提交真实注册或改变任何权限编码。
|
||||
|
||||
## 2026-10-14:注册单次失败提示与公共表头拖拽
|
||||
|
||||
用户发现公开代理注册在 1050/1001 模板错误时,公共请求层与页面 catch 分别弹消息。只给原注册请求设置 `errorMessageMode: 'none'`,页面以共享映射处理非零响应或 HTTP 错误:1050/1001 显示「注册失败, 请联系管理员」,其他可读业务原因保留。短信、后台注册审核和公共 HTTP 不改。请求进行中阻止重复提交,失败保留输入,不日志输出密码。
|
||||
|
||||
代理注册申请列表还报告 `Sortable: el must be an HTMLElement`。仓库唯一 VueDraggable 位于公共表头 Popover 的列设置;原组件自动启动可能拿到未渲染/已离开的空 ref。修复改用 `useDraggable` 禁止自动启动,Popover 打开且进入后仅对真实、仍连接文档的 HTMLElement 初始化;关闭、卸载和 KeepAlive 停用销毁,晚到回调忽略。原列排序双向 model、勾选状态和按钮不变。
|
||||
|
||||
| 证据 | 已确认结果 | 实现路径 |
|
||||
| --- | --- | --- |
|
||||
| 共享错误映射及服务桩测试 | 业务/HTTP 的 1050/1001 隐藏配置细节,原注册配置关闭公共消息,短信配置不变 | `agentRegistrationError.ts`、`agentDistribution.ts` |
|
||||
| 实际扫码页 setup 执行测试 | 每种模板错误只调用一次指定消息;并发重复点击不新增请求;提交失败、加载状态及表单正确保留 | `octoberBatchOne.test.mjs`、扫码页 |
|
||||
| 编译后的表头 Vue 生命周期测试,拖拽控制器使用桩 | 首次挂载不自动启动;空/非元素/脱离节点不启动;开关、卸载和缓存切换正确清理;列顺序及 checked 保持 | `tableHeaderDragLifecycle.test.mjs`、`ArtTableHeader.vue` |
|
||||
|
||||
ui-ux-pro-max 的生命周期建议用于把拖拽实例绑定真实节点和清理事件,不做视觉改版。docs-generator 用于区分桩/组件逻辑证据与真实浏览器验收。全套 78 项 Node 测试、类型、受影响文件 lint/stylelint、格式、编码、严格规范及生产构建通过;构建仍存在此前记录的常量赋值/循环分块/大 chunk 警告。当前无浏览器连接,未声称已重放用户浏览器的 console 堆栈,也未发送真实注册、短信或修改权限。
|
||||
@@ -0,0 +1,92 @@
|
||||
# Change: 十月第 1 批后台前端对接修正
|
||||
|
||||
## Why
|
||||
|
||||
依据 [第 1 批前端对接说明](../../../docs/产品迭代10月份修改/第1批-8-9月迭代前端对接说明.md),后台现有代码仍使用旧密码校验、旧审批业务状态和旧预警规则字段,缺少订单在线支付记录与换货手机号冲突反馈。后端已部署测试环境,后台需要同步契约与交互,避免失败单据继续显示审批恢复操作、导入提示误导以及已删除字段显示异常。
|
||||
|
||||
用户已于 2026-10-13 批准实施。后台代码已完成适配,本地验证与真实后端联调状态分开记录在 [实施记录](./implementation.md)。原范围只管后台;2026-10-14 用户明确追加代理扫码注册页及同一注册接口的密码校验和失败提示,其余 `/api/c/v1` 接口及 C 端页面仍不在范围内。
|
||||
|
||||
## What Changes
|
||||
|
||||
- M3:后台订单列表和详情展示 `third_party_trade_no`、`payment_channel`、`payment_merchant_name`;详情新增支付记录表,详情类型与列表/创建类型分离,支付单状态独立于订单支付状态。
|
||||
- M8、M14:六类后台业务补充各自的「审批提交失败」终态、筛选、标签和操作判断;显式失败不再恢复原审批,结果未知保留原有恢复资格与权限判断。
|
||||
- M8:核销申请列表和详情使用真实的 `approval_submission_status` 展示审批提交状态,不能只依赖当前可能为空的名称字段;账单详情中的申请状态同步扩展。
|
||||
- M1:**BREAKING**:按 2026-10-14 用户修正,后台七个密码接口相关表单、服务和类型统一到「8~12 位,大写、小写、数字、半角特殊符号至少三类,无空格或中文」,包括后台 `PUT /api/auth/password`;账号独立改密使用 `new_password`。本人改密弹窗挂载到 body,使遮罩覆盖侧栏。旧密码输入、操作密码和 WiFi 密码不套用新规则。
|
||||
- 用户追加 M1:代理扫码注册页与 `POST /api/c/v1/agent-distribution-registrations` 的 `password` 复用相同校验;同步 12 位输入上限、可见规则及强度反馈,其他注册字段、短信、接口路径和免 Token 行为不变。
|
||||
- 用户追加注册反馈:仅原公开代理注册请求关闭公共错误消息,页面将 1050/1001 映射为「注册失败, 请联系管理员」且每次失败只提示一次,其他业务错误按其具体原因展示;不修改公共 HTTP 处理或其他接口。
|
||||
- M12:创建换货与确认完成捕获错误码 `1202`,从错误响应 `data.phone` 读取手机号,在弹窗中引导到已有「手机号资产关联」入口;不自动解绑、不新增扫码/退款前置拦截,失败时保留表单及原单状态。
|
||||
- 用户追加 M12 快捷处理:跳转携带本次新资产标识与关联手机号,关联页面自动预填筛选并勾选匹配有效记录;复用原批量解绑权限和二次确认,结果表布尔值改为中文成功/失败,不自动执行解绑。
|
||||
- M16:**BREAKING**:删除预警规则响应类型、规则列表及规则详情展示中对 `real_data_mb` 的依赖;预警列表和详情补齐 `used_mb`、`limit_mb` 及新增 `threshold_mb`,以 MB 展示触发时快照,说明包含加油包。套餐接口和套餐选项中的 `real_data_mb` 保留。
|
||||
- M2:**BREAKING**:店铺业务员批量换绑说明及前端内置模板(如有)改用固定表头 `店铺编码,操作类型,平台登录账号,备注`,注明换绑时只填写平台用户登录手机号、清空时该列留空;不兼容旧表头,保留逐行失败原因。
|
||||
- M23:设备导入文案将 IMEI 列从可选改为必填,不改变现有模板列名、列序、请求结构,也不新增 IMEI 长度、格式或重复校验;失败详情继续展示后端行号和原因。
|
||||
- M13:保留退款状态 3 的重新发起入口;若存在引导在企微重新提交的文案则移除,统一指向后台退款重提流程。
|
||||
- M4~M6 及 M16 导出补列:仅安排新建/历史导出任务下载回归,文件列由后端生成,不增加前端导出模板或修改历史文件。
|
||||
|
||||
## Scope
|
||||
|
||||
| 项目 | 后台纳入内容 | 不纳入内容 |
|
||||
| --- | --- | --- |
|
||||
| M1 | 后台七个密码接口;用户追加代理扫码注册页面及原注册接口的密码校验、失败提示 | 其他 C 端页面/接口与非登录密码 |
|
||||
| M3 | `/api/admin/orders` 列表/创建响应与详情支付记录 | C 端订单请求、支付流程 |
|
||||
| M8、M14 | 核销、退款、代理注册审核、线下充值、佣金提现、提现资料资格 | C 端注册申请及其他 `/api/c/v1` 调用 |
|
||||
| M12、M13 | 换货冲突提示、退款重提引导及回归 | 后端手机号解绑规则、企微回调实现 |
|
||||
| M16 | 预警规则与记录的展示契约、导出回归 | 预警计算、套餐商品额度调整 |
|
||||
| M2、M23 | 导入说明/已有模板表头及任务失败原因 | 后端 CSV/Excel 解析器实现 |
|
||||
| F1、M9 | 无 | H5 手机号绑定、登录响应、资产临期提醒、通知中心 |
|
||||
|
||||
### 审批失败状态与后台处理
|
||||
|
||||
| 后台业务 | 新业务状态 | 失败后的后台处理 |
|
||||
| --- | --- | --- |
|
||||
| 核销申请 | `4` | 有修改权限时,通过原 `PUT /api/admin/employee-collection-applications/{id}` 重新提交;账单重新读取可核销金额 |
|
||||
| 退款 | `7` | 有重提权限时,通过原 `POST /api/admin/refunds/{id}/resubmit` 重新发起 |
|
||||
| 代理注册审核 | `3` | 隐藏恢复审批,提示「请申请人重新扫码申请」;后台不代申请人发起 C 端注册请求 |
|
||||
| 线下充值 | `7` | 复用现有线下新建表单,通过 `POST /api/admin/agent-recharges` 新建单,不给原单补发审批 |
|
||||
| 佣金提现 | `5` | 在有操作资格的店铺提现入口,通过原 `PUT /api/admin/shops/{shop_id}/withdrawal-requests/{id}` 重新提交 |
|
||||
| 提现资料资格 | `4` | 复用已有资料提交表单,通过原 `POST /api/admin/shops/{shop_id}/withdrawal-qualifications` 提交新版本 |
|
||||
|
||||
### 不新增的能力
|
||||
|
||||
- 除用户明确追加的代理扫码注册密码规则与失败提示外,不修改其他 `/api/c/v1` 服务或页面;不改变公开注册请求路径、字段和免 Token 行为。
|
||||
- 不新增后端接口、权限编码、审批实例或财务冻结/释放逻辑。
|
||||
- 不因密码接口清单存在而补建目前没有的账号改密页面;覆盖既有页面和服务契约,新增入口须另行确认。
|
||||
- 不修改 `src/types/components.d.ts` 的用户已有改动。
|
||||
|
||||
## Impact
|
||||
|
||||
- Affected specs: `order-management`、`admin-authentication`、`employee-collection`、`refund-management`、`agent-distribution-registration`、`agent-recharge`、`commission-management`、`exchange-management`、`phone-asset-association-management`、`package-traffic-alert`、`shop-management`、`device-batch-import`。
|
||||
- Affected code:
|
||||
- `src/types/api/{order,account,employeeCollection,refund,agentDistributionRegistration,agentRecharge,commission,packageTrafficAlert}.ts` 及相关类型导出。
|
||||
- `src/api/modules/{order,account,exchange}.ts`;其余审批相关服务仅按既有接口复用,不扩展 C 端请求。
|
||||
- 用户追加:`src/views/agent-registration/index.vue`、`src/api/modules/agentDistribution.ts` 的注册密码校验与类型注释。
|
||||
- `src/views/order-management/order-list/{index,detail}.vue`。
|
||||
- `src/components/core/layouts/art-header-bar/ChangePasswordDialog.vue`、`src/views/account-management/{account,enterprise-customer}/index.vue`、`src/views/common/account-list.vue`、`src/views/shop-management/list/index.vue`。
|
||||
- `src/views/finance/employee-collection/`、`src/views/finance/refund/`、`src/views/finance/agent-recharge/`、`src/views/shop-management/agent-distribution-registrations/`。
|
||||
- `src/views/commission-management/{withdrawal-approval,my-commission}/index.vue` 及使用相同提现状态的其他后台视图。
|
||||
- `src/views/asset-management/exchange-management/{index,detail}.vue`。
|
||||
- `src/views/package-management/traffic-alert-rules/index.vue`、`src/views/package-management/traffic-alerts/{index,detail}.vue`。
|
||||
- `src/views/shop-management/business-owner-import/index.vue`、`src/views/asset-management/task-management/device-task/index.vue`。
|
||||
- `src/config/constants/{refund,commission}.ts`、新密码专用校验工具、`src/utils/business/apiError.ts`、必要的中英文文案。
|
||||
- 不引入新依赖;复用现有 Vue、Element Plus、权限、表单、错误处理和异步任务机制。
|
||||
|
||||
### 与现有提案的关系
|
||||
|
||||
当前 `openspec/specs/` 无已发布能力规范,相关功能仅存在于历史未归档提案与业务代码中,因此本次沿用既有 capability 名称,以 `ADDED Requirements` 记录本批次的独立适配约束,不伪造 `MODIFIED` 基线。
|
||||
|
||||
- 订单:承接 `update-order-management-response-semantics`,保持操作者/销售店铺/佣金语义。
|
||||
- 核销:承接 `update-employee-collection-approval-recovery`、`update-writeoff-application-and-superadmin-commission`,不回退抽屉和账单筛选优化。
|
||||
- 退款:承接 `update-refund-management`、`add-refund-approval-recovery`。旧提案允许显式提交失败恢复原审批的描述,在新业务终态 `7` 下不再适用;保留结果未知的恢复路径。
|
||||
- 代理注册:承接 `add-agent-registration-approval-management`,仅扩展后台审核状态和反馈。
|
||||
- 充值:承接 `update-agent-self-recharge-and-offline-approval`,保留线下凭证、OCR、收款方式等已有字段。
|
||||
- 佣金:承接 `add-commission-management`,保留既有店铺范围和超管选店逻辑。
|
||||
- 换货:承接 `update-exchange-refund-interception-feedback`、`update-exchange-migration-and-shop-import`,`1202` 为独立定制反馈,非 `1202` 错误继续按原逻辑展示。
|
||||
- 预警:承接 `add-package-traffic-alert`,其旧「规则展示当前真流量额度」描述被本批次规则响应契约取代。
|
||||
- 导入:承接 `update-exchange-migration-and-shop-import`、`update-device-batch-import-contract`,保留任务字段与设备模板结构。
|
||||
|
||||
## 已确认的实施依据
|
||||
|
||||
1. 用户确认没有最新 `admin-openapi.yaml`,本次不要求提供,也不将其作为实施前置条件;接口适配以第 1 批对接说明为依据,仓库中的八月 OpenAPI 不作为十月最新版。
|
||||
2. 用户于 2026-10-14 修正为允许特殊符号,恢复说明中的「四类至少三类」口径,长度 8~12 位、禁止空白和中文;半角可打印 ASCII 特殊符号均可用。此前禁止特殊符号的确认不再适用。
|
||||
3. 除 2026-10-14 明确追加的代理扫码注册页/同一注册接口的密码规则与失败提示外,其他 `/api/c/v1` 和 C 端页面仍排除。
|
||||
|
||||
以上需求疑问已消除。详见 [设计说明](./design.md)、[任务清单](./tasks.md) 与 [实施记录](./implementation.md);如联调发现实际接口与说明或用户确认不符,先向用户反馈,不自行改变口径。
|
||||
@@ -0,0 +1,107 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: 后台新登录密码统一校验
|
||||
|
||||
后台既有设置新登录密码的表单 SHALL 按 2026-10-14 用户修正规则校验:长度 8~12 位,大写字母、小写字母、数字、半角特殊符号四类至少包含三类。可打印 ASCII 标点符号 MUST 允许;空白、中文、控制字符、emoji 等非 ASCII 字符 MUST 拒绝,不静默 trim。
|
||||
|
||||
#### Scenario: 有效新密码
|
||||
|
||||
- **WHEN** 用户在后台本人改密、账号创建、店铺初始账号、企业创建或企业改密入口输入 `Abc12345`
|
||||
- **THEN** 新密码校验 MUST 通过
|
||||
- **AND** 新密码/确认密码输入限制及说明 MUST 为 8~12 位,四类字符至少包含三类,允许半角特殊符号
|
||||
- **AND** 需要确认密码的表单 MUST 验证其与新密码一致
|
||||
|
||||
#### Scenario: 无效新密码
|
||||
|
||||
- **WHEN** 用户输入 7 位、13 位、只包含两类字符的密码,或包含空白、中文、emoji 等非法字符的密码
|
||||
- **THEN** 前端 MUST 阻止提交并展示具体规则提示
|
||||
- **AND** MUST NOT 静默 trim 密码后当作合法值提交
|
||||
|
||||
#### Scenario: 含特殊符号且满足三类
|
||||
|
||||
- **WHEN** 用户输入 `Admin@12345`、`ABC1234!`、`abc1234!` 或 `Abcdefg!`
|
||||
- **THEN** 前端 MUST 按至少三类规则放行,不额外要求大写、小写和数字三者同时存在
|
||||
- **AND** 提示 MUST 不再显示「不允许特殊符号」
|
||||
|
||||
#### Scenario: 修改账号未设置新密码
|
||||
|
||||
- **WHEN** 既有账号修改操作未提供可选 `password`
|
||||
- **THEN** 页面 MUST NOT 因缺少密码阻止其他字段修改
|
||||
- **AND** MUST NOT 提交空密码覆盖原值
|
||||
- **AND** 本批次 MUST NOT 仅为接口清单补建当前没有的账号密码编辑入口
|
||||
|
||||
### Requirement: 后台密码接口字段与旧密码兼容
|
||||
|
||||
后台密码服务 SHALL 保持各接口规定的请求字段;本人改密和账号独立改密的新密码使用 `new_password`,账号创建/可选修改及企业创建/改密使用 `password`,店铺初始密码使用 `init_password`。后端字段级错误 MUST 以既有 `msg` 或提供的 `message` 展示,不替换为笼统提示,不记录密码。
|
||||
|
||||
#### Scenario: 独立修改账号密码
|
||||
|
||||
- **WHEN** 既有服务调用 `PUT /api/admin/accounts/{id}/password`
|
||||
- **THEN** 请求体 MUST 按本批次说明使用 `new_password`,而不是当前旧封装的 `password`
|
||||
- **AND** 本批次 MUST NOT 将其他账号接口的 `password` 改名
|
||||
|
||||
#### Scenario: 使用旧密码登录和本人改密
|
||||
|
||||
- **WHEN** 用户使用仍被后端接受的旧密码登录或填写本人改密 `old_password`
|
||||
- **THEN** 前端 MUST NOT 对这些旧密码输入套用新的 8~12 位/至少三类限制
|
||||
- **AND** 本人改密成功后的清理表单、清理登录态和返回登录页行为 MUST 保留
|
||||
|
||||
#### Scenario: 非登录密码与其余 C 端保持不变
|
||||
|
||||
- **WHEN** 实施本批次密码适配
|
||||
- **THEN** 操作密码、WiFi 密码和通用校验器其他调用行为 MUST 保持不变
|
||||
- **AND** 除用户明确追加的代理扫码注册密码校验及失败提示外,其余 C 端页面和 `/api/c/v1` 服务 MUST 不修改
|
||||
|
||||
#### Scenario: 展示后端字段级原因
|
||||
|
||||
- **WHEN** 密码相关请求返回包含具体校验原因的 `msg` 或 `message`
|
||||
- **THEN** 页面 MUST 展示该原因且不重复弹错
|
||||
- **AND** 请求、日志和错误反馈 MUST NOT 输出输入的密码值
|
||||
|
||||
### Requirement: 本人改密遮罩覆盖整个后台
|
||||
|
||||
本人修改密码弹窗 SHALL 使用 `append-to-body` 脱离顶栏堆叠上下文;遮罩 MUST 覆盖左侧菜单、顶栏和内容区,避免白色菜单压在遮罩上层,同时保留原表单、确认和关闭行为。
|
||||
|
||||
#### Scenario: 从顶栏打开改密弹窗
|
||||
|
||||
- **WHEN** 已登录用户打开本人修改密码弹窗
|
||||
- **THEN** 弹窗遮罩 MUST 挂载到 body,左侧菜单 MUST 与页面其他背景一起变暗且不可点击
|
||||
- **AND** 弹窗 MUST 继续支持 375px 视口,规则说明与错误提示不得重叠
|
||||
|
||||
### Requirement: 代理扫码注册密码复用统一规则
|
||||
|
||||
公开代理扫码注册表单及注册服务 SHALL 按用户明确追加范围复用后台新密码规则:8~12 位,大写字母、小写字母、数字、半角特殊符号至少三类,禁止空格和中文等非法字符,不静默 trim。注册路径、其他字段、短信验证码和免 Token 行为 MUST 保持不变,不扩大到其他 C 端功能。
|
||||
|
||||
#### Scenario: 输入有效注册密码
|
||||
|
||||
- **WHEN** 用户输入 `Abc12345`、`ABC1234!`、`abc1234!` 或 `Abcdefg!`
|
||||
- **THEN** 表单及服务 MUST 校验通过,原样发送 `password` 至既有注册接口
|
||||
- **AND** 页面 MUST 展示完整规则、12 位输入上限和「密码符合规则」反馈
|
||||
|
||||
#### Scenario: 输入无效注册密码
|
||||
|
||||
- **WHEN** 用户输入过短、过长、仅两类字符,或带空格/中文的密码
|
||||
- **THEN** 表单及服务 MUST 阻止注册提交
|
||||
- **AND** 页面 MUST 展示具体校验原因,不能把空格/中文显示为满足规则
|
||||
- **AND** 规则说明和长错误文本 MUST 正常换行,不覆盖下一个表单项
|
||||
|
||||
### Requirement: 代理扫码注册失败仅提示一次
|
||||
|
||||
原公开代理注册请求 SHALL 关闭公共错误消息,由扫码注册页面统一处理失败;后台接口、短信及其他请求 MUST 保留原错误处理。错误码 1050/1001 MUST 显示「注册失败, 请联系管理员」,不暴露企业微信审批场景/模板配置细节。
|
||||
|
||||
#### Scenario: 企业微信模板错误阻止注册
|
||||
|
||||
- **WHEN** 注册接口以业务响应或 HTTP 错误返回 1050/1001
|
||||
- **THEN** 每次失败 MUST 只显示一次「注册失败, 请联系管理员」
|
||||
- **AND** 表单 MUST 保留供重试,不能显示提交成功或再显示「分销码不可用」
|
||||
|
||||
#### Scenario: 其他注册错误
|
||||
|
||||
- **WHEN** 注册失败不是 1050/1001,且后端提供可读 `msg` 或 `message`
|
||||
- **THEN** 页面 MUST 只提示一次具体业务原因,不一律错误归因于分销码
|
||||
- **AND** 无业务消息的网络错误 MUST 使用既有安全降级提示,不记录密码
|
||||
|
||||
#### Scenario: 注册提交仍在进行
|
||||
|
||||
- **WHEN** 用户重复点击提交,且上一次注册请求尚未完成
|
||||
- **THEN** 页面 MUST 阻止并行重复提交,避免重复申请和重复失败提示
|
||||
@@ -0,0 +1,19 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: 后台代理注册审批提交失败反馈
|
||||
|
||||
后台代理注册审核 SHALL 支持业务状态 `3`「审批提交失败」的筛选和失败标签,终态下隐藏恢复审批,并提示申请人从原扫码入口重新申请。后台 MUST NOT 为重新申请调用任何 `/api/c/v1` 接口。
|
||||
|
||||
#### Scenario: 审核失败申请
|
||||
|
||||
- **WHEN** 列表或详情收到 `status=3` 的注册申请
|
||||
- **THEN** 页面 MUST 展示「审批提交失败」,查询类型和筛选 MUST 支持值 3
|
||||
- **AND** MUST 隐藏恢复审批,即使陈旧响应 `recoverable=true`
|
||||
- **AND** MUST 提示「请申请人重新扫码申请」,保留详情只读功能
|
||||
- **AND** MUST NOT 新增后台代注册提交或修改公开注册页面
|
||||
|
||||
#### Scenario: 非终态未知结果仍可恢复
|
||||
|
||||
- **WHEN** 非失败终态申请的提交结果未知,后端允许恢复且用户有原恢复权限
|
||||
- **THEN** 页面 MUST 保留原恢复审批行为并在操作后刷新详情
|
||||
- **AND** MUST NOT 把提交状态数值直接当作注册业务状态
|
||||
@@ -0,0 +1,26 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: 线下充值审批失败重新新建
|
||||
|
||||
后台线下充值 SHALL 识别业务状态 `7` 为「审批提交失败」终态,支持状态筛选和失败标签;有原创建资格的用户 SHALL 通过既有线下新建表单重新发起,使用 `POST /api/admin/agent-recharges` 新建单,而不是给原单恢复/补发审批。
|
||||
|
||||
#### Scenario: 失败单只读与终态操作
|
||||
|
||||
- **WHEN** 线下充值列表或详情展示 `status=7` 的单据
|
||||
- **THEN** 页面 MUST 展示「审批提交失败」,筛选 MUST 支持值 7
|
||||
- **AND** MUST 隐藏原单补发审批、恢复审批及仅适用于待处理单的确认/拒绝操作
|
||||
- **AND** 原权限允许的查看详情和查看凭证 MUST 保留
|
||||
|
||||
#### Scenario: 重新发起线下充值
|
||||
|
||||
- **WHEN** 具备现有线下创建资格的用户为失败单选择重新发起
|
||||
- **THEN** 页面 MUST 打开既有线下创建表单并沿用原字段校验
|
||||
- **AND** 提交 MUST 使用 `POST /api/admin/agent-recharges`,不得携带原单 ID 调用虚构重提接口
|
||||
- **AND** 新建成功后 MUST 刷新列表,不乐观将旧单状态改成成功
|
||||
|
||||
#### Scenario: 保留线上充值与原权限
|
||||
|
||||
- **WHEN** 实施终态适配
|
||||
- **THEN** 在线支付、可用方式、线下收款方式/流水号/OCR/凭证等原行为 MUST 保持不变
|
||||
- **AND** 前端 MUST NOT 为重新发起扩大原角色、店铺或创建权限
|
||||
- **AND** MUST NOT 修改 C 端接口或将未知结果自动视为失败
|
||||
@@ -0,0 +1,37 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: 佣金提现审批提交失败状态
|
||||
|
||||
后台提现审核、店铺提现记录和相关详情 SHALL 支持业务状态 `5`「审批提交失败」,各原有提现状态筛选 MUST 包含值 5;具备既有店铺操作资格的用户 SHALL 通过原提现重提接口重新提交,不复用失败审批或本地模拟冻结金额。
|
||||
|
||||
#### Scenario: 失败提现展示与操作
|
||||
|
||||
- **WHEN** 提现列表或详情收到 `status=5`
|
||||
- **THEN** 页面 MUST 展示失败标签并支持筛选值 5
|
||||
- **AND** MUST NOT 为该终态展示待审核专有审批或恢复旧审批操作
|
||||
- **AND** 可操作的店铺提现入口 MUST 支持「重新提交」,调用 `PUT /api/admin/shops/{shop_id}/withdrawal-requests/{id}`
|
||||
- **AND** 既有金额、收款信息、附件校验及店铺权限范围 MUST 保留
|
||||
|
||||
#### Scenario: 刷新已释放的冻结金额
|
||||
|
||||
- **WHEN** 失败状态已由后端释放冻结金额,或用户成功重新提交提现
|
||||
- **THEN** 页面 MUST 刷新后端佣金概览和提现记录
|
||||
- **AND** MUST NOT 前端自行增减冻结金额或推断新的冻结结果
|
||||
|
||||
### Requirement: 提现资料审批失败提交新版本
|
||||
|
||||
后台提现资料 SHALL 识别业务状态 `4` 为「审批提交失败」,展示失败标签并支持以值 4 筛选。原权限允许的用户 SHALL 使用已有资料表单提交新版本,不对失败实例恢复审批。
|
||||
|
||||
#### Scenario: 失败资料展示和重提
|
||||
|
||||
- **WHEN** 店铺提现资料返回 `status=4`
|
||||
- **THEN** 页面 MUST 展示「审批提交失败」,资料状态筛选 MUST 支持值 4
|
||||
- **AND** 有原资料提交资格时 MUST 允许复用原表单,通过 `POST /api/admin/shops/{shop_id}/withdrawal-qualifications` 提交新版本
|
||||
- **AND** 成功后 MUST 刷新版本列表,保留旧版本历史,不乐观复用旧审批
|
||||
- **AND** 原店铺隔离、附件校验和作废权限 MUST 保持不变
|
||||
|
||||
#### Scenario: 状态数值不跨业务共用
|
||||
|
||||
- **WHEN** 页面同时处理提现状态 5、资料状态 4 和佣金明细状态
|
||||
- **THEN** 前端 MUST 使用各自业务映射
|
||||
- **AND** MUST NOT 将佣金明细的状态 5「回溯」改成审批提交失败
|
||||
@@ -0,0 +1,27 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: 设备导入说明标注 IMEI 必填
|
||||
|
||||
后台设备导入说明 SHALL 将独立 IMEI 列标注为必填,不再列作可选;现有 Excel 模板列名、列数、列序和上传结构 MUST 不变,前端 MUST NOT 增加文档以外的 IMEI 格式、长度或重复限制。
|
||||
|
||||
#### Scenario: 查看导入说明和模板
|
||||
|
||||
- **WHEN** 用户打开设备导入弹窗
|
||||
- **THEN** 说明 MUST 明确 IMEI 必填,且不能因为首列允许 IMEI 作为设备标识就误认为独立 IMEI 列可省略
|
||||
- **AND** 原模板下载及列结构 MUST 保持不变
|
||||
- **AND** 其他已约定的设备标识、SN 和卡 ICCID 规则 MUST 保留
|
||||
|
||||
### Requirement: 保留设备导入行级失败反馈
|
||||
|
||||
设备导入任务详情 SHALL 继续按后端 `failed_items` 展示行号、设备标识和原因,IMEI 空值/空白导致的失败 MUST 不影响后端已成功导入的其他行。
|
||||
|
||||
#### Scenario: 混合成功与 IMEI 空值失败
|
||||
|
||||
- **WHEN** 任务详情返回某行原因「设备IMEI(imei)不能为空」和其他成功行
|
||||
- **THEN** 页面 MUST 展示该行号和原始失败原因,保留任务成功/失败计数
|
||||
- **AND** 前端 MUST NOT 因单行为空在提交前拒绝整个文件
|
||||
|
||||
#### Scenario: 全部失败
|
||||
|
||||
- **WHEN** 整个文件所有行失败,后端任务状态为失败
|
||||
- **THEN** 页面 MUST 展示后端失败状态及行级明细,不当作上传成功等于导入成功
|
||||
@@ -0,0 +1,34 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: 核销审批提交失败终态与重提
|
||||
|
||||
核销申请 SHALL 识别业务状态 `4` 为「审批提交失败」终态,申请列表、详情及账单中的关联申请状态 MUST 一致。该状态不得恢复原审批,有原修改权限的用户 SHALL 通过既有修改表单重新提交申请。
|
||||
|
||||
#### Scenario: 显式失败申请
|
||||
|
||||
- **WHEN** 核销申请 `status=4`,或账单分摊记录 `application_status=4`
|
||||
- **THEN** 页面 MUST 以失败标签展示「审批提交失败」,申请筛选 MUST 包含值 4
|
||||
- **AND** MUST 隐藏恢复审批,即使陈旧数据仍返回 `recoverable=true`
|
||||
- **AND** 有原修改权限时 MUST 允许通过 `PUT /api/admin/employee-collection-applications/{id}` 重新提交
|
||||
- **AND** MUST 保留原表单、账单分摊与权限范围
|
||||
|
||||
#### Scenario: 金额释放与重提结果
|
||||
|
||||
- **WHEN** 核销申请失败后用户刷新账单,或通过既有接口重新提交申请
|
||||
- **THEN** 页面 MUST 从后端重新读取预占和可核销金额,不本地模拟释放金额
|
||||
- **AND** 成功重提后 MUST 刷新申请与关联账单
|
||||
|
||||
### Requirement: 核销真实审批提交状态
|
||||
|
||||
核销列表和详情 SHALL 根据真实 `approval_submission_status` 展示 `0 待提交 / 1 提交中 / 2 已提交 / 3 提交失败 / 4 结果未知`;后端名称为空时 MUST 按数值回退,不仅依赖名称字段。
|
||||
|
||||
#### Scenario: 无审批上下文
|
||||
|
||||
- **WHEN** 申请返回 `approval_submission_status=0`
|
||||
- **THEN** 列表和详情 MUST 展示「待提交」,不得因 0 为 falsy 而展示为缺失
|
||||
|
||||
#### Scenario: 提交结果未知
|
||||
|
||||
- **WHEN** 提交状态为 4,业务单并非失败终态,且后端返回 `recoverable=true`
|
||||
- **THEN** 有原恢复权限的用户 MUST 仍能看到恢复审批入口
|
||||
- **AND** 前端 MUST NOT 将结果未知自行当作审批提交失败或直接生成新审批
|
||||
@@ -0,0 +1,67 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: 换货新资产手机号绑定冲突提示
|
||||
|
||||
后台创建换货和确认完成 SHALL 在错误码 `1202` 时用一次文本弹窗原样展示后端 `msg`。`1202` 同时用于已换货等业务拒绝,只有错误响应带有效字符串 `data.phone` 且用户有原查看权限时 MUST 提供解除关联跳转;处理 MUST 覆盖业务失败与 HTTP 错误,不自动解绑或扩大权限。
|
||||
|
||||
#### Scenario: 1202 返回手机号
|
||||
|
||||
- **WHEN** `POST /api/admin/exchanges` 或 `POST /api/admin/exchanges/{id}/complete` 返回 `code=1202` 且含 `data.phone`
|
||||
- **THEN** 页面 MUST 原样展示后端 `msg`,不得拼接手机号或替换为固定文案
|
||||
- **AND** 有原查看权限且已知新资产时 MUST 提供「前往手机号资产关联」按钮并带参跳转
|
||||
- **AND** 默认错误提示与该弹窗 MUST NOT 重复展示
|
||||
- **AND** 手机号 MUST 只用于用户主动发起的路由参数,不额外写日志或本地存储
|
||||
- **AND** 前端 MUST NOT 自动调用单条、批量或 CSV 解绑接口
|
||||
|
||||
#### Scenario: 号码缺失或无管理权限
|
||||
|
||||
- **WHEN** 1202 响应不含有效号码,或用户没有关联管理入口权限
|
||||
- **THEN** 页面 MUST 使用仅有「知道了」的提示弹窗原样展示 `msg`,不展示跳转/解绑按钮
|
||||
- **AND** MUST 不根据选中资产 `associated_phones` 推断该错误为手机号绑定冲突
|
||||
|
||||
#### Scenario: 已完成过换货的 1202
|
||||
|
||||
- **WHEN** 接口返回 `code=1202,data=null,msg=该资产已完成过换货,如需再次换货请使用换货后的新资产`
|
||||
- **THEN** 页面 MUST 显示该原始 `msg` 和「知道了」,不显示「前往手机号资产关联」
|
||||
|
||||
### Requirement: 换货冲突后保持数据并允许手动重试
|
||||
|
||||
1202 失败后后台 SHALL 保留当前创建表单或后端原完成状态,解除关联后允许用户手动再次提交。非 1202 错误 MUST 保留原统一反馈及业务判断。
|
||||
|
||||
#### Scenario: 创建失败保留表单
|
||||
|
||||
- **WHEN** 创建换货因 1202 被拒绝
|
||||
- **THEN** 当前新旧资产、原因、换货类型和其他表单值 MUST 保留
|
||||
- **AND** loading MUST 结束,取消提示 MUST NOT 被当作成功
|
||||
- **AND** 用户解除关联后 MUST 可手动再次提交原接口
|
||||
|
||||
#### Scenario: 确认完成被拒绝
|
||||
|
||||
- **WHEN** 确认完成接口因 1202 被拒绝
|
||||
- **THEN** 页面 MUST 刷新原换货单,并保持后端「已发货待确认」状态
|
||||
- **AND** MUST NOT 乐观标记换货完成或清空当前单据
|
||||
- **AND** 用户解除关联后 MUST 可手动重新确认
|
||||
|
||||
#### Scenario: 其他错误及原流程不变
|
||||
|
||||
- **WHEN** 换货接口返回非 1202 错误,包括退款拦截、权限失败、迁移失败或网络错误
|
||||
- **THEN** 页面 MUST 继续按原业务文案及统一错误分类反馈,不重复弹错
|
||||
- **AND** MUST NOT 新增依据扫码历史或退款状态的前置拒绝逻辑
|
||||
- **AND** 当前换货迁移字段、角色限制和接口成功行为 MUST 保持不变
|
||||
|
||||
### Requirement: 换货冲突跳转携带新资产与手机号
|
||||
|
||||
收到带有效 `data.phone` 的 1202 后,用户点击「前往手机号资产关联」时,后台 SHALL 通过 `asset_identifier` 和 `phone` 路由参数传递本次提交的新资产标识与错误响应手机号。创建换货 MUST 使用提交时选中的新卡 ICCID 或设备虚拟号;确认完成 MUST 使用换货单的新资产标识,不得带入旧资产。手机号缺失时 MUST 不从 `associated_phones` 回退生成解绑入口。
|
||||
|
||||
#### Scenario: 创建换货选择新资产后被拒
|
||||
|
||||
- **WHEN** 创建请求因新资产已有手机号关联返回 1202,用户选择跳转
|
||||
- **THEN** 路由 MUST 携带选中新资产的 `asset_identifier` 与对应 `phone`
|
||||
- **AND** 新旧资产同时存在手机号关联时 MUST NOT 使用旧资产标识或旧手机号
|
||||
- **AND** 长 ICCID MUST 保持字符串,不转为数值
|
||||
|
||||
#### Scenario: 确认完成失败后跳转
|
||||
|
||||
- **WHEN** 确认完成返回 1202,用户选择跳转
|
||||
- **THEN** 路由 MUST 携带该换货单的 `new_asset_identifier` 和错误响应手机号
|
||||
- **AND** 参数不完整时 MUST 不猜测缺失值或自动执行解绑
|
||||
@@ -0,0 +1,36 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: 后台订单在线支付摘要
|
||||
|
||||
后台订单公共类型 SHALL 接收 `third_party_trade_no`、`payment_channel`、`payment_merchant_name` 三个字符串字段;订单列表和详情 MUST 分别展示交易流水号、支付渠道和收款商户,不自行推断或补造后端未提供的值。
|
||||
|
||||
#### Scenario: 查看个人客户已支付在线订单
|
||||
|
||||
- **WHEN** 后台订单列表或详情收到个人客户微信/支付宝已支付订单的支付摘要
|
||||
- **THEN** 页面 MUST 展示后端返回的三个字段
|
||||
- **AND** `wechat`、`wechat_v2`、`fuiou` MUST 分别展示为微信直连 v3、微信直连 v2、富友
|
||||
- **AND** 未知非空渠道 MUST 保留原值,不错误映射成其他渠道
|
||||
- **AND** 已退款订单返回的原支付信息 MUST 继续展示
|
||||
|
||||
#### Scenario: 查看无在线支付摘要的订单
|
||||
|
||||
- **WHEN** 代理、钱包、线下或未支付订单的三个字段为空串
|
||||
- **THEN** 页面 MUST 统一展示 `-`,不得显示 `undefined` 或虚构渠道/商户
|
||||
- **AND** 列表和创建响应类型 MUST NOT 要求存在详情专有的 `payments`
|
||||
|
||||
### Requirement: 后台订单详情支付记录
|
||||
|
||||
后台订单详情 SHALL 使用独立于列表/创建响应的详情类型,接收并展示 `payments` 数组。支付单状态 MUST 使用独立映射 `0 待支付 / 1 已支付 / 2 已失败 / 3 已退款`,不得复用订单支付状态枚举。
|
||||
|
||||
#### Scenario: 展示多个支付尝试
|
||||
|
||||
- **WHEN** `GET /api/admin/orders/{id}` 返回多条支付记录
|
||||
- **THEN** 页面 MUST 按后端返回的创建时间倒序展示,不删除待支付或失败记录
|
||||
- **AND** MUST 展示支付单号、支付方式、渠道、商户、交易流水号、金额、状态、创建/支付/过期时间
|
||||
- **AND** 金额 MUST 从分转换为元,`paid_at`、`expire_at` 的 null 值 MUST 展示 `-`
|
||||
|
||||
#### Scenario: 无支付记录
|
||||
|
||||
- **WHEN** 订单详情返回 `payments=[]`
|
||||
- **THEN** 页面 MUST 显示支付记录空态,不报错或生成占位支付单
|
||||
- **AND** 页面 MUST NOT 为加载支付记录调用 C 端接口
|
||||
@@ -0,0 +1,41 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: 预警规则不依赖已删除额度字段
|
||||
|
||||
后台预警规则 SHALL 按本批次响应字段展示规则,响应类型、列表、详情和列选项 MUST NOT 依赖 `real_data_mb`;套餐商品接口和套餐选项的同名额度字段 MUST 保留。
|
||||
|
||||
#### Scenario: 规则响应不含额度
|
||||
|
||||
- **WHEN** 后台加载规则列表或详情且后端不再返回 `real_data_mb`
|
||||
- **THEN** 页面 MUST 不展示规则的套餐流量额度列及详情字段
|
||||
- **AND** MUST 正常展示套餐、阈值百分比、启用状态、备注和更新时间
|
||||
- **AND** MUST NOT 因删除字段显示 `undefined` 或产生类型错误
|
||||
|
||||
#### Scenario: 套餐商品额度保留
|
||||
|
||||
- **WHEN** 规则表单从 `/api/admin/packages` 加载套餐候选
|
||||
- **THEN** 套餐类型及选项中 `real_data_mb` 的原用途 MUST 保留
|
||||
- **AND** 原规则创建/修改参数与阈值百分比校验 MUST 不变
|
||||
|
||||
### Requirement: 预警记录展示主套餐与加油包流量快照
|
||||
|
||||
后台预警列表和详情 SHALL 接收并展示后端 `threshold_mb`、`used_mb`、`limit_mb`,三者单位为 MB;阈值流量 MUST 使用触发时快照,不以当前套餐额度重新计算,已用和总量说明 MUST 标注包含加油包。
|
||||
|
||||
#### Scenario: 展示预警流量
|
||||
|
||||
- **WHEN** 预警列表或详情返回三项 MB 数值
|
||||
- **THEN** 页面 MUST 展示「阈值流量(MB)」「已用流量(MB,含加油包)」「总流量(MB,含加油包)」或同等明确标签
|
||||
- **AND** MUST 以两位小数展示,不混用规则百分比或 GB 数值
|
||||
- **AND** MUST NOT 使用当前套餐商品或前端计算覆盖 `threshold_mb`
|
||||
|
||||
#### Scenario: 零与缺失值
|
||||
|
||||
- **WHEN** 流量值为 0、null 或缺失
|
||||
- **THEN** 0 MUST 展示 `0.00`,null/缺失 MUST 展示 `-`
|
||||
- **AND** MUST NOT 把 0 显示为缺失或将缺失值当作 0
|
||||
|
||||
#### Scenario: 导出仍由后端生成
|
||||
|
||||
- **WHEN** 用户创建预警导出任务或下载历史文件
|
||||
- **THEN** 前端 MUST 复用原导出任务流程,不新增前端列模板或重写历史文件
|
||||
- **AND** 本批次验收 MUST 检查新任务最后一列阈值流量及历史任务原文件不变
|
||||
@@ -0,0 +1,34 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: 按换货新资产与手机号预填查询并勾选
|
||||
|
||||
手机号资产关联页面 SHALL 读取路由 `asset_identifier` 和 `phone`,预填筛选并从 `page=1,page_size=20` 请求列表。用户具备原批量解绑权限时,页面 MUST 默认勾选同时匹配资产标识、手机号且 `status=1` 的当前页记录,旧资产、其他手机号和已失效记录不得勾选。
|
||||
|
||||
#### Scenario: 从换货冲突入口进入
|
||||
|
||||
- **WHEN** 路由携带新资产和手机号参数
|
||||
- **THEN** 页面 MUST 使用两项参数调用 `GET /api/admin/phone-asset-associations`
|
||||
- **AND** 数据渲染后 MUST 实际勾选匹配有效记录,使已有批量解绑按钮可用
|
||||
- **AND** MUST 保留解除原因必填与二次确认,不自动发送解绑请求
|
||||
|
||||
#### Scenario: 缓存页面再次接收另一资产
|
||||
|
||||
- **WHEN** 关联页面已存在缓存或同一路径查询参数改变
|
||||
- **THEN** 页面 MUST 重置分页、筛选和旧勾选并重新查询新的两项条件
|
||||
- **AND** 过期请求 MUST NOT 覆盖最新数据或选中新目标以外的行
|
||||
|
||||
#### Scenario: 参数缺失、手动筛选或解绑后刷新
|
||||
|
||||
- **WHEN** 两项参数不完整、用户修改筛选/翻页、手工取消选择或完成批量解绑
|
||||
- **THEN** 页面 MUST NOT 将无关记录全选或恢复旧勾选
|
||||
- **AND** 无批量解绑权限时 MUST NOT 显示可执行的批量解绑入口
|
||||
|
||||
### Requirement: 批量解绑逐项结果使用中文
|
||||
|
||||
批量解绑结果表 SHALL 将 `success=true` 展示为「解绑成功」,`success=false` 展示为「解绑失败」,保留中文汇总、解除关系数及后端失败原因,不显示原始布尔值。
|
||||
|
||||
#### Scenario: 显示成功或失败结果
|
||||
|
||||
- **WHEN** 后端返回批量解绑逐项结果
|
||||
- **THEN** 结果列 MUST 使用中文成功/失败标签,不显示 `true` 或 `false`
|
||||
- **AND** 失败原因、统计值及原结果布尔类型 MUST 保持原后端契约
|
||||
@@ -0,0 +1,36 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: 退款审批提交失败状态与后台重提
|
||||
|
||||
退款后台 SHALL 识别业务状态 `7` 为「审批提交失败」终态,列表与详情 MUST 支持该状态展示和筛选。有原重提权限的用户 SHALL 使用原退款重提表单重新发起,不得恢复失败单的原审批。
|
||||
|
||||
#### Scenario: 显式提交失败
|
||||
|
||||
- **WHEN** 退款记录 `status=7`
|
||||
- **THEN** 列表和详情 MUST 展示失败标签,状态筛选 MUST 允许值 7
|
||||
- **AND** MUST 隐藏恢复及补发审批,不因陈旧 `approval_recoverable=true` 重新显示
|
||||
- **AND** 有重提权限时 MUST 通过 `POST /api/admin/refunds/{id}/resubmit` 重新发起
|
||||
- **AND** 成功后 MUST 刷新记录,不复用旧审批实例
|
||||
|
||||
#### Scenario: 不混淆原路退款失败
|
||||
|
||||
- **WHEN** 退款记录 `status=6`
|
||||
- **THEN** 页面 MUST 继续按原「原路退款失败」含义及 `anomaly_flag` 限制处理
|
||||
- **AND** MUST NOT 将该状态改成审批提交失败或放宽其原有异常限制
|
||||
|
||||
#### Scenario: 结果未知保留恢复资格
|
||||
|
||||
- **WHEN** 退款提交结果未知,业务状态不是 7,后端允许恢复且用户有原权限
|
||||
- **THEN** 页面 MUST 保留恢复审批入口
|
||||
- **AND** MUST NOT 直接把未知结果改成终态或创建重复申请
|
||||
|
||||
### Requirement: 退款企微结束后使用后台重新发起
|
||||
|
||||
后台退款页面 SHALL 对企微拒绝/撤销/删除后返回的 `status=3` 按「已拒绝」处理,允许符合原权限和规则的后台重提。页面 MUST NOT 引导用户在企微重新提交作为后台退款重提方式。
|
||||
|
||||
#### Scenario: 已拒绝退款重新发起
|
||||
|
||||
- **WHEN** 用户查看状态 3 的退款,且具备原重提权限
|
||||
- **THEN** 页面 MUST 保留后台重新发起入口并调用原 `resubmit` 接口
|
||||
- **AND** 若存在「在企微重新提交」文案,MUST 移除或改为后台重新发起指引
|
||||
- **AND** 换货资格 MUST 仍由换货接口判断,不新增退款状态前置拦截
|
||||
@@ -0,0 +1,19 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: 业务员批量换绑使用平台登录手机号表头
|
||||
|
||||
后台业务员批量换绑页面 SHALL 将说明及已有前端内置模板(如有)统一为固定表头 `店铺编码,操作类型,平台登录账号,备注`,说明「平台登录账号」仅填写平台用户登录手机号。请求路径、结构、逐行结果和已有任务信息 MUST 保持不变。
|
||||
|
||||
#### Scenario: 换绑说明和清空规则
|
||||
|
||||
- **WHEN** 用户查看导入说明或下载已有前端模板
|
||||
- **THEN** 表头 MUST 使用「平台登录账号」,不得保留「业务员登录账号」
|
||||
- **AND** MUST 说明换绑时填写平台用户登录手机号而非用户名,清空时该列留空
|
||||
- **AND** MUST NOT 自动兼容/转换旧表头或把用户名转换为手机号
|
||||
|
||||
#### Scenario: 展示逐行失败
|
||||
|
||||
- **WHEN** 后端返回表头错误或行级格式不对、手机号不存在、非平台用户、账号禁用、多账号匹配等原因
|
||||
- **THEN** 页面 MUST 原样展示后端原因
|
||||
- **AND** 混合结果 MUST 保留成功行与失败行,不因部分失败改为前端整批拒绝
|
||||
- **AND** 接口 MUST 继续使用 `POST /api/admin/shops/business-owner-imports`
|
||||
@@ -0,0 +1,89 @@
|
||||
## 1. 实施前核对
|
||||
|
||||
- [x] 1.1 用户于 2026-10-13 批准实施,仅后台,不修改 `/api/c/v1`。
|
||||
- [x] 1.2 按说明落实账号独立改密、核销提交状态、预警字段和错误响应,不依赖最新 OpenAPI。
|
||||
- [x] 1.3 按已确认密码规则准备长度、字符类别、非法字符及旧密码边界用例。
|
||||
- [x] 1.4 核对旧提案与代码,保留权限、核销抽屉、店铺范围、原换货流程及用户改动。
|
||||
|
||||
## 2. 订单在线支付信息(M3)
|
||||
|
||||
- [x] 2.1 补订单公共摘要字段、独立支付单状态与详情类型,列表/创建不要求 `payments`。
|
||||
- [x] 2.2 列表和详情展示三项支付摘要、渠道映射、未知值及空值。
|
||||
- [x] 2.3 详情支付表展示字段、金额、独立状态及空时间,保留失败记录和后端顺序。
|
||||
|
||||
## 3. 审批提交失败终态(M8、M14)
|
||||
|
||||
- [x] 3.1 核销状态 4、筛选/标签、关联申请和真实提交状态;支持原表单重提,终态隐藏恢复。
|
||||
- [x] 3.2 退款状态 7、筛选/标签和原 resubmit,终态禁止恢复/补发,状态 6 异常限制保留。
|
||||
- [x] 3.3 后台代理注册状态 3、筛选/标签和重新扫码指引,终态隐藏恢复,不改 C 端。
|
||||
- [x] 3.4 线下充值状态 7、筛选/标签及操作判断,复用原创建权限/表单发起新单。
|
||||
- [x] 3.5 提现状态 5、相关后台筛选/标签/详情、原重提入口及概览刷新,不本地模拟金额。
|
||||
- [x] 3.6 资料资格状态 4、筛选/标签和原资料表单提交新版本。
|
||||
- [x] 3.7 本地代码与逻辑测试复核终态/未知结果、只读操作和权限判断;财务事实随 7.3 联调。
|
||||
|
||||
## 4. 后台新密码规则(M1)
|
||||
|
||||
- [x] 4.1 按 2026-10-14 修正,新密码 8~12 位,允许半角特殊符号,四类至少三类,拒绝空白/中文等字符,不 trim。
|
||||
- [x] 4.2 本人改密新密码/确认限制及双语说明;旧密码仅必填,原成功行为保持;错误换行不重叠。
|
||||
- [x] 4.3 账号及客户账号创建接入校验,可选修改空密码不发送,不新增入口。
|
||||
- [x] 4.4 账号独立改密改为 `new_password`,其他字段不改名。
|
||||
- [x] 4.5 店铺初始密码、企业创建/改密接入校验及 maxlength。
|
||||
- [x] 4.6 兼容 `msg`/`message`,受影响密码操作检查非零业务码且不记录带密码的错误对象;其他密码与 C 端不改。
|
||||
|
||||
## 5. 换货手机号冲突反馈(M12)
|
||||
|
||||
- [x] 5.1 两入口共用 1202 提取/提示,兼容业务与 HTTP 错误和无号码降级。
|
||||
- [x] 5.2 创建保留表单,完成失败重新读原单,用户解除后手动重试。
|
||||
- [x] 5.3 按已有权限指引,不自动解绑、记录或持久化号码。
|
||||
- [x] 5.4 非 1202 保持后端原因与原错误分类,不新增前置检查或重复默认提示。
|
||||
|
||||
## 6. 预警口径与导入说明(M16、M2、M23)
|
||||
|
||||
- [x] 6.1 删除规则额度引用,保留套餐商品/候选额度及规则参数。
|
||||
- [x] 6.2 补三项 MB 快照、两位小数、0/空值与加油包说明,不重算历史阈值。
|
||||
- [x] 6.3 新 CSV 表头及说明;下载从统一 UTF-8 BOM 文本生成,原 GBK 文件保留,逐行结果不变。
|
||||
- [x] 6.4 IMEI 说明改必填,原 Excel 模板及上传/失败明细保持,不加格式或去重限制。
|
||||
|
||||
## 7. 回归与验收
|
||||
|
||||
- [x] 7.1 未发现引导企微重提的后台文案;本地测试确认状态 3 仍允许后台重提,真实流程随 7.3 联调。
|
||||
- [ ] 7.2 检查订单个人在线已支付/已退款信息,未支付及代理/钱包/线下空字段,详情多个支付记录的顺序、金额、状态和空时间。
|
||||
- [ ] 7.3 检查六类失败终态、状态筛选、恢复隐藏、重提入口;覆盖陈旧 recoverable=true、结果未知、无权限及刷新财务数据。
|
||||
- [x] 7.4 本地规则与改密页检查长度、三类、非法字符、可选空密码及旧密码兼容;375px 错误文案不重叠,其他密码代码未改。
|
||||
- [ ] 7.5 检查换货两入口 1202 有/无号码、无管理权限、用户取消、解除后重试和其他错误;确认日志不含号码、原完成状态不被误改。
|
||||
- [x] 7.6 本地规则/详情页与数值测试确认规则无额度、套餐字段保留、三项 MB/0/空值及加油包文案。
|
||||
- [ ] 7.7 检查 CSV 新/旧表头、用户名误填、清空行和混合成功失败;检查设备 IMEI 空白行、部分成功、全失败以及模板未改变。
|
||||
- [ ] 7.8 新建订单/IoT 卡/设备/预警导出任务检查后端新增列,下载历史任务检查旧列仍在;不修改前端导出模板或历史文件。
|
||||
- [x] 7.9 本地 63 项测试、受影响文件 lint、类型检查、生产构建、UTF-8、OpenSpec 严格校验通过;模拟页面检查通过,真实环境项单列。
|
||||
- [x] 7.10 C 端页面/服务无差异,组件声明 SHA-256 与实施前一致;回写实际完成和待联调项。
|
||||
- [ ] 7.11 完成真实测试环境联调及用户验收后归档,不以模拟页面替代后端验收。
|
||||
|
||||
7.2、7.3、7.5、7.7 的本地逻辑与部分模拟页面已覆盖;尚未验证真实支付、冻结/预占金额、解除后重试、导入结果与导出文件。复现方式及证据见 [实施记录](./implementation.md)。
|
||||
|
||||
## 8. 换货冲突关联管理快捷处理(用户追加)
|
||||
|
||||
- [x] 8.1 两个换货入口携带当前新资产标识和关联手机号跳转,提交时冻结目标,禁止旧资产回退。
|
||||
- [x] 8.2 关联页预填两项筛选,默认 1 页/20 条,仅勾选匹配有效记录;缓存、参数变化、过期响应和手工筛选清除旧选择。
|
||||
- [x] 8.3 复用原批量解绑权限、原因与二次确认,结果布尔值改中文成功/失败。
|
||||
- [x] 8.4 66 项回归测试通过,本地完整跳转、实际勾选、手工取消及模拟批量结果验证通过;未操作真实资产。
|
||||
- [x] 8.5 按用户修正区分共用 1202:`data=null` 只展示原始 `msg` 和「知道了」,仅带有效响应手机号才提供去解绑;不从历史数组回退。新增回归,全套 67 项通过。
|
||||
|
||||
## 9. 密码特殊符号与侧栏遮罩修正(2026-10-14)
|
||||
|
||||
- [x] 9.1 专用校验恢复四类至少三类,允许所有可打印 ASCII 标点,同步中英文提示、类型注释和回归测试。
|
||||
- [x] 9.2 本人改密弹窗挂载到 body,修复左侧菜单未被遮罩覆盖,不调整全局顶栏/侧栏层级。
|
||||
- [x] 9.3 全套 68 项自动测试、类型/lint/stylelint 检查通过;本地桌面和 375px 页面确认遮罩覆盖侧栏,含符号密码发出模拟改密请求,没有修改真实密码。
|
||||
- [x] 9.4 按用户要求全量核对后台新密码入口,确认五个文件中的七个输入统一校验/说明/长度且不 trim;补源码契约回归,全套 69 项通过,记录覆盖范围,不修改其他密码或新增权限。
|
||||
|
||||
## 10. 用户追加:代理扫码注册密码(2026-10-14)
|
||||
|
||||
- [x] 10.1 仅将代理扫码注册页及原注册接口的密码校验纳入,保持其他 C 端范围排除,同步规范。
|
||||
- [x] 10.2 表单和注册服务复用统一规则;输入上限 12,完整规则独立显示,强度反馈不误认空格/中文,不 trim 密码。
|
||||
- [x] 10.3 添加有效/无效密码、原字段/路径/免 Token/短信不变的回归;全套 71 项测试与类型、lint、stylelint、格式、编码、规范和生产构建检查通过。
|
||||
- [ ] 10.4 当前浏览器连接不可用,扫码页移动端视觉和真实后端注册联调待验收;未发送真实短信或注册申请。
|
||||
|
||||
## 11. 用户追加:注册错误提示与表头拖拽修复
|
||||
|
||||
- [x] 11.1 仅公开注册关闭公共消息,1050/1001 统一指定文案,其他错误按具体原因;失败保留表单,提交中阻止重复请求。
|
||||
- [x] 11.2 公共列设置拖拽延后启动,校验真实且连接文档的 DOM;关闭/卸载/缓存停用销毁,列勾选和排序 model 保持。
|
||||
- [x] 11.3 新增页面单次消息、HTTP/业务映射、表头生命周期回归,全套 78 项、类型、lint/stylelint、格式、编码、规范及生产构建通过;真实浏览器和后台验收仍待完成。
|
||||
@@ -0,0 +1,18 @@
|
||||
# Change: 新建订单套餐作废任务支持下载 CSV 模板
|
||||
|
||||
## Why
|
||||
|
||||
运营创建订单套餐批量作废任务时,需要按系统要求准备订单号 CSV。当前创建抽屉只有文件上传入口,无法直接取得格式样例,容易因文件列格式不符而返工。
|
||||
|
||||
## What Changes
|
||||
|
||||
- 在新建订单套餐作废任务抽屉的 CSV 上传项旁提供“下载模板”入口。
|
||||
- 下载仓库中已有的静态模板 `src/template/订单批量作废模板.csv`,保留其 `order_no` 表头,不增加模板生成接口。
|
||||
- 不改变现有 CSV 上传校验、任务创建、权限或后端接口。
|
||||
|
||||
## Impact
|
||||
|
||||
- Affected specs: `order-package-invalidate-task`
|
||||
- Affected code: `src/views/asset-management/task-management/order-package-invalidate-task/index.vue`
|
||||
- Existing user-provided asset: `src/template/订单批量作废模板.csv`(只读取,不修改)
|
||||
- Breaking changes: 无。
|
||||
@@ -0,0 +1,13 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Order Package Invalidation CSV Template Download
|
||||
|
||||
The admin frontend SHALL let users creating an order package invalidation task download the CSV template used by the task's CSV upload field.
|
||||
|
||||
#### Scenario: Download the static CSV template
|
||||
|
||||
- **GIVEN** 用户已打开新建订单套餐作废任务抽屉
|
||||
- **WHEN** 用户点击 CSV 上传项旁的模板下载入口
|
||||
- **THEN** 页面 MUST 下载静态文件 `订单批量作废模板.csv`
|
||||
- **AND** 下载内容 MUST match `src/template/订单批量作废模板.csv`, including the `order_no` header
|
||||
- **AND** 页面 MUST NOT make a template-generation API request
|
||||
@@ -0,0 +1,4 @@
|
||||
## 1. Implementation
|
||||
|
||||
- [x] 1.1 在订单套餐作废任务创建抽屉中添加静态 CSV 模板下载入口。
|
||||
- [x] 1.2 验证下载内容、文件名与现有模板一致,并运行相关前端检查。
|
||||
288
scripts/tests/assetBindingCardRender.test.mjs
Normal file
288
scripts/tests/assetBindingCardRender.test.mjs
Normal file
@@ -0,0 +1,288 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import ts from 'typescript'
|
||||
import * as vue from 'vue'
|
||||
import { compileScript, parse } from '@vue/compiler-sfc'
|
||||
|
||||
function evaluate(source, imports) {
|
||||
const compiled = ts.transpileModule(source, {
|
||||
compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.CommonJS }
|
||||
}).outputText
|
||||
const module = { exports: {} }
|
||||
new Function('require', 'module', 'exports', compiled)(
|
||||
(name) => {
|
||||
assert.ok(imports[name], `Unexpected runtime dependency: ${name}`)
|
||||
return imports[name]
|
||||
},
|
||||
module,
|
||||
module.exports
|
||||
)
|
||||
return module.exports
|
||||
}
|
||||
|
||||
const basePath = 'src/views/asset-management/asset-information'
|
||||
const { descriptor } = parse(readFileSync(`${basePath}/components/BasicInfoCard.vue`, 'utf8'))
|
||||
const componentSource = compileScript(descriptor, {
|
||||
id: 'binding-card-test',
|
||||
inlineTemplate: true
|
||||
}).content
|
||||
const formatters = evaluate(readFileSync(`${basePath}/composables/useAssetFormatters.ts`, 'utf8'), {
|
||||
'@/config/constants/carrierTypes': {
|
||||
getCarrierTypeLabel: (code) => ({ CTCC: '中国电信', CMCC: '中国移动' })[code] || code
|
||||
}
|
||||
})
|
||||
|
||||
function createHostNode(tag, text = '') {
|
||||
return {
|
||||
tag,
|
||||
text,
|
||||
props: {},
|
||||
children: [],
|
||||
parentNode: null,
|
||||
removeChild(child) {
|
||||
const index = this.children.indexOf(child)
|
||||
assert.notEqual(index, -1)
|
||||
this.children.splice(index, 1)
|
||||
child.parentNode = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mountBasicInfo(t, userType, permissions = []) {
|
||||
const user = vue.reactive({ info: { id: userType, user_type: userType }, permissions })
|
||||
const hasAuth = (permission) =>
|
||||
Number(user.info.user_type) === 1 || user.permissions.includes(permission)
|
||||
user.hasPermission = hasAuth
|
||||
user.hasButton = hasAuth
|
||||
const elements = Object.fromEntries(
|
||||
[
|
||||
'ElCard',
|
||||
'ElDescriptions',
|
||||
'ElDescriptionsItem',
|
||||
'ElTag',
|
||||
'ElTooltip',
|
||||
'ElSwitch',
|
||||
'ElDivider',
|
||||
'ElButton',
|
||||
'ElAlert',
|
||||
'ElEmpty'
|
||||
].map((name) => [
|
||||
name,
|
||||
vue.defineComponent({
|
||||
name,
|
||||
setup:
|
||||
(_, { slots, attrs }) =>
|
||||
() =>
|
||||
vue.h(name, attrs, [slots.header?.(), slots.default?.()])
|
||||
})
|
||||
])
|
||||
)
|
||||
const component = evaluate(componentSource, {
|
||||
vue,
|
||||
'@vueuse/core': { useWindowSize: () => ({ width: vue.ref(1200) }) },
|
||||
'element-plus': { ...elements, ElMessageBox: {}, ElMessage: {} },
|
||||
'@element-plus/icons-vue': {
|
||||
CopyDocument: vue.defineComponent(() => () => vue.h('copy-icon'))
|
||||
},
|
||||
'../composables/useAssetFormatters': formatters,
|
||||
'@/composables/useAuth': { useAuth: () => ({ hasAuth }) },
|
||||
'@/store/modules/user': { useUserStore: () => user },
|
||||
'@/config/constants': {
|
||||
JULY_PERMISSIONS: { speedTier: { view: 'speed:view', update: 'speed:update' } }
|
||||
},
|
||||
'@/utils/business/format': { formatDateTime: (value) => String(value || '') },
|
||||
'@/utils/business/expiryEstimate': {
|
||||
getExpiryEstimateText: () => '-',
|
||||
getExpiryEstimateTooltip: () => '',
|
||||
getExpiryEstimateClass: () => ''
|
||||
},
|
||||
'@/config/constants/audit': { AUDIT_PERMISSIONS: {} },
|
||||
'@/utils/business/auditNavigation': { resolveAuditResourceTarget: () => null },
|
||||
'@/components/business/audit/investigationController': { openAuditInvestigation: () => {} }
|
||||
}).default
|
||||
const renderer = vue.createRenderer({
|
||||
createElement: (tag) => createHostNode(tag),
|
||||
createText: (text) => createHostNode('#text', text),
|
||||
createComment: (text) => createHostNode('#comment', text),
|
||||
setText: (node, text) => {
|
||||
node.text = text
|
||||
},
|
||||
setElementText: (node, text) => {
|
||||
node.text = text
|
||||
node.children = []
|
||||
},
|
||||
parentNode: (node) => node.parentNode,
|
||||
nextSibling: (node) => {
|
||||
const siblings = node.parentNode?.children || []
|
||||
return siblings[siblings.indexOf(node) + 1] || null
|
||||
},
|
||||
patchProp: (node, key, _, value) => {
|
||||
node.props[key] = value
|
||||
},
|
||||
insert: (node, parent, anchor) => {
|
||||
node.parentNode?.removeChild(node)
|
||||
const index = anchor ? parent.children.indexOf(anchor) : parent.children.length
|
||||
assert.notEqual(index, -1, 'Vue tried to insert beside a node removed outside its renderer')
|
||||
parent.children.splice(index, 0, node)
|
||||
node.parentNode = parent
|
||||
},
|
||||
remove: (node) => node.parentNode?.removeChild(node)
|
||||
})
|
||||
const asset = vue.reactive({
|
||||
asset_type: 'device',
|
||||
asset_id: 101,
|
||||
identifier: 'DEVICE-A',
|
||||
cards: [
|
||||
{
|
||||
iccid: 'CARD-1',
|
||||
msisdn: '13800000001',
|
||||
carrier_name: '平台运营商账户',
|
||||
carrier_type: 'CTCC',
|
||||
slot_position: 1,
|
||||
is_current: true,
|
||||
network_status: 1
|
||||
},
|
||||
{
|
||||
iccid: 'CARD-2',
|
||||
msisdn: '13800000002',
|
||||
carrier_name: '第二运营商账户',
|
||||
carrier_type: 'CMCC',
|
||||
slot_position: 2,
|
||||
is_current: false,
|
||||
network_status: 0
|
||||
}
|
||||
]
|
||||
})
|
||||
const root = createHostNode('root')
|
||||
const app = renderer.createApp({
|
||||
render: () => vue.h(component, { cardInfo: asset, deviceRealtime: null, pollingEnabled: false })
|
||||
})
|
||||
const directives = evaluate(readFileSync('src/directives/permission.ts', 'utf8'), {
|
||||
'@/store/modules/user': { useUserStore: () => user }
|
||||
})
|
||||
directives.setupPermissionDirective(app)
|
||||
app.directive('loading', {})
|
||||
app.component(
|
||||
'el-icon',
|
||||
vue.defineComponent({
|
||||
setup:
|
||||
(_, { slots }) =>
|
||||
() =>
|
||||
vue.h('icon', slots.default?.())
|
||||
})
|
||||
)
|
||||
app.mount(root)
|
||||
t.after(() => app.unmount())
|
||||
return { root, asset, user }
|
||||
}
|
||||
|
||||
const textOf = (node) =>
|
||||
node.tag === '#comment' ? '' : node.text + node.children.map(textOf).join('')
|
||||
const nodesWithClass = (node, className) => [
|
||||
...(String(node.props.class || '')
|
||||
.split(' ')
|
||||
.includes(className)
|
||||
? [node]
|
||||
: []),
|
||||
...node.children.flatMap((child) => nodesWithClass(child, className))
|
||||
]
|
||||
|
||||
test('all account types render both binding cards; only the established carrier label rule differs', async (t) => {
|
||||
for (const userType of [1, 2, 3, 4]) {
|
||||
const { root } = mountBasicInfo(t, userType)
|
||||
await vue.nextTick()
|
||||
const cards = nodesWithClass(root, 'binding-card')
|
||||
assert.equal(cards.length, 2)
|
||||
assert.match(textOf(cards[0]), /CARD-1/)
|
||||
assert.match(textOf(cards[1]), /CARD-2/)
|
||||
assert.match(textOf(cards[0]), /13800000001/)
|
||||
assert.match(textOf(cards[0]), userType < 3 ? /平台运营商账户/ : /中国电信/)
|
||||
}
|
||||
})
|
||||
|
||||
test('permission changes and current-card/status updates preserve card data without external DOM removal', async (t) => {
|
||||
const { root, asset, user } = mountBasicInfo(t, 3, ['iot_info:stop'])
|
||||
await vue.nextTick()
|
||||
assert.match(textOf(nodesWithClass(root, 'binding-card-actions')[0]), /停用此卡/)
|
||||
user.permissions = ['iot_info:start', 'bound_card:update_realname_status']
|
||||
asset.cards[0].network_status = 0
|
||||
asset.cards[0].is_current = false
|
||||
asset.cards[1].is_current = true
|
||||
await vue.nextTick()
|
||||
const cards = nodesWithClass(root, 'binding-card')
|
||||
assert.equal(cards.length, 2)
|
||||
assert.match(textOf(cards[0]), /CARD-2/)
|
||||
assert.match(textOf(cards[1]), /CARD-1/)
|
||||
assert.match(textOf(nodesWithClass(cards[1], 'binding-card-actions')[0]), /启用此卡/)
|
||||
assert.match(textOf(nodesWithClass(cards[1], 'binding-card-actions')[0]), /更新实名状态/)
|
||||
assert.doesNotMatch(textOf(nodesWithClass(cards[1], 'binding-card-actions')[0]), /停用此卡/)
|
||||
user.permissions = []
|
||||
await vue.nextTick()
|
||||
assert.equal(nodesWithClass(root, 'binding-card').length, 2)
|
||||
for (const actions of nodesWithClass(root, 'binding-card-actions'))
|
||||
assert.equal(textOf(actions).trim(), '')
|
||||
})
|
||||
|
||||
test('missing network status renders unknown and exposes neither start nor stop', async (t) => {
|
||||
const { root, asset } = mountBasicInfo(t, 3, ['iot_info:start', 'iot_info:stop'])
|
||||
delete asset.cards[0].network_status
|
||||
await vue.nextTick()
|
||||
const card = nodesWithClass(root, 'binding-card')[0]
|
||||
assert.match(textOf(card), /网络状态未知/)
|
||||
assert.doesNotMatch(textOf(nodesWithClass(card, 'binding-card-actions')[0]), /启用此卡|停用此卡/)
|
||||
})
|
||||
|
||||
test('read-only accounts render realtime start/stop transitions without losing binding-card nodes', async (t) => {
|
||||
for (const userType of [2, 3, 4]) {
|
||||
const { root, asset } = mountBasicInfo(t, userType)
|
||||
asset.cards[0].network_status = 0
|
||||
await vue.nextTick()
|
||||
assert.equal(nodesWithClass(root, 'binding-card').length, 2)
|
||||
assert.match(textOf(nodesWithClass(root, 'binding-card')[0]), /网络状态停机/)
|
||||
asset.cards[0].network_status = 1
|
||||
await vue.nextTick()
|
||||
assert.match(textOf(nodesWithClass(root, 'binding-card')[0]), /网络状态正常/)
|
||||
for (const actions of nodesWithClass(root, 'binding-card-actions')) {
|
||||
assert.equal(textOf(actions).trim(), '')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
test('current-first sorting does not mutate source cards; zero, one, and multiple bindings render stably', async (t) => {
|
||||
const { root, asset } = mountBasicInfo(t, 2)
|
||||
const originalOrder = asset.cards.map((card) => card.iccid)
|
||||
asset.cards[0].is_current = false
|
||||
asset.cards[1].is_current = true
|
||||
await vue.nextTick()
|
||||
assert.deepEqual(
|
||||
asset.cards.map((card) => card.iccid),
|
||||
originalOrder
|
||||
)
|
||||
assert.match(textOf(nodesWithClass(root, 'binding-card')[0]), /CARD-2/)
|
||||
asset.cards = [asset.cards[1]]
|
||||
await vue.nextTick()
|
||||
assert.equal(nodesWithClass(root, 'binding-card').length, 1)
|
||||
asset.cards = []
|
||||
await vue.nextTick()
|
||||
assert.equal(nodesWithClass(root, 'binding-card').length, 0)
|
||||
})
|
||||
|
||||
test('device/card type switches and denied actions do not leave removed DOM anchors', async (t) => {
|
||||
const { root, asset, user } = mountBasicInfo(t, 3)
|
||||
asset.asset_type = 'card'
|
||||
asset.iccid = 'CARD-1'
|
||||
asset.network_status = 1
|
||||
await vue.nextTick()
|
||||
asset.network_status = 0
|
||||
await vue.nextTick()
|
||||
assert.equal(textOf(nodesWithClass(root, 'card-operations')[0]).trim(), '')
|
||||
user.permissions = ['iot_info:start']
|
||||
await vue.nextTick()
|
||||
assert.match(textOf(nodesWithClass(root, 'card-operations')[0]), /启用此卡/)
|
||||
asset.asset_type = 'device'
|
||||
user.permissions = ['device_info:reboot']
|
||||
await vue.nextTick()
|
||||
assert.equal(nodesWithClass(root, 'binding-card').length, 2)
|
||||
assert.match(textOf(nodesWithClass(root, 'device-operations')[0]), /重启设备/)
|
||||
})
|
||||
686
scripts/tests/assetInfoState.test.mjs
Normal file
686
scripts/tests/assetInfoState.test.mjs
Normal file
@@ -0,0 +1,686 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import ts from 'typescript'
|
||||
import * as vue from 'vue'
|
||||
import { parse } from '@vue/compiler-sfc'
|
||||
|
||||
const sourcePath = 'src/views/asset-management/asset-information/composables/useAssetInfo.ts'
|
||||
const compiledSource = ts.transpileModule(readFileSync(sourcePath, 'utf8'), {
|
||||
compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.CommonJS }
|
||||
}).outputText
|
||||
|
||||
const response = (data) => ({ code: 0, data })
|
||||
const deferred = () => {
|
||||
let resolve, reject
|
||||
const promise = new Promise((resolvePromise, rejectPromise) => {
|
||||
resolve = resolvePromise
|
||||
reject = rejectPromise
|
||||
})
|
||||
return { promise, resolve, reject }
|
||||
}
|
||||
|
||||
const boundCards = () => [
|
||||
{
|
||||
card_id: 11,
|
||||
iccid: 'CARD-1',
|
||||
msisdn: '13800000001',
|
||||
carrier_name: '运营商账户',
|
||||
carrier_type: 'CTCC',
|
||||
slot_position: 1,
|
||||
is_current: true,
|
||||
network_status: 1,
|
||||
real_name_status: 1,
|
||||
real_name_at: '2026-10-01T01:00:00Z',
|
||||
realname_policy: 'before_order',
|
||||
gateway_extend: 'old reason'
|
||||
},
|
||||
{
|
||||
card_id: 12,
|
||||
iccid: 'CARD-2',
|
||||
msisdn: '13800000002',
|
||||
carrier_name: '另一运营商账户',
|
||||
carrier_type: 'CMCC',
|
||||
slot_position: 2,
|
||||
is_current: false,
|
||||
network_status: 0,
|
||||
real_name_status: 0,
|
||||
real_name_at: null
|
||||
}
|
||||
]
|
||||
|
||||
const detail = (identifier = 'DEVICE-A', cards = boundCards()) => ({
|
||||
asset_type: 'device',
|
||||
asset_id: identifier === 'DEVICE-A' ? 101 : 202,
|
||||
virtual_no: identifier,
|
||||
bound_card_count: cards.length,
|
||||
cards,
|
||||
real_total_mb: 1024,
|
||||
real_used_mb: 100
|
||||
})
|
||||
|
||||
function harness(t, overrides = {}) {
|
||||
const user = vue.reactive({ info: { id: 1, user_type: 1 }, isLogin: true })
|
||||
const messages = []
|
||||
const api = {
|
||||
resolveAsset: async (identifier) => response(detail(identifier)),
|
||||
getRealtimeStatus: async () => response(null),
|
||||
getCurrentPackage: async () => response(null),
|
||||
getAssetWallet: async () => response(null),
|
||||
getAssetPackages: async () => response({ items: [], total: 0 }),
|
||||
refreshAsset: async () => response(null),
|
||||
...overrides
|
||||
}
|
||||
const imports = {
|
||||
vue,
|
||||
'element-plus': {
|
||||
ElMessage: Object.fromEntries(
|
||||
['error', 'success', 'warning'].map((type) => [
|
||||
type,
|
||||
(message) => messages.push({ type, message })
|
||||
])
|
||||
)
|
||||
},
|
||||
'@/api/modules': { AssetService: api },
|
||||
'@/utils/business/apiRateLimit': { FrontendRateLimitError: class extends Error {} },
|
||||
'@/store/modules/user': { useUserStore: () => user }
|
||||
}
|
||||
const module = { exports: {} }
|
||||
new Function('require', 'module', 'exports', compiledSource)(
|
||||
(name) => {
|
||||
assert.ok(imports[name], `Unexpected runtime dependency: ${name}`)
|
||||
return imports[name]
|
||||
},
|
||||
module,
|
||||
module.exports
|
||||
)
|
||||
const scope = vue.effectScope()
|
||||
const state = scope.run(() => module.exports.useAssetInfo())
|
||||
t.after(() => scope.stop())
|
||||
return { state, api, user, messages, scope }
|
||||
}
|
||||
|
||||
test('partial realtime responses retain the complete resolved binding-card roster', async (t) => {
|
||||
const { state } = harness(t, {
|
||||
getRealtimeStatus: async () =>
|
||||
response({
|
||||
asset_type: 'device',
|
||||
asset_id: 101,
|
||||
cards: [{ iccid: 'CARD-1', network_status: 0 }]
|
||||
})
|
||||
})
|
||||
await state.fetchAssetDetail('DEVICE-A')
|
||||
assert.deepEqual(
|
||||
state.cardInfo.value.cards.map((card) => card.iccid),
|
||||
['CARD-1', 'CARD-2']
|
||||
)
|
||||
assert.equal(state.cardInfo.value.cards[0].network_status, 0)
|
||||
assert.equal(state.cardInfo.value.cards[1].msisdn, '13800000002')
|
||||
})
|
||||
|
||||
test('realtime fields cannot erase resolved card identity, carrier, slot, policy, or real-name time', async (t) => {
|
||||
const { state } = harness(t, {
|
||||
getRealtimeStatus: async () =>
|
||||
response({
|
||||
asset_type: 'device',
|
||||
asset_id: 101,
|
||||
cards: [
|
||||
{
|
||||
iccid: 'CARD-1',
|
||||
card_id: 0,
|
||||
msisdn: '',
|
||||
carrier_name: '',
|
||||
carrier_type: '',
|
||||
slot_position: 0,
|
||||
realname_policy: '',
|
||||
real_name_at: 'untrusted realtime time',
|
||||
network_status: 0,
|
||||
real_name_status: 0,
|
||||
is_current: false,
|
||||
gateway_extend: ''
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
await state.fetchAssetDetail('DEVICE-A')
|
||||
assert.deepEqual(state.cardInfo.value.cards[0], {
|
||||
...boundCards()[0],
|
||||
network_status: 0,
|
||||
real_name_status: 0,
|
||||
is_current: false,
|
||||
gateway_extend: ''
|
||||
})
|
||||
})
|
||||
|
||||
test('empty or omitted realtime cards preserve the detail roster; detail reload can remove bindings', async (t) => {
|
||||
const { state, api } = harness(t)
|
||||
await state.fetchAssetDetail('DEVICE-A')
|
||||
for (const cards of [[], undefined, null]) {
|
||||
api.getRealtimeStatus = async () => response({ asset_type: 'device', asset_id: 101, cards })
|
||||
await state.loadRealtimeStatus('DEVICE-A', 'device')
|
||||
assert.equal(state.cardInfo.value.cards.length, 2)
|
||||
}
|
||||
api.resolveAsset = async () => response(detail('DEVICE-A', []))
|
||||
await state.fetchAssetDetail('DEVICE-A')
|
||||
assert.deepEqual(state.cardInfo.value.cards, [])
|
||||
})
|
||||
|
||||
test('unknown realtime cards do not introduce bindings absent from the authorized detail response', async (t) => {
|
||||
const { state } = harness(t, {
|
||||
getRealtimeStatus: async () =>
|
||||
response({ asset_type: 'device', asset_id: 101, cards: [{ iccid: 'UNRESOLVED-CARD' }] })
|
||||
})
|
||||
await state.fetchAssetDetail('DEVICE-A')
|
||||
assert.deepEqual(
|
||||
state.cardInfo.value.cards.map((card) => card.iccid),
|
||||
['CARD-1', 'CARD-2']
|
||||
)
|
||||
})
|
||||
|
||||
test('realtime card order does not change the resolved roster; explicit nullable timestamps can clear', async (t) => {
|
||||
const cards = boundCards()
|
||||
cards[0].last_data_check_at = 'old timestamp'
|
||||
const { state } = harness(t, {
|
||||
resolveAsset: async () => response(detail('DEVICE-A', cards)),
|
||||
getRealtimeStatus: async () =>
|
||||
response({
|
||||
asset_type: 'device',
|
||||
asset_id: 101,
|
||||
cards: [
|
||||
{ iccid: 'CARD-2' },
|
||||
{ iccid: 'CARD-1', last_data_check_at: null, real_name_status: null }
|
||||
]
|
||||
})
|
||||
})
|
||||
await state.fetchAssetDetail('DEVICE-A')
|
||||
assert.deepEqual(
|
||||
state.cardInfo.value.cards.map((card) => card.iccid),
|
||||
['CARD-1', 'CARD-2']
|
||||
)
|
||||
assert.equal(state.cardInfo.value.cards[0].last_data_check_at, null)
|
||||
assert.equal(state.cardInfo.value.cards[0].real_name_status, 1)
|
||||
})
|
||||
|
||||
test('a late resolve response cannot replace a newer search', async (t) => {
|
||||
const oldDetail = deferred()
|
||||
const { state } = harness(t, {
|
||||
resolveAsset: (identifier) =>
|
||||
identifier === 'DEVICE-A' ? oldDetail.promise : Promise.resolve(response(detail(identifier)))
|
||||
})
|
||||
const oldSearch = state.fetchAssetDetail('DEVICE-A')
|
||||
await state.fetchAssetDetail('DEVICE-B')
|
||||
oldDetail.resolve(response(detail('DEVICE-A')))
|
||||
await oldSearch
|
||||
assert.equal(state.cardInfo.value.identifier, 'DEVICE-B')
|
||||
})
|
||||
|
||||
test('late realtime responses cannot write old card data into a different asset', async (t) => {
|
||||
const { state, api } = harness(t)
|
||||
await state.fetchAssetDetail('DEVICE-A')
|
||||
const oldRealtime = deferred()
|
||||
api.getRealtimeStatus = () => oldRealtime.promise
|
||||
const oldLoad = state.loadRealtimeStatus('DEVICE-A', 'device')
|
||||
api.getRealtimeStatus = async () => response(null)
|
||||
await state.fetchAssetDetail('DEVICE-B')
|
||||
oldRealtime.resolve(
|
||||
response({ asset_type: 'device', asset_id: 101, cards: [{ iccid: 'OLD-CARD' }] })
|
||||
)
|
||||
await oldLoad
|
||||
assert.equal(state.cardInfo.value.identifier, 'DEVICE-B')
|
||||
assert.deepEqual(
|
||||
state.cardInfo.value.cards.map((card) => card.iccid),
|
||||
['CARD-1', 'CARD-2']
|
||||
)
|
||||
})
|
||||
|
||||
test('the newest same-asset realtime request wins and stale completion cannot end its loading state', async (t) => {
|
||||
const { state, api } = harness(t)
|
||||
await state.fetchAssetDetail('DEVICE-A')
|
||||
const older = deferred()
|
||||
const newer = deferred()
|
||||
api.getRealtimeStatus = () => older.promise
|
||||
const oldLoad = state.loadRealtimeStatus('DEVICE-A', 'device')
|
||||
api.getRealtimeStatus = () => newer.promise
|
||||
const newLoad = state.loadRealtimeStatus('DEVICE-A', 'device')
|
||||
older.resolve(
|
||||
response({
|
||||
asset_type: 'device',
|
||||
asset_id: 101,
|
||||
cards: [{ iccid: 'CARD-1', network_status: 0 }]
|
||||
})
|
||||
)
|
||||
await oldLoad
|
||||
assert.equal(state.realtimeLoading.value, true)
|
||||
assert.equal(state.cardInfo.value.cards[0].network_status, 1)
|
||||
newer.resolve(
|
||||
response({
|
||||
asset_type: 'device',
|
||||
asset_id: 101,
|
||||
cards: [{ iccid: 'CARD-1', network_status: 1 }]
|
||||
})
|
||||
)
|
||||
await newLoad
|
||||
assert.equal(state.realtimeLoading.value, false)
|
||||
assert.equal(state.cardInfo.value.cards[0].network_status, 1)
|
||||
})
|
||||
|
||||
test('realtime responses identifying a different asset are ignored', async (t) => {
|
||||
const { state, api } = harness(t)
|
||||
await state.fetchAssetDetail('DEVICE-A')
|
||||
for (const identity of [
|
||||
{ asset_type: 'device', asset_id: 202 },
|
||||
{ asset_type: 'card', asset_id: 101 }
|
||||
]) {
|
||||
api.getRealtimeStatus = async () =>
|
||||
response({ ...identity, cards: [{ iccid: 'CARD-1', network_status: 0 }] })
|
||||
await state.loadRealtimeStatus('DEVICE-A', 'device')
|
||||
assert.equal(state.cardInfo.value.cards[0].network_status, 1)
|
||||
}
|
||||
})
|
||||
|
||||
test('starting a new search clears previous device, package, wallet, and binding data immediately', async (t) => {
|
||||
const { state, api } = harness(t)
|
||||
await state.fetchAssetDetail('DEVICE-A')
|
||||
state.deviceRealtime.value = { current_iccid: 'CARD-1' }
|
||||
state.currentPackage.value = { package_name: 'old package' }
|
||||
state.packageList.value = [{ id: 1 }]
|
||||
state.walletInfo.value = { total_balance: 123 }
|
||||
const newDetail = deferred()
|
||||
api.resolveAsset = () => newDetail.promise
|
||||
const nextSearch = state.fetchAssetDetail('DEVICE-B')
|
||||
assert.equal(state.cardInfo.value, null)
|
||||
assert.equal(state.deviceRealtime.value, null)
|
||||
assert.equal(state.currentPackage.value, null)
|
||||
assert.equal(state.walletInfo.value, null)
|
||||
assert.deepEqual(state.packageList.value, [])
|
||||
newDetail.resolve({ code: 403, msg: 'forbidden' })
|
||||
await nextSearch
|
||||
assert.equal(state.cardInfo.value, null)
|
||||
})
|
||||
|
||||
test('changing account invalidates pending requests even when searching the same identifier', async (t) => {
|
||||
const oldDetail = deferred()
|
||||
const { state, user, api } = harness(t, { resolveAsset: () => oldDetail.promise })
|
||||
const oldSearch = state.fetchAssetDetail('DEVICE-A')
|
||||
user.info = { id: 2, user_type: 3 }
|
||||
api.resolveAsset = async () => response(detail('DEVICE-A', [boundCards()[1]]))
|
||||
await state.fetchAssetDetail('DEVICE-A')
|
||||
oldDetail.resolve(response(detail('DEVICE-A')))
|
||||
await oldSearch
|
||||
assert.deepEqual(
|
||||
state.cardInfo.value.cards.map((card) => card.iccid),
|
||||
['CARD-2']
|
||||
)
|
||||
})
|
||||
|
||||
test('logout clears visible data and invalidates pending realtime responses', async (t) => {
|
||||
const { state, user, api } = harness(t)
|
||||
await state.fetchAssetDetail('DEVICE-A')
|
||||
const pending = deferred()
|
||||
api.getRealtimeStatus = () => pending.promise
|
||||
const load = state.loadRealtimeStatus('DEVICE-A', 'device')
|
||||
user.isLogin = false
|
||||
assert.equal(state.cardInfo.value, null)
|
||||
pending.resolve(response({ asset_type: 'device', asset_id: 101, cards: boundCards() }))
|
||||
await load
|
||||
assert.equal(state.cardInfo.value, null)
|
||||
})
|
||||
|
||||
test('a late failure of an old search does not clear the current successful asset', async (t) => {
|
||||
const oldDetail = deferred()
|
||||
const { state } = harness(t, {
|
||||
resolveAsset: (identifier) =>
|
||||
identifier === 'DEVICE-A' ? oldDetail.promise : Promise.resolve(response(detail(identifier)))
|
||||
})
|
||||
const oldSearch = state.fetchAssetDetail('DEVICE-A')
|
||||
await state.fetchAssetDetail('DEVICE-B')
|
||||
oldDetail.reject(new Error('old request failed'))
|
||||
await oldSearch
|
||||
assert.equal(state.cardInfo.value?.identifier, 'DEVICE-B')
|
||||
})
|
||||
|
||||
test('account types 1/2/3/4 retain the same resolved bindings despite sparse realtime fields', async (t) => {
|
||||
for (const userType of [1, 2, 3, 4]) {
|
||||
const { state, user } = harness(t, {
|
||||
getRealtimeStatus: async () =>
|
||||
response({
|
||||
asset_type: 'device',
|
||||
asset_id: 101,
|
||||
cards: [{ iccid: 'CARD-1', carrier_name: '' }]
|
||||
})
|
||||
})
|
||||
user.info = { id: userType, user_type: userType }
|
||||
await state.fetchAssetDetail('DEVICE-A')
|
||||
assert.deepEqual(state.cardInfo.value.cards, boundCards())
|
||||
}
|
||||
})
|
||||
|
||||
test('a current-card change clears the previous current flag even for a partial realtime list', async (t) => {
|
||||
const { state } = harness(t, {
|
||||
getRealtimeStatus: async () =>
|
||||
response({
|
||||
asset_type: 'device',
|
||||
asset_id: 101,
|
||||
cards: [{ iccid: 'CARD-2', is_current: true }]
|
||||
})
|
||||
})
|
||||
await state.fetchAssetDetail('DEVICE-A')
|
||||
assert.deepEqual(
|
||||
state.cardInfo.value.cards.map((card) => card.is_current),
|
||||
[false, true]
|
||||
)
|
||||
})
|
||||
|
||||
test('same-identifier re-search never takes a real-name timestamp from a previous search or realtime', async (t) => {
|
||||
const { state, api } = harness(t)
|
||||
await state.fetchAssetDetail('DEVICE-A')
|
||||
api.resolveAsset = async () =>
|
||||
response(detail('DEVICE-A', [{ ...boundCards()[0], real_name_at: null }]))
|
||||
api.getRealtimeStatus = async () =>
|
||||
response({
|
||||
asset_type: 'device',
|
||||
asset_id: 101,
|
||||
cards: [{ iccid: 'CARD-1', real_name_at: 'stale time' }]
|
||||
})
|
||||
await state.fetchAssetDetail('DEVICE-A')
|
||||
assert.equal(state.cardInfo.value.cards[0].real_name_at, null)
|
||||
})
|
||||
|
||||
test('manual refresh resolves new binding relations and preserves the existing package page', async (t) => {
|
||||
let resolveCalls = 0
|
||||
const { state } = harness(t, {
|
||||
resolveAsset: async () => response(detail('DEVICE-A', ++resolveCalls === 1 ? boundCards() : []))
|
||||
})
|
||||
await state.fetchAssetDetail('DEVICE-A')
|
||||
state.packageList.value = [{ id: 88, children: [{ id: 89 }] }]
|
||||
assert.equal(await state.refreshAsset('DEVICE-A', 'device'), true)
|
||||
assert.equal(resolveCalls, 2)
|
||||
assert.deepEqual(state.cardInfo.value.cards, [])
|
||||
assert.deepEqual(state.packageList.value, [{ id: 88, children: [{ id: 89 }] }])
|
||||
})
|
||||
|
||||
test('a pending refresh does not re-search or overwrite a newer asset', async (t) => {
|
||||
const pending = deferred()
|
||||
const calls = []
|
||||
const { state } = harness(t, {
|
||||
refreshAsset: () => pending.promise,
|
||||
resolveAsset: async (identifier) => {
|
||||
calls.push(identifier)
|
||||
return response(detail(identifier))
|
||||
}
|
||||
})
|
||||
await state.fetchAssetDetail('DEVICE-A')
|
||||
const refresh = state.refreshAsset('DEVICE-A', 'device')
|
||||
await state.fetchAssetDetail('DEVICE-B')
|
||||
pending.resolve(response(null))
|
||||
assert.equal(await refresh, false)
|
||||
assert.equal(state.cardInfo.value.identifier, 'DEVICE-B')
|
||||
assert.deepEqual(calls, ['DEVICE-A', 'DEVICE-B'])
|
||||
})
|
||||
|
||||
test('late current-package, wallet, and package-list responses do not contaminate a new asset', async (t) => {
|
||||
const { state, api } = harness(t)
|
||||
await state.fetchAssetDetail('DEVICE-A')
|
||||
const pending = { package: deferred(), wallet: deferred(), list: deferred() }
|
||||
api.getCurrentPackage = () => pending.package.promise
|
||||
api.getAssetWallet = () => pending.wallet.promise
|
||||
api.getAssetPackages = () => pending.list.promise
|
||||
const oldLoads = [
|
||||
state.loadCurrentPackage('DEVICE-A'),
|
||||
state.loadAssetWallet('DEVICE-A'),
|
||||
state.loadPackageList('DEVICE-A')
|
||||
]
|
||||
api.getCurrentPackage = async () => response(null)
|
||||
api.getAssetWallet = async () => response(null)
|
||||
await state.fetchAssetDetail('DEVICE-B')
|
||||
pending.package.resolve(response({ package_name: 'old package' }))
|
||||
pending.wallet.resolve(response({ total_balance: 123 }))
|
||||
pending.list.resolve(response({ items: [{ id: 1 }], total: 1 }))
|
||||
const results = await Promise.all(oldLoads)
|
||||
assert.equal(state.currentPackage.value, null)
|
||||
assert.equal(state.walletInfo.value, null)
|
||||
assert.deepEqual(state.packageList.value, [])
|
||||
assert.equal(results[2], null)
|
||||
})
|
||||
|
||||
test('a newer same-asset package page wins even if the older page returns last', async (t) => {
|
||||
const { state, api } = harness(t)
|
||||
await state.fetchAssetDetail('DEVICE-A')
|
||||
const older = deferred()
|
||||
api.getAssetPackages = () => older.promise
|
||||
const firstPage = state.loadPackageList('DEVICE-A', 1)
|
||||
api.getAssetPackages = async () =>
|
||||
response({ items: [{ id: 2, children: [{ id: 3 }] }], total: 9, page: 2 })
|
||||
await state.loadPackageList('DEVICE-A', 2)
|
||||
older.resolve(response({ items: [{ id: 1 }], total: 1, page: 1 }))
|
||||
assert.equal(await firstPage, null)
|
||||
assert.deepEqual(state.packageList.value, [{ id: 2, children: [{ id: 3 }] }])
|
||||
})
|
||||
|
||||
test('unmount invalidates outstanding resolve requests', async (t) => {
|
||||
const pending = deferred()
|
||||
const { state, scope } = harness(t, { resolveAsset: () => pending.promise })
|
||||
const search = state.fetchAssetDetail('DEVICE-A')
|
||||
scope.stop()
|
||||
pending.resolve(response(detail('DEVICE-A')))
|
||||
assert.equal(await search, null)
|
||||
assert.equal(state.cardInfo.value, null)
|
||||
})
|
||||
|
||||
test('failed realtime loading preserves resolved bindings and a sparse identified request can update status', async (t) => {
|
||||
t.mock.method(console, 'error', () => {})
|
||||
const { state, api } = harness(t, {
|
||||
getRealtimeStatus: async () => {
|
||||
throw new Error('realtime unavailable')
|
||||
}
|
||||
})
|
||||
await state.fetchAssetDetail('DEVICE-A')
|
||||
assert.deepEqual(state.cardInfo.value.cards, boundCards())
|
||||
assert.equal(state.realtimeLoading.value, false)
|
||||
api.getRealtimeStatus = async () => response({ cards: [{ iccid: 'CARD-1', network_status: 0 }] })
|
||||
await state.loadRealtimeStatus('DEVICE-A', 'device')
|
||||
assert.equal(state.cardInfo.value.cards[0].network_status, 0)
|
||||
assert.equal(state.cardInfo.value.cards.length, 2)
|
||||
})
|
||||
|
||||
test('updating user metadata without changing the account or data scope does not clear asset data', async (t) => {
|
||||
const { state, user } = harness(t)
|
||||
await state.fetchAssetDetail('DEVICE-A')
|
||||
const asset = state.cardInfo.value
|
||||
user.info = { ...user.info, username: 'updated display name' }
|
||||
await vue.nextTick()
|
||||
assert.equal(state.cardInfo.value, asset)
|
||||
})
|
||||
|
||||
test('a disposed asset composable cannot restart loads after an operation finishes late', async (t) => {
|
||||
let calls = 0
|
||||
const { state, scope } = harness(t, {
|
||||
resolveAsset: async () => {
|
||||
calls += 1
|
||||
return response(detail('DEVICE-A'))
|
||||
}
|
||||
})
|
||||
scope.stop()
|
||||
assert.equal(await state.fetchAssetDetail('DEVICE-A'), null)
|
||||
assert.equal(calls, 0)
|
||||
})
|
||||
|
||||
test('standalone card realtime status still updates while the resolved gateway IMEI remains authoritative', async (t) => {
|
||||
const { state } = harness(t, {
|
||||
resolveAsset: async () =>
|
||||
response({
|
||||
...detail('CARD-1', []),
|
||||
asset_type: 'card',
|
||||
iccid: 'CARD-1',
|
||||
gateway_card_imei: 'resolved-imei'
|
||||
}),
|
||||
getRealtimeStatus: async () =>
|
||||
response({
|
||||
asset_type: 'card',
|
||||
asset_id: 202,
|
||||
network_status: 0,
|
||||
real_name_status: 1,
|
||||
gateway_card_imei: 'realtime-imei'
|
||||
})
|
||||
})
|
||||
await state.fetchAssetDetail('CARD-1')
|
||||
assert.equal(state.cardInfo.value.network_status, 0)
|
||||
assert.equal(state.cardInfo.value.real_name_status, 1)
|
||||
assert.equal(state.cardInfo.value.gateway_card_imei, 'resolved-imei')
|
||||
})
|
||||
|
||||
function pageHandlers(state) {
|
||||
const { descriptor } = parse(
|
||||
readFileSync('src/views/asset-management/asset-information/index.vue', 'utf8')
|
||||
)
|
||||
const source = ts.createSourceFile(
|
||||
'asset-information.ts',
|
||||
descriptor.scriptSetup.content,
|
||||
ts.ScriptTarget.Latest,
|
||||
true,
|
||||
ts.ScriptKind.TS
|
||||
)
|
||||
const wanted = new Set([
|
||||
'handleSearch',
|
||||
'handleRefresh',
|
||||
'showUpdateRealnameStatusDialog',
|
||||
'handleUpdateRealnameStatusSuccess',
|
||||
'handleUpdateBindingCardRealnameStatus',
|
||||
'handleBindingCardRealnameStatusSuccess'
|
||||
])
|
||||
const declarations = []
|
||||
function visit(node) {
|
||||
if (ts.isVariableDeclaration(node) && wanted.has(node.name.getText(source)))
|
||||
declarations.push(node.getText(source))
|
||||
ts.forEachChild(node, visit)
|
||||
}
|
||||
visit(source)
|
||||
assert.equal(declarations.length, wanted.size)
|
||||
const bindings = {
|
||||
cardInfo: state.cardInfo,
|
||||
fetchAssetDetail: state.fetchAssetDetail,
|
||||
loadPackageList: state.loadPackageList,
|
||||
refreshAsset: state.refreshAsset,
|
||||
refreshSubmitting: vue.ref(false),
|
||||
refreshDisabled: vue.ref(false),
|
||||
updateRateLimitNow: () => {},
|
||||
assetSearchCardRef: vue.ref(null),
|
||||
startFailureMessage: vue.ref(''),
|
||||
packagePagination: vue.ref({ page: 1, total: 0, pageSize: 5, status: undefined }),
|
||||
walletTransactionSearchToken: vue.ref(0),
|
||||
pollingEnabled: vue.ref(false),
|
||||
updateRealnameStatusDialogVisible: vue.ref(false),
|
||||
bindingCardRealnameStatusDialogVisible: vue.ref(false),
|
||||
bindingCardRealnameStatusIccid: vue.ref(''),
|
||||
bindingCardRealnameStatusValue: vue.ref(0),
|
||||
nextTick: vue.nextTick
|
||||
}
|
||||
const compiled = ts.transpileModule(
|
||||
`let searchRequestId = 0, pollingInitializing = false, realnameStatusAsset = null, bindingCardRealnameStatusAsset = null\n${declarations.map((declaration) => `const ${declaration}`).join('\n')}\nreturn { ${[...wanted].join(', ')} }`,
|
||||
{ compilerOptions: { target: ts.ScriptTarget.ES2022 } }
|
||||
).outputText
|
||||
return {
|
||||
...new Function(...Object.keys(bindings), compiled)(...Object.values(bindings)),
|
||||
...bindings
|
||||
}
|
||||
}
|
||||
|
||||
test('page search resolves a device only once and uses its canonical identifier for related requests', async (t) => {
|
||||
const calls = []
|
||||
const { state } = harness(t, {
|
||||
resolveAsset: async (identifier) => {
|
||||
calls.push(['resolve', identifier])
|
||||
return response(detail('DEVICE-A'))
|
||||
},
|
||||
getRealtimeStatus: async (identifier) => {
|
||||
calls.push(['realtime', identifier])
|
||||
return response(null)
|
||||
},
|
||||
getAssetPackages: async (identifier) => {
|
||||
calls.push(['packages', identifier])
|
||||
return response({ items: [], total: 0 })
|
||||
}
|
||||
})
|
||||
await pageHandlers(state).handleSearch({ identifier: 'IMEI-ALIAS' })
|
||||
assert.deepEqual(calls, [
|
||||
['resolve', 'IMEI-ALIAS'],
|
||||
['realtime', 'DEVICE-A'],
|
||||
['packages', 'DEVICE-A']
|
||||
])
|
||||
})
|
||||
|
||||
test('active gateway synchronization is called only by the sync button, never by searches or data reloads', async (t) => {
|
||||
const syncCalls = []
|
||||
const { state } = harness(t, {
|
||||
refreshAsset: async (identifier) => {
|
||||
syncCalls.push(identifier)
|
||||
return response(null)
|
||||
}
|
||||
})
|
||||
const page = pageHandlers(state)
|
||||
await page.handleRefresh()
|
||||
await page.handleSearch({ identifier: 'DEVICE-A' })
|
||||
await page.handleSearch({ identifier: 'DEVICE-A' })
|
||||
await state.loadRealtimeStatus('DEVICE-A', 'device')
|
||||
page.handleUpdateBindingCardRealnameStatus({ card: boundCards()[0] })
|
||||
await page.handleBindingCardRealnameStatusSuccess()
|
||||
page.showUpdateRealnameStatusDialog()
|
||||
await page.handleUpdateRealnameStatusSuccess()
|
||||
assert.deepEqual(syncCalls, [])
|
||||
|
||||
await page.handleRefresh()
|
||||
assert.deepEqual(syncCalls, ['DEVICE-A'])
|
||||
await state.fetchAssetDetail('DEVICE-A')
|
||||
page.refreshDisabled.value = true
|
||||
await page.handleRefresh()
|
||||
assert.deepEqual(syncCalls, ['DEVICE-A'])
|
||||
})
|
||||
|
||||
test('a stale page search cannot start additional loads or reset the newer search pagination', async (t) => {
|
||||
const pending = deferred()
|
||||
const { state } = harness(t, {
|
||||
resolveAsset: (identifier) =>
|
||||
identifier === 'DEVICE-A' ? pending.promise : Promise.resolve(response(detail(identifier))),
|
||||
getAssetPackages: async () => response({ items: [{ id: 2 }], total: 22 })
|
||||
})
|
||||
const page = pageHandlers(state)
|
||||
const older = page.handleSearch({ identifier: 'DEVICE-A' })
|
||||
await page.handleSearch({ identifier: 'DEVICE-B' })
|
||||
pending.resolve(response(detail('DEVICE-A')))
|
||||
await older
|
||||
assert.equal(page.packagePagination.value.total, 22)
|
||||
assert.equal(page.walletTransactionSearchToken.value, 1)
|
||||
assert.equal(state.cardInfo.value.identifier, 'DEVICE-B')
|
||||
})
|
||||
|
||||
test('successful bound-card real-name update reloads detail fields but an old dialog cannot reload a new asset', async (t) => {
|
||||
let resolveCalls = 0
|
||||
const { state, api } = harness(t, {
|
||||
resolveAsset: async (identifier) => {
|
||||
resolveCalls += 1
|
||||
return response(detail(identifier))
|
||||
}
|
||||
})
|
||||
await state.fetchAssetDetail('DEVICE-A')
|
||||
const page = pageHandlers(state)
|
||||
page.handleUpdateBindingCardRealnameStatus({ card: boundCards()[0] })
|
||||
api.resolveAsset = async () => {
|
||||
resolveCalls += 1
|
||||
return response(
|
||||
detail('DEVICE-A', [{ ...boundCards()[0], real_name_status: 0, real_name_at: null }])
|
||||
)
|
||||
}
|
||||
await page.handleBindingCardRealnameStatusSuccess()
|
||||
assert.equal(state.cardInfo.value.cards[0].real_name_status, 0)
|
||||
assert.equal(state.cardInfo.value.cards[0].real_name_at, null)
|
||||
assert.equal(resolveCalls, 2)
|
||||
api.resolveAsset = async (identifier) => {
|
||||
resolveCalls += 1
|
||||
return response(detail(identifier))
|
||||
}
|
||||
page.handleUpdateBindingCardRealnameStatus({ card: boundCards()[0] })
|
||||
await state.fetchAssetDetail('DEVICE-B')
|
||||
await page.handleBindingCardRealnameStatusSuccess()
|
||||
assert.equal(state.cardInfo.value.identifier, 'DEVICE-B')
|
||||
assert.equal(resolveCalls, 3)
|
||||
})
|
||||
377
scripts/tests/carrierRealnameControl.test.mjs
Normal file
377
scripts/tests/carrierRealnameControl.test.mjs
Normal file
@@ -0,0 +1,377 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import ts from 'typescript'
|
||||
import * as vue from 'vue'
|
||||
import { compileScript, parse } from '@vue/compiler-sfc'
|
||||
|
||||
function evaluate(source, imports = {}, globals = {}) {
|
||||
const compiled = ts.transpileModule(source, {
|
||||
compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.CommonJS }
|
||||
}).outputText
|
||||
const module = { exports: {} }
|
||||
new Function('require', 'module', 'exports', ...Object.keys(globals), compiled)(
|
||||
(name) => {
|
||||
assert.ok(imports[name], `Unexpected dependency: ${name}`)
|
||||
return imports[name]
|
||||
},
|
||||
module,
|
||||
module.exports,
|
||||
...Object.values(globals)
|
||||
)
|
||||
return module.exports
|
||||
}
|
||||
|
||||
const read = (path) => readFileSync(path, 'utf8')
|
||||
const carrierTypes = evaluate(read('src/types/api/carrier.ts'))
|
||||
const carrierConfig = evaluate(read('src/config/constants/carrierTypes.ts'), {
|
||||
'@/types/api': carrierTypes
|
||||
})
|
||||
const checkedColumns = evaluate(read('src/composables/useCheckedColumns.ts'), { vue })
|
||||
const components = Object.fromEntries(
|
||||
['index', 'detail'].map((name) => {
|
||||
const { descriptor } = parse(read(`src/views/system/carrier-management/${name}.vue`))
|
||||
return [
|
||||
name,
|
||||
{ descriptor, script: compileScript(descriptor, { id: `carrier-${name}` }).content }
|
||||
]
|
||||
})
|
||||
)
|
||||
|
||||
test('carrier form grid top-aligns items so helper text cannot offset adjacent controls', () => {
|
||||
const style = components.index.descriptor.styles.map((block) => block.content).join('\n')
|
||||
assert.match(style, /\.carrier-form-grid\s*\{[^}]*align-items:\s*start\s*;/)
|
||||
})
|
||||
|
||||
const carrier = (enabled) => ({
|
||||
id: 7,
|
||||
carrier_code: 'carrier-test',
|
||||
carrier_name: '测试运营商',
|
||||
carrier_type: 'CMCC',
|
||||
realname_control_enabled: enabled,
|
||||
status: 1,
|
||||
created_at: '',
|
||||
updated_at: ''
|
||||
})
|
||||
|
||||
function harness(userType, responseCarrier = carrier(1)) {
|
||||
const writes = []
|
||||
const confirmations = []
|
||||
const user = vue.reactive({ info: { user_type: userType }, permissions: [], buttons: [] })
|
||||
const permission = evaluate(read('src/composables/usePermission.ts'), {
|
||||
vue,
|
||||
'@/store/modules/user': { useUserStore: () => user }
|
||||
})
|
||||
const service = {
|
||||
getCarriers: async () => ({ code: 0, data: { items: [responseCarrier], total: 1 } }),
|
||||
getCarrierDetail: async () => ({ code: 0, data: responseCarrier }),
|
||||
createCarrier: async (data) => writes.push({ method: 'create', data: { ...data } }),
|
||||
updateCarrier: async (id, data) => writes.push({ method: 'update', id, data: { ...data } })
|
||||
}
|
||||
const runtimeVue = { ...vue, onMounted: () => {} }
|
||||
const imports = {
|
||||
vue: runtimeVue,
|
||||
'vue-router': { useRouter: () => ({ push() {} }), useRoute: () => ({ params: { id: '7' } }) },
|
||||
'@vueuse/core': { useWindowSize: () => ({ width: vue.ref(1200) }) },
|
||||
'@/api/modules': { CarrierService: service },
|
||||
'element-plus': {
|
||||
ElMessage: { success() {}, warning() {} },
|
||||
ElMessageBox: {
|
||||
confirm: async (...args) => {
|
||||
confirmations.push(args)
|
||||
return 'confirm'
|
||||
}
|
||||
},
|
||||
ElTag: {},
|
||||
ElSwitch: {},
|
||||
ElButton: {}
|
||||
},
|
||||
'@/composables/useCheckedColumns': checkedColumns,
|
||||
'@/composables/useAuth': { useAuth: () => ({ hasAuth: () => true }) },
|
||||
'@/composables/usePermission': permission,
|
||||
'@/router/routesAlias': {
|
||||
RoutesAlias: { CarrierDetail: '/carrier', CarrierManagement: '/carrier' }
|
||||
},
|
||||
'@/utils/codeGenerator': { generateCarrierCode: () => 'carrier-test' },
|
||||
'@/utils/business/format': { formatDateTime: (value) => value },
|
||||
'@/config/constants': {
|
||||
...carrierConfig,
|
||||
CommonStatus: { ENABLED: 1, DISABLED: 0 },
|
||||
getStatusText: (value) => String(value)
|
||||
}
|
||||
}
|
||||
const setup = (name) =>
|
||||
evaluate(components[name].script, imports, runtimeVue).default.setup({}, { expose() {} })
|
||||
return {
|
||||
list: setup('index'),
|
||||
detail: setup('detail'),
|
||||
writes,
|
||||
confirmations,
|
||||
messageBox: imports['element-plus'].ElMessageBox,
|
||||
service
|
||||
}
|
||||
}
|
||||
|
||||
const validForm = {
|
||||
validate: async (callback) => callback(true),
|
||||
resetFields() {},
|
||||
clearValidate() {}
|
||||
}
|
||||
|
||||
for (const userType of [1, 2, '1', '2', 3, 4, 0, undefined]) {
|
||||
const allowed = [1, 2].includes(Number(userType))
|
||||
test(`user_type=${userType}: list visibility, detail visibility and create/update field access`, async () => {
|
||||
const { list, detail, writes } = harness(userType)
|
||||
assert.equal(list.canConfigureRealnameControl.value, allowed)
|
||||
assert.equal(detail.canConfigureRealnameControl.value, allowed)
|
||||
assert.equal(
|
||||
list.columnOptions.some((column) => column.prop === 'realname_control_enabled'),
|
||||
allowed
|
||||
)
|
||||
assert.equal(
|
||||
list.columns.value.some((column) => column.prop === 'realname_control_enabled'),
|
||||
allowed
|
||||
)
|
||||
assert.equal(
|
||||
list.columnChecks.value.some((column) => column.prop === 'realname_control_enabled'),
|
||||
allowed
|
||||
)
|
||||
|
||||
await list.getTableData()
|
||||
await detail.loadCarrier()
|
||||
assert.equal(list.carrierList.value[0].realname_control_enabled, 1)
|
||||
assert.equal(detail.carrier.value.realname_control_enabled, 1)
|
||||
|
||||
list.showDialog('add')
|
||||
assert.equal(list.form.realname_control_enabled, 0)
|
||||
list.form.realname_control_enabled = 1
|
||||
await list.handleSubmit(validForm)
|
||||
list.showDialog('edit', carrier(1))
|
||||
assert.equal(list.form.realname_control_enabled, 1)
|
||||
list.form.realname_control_enabled = 0
|
||||
await list.handleSubmit(validForm)
|
||||
|
||||
assert.equal(writes.length, 2)
|
||||
assert.equal(writes[0].method, 'create')
|
||||
assert.equal(writes[1].method, 'update')
|
||||
assert.equal(writes[1].id, 7)
|
||||
for (const [index, write] of writes.entries()) {
|
||||
assert.equal(Object.hasOwn(write.data, 'realname_control_enabled'), allowed)
|
||||
if (allowed) assert.equal(write.data.realname_control_enabled, index === 0 ? 1 : 0)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
test('labels preserve numeric zero and handle missing fields without inventing a state', () => {
|
||||
const { getCarrierRealnameControlLabel: label } = carrierConfig
|
||||
assert.equal(label(0), '不管控')
|
||||
assert.equal(label(1), '管控')
|
||||
assert.equal(label(undefined), '-')
|
||||
assert.equal(label(null), '-')
|
||||
const { list } = harness(1)
|
||||
const column = list.columns.value.find((item) => item.prop === 'realname_control_enabled')
|
||||
assert.equal(column.formatter(carrier(0)), '不管控')
|
||||
assert.equal(column.formatter(carrier(1)), '管控')
|
||||
assert.equal(column.formatter(carrier(undefined)), '-')
|
||||
})
|
||||
|
||||
test('editing then creating resets control state; default creation sends numeric zero', async () => {
|
||||
const { list, writes } = harness(2)
|
||||
list.showDialog('edit', carrier(1))
|
||||
list.showDialog('add')
|
||||
assert.equal(list.form.realname_control_enabled, 0)
|
||||
await list.handleSubmit(validForm)
|
||||
assert.equal(writes[0].data.realname_control_enabled, 0)
|
||||
list.showDialog('edit', carrier(0))
|
||||
assert.equal(list.form.realname_control_enabled, 0)
|
||||
list.showDialog('edit', carrier(undefined))
|
||||
assert.equal(list.form.realname_control_enabled, 0)
|
||||
})
|
||||
|
||||
for (const userType of [1, 2]) {
|
||||
test(`user_type=${userType}: enabling control requires confirmation before PUT and sends true`, async () => {
|
||||
const { list, writes, confirmations, messageBox } = harness(userType)
|
||||
list.showDialog('edit', carrier(0))
|
||||
list.form.realname_control_enabled = 1
|
||||
let confirm
|
||||
messageBox.confirm = (...args) => {
|
||||
confirmations.push(args)
|
||||
return new Promise((resolve) => {
|
||||
confirm = resolve
|
||||
})
|
||||
}
|
||||
const pending = list.handleSubmit(validForm)
|
||||
assert.equal(confirmations.length, 1)
|
||||
assert.match(confirmations[0][0], /未实名的开机卡会在下一次评估时被停机/)
|
||||
assert.deepEqual(writes, [])
|
||||
assert.equal(list.submitLoading.value, true)
|
||||
await list.handleSubmit(validForm)
|
||||
assert.equal(confirmations.length, 1)
|
||||
confirm('confirm')
|
||||
await pending
|
||||
assert.equal(writes.length, 1)
|
||||
assert.equal(writes[0].method, 'update')
|
||||
assert.equal(writes[0].data.realname_control_enabled, 1)
|
||||
assert.equal(writes[0].data.realname_control_confirm, true)
|
||||
assert.equal(list.submitLoading.value, false)
|
||||
})
|
||||
}
|
||||
|
||||
for (const reason of ['cancel', 'close']) {
|
||||
test(`${reason} of realname confirmation does not submit; retry requires a fresh confirmation`, async () => {
|
||||
const { list, writes, messageBox } = harness(1)
|
||||
list.showDialog('edit', carrier(0))
|
||||
list.form.realname_control_enabled = 1
|
||||
let prompts = 0
|
||||
messageBox.confirm = async () => {
|
||||
prompts += 1
|
||||
throw reason
|
||||
}
|
||||
await list.handleSubmit(validForm)
|
||||
assert.deepEqual(writes, [])
|
||||
assert.equal(list.dialogVisible.value, true)
|
||||
assert.equal(list.submitLoading.value, false)
|
||||
assert.equal(list.form.realname_control_enabled, 1)
|
||||
messageBox.confirm = async () => {
|
||||
prompts += 1
|
||||
return 'confirm'
|
||||
}
|
||||
await list.handleSubmit(validForm)
|
||||
assert.equal(prompts, 2)
|
||||
assert.equal(writes[0].data.realname_control_confirm, true)
|
||||
})
|
||||
}
|
||||
|
||||
test('unchanged, disabled, new, and unauthorized carriers never send confirmation automatically', async () => {
|
||||
for (const [userType, mode, original, selected] of [
|
||||
[1, 'edit', 1, 1],
|
||||
[1, 'edit', 0, 0],
|
||||
[2, 'edit', 1, 0],
|
||||
[1, 'add', 0, 1],
|
||||
[3, 'edit', 0, 1],
|
||||
[4, 'edit', 0, 1]
|
||||
]) {
|
||||
const { list, writes, confirmations } = harness(userType)
|
||||
list.showDialog(mode, carrier(original))
|
||||
list.form.realname_control_enabled = selected
|
||||
await list.handleSubmit(validForm)
|
||||
assert.equal(confirmations.length, 0)
|
||||
assert.equal(writes.length, 1)
|
||||
assert.equal(Object.hasOwn(writes[0].data, 'realname_control_confirm'), false)
|
||||
}
|
||||
})
|
||||
|
||||
test('opening another carrier resets the original control state after a cancelled enabling', async () => {
|
||||
const { list, writes, messageBox } = harness(2)
|
||||
list.showDialog('edit', carrier(0))
|
||||
list.form.realname_control_enabled = 1
|
||||
messageBox.confirm = async () => {
|
||||
throw 'cancel'
|
||||
}
|
||||
await list.handleSubmit(validForm)
|
||||
list.showDialog('edit', { ...carrier(1), id: 8 })
|
||||
await list.handleSubmit(validForm)
|
||||
assert.equal(writes[0].id, 8)
|
||||
assert.equal(Object.hasOwn(writes[0].data, 'realname_control_confirm'), false)
|
||||
})
|
||||
|
||||
test('a failed PUT requires a fresh confirmation on retry', async (t) => {
|
||||
const { list, writes, confirmations, service } = harness(2)
|
||||
t.mock.method(console, 'error', () => {})
|
||||
list.showDialog('edit', carrier(0))
|
||||
list.form.realname_control_enabled = 1
|
||||
const updateCarrier = service.updateCarrier
|
||||
service.updateCarrier = async () => {
|
||||
throw new Error('PUT failed')
|
||||
}
|
||||
await list.handleSubmit(validForm)
|
||||
assert.equal(confirmations.length, 1)
|
||||
assert.deepEqual(writes, [])
|
||||
assert.equal(list.dialogVisible.value, true)
|
||||
assert.equal(list.submitLoading.value, false)
|
||||
service.updateCarrier = updateCarrier
|
||||
await list.handleSubmit(validForm)
|
||||
assert.equal(confirmations.length, 2)
|
||||
assert.equal(writes[0].data.realname_control_confirm, true)
|
||||
})
|
||||
|
||||
function findElement(node, predicate) {
|
||||
if (node.type === 1 && predicate(node)) return node
|
||||
for (const child of node.children || []) {
|
||||
const match = findElement(child, predicate)
|
||||
if (match) return match
|
||||
}
|
||||
}
|
||||
|
||||
test('form and detail guard the field, and the switch uses numeric 1/0', () => {
|
||||
for (const [name, tag] of [
|
||||
['index', 'ElFormItem'],
|
||||
['detail', 'ElDescriptionsItem']
|
||||
]) {
|
||||
const field = findElement(
|
||||
components[name].descriptor.template.ast,
|
||||
(node) =>
|
||||
node.tag === tag &&
|
||||
node.props.some((prop) => prop.name === 'label' && prop.value?.content === '通道实名管控')
|
||||
)
|
||||
assert.ok(field)
|
||||
assert.equal(
|
||||
field.props.find((prop) => prop.type === 7 && prop.name === 'if')?.exp?.content,
|
||||
'canConfigureRealnameControl'
|
||||
)
|
||||
if (name === 'index') {
|
||||
const toggle = findElement(field, (node) => node.tag === 'ElSwitch')
|
||||
for (const [arg, value] of [
|
||||
['active-value', '1'],
|
||||
['inactive-value', '0']
|
||||
]) {
|
||||
assert.equal(
|
||||
toggle.props.find((prop) => prop.type === 7 && prop.arg?.content === arg)?.exp?.content,
|
||||
value
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
test('carrier endpoints preserve the field in list/detail responses and create/update requests', async () => {
|
||||
const calls = []
|
||||
class BaseService {
|
||||
static getPage(url) {
|
||||
calls.push({ method: 'GET', url })
|
||||
return Promise.resolve({ code: 0, data: { items: [carrier(1)] } })
|
||||
}
|
||||
static getOne(url) {
|
||||
calls.push({ method: 'GET', url })
|
||||
return Promise.resolve({ code: 0, data: carrier(0) })
|
||||
}
|
||||
static create(url, data) {
|
||||
calls.push({ method: 'POST', url, data })
|
||||
return Promise.resolve({ code: 0, data })
|
||||
}
|
||||
static update(url, data) {
|
||||
calls.push({ method: 'PUT', url, data })
|
||||
return Promise.resolve({ code: 0, data })
|
||||
}
|
||||
}
|
||||
const { CarrierService } = evaluate(read('src/api/modules/carrier.ts'), {
|
||||
'../BaseService': { BaseService }
|
||||
})
|
||||
assert.equal((await CarrierService.getCarriers()).data.items[0].realname_control_enabled, 1)
|
||||
assert.equal((await CarrierService.getCarrierDetail(7)).data.realname_control_enabled, 0)
|
||||
await CarrierService.createCarrier({ ...carrier(1) })
|
||||
await CarrierService.updateCarrier(7, {
|
||||
realname_control_enabled: 1,
|
||||
realname_control_confirm: true
|
||||
})
|
||||
assert.deepEqual(calls, [
|
||||
{ method: 'GET', url: '/api/admin/carriers' },
|
||||
{ method: 'GET', url: '/api/admin/carriers/7' },
|
||||
{ method: 'POST', url: '/api/admin/carriers', data: carrier(1) },
|
||||
{
|
||||
method: 'PUT',
|
||||
url: '/api/admin/carriers/7',
|
||||
data: { realname_control_enabled: 1, realname_control_confirm: true }
|
||||
}
|
||||
])
|
||||
})
|
||||
233
scripts/tests/employeeCollectionActing.test.mjs
Normal file
233
scripts/tests/employeeCollectionActing.test.mjs
Normal file
@@ -0,0 +1,233 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import ts from 'typescript'
|
||||
import * as vue from 'vue'
|
||||
import { compileScript, parse } from '@vue/compiler-sfc'
|
||||
|
||||
function evaluate(source, imports = {}) {
|
||||
const compiled = ts.transpileModule(source, {
|
||||
compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.CommonJS }
|
||||
}).outputText
|
||||
const module = { exports: {} }
|
||||
new Function('require', 'module', 'exports', compiled)(
|
||||
(name) => {
|
||||
assert.ok(imports[name], `Unexpected dependency: ${name}`)
|
||||
return imports[name]
|
||||
},
|
||||
module,
|
||||
module.exports
|
||||
)
|
||||
return module.exports
|
||||
}
|
||||
|
||||
const acting = evaluate(readFileSync('src/utils/business/employeeCollectionActing.ts', 'utf8'))
|
||||
const { descriptor } = parse(
|
||||
readFileSync(
|
||||
'src/views/finance/employee-collection/applications/components/ApplicationFormDialog.vue',
|
||||
'utf8'
|
||||
)
|
||||
)
|
||||
const componentSource = compileScript(descriptor, { id: 'collection-acting-test' }).content
|
||||
|
||||
const employee = { id: 10, name: '测试员工', user_type: 1 }
|
||||
const bill = (id, name = employee.name, accountId = 99) => ({
|
||||
id,
|
||||
remaining_amount: 10000,
|
||||
status: 0,
|
||||
debtor_account_id: accountId,
|
||||
debtor_snapshot: { account_id: accountId, account_name: name }
|
||||
})
|
||||
|
||||
function formHarness(props = {}, candidates = [], details = {}) {
|
||||
const calls = []
|
||||
const detailCalls = []
|
||||
const cleared = []
|
||||
const user = vue.reactive({ info: { ...employee }, isSuperAdmin: true })
|
||||
const service = {
|
||||
getPaymentMethods: async () => ({
|
||||
code: 0,
|
||||
data: [{ id: 1, name: '银行转账', enabled: true }]
|
||||
}),
|
||||
getBills: async () => ({ code: 0, data: { items: candidates, total: candidates.length } }),
|
||||
getApplicationById: async () => ({
|
||||
code: 0,
|
||||
data: {
|
||||
allocations: Object.keys(details).map((id) => ({ bill_id: Number(id), amount: 5000 }))
|
||||
}
|
||||
}),
|
||||
getBillById: async (id) => {
|
||||
detailCalls.push(id)
|
||||
return { code: 0, data: { bill: details[id] } }
|
||||
},
|
||||
createApplication: async (data) => {
|
||||
calls.push({ method: 'create', data })
|
||||
return { code: 0 }
|
||||
},
|
||||
updateApplication: async (id, data) => {
|
||||
calls.push({ method: 'update', id, data })
|
||||
return { code: 0 }
|
||||
}
|
||||
}
|
||||
const display = {
|
||||
BILL_SOURCE_OPTIONS: [],
|
||||
BILL_STATUS_OPTIONS: [],
|
||||
canCreateApplication: () => true,
|
||||
formatCollectionCurrency: String,
|
||||
normalizeCollectionList: (data) => (Array.isArray(data) ? data : data.items || []),
|
||||
normalizeCollectionPage: (data) => ({ list: data.items || [], total: data.total || 0 })
|
||||
}
|
||||
const component = evaluate(componentSource, {
|
||||
vue,
|
||||
'element-plus': { ElMessage: { success() {}, error() {}, warning() {} } },
|
||||
'@/api/modules': {
|
||||
EmployeeCollectionService: service,
|
||||
AgentRechargeService: {},
|
||||
ShopService: {}
|
||||
},
|
||||
'@/utils/business/format': {
|
||||
fenToYuan: (value) => Number(value || 0) / 100,
|
||||
yuanToFen: (value) => Math.round(Number(value || 0) * 100)
|
||||
},
|
||||
'@/utils/business': {
|
||||
getErrorMessage: String,
|
||||
toVoucherKeyList: (value) => (Array.isArray(value) ? value : value ? [value] : [])
|
||||
},
|
||||
'@/store/modules/user': { useUserStore: () => user },
|
||||
'@/utils/business/employeeCollectionActing': acting,
|
||||
'@/components/business/VoucherUpload.vue': { default: {} },
|
||||
'../../employeeCollectionDisplay': display
|
||||
}).default
|
||||
const reactiveProps = vue.reactive({
|
||||
modelValue: true,
|
||||
application: null,
|
||||
presetBill: null,
|
||||
...props
|
||||
})
|
||||
const state = component.setup(reactiveProps, { expose() {}, emit() {} })
|
||||
state.formRef.value = {
|
||||
clearValidate: (field) => cleared.push(field),
|
||||
validate: async () => {
|
||||
if (state.rules.value.acting_reason?.[0]?.required && !state.form.acting_reason.trim()) {
|
||||
throw new Error('请填写代办原因')
|
||||
}
|
||||
}
|
||||
}
|
||||
const fillPayment = () =>
|
||||
Object.assign(state.form, {
|
||||
payment_method_id: 1,
|
||||
paid_amount: 100,
|
||||
paid_at: '2026-10-14T15:00:00+08:00',
|
||||
payer_name: '付款方',
|
||||
external_transaction_no: 'LOCAL_TEST',
|
||||
payment_voucher_keys: ['test-voucher']
|
||||
})
|
||||
return { state, user, calls, cleared, detailCalls, fillPayment }
|
||||
}
|
||||
|
||||
test('matching nonempty me.name makes a bill self-handled even when account IDs differ', () => {
|
||||
assert.equal(acting.isEmployeeCollectionBillSelf(bill(1), employee), true)
|
||||
assert.equal(acting.isEmployeeCollectionBillSelf(bill(1, ' 测试员工 '), employee), true)
|
||||
assert.equal(acting.isEmployeeCollectionBillSelf(bill(1, '其他员工'), employee), false)
|
||||
assert.equal(acting.isEmployeeCollectionBillSelf(bill(1, '', 10), employee), true)
|
||||
assert.equal(
|
||||
acting.isEmployeeCollectionBillSelf(bill(1, '', null), { name: '', user_type: 1 }),
|
||||
false
|
||||
)
|
||||
assert.equal(acting.requiresEmployeeCollectionActingReason([bill(1), bill(2)], employee), false)
|
||||
assert.equal(
|
||||
acting.requiresEmployeeCollectionActingReason([bill(1), bill(2, '其他员工')], employee),
|
||||
true
|
||||
)
|
||||
assert.equal(acting.requiresEmployeeCollectionActingReason([undefined], employee), true)
|
||||
assert.equal(acting.requiresEmployeeCollectionActingReason([], employee), true)
|
||||
assert.equal(
|
||||
acting.requiresEmployeeCollectionActingReason([bill(2, '其他员工')], {
|
||||
...employee,
|
||||
user_type: 2
|
||||
}),
|
||||
false
|
||||
)
|
||||
})
|
||||
|
||||
test('creating a self-handled application has no acting reason rule and omits the field entirely', async () => {
|
||||
const { state, calls, fillPayment } = formHarness({ presetBill: bill(1) })
|
||||
await state.initialize()
|
||||
await vue.nextTick()
|
||||
fillPayment()
|
||||
assert.equal(state.isActing.value, false)
|
||||
assert.equal(state.rules.value.acting_reason, undefined)
|
||||
state.form.acting_reason = '不得发送的残留值'
|
||||
await state.handleSubmit()
|
||||
assert.equal(calls[0].method, 'create')
|
||||
assert.equal(Object.hasOwn(calls[0].data, 'acting_reason'), false)
|
||||
assert.deepEqual(calls[0].data.allocations, [{ bill_id: 1, amount: 10000 }])
|
||||
})
|
||||
|
||||
test('acting for another employee remains required; switching back to self clears the old value and validation', async () => {
|
||||
const { state, calls, cleared, fillPayment } = formHarness()
|
||||
fillPayment()
|
||||
state.toggleBill(bill(2, '其他员工'))
|
||||
await vue.nextTick()
|
||||
assert.equal(state.rules.value.acting_reason[0].required, true)
|
||||
await assert.rejects(state.handleSubmit(), /代办原因/)
|
||||
assert.equal(calls.length, 0)
|
||||
state.form.acting_reason = '代办核销'
|
||||
state.toggleBill(bill(2, '其他员工'))
|
||||
state.toggleBill(bill(1))
|
||||
await vue.nextTick()
|
||||
assert.equal(state.isActing.value, false)
|
||||
assert.equal(state.form.acting_reason, '')
|
||||
assert.ok(cleared.includes('acting_reason'))
|
||||
await state.handleSubmit()
|
||||
assert.equal(Object.hasOwn(calls[0].data, 'acting_reason'), false)
|
||||
})
|
||||
|
||||
test('resubmission loads responsibility for bills outside the current candidate page and omits a historical acting reason', async () => {
|
||||
const application = {
|
||||
id: 8,
|
||||
acting_reason: '历史代办原因',
|
||||
paid_amount: 5000,
|
||||
payment_method_id: 1
|
||||
}
|
||||
const { state, calls, detailCalls, fillPayment } = formHarness({ application }, [], {
|
||||
21: bill(21)
|
||||
})
|
||||
await state.initialize()
|
||||
await vue.nextTick()
|
||||
fillPayment()
|
||||
assert.deepEqual(detailCalls, [21])
|
||||
assert.equal(state.displayBills.value[0].debtor_snapshot.account_name, employee.name)
|
||||
assert.equal(state.isActing.value, false)
|
||||
assert.equal(state.rules.value.acting_reason, undefined)
|
||||
assert.equal(state.form.acting_reason, '')
|
||||
await state.handleSubmit()
|
||||
assert.equal(calls[0].method, 'update')
|
||||
assert.equal(calls[0].id, 8)
|
||||
assert.equal(Object.hasOwn(calls[0].data, 'acting_reason'), false)
|
||||
assert.deepEqual(calls[0].data.allocations, [{ bill_id: 21, amount: 5000 }])
|
||||
})
|
||||
|
||||
test('resubmission reuses responsibility from the candidate page and cannot be shadowed by an incomplete allocation cache', async () => {
|
||||
const { state, detailCalls } = formHarness({ application: { id: 9 } }, [bill(1)], { 1: bill(1) })
|
||||
await state.initialize()
|
||||
await vue.nextTick()
|
||||
assert.deepEqual(detailCalls, [])
|
||||
state.selectedBillOptions.value[1] = { id: 1, remaining_amount: 10000 }
|
||||
assert.equal(state.isActing.value, false)
|
||||
})
|
||||
|
||||
test('mixed-responsibility resubmission still sends the required acting reason', async () => {
|
||||
const { state, calls, fillPayment } = formHarness({ application: { id: 10 } }, [], {
|
||||
1: bill(1),
|
||||
2: bill(2, '其他员工')
|
||||
})
|
||||
await state.initialize()
|
||||
await vue.nextTick()
|
||||
fillPayment()
|
||||
assert.equal(state.isActing.value, true)
|
||||
assert.equal(state.rules.value.acting_reason[0].required, true)
|
||||
state.form.acting_reason = ' 帮员工提交核销 '
|
||||
await state.handleSubmit()
|
||||
assert.equal(calls[0].data.acting_reason, '帮员工提交核销')
|
||||
})
|
||||
257
scripts/tests/iotCardRecallLineInput.test.mjs
Normal file
257
scripts/tests/iotCardRecallLineInput.test.mjs
Normal file
@@ -0,0 +1,257 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import ts from 'typescript'
|
||||
import * as vue from 'vue'
|
||||
import { compileScript, parse } from '@vue/compiler-sfc'
|
||||
|
||||
function evaluate(source, imports = {}, globals = {}) {
|
||||
const compiled = ts.transpileModule(source, {
|
||||
compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.CommonJS }
|
||||
}).outputText
|
||||
const module = { exports: {} }
|
||||
new Function('require', 'module', 'exports', ...Object.keys(globals), compiled)(
|
||||
(name) => {
|
||||
assert.ok(imports[name], `Unexpected dependency: ${name}`)
|
||||
return imports[name]
|
||||
},
|
||||
module,
|
||||
module.exports,
|
||||
...Object.values(globals)
|
||||
)
|
||||
return module.exports
|
||||
}
|
||||
|
||||
const read = (path) => readFileSync(path, 'utf8')
|
||||
const cardTypes = evaluate(read('src/types/api/card.ts'))
|
||||
const { descriptor } = parse(read('src/views/asset-management/iot-card-management/index.vue'))
|
||||
const script = compileScript(descriptor, { id: 'iot-card-recall-lines' }).content
|
||||
|
||||
function harness() {
|
||||
const writes = []
|
||||
const warnings = []
|
||||
const errors = []
|
||||
let refreshes = 0
|
||||
let response = {
|
||||
code: 0,
|
||||
data: { allocation_no: 'RECALL-1', total_count: 2, success_count: 1, fail_count: 1 }
|
||||
}
|
||||
class BaseService {
|
||||
static async post(url, data) {
|
||||
writes.push({ url, data: structuredClone(vue.toRaw(data)) })
|
||||
return response
|
||||
}
|
||||
}
|
||||
const { CardService } = evaluate(read('src/api/modules/card.ts'), {
|
||||
'../BaseService': { BaseService }
|
||||
})
|
||||
CardService.getStandaloneIotCards = async () => {
|
||||
refreshes += 1
|
||||
return { code: 0, data: { items: [], total: 0 } }
|
||||
}
|
||||
const runtimeVue = { ...vue, onMounted() {} }
|
||||
const imports = {
|
||||
vue: runtimeVue,
|
||||
'vue-router': { useRouter: () => ({ push() {} }) },
|
||||
'@/router/routesAlias': { RoutesAlias: {} },
|
||||
'@/config/constants/audit': { AUDIT_PERMISSIONS: {} },
|
||||
'@/utils/business/auditNavigation': { resolveAuditResourceTarget() {} },
|
||||
'@/components/business/audit/investigationController': { openAuditInvestigation() {} },
|
||||
'@/api/modules': {
|
||||
CardService,
|
||||
CarrierService: { getCarriers: async () => ({ code: 0, data: { items: [] } }) }
|
||||
},
|
||||
'element-plus': {
|
||||
ElMessage: {
|
||||
warning: (message) => warnings.push(message),
|
||||
error: (message) => errors.push(message)
|
||||
}
|
||||
},
|
||||
'@element-plus/icons-vue': {},
|
||||
'@/composables/useCheckedColumns': {
|
||||
useCheckedColumns: () => ({ columnChecks: vue.ref([]), columns: vue.ref([]) })
|
||||
},
|
||||
'@/composables/useAuth': { useAuth: () => ({ hasAuth: () => true }) },
|
||||
'@/store/modules/user': { useUserStore: () => ({}) },
|
||||
pinia: { storeToRefs: () => ({ info: vue.ref({ user_type: 1 }) }) },
|
||||
'@/utils/business/format': {},
|
||||
'@/utils/business/expiryEstimate': {},
|
||||
'@/utils/business/apiRateLimit': {},
|
||||
'@/types/api/card': cardTypes
|
||||
}
|
||||
for (const name of [
|
||||
'@/components/device/RealnamePolicyDialog.vue',
|
||||
'@/components/business/BatchRealnamePolicyDialog.vue',
|
||||
'@/components/business/UpdateRealnameStatusDialog.vue',
|
||||
'@/components/business/ExportTaskCreateDialog.vue'
|
||||
]) {
|
||||
imports[name] = { default: {} }
|
||||
}
|
||||
const state = evaluate(script, imports, runtimeVue).default.setup({}, { expose() {} })
|
||||
const validationErrors = []
|
||||
state.recallFormRef.value = {
|
||||
// Run the component's own validators for the fields mounted in the active mode.
|
||||
async validate(callback) {
|
||||
validationErrors.length = 0
|
||||
const fields =
|
||||
state.recallForm.selection_type === 'lines'
|
||||
? ['iccids_text']
|
||||
: state.recallForm.selection_type === 'range'
|
||||
? ['iccid_start', 'iccid_end']
|
||||
: []
|
||||
for (const field of fields) {
|
||||
for (const rule of state.recallRules[field]) {
|
||||
rule.validator(rule, state.recallForm[field], (error) => {
|
||||
if (error) validationErrors.push(error.message)
|
||||
})
|
||||
}
|
||||
}
|
||||
await callback(validationErrors.length === 0)
|
||||
},
|
||||
resetFields() {
|
||||
// Emulate Element Plus restoring its initial selection when reopening.
|
||||
state.recallForm.selection_type = 'list'
|
||||
state.recallForm.iccids_text = ''
|
||||
},
|
||||
clearValidate() {
|
||||
validationErrors.length = 0
|
||||
}
|
||||
}
|
||||
return {
|
||||
state,
|
||||
writes,
|
||||
warnings,
|
||||
errors,
|
||||
validationErrors,
|
||||
refreshes: () => refreshes,
|
||||
setResponse(value) {
|
||||
response = value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
test('unselected entry defaults to line input; reopening resets input without losing default', () => {
|
||||
const { state } = harness()
|
||||
state.showRecallDialog()
|
||||
assert.equal(state.recallDialogVisible.value, true)
|
||||
assert.equal(state.recallForm.selection_type, 'lines')
|
||||
state.recallForm.iccids_text = 'OLD-CARD'
|
||||
state.handleRecallDialogClose()
|
||||
assert.equal(state.recallForm.iccids_text, '')
|
||||
state.showRecallDialog()
|
||||
assert.equal(state.recallForm.selection_type, 'lines')
|
||||
assert.equal(state.recallForm.iccids_text, '')
|
||||
state.selectedCards.value = [{ iccid: 'SELECTED-CARD' }]
|
||||
state.showRecallDialog()
|
||||
assert.equal(state.recallForm.selection_type, 'list')
|
||||
})
|
||||
|
||||
for (const ending of ['\n', '\r\n']) {
|
||||
test(`line mode trims and skips blank lines, preserves strings, and reuses list API (${JSON.stringify(ending)})`, async () => {
|
||||
const { state, writes, refreshes } = harness()
|
||||
state.selectedCards.value = [{ iccid: 'MUST-NOT-BE-SENT' }]
|
||||
state.showRecallDialog()
|
||||
Object.assign(state.recallForm, {
|
||||
selection_type: 'lines',
|
||||
iccids_text: [' 089860012345678901234 ', '', '\t', '89860012345678901235F'].join(ending),
|
||||
iccid_start: 'OLD-START',
|
||||
iccid_end: 'OLD-END',
|
||||
carrier_id: 7,
|
||||
batch_no: 'OLD-BATCH',
|
||||
remark: '回收测试'
|
||||
})
|
||||
await state.handleRecall()
|
||||
assert.deepEqual(writes, [
|
||||
{
|
||||
url: '/api/admin/iot-cards/standalone/recall',
|
||||
data: {
|
||||
selection_type: 'list',
|
||||
iccids: ['089860012345678901234', '89860012345678901235F'],
|
||||
remark: '回收测试'
|
||||
}
|
||||
}
|
||||
])
|
||||
assert.equal(state.recallDialogVisible.value, false)
|
||||
assert.equal(state.resultDialogVisible.value, true)
|
||||
assert.equal(state.resultTitle.value, '批量回收结果')
|
||||
assert.equal(state.allocationResult.value.success_count, 1)
|
||||
assert.equal(state.allocationResult.value.fail_count, 1)
|
||||
assert.deepEqual(state.selectedCards.value, [])
|
||||
assert.equal(state.recallLoading.value, false)
|
||||
assert.equal(refreshes(), 1)
|
||||
})
|
||||
}
|
||||
|
||||
for (const text of ['', ' \r\n \t\n']) {
|
||||
test(`empty input is rejected without a request (${JSON.stringify(text)})`, async () => {
|
||||
const { state, writes, validationErrors } = harness()
|
||||
state.showRecallDialog()
|
||||
state.recallForm.iccids_text = text
|
||||
await state.handleRecall()
|
||||
assert.deepEqual(writes, [])
|
||||
assert.deepEqual(validationErrors, ['请输入ICCID,一行一个'])
|
||||
assert.equal(state.recallDialogVisible.value, true)
|
||||
assert.equal(state.recallLoading.value, false)
|
||||
})
|
||||
}
|
||||
|
||||
for (const [mode, expected] of [
|
||||
['list', { iccids: ['SELECTED-CARD'] }],
|
||||
['range', { iccid_start: '89860000000000000000', iccid_end: '89860000000000000999' }],
|
||||
['filter', { carrier_id: 7, batch_no: 'BATCH-1' }]
|
||||
]) {
|
||||
test(`switching from line input to ${mode} preserves its existing parameters`, async () => {
|
||||
const { state, writes } = harness()
|
||||
state.selectedCards.value = [{ iccid: 'SELECTED-CARD' }]
|
||||
state.showRecallDialog()
|
||||
Object.assign(state.recallForm, {
|
||||
selection_type: 'lines',
|
||||
iccids_text: 'MANUAL-CARD',
|
||||
iccid_start: '89860000000000000000',
|
||||
iccid_end: '89860000000000000999',
|
||||
carrier_id: 7,
|
||||
batch_no: 'BATCH-1'
|
||||
})
|
||||
state.recallForm.selection_type = mode
|
||||
assert.equal(state.recallRangeCountText.value, '1,000')
|
||||
await state.handleRecall()
|
||||
assert.deepEqual(writes[0].data, { selection_type: mode, remark: '', ...expected })
|
||||
})
|
||||
}
|
||||
|
||||
test('list mode still rejects an empty table selection', async () => {
|
||||
const { state, writes, warnings } = harness()
|
||||
state.showRecallDialog()
|
||||
state.recallForm.selection_type = 'list'
|
||||
await state.handleRecall()
|
||||
assert.deepEqual(writes, [])
|
||||
assert.deepEqual(warnings, ['请先选择要回收的卡'])
|
||||
})
|
||||
|
||||
test('failed requests retain manual input for retry and do not refresh the table', async () => {
|
||||
const { state, errors, setResponse, refreshes } = harness()
|
||||
state.showRecallDialog()
|
||||
state.recallForm.iccids_text = 'RETRY-CARD'
|
||||
setResponse({ code: 1, msg: '回收失败' })
|
||||
await state.handleRecall()
|
||||
assert.deepEqual(errors, ['回收失败'])
|
||||
assert.equal(state.recallForm.iccids_text, 'RETRY-CARD')
|
||||
assert.equal(state.recallDialogVisible.value, true)
|
||||
assert.equal(state.recallLoading.value, false)
|
||||
assert.equal(refreshes(), 0)
|
||||
})
|
||||
|
||||
test('template keeps recall permission, enables its entry, and binds the labeled textarea', () => {
|
||||
const source = descriptor.template.content
|
||||
const entry = source.match(/<ElButton\b[^>]*@click="showRecallDialog"[^>]*>/)[0]
|
||||
assert.match(entry, /v-permission="'iot_card:batch_recycle'"/)
|
||||
assert.doesNotMatch(entry, /:disabled/)
|
||||
const dialog = source.match(/<ElDialog\s+v-model="recallDialogVisible"[\s\S]*?<\/ElDialog>/)[0]
|
||||
assert.match(dialog, /<ElRadio label="lines">一行一个ICCID<\/ElRadio>/)
|
||||
assert.match(
|
||||
dialog,
|
||||
/v-if="recallForm\.selection_type === 'lines'"\s+label="ICCID"\s+prop="iccids_text"/
|
||||
)
|
||||
assert.match(dialog, /v-model="recallForm\.iccids_text"\s+type="textarea"/)
|
||||
assert.match(dialog, /placeholder="请输入ICCID,一行一个"/)
|
||||
})
|
||||
632
scripts/tests/octoberBatchOne.test.mjs
Normal file
632
scripts/tests/octoberBatchOne.test.mjs
Normal file
@@ -0,0 +1,632 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import { resolve } from 'node:path'
|
||||
import { createRequire } from 'node:module'
|
||||
import ts from 'typescript'
|
||||
import * as vue from 'vue'
|
||||
import { compileScript, parse } from '@vue/compiler-sfc'
|
||||
|
||||
const require = createRequire(import.meta.url)
|
||||
const esbuild = createRequire(require.resolve('vite'))('esbuild')
|
||||
|
||||
async function loadModule(entry, stubService = false) {
|
||||
const result = await esbuild.build({
|
||||
entryPoints: [entry],
|
||||
bundle: true,
|
||||
write: false,
|
||||
format: 'cjs',
|
||||
platform: 'node',
|
||||
alias: { '@': resolve('src') },
|
||||
plugins: stubService
|
||||
? [
|
||||
{
|
||||
name: 'stub-base-service',
|
||||
setup(build) {
|
||||
build.onResolve({ filter: /BaseService$/ }, () => ({
|
||||
path: 'base-service',
|
||||
namespace: 'stub'
|
||||
}))
|
||||
build.onLoad({ filter: /.*/, namespace: 'stub' }, () => ({
|
||||
contents: `
|
||||
export class BaseService {
|
||||
static calls = [];
|
||||
static put(url, data, config) { this.calls.push({url, data, config}); return Promise.resolve({code:0, data:{}}); }
|
||||
static update(url, data) { return this.put(url, data); }
|
||||
static post(url, data, config) { this.calls.push({url, data, config}); return Promise.resolve({code:0, data:{}}); }
|
||||
}`
|
||||
}))
|
||||
}
|
||||
}
|
||||
]
|
||||
: []
|
||||
})
|
||||
const module = { exports: {} }
|
||||
new Function('require', 'module', 'exports', result.outputFiles[0].text)(
|
||||
require,
|
||||
module,
|
||||
module.exports
|
||||
)
|
||||
return module.exports
|
||||
}
|
||||
|
||||
test('new login password allows special characters and requires at least three of four classes', async () => {
|
||||
const { getNewLoginPasswordError, createNewLoginPasswordRule } = await loadModule(
|
||||
'src/utils/validation/loginPassword.ts'
|
||||
)
|
||||
for (const password of [
|
||||
'Abc12345',
|
||||
'Abc123456789',
|
||||
'Abc1234!',
|
||||
'Abc1234_',
|
||||
'ABC1234!',
|
||||
'abc1234!',
|
||||
'Abcdefg!',
|
||||
'Ab1~`-=[]{}',
|
||||
'Ab1;:\\|,<>/?'
|
||||
])
|
||||
assert.equal(getNewLoginPasswordError(password), undefined)
|
||||
for (const password of [
|
||||
'Abc1234',
|
||||
'Abc123456789X',
|
||||
'abcd1234',
|
||||
'ABCD1234',
|
||||
'AbcDefGh',
|
||||
'ABCDEF!!',
|
||||
'abcdef!!',
|
||||
'123456!!',
|
||||
'Abc1234 ',
|
||||
' Abc12345',
|
||||
'Abc1234\n',
|
||||
'Abc1234中',
|
||||
'Abc123😀',
|
||||
'Abc12345'
|
||||
]) {
|
||||
assert.ok(getNewLoginPasswordError(password), `must reject ${JSON.stringify(password)}`)
|
||||
}
|
||||
const rule = createNewLoginPasswordRule()
|
||||
for (const value of ['', undefined, null])
|
||||
rule.validator({}, value, (error) => assert.equal(error, undefined))
|
||||
rule.validator({}, 'Abc1234!', (error) => assert.equal(error, undefined))
|
||||
rule.validator({}, 'abcdef!!', (error) => assert.ok(error instanceof Error))
|
||||
for (const symbol of Array.from('!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~')) {
|
||||
assert.equal(getNewLoginPasswordError(`Ab12345${symbol}`), undefined)
|
||||
}
|
||||
})
|
||||
|
||||
test('admin and scan-registration new-password forms share validation, hints and the 12-character input limit', async () => {
|
||||
const forms = [
|
||||
{
|
||||
path: 'src/components/core/layouts/art-header-bar/ChangePasswordDialog.vue',
|
||||
models: ['formData.new_password', 'formData.confirm_password'],
|
||||
fields: ['new_password', 'confirm_password'],
|
||||
hint: "t('passwordChange.passwordRule')"
|
||||
},
|
||||
{
|
||||
path: 'src/views/account-management/account/index.vue',
|
||||
models: ['formData.password'],
|
||||
fields: ['password']
|
||||
},
|
||||
{
|
||||
path: 'src/views/common/account-list.vue',
|
||||
models: ['accountForm.password'],
|
||||
fields: ['password']
|
||||
},
|
||||
{
|
||||
path: 'src/views/shop-management/list/index.vue',
|
||||
models: ['formData.init_password'],
|
||||
fields: ['init_password']
|
||||
},
|
||||
{
|
||||
path: 'src/views/account-management/enterprise-customer/index.vue',
|
||||
models: ['form.password', 'passwordForm.password'],
|
||||
fields: ['password', 'password']
|
||||
},
|
||||
{
|
||||
path: 'src/views/agent-registration/index.vue',
|
||||
models: ['form.password'],
|
||||
fields: ['password'],
|
||||
hint: null
|
||||
}
|
||||
]
|
||||
for (const { path, models, fields, hint = 'NEW_LOGIN_PASSWORD_HINT' } of forms) {
|
||||
const source = await readFile(path, 'utf8')
|
||||
assert.match(source, /from '@\/utils\/validation\/loginPassword'/, path)
|
||||
const inputs = [...source.matchAll(/<ElInput\b[\s\S]*?\/>/g)].map(([input]) => input)
|
||||
for (const model of models) {
|
||||
// Exact v-model also rejects a silent .trim modifier on password inputs.
|
||||
const matches = inputs.filter((input) => input.includes(`v-model="${model}"`))
|
||||
assert.equal(matches.length, 1, `${path}: ${model}`)
|
||||
assert.match(matches[0], /type="password"/, `${path}: ${model}`)
|
||||
assert.match(matches[0], /maxlength="12"/, `${path}: ${model}`)
|
||||
if (hint) {
|
||||
assert.ok(matches[0].includes(`:placeholder="${hint}"`), `${path}: ${model} hint`)
|
||||
} else {
|
||||
assert.match(matches[0], /aria-describedby="registration-password-rule"/, path)
|
||||
assert.match(source, /id="registration-password-rule"[\s\S]*?NEW_LOGIN_PASSWORD_HINT/, path)
|
||||
}
|
||||
}
|
||||
const rules = [
|
||||
...source.matchAll(
|
||||
/\b(password|new_password|confirm_password|init_password):\s*\[([\s\S]*?)\n\s*\]/g
|
||||
)
|
||||
]
|
||||
assert.deepEqual(rules.map(([, field]) => field).sort(), [...fields].sort(), path)
|
||||
for (const [, field, rule] of rules) {
|
||||
assert.match(rule, /required: true/, `${path}: ${field}`)
|
||||
assert.match(rule, /createNewLoginPasswordRule\(/, `${path}: ${field}`)
|
||||
assert.doesNotMatch(rule, /\b(?:min|max|pattern):/, `${path}: ${field} stale rule`)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
test('scan registration validates password and locally handles errors without changing public endpoint, payload or SMS behavior', async () => {
|
||||
const { AgentDistributionService } = await loadModule(
|
||||
'src/api/modules/agentDistribution.ts',
|
||||
true
|
||||
)
|
||||
AgentDistributionService.calls = []
|
||||
const params = {
|
||||
distribution_code: 'local-test',
|
||||
phone: '13800000000',
|
||||
code: '123456',
|
||||
shop_name: '本地测试店铺',
|
||||
shop_code: 'LOCAL_TEST',
|
||||
username: 'local_test'
|
||||
}
|
||||
for (const password of ['Abc12345', 'Abc123456789', 'ABC1234!', 'abc1234!', 'Abcdefg!']) {
|
||||
await AgentDistributionService.registerAgent({ ...params, password })
|
||||
assert.deepEqual(AgentDistributionService.calls.at(-1), {
|
||||
url: '/api/c/v1/agent-distribution-registrations',
|
||||
data: { ...params, password },
|
||||
config: { requestOptions: { withToken: false, errorMessageMode: 'none' } }
|
||||
})
|
||||
}
|
||||
for (const password of ['', 'Abc1234', 'Abc123456789X', 'abcd1234', 'Abc1234 ', 'Abc1234中']) {
|
||||
await assert.rejects(AgentDistributionService.registerAgent({ ...params, password }))
|
||||
}
|
||||
assert.equal(AgentDistributionService.calls.length, 5)
|
||||
await AgentDistributionService.sendCode({ phone: params.phone, scene: 'bind_phone' })
|
||||
assert.deepEqual(AgentDistributionService.calls.at(-1), {
|
||||
url: '/api/c/v1/auth/send-code',
|
||||
data: { phone: params.phone, scene: 'bind_phone' },
|
||||
config: { requestOptions: { withToken: false } }
|
||||
})
|
||||
})
|
||||
|
||||
test('scan registration masks template errors in both business and HTTP responses and uses only local feedback', async () => {
|
||||
const { getAgentRegistrationFailureMessage } = await loadModule(
|
||||
'src/utils/business/agentRegistrationError.ts'
|
||||
)
|
||||
for (const code of [1050, 1001, '1050', '1001']) {
|
||||
const failure = { code, data: null, msg: '企业微信审批模板无效或不可访问' }
|
||||
for (const value of [
|
||||
failure,
|
||||
{ ...failure, data: { detail: 'internal template settings' } },
|
||||
{ isAxiosError: true, response: { status: 400, data: failure } },
|
||||
{ isAxiosError: true, response: { status: 500, data: failure } },
|
||||
{ data: failure }
|
||||
]) {
|
||||
assert.equal(getAgentRegistrationFailureMessage(value), '注册失败, 请联系管理员')
|
||||
}
|
||||
}
|
||||
assert.equal(getAgentRegistrationFailureMessage({ code: 1203, msg: '验证码错误' }), '验证码错误')
|
||||
assert.equal(
|
||||
getAgentRegistrationFailureMessage({ code: 1204, message: '分销码不可用' }),
|
||||
'分销码不可用'
|
||||
)
|
||||
assert.equal(
|
||||
getAgentRegistrationFailureMessage({ isAxiosError: true, code: 'ECONNABORTED' }),
|
||||
'请求超时,结果可能未知,请刷新确认'
|
||||
)
|
||||
for (const value of [null, undefined, new Error('network')]) {
|
||||
assert.equal(typeof getAgentRegistrationFailureMessage(value), 'string')
|
||||
}
|
||||
const page = await readFile('src/views/agent-registration/index.vue', 'utf8')
|
||||
assert.match(page, /ElMessage.error\(getAgentRegistrationFailureMessage\(res\)\)/)
|
||||
assert.match(
|
||||
page,
|
||||
/catch \(error\)\s*\{\s*ElMessage.error\(getAgentRegistrationFailureMessage\(error\)\)/
|
||||
)
|
||||
assert.doesNotMatch(page, /ElMessage.error\('分销码不可用'\)/)
|
||||
assert.match(page, /if \(!valid \|\| submitting.value\) return/)
|
||||
})
|
||||
|
||||
test('scan registration emits exactly one masked message per template failure and retains the form for retry', async () => {
|
||||
const { getAgentRegistrationFailureMessage } = await loadModule(
|
||||
'src/utils/business/agentRegistrationError.ts'
|
||||
)
|
||||
const passwordValidation = await loadModule('src/utils/validation/loginPassword.ts')
|
||||
const { descriptor } = parse(await readFile('src/views/agent-registration/index.vue', 'utf8'))
|
||||
const script = compileScript(descriptor, { id: 'scan-registration-error-test' }).content
|
||||
const compiled = ts.transpileModule(script, {
|
||||
compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.CommonJS }
|
||||
}).outputText
|
||||
for (const code of [1050, 1001]) {
|
||||
for (const rejected of [false, true]) {
|
||||
const messages = []
|
||||
const failure = { code, data: null, msg: '企业微信审批模板无效或不可访问' }
|
||||
const imports = {
|
||||
vue: { ...vue, onBeforeUnmount() {} },
|
||||
'vue-router': { useRoute: () => ({ query: {} }) },
|
||||
'element-plus': { ElMessage: { error: (message) => messages.push(message) } },
|
||||
'@/api/modules/agentDistribution': {
|
||||
AgentDistributionService: {
|
||||
registerAgent: async () => {
|
||||
if (rejected) throw { isAxiosError: true, response: { status: 400, data: failure } }
|
||||
return failure
|
||||
}
|
||||
}
|
||||
},
|
||||
'@/utils/constants/regionData': { regionData: [] },
|
||||
'@/utils/validation/loginPassword': passwordValidation,
|
||||
'@/utils/business/agentRegistrationError': { getAgentRegistrationFailureMessage }
|
||||
}
|
||||
const module = { exports: {} }
|
||||
new Function('require', 'module', 'exports', compiled)(
|
||||
(name) => {
|
||||
assert.ok(imports[name], `Unexpected dependency: ${name}`)
|
||||
return imports[name]
|
||||
},
|
||||
module,
|
||||
module.exports
|
||||
)
|
||||
const state = module.exports.default.setup({}, { expose() {} })
|
||||
Object.assign(state.form, { distribution_code: 'local-test', password: 'Abc1234!' })
|
||||
let submission
|
||||
state.formRef.value = {
|
||||
validate: (callback) => {
|
||||
submission = callback(true)
|
||||
}
|
||||
}
|
||||
state.handleSubmit()
|
||||
state.handleSubmit()
|
||||
await submission
|
||||
assert.deepEqual(messages, ['注册失败, 请联系管理员'])
|
||||
assert.equal(state.submitted.value, false)
|
||||
assert.equal(state.submitting.value, false)
|
||||
assert.equal(state.form.distribution_code, 'local-test')
|
||||
assert.equal(state.form.password, 'Abc1234!')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
test('scan registration password feedback uses the shared rule rather than treating spaces or Chinese as symbols', async () => {
|
||||
const page = await readFile('src/views/agent-registration/index.vue', 'utf8')
|
||||
assert.match(page, /return getNewLoginPasswordError\(pwd\) \? 1 : 3/)
|
||||
assert.match(page, /密码符合规则/)
|
||||
assert.match(page, /aria-live="polite"/)
|
||||
assert.match(page, /password-form-item :deep\(\.el-form-item__error\)[\s\S]*?position: static/)
|
||||
assert.doesNotMatch(page, /8-32|maxlength="32"/)
|
||||
assert.match(page, /password: form.password,/)
|
||||
})
|
||||
|
||||
test('account password requests use the right field and omit unchanged optional password', async () => {
|
||||
const { AccountService } = await loadModule('src/api/modules/account.ts', true)
|
||||
AccountService.calls = []
|
||||
await AccountService.updateAccountPassword(12, 'Abc12345')
|
||||
assert.deepEqual(AccountService.calls[0].data, { new_password: 'Abc12345' })
|
||||
await AccountService.updateAccount(12, { username: 'operator', password: '' })
|
||||
assert.deepEqual(AccountService.calls[1].data, { username: 'operator' })
|
||||
await AccountService.updateAccount(12, { password: 'Abc1234!' })
|
||||
assert.deepEqual(AccountService.calls[2].data, { password: 'Abc1234!' })
|
||||
await AccountService.updateAccountPassword(12, 'ABC1234!')
|
||||
assert.deepEqual(AccountService.calls[3].data, { new_password: 'ABC1234!' })
|
||||
await assert.rejects(AccountService.updateAccount(12, { password: 'abcdef!!' }))
|
||||
await assert.rejects(AccountService.updateAccountPassword(12, 'abcd1234'))
|
||||
assert.equal(AccountService.calls.length, 4)
|
||||
})
|
||||
|
||||
test('change-password dialog is appended to body so its overlay covers the sidebar stacking context', async () => {
|
||||
const dialog = await readFile(
|
||||
'src/components/core/layouts/art-header-bar/ChangePasswordDialog.vue',
|
||||
'utf8'
|
||||
)
|
||||
assert.match(dialog, /append-to-body/)
|
||||
assert.match(dialog, /createNewLoginPasswordRule\(t\('passwordChange.passwordRule'\)\)/)
|
||||
for (const language of ['zh', 'en']) {
|
||||
const locale = JSON.parse(await readFile(`src/locales/langs/${language}.json`, 'utf8'))
|
||||
assert.doesNotMatch(locale.passwordChange.passwordRule, /不允许特殊符号|no special characters/)
|
||||
}
|
||||
})
|
||||
|
||||
test('writeoff terminal failure blocks recovery but allows resubmission; unknown result stays recoverable', async () => {
|
||||
const module = await loadModule(
|
||||
'src/views/finance/employee-collection/employeeCollectionDisplay.ts'
|
||||
)
|
||||
assert.equal(module.canRecoverApplicationApproval({ status: 4, recoverable: true }), false)
|
||||
assert.equal(module.canResubmitApplication({ status: 4 }), true)
|
||||
assert.equal(
|
||||
module.canRecoverApplicationApproval({
|
||||
status: 0,
|
||||
approval_submission_status: 4,
|
||||
recoverable: true
|
||||
}),
|
||||
true
|
||||
)
|
||||
assert.equal(module.canRecoverApplicationApproval({ status: 0, recoverable: false }), false)
|
||||
assert.equal(module.getApplicationStatusTagType(4), 'danger')
|
||||
for (const [value, label] of [
|
||||
[0, '待提交'],
|
||||
[1, '提交中'],
|
||||
[2, '已提交'],
|
||||
[3, '提交失败'],
|
||||
[4, '结果未知']
|
||||
]) {
|
||||
assert.equal(module.getApplicationSubmissionLabel({ approval_submission_status: value }), label)
|
||||
}
|
||||
})
|
||||
|
||||
test('refund submission failure uses resubmit, not recovery, without changing status 6 anomaly handling', async () => {
|
||||
const module = await loadModule('src/config/constants/refund.ts')
|
||||
assert.equal(module.canRecoverRefundApproval({ status: 7, approval_recoverable: true }), false)
|
||||
assert.equal(module.canResubmitRefund({ status: 7 }), true)
|
||||
assert.equal(module.canResubmitRefund({ status: 3 }), true)
|
||||
assert.equal(
|
||||
module.canRecoverRefundApproval({
|
||||
status: 1,
|
||||
submission_status: 4,
|
||||
approval_recoverable: true
|
||||
}),
|
||||
true
|
||||
)
|
||||
assert.equal(module.canResubmitRefund({ status: 6, anomaly_flag: 1 }), false)
|
||||
assert.equal(module.canResubmitRefund({ status: 6, anomaly_flag: 0 }), true)
|
||||
assert.equal(module.RefundStatusNameMap[7], '审批提交失败')
|
||||
})
|
||||
|
||||
test('admin agent registration does not recover terminal failures and provides status fallback', async () => {
|
||||
const module = await loadModule('src/types/api/agentDistributionRegistration.ts')
|
||||
assert.equal(module.canRecoverAgentRegistration({ status: 3, recoverable: true }), false)
|
||||
assert.equal(module.canRecoverAgentRegistration({ status: 0, recoverable: true }), true)
|
||||
assert.equal(module.getAgentRegistrationStatusName({ status: 3 }), '审批提交失败')
|
||||
})
|
||||
|
||||
test('offline recharge failure keeps read actions and starts a new order only with existing role/permission', async () => {
|
||||
const { buildAgentRechargeActions } = await loadModule(
|
||||
'src/views/finance/agent-recharge/agentRechargeActions.ts'
|
||||
)
|
||||
const row = { id: 8, status: 7, payment_method: 'offline', payment_voucher_key: ['voucher'] }
|
||||
let restarted = false
|
||||
const options = {
|
||||
hasAuth: () => true,
|
||||
canCreateOffline: true,
|
||||
onRestart: () => {
|
||||
restarted = true
|
||||
},
|
||||
onViewPaymentVoucher() {},
|
||||
onConfirmPayment() {},
|
||||
onReject() {},
|
||||
onTriggerApproval() {}
|
||||
}
|
||||
const actions = buildAgentRechargeActions(row, options)
|
||||
assert.deepEqual(
|
||||
actions.map((action) => action.label),
|
||||
['支付凭证', '重新发起']
|
||||
)
|
||||
actions[1].handler()
|
||||
assert.equal(restarted, true)
|
||||
assert.deepEqual(
|
||||
buildAgentRechargeActions(row, { ...options, canCreateOffline: false }).map(
|
||||
(action) => action.label
|
||||
),
|
||||
['支付凭证']
|
||||
)
|
||||
assert.deepEqual(buildAgentRechargeActions(row, { ...options, hasAuth: () => false }), [])
|
||||
})
|
||||
|
||||
test('withdrawal failure is independently typed from commission clawback and supports resubmit', async () => {
|
||||
const module = await loadModule('src/config/constants/commission.ts')
|
||||
assert.equal(module.WithdrawalStatusMap[5].label, '审批提交失败')
|
||||
assert.equal(module.canResubmitWithdrawal(5), true)
|
||||
assert.equal(module.canResubmitWithdrawal(3), true)
|
||||
assert.equal(module.canResubmitWithdrawal(1), false)
|
||||
assert.equal(module.getCommissionStatusLabel(5), '回溯')
|
||||
assert.equal(
|
||||
module.WITHDRAWAL_QUALIFICATION_STATUS_OPTIONS.find((item) => item.value === 4).label,
|
||||
'审批提交失败'
|
||||
)
|
||||
})
|
||||
|
||||
test('order payment record status is independent from order status and channels preserve unknown codes', async () => {
|
||||
const module = await loadModule('src/utils/business/orderPayment.ts')
|
||||
assert.equal(module.getOrderPaymentRecordStatusName(0), '待支付')
|
||||
assert.equal(module.getOrderPaymentRecordStatusName(1), '已支付')
|
||||
assert.equal(module.getOrderPaymentRecordStatusName(2), '已失败')
|
||||
assert.equal(module.getOrderPaymentRecordStatusName(3), '已退款')
|
||||
assert.equal(module.getOrderPaymentRecordTagType(2), 'danger')
|
||||
assert.equal(module.getOrderPaymentChannelName('wechat'), '微信直连 v3')
|
||||
assert.equal(module.getOrderPaymentChannelName('wechat_v2'), '微信直连 v2')
|
||||
assert.equal(module.getOrderPaymentChannelName('fuiou'), '富友')
|
||||
assert.equal(module.getOrderPaymentChannelName(''), '-')
|
||||
assert.equal(module.getOrderPaymentChannelName('future-channel'), 'future-channel')
|
||||
})
|
||||
|
||||
test('exchange phone conflicts support HTTP error and business response without inventing a missing number', async () => {
|
||||
const module = await loadModule('src/utils/business/exchangeError.ts')
|
||||
const failure = {
|
||||
code: 1202,
|
||||
data: { phone: '13800000000' },
|
||||
msg: '新资产已绑定手机号,请先在后台解除该资产的手机号绑定,再重新提交换货申请'
|
||||
}
|
||||
assert.equal(module.getExchangePhoneConflictMessage(failure), failure.msg)
|
||||
assert.equal(
|
||||
module.getExchangePhoneConflictMessage({ response: { data: failure } }),
|
||||
module.getExchangePhoneConflictMessage(failure)
|
||||
)
|
||||
assert.match(module.getExchangePhoneConflictMessage({ code: 1202 }), /换货申请未完成/)
|
||||
assert.doesNotMatch(module.getExchangePhoneConflictMessage({ code: 1202 }), /undefined|null/)
|
||||
assert.equal(module.getExchangePhoneConflictMessage({ code: 1206 }), undefined)
|
||||
assert.equal(
|
||||
module.getExchangeBusinessErrorMessage({ response: { data: { message: '迁移失败' } } }),
|
||||
'迁移失败'
|
||||
)
|
||||
const { ExchangeService } = await loadModule('src/api/modules/exchange.ts', true)
|
||||
ExchangeService.calls = []
|
||||
const config = { requestOptions: { errorMessageMode: 'none' } }
|
||||
await ExchangeService.completeExchange(9, config)
|
||||
assert.deepEqual(ExchangeService.calls[0], {
|
||||
url: '/api/admin/exchanges/9/complete',
|
||||
data: {},
|
||||
config
|
||||
})
|
||||
})
|
||||
|
||||
test('exchange association handoff carries only the new asset and its bound phone as strings', async () => {
|
||||
const { getExchangePhoneAssociationQuery } = await loadModule(
|
||||
'src/utils/business/exchangeError.ts'
|
||||
)
|
||||
const newAsset = { asset_identifier: '89860624590014594318', associated_phones: ['19232713115'] }
|
||||
assert.deepEqual(
|
||||
getExchangePhoneAssociationQuery({ code: 1202, data: { phone: '19232713115' } }, newAsset),
|
||||
{
|
||||
asset_identifier: '89860624590014594318',
|
||||
phone: '19232713115'
|
||||
}
|
||||
)
|
||||
assert.equal(
|
||||
getExchangePhoneAssociationQuery({ response: { data: { code: 1202 } } }, newAsset),
|
||||
undefined
|
||||
)
|
||||
assert.equal(getExchangePhoneAssociationQuery({ code: 1206 }, newAsset), undefined)
|
||||
assert.equal(
|
||||
getExchangePhoneAssociationQuery({ code: 1202, data: { phone: '19232713115' } }, {}),
|
||||
undefined
|
||||
)
|
||||
assert.equal(
|
||||
getExchangePhoneAssociationQuery(
|
||||
{ code: 1202 },
|
||||
{ asset_identifier: '89860624590014594318', associated_phones: [] }
|
||||
),
|
||||
undefined
|
||||
)
|
||||
assert.deepEqual(
|
||||
getExchangePhoneAssociationQuery({ code: 1202, data: { phone: '13900000000' } }, newAsset),
|
||||
{
|
||||
asset_identifier: '89860624590014594318',
|
||||
phone: '13900000000'
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('1202 with data null keeps the original msg and cannot navigate to unbind despite asset phone history', async () => {
|
||||
const { getExchangePhoneConflictMessage, getExchangePhoneAssociationQuery } = await loadModule(
|
||||
'src/utils/business/exchangeError.ts'
|
||||
)
|
||||
const failure = {
|
||||
code: 1202,
|
||||
data: null,
|
||||
msg: '该资产已完成过换货,如需再次换货请使用换货后的新资产'
|
||||
}
|
||||
const newAsset = { asset_identifier: '89860624590014594318', associated_phones: ['19232713115'] }
|
||||
for (const value of [failure, { response: { data: failure } }]) {
|
||||
assert.equal(getExchangePhoneConflictMessage(value), failure.msg)
|
||||
assert.equal(getExchangePhoneAssociationQuery(value, newAsset), undefined)
|
||||
}
|
||||
for (const phone of ['', ' ', null, 19232713115]) {
|
||||
assert.equal(
|
||||
getExchangePhoneAssociationQuery({ ...failure, data: { phone } }, newAsset),
|
||||
undefined
|
||||
)
|
||||
}
|
||||
const page = await readFile('src/views/asset-management/exchange-management/index.vue', 'utf8')
|
||||
assert.match(page, /if \(!canManageAssociations\)/)
|
||||
assert.match(page, /ElMessageBox.alert\(conflictMessage, '换货提示'/)
|
||||
})
|
||||
|
||||
test('association preselection excludes old assets, different phones and invalid historical rows', async () => {
|
||||
const {
|
||||
getPhoneAssetAssociationTarget,
|
||||
getMatchingPhoneAssetAssociations,
|
||||
getPhoneAssetUnbindResultName
|
||||
} = await loadModule('src/utils/business/phoneAssetAssociation.ts')
|
||||
const target = getPhoneAssetAssociationTarget({
|
||||
asset_identifier: ' 89860624590014594318 ',
|
||||
phone: '19232713115'
|
||||
})
|
||||
const rows = [
|
||||
{ id: 1, asset_identifier: target.asset_identifier, phone: target.phone, status: 1 },
|
||||
{ id: 2, asset_identifier: '89860625770070732445', phone: target.phone, status: 1 },
|
||||
{ id: 3, asset_identifier: target.asset_identifier, phone: '13900000000', status: 1 },
|
||||
{ id: 4, asset_identifier: target.asset_identifier, phone: target.phone, status: 0 }
|
||||
]
|
||||
assert.deepEqual(
|
||||
getMatchingPhoneAssetAssociations(rows, target).map((row) => row.id),
|
||||
[1]
|
||||
)
|
||||
assert.deepEqual(getMatchingPhoneAssetAssociations(rows, { ...target, phone: '' }), [])
|
||||
assert.deepEqual(
|
||||
getPhoneAssetAssociationTarget({ asset_identifier: ['a', 'b'], phone: ['19232713115'] }),
|
||||
{ asset_identifier: '', phone: '' }
|
||||
)
|
||||
assert.equal(getPhoneAssetUnbindResultName(true), '解绑成功')
|
||||
assert.equal(getPhoneAssetUnbindResultName(false), '解绑失败')
|
||||
})
|
||||
|
||||
test('association page watches handoff changes, clears stale selections and retains manual unbind confirmation', async () => {
|
||||
const page = await readFile(
|
||||
'src/views/asset-management/phone-asset-association/index.vue',
|
||||
'utf8'
|
||||
)
|
||||
assert.match(page, /getPhoneAssetAssociationTarget\(route.query\)/)
|
||||
assert.match(page, /toggleRowSelection\(row, true\)/)
|
||||
assert.match(page, /requestId !== listRequestId/)
|
||||
assert.match(page, /getPhoneAssetUnbindResultName\(row.success\)/)
|
||||
assert.doesNotMatch(page, /prop="success"/)
|
||||
assert.match(page, /batchForm.confirmed = false/)
|
||||
assert.match(page, /batchFormRef.value\?\.validate/)
|
||||
const table = await readFile('src/components/core/tables/ArtTable.vue', 'utf8')
|
||||
assert.match(table, /clearSelection:.*clearSelection\(\)/)
|
||||
})
|
||||
|
||||
test('password validation errors accept backend message as well as msg', async () => {
|
||||
const { normalizeApiError } = await loadModule('src/utils/business/apiError.ts')
|
||||
for (const field of ['msg', 'message']) {
|
||||
assert.equal(
|
||||
normalizeApiError({
|
||||
isAxiosError: true,
|
||||
response: { status: 400, data: { [field]: '新密码不合法' } }
|
||||
}).message,
|
||||
'新密码不合法'
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
test('traffic snapshots preserve zero, missing values and MB precision', async () => {
|
||||
const { formatTrafficAlertMb } = await loadModule('src/utils/business/trafficAlert.ts')
|
||||
assert.equal(formatTrafficAlertMb(0), '0.00')
|
||||
assert.equal(formatTrafficAlertMb(1234.567), '1234.57')
|
||||
for (const value of [undefined, null, NaN]) assert.equal(formatTrafficAlertMb(value), '-')
|
||||
})
|
||||
|
||||
test('CSV download has the new exact four-column header and preserves phone identifiers as text', async () => {
|
||||
const { SHOP_BUSINESS_OWNER_CSV_TEMPLATE } = await loadModule(
|
||||
'src/utils/business/shopBusinessOwnerImport.ts'
|
||||
)
|
||||
assert.equal(SHOP_BUSINESS_OWNER_CSV_TEMPLATE.charCodeAt(0), 0xfeff)
|
||||
const [header, instruction] = SHOP_BUSINESS_OWNER_CSV_TEMPLATE.slice(1).trimEnd().split('\r\n')
|
||||
assert.deepEqual(header.split(','), ['店铺编码', '操作类型', '平台登录账号', '备注'])
|
||||
assert.equal(instruction.split(',').length, 4)
|
||||
assert.match(instruction, /手机号/)
|
||||
assert.match(instruction, /清空留空/)
|
||||
assert.doesNotMatch(SHOP_BUSINESS_OWNER_CSV_TEMPLATE, /业务员登录账号/)
|
||||
})
|
||||
|
||||
test('affected view contracts preserve raw payment history, package quota and device template', async () => {
|
||||
const order = await readFile('src/views/order-management/order-list/detail.vue', 'utf8')
|
||||
assert.match(order, /detailData\.payments \|\| \[\]/)
|
||||
assert.doesNotMatch(order, /payments\.(filter|sort)/)
|
||||
const rules = await readFile('src/views/package-management/traffic-alert-rules/index.vue', 'utf8')
|
||||
assert.match(rules, /item\.real_data_mb/)
|
||||
assert.doesNotMatch(rules, /row\.real_data_mb|prop: 'real_data_mb'/)
|
||||
const devices = await readFile(
|
||||
'src/views/asset-management/task-management/device-task/index.vue',
|
||||
'utf8'
|
||||
)
|
||||
assert.ok(
|
||||
/独立的 IMEI\s+列/.test(devices),
|
||||
'import instructions must require the standalone IMEI column'
|
||||
)
|
||||
assert.match(devices, /@\/template\/设备导入模板\.xlsx/)
|
||||
assert.match(devices, /failed_items/)
|
||||
})
|
||||
271
scripts/tests/octoberBrowserFixtures.mjs
Normal file
271
scripts/tests/octoberBrowserFixtures.mjs
Normal file
@@ -0,0 +1,271 @@
|
||||
const time = '2026-10-13T10:00:00+08:00'
|
||||
const order = {
|
||||
id: 1,
|
||||
order_no: 'MOCK-ORDER-001',
|
||||
order_type: 'single_card',
|
||||
buyer_type: 'personal',
|
||||
payment_status: 2,
|
||||
payment_status_text: '已支付',
|
||||
payment_method: 'wechat',
|
||||
total_amount: 1000,
|
||||
actual_paid_amount: 1000,
|
||||
third_party_trade_no: 'MOCK-TRADE-001',
|
||||
payment_channel: 'wechat',
|
||||
payment_merchant_name: '模拟收款商户',
|
||||
commission_status: 2,
|
||||
commission_result: 2,
|
||||
created_at: time,
|
||||
updated_at: time,
|
||||
paid_at: time,
|
||||
items: [],
|
||||
payments: [
|
||||
{
|
||||
payment_no: 'MOCK-PAY-002',
|
||||
payment_method: 'wechat',
|
||||
payment_channel: 'wechat',
|
||||
payment_merchant_name: '模拟收款商户',
|
||||
third_party_trade_no: 'MOCK-TRADE-001',
|
||||
amount: 1000,
|
||||
status: 1,
|
||||
created_at: time,
|
||||
paid_at: time,
|
||||
expire_at: null
|
||||
},
|
||||
{
|
||||
payment_no: 'MOCK-PAY-001',
|
||||
payment_method: 'alipay',
|
||||
payment_channel: 'fuiou',
|
||||
payment_merchant_name: '模拟收款商户',
|
||||
third_party_trade_no: '',
|
||||
amount: 1000,
|
||||
status: 2,
|
||||
created_at: time,
|
||||
paid_at: null,
|
||||
expire_at: null
|
||||
}
|
||||
]
|
||||
}
|
||||
const application = {
|
||||
id: 1,
|
||||
status: 4,
|
||||
status_name: '审批提交失败',
|
||||
recoverable: true,
|
||||
approval_submission_status: 3,
|
||||
paid_amount: 1000,
|
||||
created_at: time
|
||||
}
|
||||
const registration = {
|
||||
id: 1,
|
||||
status: 3,
|
||||
recoverable: true,
|
||||
phone: '13800000000',
|
||||
username: 'mock-user',
|
||||
shop_name: '模拟店铺',
|
||||
created_at: time
|
||||
}
|
||||
const rule = {
|
||||
id: 1,
|
||||
package_id: 1,
|
||||
package_name: '模拟套餐',
|
||||
threshold_percent: 80,
|
||||
enabled: true,
|
||||
enabled_name: '启用',
|
||||
remark: '',
|
||||
updated_at: time
|
||||
}
|
||||
const traffic = {
|
||||
id: 1,
|
||||
package_name: '模拟套餐',
|
||||
threshold_percent: 80,
|
||||
threshold_mb: 819.2,
|
||||
used_mb: 0,
|
||||
limit_mb: 1024,
|
||||
triggered_at: time,
|
||||
notification_status: 1,
|
||||
asset_type: 'iot_card',
|
||||
asset_identifier: 'MOCK-ASSET'
|
||||
}
|
||||
const exchange = {
|
||||
id: 1,
|
||||
exchange_no: 'MOCK-EXCHANGE-001',
|
||||
status: 3,
|
||||
status_name: '已发货待确认',
|
||||
status_text: '已发货待确认',
|
||||
old_asset_type: 'iot_card',
|
||||
old_asset_identifier: 'MOCK-OLD-ASSET',
|
||||
new_asset_identifier: 'MOCK-NEW-ASSET',
|
||||
flow_type: 'shipping',
|
||||
flow_type_name: '物流换货',
|
||||
migration_status: 'pending',
|
||||
created_at: time,
|
||||
updated_at: time
|
||||
}
|
||||
|
||||
const associations = [
|
||||
{
|
||||
id: 101,
|
||||
asset_id: 1001,
|
||||
asset_type: 'iot_card',
|
||||
asset_identifier: exchange.new_asset_identifier,
|
||||
phone: '13800000000',
|
||||
status: 1,
|
||||
status_name: '有效',
|
||||
established_at: time
|
||||
},
|
||||
{
|
||||
id: 102,
|
||||
asset_id: 1001,
|
||||
asset_type: 'iot_card',
|
||||
asset_identifier: exchange.new_asset_identifier,
|
||||
phone: '13800000000',
|
||||
status: 0,
|
||||
status_name: '已失效',
|
||||
established_at: time
|
||||
},
|
||||
{
|
||||
id: 103,
|
||||
asset_id: 1002,
|
||||
asset_type: 'iot_card',
|
||||
asset_identifier: exchange.old_asset_identifier,
|
||||
phone: '13800000000',
|
||||
status: 1,
|
||||
status_name: '有效',
|
||||
established_at: time
|
||||
},
|
||||
{
|
||||
id: 104,
|
||||
asset_id: 1002,
|
||||
asset_type: 'iot_card',
|
||||
asset_identifier: exchange.old_asset_identifier,
|
||||
phone: '13900000000',
|
||||
status: 1,
|
||||
status_name: '有效',
|
||||
established_at: time
|
||||
}
|
||||
]
|
||||
|
||||
export const mockApiPlugin = {
|
||||
name: 'october-local-mock-api',
|
||||
configureServer(server) {
|
||||
server.middlewares.use((req, res, next) => {
|
||||
const url = new URL(req.url, 'http://127.0.0.1')
|
||||
const path = url.pathname
|
||||
if (!path.startsWith('/api/')) return next()
|
||||
if (path === '/api/auth/login' || path === '/api/auth/me') {
|
||||
const user = {
|
||||
id: 1,
|
||||
user_type: 1,
|
||||
username: '模拟管理员',
|
||||
phone: '13800000000',
|
||||
roles: ['R_SUPER']
|
||||
}
|
||||
res.setHeader('Content-Type', 'application/json; charset=utf-8')
|
||||
res.end(
|
||||
JSON.stringify({
|
||||
code: 0,
|
||||
msg: 'mock',
|
||||
data: {
|
||||
access_token: 'local-mock-only',
|
||||
refresh_token: '',
|
||||
expires_in: 3600,
|
||||
user,
|
||||
permissions: ['*:*:*'],
|
||||
buttons: [],
|
||||
menus: [{ url: '/asset-management', name: '资产管理' }]
|
||||
}
|
||||
})
|
||||
)
|
||||
return
|
||||
}
|
||||
if (req.method !== 'GET') {
|
||||
if (path === '/api/admin/exchanges/2/complete') {
|
||||
res.setHeader('Content-Type', 'application/json; charset=utf-8')
|
||||
res.end(
|
||||
JSON.stringify({
|
||||
code: 1202,
|
||||
data: null,
|
||||
msg: '该资产已完成过换货,如需再次换货请使用换货后的新资产'
|
||||
})
|
||||
)
|
||||
return
|
||||
}
|
||||
if (path === '/api/admin/phone-asset-associations/batch-unbind') {
|
||||
let body = ''
|
||||
req.on('data', (chunk) => {
|
||||
body += chunk
|
||||
})
|
||||
req.on('end', () => {
|
||||
const request = JSON.parse(body)
|
||||
const items = request.assets.map((asset) => {
|
||||
const matches = associations.filter(
|
||||
(row) =>
|
||||
row.asset_id === asset.asset_id &&
|
||||
row.asset_type === asset.asset_type &&
|
||||
row.status === 1
|
||||
)
|
||||
matches.forEach((row) => {
|
||||
row.status = 0
|
||||
row.status_name = '已失效'
|
||||
})
|
||||
return { ...asset, success: true, unbound_count: matches.length, reason: '' }
|
||||
})
|
||||
res.setHeader('Content-Type', 'application/json; charset=utf-8')
|
||||
res.end(
|
||||
JSON.stringify({
|
||||
code: 0,
|
||||
msg: 'mock',
|
||||
data: { success_count: items.length, fail_count: 0, items }
|
||||
})
|
||||
)
|
||||
})
|
||||
return
|
||||
}
|
||||
res.setHeader('Content-Type', 'application/json; charset=utf-8')
|
||||
res.end(
|
||||
JSON.stringify({
|
||||
code: 1202,
|
||||
msg: '新资产已绑定手机号,请先在后台解除该资产的手机号绑定,再重新提交换货申请',
|
||||
data: { phone: '13800000000' }
|
||||
})
|
||||
)
|
||||
return
|
||||
}
|
||||
const page = (items) => ({
|
||||
items,
|
||||
list: items,
|
||||
total: items.length,
|
||||
page: 1,
|
||||
size: 20,
|
||||
page_size: 20
|
||||
})
|
||||
let data = page([])
|
||||
if (path === '/api/admin/phone-asset-associations')
|
||||
data = page(
|
||||
associations.filter(
|
||||
(row) =>
|
||||
(!url.searchParams.get('asset_identifier') ||
|
||||
row.asset_identifier === url.searchParams.get('asset_identifier')) &&
|
||||
(!url.searchParams.get('phone') || row.phone === url.searchParams.get('phone'))
|
||||
)
|
||||
)
|
||||
if (path === '/api/admin/orders/1') data = order
|
||||
if (path === '/api/admin/exchanges')
|
||||
data = page([exchange, { ...exchange, id: 2, exchange_no: 'MOCK-EXCHANGE-002' }])
|
||||
if (path === '/api/admin/exchanges/1') data = exchange
|
||||
if (path === '/api/admin/exchanges/2')
|
||||
data = { ...exchange, id: 2, exchange_no: 'MOCK-EXCHANGE-002' }
|
||||
if (path === '/api/admin/orders') data = page([order])
|
||||
if (path === '/api/admin/employee-collection-applications/1')
|
||||
data = { application, allocations: [], attempts: [] }
|
||||
if (path === '/api/admin/employee-collection-applications') data = page([application])
|
||||
if (path === '/api/admin/agent-distribution-registrations/1') data = registration
|
||||
if (path === '/api/admin/agent-distribution-registrations') data = page([registration])
|
||||
if (path === '/api/admin/package-traffic-alert-rules') data = page([rule])
|
||||
if (path === '/api/admin/package-traffic-alert-rules/1') data = rule
|
||||
if (path === '/api/admin/package-traffic-alerts') data = page([traffic])
|
||||
if (path === '/api/admin/package-traffic-alerts/1') data = traffic
|
||||
res.setHeader('Content-Type', 'application/json; charset=utf-8')
|
||||
res.end(JSON.stringify({ code: 0, msg: 'mock', data }))
|
||||
})
|
||||
}
|
||||
}
|
||||
65
scripts/tests/refundMethodOptions.test.mjs
Normal file
65
scripts/tests/refundMethodOptions.test.mjs
Normal file
@@ -0,0 +1,65 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import ts from 'typescript'
|
||||
|
||||
function evaluate(source, imports = {}) {
|
||||
const compiled = ts.transpileModule(source, {
|
||||
compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.CommonJS }
|
||||
}).outputText
|
||||
const module = { exports: {} }
|
||||
new Function('require', 'module', 'exports', compiled)(
|
||||
(name) => {
|
||||
assert.ok(imports[name], `Unexpected dependency: ${name}`)
|
||||
return imports[name]
|
||||
},
|
||||
module,
|
||||
module.exports
|
||||
)
|
||||
return module.exports
|
||||
}
|
||||
|
||||
const types = evaluate(readFileSync('src/types/api/refund.ts', 'utf8'))
|
||||
const { RefundMethod } = types
|
||||
const { RefundMethodOptions, RefundMethodNameMap } = evaluate(
|
||||
readFileSync('src/config/constants/refund.ts', 'utf8'),
|
||||
{ '@/types/api/refund': types }
|
||||
)
|
||||
const dialogSource = readFileSync('src/components/business/CreateRefundDialog.vue', 'utf8')
|
||||
|
||||
test('refund forms hide original route while preserving historical labels', () => {
|
||||
assert.deepEqual(
|
||||
RefundMethodOptions.map((option) => option.value),
|
||||
[RefundMethod.CUSTOMER_ACCOUNT, RefundMethod.ASSET_WALLET, RefundMethod.AGENT_WALLET]
|
||||
)
|
||||
assert.equal(RefundMethodNameMap[RefundMethod.ORIGINAL_ROUTE], '原路退回')
|
||||
for (const path of [
|
||||
'src/components/business/CreateRefundDialog.vue',
|
||||
'src/views/finance/refund/index.vue',
|
||||
'src/views/finance/refund/detail.vue'
|
||||
]) {
|
||||
assert.match(readFileSync(path, 'utf8'), /v-for="opt in RefundMethodOptions"/)
|
||||
}
|
||||
})
|
||||
|
||||
test('creation defaults and reset never select the hidden original route', () => {
|
||||
assert.match(dialogSource, /method: RefundMethod\.CUSTOMER_ACCOUNT/)
|
||||
assert.match(dialogSource, /formData\.method = RefundMethod\.CUSTOMER_ACCOUNT/)
|
||||
assert.doesNotMatch(dialogSource, /RefundMethod\.ORIGINAL_ROUTE/)
|
||||
const resolver = dialogSource.match(/const resolveRefundMethod = [\s\S]*?\n }/)[0]
|
||||
const { resolveRefundMethod } = evaluate(
|
||||
`const RefundMethod = ${JSON.stringify(RefundMethod)}; export ${resolver}`
|
||||
)
|
||||
for (const payment_method of ['wechat', 'alipay', 'fuiou', 'offline']) {
|
||||
assert.equal(resolveRefundMethod({ payment_method }), RefundMethod.CUSTOMER_ACCOUNT)
|
||||
}
|
||||
assert.match(dialogSource, /fuiou: '富友支付'/)
|
||||
assert.equal(
|
||||
resolveRefundMethod({ payment_method: 'wallet', buyer_type: 'agent' }),
|
||||
RefundMethod.AGENT_WALLET
|
||||
)
|
||||
assert.equal(
|
||||
resolveRefundMethod({ payment_method: 'wallet', buyer_type: 'customer' }),
|
||||
RefundMethod.ASSET_WALLET
|
||||
)
|
||||
})
|
||||
14
scripts/tests/register-esbuild.mjs
Normal file
14
scripts/tests/register-esbuild.mjs
Normal file
@@ -0,0 +1,14 @@
|
||||
import { createRequire, register } from 'node:module'
|
||||
import { isMainThread } from 'node:worker_threads'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
|
||||
// pnpm 的严格依赖布局下,旧测试从根目录无法直接导入 Vite 的 esbuild 依赖。
|
||||
const require = createRequire(import.meta.url)
|
||||
const esbuildUrl = pathToFileURL(createRequire(require.resolve('vite')).resolve('esbuild')).href
|
||||
if (isMainThread) register(import.meta.url, { parentURL: import.meta.url })
|
||||
|
||||
export function resolve(specifier, context, nextResolve) {
|
||||
return specifier === 'esbuild'
|
||||
? { url: esbuildUrl, shortCircuit: true }
|
||||
: nextResolve(specifier, context)
|
||||
}
|
||||
258
scripts/tests/tableHeaderDragLifecycle.test.mjs
Normal file
258
scripts/tests/tableHeaderDragLifecycle.test.mjs
Normal file
@@ -0,0 +1,258 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import ts from 'typescript'
|
||||
import * as vue from 'vue'
|
||||
import { compileScript, parse } from '@vue/compiler-sfc'
|
||||
|
||||
const { descriptor } = parse(readFileSync('src/components/core/tables/ArtTableHeader.vue', 'utf8'))
|
||||
const componentSource = compileScript(descriptor, {
|
||||
id: 'table-header-drag-test',
|
||||
inlineTemplate: true
|
||||
}).content
|
||||
|
||||
class HostElement {
|
||||
constructor(tag, text = '') {
|
||||
this.tag = tag
|
||||
this.text = text
|
||||
this.props = {}
|
||||
this.children = []
|
||||
this.parentNode = null
|
||||
}
|
||||
|
||||
get isConnected() {
|
||||
return this.tag === 'root' || Boolean(this.parentNode?.isConnected)
|
||||
}
|
||||
|
||||
removeChild(child) {
|
||||
const index = this.children.indexOf(child)
|
||||
assert.notEqual(index, -1)
|
||||
this.children.splice(index, 1)
|
||||
child.parentNode = null
|
||||
}
|
||||
}
|
||||
|
||||
function evaluate(source, imports) {
|
||||
const compiled = ts.transpileModule(source, {
|
||||
compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.CommonJS }
|
||||
}).outputText
|
||||
const module = { exports: {} }
|
||||
new Function('require', 'module', 'exports', compiled)(
|
||||
(name) => {
|
||||
assert.ok(imports[name], `Unexpected dependency: ${name}`)
|
||||
return imports[name]
|
||||
},
|
||||
module,
|
||||
module.exports
|
||||
)
|
||||
return module.exports
|
||||
}
|
||||
|
||||
function mountHeader(t) {
|
||||
const previousGlobals = { HTMLElement: globalThis.HTMLElement, document: globalThis.document }
|
||||
globalThis.HTMLElement = HostElement
|
||||
globalThis.document = { addEventListener() {}, removeEventListener() {} }
|
||||
const controls = []
|
||||
const store = vue.reactive({
|
||||
tableSize: 'default',
|
||||
isZebra: false,
|
||||
isBorder: false,
|
||||
isHeaderBackground: false
|
||||
})
|
||||
const slotComponent = (name) =>
|
||||
vue.defineComponent({
|
||||
name,
|
||||
setup:
|
||||
(_, { slots, attrs }) =>
|
||||
() =>
|
||||
vue.h(name, attrs, [slots.reference?.(), slots.default?.(), slots.dropdown?.()])
|
||||
})
|
||||
const elements = Object.fromEntries(
|
||||
['ElPopover', 'ElCheckbox', 'ElDropdown', 'ElDropdownMenu', 'ElDropdownItem'].map((name) => [
|
||||
name,
|
||||
slotComponent(name)
|
||||
])
|
||||
)
|
||||
const component = evaluate(componentSource, {
|
||||
vue,
|
||||
pinia: { storeToRefs: (value) => vue.toRefs(value) },
|
||||
'element-plus': elements,
|
||||
'vue-i18n': { useI18n: () => ({ t: (key) => key }) },
|
||||
'@/enums/formEnum': { TableSizeEnum: { SMALL: 'small', DEFAULT: 'default', LARGE: 'large' } },
|
||||
'@/store/modules/table': { useTableStore: () => store },
|
||||
'vue-draggable-plus': {
|
||||
useDraggable: (target, model, options) => {
|
||||
const control = {
|
||||
target,
|
||||
model,
|
||||
options,
|
||||
starts: [],
|
||||
active: false,
|
||||
destroys: 0,
|
||||
start(element = target.value) {
|
||||
assert.ok(
|
||||
element instanceof HostElement && element.isConnected,
|
||||
'Sortable needs a connected native element'
|
||||
)
|
||||
this.starts.push(element)
|
||||
this.active = true
|
||||
},
|
||||
destroy() {
|
||||
this.destroys += 1
|
||||
this.active = false
|
||||
}
|
||||
}
|
||||
controls.push(control)
|
||||
vue.onMounted(() => {
|
||||
if (options.immediate !== false) control.start()
|
||||
})
|
||||
return control
|
||||
}
|
||||
}
|
||||
}).default
|
||||
const renderer = vue.createRenderer({
|
||||
createElement: (tag) => new HostElement(tag),
|
||||
createText: (text) => new HostElement('#text', text),
|
||||
createComment: (text) => new HostElement('#comment', text),
|
||||
setText: (node, text) => {
|
||||
node.text = text
|
||||
},
|
||||
setElementText: (node, text) => {
|
||||
node.text = text
|
||||
node.children = []
|
||||
},
|
||||
parentNode: (node) => node.parentNode,
|
||||
nextSibling: (node) => {
|
||||
const siblings = node.parentNode?.children || []
|
||||
return siblings[siblings.indexOf(node) + 1] || null
|
||||
},
|
||||
patchProp: (node, key, _, value) => {
|
||||
node.props[key] = value
|
||||
},
|
||||
insert: (node, parent, anchor) => {
|
||||
node.parentNode?.removeChild(node)
|
||||
const index = anchor ? parent.children.indexOf(anchor) : parent.children.length
|
||||
assert.notEqual(index, -1)
|
||||
parent.children.splice(index, 0, node)
|
||||
node.parentNode = parent
|
||||
},
|
||||
remove: (node) => node.parentNode?.removeChild(node)
|
||||
})
|
||||
const columns = vue.ref([
|
||||
{ prop: 'phone', label: '手机号', checked: true },
|
||||
{ prop: 'shop_name', label: '店铺', checked: false }
|
||||
])
|
||||
const active = vue.ref(true)
|
||||
const root = new HostElement('root')
|
||||
const app = renderer.createApp({
|
||||
render: () =>
|
||||
vue.h(vue.KeepAlive, null, {
|
||||
default: () =>
|
||||
active.value
|
||||
? vue.h(component, {
|
||||
columns: columns.value,
|
||||
'onUpdate:columns': (value) => {
|
||||
columns.value = value
|
||||
}
|
||||
})
|
||||
: vue.h('placeholder')
|
||||
})
|
||||
})
|
||||
for (const [name, element] of Object.entries(elements)) app.component(name, element)
|
||||
app.mount(root)
|
||||
let mounted = true
|
||||
const unmount = () => {
|
||||
if (mounted) {
|
||||
app.unmount()
|
||||
mounted = false
|
||||
}
|
||||
}
|
||||
t.after(() => {
|
||||
unmount()
|
||||
for (const [key, value] of Object.entries(previousGlobals)) {
|
||||
if (value === undefined) delete globalThis[key]
|
||||
else globalThis[key] = value
|
||||
}
|
||||
})
|
||||
const find = (node, tag) =>
|
||||
node.tag === tag ? node : node.children.map((child) => find(child, tag)).find(Boolean)
|
||||
return { control: controls[0], columns, active, unmount, popover: find(root, 'ElPopover') }
|
||||
}
|
||||
|
||||
const openPopover = (popover) => {
|
||||
popover.props['onUpdate:visible'](true)
|
||||
popover.props.onAfterEnter()
|
||||
}
|
||||
|
||||
test('table header does not auto-start Sortable until the column popover has entered', async (t) => {
|
||||
const { control, popover } = mountHeader(t)
|
||||
await vue.nextTick()
|
||||
assert.equal(control.options.immediate, false)
|
||||
assert.equal(control.starts.length, 0)
|
||||
popover.props.onAfterEnter()
|
||||
assert.equal(control.starts.length, 0, 'a stale enter without opening is ignored')
|
||||
openPopover(popover)
|
||||
assert.equal(control.starts.length, 1)
|
||||
assert.equal(control.starts[0], control.target.value)
|
||||
})
|
||||
|
||||
test('closing and reopening column settings destroys the drag instance and rejects a late enter', async (t) => {
|
||||
const { control, popover } = mountHeader(t)
|
||||
openPopover(popover)
|
||||
popover.props.onBeforeLeave()
|
||||
assert.equal(control.active, false)
|
||||
assert.equal(control.destroys, 1)
|
||||
popover.props.onAfterEnter()
|
||||
assert.equal(control.starts.length, 1)
|
||||
openPopover(popover)
|
||||
assert.equal(control.starts.length, 2)
|
||||
})
|
||||
|
||||
test('missing, non-element and detached column targets never start Sortable', async (t) => {
|
||||
const { control, popover } = mountHeader(t)
|
||||
const original = control.target.value
|
||||
for (const target of [null, undefined, {}, new HostElement('detached')]) {
|
||||
control.target.value = target
|
||||
openPopover(popover)
|
||||
assert.equal(control.starts.length, 0)
|
||||
}
|
||||
control.target.value = original
|
||||
openPopover(popover)
|
||||
assert.equal(control.starts.length, 1)
|
||||
})
|
||||
|
||||
test('unmounting before or after opening safely cleans up and rejects queued popover callbacks', async (t) => {
|
||||
for (const opened of [false, true]) {
|
||||
const { control, popover, unmount } = mountHeader(t)
|
||||
if (opened) openPopover(popover)
|
||||
const count = control.starts.length
|
||||
unmount()
|
||||
await vue.nextTick()
|
||||
assert.equal(control.active, false)
|
||||
assert.ok(control.destroys > 0)
|
||||
popover.props.onAfterEnter()
|
||||
assert.equal(control.starts.length, count)
|
||||
}
|
||||
})
|
||||
|
||||
test('cached page deactivation cleans up; returning preserves column order and checked state', async (t) => {
|
||||
const { control, popover, active, columns } = mountHeader(t)
|
||||
openPopover(popover)
|
||||
control.model.value = [...control.model.value].reverse()
|
||||
await vue.nextTick()
|
||||
assert.deepEqual(
|
||||
columns.value.map((item) => item.prop),
|
||||
['shop_name', 'phone']
|
||||
)
|
||||
active.value = false
|
||||
await vue.nextTick()
|
||||
assert.equal(control.active, false)
|
||||
popover.props.onAfterEnter()
|
||||
assert.equal(control.starts.length, 1)
|
||||
active.value = true
|
||||
await vue.nextTick()
|
||||
openPopover(popover)
|
||||
assert.equal(control.starts.length, 2)
|
||||
assert.equal(columns.value[0].checked, false)
|
||||
assert.equal(columns.value[1].checked, true)
|
||||
})
|
||||
71
scripts/tests/verifyBuild.mjs
Normal file
71
scripts/tests/verifyBuild.mjs
Normal file
@@ -0,0 +1,71 @@
|
||||
import { mkdtemp, readFile } from 'node:fs/promises'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { build, createServer, loadConfigFromFile } from 'vite'
|
||||
import Components from 'unplugin-vue-components/vite'
|
||||
import AutoImport from 'unplugin-auto-import/vite'
|
||||
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
||||
|
||||
// 与生产配置相同的构建,关闭声明文件生成,避免覆盖工作区已有的用户修改。
|
||||
const protectedPaths = [
|
||||
'src/types/components.d.ts',
|
||||
'src/types/auto-imports.d.ts',
|
||||
'.auto-import.json'
|
||||
]
|
||||
const snapshots = await Promise.all(protectedPaths.map((path) => readFile(path)))
|
||||
const serve = process.argv.includes('--serve')
|
||||
const loaded = await loadConfigFromFile({
|
||||
command: serve ? 'serve' : 'build',
|
||||
mode: serve ? 'development' : 'production'
|
||||
})
|
||||
const outputDir = await mkdtemp(join(tmpdir(), 'one-pipe-october-build-'))
|
||||
const plugins = loaded.config.plugins
|
||||
.flat(Infinity)
|
||||
.filter(
|
||||
(plugin) => plugin && !['unplugin-vue-components', 'unplugin-auto-import'].includes(plugin.name)
|
||||
)
|
||||
plugins.push(
|
||||
Components({
|
||||
deep: true,
|
||||
extensions: ['vue'],
|
||||
dirs: ['src/components'],
|
||||
resolvers: [ElementPlusResolver()],
|
||||
dts: false
|
||||
}),
|
||||
AutoImport({
|
||||
imports: ['vue', 'vue-router', '@vueuse/core', 'pinia'],
|
||||
resolvers: [ElementPlusResolver()],
|
||||
dts: false,
|
||||
eslintrc: { enabled: false }
|
||||
})
|
||||
)
|
||||
if (serve) {
|
||||
const { mockApiPlugin } = await import('./octoberBrowserFixtures.mjs')
|
||||
const server = await createServer({
|
||||
...loaded.config,
|
||||
configFile: false,
|
||||
mode: 'development',
|
||||
plugins: [mockApiPlugin, ...plugins],
|
||||
server: { host: '127.0.0.1', port: 5190, strictPort: true, proxy: {} }
|
||||
})
|
||||
await server.listen()
|
||||
console.log(
|
||||
'Local mock preview: http://127.0.0.1:5190 (all /api requests intercepted; no real backend writes)'
|
||||
)
|
||||
} else {
|
||||
await build({
|
||||
...loaded.config,
|
||||
configFile: false,
|
||||
plugins,
|
||||
logLevel: 'warn',
|
||||
build: { ...loaded.config.build, outDir: outputDir, emptyOutDir: false }
|
||||
})
|
||||
}
|
||||
for (let i = 0; i < protectedPaths.length; i++) {
|
||||
if (!snapshots[i].equals(await readFile(protectedPaths[i])))
|
||||
throw new Error(`Build modified protected file: ${protectedPaths[i]}`)
|
||||
}
|
||||
if (!serve)
|
||||
console.log(
|
||||
`Production build passed. Generated declaration files preserved. Output: ${outputDir}`
|
||||
)
|
||||
108
scripts/tests/wechatAuthorization.test.mjs
Normal file
108
scripts/tests/wechatAuthorization.test.mjs
Normal file
@@ -0,0 +1,108 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { createRequire } from 'node:module'
|
||||
import ts from 'typescript'
|
||||
import * as vue from 'vue'
|
||||
import { compileScript, parse } from '@vue/compiler-sfc'
|
||||
|
||||
const require = createRequire(import.meta.url)
|
||||
const elementPlusRequire = createRequire(require.resolve('element-plus'))
|
||||
const Schema = elementPlusRequire('async-validator').default
|
||||
const { descriptor } = parse(
|
||||
readFileSync(
|
||||
'src/views/settings/payment-merchant-pools/components/WechatAuthorizationManagement.vue',
|
||||
'utf8'
|
||||
)
|
||||
)
|
||||
const compiled = ts.transpileModule(
|
||||
compileScript(descriptor, { id: 'wechat-authorization-test' }).content,
|
||||
{ compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.CommonJS } }
|
||||
).outputText
|
||||
|
||||
function harness() {
|
||||
const calls = []
|
||||
const imports = {
|
||||
vue: { ...vue, onMounted: () => {}, onUnmounted: () => {} },
|
||||
'element-plus': { ElMessage: { success: () => {} } },
|
||||
'@/api/modules': {
|
||||
PaymentMerchantPoolsService: {
|
||||
updateWechatAuthorization: async (payload) => {
|
||||
calls.push({ ...payload })
|
||||
return { code: 0, data: payload }
|
||||
}
|
||||
}
|
||||
},
|
||||
'@/composables/useAuth': { useAuth: () => ({ hasAuth: () => true }) },
|
||||
'@/config/constants/paymentMerchantPools': {
|
||||
PAYMENT_MERCHANT_POOL_PERMISSIONS: { wechatAuthEdit: 'wechat_auth_edit' }
|
||||
}
|
||||
}
|
||||
const module = { exports: {} }
|
||||
new Function('require', 'module', 'exports', 'computed', compiled)(
|
||||
(name) => {
|
||||
assert.ok(imports[name], `Unexpected runtime dependency: ${name}`)
|
||||
return imports[name]
|
||||
},
|
||||
module,
|
||||
module.exports,
|
||||
vue.computed
|
||||
)
|
||||
const state = module.exports.default.setup({}, { expose: () => {} })
|
||||
state.formRef.value = {
|
||||
validate: () => new Schema(state.formRules).validate(state.form)
|
||||
}
|
||||
return { state, calls }
|
||||
}
|
||||
|
||||
test('miniapp AppID starts empty without default or placeholder text', () => {
|
||||
const { state } = harness()
|
||||
assert.equal(state.form.miniapp_app_id, '')
|
||||
const input = descriptor.template.content.match(
|
||||
/<ElInput\b[^>]*v-model="form\.miniapp_app_id"[^>]*\/>/
|
||||
)?.[0]
|
||||
assert.ok(input)
|
||||
assert.doesNotMatch(input, /\b(?:placeholder|(?:default-)?value)\s*=/)
|
||||
})
|
||||
|
||||
for (const enabled of [false, true]) {
|
||||
for (const miniappAppId of ['', ' ', null, undefined]) {
|
||||
test(`saves ${enabled ? 'enabled' : 'disabled'} authorization without optional AppID ${JSON.stringify(miniappAppId)}`, async () => {
|
||||
const { state, calls } = harness()
|
||||
Object.assign(state.form, {
|
||||
enabled,
|
||||
miniapp_app_id: miniappAppId,
|
||||
oa_app_id: 'wx-official-account',
|
||||
oa_oauth_redirect_url: 'https://example.com/oauth'
|
||||
})
|
||||
await state.handleSubmit()
|
||||
|
||||
assert.deepEqual(calls, [
|
||||
{
|
||||
enabled,
|
||||
oa_app_id: 'wx-official-account',
|
||||
oa_oauth_redirect_url: 'https://example.com/oauth'
|
||||
}
|
||||
])
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
test('submits a provided miniapp AppID after trimming and clears sensitive inputs after saving', async () => {
|
||||
const { state, calls } = harness()
|
||||
state.form.miniapp_app_id = ' wx-miniapp '
|
||||
state.sensitive.miniapp_app_secret = 'new-miniapp-secret'
|
||||
await state.handleSubmit()
|
||||
|
||||
assert.equal(calls[0].miniapp_app_id, 'wx-miniapp')
|
||||
assert.equal(calls[0].miniapp_app_secret, 'new-miniapp-secret')
|
||||
assert.equal(state.sensitive.miniapp_app_secret, '')
|
||||
})
|
||||
|
||||
test('still rejects a miniapp AppID longer than 64 characters', async () => {
|
||||
const { state, calls } = harness()
|
||||
state.form.miniapp_app_id = 'x'.repeat(65)
|
||||
await state.handleSubmit()
|
||||
|
||||
assert.deepEqual(calls, [])
|
||||
})
|
||||
363
scripts/tests/wecomSceneMappings.test.mjs
Normal file
363
scripts/tests/wecomSceneMappings.test.mjs
Normal file
@@ -0,0 +1,363 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import * as vue from 'vue'
|
||||
import { renderToString } from 'vue/server-renderer'
|
||||
import { compileScript, parse } from '@vue/compiler-sfc'
|
||||
import ts from 'typescript'
|
||||
|
||||
const { descriptor } = parse(readFileSync('src/views/settings/wecom/scenes/index.vue', 'utf8'))
|
||||
const compiled = ts.transpileModule(
|
||||
compileScript(descriptor, { id: 'wecom-mappings-test' }).content,
|
||||
{
|
||||
compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.CommonJS }
|
||||
}
|
||||
).outputText
|
||||
const field = (code, name = code, required_mapping = false) => ({
|
||||
code,
|
||||
name,
|
||||
required_mapping,
|
||||
value_type: 'string',
|
||||
description: `${name}说明`
|
||||
})
|
||||
const refundFields = [
|
||||
['refund_no', '退款单号'],
|
||||
['order_id', '订单 ID'],
|
||||
['order_no', '订单号'],
|
||||
['asset_identifier', '资产标识'],
|
||||
['actual_received_amount', '订单实收金额'],
|
||||
['requested_refund_amount', '申请退款金额'],
|
||||
['refund_voucher_key', '退款凭证'],
|
||||
['refund_reason', '退款原因'],
|
||||
['package_usage_id', '套餐使用记录 ID'],
|
||||
['refund_asset_type', '资产类型', true],
|
||||
['refund_device_type', '设备类型', true],
|
||||
['refund_device_model', '设备型号', true],
|
||||
['refund_package_used_mb', '当前退款套餐已用量(MB)', true],
|
||||
['refund_package_total_mb', '当前退款套餐总量(MB)', true],
|
||||
['refund_channel_trade_no', '原支付渠道交易流水号', true],
|
||||
['refund_applicant_remark', '申请人备注', true],
|
||||
['refund_method_code', '退款方式编码'],
|
||||
['refund_method', '退款方式', true],
|
||||
['customer_account_info', '客户收款信息'],
|
||||
['customer_voucher_key', '客户收款凭证'],
|
||||
['submitter_id', '提交人账号 ID'],
|
||||
['submitter_name', '提交人名称']
|
||||
].map((args) => field(...args))
|
||||
const control = (id, required = false) => ({ id, title: `控件 ${id}`, type: 'Text', required })
|
||||
const response = (data) => ({ code: 0, data })
|
||||
const scene = (mapping = []) => ({
|
||||
business_type: 'refund_approval',
|
||||
application_id: 1,
|
||||
template_id: 'template-1',
|
||||
status: 1,
|
||||
control_mapping: mapping
|
||||
})
|
||||
const settle = () => new Promise(setImmediate)
|
||||
function deferred() {
|
||||
let resolve, reject
|
||||
const promise = new Promise((yes, no) => {
|
||||
resolve = yes
|
||||
reject = no
|
||||
})
|
||||
return { promise, resolve, reject }
|
||||
}
|
||||
|
||||
function harness(overrides = {}) {
|
||||
const calls = { fields: [], templates: [], saves: [], warnings: [], errors: [] }
|
||||
const service = {
|
||||
getBusinessFields: async (type) => {
|
||||
calls.fields.push(type)
|
||||
return response({ items: refundFields })
|
||||
},
|
||||
inspectTemplate: async (...args) => {
|
||||
calls.templates.push(args)
|
||||
return response({ name: '模板', controls: [control('text-1')] })
|
||||
},
|
||||
saveScene: async (...args) => {
|
||||
calls.saves.push(args)
|
||||
return response({})
|
||||
},
|
||||
getApplications: async () => response({ items: [] }),
|
||||
getScenes: async () => response({ items: [] }),
|
||||
...overrides
|
||||
}
|
||||
const imports = {
|
||||
vue: { ...vue, onMounted() {} },
|
||||
'element-plus': {
|
||||
ElMessage: {
|
||||
warning: (message) => calls.warnings.push(message),
|
||||
error: (message) => calls.errors.push(message),
|
||||
success() {}
|
||||
},
|
||||
ElTag: {}
|
||||
},
|
||||
'@/composables/useCheckedColumns': {
|
||||
useCheckedColumns: () => ({ columns: vue.ref([]), columnChecks: vue.ref([]) })
|
||||
},
|
||||
'@/composables/useAuth': { useAuth: () => ({ hasAuth: () => true }) },
|
||||
'@/api/modules': { WecomService: service },
|
||||
'@/config/constants': { JULY_PERMISSIONS: { wecom: {} } },
|
||||
'@/utils/business/format': { formatDateTime: (value) => value }
|
||||
}
|
||||
const module = { exports: {} }
|
||||
new Function('require', 'module', 'exports', compiled)(
|
||||
(name) => {
|
||||
assert.ok(imports[name], `Unexpected dependency: ${name}`)
|
||||
return imports[name]
|
||||
},
|
||||
module,
|
||||
module.exports
|
||||
)
|
||||
const state = module.exports.default.setup({}, { expose() {} })
|
||||
return { state, service, calls }
|
||||
}
|
||||
|
||||
test('opening a new scene displays all 22 API fields before any template is synchronized', async () => {
|
||||
const { state, calls } = harness()
|
||||
state.createScene()
|
||||
await settle()
|
||||
assert.deepEqual(calls.fields, ['refund_approval'])
|
||||
assert.equal(calls.templates.length, 0)
|
||||
assert.equal(state.mappingRows.value.length, 22)
|
||||
assert.deepEqual(
|
||||
state.mappingRows.value.map((row) => row.business_field),
|
||||
refundFields.map((f) => f.code)
|
||||
)
|
||||
for (const [index, row] of state.mappingRows.value.entries()) {
|
||||
assert.equal(row.field_name, refundFields[index].name)
|
||||
assert.equal(row.required_mapping, refundFields[index].required_mapping)
|
||||
assert.equal(row.control_id, '')
|
||||
}
|
||||
})
|
||||
|
||||
test('selecting a business type immediately replaces old rows with all fields for that type', async () => {
|
||||
const { state, service } = harness()
|
||||
state.createScene()
|
||||
await settle()
|
||||
service.getBusinessFields = async (type) => {
|
||||
assert.equal(type, 'offline_recharge_approval')
|
||||
return response({ items: [field('recharge_no', '充值单号', true), field('remark', '备注')] })
|
||||
}
|
||||
state.sceneForm.business_type = 'offline_recharge_approval'
|
||||
state.handleBusinessTypeChange()
|
||||
assert.equal(state.mappingRows.value.length, 0)
|
||||
await settle()
|
||||
assert.deepEqual(
|
||||
state.mappingRows.value.map((row) => row.business_field),
|
||||
['recharge_no', 'remark']
|
||||
)
|
||||
})
|
||||
|
||||
for (const templateFirst of [false, true]) {
|
||||
test(`editing retains saved bindings and option mappings when ${templateFirst ? 'template' : 'fields'} responds first`, async () => {
|
||||
const fields = deferred()
|
||||
const template = deferred()
|
||||
const { state } = harness({
|
||||
getBusinessFields: () => fields.promise,
|
||||
inspectTemplate: () => template.promise
|
||||
})
|
||||
state.editScene(
|
||||
scene([
|
||||
{
|
||||
business_field: 'refund_method',
|
||||
control_id: 'select-1',
|
||||
control_type: 'Selector',
|
||||
option_mapping: { original: '原路退回' }
|
||||
}
|
||||
])
|
||||
)
|
||||
const finishFields = () => fields.resolve(response({ items: refundFields }))
|
||||
const finishTemplate = () =>
|
||||
template.resolve(
|
||||
response({
|
||||
name: '退款模板',
|
||||
controls: [{ ...control('select-1'), type: 'Selector' }]
|
||||
})
|
||||
)
|
||||
;(templateFirst ? finishTemplate : finishFields)()
|
||||
await settle()
|
||||
;(templateFirst ? finishFields : finishTemplate)()
|
||||
await settle()
|
||||
assert.equal(state.mappingRows.value.length, 22)
|
||||
const mapping = state.mappingRows.value.find((row) => row.business_field === 'refund_method')
|
||||
assert.equal(mapping.control_id, 'select-1')
|
||||
assert.equal(mapping.control_title, '控件 select-1')
|
||||
assert.equal(mapping.control_type, 'Selector')
|
||||
assert.deepEqual(JSON.parse(mapping.option_mapping), { original: '原路退回' })
|
||||
})
|
||||
}
|
||||
|
||||
test('resyncing templates keeps all business rows but clears controls removed from the template', async () => {
|
||||
const { state, service } = harness()
|
||||
state.editScene(
|
||||
scene([{ business_field: 'refund_no', control_id: 'text-1', control_type: 'Text' }])
|
||||
)
|
||||
await settle()
|
||||
service.inspectTemplate = async () => response({ name: '新模板', controls: [control('text-2')] })
|
||||
await state.syncTemplate()
|
||||
assert.equal(state.mappingRows.value.length, 22)
|
||||
assert.equal(state.mappingRows.value[0].control_id, '')
|
||||
assert.equal(state.mappingRows.value[0].control_type, '')
|
||||
})
|
||||
|
||||
test('required_mapping blocks saving missing business bindings; optional blank fields are not submitted', async () => {
|
||||
const { state, calls } = harness({
|
||||
getBusinessFields: async () =>
|
||||
response({ items: [field('required', '必填字段', true), field('optional')] })
|
||||
})
|
||||
state.editScene(scene())
|
||||
await settle()
|
||||
await state.saveScene()
|
||||
assert.equal(calls.saves.length, 0)
|
||||
assert.match(calls.warnings.at(-1), /必填业务字段“必填字段”/)
|
||||
const row = state.mappingRows.value[0]
|
||||
row.control_id = 'text-1'
|
||||
state.handleControlChange(row)
|
||||
await state.saveScene()
|
||||
assert.deepEqual(calls.saves[0], [
|
||||
'refund_approval',
|
||||
{
|
||||
application_id: 1,
|
||||
template_id: 'template-1',
|
||||
status: 1,
|
||||
control_mapping: [
|
||||
{
|
||||
business_field: 'required',
|
||||
control_id: 'text-1',
|
||||
control_type: 'Text',
|
||||
option_mapping: {}
|
||||
}
|
||||
]
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
test('required template controls still require a business field independently of required_mapping', async () => {
|
||||
const { state, calls } = harness({
|
||||
getBusinessFields: async () => response({ items: [field('optional')] }),
|
||||
inspectTemplate: async () => response({ controls: [control('required-control', true)] })
|
||||
})
|
||||
state.editScene(scene())
|
||||
await settle()
|
||||
assert.equal(state.parseMapping(), undefined)
|
||||
assert.match(calls.warnings.at(-1), /必填控件/)
|
||||
})
|
||||
|
||||
test('selecting and clearing controls updates control IDs and types without changing the business field', async () => {
|
||||
const { state } = harness()
|
||||
state.editScene(scene())
|
||||
await settle()
|
||||
const row = state.mappingRows.value[0]
|
||||
row.control_id = 'text-1'
|
||||
state.handleControlChange(row)
|
||||
assert.equal(row.control_type, 'Text')
|
||||
assert.equal(row.control_title, '控件 text-1')
|
||||
row.control_id = ''
|
||||
state.handleControlChange(row)
|
||||
assert.equal(row.control_type, '')
|
||||
assert.equal(row.control_title, '')
|
||||
assert.equal(row.business_field, 'refund_no')
|
||||
})
|
||||
|
||||
test('out-of-order business field responses cannot overwrite a newer business type', async () => {
|
||||
const older = deferred()
|
||||
const newer = deferred()
|
||||
const { state } = harness({
|
||||
getBusinessFields: (type) => (type === 'refund_approval' ? older.promise : newer.promise)
|
||||
})
|
||||
state.createScene()
|
||||
state.sceneForm.business_type = 'offline_recharge_approval'
|
||||
state.handleBusinessTypeChange()
|
||||
newer.resolve(response({ items: [field('new-type')] }))
|
||||
await settle()
|
||||
older.resolve(response({ items: refundFields }))
|
||||
await settle()
|
||||
assert.equal(state.mappingRows.value[0].business_field, 'new-type')
|
||||
assert.equal(state.fieldsLoading.value, false)
|
||||
})
|
||||
|
||||
test('resetting the editor rejects pending responses even when the business type is unchanged', async () => {
|
||||
const pending = deferred()
|
||||
const { state, service } = harness({ getBusinessFields: () => pending.promise })
|
||||
state.createScene()
|
||||
service.getBusinessFields = async () => response({ items: [field('new-session')] })
|
||||
state.createScene()
|
||||
await settle()
|
||||
pending.resolve(response({ items: refundFields }))
|
||||
await settle()
|
||||
assert.equal(state.mappingRows.value[0].business_field, 'new-session')
|
||||
})
|
||||
|
||||
test('changing template settings rejects pending template responses and clears old control bindings', async () => {
|
||||
const pending = deferred()
|
||||
const { state } = harness({ inspectTemplate: () => pending.promise })
|
||||
state.editScene(scene())
|
||||
await settle()
|
||||
state.sceneForm.template_id = 'new-template'
|
||||
state.handleTemplateChange()
|
||||
pending.resolve(response({ name: '过期模板', controls: [control('old-control')] }))
|
||||
await settle()
|
||||
assert.equal(state.templateControls.value.length, 0)
|
||||
assert.equal(state.templateLoaded.value, false)
|
||||
assert.equal(state.mappingRows.value.length, 22)
|
||||
})
|
||||
|
||||
test('loading or failed field discovery cannot save an empty incomplete mapping', async (t) => {
|
||||
const pending = deferred()
|
||||
const { state, calls } = harness({ getBusinessFields: () => pending.promise })
|
||||
t.mock.method(console, 'error', () => {})
|
||||
state.sceneForm.template_id = 'template'
|
||||
const loading = state.loadBusinessFields('refund_approval')
|
||||
await state.saveScene()
|
||||
assert.equal(calls.saves.length, 0)
|
||||
pending.reject(new Error('network unavailable'))
|
||||
await loading
|
||||
await state.saveScene()
|
||||
assert.equal(calls.saves.length, 0)
|
||||
assert.equal(state.businessFieldsLoaded.value, false)
|
||||
assert.equal(calls.errors.length, 1)
|
||||
})
|
||||
|
||||
function findMappingSection(node) {
|
||||
if (
|
||||
node.type === 1 &&
|
||||
node.props.some(
|
||||
(prop) => prop.name === 'class' && prop.value?.content.includes('mapping-section')
|
||||
)
|
||||
)
|
||||
return node
|
||||
return node.children?.map(findMappingSection).find(Boolean)
|
||||
}
|
||||
|
||||
test('rendered mapping section shows all 22 field names and exactly eight required stars before template sync', async () => {
|
||||
const { state } = harness()
|
||||
state.createScene()
|
||||
await settle()
|
||||
const section = findMappingSection(descriptor.template.ast)
|
||||
const app = vue.createSSRApp({
|
||||
setup: () => ({ ...state }),
|
||||
render: vue.compile(section.loc.source)
|
||||
})
|
||||
for (const name of ['ElTag', 'ElSelect', 'ElOption', 'ElInput', 'ElEmpty']) {
|
||||
app.component(
|
||||
name,
|
||||
vue.defineComponent({
|
||||
setup:
|
||||
(_, { attrs, slots }) =>
|
||||
() =>
|
||||
vue.h('div', attrs, slots.default?.())
|
||||
})
|
||||
)
|
||||
}
|
||||
app.directive('loading', { getSSRProps: () => ({}) })
|
||||
const html = await renderToString(app)
|
||||
assert.equal((html.match(/class="mapping-row"/g) || []).length, 22)
|
||||
assert.equal((html.match(/aria-label="必填"/g) || []).length, 8)
|
||||
for (const field of refundFields) assert.ok(html.includes(field.name), field.name)
|
||||
assert.match(html, /请先同步模板/)
|
||||
assert.doesNotMatch(html, /暂无控件映射,请新增一条/)
|
||||
assert.doesNotMatch(html, /控件 ID|选择模板控件后自动填充/)
|
||||
assert.doesNotMatch(html, /mapping-field__description/)
|
||||
for (const field of refundFields) assert.ok(!html.includes(field.description), field.description)
|
||||
})
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
import { BaseService } from '../BaseService'
|
||||
import { getNewLoginPasswordError } from '@/utils/validation/loginPassword'
|
||||
import type {
|
||||
PlatformAccount,
|
||||
AccountQueryParams,
|
||||
@@ -48,7 +49,13 @@ export class AccountService extends BaseService {
|
||||
id: number,
|
||||
data: Partial<CreatePlatformAccountParams>
|
||||
): Promise<BaseResponse> {
|
||||
return this.update(`/api/admin/accounts/${id}`, data)
|
||||
const payload = { ...data }
|
||||
if (payload.password === '') delete payload.password
|
||||
if (payload.password !== undefined) {
|
||||
const error = getNewLoginPasswordError(payload.password)
|
||||
if (error) return Promise.reject(new Error(error))
|
||||
}
|
||||
return this.update(`/api/admin/accounts/${id}`, payload)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +113,9 @@ export class AccountService extends BaseService {
|
||||
* @param password 新密码
|
||||
*/
|
||||
static updateAccountPassword(id: number, password: string): Promise<BaseResponse> {
|
||||
return this.put<BaseResponse>(`/api/admin/accounts/${id}/password`, { password })
|
||||
const error = getNewLoginPasswordError(password)
|
||||
if (error) return Promise.reject(new Error(error))
|
||||
return this.put<BaseResponse>(`/api/admin/accounts/${id}/password`, { new_password: password })
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
import { BaseService } from '../BaseService'
|
||||
import { getNewLoginPasswordError } from '@/utils/validation/loginPassword'
|
||||
import type {
|
||||
AgentDistributionRegistrationPageResult,
|
||||
AgentDistributionRegistrationQueryParams,
|
||||
@@ -33,7 +34,7 @@ export interface AgentDistributionRegistrationParams {
|
||||
distribution_code: string // 分销码
|
||||
phone: string // 手机号
|
||||
code: string // 短信验证码
|
||||
password: string // 密码
|
||||
password: string // 8~12 位,大小写字母、数字、半角特殊符号至少三类,无空格和中文
|
||||
shop_name: string // 店铺名称
|
||||
shop_code: string // 店铺编号
|
||||
username: string // 用户名
|
||||
@@ -71,10 +72,12 @@ export class AgentDistributionService extends BaseService {
|
||||
static registerAgent(
|
||||
params: AgentDistributionRegistrationParams
|
||||
): Promise<BaseResponse<AgentDistributionRegistrationResponse>> {
|
||||
const error = getNewLoginPasswordError(params.password)
|
||||
if (error) return Promise.reject(new Error(error))
|
||||
return this.post<BaseResponse<AgentDistributionRegistrationResponse>>(
|
||||
'/api/c/v1/agent-distribution-registrations',
|
||||
params,
|
||||
{ requestOptions: { withToken: false } }
|
||||
{ requestOptions: { withToken: false, errorMessageMode: 'none' } }
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import { BaseService } from '../BaseService'
|
||||
import type {
|
||||
LoginParams,
|
||||
LoginData,
|
||||
UserInfo,
|
||||
UserInfoResponse,
|
||||
RefreshTokenParams,
|
||||
RefreshTokenData,
|
||||
@@ -51,7 +50,9 @@ export class AuthService extends BaseService {
|
||||
* @param params 修改密码参数
|
||||
*/
|
||||
static changePassword(params: ChangePasswordParams): Promise<BaseResponse> {
|
||||
return this.put<BaseResponse>('/api/auth/password', params)
|
||||
return this.put<BaseResponse>('/api/auth/password', params, {
|
||||
requestOptions: { errorMessageMode: 'none' }
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
24
src/api/modules/carrierTrafficThresholdHit.ts
Normal file
24
src/api/modules/carrierTrafficThresholdHit.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
/** 运营商通道阈值命中记录查询 API */
|
||||
|
||||
import { BaseService } from '../BaseService'
|
||||
import type { BaseResponse } from '@/types/api'
|
||||
import type {
|
||||
CarrierTrafficThresholdHitPageResult,
|
||||
CarrierTrafficThresholdHitQueryParams
|
||||
} from '@/types/api/carrierTrafficThresholdHit'
|
||||
|
||||
export class CarrierTrafficThresholdHitService extends BaseService {
|
||||
/**
|
||||
* 查询通道阈值命中记录
|
||||
* GET /api/admin/carrier-traffic-threshold-hits
|
||||
* 仅超级管理员和平台账号可访问,后端负责卡数据范围过滤。
|
||||
*/
|
||||
static getHits(
|
||||
params?: CarrierTrafficThresholdHitQueryParams
|
||||
): Promise<BaseResponse<CarrierTrafficThresholdHitPageResult>> {
|
||||
return this.get<BaseResponse<CarrierTrafficThresholdHitPageResult>>(
|
||||
'/api/admin/carrier-traffic-threshold-hits',
|
||||
params
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -138,8 +138,15 @@ export class ExchangeService extends BaseService {
|
||||
* POST /api/admin/exchanges/{id}/complete
|
||||
* @param id 换货单ID
|
||||
*/
|
||||
static completeExchange(id: number): Promise<BaseResponse<ExchangeResponse>> {
|
||||
return this.post<BaseResponse<ExchangeResponse>>(`/api/admin/exchanges/${id}/complete`, {})
|
||||
static completeExchange(
|
||||
id: number,
|
||||
config?: Record<string, any>
|
||||
): Promise<BaseResponse<ExchangeResponse>> {
|
||||
return this.post<BaseResponse<ExchangeResponse>>(
|
||||
`/api/admin/exchanges/${id}/complete`,
|
||||
{},
|
||||
config
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,7 @@ export { StorageService } from './storage'
|
||||
export { AuthorizationService } from './authorization'
|
||||
export { DeviceService } from './device'
|
||||
export { CarrierService } from './carrier'
|
||||
export { CarrierTrafficThresholdHitService } from './carrierTrafficThresholdHit'
|
||||
export { PackageSeriesService } from './packageSeries'
|
||||
export { PackageManageService } from './packageManage'
|
||||
export { ShopSeriesGrantService } from './shopSeriesGrant'
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import { BaseService } from '../BaseService'
|
||||
import type {
|
||||
Order,
|
||||
OrderDetail,
|
||||
OrderQueryParams,
|
||||
OrderListResponse,
|
||||
CreateOrderRequest,
|
||||
@@ -25,8 +25,8 @@ export class OrderService extends BaseService {
|
||||
* 获取订单详情
|
||||
* @param id 订单ID
|
||||
*/
|
||||
static getOrderById(id: number): Promise<BaseResponse<Order>> {
|
||||
return this.getOne<Order>(`/api/admin/orders/${id}`)
|
||||
static getOrderById(id: number): Promise<BaseResponse<OrderDetail>> {
|
||||
return this.getOne<OrderDetail>(`/api/admin/orders/${id}`)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,9 +39,7 @@ export class PhoneAssetAssociationService extends BaseService {
|
||||
/**
|
||||
* 解除单条手机号资产关联
|
||||
* DELETE /api/admin/phone-asset-associations/{id}
|
||||
*
|
||||
* 注意:接口文档未定义请求体,reason 与 confirmed 当前按查询参数传递;
|
||||
* 联调时若后端以 JSON body 接收,需调整为请求体方式。
|
||||
* 请求体:{ reason, confirmed }
|
||||
*/
|
||||
static unbindAssociation(
|
||||
id: number,
|
||||
@@ -50,7 +48,8 @@ export class PhoneAssetAssociationService extends BaseService {
|
||||
): Promise<BaseResponse<UnbindPhoneAssetAssociationResponse>> {
|
||||
return this.delete<BaseResponse<UnbindPhoneAssetAssociationResponse>>(
|
||||
`/api/admin/phone-asset-associations/${id}`,
|
||||
{ reason, confirmed }
|
||||
undefined,
|
||||
{ data: { reason, confirmed } }
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ export class ShopService extends BaseService {
|
||||
// ========== 业务负责人 CSV 导入 ==========
|
||||
|
||||
/**
|
||||
* 创建业务负责人导入任务
|
||||
* 创建批量换绑业务员任务
|
||||
* POST /api/admin/shops/business-owner-imports
|
||||
* @param data 上传后拿到的 file_key
|
||||
*/
|
||||
@@ -191,7 +191,7 @@ export class ShopService extends BaseService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询业务负责人导入任务详情
|
||||
* 查询批量换绑业务员任务详情
|
||||
* GET /api/admin/shops/business-owner-imports/{id}
|
||||
*/
|
||||
static getBusinessOwnerImportDetail(
|
||||
@@ -201,7 +201,7 @@ export class ShopService extends BaseService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询业务负责人导入任务列表
|
||||
* 查询批量换绑业务员任务列表
|
||||
* GET /api/admin/shops/business-owner-imports
|
||||
*/
|
||||
static getBusinessOwnerImportList(
|
||||
|
||||
@@ -138,7 +138,6 @@
|
||||
|
||||
html,
|
||||
body {
|
||||
touch-action: none; /* 禁用触摸事件 */
|
||||
overflow-x: hidden; /* 禁用横向滚动 */
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@
|
||||
}>({
|
||||
order_id: null,
|
||||
package_usage_id: undefined,
|
||||
method: RefundMethod.ORIGINAL_ROUTE,
|
||||
method: RefundMethod.CUSTOMER_ACCOUNT,
|
||||
requested_refund_amount: undefined,
|
||||
actual_received_amount: 0,
|
||||
refund_reason: '',
|
||||
@@ -242,9 +242,10 @@
|
||||
)
|
||||
const paymentMethodLabel = computed(() => {
|
||||
const labels = {
|
||||
wallet: '钱包支付',
|
||||
wallet: '预存款支付',
|
||||
wechat: '微信支付',
|
||||
alipay: '支付宝支付',
|
||||
fuiou: '富友支付',
|
||||
offline: '线下支付'
|
||||
}
|
||||
return selectedOrder.value ? labels[selectedOrder.value.payment_method] : '-'
|
||||
@@ -258,8 +259,7 @@
|
||||
if (order.payment_method === 'wallet') {
|
||||
return order.buyer_type === 'agent' ? RefundMethod.AGENT_WALLET : RefundMethod.ASSET_WALLET
|
||||
}
|
||||
if (order.payment_method === 'offline') return RefundMethod.CUSTOMER_ACCOUNT
|
||||
return RefundMethod.ORIGINAL_ROUTE
|
||||
return RefundMethod.CUSTOMER_ACCOUNT
|
||||
}
|
||||
|
||||
const searchOrders = async (query: string) => {
|
||||
@@ -320,7 +320,7 @@
|
||||
voucherUploading.value = false
|
||||
formData.order_id = null
|
||||
formData.package_usage_id = undefined
|
||||
formData.method = RefundMethod.ORIGINAL_ROUTE
|
||||
formData.method = RefundMethod.CUSTOMER_ACCOUNT
|
||||
formData.requested_refund_amount = undefined
|
||||
formData.actual_received_amount = 0
|
||||
formData.refund_reason = ''
|
||||
|
||||
@@ -160,6 +160,11 @@
|
||||
.filter(Boolean)
|
||||
: []
|
||||
|
||||
const currentKeys = Array.from(voucherFileKeyMap.values())
|
||||
const isEchoOfCurrentValue =
|
||||
keys.length === currentKeys.length && keys.every((key, index) => key === currentKeys[index])
|
||||
if (isEchoOfCurrentValue) return
|
||||
|
||||
voucherFileKeyMap.clear()
|
||||
keys.slice(0, getMaxCount()).forEach((key, index) => {
|
||||
voucherFileKeyMap.set(index + 1, key)
|
||||
|
||||
@@ -190,8 +190,13 @@
|
||||
{
|
||||
text: '今天',
|
||||
value: () => {
|
||||
const today = new Date()
|
||||
return [today, today] as [Date, Date]
|
||||
const start = new Date()
|
||||
const end = new Date()
|
||||
if (type === 'datetimerange') {
|
||||
start.setHours(0, 0, 0, 0)
|
||||
end.setHours(23, 59, 59, 0)
|
||||
}
|
||||
return [start, end] as [Date, Date]
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
<template>
|
||||
<ElDialog
|
||||
v-model="dialogVisible"
|
||||
append-to-body
|
||||
:title="t('passwordChange.title')"
|
||||
width="min(420px, calc(100vw - 32px))"
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="!submitting"
|
||||
:show-close="!submitting"
|
||||
@closed="resetForm"
|
||||
>
|
||||
<ElForm
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-position="top"
|
||||
@submit.prevent="handleSubmit"
|
||||
>
|
||||
<ElFormItem prop="old_password" :label="t('passwordChange.oldPassword')">
|
||||
<ElInput
|
||||
v-model="formData.old_password"
|
||||
type="password"
|
||||
autocomplete="current-password"
|
||||
show-password
|
||||
:disabled="submitting"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElAlert
|
||||
:title="t('passwordChange.passwordRule')"
|
||||
type="info"
|
||||
:closable="false"
|
||||
style="margin-bottom: 16px"
|
||||
/>
|
||||
<ElFormItem prop="new_password" :label="t('passwordChange.newPassword')">
|
||||
<ElInput
|
||||
v-model="formData.new_password"
|
||||
type="password"
|
||||
autocomplete="new-password"
|
||||
maxlength="12"
|
||||
:placeholder="t('passwordChange.passwordRule')"
|
||||
show-password
|
||||
:disabled="submitting"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem prop="confirm_password" :label="t('passwordChange.confirmPassword')">
|
||||
<ElInput
|
||||
v-model="formData.confirm_password"
|
||||
type="password"
|
||||
autocomplete="new-password"
|
||||
maxlength="12"
|
||||
:placeholder="t('passwordChange.passwordRule')"
|
||||
show-password
|
||||
:disabled="submitting"
|
||||
@keyup.enter="handleSubmit"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
|
||||
<template #footer>
|
||||
<ElButton :disabled="submitting" @click="dialogVisible = false">
|
||||
{{ t('common.cancel') }}
|
||||
</ElButton>
|
||||
<ElButton type="primary" :loading="submitting" @click="handleSubmit">
|
||||
{{ t('passwordChange.submit') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { ElAlert, ElMessage } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { AuthService } from '@/api/modules'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { normalizeApiError } from '@/utils/business/apiError'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { createNewLoginPasswordRule } from '@/utils/validation/loginPassword'
|
||||
|
||||
defineOptions({ name: 'ChangePasswordDialog' })
|
||||
|
||||
const props = defineProps<{ modelValue: boolean }>()
|
||||
const emit = defineEmits<{ 'update:modelValue': [value: boolean] }>()
|
||||
|
||||
const { t } = useI18n()
|
||||
const userStore = useUserStore()
|
||||
const dialogVisible = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (value: boolean) => emit('update:modelValue', value)
|
||||
})
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const submitting = ref(false)
|
||||
const formData = reactive({
|
||||
old_password: '',
|
||||
new_password: '',
|
||||
confirm_password: ''
|
||||
})
|
||||
|
||||
const formRules = computed<FormRules>(() => ({
|
||||
old_password: [
|
||||
{ required: true, message: t('passwordChange.oldPasswordRequired'), trigger: 'blur' }
|
||||
],
|
||||
new_password: [
|
||||
{ required: true, message: t('passwordChange.newPasswordRequired'), trigger: 'blur' },
|
||||
createNewLoginPasswordRule(t('passwordChange.passwordRule'))
|
||||
],
|
||||
confirm_password: [
|
||||
{ required: true, message: t('passwordChange.confirmPasswordRequired'), trigger: 'blur' },
|
||||
createNewLoginPasswordRule(t('passwordChange.passwordRule')),
|
||||
{
|
||||
validator: (_rule, value: string, callback) => {
|
||||
if (value && value !== formData.new_password) {
|
||||
callback(new Error(t('passwordChange.passwordMismatch')))
|
||||
return
|
||||
}
|
||||
callback()
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
}))
|
||||
|
||||
const resetForm = () => {
|
||||
formData.old_password = ''
|
||||
formData.new_password = ''
|
||||
formData.confirm_password = ''
|
||||
formRef.value?.clearValidate()
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!formRef.value || submitting.value) return
|
||||
|
||||
try {
|
||||
await formRef.value.validate()
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
if (submitting.value) return
|
||||
|
||||
submitting.value = true
|
||||
try {
|
||||
const response = await AuthService.changePassword({
|
||||
old_password: formData.old_password,
|
||||
new_password: formData.new_password
|
||||
})
|
||||
|
||||
if (response.code !== 0) {
|
||||
ElMessage.error(response.msg || response.message || t('passwordChange.failure'))
|
||||
return
|
||||
}
|
||||
|
||||
ElMessage.success(t('passwordChange.success'))
|
||||
resetForm()
|
||||
dialogVisible.value = false
|
||||
userStore.clearLocalState()
|
||||
} catch (error) {
|
||||
const normalized = normalizeApiError(error)
|
||||
ElMessage.error(normalized.message || t('passwordChange.failure'))
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
:deep(.el-form-item__error) {
|
||||
position: static;
|
||||
width: 100%;
|
||||
line-height: 1.5;
|
||||
}
|
||||
</style>
|
||||
@@ -158,6 +158,12 @@
|
||||
<i class="menu-icon iconfont-sys"></i>
|
||||
<span class="menu-txt">{{ $t('topBar.user.userCenter') }}</span>
|
||||
</li>
|
||||
<li>
|
||||
<button class="user-menu-action" type="button" @click="openChangePassword">
|
||||
<el-icon class="menu-icon"><Key /></el-icon>
|
||||
<span class="menu-txt">{{ $t('topBar.user.changePassword') }}</span>
|
||||
</button>
|
||||
</li>
|
||||
<li @click="lockScreen()">
|
||||
<i class="menu-icon iconfont-sys"></i>
|
||||
<span class="menu-txt">{{ $t('topBar.user.lockScreen') }}</span>
|
||||
@@ -175,12 +181,15 @@
|
||||
</div>
|
||||
<ArtWorkTab />
|
||||
|
||||
<ChangePasswordDialog v-model="changePasswordDialogVisible" />
|
||||
<art-notification v-model="showNotice" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onBeforeUnmount, onMounted } from 'vue'
|
||||
import { Key } from '@element-plus/icons-vue'
|
||||
import ChangePasswordDialog from './ChangePasswordDialog.vue'
|
||||
import { MenuTypeEnum, MenuWidth } from '@/enums/appEnum'
|
||||
import { useSettingStore } from '@/store/modules/setting'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
@@ -217,6 +226,7 @@
|
||||
const { menuList } = storeToRefs(useMenuStore())
|
||||
|
||||
const showNotice = ref(false)
|
||||
const changePasswordDialogVisible = ref(false)
|
||||
const userMenuPopover = ref()
|
||||
|
||||
const isLeftMenu = computed(() => menuType.value === MenuTypeEnum.LEFT)
|
||||
@@ -348,6 +358,13 @@
|
||||
mittBus.emit('openLockScreen')
|
||||
}
|
||||
|
||||
const openChangePassword = () => {
|
||||
closeUserMenu()
|
||||
window.setTimeout(() => {
|
||||
changePasswordDialogVisible.value = true
|
||||
}, 100)
|
||||
}
|
||||
|
||||
const closeUserMenu = () => {
|
||||
setTimeout(() => {
|
||||
userMenuPopover.value.hide()
|
||||
|
||||
@@ -88,6 +88,23 @@
|
||||
}
|
||||
}
|
||||
|
||||
.user-menu-action {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--el-color-primary);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.line {
|
||||
width: 100%;
|
||||
height: 1px;
|
||||
|
||||
@@ -234,6 +234,9 @@
|
||||
|
||||
// 提供给父组件的方法
|
||||
defineExpose({
|
||||
clearSelection: () => tableRef.value?.clearSelection(),
|
||||
toggleRowSelection: (row: any, selected?: boolean) =>
|
||||
tableRef.value?.toggleRowSelection(row, selected),
|
||||
// 展开所有行
|
||||
expandAll: () => {
|
||||
const elTable = tableRef.value
|
||||
|
||||
@@ -53,12 +53,18 @@
|
||||
</div>
|
||||
|
||||
<!-- 列设置 -->
|
||||
<ElPopover placement="bottom" trigger="click">
|
||||
<ElPopover
|
||||
v-model:visible="columnSettingsOpen"
|
||||
placement="bottom"
|
||||
trigger="click"
|
||||
@after-enter="startColumnDrag"
|
||||
@before-leave="stopColumnDrag"
|
||||
>
|
||||
<template #reference>
|
||||
<div class="btn"><i class="iconfont-sys" style="font-size: 17px"></i> </div>
|
||||
</template>
|
||||
<div>
|
||||
<VueDraggable v-model="columns">
|
||||
<div ref="columnSettingsRef">
|
||||
<div v-for="item in columns" :key="item.prop || item.type" class="column-option">
|
||||
<div class="drag-icon">
|
||||
<i class="iconfont-sys"></i>
|
||||
@@ -67,7 +73,7 @@
|
||||
item.label || (item.type === 'selection' ? t('table.selection') : '')
|
||||
}}</ElCheckbox>
|
||||
</div>
|
||||
</VueDraggable>
|
||||
</div>
|
||||
</div>
|
||||
</ElPopover>
|
||||
<!-- 其他设置 -->
|
||||
@@ -98,8 +104,10 @@
|
||||
import { TableSizeEnum } from '@/enums/formEnum'
|
||||
import { useTableStore } from '@/store/modules/table'
|
||||
import { ElPopover, ElCheckbox } from 'element-plus'
|
||||
import { VueDraggable } from 'vue-draggable-plus'
|
||||
import { useDraggable } from 'vue-draggable-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { onBeforeUnmount, onDeactivated, onMounted, onUnmounted, ref } from 'vue'
|
||||
import { storeToRefs } from 'pinia'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
@@ -128,6 +136,27 @@
|
||||
|
||||
const columns = defineModel<ColumnOption[]>('columns', { required: true })
|
||||
|
||||
const columnSettingsRef = ref<HTMLElement | null>(null)
|
||||
const columnSettingsOpen = ref(false)
|
||||
// Popover 内容和路由生命周期不同,禁止拖拽库在挂载时用空 ref 自动初始化。
|
||||
const columnDraggable = useDraggable(columnSettingsRef, columns, { immediate: false })
|
||||
|
||||
const startColumnDrag = () => {
|
||||
const element = columnSettingsRef.value
|
||||
if (!columnSettingsOpen.value || !(element instanceof HTMLElement) || !element.isConnected) {
|
||||
return
|
||||
}
|
||||
columnDraggable.start(element)
|
||||
}
|
||||
|
||||
const stopColumnDrag = () => {
|
||||
columnSettingsOpen.value = false
|
||||
columnDraggable.destroy()
|
||||
}
|
||||
|
||||
onBeforeUnmount(stopColumnDrag)
|
||||
onDeactivated(stopColumnDrag)
|
||||
|
||||
// 定义视图模式 model
|
||||
const currentView = defineModel<'table' | 'descriptions'>('currentView', { default: 'table' })
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* 运营商类型配置
|
||||
*/
|
||||
|
||||
import { CarrierType } from '@/types/api'
|
||||
import { CarrierType, type CarrierRealnameControlEnabled } from '@/types/api'
|
||||
|
||||
// 运营商类型选项
|
||||
export const CARRIER_TYPE_OPTIONS = [
|
||||
@@ -30,3 +30,11 @@ export function getCarrierTypeLabel(type: CarrierType): string {
|
||||
export function getCarrierTypeColor(type: CarrierType): string {
|
||||
return CARRIER_TYPE_MAP[type]?.color || '#666'
|
||||
}
|
||||
|
||||
export function getCarrierRealnameControlLabel(
|
||||
enabled?: CarrierRealnameControlEnabled | null
|
||||
): string {
|
||||
if (enabled === 1) return '管控'
|
||||
if (enabled === 0) return '不管控'
|
||||
return '-'
|
||||
}
|
||||
|
||||
@@ -19,7 +19,12 @@ export const WITHDRAWAL_STATUS_OPTIONS = [
|
||||
{ label: '待审核', value: WithdrawalStatus.PENDING, type: 'warning' as const },
|
||||
{ label: '已通过', value: WithdrawalStatus.APPROVED, type: 'success' as const },
|
||||
{ label: '已拒绝', value: WithdrawalStatus.REJECTED, type: 'danger' as const },
|
||||
{ label: '已到账', value: WithdrawalStatus.COMPLETED, type: 'success' as const }
|
||||
{ label: '已到账', value: WithdrawalStatus.COMPLETED, type: 'success' as const },
|
||||
{
|
||||
label: '审批提交失败',
|
||||
value: WithdrawalStatus.APPROVAL_SUBMISSION_FAILED,
|
||||
type: 'danger' as const
|
||||
}
|
||||
]
|
||||
|
||||
// 支付方式选项
|
||||
@@ -36,9 +41,22 @@ export const WithdrawalStatusMap = {
|
||||
1: { label: '待审核', type: 'warning' as const, color: '#E6A23C' },
|
||||
2: { label: '已通过', type: 'success' as const, color: '#67C23A' },
|
||||
3: { label: '已拒绝', type: 'danger' as const, color: '#F56C6C' },
|
||||
4: { label: '已到账', type: 'success' as const, color: '#67C23A' }
|
||||
4: { label: '已到账', type: 'success' as const, color: '#67C23A' },
|
||||
5: { label: '审批提交失败', type: 'danger' as const, color: '#F56C6C' }
|
||||
}
|
||||
|
||||
export const WITHDRAWAL_QUALIFICATION_APPROVAL_FAILED = 4
|
||||
export const WITHDRAWAL_QUALIFICATION_STATUS_OPTIONS = [
|
||||
{ label: '待审批', value: 0 },
|
||||
{ label: '已通过', value: 1 },
|
||||
{ label: '已驳回', value: 2 },
|
||||
{ label: '已作废', value: 3 },
|
||||
{ label: '审批提交失败', value: WITHDRAWAL_QUALIFICATION_APPROVAL_FAILED }
|
||||
]
|
||||
|
||||
export const canResubmitWithdrawal = (status: number): boolean =>
|
||||
status === WithdrawalStatus.REJECTED || status === WithdrawalStatus.APPROVAL_SUBMISSION_FAILED
|
||||
|
||||
// ========== 佣金状态映射 ==========
|
||||
|
||||
// 佣金状态映射 (1:已冻结, 2:解冻中, 3:已发放, 4:已失效, 99:待人工修正)
|
||||
@@ -134,10 +152,7 @@ export const COMMISSION_RECORD_STATUS_OPTIONS = [
|
||||
]
|
||||
|
||||
// 是否回溯明细行(source 与 status 双判断,兼容未返回 source 的响应)
|
||||
export function isCommissionClawbackRecord(record: {
|
||||
source?: string
|
||||
status?: number
|
||||
}): boolean {
|
||||
export function isCommissionClawbackRecord(record: { source?: string; status?: number }): boolean {
|
||||
return record.source === 'clawback' || record.status === CommissionStatus.CLAWBACK
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@ export const RefundStatusNameMap: Record<RefundStatus, string> = {
|
||||
[RefundStatus.REJECTED]: '已拒绝',
|
||||
[RefundStatus.RETURNED]: '已退回',
|
||||
[RefundStatus.REFUNDING]: '原路退款处理中',
|
||||
[RefundStatus.REFUND_FAILED]: '原路退款失败'
|
||||
[RefundStatus.REFUND_FAILED]: '原路退款失败',
|
||||
[RefundStatus.APPROVAL_SUBMISSION_FAILED]: '审批提交失败'
|
||||
}
|
||||
|
||||
/** 退款状态标签类型映射 */
|
||||
@@ -27,7 +28,8 @@ export const RefundStatusTypeMap: Record<RefundStatus, 'warning' | 'success' | '
|
||||
[RefundStatus.REJECTED]: 'danger',
|
||||
[RefundStatus.RETURNED]: 'info',
|
||||
[RefundStatus.REFUNDING]: 'warning',
|
||||
[RefundStatus.REFUND_FAILED]: 'danger'
|
||||
[RefundStatus.REFUND_FAILED]: 'danger',
|
||||
[RefundStatus.APPROVAL_SUBMISSION_FAILED]: 'danger'
|
||||
}
|
||||
|
||||
/** 退款方式名称映射 */
|
||||
@@ -57,9 +59,8 @@ export const RefundFailureReasonNameMap: Record<RefundFailureReason, string> = {
|
||||
[RefundFailureReason.PAYMENT_FACT_INVALID]: '本地原支付事实不可用'
|
||||
}
|
||||
|
||||
/** 退款方式选项(表单用) */
|
||||
/** 退款方式选项(表单用,原路退回暂不开放;历史记录仍保留名称映射) */
|
||||
export const RefundMethodOptions = [
|
||||
{ label: '原路退回', value: RefundMethod.ORIGINAL_ROUTE },
|
||||
{ label: '线下退款', value: RefundMethod.CUSTOMER_ACCOUNT },
|
||||
{ label: '资产钱包', value: RefundMethod.ASSET_WALLET },
|
||||
{ label: '代理钱包', value: RefundMethod.AGENT_WALLET }
|
||||
@@ -73,7 +74,12 @@ export const canResubmitRefund = (item: {
|
||||
anomaly_flag?: number
|
||||
}): boolean => {
|
||||
if (!item.status) return false
|
||||
if (item.status === RefundStatus.REJECTED || item.status === RefundStatus.RETURNED) return true
|
||||
if (
|
||||
item.status === RefundStatus.REJECTED ||
|
||||
item.status === RefundStatus.RETURNED ||
|
||||
item.status === RefundStatus.APPROVAL_SUBMISSION_FAILED
|
||||
)
|
||||
return true
|
||||
if (item.status === RefundStatus.REFUND_FAILED) return item.anomaly_flag !== 1
|
||||
return false
|
||||
}
|
||||
@@ -85,3 +91,9 @@ export const canManualApproveRefund = (item: {
|
||||
status?: RefundStatus
|
||||
approval_instance_id?: number | null
|
||||
}): boolean => item.status === RefundStatus.PENDING && !item.approval_instance_id
|
||||
|
||||
export const canRecoverRefundApproval = (item: {
|
||||
status?: RefundStatus
|
||||
approval_recoverable?: boolean
|
||||
}): boolean =>
|
||||
item.status !== RefundStatus.APPROVAL_SUBMISSION_FAILED && item.approval_recoverable === true
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
"userCenter": "User center",
|
||||
"docs": "Document",
|
||||
"github": "Github",
|
||||
"changePassword": "Change password",
|
||||
"lockScreen": "Lock screen",
|
||||
"logout": "Log out"
|
||||
}
|
||||
@@ -17,6 +18,21 @@
|
||||
"confirm": "Confirm",
|
||||
"logOutTips": "Do you want to log out?"
|
||||
},
|
||||
"passwordChange": {
|
||||
"title": "Change password",
|
||||
"oldPassword": "Current password",
|
||||
"newPassword": "New password",
|
||||
"confirmPassword": "Confirm new password",
|
||||
"oldPasswordRequired": "Please enter your current password",
|
||||
"newPasswordRequired": "Please enter a new password",
|
||||
"confirmPasswordRequired": "Please enter the new password again",
|
||||
"passwordLength": "Password must be 8-12 characters",
|
||||
"passwordRule": "8-12 characters; at least three of uppercase letters, lowercase letters, digits and special characters. No spaces or Chinese characters.",
|
||||
"passwordMismatch": "The new passwords do not match",
|
||||
"submit": "Change password",
|
||||
"success": "Password changed successfully",
|
||||
"failure": "Failed to change password"
|
||||
},
|
||||
"search": {
|
||||
"placeholder": "Search page",
|
||||
"historyTitle": "Search history",
|
||||
@@ -342,6 +358,8 @@
|
||||
"role": "Role Manage",
|
||||
"permission": "Permission Manage",
|
||||
"carrierManagement": "Carrier Management",
|
||||
"carrierDetail": "Carrier Details",
|
||||
"carrierTrafficThresholdHits": "Carrier Threshold Hit Records",
|
||||
"userCenter": "User Center",
|
||||
"menu": "Menu Manage",
|
||||
"nested": "Nested Menu",
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
"userCenter": "个人中心",
|
||||
"docs": "使用文档",
|
||||
"github": "Github",
|
||||
"changePassword": "修改密码",
|
||||
"lockScreen": "锁定屏幕",
|
||||
"logout": "退出登录"
|
||||
}
|
||||
@@ -18,6 +19,21 @@
|
||||
"logOutTips": "您是否要退出登录?",
|
||||
"back": "返回"
|
||||
},
|
||||
"passwordChange": {
|
||||
"title": "修改密码",
|
||||
"oldPassword": "当前密码",
|
||||
"newPassword": "新密码",
|
||||
"confirmPassword": "确认新密码",
|
||||
"oldPasswordRequired": "请输入当前密码",
|
||||
"newPasswordRequired": "请输入新密码",
|
||||
"confirmPasswordRequired": "请再次输入新密码",
|
||||
"passwordLength": "密码长度需为8-12位",
|
||||
"passwordRule": "8~12位,大写字母、小写字母、数字、特殊符号至少包含三类,不允许空格和中文",
|
||||
"passwordMismatch": "两次输入的新密码不一致",
|
||||
"submit": "确认修改",
|
||||
"success": "密码修改成功",
|
||||
"failure": "密码修改失败"
|
||||
},
|
||||
"search": {
|
||||
"placeholder": "搜索页面",
|
||||
"historyTitle": "搜索历史",
|
||||
@@ -341,6 +357,8 @@
|
||||
"role": "角色管理",
|
||||
"permission": "权限管理",
|
||||
"carrierManagement": "运营商管理",
|
||||
"carrierDetail": "运营商详情",
|
||||
"carrierTrafficThresholdHits": "通道阈值命中记录",
|
||||
"userCenter": "个人中心"
|
||||
},
|
||||
"packageManagement": {
|
||||
@@ -367,7 +385,7 @@
|
||||
"title": "店铺管理",
|
||||
"shopList": "店铺列表",
|
||||
"businessUserGroups": "业务用户组",
|
||||
"businessOwnerImport": "业务负责人导入",
|
||||
"businessOwnerImport": "批量换绑业务员",
|
||||
"agentDistributionRegistrations": "代理注册申请",
|
||||
"agentDistributionRegistrationDetail": "代理注册申请详情"
|
||||
},
|
||||
|
||||
@@ -238,7 +238,7 @@ async function processFrontendMenu(router: Router): Promise<void> {
|
||||
throw new Error('获取用户角色失败')
|
||||
}
|
||||
|
||||
const filteredMenuList = filterMenuByRoles(menuList, roles)
|
||||
const filteredMenuList = filterMenuByRoles(menuList, roles, Number(userStore.info.user_type))
|
||||
await new Promise((resolve) => setTimeout(resolve, 300))
|
||||
await registerAndStoreMenu(router, filteredMenuList, closeLoading)
|
||||
} catch (error) {
|
||||
@@ -264,7 +264,11 @@ async function processBackendMenu(router: Router): Promise<void> {
|
||||
}
|
||||
|
||||
// 普通用户:使用后端返回的菜单
|
||||
const backendMenus = userStore.menus || []
|
||||
let backendMenus = userStore.menus || []
|
||||
if (Number(userStore.info.user_type) === 2) {
|
||||
backendMenus = ensureCarrierManagementMenuEntries(backendMenus)
|
||||
userStore.setMenus(backendMenus)
|
||||
}
|
||||
const routeMap = buildRouteMap(asyncRoutes)
|
||||
|
||||
const menuList = backendMenus
|
||||
@@ -279,6 +283,46 @@ async function processBackendMenu(router: Router): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Backend menu mode may return the existing System menu without the newly added
|
||||
* carrier detail and threshold-hit entries. Add those as sibling routes under System
|
||||
* for platform accounts, without introducing a nested RouterView layout.
|
||||
*/
|
||||
function ensureCarrierManagementMenuEntries(menus: any[]): any[] {
|
||||
const requiredEntries = [
|
||||
{
|
||||
url: `${RoutesAlias.CarrierDetail}/:id`,
|
||||
name: 'menus.system.carrierDetail'
|
||||
},
|
||||
{
|
||||
url: RoutesAlias.CarrierTrafficThresholdHits,
|
||||
name: 'menus.system.carrierTrafficThresholdHits'
|
||||
}
|
||||
]
|
||||
let systemMenuFound = false
|
||||
|
||||
const visit = (items: any[]): any[] =>
|
||||
items.map((item) => {
|
||||
const children = Array.isArray(item.children) ? visit(item.children) : []
|
||||
const itemUrl = item.url || item.path
|
||||
|
||||
if (itemUrl === '/system') {
|
||||
systemMenuFound = true
|
||||
const existingUrls = new Set(children.map((child) => child.url || child.path))
|
||||
const missingEntries = requiredEntries.filter((entry) => !existingUrls.has(entry.url))
|
||||
return { ...item, children: [...children, ...missingEntries] }
|
||||
}
|
||||
|
||||
return Array.isArray(item.children) ? { ...item, children } : item
|
||||
})
|
||||
|
||||
const enrichedMenus = visit(menus)
|
||||
if (systemMenuFound) return enrichedMenus
|
||||
|
||||
const systemMenu = { url: '/system', name: 'menus.system.title', children: requiredEntries }
|
||||
return [...enrichedMenus, systemMenu]
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并默认菜单
|
||||
* 将配置的默认菜单合并到后端返回的菜单中
|
||||
@@ -448,15 +492,21 @@ function handleMenuError(error: unknown): void {
|
||||
/**
|
||||
* 根据角色过滤菜单
|
||||
*/
|
||||
const filterMenuByRoles = (menu: AppRouteRecord[], roles: string[]): AppRouteRecord[] => {
|
||||
const filterMenuByRoles = (
|
||||
menu: AppRouteRecord[],
|
||||
roles: string[],
|
||||
userType: number
|
||||
): AppRouteRecord[] => {
|
||||
return menu.reduce((acc: AppRouteRecord[], item) => {
|
||||
const itemRoles = item.meta?.roles
|
||||
const hasPermission = !itemRoles || itemRoles.some((role) => roles?.includes(role))
|
||||
const allowedUserTypes = item.meta?.allowedUserTypes as number[] | undefined
|
||||
const hasRole = !itemRoles || itemRoles.some((role) => roles?.includes(role))
|
||||
const hasAllowedUserType = !allowedUserTypes || allowedUserTypes.includes(userType)
|
||||
|
||||
if (hasPermission) {
|
||||
if (hasRole && hasAllowedUserType) {
|
||||
const filteredItem = { ...item }
|
||||
if (filteredItem.children?.length) {
|
||||
filteredItem.children = filterMenuByRoles(filteredItem.children, roles)
|
||||
filteredItem.children = filterMenuByRoles(filteredItem.children, roles, userType)
|
||||
}
|
||||
acc.push(filteredItem)
|
||||
}
|
||||
|
||||
@@ -205,4 +205,3 @@ export const buildLoginRedirect = (currentPath: string): string => {
|
||||
}
|
||||
return `/auth/login?redirect=${encodeURIComponent(currentPath)}`
|
||||
}
|
||||
|
||||
|
||||
@@ -118,6 +118,26 @@ export const asyncRoutes: AppRouteRecord[] = [
|
||||
keepAlive: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'carrier-management/detail/:id',
|
||||
name: 'CarrierDetail',
|
||||
component: RoutesAlias.CarrierDetail,
|
||||
meta: {
|
||||
title: 'menus.system.carrierDetail',
|
||||
isHide: true,
|
||||
keepAlive: false
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'carrier-traffic-threshold-hits',
|
||||
name: 'CarrierTrafficThresholdHits',
|
||||
component: RoutesAlias.CarrierTrafficThresholdHitsPage,
|
||||
meta: {
|
||||
title: 'menus.system.carrierTrafficThresholdHits',
|
||||
keepAlive: true,
|
||||
allowedUserTypes: [1, 2]
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'user-center',
|
||||
name: 'UserCenter',
|
||||
@@ -298,7 +318,7 @@ export const asyncRoutes: AppRouteRecord[] = [
|
||||
permissions: [BUSINESS_USER_GROUP_PERMISSIONS.page]
|
||||
}
|
||||
},
|
||||
// 业务负责人导入
|
||||
// 批量换绑业务员
|
||||
{
|
||||
path: 'business-owner-import',
|
||||
name: 'BusinessOwnerImport',
|
||||
@@ -626,164 +646,166 @@ export const asyncRoutes: AppRouteRecord[] = [
|
||||
permissions: [BULK_PURCHASE_PERMISSIONS.detail],
|
||||
keepAlive: false
|
||||
}
|
||||
},
|
||||
// 导出管理
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
// 导出管理
|
||||
{
|
||||
path: '/asset-management/export-task-management',
|
||||
name: 'ExportTaskManagement',
|
||||
component: RoutesAlias.Home,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportTaskManagement',
|
||||
icon: '',
|
||||
keepAlive: true
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'export-task-management',
|
||||
name: 'ExportTaskManagement',
|
||||
component: '',
|
||||
path: 'export-device',
|
||||
name: 'ExportDeviceTaskList',
|
||||
component: RoutesAlias.ExportDeviceTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportTaskManagement',
|
||||
title: 'menus.assetManagement.exportDevice',
|
||||
exportTaskScene: 'device',
|
||||
keepAlive: true
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'export-device',
|
||||
name: 'ExportDeviceTaskList',
|
||||
component: RoutesAlias.ExportDeviceTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportDevice',
|
||||
exportTaskScene: 'device',
|
||||
keepAlive: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-iot-card',
|
||||
name: 'ExportIotCardTaskList',
|
||||
component: RoutesAlias.ExportIotCardTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportIotCard',
|
||||
exportTaskScene: 'iot_card',
|
||||
keepAlive: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-order',
|
||||
name: 'ExportOrderTaskList',
|
||||
component: RoutesAlias.ExportOrderTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportOrder',
|
||||
exportTaskScene: 'order',
|
||||
keepAlive: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-package',
|
||||
name: 'ExportPackageTaskList',
|
||||
component: RoutesAlias.ExportPackageTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportPackage',
|
||||
exportTaskScene: 'package',
|
||||
keepAlive: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-agent-wallet-transaction',
|
||||
name: 'ExportAgentWalletTransactionTaskList',
|
||||
component: RoutesAlias.ExportAgentWalletTransactionTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportAgentWalletTransaction',
|
||||
exportTaskScene: 'agent_wallet_transaction',
|
||||
keepAlive: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-refund',
|
||||
name: 'ExportRefundTaskList',
|
||||
component: RoutesAlias.ExportRefundTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportRefund',
|
||||
exportTaskScene: 'refund',
|
||||
keepAlive: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-agent-recharge',
|
||||
name: 'ExportAgentRechargeTaskList',
|
||||
component: RoutesAlias.ExportAgentRechargeTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportAgentRecharge',
|
||||
exportTaskScene: 'agent_recharge',
|
||||
keepAlive: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-exchange',
|
||||
name: 'ExportExchangeTaskList',
|
||||
component: RoutesAlias.ExportExchangeTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportExchange',
|
||||
exportTaskScene: 'exchange',
|
||||
keepAlive: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-commission-record',
|
||||
name: 'ExportCommissionRecordTaskList',
|
||||
component: RoutesAlias.ExportCommissionRecordTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportCommissionRecord',
|
||||
exportTaskScene: 'commission_record',
|
||||
keepAlive: true,
|
||||
permissions: [EXPORT_TASK_SCENE_CONFIG.commission_record.permissions.page]
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-package-traffic-alert',
|
||||
name: 'ExportPackageTrafficAlertTaskList',
|
||||
component: RoutesAlias.ExportPackageTrafficAlertTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportPackageTrafficAlert',
|
||||
exportTaskScene: 'package_traffic_alert',
|
||||
keepAlive: true,
|
||||
permissions: [EXPORT_TASK_SCENE_CONFIG.package_traffic_alert.permissions.page]
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-expiring-asset',
|
||||
name: 'ExportExpiringAssetTaskList',
|
||||
component: RoutesAlias.ExportExpiringAssetTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportExpiringAsset',
|
||||
exportTaskScene: 'expiring_asset',
|
||||
keepAlive: true,
|
||||
permissions: [EXPORT_TASK_SCENE_CONFIG.expiring_asset.permissions.page]
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-operations-activation',
|
||||
name: 'ExportOperationsActivationTaskList',
|
||||
component: RoutesAlias.ExportOperationsActivationTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportOperationsActivation',
|
||||
exportTaskScene: 'operations_activation',
|
||||
keepAlive: true,
|
||||
permissions: [EXPORT_TASK_SCENE_CONFIG.operations_activation.permissions.page]
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-operations-renewal',
|
||||
name: 'ExportOperationsRenewalTaskList',
|
||||
component: RoutesAlias.ExportOperationsRenewalTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportOperationsRenewal',
|
||||
exportTaskScene: 'operations_renewal',
|
||||
keepAlive: true,
|
||||
permissions: [EXPORT_TASK_SCENE_CONFIG.operations_renewal.permissions.page]
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-task-detail',
|
||||
name: 'ExportTaskDetail',
|
||||
component: RoutesAlias.ExportTaskDetail,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportTaskDetail',
|
||||
isHide: true,
|
||||
keepAlive: false,
|
||||
permissions: [EXPORT_TASK_DETAIL_PAGE_PERMISSION]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-iot-card',
|
||||
name: 'ExportIotCardTaskList',
|
||||
component: RoutesAlias.ExportIotCardTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportIotCard',
|
||||
exportTaskScene: 'iot_card',
|
||||
keepAlive: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-order',
|
||||
name: 'ExportOrderTaskList',
|
||||
component: RoutesAlias.ExportOrderTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportOrder',
|
||||
exportTaskScene: 'order',
|
||||
keepAlive: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-package',
|
||||
name: 'ExportPackageTaskList',
|
||||
component: RoutesAlias.ExportPackageTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportPackage',
|
||||
exportTaskScene: 'package',
|
||||
keepAlive: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-agent-wallet-transaction',
|
||||
name: 'ExportAgentWalletTransactionTaskList',
|
||||
component: RoutesAlias.ExportAgentWalletTransactionTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportAgentWalletTransaction',
|
||||
exportTaskScene: 'agent_wallet_transaction',
|
||||
keepAlive: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-refund',
|
||||
name: 'ExportRefundTaskList',
|
||||
component: RoutesAlias.ExportRefundTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportRefund',
|
||||
exportTaskScene: 'refund',
|
||||
keepAlive: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-agent-recharge',
|
||||
name: 'ExportAgentRechargeTaskList',
|
||||
component: RoutesAlias.ExportAgentRechargeTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportAgentRecharge',
|
||||
exportTaskScene: 'agent_recharge',
|
||||
keepAlive: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-exchange',
|
||||
name: 'ExportExchangeTaskList',
|
||||
component: RoutesAlias.ExportExchangeTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportExchange',
|
||||
exportTaskScene: 'exchange',
|
||||
keepAlive: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-commission-record',
|
||||
name: 'ExportCommissionRecordTaskList',
|
||||
component: RoutesAlias.ExportCommissionRecordTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportCommissionRecord',
|
||||
exportTaskScene: 'commission_record',
|
||||
keepAlive: true,
|
||||
permissions: [EXPORT_TASK_SCENE_CONFIG.commission_record.permissions.page]
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-package-traffic-alert',
|
||||
name: 'ExportPackageTrafficAlertTaskList',
|
||||
component: RoutesAlias.ExportPackageTrafficAlertTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportPackageTrafficAlert',
|
||||
exportTaskScene: 'package_traffic_alert',
|
||||
keepAlive: true,
|
||||
permissions: [EXPORT_TASK_SCENE_CONFIG.package_traffic_alert.permissions.page]
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-expiring-asset',
|
||||
name: 'ExportExpiringAssetTaskList',
|
||||
component: RoutesAlias.ExportExpiringAssetTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportExpiringAsset',
|
||||
exportTaskScene: 'expiring_asset',
|
||||
keepAlive: true,
|
||||
permissions: [EXPORT_TASK_SCENE_CONFIG.expiring_asset.permissions.page]
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-operations-activation',
|
||||
name: 'ExportOperationsActivationTaskList',
|
||||
component: RoutesAlias.ExportOperationsActivationTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportOperationsActivation',
|
||||
exportTaskScene: 'operations_activation',
|
||||
keepAlive: true,
|
||||
permissions: [EXPORT_TASK_SCENE_CONFIG.operations_activation.permissions.page]
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-operations-renewal',
|
||||
name: 'ExportOperationsRenewalTaskList',
|
||||
component: RoutesAlias.ExportOperationsRenewalTaskList,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportOperationsRenewal',
|
||||
exportTaskScene: 'operations_renewal',
|
||||
keepAlive: true,
|
||||
permissions: [EXPORT_TASK_SCENE_CONFIG.operations_renewal.permissions.page]
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-task-detail',
|
||||
name: 'ExportTaskDetail',
|
||||
component: RoutesAlias.ExportTaskDetail,
|
||||
meta: {
|
||||
title: 'menus.assetManagement.exportTaskDetail',
|
||||
isHide: true,
|
||||
keepAlive: false,
|
||||
permissions: [EXPORT_TASK_DETAIL_PAGE_PERMISSION]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -21,6 +21,9 @@ export enum RoutesAlias {
|
||||
RoleDetail = '/system/role/detail', // 角色详情
|
||||
Permission = '/system/permission', // 权限管理
|
||||
CarrierManagement = '/system/carrier-management', // 运营商管理
|
||||
CarrierDetail = '/system/carrier-management/detail', // 运营商详情
|
||||
CarrierTrafficThresholdHits = '/system/carrier-traffic-threshold-hits', // 通道阈值命中记录
|
||||
CarrierTrafficThresholdHitsPage = '/system/carrier-management/traffic-threshold-hits', // 通道阈值命中记录组件
|
||||
UserCenter = '/system/user-center', // 用户中心
|
||||
|
||||
// 审计中心
|
||||
@@ -46,7 +49,7 @@ export enum RoutesAlias {
|
||||
Shop = '/shop-management/list', // 店铺列表
|
||||
ShopDetail = '/shop-management/detail', // 店铺详情
|
||||
BusinessUserGroups = '/shop-management/business-user-groups', // 业务用户组
|
||||
BusinessOwnerImport = '/shop-management/business-owner-import', // 业务负责人导入
|
||||
BusinessOwnerImport = '/shop-management/business-owner-import', // 批量换绑业务员
|
||||
AgentDistributionRegistrations = '/shop-management/agent-distribution-registrations', // 代理注册申请
|
||||
AgentDistributionRegistrationDetail = '/shop-management/agent-distribution-registrations/detail', // 代理注册申请详情
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
店铺编码,操作类型,业务员登录账号,备注
|
||||
|
2
src/template/批量换绑业务员模板.csv
Normal file
2
src/template/批量换绑业务员模板.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
店铺编码,操作类型,业务员登录账号,备注
|
||||
,仅支持「换绑」或「清空」,注意: 清空不要填写业务员登录账号,
|
||||
|
1
src/template/订单批量作废模板.csv
Normal file
1
src/template/订单批量作废模板.csv
Normal file
@@ -0,0 +1 @@
|
||||
order_no
|
||||
|
Binary file not shown.
@@ -124,7 +124,7 @@ export interface AgentQueryParams extends PaginationParams {
|
||||
// 创建账号参数(匹配后端 ModelCreateAccountRequest)
|
||||
export interface CreatePlatformAccountParams {
|
||||
username: string // 用户名 (3-50字符)
|
||||
password: string // 密码 (8-32字符)
|
||||
password: string // 8~12位,大写、小写、数字、特殊符号至少三类,无空格或中文
|
||||
phone: string // 手机号 (11位)
|
||||
user_type: number // 用户类型 (1:超级管理员, 2:平台用户, 3:代理账号, 4:企业账号)
|
||||
enterprise_id?: number | null // 关联企业ID(企业账号必填)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
export interface AgentDistributionRegistrationQueryParams {
|
||||
page?: number
|
||||
page_size?: number
|
||||
status?: 0 | 1 | 2
|
||||
status?: 0 | 1 | 2 | 3
|
||||
start_time?: string
|
||||
end_time?: string
|
||||
decided_start_time?: string
|
||||
@@ -54,3 +54,17 @@ export interface RecoverAgentDistributionRegistrationResponse {
|
||||
id: number
|
||||
message?: string
|
||||
}
|
||||
|
||||
export const AGENT_REGISTRATION_APPROVAL_FAILED_STATUS = 3
|
||||
|
||||
export const canRecoverAgentRegistration = (
|
||||
item?: AgentDistributionRegistrationItem | null
|
||||
): boolean =>
|
||||
!!item && item.status !== AGENT_REGISTRATION_APPROVAL_FAILED_STATUS && item.recoverable === true
|
||||
|
||||
export const getAgentRegistrationStatusName = (item: AgentDistributionRegistrationItem): string =>
|
||||
item.status_name ||
|
||||
({ 0: '待审批', 1: '已通过', 2: '已驳回', 3: '审批提交失败' } as Record<number, string>)[
|
||||
item.status
|
||||
] ||
|
||||
String(item.status)
|
||||
|
||||
@@ -9,7 +9,8 @@ export enum AgentRechargeStatus {
|
||||
COMPLETED = 3, // 已完成
|
||||
CLOSED = 4, // 已关闭
|
||||
REFUNDED = 5, // 已退款
|
||||
REJECTED = 6 // 已驳回
|
||||
REJECTED = 6, // 已驳回
|
||||
APPROVAL_SUBMISSION_FAILED = 7 // 审批提交失败(终态)
|
||||
}
|
||||
|
||||
// 支付方式
|
||||
|
||||
@@ -32,6 +32,7 @@ export interface LoginData {
|
||||
export interface UserInfo {
|
||||
id: number // 用户ID
|
||||
username: string // 用户名
|
||||
name?: string | null // me 接口返回的员工姓名
|
||||
phone: string // 手机号
|
||||
user_type: number // 用户类型 (1:超级管理员, 2:平台用户, 3:代理账号, 4:企业账号)
|
||||
user_type_name: string // 用户类型名称
|
||||
@@ -63,7 +64,6 @@ export interface RefreshTokenData {
|
||||
|
||||
// 修改密码参数
|
||||
export interface ChangePasswordParams {
|
||||
oldPassword: string
|
||||
newPassword: string
|
||||
confirmPassword: string
|
||||
old_password: string
|
||||
new_password: string
|
||||
}
|
||||
|
||||
@@ -91,6 +91,7 @@ export interface BusinessUserGroupMember {
|
||||
current_group_id?: number | null
|
||||
current_group_code?: string | null
|
||||
current_group_name?: string | null
|
||||
current_group_enabled?: boolean | null
|
||||
operation?: 'add' | 'already_member' | 'move' | string
|
||||
operation_name?: string | null
|
||||
}
|
||||
|
||||
@@ -12,16 +12,24 @@ export enum CarrierType {
|
||||
CBN = 'CBN' // 中国广电
|
||||
}
|
||||
|
||||
export type CarrierTrafficThresholdEnabled = 0 | 1
|
||||
export type CarrierTrafficThresholdUnit = 'MB' | 'GB'
|
||||
export type CarrierRealnameControlEnabled = 0 | 1
|
||||
|
||||
// 运营商响应数据
|
||||
export interface Carrier {
|
||||
id: number
|
||||
carrier_code: string
|
||||
carrier_name: string
|
||||
carrier_type: CarrierType
|
||||
description?: string
|
||||
description?: string | null
|
||||
data_reset_day?: number | null // 上游流量重置日(1-28)
|
||||
realname_link_type?: string // 实名链接类型
|
||||
realname_link_template?: string // 实名链接模板
|
||||
realname_control_enabled?: CarrierRealnameControlEnabled // 通道实名管控,仅超级管理员与平台账号可见
|
||||
realname_link_type?: string | null // 实名链接类型
|
||||
realname_link_template?: string | null // 实名链接模板
|
||||
traffic_threshold_enabled?: CarrierTrafficThresholdEnabled | null // 通道流量阈值开关
|
||||
traffic_threshold_unit?: CarrierTrafficThresholdUnit | null // 通道流量阈值单位
|
||||
traffic_threshold_value?: number | null // 通道流量阈值数值
|
||||
status: number
|
||||
created_at: string
|
||||
updated_at: string
|
||||
@@ -39,19 +47,28 @@ export interface CreateCarrierParams {
|
||||
carrier_code: string
|
||||
carrier_name: string
|
||||
carrier_type: CarrierType
|
||||
description?: string
|
||||
description?: string | null
|
||||
data_reset_day?: number | null // 上游流量重置日(1-28)
|
||||
realname_link_type?: string // 实名链接类型
|
||||
realname_link_template?: string // 实名链接模板
|
||||
realname_control_enabled?: CarrierRealnameControlEnabled // 通道实名管控 (0:不管控, 1:管控)
|
||||
realname_link_type?: string | null // 实名链接类型
|
||||
realname_link_template?: string | null // 实名链接模板
|
||||
traffic_threshold_enabled?: CarrierTrafficThresholdEnabled | null // 通道流量阈值开关
|
||||
traffic_threshold_unit?: CarrierTrafficThresholdUnit | null // 通道流量阈值单位
|
||||
traffic_threshold_value?: number | null // 通道流量阈值数值
|
||||
}
|
||||
|
||||
// 更新运营商请求参数
|
||||
export interface UpdateCarrierParams {
|
||||
carrier_name?: string
|
||||
description?: string
|
||||
description?: string | null
|
||||
data_reset_day?: number | null // 上游流量重置日(1-28)
|
||||
realname_link_type?: string // 实名链接类型
|
||||
realname_link_template?: string // 实名链接模板
|
||||
realname_control_enabled?: CarrierRealnameControlEnabled // 通道实名管控 (0:不管控, 1:管控)
|
||||
realname_control_confirm?: boolean // 从不管控改为管控时,确认未实名开机卡将在下次评估时被停机
|
||||
realname_link_type?: string | null // 实名链接类型
|
||||
realname_link_template?: string | null // 实名链接模板
|
||||
traffic_threshold_enabled?: CarrierTrafficThresholdEnabled | null // 通道流量阈值开关
|
||||
traffic_threshold_unit?: CarrierTrafficThresholdUnit | null // 通道流量阈值单位
|
||||
traffic_threshold_value?: number | null // 通道流量阈值数值
|
||||
}
|
||||
|
||||
// 更新运营商状态参数
|
||||
|
||||
35
src/types/api/carrierTrafficThresholdHit.ts
Normal file
35
src/types/api/carrierTrafficThresholdHit.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
/** 运营商通道阈值命中记录 */
|
||||
|
||||
export interface CarrierTrafficThresholdHitQueryParams {
|
||||
page?: number
|
||||
page_size?: number
|
||||
carrier_id?: number
|
||||
card_id?: number
|
||||
period_start?: string
|
||||
start_time?: string
|
||||
end_time?: string
|
||||
}
|
||||
|
||||
export interface CarrierTrafficThresholdHitItem {
|
||||
id: number
|
||||
card_id: number
|
||||
carrier_id: number
|
||||
hit_traffic_mb: number | null
|
||||
hit_threshold_value: number | null
|
||||
hit_threshold_unit: string
|
||||
period_start: string
|
||||
judged_at: string
|
||||
trigger_source: string
|
||||
status: string
|
||||
unlocked_at: string | null
|
||||
resume_result: string
|
||||
failure_reason: string
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export interface CarrierTrafficThresholdHitPageResult {
|
||||
items: CarrierTrafficThresholdHitItem[] | null
|
||||
page: number
|
||||
size: number
|
||||
total: number
|
||||
}
|
||||
@@ -137,7 +137,8 @@ export enum WithdrawalStatus {
|
||||
PENDING = 1, // 待审核
|
||||
APPROVED = 2, // 已通过
|
||||
REJECTED = 3, // 已拒绝
|
||||
COMPLETED = 4 // 已到账
|
||||
COMPLETED = 4, // 已到账
|
||||
APPROVAL_SUBMISSION_FAILED = 5 // 审批提交失败(终态)
|
||||
}
|
||||
|
||||
// 佣金类型
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
export interface BaseResponse<T = any> {
|
||||
code: number
|
||||
msg: string
|
||||
message?: string
|
||||
data: T
|
||||
timestamp?: string
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ export type CloseEmployeeCollectionBillResult = EmployeeCollectionBill
|
||||
|
||||
// ========== 核销申请 ==========
|
||||
|
||||
/** 申请状态:0 审批中 / 1 已通过 / 2 已驳回 / 3 已关闭 */
|
||||
/** 申请状态:0 审批中 / 1 已通过 / 2 已驳回 / 3 已关闭 / 4 审批提交失败 */
|
||||
export type EmployeeCollectionApplicationStatus = number
|
||||
|
||||
/** 审批尝试记录(历史材料不被覆盖) */
|
||||
|
||||
@@ -9,7 +9,7 @@ export type H5PopupPage = 'home' | 'asset_detail' | 'package_purchase' | 'asset_
|
||||
// 弹窗类型(promotion: 套餐政策推广, announcement: 通用公告)
|
||||
export type H5PopupType = 'promotion' | 'announcement'
|
||||
|
||||
// 投放频率 (once:每客户每配置版本仅一次, daily:每客户每配置版本每个上海自然日一次)
|
||||
// 投放频率 (once:每客户每配置版本仅一次, daily:每客户每配置版本每天一次)
|
||||
export type H5PopupFrequency = 'once' | 'daily'
|
||||
|
||||
// 受控动作 (package_purchase:套餐购买, asset_wallet_recharge:资产钱包充值);空字符串表示无受控动作
|
||||
|
||||
@@ -66,6 +66,7 @@ export * from './enterpriseDevice'
|
||||
|
||||
// 运营商相关
|
||||
export * from './carrier'
|
||||
export * from './carrierTrafficThresholdHit'
|
||||
|
||||
// 订单相关
|
||||
export * from './order'
|
||||
|
||||
@@ -10,6 +10,28 @@ export enum PaymentStatus {
|
||||
REFUNDED = 4 // 已退款
|
||||
}
|
||||
|
||||
// 支付单状态与订单支付状态数值不同,必须独立处理。
|
||||
export enum OrderPaymentRecordStatus {
|
||||
PENDING = 0,
|
||||
PAID = 1,
|
||||
FAILED = 2,
|
||||
REFUNDED = 3
|
||||
}
|
||||
|
||||
export interface OrderPaymentRecord {
|
||||
payment_no: string
|
||||
payment_method: 'wechat' | 'alipay'
|
||||
payment_channel: string
|
||||
payment_merchant_name: string
|
||||
third_party_trade_no: string
|
||||
amount: number // 分
|
||||
status: OrderPaymentRecordStatus
|
||||
status_name: string
|
||||
created_at: string
|
||||
paid_at: string | null
|
||||
expire_at: string | null
|
||||
}
|
||||
|
||||
// 订单类型
|
||||
export type OrderType = 'single_card' | 'device'
|
||||
|
||||
@@ -17,7 +39,7 @@ export type OrderType = 'single_card' | 'device'
|
||||
export type BuyerType = 'personal' | 'agent'
|
||||
|
||||
// 订单支付方式
|
||||
export type OrderPaymentMethod = 'wallet' | 'wechat' | 'alipay' | 'offline'
|
||||
export type OrderPaymentMethod = 'wallet' | 'wechat' | 'alipay' | 'fuiou' | 'offline'
|
||||
|
||||
// 订单操作者类型
|
||||
export type OrderOperatorType = 'platform' | 'agent' | 'enterprise' | 'personal_customer'
|
||||
@@ -68,6 +90,9 @@ export interface Order {
|
||||
payment_status: PaymentStatus
|
||||
payment_status_text: string
|
||||
payment_method: OrderPaymentMethod
|
||||
third_party_trade_no: string
|
||||
payment_channel: string
|
||||
payment_merchant_name: string
|
||||
total_amount: number // 订单总金额(分)
|
||||
actual_paid_amount?: number // 实付金额(分)
|
||||
paid_at: string | null
|
||||
@@ -97,6 +122,10 @@ export interface Order {
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface OrderDetail extends Order {
|
||||
payments: OrderPaymentRecord[]
|
||||
}
|
||||
|
||||
// 订单查询参数
|
||||
export interface OrderQueryParams {
|
||||
page?: number
|
||||
|
||||
@@ -19,7 +19,6 @@ export interface PackageTrafficAlertRuleItem {
|
||||
id: number // 预警规则ID
|
||||
package_id: number // 套餐商品ID
|
||||
package_name: string // 套餐名称
|
||||
real_data_mb: number // 套餐商品当前真流量额度(MB),仅用于配置校验展示,不作为预警分母
|
||||
threshold_percent: number // 真流量预警阈值百分比(1~100,允许两位小数)
|
||||
enabled: boolean // 是否启用
|
||||
enabled_name: string // 启用状态名称(中文)
|
||||
@@ -90,6 +89,9 @@ export interface PackageTrafficAlertRecordItem {
|
||||
asset_type?: PackageTrafficAlertAssetType | null // 资产类型快照
|
||||
asset_identifier?: string | null // 资产或卡标识快照
|
||||
threshold_percent?: number // 触发阈值快照
|
||||
threshold_mb?: number | null // 触发时阈值流量(MB),主套餐与加油包汇总
|
||||
used_mb?: number | null // 触发时已用流量(MB),含加油包
|
||||
limit_mb?: number | null // 触发时总额度(MB),含加油包
|
||||
triggered_at?: string // 触发时间
|
||||
notification_status?: PackageTrafficAlertNotificationStatus // 通知投递结果
|
||||
notification_status_name?: string // 通知投递结果名称
|
||||
|
||||
@@ -9,7 +9,8 @@ export enum RefundStatus {
|
||||
REJECTED = 3, // 已拒绝
|
||||
RETURNED = 4, // 已退回
|
||||
REFUNDING = 5, // 原路退款处理中
|
||||
REFUND_FAILED = 6 // 原路退款失败
|
||||
REFUND_FAILED = 6, // 原路退款失败
|
||||
APPROVAL_SUBMISSION_FAILED = 7 // 审批提交失败(终态)
|
||||
}
|
||||
|
||||
// 退款方式
|
||||
|
||||
@@ -166,7 +166,7 @@ export interface BatchUpdateBusinessOwnerResult {
|
||||
|
||||
// ========== 业务负责人 CSV 导入 ==========
|
||||
|
||||
/** 业务负责人导入任务行级结果 */
|
||||
/** 批量换绑业务员任务行级结果 */
|
||||
export interface BusinessOwnerImportRow {
|
||||
line: number // 行号,从数据首行 1 开始
|
||||
shop_code: string // 店铺编码
|
||||
@@ -176,7 +176,7 @@ export interface BusinessOwnerImportRow {
|
||||
reason: string // 失败原因
|
||||
}
|
||||
|
||||
/** 业务负责人导入任务详情 */
|
||||
/** 批量换绑业务员任务详情 */
|
||||
export interface BusinessOwnerImportDetail {
|
||||
id: number // 导入任务ID
|
||||
task_no?: string // 任务编号
|
||||
@@ -195,19 +195,19 @@ export interface BusinessOwnerImportDetail {
|
||||
updated_at?: string
|
||||
}
|
||||
|
||||
/** 创建业务负责人导入任务请求 */
|
||||
/** 创建批量换绑业务员任务请求 */
|
||||
export interface CreateBusinessOwnerImportParams {
|
||||
file_key: string // 由 /storage/upload-url(purpose=shop_import)获取
|
||||
}
|
||||
|
||||
/** 业务负责人导入任务列表查询参数 */
|
||||
/** 批量换绑业务员任务列表查询参数 */
|
||||
export interface BusinessOwnerImportQueryParams {
|
||||
page?: number
|
||||
page_size?: number
|
||||
status?: number // 按状态筛选
|
||||
}
|
||||
|
||||
/** 业务负责人导入任务列表响应 */
|
||||
/** 批量换绑业务员任务列表响应 */
|
||||
export interface BusinessOwnerImportPageResult {
|
||||
items: BusinessOwnerImportDetail[] | null
|
||||
page?: number
|
||||
|
||||
@@ -97,6 +97,7 @@ export interface WecomBusinessField {
|
||||
description: string
|
||||
name: string
|
||||
value_type: string
|
||||
required_mapping: boolean
|
||||
}
|
||||
|
||||
export interface WecomBusinessFieldList {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user