liuyun 8743e68451 chore: archive dict-driven-enums change + sync specs to main specs
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-11 14:44:56 +08:00

37 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 1. 数据模型
- [x] 1.1 Prisma schema:`dict_type` 加 `built_in`(Boolean 默认 false),`dict_item` 加 `built_in`(Boolean 默认 false)与 `color_type`(String? 可空)
- [x] 1.2 生成并应用 Prisma migration(增量加列,无破坏)
- [x] 1.3 seed 预置 5 个内置字典类型 + 字典项(含 label / color_type / sort,按 `(tenantCode, code)` 与 `(tenantCode, dictTypeCode, value)` 幂等 upsert,内置项 `built_in=true`)
## 2. 后端字典保护与聚合接口
- [x] 2.1 dicts.service:删除内置类型 / 删除内置项 拦截并返回明确错误
- [x] 2.2 dicts.service:修改内置项 value 拦截(label / sort / color_type 放行)
- [x] 2.3 新增 `GET /dicts` 聚合接口(当前租户启用类型 + 启用项,项按 sort 升序)
- [x] 2.4 字典 DTO 补充 `built_in` / `color_type` 字段映射与校验
## 3. 前端字典机制
- [x] 3.1 新增 `src/stores/modules/dict.ts`(dicts / loaded / fetch / reset)
- [x] 3.2 新增 `src/composables/useDict.ts`(字典项数组 + tagMap + options 三种视图)
- [x] 3.3 `layout/default.vue` 登录后拉取字典;`main.ts` 登出/auth 失效清空字典缓存
## 4. 组件库 dictCode 支持
- [x] 4.1 `src/types/crud.ts`:JsonSchemaProperty 增 `dictCode`、TableColumn 增 `dictCode`
- [x] 4.2 ty-form / ty-search-form:字段声明 `dictCode` 时自动解析下拉选项(忽略手写 enum/enumNames)
- [x] 4.3 ty-table:列声明 `dictCode` 时按字典渲染标签(label + color_type 着色)
## 5. 页面去硬编码与保护交互
- [x] 5.1 字典管理页:内置类型/项「内置」标记 + value 只读/禁删 + color_type 编辑
- [x] 5.2 用户 / 角色 / 资源 / 组织 / 租户页删除本地 `STATUS_MAP` / `TYPE_MAP` / `DATA_SCOPE_MAP`,改用 dictCode / useDict
- [x] 5.3 审计 / 登录日志页删除 success/fail 硬编码映射,改用 dictCode
## 6. 验证
- [x] 6.1 后端 `pnpm build` + 保护规则与 `GET /dicts` 冒烟验证
- [x] 6.2 前端 `pnpm type-check` + `pnpm build` 通过
- [x] 6.3 联调验收:改字典 label 全局生效、内置项 value 受保护、下拉/标签字典驱动渲染