feat(dc): Complete Tool C quick action buttons Phase 1-2 - 7 functions
Summary: - Implement 7 quick action functions (filter, recode, binning, conditional, dropna, compute, pivot) - Refactor to pre-written Python functions architecture (stable and secure) - Add 7 Python operations modules with full type hints - Add 7 frontend Dialog components with user-friendly UI - Fix NaN serialization issues and auto type conversion - Update all related documentation Technical Details: - Python: operations/ module (filter.py, recode.py, binning.py, conditional.py, dropna.py, compute.py, pivot.py) - Backend: QuickActionService.ts with 7 execute methods - Frontend: 7 Dialog components with complete validation - Toolbar: Enable 7 quick action buttons Status: Phase 1-2 completed, basic testing passed, ready for further testing
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
Wand2,
|
||||
Filter,
|
||||
Search,
|
||||
Trash2,
|
||||
} from 'lucide-react';
|
||||
|
||||
interface ToolbarButtonProps {
|
||||
@@ -33,63 +34,130 @@ const ToolbarButton: React.FC<ToolbarButtonProps> = ({
|
||||
<button
|
||||
onClick={onClick}
|
||||
disabled={disabled}
|
||||
className={`flex flex-col items-center justify-center w-20 h-14 rounded-lg transition-all hover:shadow-sm disabled:opacity-50 disabled:cursor-not-allowed ${colorClass}`}
|
||||
className={`
|
||||
flex items-center gap-1.5
|
||||
px-3 py-2
|
||||
rounded-lg
|
||||
transition-all
|
||||
disabled:opacity-40 disabled:cursor-not-allowed
|
||||
hover:bg-slate-50 hover:shadow-sm
|
||||
${disabled ? 'text-slate-400' : colorClass}
|
||||
`}
|
||||
title={disabled ? '开发中...' : label}
|
||||
>
|
||||
<Icon className="w-5 h-5 mb-1" />
|
||||
<span className="text-[10px] font-medium">{label}</span>
|
||||
<Icon className="w-4 h-4" />
|
||||
<span className="text-xs font-medium">{label}</span>
|
||||
</button>
|
||||
);
|
||||
};
|
||||
|
||||
const Toolbar = () => {
|
||||
interface ToolbarProps {
|
||||
onFilterClick?: () => void;
|
||||
onRecodeClick?: () => void;
|
||||
onBinningClick?: () => void;
|
||||
onConditionalClick?: () => void;
|
||||
onDropnaClick?: () => void;
|
||||
onComputeClick?: () => void;
|
||||
onDedupClick?: () => void;
|
||||
onPivotClick?: () => void;
|
||||
onMiceClick?: () => void;
|
||||
sessionId: string | null;
|
||||
}
|
||||
|
||||
const Toolbar: React.FC<ToolbarProps> = ({
|
||||
onFilterClick,
|
||||
onRecodeClick,
|
||||
onBinningClick,
|
||||
onConditionalClick,
|
||||
onDropnaClick,
|
||||
onComputeClick,
|
||||
onDedupClick,
|
||||
onPivotClick,
|
||||
onMiceClick,
|
||||
sessionId,
|
||||
}) => {
|
||||
return (
|
||||
<div className="bg-white border-b border-slate-200 px-4 py-2 flex items-center gap-1 overflow-x-auto flex-none shadow-sm z-10">
|
||||
{/* 7个快捷按钮 */}
|
||||
<div className="bg-white border-b border-slate-200 px-4 py-2 flex items-center gap-2 overflow-x-auto flex-none shadow-sm z-10">
|
||||
{/* 核心按钮(Phase 1-2) */}
|
||||
<ToolbarButton
|
||||
icon={Calculator}
|
||||
label="生成新变量"
|
||||
colorClass="text-emerald-600 bg-emerald-50 hover:bg-emerald-100"
|
||||
/>
|
||||
<ToolbarButton
|
||||
icon={CalendarClock}
|
||||
label="时间差"
|
||||
colorClass="text-blue-600 bg-blue-50 hover:bg-blue-100"
|
||||
icon={Filter}
|
||||
label="高级筛选"
|
||||
colorClass="text-indigo-600 bg-indigo-50 hover:bg-indigo-100"
|
||||
onClick={onFilterClick}
|
||||
disabled={!sessionId}
|
||||
/>
|
||||
<ToolbarButton
|
||||
icon={ArrowLeftRight}
|
||||
label="横纵转换"
|
||||
label="数值映射"
|
||||
colorClass="text-cyan-600 bg-cyan-50 hover:bg-cyan-100"
|
||||
onClick={onRecodeClick}
|
||||
disabled={!sessionId}
|
||||
/>
|
||||
<ToolbarButton
|
||||
icon={Calculator}
|
||||
label="生成分类"
|
||||
colorClass="text-emerald-600 bg-emerald-50 hover:bg-emerald-100"
|
||||
onClick={onBinningClick}
|
||||
disabled={!sessionId}
|
||||
/>
|
||||
|
||||
<div className="w-[1px] h-8 bg-slate-200 mx-2"></div>
|
||||
|
||||
<ToolbarButton
|
||||
icon={FileSearch}
|
||||
label="查重"
|
||||
colorClass="text-orange-600 bg-orange-50 hover:bg-orange-100"
|
||||
/>
|
||||
{/* 辅助按钮(Phase 2) */}
|
||||
<ToolbarButton
|
||||
icon={Wand2}
|
||||
label="多重插补"
|
||||
colorClass="text-rose-600 bg-rose-50 hover:bg-rose-100"
|
||||
label="条件生成列"
|
||||
colorClass="text-purple-600 bg-purple-50 hover:bg-purple-100"
|
||||
onClick={onConditionalClick}
|
||||
disabled={!sessionId}
|
||||
/>
|
||||
<ToolbarButton
|
||||
icon={Trash2}
|
||||
label="删除缺失值"
|
||||
colorClass="text-red-600 bg-red-50 hover:bg-red-100"
|
||||
onClick={onDropnaClick}
|
||||
disabled={!sessionId}
|
||||
/>
|
||||
<ToolbarButton
|
||||
icon={Calculator}
|
||||
label="计算列"
|
||||
colorClass="text-green-600 bg-green-50 hover:bg-green-100"
|
||||
onClick={onComputeClick}
|
||||
disabled={!sessionId}
|
||||
/>
|
||||
<ToolbarButton
|
||||
icon={FileSearch}
|
||||
label="去重"
|
||||
colorClass="text-orange-600 bg-orange-50 hover:bg-orange-100"
|
||||
onClick={onDedupClick}
|
||||
disabled={true}
|
||||
/>
|
||||
|
||||
<div className="w-[1px] h-8 bg-slate-200 mx-2"></div>
|
||||
|
||||
{/* 高级按钮(Phase 3) */}
|
||||
<ToolbarButton
|
||||
icon={Filter}
|
||||
label="筛选分析集"
|
||||
icon={ArrowLeftRight}
|
||||
label="长→宽表"
|
||||
colorClass="text-indigo-600 bg-indigo-50 hover:bg-indigo-100"
|
||||
onClick={onPivotClick}
|
||||
disabled={!sessionId}
|
||||
/>
|
||||
<ToolbarButton
|
||||
icon={CalendarClock}
|
||||
label="多重插补"
|
||||
colorClass="text-rose-600 bg-rose-50 hover:bg-rose-100"
|
||||
onClick={onMiceClick}
|
||||
disabled={true}
|
||||
/>
|
||||
|
||||
<div className="flex-1"></div>
|
||||
|
||||
{/* 搜索框 */}
|
||||
{/* ✅ 优化3.2:搜索框高度缩小 */}
|
||||
<div className="relative">
|
||||
<Search size={16} className="absolute left-3 top-1/2 -translate-y-1/2 text-slate-400" />
|
||||
<Search size={14} className="absolute left-2.5 top-1/2 -translate-y-1/2 text-slate-400" />
|
||||
<input
|
||||
className="pl-9 pr-4 py-1.5 text-sm bg-slate-100 border-none rounded-full w-48 focus:w-64 transition-all outline-none focus:ring-2 focus:ring-emerald-500/20"
|
||||
className="pl-8 pr-4 py-1.5 text-xs bg-slate-50 border border-slate-200 rounded-lg w-48 focus:w-64 transition-all outline-none focus:ring-2 focus:ring-emerald-500/20 focus:border-emerald-500"
|
||||
placeholder="搜索值..."
|
||||
disabled
|
||||
title="开发中..."
|
||||
@@ -101,3 +169,4 @@ const Toolbar = () => {
|
||||
|
||||
export default Toolbar;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user