From 3c3ac0c2c225f763fffb05ad669d76b50b4f6e45 Mon Sep 17 00:00:00 2001
From: zhangyongtian <1181606322@qq.com>
Date: Fri, 06 Sep 2024 16:17:04 +0800
Subject: [PATCH] Merge branch 'master' of http://120.79.193.119:9090/r/gzzfw/frontEnd/gzDyh

---
 gz-customerSystem/src/views/register/matterDetail/FileUpLoad.jsx |   67 +++++++++++++++++++++++++--------
 1 files changed, 51 insertions(+), 16 deletions(-)

diff --git a/gz-customerSystem/src/views/register/matterDetail/FileUpLoad.jsx b/gz-customerSystem/src/views/register/matterDetail/FileUpLoad.jsx
index e68d3ab..ec1a057 100644
--- a/gz-customerSystem/src/views/register/matterDetail/FileUpLoad.jsx
+++ b/gz-customerSystem/src/views/register/matterDetail/FileUpLoad.jsx
@@ -1,11 +1,13 @@
-import React, { useState, useEffect } from 'react';
-import { Typography, Button } from 'antd';
-import { CheckOutlined, } from '@ant-design/icons';
+import React, { useState, useRef } from 'react';
+import { Button } from 'antd';
+import * as $$ from '@/utils/utility';
 import { Form, Input, Modal, Upload } from '@arco-design/web-react';
 import { IconLink } from '@arco-design/web-react/icon';
 
 
 const FormItem = Form.Item;
+const appUrl = $$.appUrl;
+
 
 const DocumentScanner = ({
   visible,
@@ -13,11 +15,12 @@
   onCancel
 
 }) => {
-
+  const formRef = useRef();
   const [scanFile, setScanFile] = useState(false);
   const [scanImage, setScanImage] = useState(false);
   const [scaned, setScaned] = useState(false);
   const [fileView, setFileView] = useState();
+  const [scanContent, setScanContent] = useState('');
 
   const handleUploadChange = (info, currentFile) => {
     if (info.length > 0) {
@@ -27,10 +30,28 @@
       ...currentFile,
       url: URL.createObjectURL(currentFile.originFile),
     });
+    setScanContent(fileView.response.data.ocrResult.wordsResult[0])
+
+
   };
 
+  const handleScaned = () => {
+    setScaned(true)
+    formRef.current.setFieldValue('scanContent', scanContent)
+
+  }
+
+  const handleText = () => {
+    onConfirm(scanContent);
+    setScanFile(false);
+    setScanImage(false);
+    setScaned(false);
+
+  }
 
 
+  console.log(fileView, 'fileView')
+  console.log(scanContent, 'scanContent')
 
   return (
     <>
@@ -51,7 +72,8 @@
               // multiple
               limit={1}
               accept='image/*'
-              // action='/'
+              headers={{ Authorization: $$.getSessionStorage('customerSystemToken') }}
+              action={`${appUrl.fileUrl}/${appUrl.sys}/api/web/fileInfo/recognitionText`}
               onDrop={(e) => {
               }}
               tip='支持png、 jpg、pdf等格式文件上传,每次上传大小不超过10M'
@@ -92,19 +114,32 @@
             objectFit: 'contain',
           }}
         />
-        <div><Button type="primary" onClick={() => setScaned(true)} style={{ marginTop: '20px' }}>开始识别</Button></div>
+        <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>
-        <div style={{  marginBottom: '8px' }}>识别内容</div>
-        <Input.TextArea
-          showWordLimit
-          rows={5}
-          placeholder=''
-          wrapperStyle={{ width: '100%' }}
-          defaultValue='识别内容'
-          onChange={(v) => console.log(v, 'vvvvvv')}
-        />
-        <div style={{ marginTop: '24px' }}><Button type="primary" onClick={() => { onConfirm(); setScanFile(false); setScanImage(false); setScaned(false); }}>使用文字</Button></div>
+        <Form
+          ref={formRef}
+          layout='vertical'
+          requiredSymbol={false}
+          scrollToFirstError={true}
+          initialValues={{
+          }}//默认值
+        >
+          <FormItem
+            label='识别内容'
+            field='scanContent'
+          >
+            <Input.TextArea
+              showWordLimit
+              rows={5}
+              placeholder=''
+              wrapperStyle={{ width: '100%' }}
+              onChange={(v) => console.log(v, 'vvvvvv')}
+            />
+            <div style={{ marginTop: '24px' }}><Button type="primary" onClick={() => { handleText() }}>使用文字</Button></div>
+          </FormItem>
+
+        </Form>
       </Modal>
 
     </>

--
Gitblit v1.8.0