24 Commits

Author SHA1 Message Date
wren c54f84382b feat: align frontend document and rule management flows 2026-05-06 09:40:37 +08:00
LiangShiyong 616f059f1e feat: 1. 完善评查点分组的删除逻辑,会涉及文档类型绑定的一级分组,分组绑定的评查点规则。新增一个评查点分组换绑的。
2. 修复交叉评查的任务中的文档列表的历史文档的查看跳转路径。
3. 修复评查点新增中评查点类型只能显示当前文档类型绑定的这几个一级分组。评查点类型=一级分组。
4. 修复文档列表关于pdf的下载失败的问题。
2025-12-19 00:21:49 +08:00
LiangShiyong 91b7518c99 feat: 1. 完善起草合同页面的逻辑交互,对接minio的接口操作 2025-12-05 20:17:37 +08:00
LiangShiyong 30e100ef3e feat: 1. 本地化思源黑体的字体包并优先使用。
2. 添加权限映射表和全局查看权限的hook,便于路由控制不同权限按钮显示/隐藏。
3. 删除评查点分组的部分旧api方法。
4. 对接评查点分组接口,文档类型接口, 提示词管理接口, 入口模块管理的接口。
5. 优化角色权限管理的接口,完善不用地区的访问权限认证。
6. 优化主页交叉评查和设置的入口样式和布局。
7. 优化评查点分组,评查规则的功能权限校验。
2025-11-29 10:37:35 +08:00
LiangShiyong d5827a2146 fix: 1. 接入入口模块的管理接口,优化样式。
2. 将查看文档评查结果详情对接接口,采用接口的方式进行查询。
2025-11-26 23:37:14 +08:00
TanWenyan da7e565bbb fix(evaluation-groups): 修复 Authorization 头缺失问题
## 问题
GET 和 DELETE 请求在 token 为 undefined 时,传递空对象 `{}` 作为 headers,导致 axios-client 拦截器无法自动添加 Authorization 头。

## 根本原因
```typescript
//  错误写法
headers: token ? { 'Authorization': `Bearer ${token}` } : {}
```
当 token 为 undefined 时,传递的是空对象 `{}`,axios-client 认为已经提供了 headers,就跳过拦截器。

## 修复方案
```typescript
//  正确写法
...(token ? { headers: { 'Authorization': `Bearer ${token}` } } : {})
```
当 token 为 undefined 时,完全不传 headers 参数,让 axios-client 拦截器自动添加。

## 修复的函数
1.  getEvaluationPointGroups (GET)
2.  getAllEvaluationPointGroups (GET)
3.  getEvaluationPointGroup (GET)
4.  getEvaluationPointGroupChildren (GET)
5.  deleteEvaluationPointGroup (DELETE)

## 未修复的函数(无需修复)
- createEvaluationPointGroup (POST) - headers 总是包含 Content-Type
- updateEvaluationPointGroup (PUT) - headers 总是包含 Content-Type
- batchUpdateEvaluationPointGroupStatus (PATCH) - headers 总是包含 Content-Type
- batchDeleteEvaluationPointGroups (DELETE) - headers 总是包含 Content-Type

POST/PUT/PATCH 请求因为总是需要设置 Content-Type,所以 headers 对象总是存在,拦截器会正常工作。

## 影响
修复后,即使 token 参数为 undefined,axios-client 拦截器也能正常添加 Authorization 头。

## 文件
- app/api/evaluation_points/rule-groups.ts

## 相关日志
解决了控制台警告:
⚠️ [apiRequest] 请求缺少 Authorization 头!headers:
2025-11-26 10:37:36 +08:00
TanWenyan bd3b6de9cd debug(evaluation-groups): 添加 getEvaluationPointGroups 调试日志
## 修改内容

在 getEvaluationPointGroups 函数中添加详细的调试日志,用于排查数据获取问题:

### 新增调试日志
- 📦 打印完整 API 响应
- 📊 打印 response.data 和 response.data.data
-  错误日志增强
-  转换成功后打印结果

### 日志输出点
1. API 响应完整数据
2. response.data 检查
3. response.data.data 存在性验证
4. 数据转换后的 ruleGroups
5. 错误捕获和详细错误信息

