fix(dc/tool-c): Fix special character handling and improve UX

Major fixes:
- Fix pivot transformation with special characters in column names
- Fix compute column validation for Chinese punctuation
- Fix recode dialog to fetch unique values from full dataset via new API
- Add column mapping mechanism to handle special characters

Database migration:
- Add column_mapping field to dc_tool_c_sessions table
- Migration file: 20251208_add_column_mapping

UX improvements:
- Darken table grid lines for better visibility
- Reduce column width by 40% with tooltip support
- Insert new columns next to source columns
- Preserve original row order after operations
- Add notice about 50-row preview limit

Modified files:
- Backend: SessionService, SessionController, QuickActionService, routes
- Python: pivot.py, compute.py, recode.py, binning.py, conditional.py
- Frontend: DataGrid, RecodeDialog, index.tsx, ag-grid-custom.css
- Database: schema.prisma, migration SQL

Status: Code complete, database migrated, ready for testing
This commit is contained in:
2025-12-08 23:20:55 +08:00
parent f729699510
commit 91cab452d1
90 changed files with 735 additions and 45 deletions

View File

@@ -128,6 +128,16 @@ def apply_conditional_column(
print(f' 规则{rule_idx}: 匹配 {matched_count} 行 → 值为 {result_value}')
# ✨ 优化:将新列移到第一个引用列旁边
first_ref_col = rules[0]['conditions'][0]['column'] # 使用第一个规则的第一个条件列作为参考
original_col_index = result.columns.get_loc(first_ref_col)
cols = list(result.columns)
# 移除新列(当前在最后)
cols.remove(new_column_name)
# 插入到原列旁边
cols.insert(original_col_index + 1, new_column_name)
result = result[cols]
# 统计结果分布
print(f'\n结果分布:')
value_counts = result[new_column_name].value_counts(dropna=False)