|
@@ -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>
|
|
|
);
|
|
|
};
|