Explorar o código

Squashed commit of the following:
merge
commit 67c1c249be25266e723c85d0528c4a763faa9cd7
Author: Renxy <18510891294@163.com>
Date: Thu Dec 14 14:49:14 2023 +0800

修改路由

commit 15967b6a4cf9296166be9d7db40292a111b1b18d
Author: Renxy <18510891294@163.com>
Date: Thu Dec 14 14:25:48 2023 +0800

修改域名

commit ba0dd0d66eea0b451a292c64480cfa31ef2c2fa5
Author: Renxy <18510891294@163.com>
Date: Thu Dec 14 09:22:21 2023 +0800

Squashed commit of the following:
cad
commit 8957b0fefd2d65de8b96e307bb7f8826fa9bef0a
Author: Renxy <18510891294@163.com>
Date: Wed Dec 13 09:58:52 2023 +0800

上传图纸添加path字段

commit 7ee0e51cbd578e252205b76f30dc99a08bd1b3d2
Author: Renxy <18510891294@163.com>
Date: Tue Dec 12 17:34:30 2023 +0800

修改bug

commit 44539389d68a26a8e5484d403694d8d1ccd30093
Author: Renxy <18510891294@163.com>
Date: Tue Dec 12 17:02:44 2023 +0800

修改bug

commit b4798de286df4e15cd179483a1595282e48b468f
Author: Renxy <18510891294@163.com>
Date: Tue Dec 12 16:36:31 2023 +0800

修改cadbug

commit 4851121dc2c2ccf4d409c19ec46ec768e6494a67
Author: Renxy <18510891294@163.com>
Date: Tue Dec 12 14:13:24 2023 +0800

创建子审批

commit b8e82187be7101126ec928b3c5fb6579faa8ee5e
Author: Renxy <18510891294@163.com>
Date: Mon Dec 11 17:16:32 2023 +0800

update

commit 7ac00c0961f3fe94597ce02eb58334ec227d0ecc
Merge: b2ba74b 879f068
Author: Renxy <18510891294@163.com>
Date: Mon Dec 11 16:17:58 2023 +0800

Merge branch 'cad' into develop
解决冲突
# Conflicts:
# src/pages/Home/index.js

commit 879f068f14d5e4fa58cb677a86a7b27021247882
Author: Renxy <18510891294@163.com>
Date: Mon Dec 11 16:15:05 2023 +0800

修改cad修改antd前缀

commit a63c9413d969e359e621ff32ccb5246b0e574416
Author: Renxy <18510891294@163.com>
Date: Thu Dec 7 17:48:01 2023 +0800

cad审批

# Conflicts:
# src/pages/Cad/components/CreateChildrenModal.js
# src/pages/Cad/components/CreateModal.js

Renxy hai 1 ano
pai
achega
b633368b14

+ 22 - 20
src/pages/Cad/components/CreateChildrenModal.js

@@ -1,6 +1,7 @@
 import { CloudUploadOutlined } from '@ant-design/icons';
-import { Modal, Form, Input, Button } from 'antd';
+import { Modal, Form, Input, Button, Upload } from 'antd';
 import { useEffect, useState } from 'react';
