From e978022eaa03c076b18c851a7c0852402e80fd1c Mon Sep 17 00:00:00 2001 From: zhangyongtian <1181606322@qq.com> Date: Fri, 06 Sep 2024 16:38:42 +0800 Subject: [PATCH] feat: 识别文字 --- gz-customerSystem/src/views/register/matterDetail/FileUpLoad.jsx | 56 +++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 45 insertions(+), 11 deletions(-) diff --git a/gz-customerSystem/src/views/register/matterDetail/FileUpLoad.jsx b/gz-customerSystem/src/views/register/matterDetail/FileUpLoad.jsx index 608105b..c23cb69 100644 --- a/gz-customerSystem/src/views/register/matterDetail/FileUpLoad.jsx +++ b/gz-customerSystem/src/views/register/matterDetail/FileUpLoad.jsx @@ -30,21 +30,38 @@ ...currentFile, url: URL.createObjectURL(currentFile.originFile), }); - }; const handleScaned = () => { setScaned(true) - setScanContent(fileView.response.data.ocrResult.wordsResult[0]) + const content = fileView.response.data.ocrResult.wordsResult.join('\n') + + setTimeout(() => { + console.log(formRef.current, content); + formRef.current.setFieldValue('scanContent', content) + }, 0) + setScanContent(content) } - - console.log(fileView, 'fileView') - console.log(scanContent,'scanContent') + const handleText = () => { + onConfirm(scanContent); + setScanFile(false); + setScanImage(false); + setScaned(false); + } return ( <> - <Modal style={{ width: '1200px' }} visible={visible} onCancel={onCancel} title='识别上传材料' centered footer={null}> + <Modal + style={{ width: '1200px' }} + visible={visible} + onCancel={onCancel} + title='识别上传材料' + centered + footer={null} + unmountOnExit={true} + maskClosable={false} + > <Form layout='vertical' requiredSymbol={false} @@ -91,7 +108,16 @@ </Form> </Modal> - <Modal style={{ width: '944px' }} visible={scanImage} onCancel={() => setScanImage(false)} footer={null} title='选择识别范围' centered> + <Modal + style={{ width: '944px' }} + visible={scanImage} + onCancel={() => setScanImage(false)} + footer={null} + title='选择识别范围' + centered + unmountOnExit={true} + maskClosable={false} + > <img src={fileView?.url} alt="" @@ -105,14 +131,23 @@ /> <div><Button type="primary" onClick={() => handleScaned()} style={{ marginTop: '20px' }}>开始识别</Button></div> </Modal> - <Modal style={{ width: '1200px' }} visible={scaned} onCancel={() => setScaned(false)} footer={null} title='识别上传材料' centered> + <Modal + style={{ width: '1200px' }} + visible={scaned} + onCancel={() => setScaned(false)} + footer={null} + title='识别上传材料' + centered + unmountOnExit={true} + maskClosable={false} + mountOnEnter={false} + > <Form ref={formRef} layout='vertical' requiredSymbol={false} scrollToFirstError={true} initialValues={{ - scanContent: scanContent, }}//默认值 > <FormItem @@ -126,9 +161,8 @@ wrapperStyle={{ width: '100%' }} onChange={(v) => console.log(v, 'vvvvvv')} /> - <div style={{ marginTop: '24px' }}><Button type="primary" onClick={() => { onConfirm(); setScanFile(false); setScanImage(false); setScaned(false); }}>使用文字</Button></div> </FormItem> - + <div style={{ marginTop: '24px' }}><Button type="primary" onClick={() => { handleText() }}>使用文字</Button></div> </Form> </Modal> -- Gitblit v1.8.0