|
@@ -1,6 +1,6 @@
|
|
|
'use client';
|
|
|
|
|
|
-import React, { useEffect, useMemo } from 'react'
|
|
|
+import React, { useEffect, useMemo, useState } from 'react'
|
|
|
import Agent from './NodeType/Agent';
|
|
|
import Form from './NodeType/Form';
|
|
|
import Unsupport from './NodeType/Unsupport';
|
|
@@ -8,6 +8,7 @@ import * as R from 'ramda'
|
|
|
import { curNodeAtom, curStepAtom, arrowStateAtom, cardInstantAtomFamily, cardInstantAtomsAtom, instantDataAtom, stepsNodesAtom } from '../store';
|
|
|
import { useAtom, useAtomValue } from 'jotai';
|
|
|
import { exportFlowToDocx } from '../export';
|
|
|
+import PreviewModal from './PreviewModal';
|
|
|
|
|
|
const NodeRender = () => {
|
|
|
const [curStep, setCurStep] = useAtom(curStepAtom)
|
|
@@ -45,12 +46,10 @@ const NodeRender = () => {
|
|
|
setCurStep(prev => prev - 1)
|
|
|
}
|
|
|
|
|
|
- const instantData = useAtomValue(instantDataAtom)
|
|
|
- const stepsNodes = useAtomValue(stepsNodesAtom)
|
|
|
+ const [isPreviewModalOpen, setPreviewModalOpen] = useState(false)
|
|
|
|
|
|
- const onExport = () => {
|
|
|
- const stepsInstantData = stepsNodes.map(node => instantData[node.id])
|
|
|
- exportFlowToDocx(stepsInstantData)
|
|
|
+ const onPreview = () => {
|
|
|
+ setPreviewModalOpen(true)
|
|
|
}
|
|
|
|
|
|
return (
|
|
@@ -65,13 +64,14 @@ const NodeRender = () => {
|
|
|
}
|
|
|
{arrowState.next
|
|
|
? <button className='btn btn-sm' onClick={onNextStep}>下一步</button>
|
|
|
- : <button className='btn btn-sm btn-neutral' onClick={onExport}>导出</button>
|
|
|
+ : <button className='btn btn-sm btn-neutral' onClick={onPreview}>预览</button>
|
|
|
}
|
|
|
</div>
|
|
|
<div className="flex-1 flex flex-col items-stretch overflow-auto">
|
|
|
<Comp key={node?.id} node={node} cardInstantAtom={cardInstantAtom}></Comp>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <PreviewModal open={isPreviewModalOpen} onClose={() => setPreviewModalOpen(false)} />
|
|
|
</div>
|
|
|
)
|
|
|
}
|