import { Steps } from "antd"; import { useEffect, useState } from "react"; import type { ArticleType } from "../article/Article"; import type { IChannel } from "./Channel"; import ChannelPickerTable from "./ChannelPickerTable"; import ChannelSentDiff from "./ChannelSentDiff"; import CopyToResult from "./CopyToResult"; interface IWidget { initStep?: number; channel?: IChannel; type?: ArticleType; articleId?: string; sentencesId?: string[]; important?: boolean; onClose?: () => void; } const CopyToStepWidget = ({ initStep = 0, channel, sentencesId, important = false, onClose, }: IWidget) => { const [current, setCurrent] = useState(0); const [destChannel, setDestChannel] = useState(); const [copyPercent, setCopyPercent] = useState(); const [total, setTotal] = useState(); useEffect(() => { setCurrent(initStep); }, [initStep]); const next = () => { setCurrent(current + 1); }; const prev = () => { setCurrent(current - 1); }; const contentStyle: React.CSSProperties = { borderRadius: 5, border: `1px dashed gray`, marginTop: 16, height: 400, overflowY: "scroll", }; const steps = [ { title: "选择目标版本", key: "channel", content: (
{ console.log("channel", e); if (e.length > 0) { setDestChannel(e[0]); setCopyPercent(100); next(); } }} />
), }, { title: "文本比对", key: "diff", content: ( { prev(); }} onSubmit={(total: number) => { setTotal(total); next(); }} /> ), }, { title: "完成", key: "finish", content: (
{ if (typeof onClose !== "undefined") { onClose(); } }} onInit={() => { setCurrent(0); }} />
), }, ]; const items = steps.map((item) => ({ key: item.key, title: item.title })); return (
{steps[current].content}
); }; export default CopyToStepWidget;