### 目的
帮助诊断以下问题:
- 后端返回数据格式是否正确
- response.data.data 是否存在
- 数据转换是否成功
- 前端为什么没有显示数据

### 文件
- app/api/evaluation_points/rule-groups.ts:1207-1225

⚠️ 注意:这是临时调试日志,问题解决后应该移除或注释掉
2025-11-26 10:23:01 +08:00
TanWenyan e7646d17a6 fix(evaluation-groups): 修复一级分组显示错误和 React key 警告
## 修复内容

### 1. 修复一级分组过滤问题
- **问题**: getEvaluationPointGroups 函数忽略了 pid 参数,导致返回所有分组(包括二级分组)
- **修复**: 添加 pid 参数处理逻辑,支持传递 "null" 字符串来查询一级分组
- **文件**: app/api/evaluation_points/rule-groups.ts:1186-1198

### 2. 修复 React key 重复警告
- **问题**: 父分组和子分组可能有相同的 ID,导致 "Encountered two children with the same key" 警告
- **修复**: 将 rowKey 从简单的 "id" 改为根据 isParent 生成唯一 key
- **文件**: app/routes/rule-groups._index.tsx:817

### 3. 新增后端 API 规范文档
- **文件**: docs/evaluation/evaluation_point_groups_backend_api_spec.md
- **内容**:
  - 完整的 9 个 FastAPI v3 接口规范
  - Python Pydantic 模型定义
  - TypeScript 接口定义
  - pid 参数处理说明(字符串 "null" 转换为 None)
  - 10 个完整测试用例
  - 数据库表结构建议

## 技术细节

**pid 参数处理**:
```typescript
// 前端发送
GET /api/v3/evaluation-point-groups?pid=null&page=1

// 后端需要识别字符串 "null" 并转换为 None/NULL
if (pid == "null") {
  query = query.filter(EvaluationPointGroup.pid.is_(None))
}
```

**唯一 key 生成**:
```typescript
rowKey={(record) => record.isParent ? `parent-${record.id}` : `child-${record.id}`}
```

🔗 相关文档: docs/evaluation/evaluation_point_groups_backend_api_spec.md
2025-11-26 10:05:39 +08:00
TanWenyan 0e812ba181 fix(rule-groups): 修复 getChildGroups 函数使用 FastAPI v3 接口
问题:
- getChildGroups 函数内部仍在调用已重命名的 getRuleGroups 函数
- 导致运行时错误:"getRuleGroups is not defined"
- 影响子分组加载功能

修复:
- 更新 getChildGroups 使用 FastAPI v3 的 getEvaluationPointGroupChildren
- 删除手动统计评查点数量的代码(FastAPI v3 接口已返回 rule_count)
- 简化函数逻辑,直接返回接口数据

影响范围:
- app/api/evaluation_points/rule-groups.ts (getChildGroups 函数)

功能:
- 获取子分组列表及评查点数量

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 20:39:11 +08:00
TanWenyan dbc9512c8b refactor(rule-groups): 替换创建/编辑页面为 FastAPI v3 接口
变更内容:
1. 补充重命名 getRuleGroup → getRuleGroup_legacy (rule-groups.ts)
2. 更新导入语句,使用新的 FastAPI v3 函数 (rule-groups.new.tsx)
3. 替换所有函数调用:
   - getRuleGroups → getEvaluationPointGroups (2处)
   - getRuleGroup → getEvaluationPointGroup
   - createRuleGroup → createEvaluationPointGroup
   - updateRuleGroup → updateEvaluationPointGroup

影响范围:
- app/api/evaluation_points/rule-groups.ts (补充遗漏的重命名)
- app/routes/rule-groups.new.tsx (创建/编辑页面)