+import { getRandomString } from '@/utils/utils';
 
 const CreateChildrenModal = ({
   loading,
@@ -15,9 +16,11 @@ const CreateChildrenModal = ({
     wrapperCol: { span: 16 },
   };
   const [upLoading, setUpLoading] = useState([]);
+  const [cadPath, setCadPath] = useState([]);
 
   useEffect(() => {
     if (!open) return;
+    setCadPath([]);
     form.resetFields();
   }, [open]);
 
@@ -42,11 +45,24 @@ const CreateChildrenModal = ({
       });
     }
   }
+  const UploadProps = {
+    action: `https://cad.greentech.com.cn/sdk/doc/upload`,
+    multiple: true,
+    data: { path: getRandomString() },
+    headers: {
+      'JWT-TOKEN': localStorage.getItem('JWT-TOKEN'),
+    },
+    onChange({ file, fileList }) {
+      if (file.status !== 'uploading') {
+        setCadPath([...cadPath, file.response.data.path]);
+      }
+    },
+  };
 
   const handleOk = () => {
     form.validateFields().then((values) => {
-      if (!values.cad_path) values.cad_path = 'test';
       values.parent_id = parentId;
+      if (!values.cad_path) values.cad_path = cadPath.join(',');
       console.log(values);
       onOk(values);
     });
@@ -65,29 +81,15 @@ const CreateChildrenModal = ({
         <Form.Item name="version" label="版本:" rules={[{ required: true }]}>
           <Input />
         </Form.Item>
-        <Form.Item name="cad_path" label="上传:">
-          <Button
-            loading={upLoading}
-            icon={<CloudUploadOutlined />}
-            onClick={dwgUpload}
-          >
-            上传
-          </Button>
-          {form.getFieldValue('cad_path')}
+        <Form.Item label="上传:">
+          <Upload {...UploadProps}>
+            <Button icon={<CloudUploadOutlined />}>Upload</Button>
+          </Upload>
         </Form.Item>
         <Form.Item name="remark" label="备注:">
           <Input.TextArea />
         </Form.Item>
       </Form>
-
-      <input
-        // multiple
-        style={{ display: 'none' }}
-        id="uploadDwg"
-        type="file"
-        onChange={uploadDwg}
-        accept=".dwg, .dxf"
-      />
     </Modal>
   );
 };

+ 23 - 39
src/pages/Cad/components/CreateModal.js

@@ -60,6 +60,7 @@ const CreateModal = ({
   useEffect(() => {
     if (!open) return;
     form.resetFields();
+    setCadPath([]);
     setApprovalProcess([]);
     userListRun();
     const params = { ...advance };
@@ -84,30 +85,29 @@ const CreateModal = ({
     },
   );
 
-  function dwgUpload() {
-    let uploadDwg = document.getElementById('uploadDwg');
-    uploadDwg.click();
-  }
+  // function dwgUpload() {
+  //   let uploadDwg = document.getElementById('uploadDwg');
+  //   uploadDwg.click();
+  // }
 
-  function uploadDwg(event) {
-    const selectedFile = event.target.files[0];
-    if (selectedFile) {
-      // ZwCloud2D.ZwEditor.ZwSetLoadingState(true);
-      setUpLoading(true);
-      ZwCloud2D.ZwDataProcessor.uploadDwg(selectedFile).then((res) => {
-        if (res.code == 200) {
-          const oldPath = form.getFieldValue('cad_path');
-          const cad_path = oldPath
-            ? oldPath + ',' + res.data.path
-            : res.data.path;
-          form.setFieldsValue({ cad_path });
-        }
-        setUpLoading(false);
-      });
-    }
-  }
+  // function uploadDwg(event) {
+  //   const selectedFile = event.target.files[0];
+  //   if (selectedFile) {
+  //     setUpLoading(true);
+  //     ZwCloud2D.ZwDataProcessor.uploadDwg(selectedFile).then((res) => {
+  //       if (res.code == 200) {
+  //         const oldPath = form.getFieldValue('cad_path');
+  //         const cad_path = oldPath
+  //           ? oldPath + ',' + res.data.path
+  //           : res.data.path;
+  //         form.setFieldsValue({ cad_path });
+  //       }
+  //       setUpLoading(false);
+  //     });
+  //   }
+  // }
   const UploadProps = {
-    action: `http://47.111.24.13:5121/sdk/doc/upload`,
+    action: `https://cad.greentech.com.cn/sdk/doc/upload`,
     multiple: true,
     data: { path: getRandomString() },
     headers: {
@@ -211,17 +211,10 @@ const CreateModal = ({
               <Input />
             </Form.Item>
             <Form.Item label="上传:">
-              {/* <Button
-                loading={upLoading}
-                icon={<CloudUploadOutlined />}
-                onClick={dwgUpload}
-              >
-                上传
-              </Button> */}
               <Upload {...UploadProps}>
                 <Button icon={<CloudUploadOutlined />}>Upload</Button>
               </Upload>
-              {form.getFieldValue('cad_path')}
+              {/* {form.getFieldValue('cad_path')} */}
             </Form.Item>
             <Form.Item name="remark" label="备注:">
               <Input.TextArea />
@@ -236,15 +229,6 @@ const CreateModal = ({
           />
         </Col>
       </Row>
-
-      {/* <input
-        // multiple
-        style={{ display: 'none' }}
-        id="uploadDwg"
-        type="file"
-        onChange={uploadDwg}
-        accept=".dwg, .dxf"
-      /> */}
     </Modal>
   );
 };