功能:
- 分组创建、编辑、编码唯一性验证

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 20:20:52 +08:00
TanWenyan ccb33e9b11 refactor(rule-groups): 重命名旧 PostgREST 函数为 _legacy 后缀
重命名函数(保留作为备份):
1. getRuleGroups → getRuleGroups_legacy
2. getAllRuleGroups → getAllRuleGroups_legacy
3. createRuleGroup → createRuleGroup_legacy
4. updateRuleGroup → updateRuleGroup_legacy
5. deleteRuleGroup → deleteRuleGroup_legacy
6. batchUpdateRuleGroupStatus → batchUpdateRuleGroupStatus_legacy
7. batchDeleteRuleGroups → batchDeleteRuleGroups_legacy

变更:
- 所有旧函数添加 _legacy 后缀
- 添加 @deprecated 注释指向新的 FastAPI v3 函数
- 保留旧函数作为备份,不删除

目的:
- 为过渡到 FastAPI v3 接口做准备
- 保留旧代码以便回滚

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 20:14:53 +08:00
TanWenyan d5a7674a9a feat(rule-groups): 添加 FastAPI v3 评查点分组接口函数
新增功能:
- 添加 9 个 FastAPI v3 接口函数到 rule-groups.ts
- 导入 apiRequest 用于调用后端 API

接口列表:
1. getEvaluationPointGroups - 获取一级分组列表 (GET /api/v3/evaluation-point-groups)
2. getAllEvaluationPointGroups - 获取树形结构 (GET /api/v3/evaluation-point-groups/all)
3. getEvaluationPointGroup - 获取单个分组详情 (GET /api/v3/evaluation-point-groups/{id})
4. getEvaluationPointGroupChildren - 获取子分组列表 (GET /api/v3/evaluation-point-groups/{parent_id}/children)
5. createEvaluationPointGroup - 创建分组 (POST /api/v3/evaluation-point-groups)
6. updateEvaluationPointGroup - 更新分组 (PUT /api/v3/evaluation-point-groups/{id})
7. deleteEvaluationPointGroup - 删除分组 (DELETE /api/v3/evaluation-point-groups/{id})
8. batchUpdateEvaluationPointGroupStatus - 批量更新状态 (PATCH /api/v3/evaluation-point-groups/batch/status)
9. batchDeleteEvaluationPointGroups - 批量删除 (DELETE /api/v3/evaluation-point-groups/batch)

技术细节:
- 新增 EvaluationPointGroupResponse 接口定义响应格式
- 新增 convertApiGroupToRuleGroup 转换函数
- 所有函数支持 JWT token 认证
- 统一的错误处理和日志输出
- 保留旧的 PostgREST 函数作为备份

相关文档:
- docs/evaluation/evaluation_point_groups.md

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 20:10:30 +08:00
TanWenyan 7f1a05107f feat(evaluation): 模块1.4 - 新增评查点分组批量操作接口
## 主要改进

### 1. 新增 batchUpdateRuleGroupStatus 函数(批量启用/禁用)
-  参数验证(ID列表不为空,每个ID有效)
-  逐个验证分组存在性
-  逐个执行更新操作
-  返回详细的操作结果
  - updated_count: 成功更新的数量
  - failed_ids: 失败的ID列表
  - errors: 详细的错误信息(包含ID和错误原因)

### 2. 新增 batchDeleteRuleGroups 函数(批量删除)
-  参数验证(ID列表不为空,每个ID有效)
-  采用安全的阻止删除策略
-  逐个检查并删除分组
-  返回详细的操作结果和错误信息
  - deleted_count: 成功删除的数量
  - failed_ids: 失败的ID列表
  - errors: 详细的错误信息(包含子分组/评查点检查结果)

### 3. 批量操作特性
-  **逐个处理**:确保每个分组都能被正确处理
-  **部分成功支持**:即使部分分组操作失败,成功的也会被处理
-  **详细的错误追踪**:记录每个失败的ID及其失败原因
-  **安全性优先**:批量删除继承单个删除的安全检查

### 4. 返回值结构

```typescript
// 批量更新状态
{
  success: boolean;          // 是否全部成功
  updated_count: number;     // 成功更新的数量
  failed_ids: string[];      // 失败的ID列表
  errors?: Array<{           // 详细错误(可选)
    id: string;
    error: string;
  }>;
}

// 批量删除
{
  success: boolean;          // 是否全部成功
  deleted_count: number;     // 成功删除的数量
  failed_ids: string[];      // 失败的ID列表
  errors?: Array<{           // 详细错误(可选)
    id: string;
    error: string;
    details?: {              // 删除失败详情
      hasChildren?: boolean;
      hasPoints?: boolean;
    };
  }>;
}
```

## 使用示例

### 批量启用分组
```typescript
const result = await batchUpdateRuleGroupStatus(
  ['1', '2', '3'],
  true,
  token
);

if (result.success) {
  console.log(`成功启用 ${result.updated_count} 个分组`);
} else {
  console.log(`成功 ${result.updated_count} 个,失败 ${result.failed_ids.length} 个`);
  result.errors?.forEach(err => {
    console.log(`分组 ${err.id}: ${err.error}`);
  });
}
```

### 批量删除分组
```typescript
const result = await batchDeleteRuleGroups(['1', '2'], token);

if (result.success) {
  console.log(`成功删除 ${result.deleted_count} 个分组`);
} else {
  result.errors?.forEach(err => {
    if (err.details?.hasChildren) {
      console.log(`分组 ${err.id} 有子分组,无法删除`);
    }
    if (err.details?.hasPoints) {
      console.log(`分组 ${err.id} 有评查点,无法删除`);
    }
  });
}
```

## 相关文件
- app/api/evaluation_points/rule-groups.ts

## 验收清单
- [x] TypeScript 类型检查通过
- [x] 完整的参数验证
- [x] 支持部分成功场景
- [x] 详细的错误追踪
- [x] 安全的删除策略

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 12:16:46 +08:00
TanWenyan 89b1d2e5f5 feat(evaluation): 模块1.3 - 增强评查点分组删除接口安全性
## 主要改进

### 1. 删除策略优化(从级联删除改为阻止删除)
-  **安全优先**:采用阻止删除策略而非级联删除
-  删除前检查子分组,如有则拒绝删除
-  删除前检查关联评查点,如有则拒绝删除
-  只有空分组才能被删除

### 2. 详细的删除检查
-  ID有效性验证
-  分组存在性验证
-  子分组检查(仅一级分组)
-  评查点关联检查(所有分组)
-  返回详细的检查结果(childCount, pointCount)

### 3. 友好的错误提示
-  明确提示存在多少个子分组
-  明确提示存在多少个评查点
-  建议用户先清理关联数据
-  区分不同类型的删除失败原因

### 4. 标记废弃函数
-  deleteChildGroup 标记为 @deprecated
-  deleteEvaluationPointsByGroupId 标记为 @deprecated
-  保留代码以备将来批量删除功能使用

## 删除策略对比

### 旧策略(级联删除)- 高风险
 删除一级分组时自动删除所有子分组
 自动删除所有关联的评查点
 用户可能误删大量数据
 无法恢复

### 新策略(阻止删除)- 安全
 拒绝删除有子分组的一级分组
 拒绝删除有评查点的分组
 用户必须手动清理关联数据
 防止误删除
 提供清晰的错误提示

## 返回值增强

```typescript
{
  success: boolean;
  error?: string;
  details?: {
    hasChildren: boolean;  // 是否有子分组
    hasPoints: boolean;    // 是否有评查点
    childCount?: number;   // 子分组数量
    pointCount?: number;   // 评查点数量
  }
}
```

## 相关文件
- app/api/evaluation_points/rule-groups.ts

## 验收清单
- [x] TypeScript 类型检查通过
- [x] 删除前完整的关联检查
- [x] 阻止删除有依赖的分组
- [x] 详细的错误提示
- [x] 返回详细的检查结果

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 12:13:57 +08:00
TanWenyan e148fca429 feat(evaluation): 模块1.2 - 增强评查点分组创建/更新接口验证
## 主要改进

### 1. 增强 createRuleGroup 函数
-  名称长度验证(1-100字符)
-  编码格式验证(只允许字母、数字、连字符、下划线)
-  编码长度验证(1-50字符)
-  编码唯一性验证(查询数据库确保不重复)
-  父级ID存在性验证(二级分组必须有有效的父级)
-  三级分组防护(不允许在二级分组下创建子分组)
-  数据库约束错误友好提示

### 2. 增强 updateRuleGroup 函数
-  ID有效性验证(检查分组是否存在)
-  名称长度验证(1-100字符)
-  编码格式验证(只允许字母、数字、连字符、下划线)
-  编码长度验证(1-50字符)
-  编码唯一性验证(排除自身)
-  **禁止修改pid**(防止分组层级混乱)
-  数据库约束错误友好提示
-  提供清晰的错误消息

### 3. 类型安全性改进
-  修复所有 TypeScript 类型错误
-  添加类型守卫防止 undefined 访问
-  确保所有返回值类型正确

## 验证规则

### 分组名称
- 必填,不能为空
- 长度:1-100字符
- 自动去除首尾空格

### 分组编码
- 必填,不能为空
- 长度:1-50字符
- 格式:只允许字母、数字、连字符(-)、下划线(_)
- 必须全局唯一
- 自动去除首尾空格

### 父级ID
- 一级分组:pid = null 或 '0'
- 二级分组:pid = 有效的父级分组ID
- 不允许三级分组
- **更新时不允许修改pid**

## 相关文件
- app/api/evaluation_points/rule-groups.ts

## 验收清单
- [x] TypeScript 类型检查通过
- [x] 完整的字段验证
- [x] 编码唯一性验证
- [x] 父级ID验证
- [x] 禁止修改pid
- [x] 友好的错误提示

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 12:11:12 +08:00
TanWenyan d3b9403d64 feat(evaluation): 模块1.1 - 增强评查点分组查询接口
## 主要改进

### 1. 增强 getRuleGroups 函数
-  添加完整的分页参数支持 (page, pageSize)
-  添加筛选参数 (name, code, is_enabled, pid)
-  添加排序参数 (orderBy, order)
-  返回总数 (totalCount)
-  支持一级分组和二级分组查询

### 2. 优化 getChildGroups 函数
-  内部使用改进后的 getRuleGroups 函数
-  自动添加评查点数量统计
-  改进类型安全性

### 3. 优化 getRuleGroup 函数
-  确保评查点数量统计准确
-  改进错误处理
-  优化类型守卫逻辑

### 4. 类型定义改进
-  新增 RuleGroupQueryParams 接口
-  ApiRuleGroup.pid 类型支持 null
-  修复所有 TypeScript 类型错误

### 5. 创建对接计划文档
-  详细的 API 对接实施计划
-  分模块逐步实施策略
-  验收标准和风险评估

## 相关文件
- app/api/evaluation_points/rule-groups.ts
- docs/evaluation/API对接实施计划.md

## 验收清单
- [x] TypeScript 类型检查通过
- [x] 支持分页、筛选、排序
- [x] 返回评查点数量统计
- [x] 向后兼容现有代码

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 12:06:48 +08:00
LiangShiyong 6dc9b4e468 feat: 1. 完善文档列表的显示效果,数据对接后端接口返回。
2. 对评查点分组和文档类型的编辑删除新增操作进行限制。
2025-11-20 15:26:11 +08:00
LiangShiyong 34cba4a34f fix: 修复评查点分组的结果保存异常 2025-11-03 09:47:46 +08:00
LiangShiyong 064f05ffa5 添加根据合同/卷宗的入口进行分类评查点列表,同时区分卷宗添加的分组属于卷宗,合同添加的分组属于合同 2025-10-29 21:01:01 +08:00
LiangShiyong 59706b70d0 给所有请求都加上jwt,隐藏生成jwt的secret(放到.env中),隐藏app-secret(放在pm2运行配置文件中,后续直接读取环境配置即可) 2025-10-17 15:28:22 +08:00
LiangShiyong b02978508d 删除所有console.log输出,优化评查结果的表格的显示,添加新的页码获取逻辑 2025-06-02 18:55:00 +08:00
LiangShiyong 5c2c367856 新增提示Toast组件 2025-04-21 09:22:13 +08:00
LiangShiyong 5cf05eca40 完成评查点分组的增删改 2025-04-07 22:40:51 +08:00
LiangShiyong 17f330d07d 创建评查点分组的API文件 2025-04-07 00:46:31 +08:00