Commit ff46bff4 authored by cellee's avatar cellee

Signed-off-by: cellee <893264950@qq.com>

parent af1211bb
...@@ -86,15 +86,15 @@ export default { ...@@ -86,15 +86,15 @@ export default {
changeOrigin: true, changeOrigin: true,
pathRewrite: { '^': '' }, pathRewrite: { '^': '' },
}, },
'/tos/': {
target: 'http://47.74.233.180:8651',
changeOrigin: true,
pathRewrite: { '^': '' },
},
// '/tos/': { // '/tos/': {
// target: 'http://192.168.1.28:8651', // target: 'http://47.74.233.180:8651',
// changeOrigin: true, // changeOrigin: true,
// pathRewrite: { '^': '' }, // pathRewrite: { '^': '' },
// }, // },
'/tos/': {
target: 'http://192.168.1.28:8651',
changeOrigin: true,
pathRewrite: { '^': '' },
},
}, },
}; };
/* /*
* @Author: your name * @Author: your name
* @Date: 2021-02-01 14:54:48 * @Date: 2021-02-01 14:54:48
* @LastEditTime: 2021-02-06 11:51:58 * @LastEditTime: 2021-02-18 13:54:59
* @LastEditors: Please set LastEditors * @LastEditors: Please set LastEditors
* @Description: In User Settings Edit * @Description: In User Settings Edit
* @FilePath: \tostumi\src\components\Form\PdfUpload.tsx * @FilePath: \tostumi\src\components\Form\PdfUpload.tsx
*/ */
import React, { useState } from 'react'; import React, { useState } from 'react';
import { Input, Upload, message, Button, Spin } from 'antd'; import { Input, Upload, message, Button, Spin } from 'antd';
import { LoadingOutlined, PlusOutlined, MinusCircleOutlined } from '@ant-design/icons'; import {
LoadingOutlined,
PlusOutlined,
MinusCircleOutlined,
FilePdfOutlined,
} from '@ant-design/icons';
interface PriceInputProps { interface PriceInputProps {
value?: any; value?: any;
...@@ -19,8 +24,12 @@ interface PriceInputProps { ...@@ -19,8 +24,12 @@ interface PriceInputProps {
} }
const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled, action, data }) => { const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled, action, data }) => {
const [loading, setLoading] = useState([false, false, false, false, false]); const [loading, setLoading] = useState([false, false, false, false, false]); // 上传中控制
const [imgList, setImgList] = useState([] as any); const [idx, setIdx] = useState(0); // 点击的第几个
const [imgList, setImgList] = useState([] as any); // 列表
const [PdfUrl, setPdfUrl] = useState(null); //地址
const [ModalVisible, setModalVisible] = useState(false); //显示隐藏
// 上传前检测 // 上传前检测
function beforeUpload(file: any) { function beforeUpload(file: any) {
...@@ -38,22 +47,26 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled, ...@@ -38,22 +47,26 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
// 上传成功怎么做 // 上传成功怎么做
const handleChange = (info: any) => { const handleChange = (info: any) => {
console.log(info); console.log(info);
console.log(info.event);
let { status, response } = info.file; let { status, response } = info.file;
if (status === 'uploading') { if (status === 'uploading') {
// setLoading(); // setLoading();
return; let v = loading;
v[idx] = true;
setLoading([...v]);
} else { } else {
// setLoading(false); let v = loading;
v[idx] = false;
setLoading([...v]);
} }
if (status === 'done') { if (status === 'done') {
let { fileName, key } = response.data; console.log('上传成功');
let { fileName, key, fileUrl } = response.data;
let list = JSON.parse(JSON.stringify(imgList)); let list = JSON.parse(JSON.stringify(imgList));
let obj = { let obj = {
uid: Math.floor(Math.random() * 100), uid: Math.floor(Math.random() * 100),
name: fileName, name: fileName,
status: 'done', status: 'done',
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png', url: fileUrl,
}; };
if (!list[parseInt(key)]) { if (!list[parseInt(key)]) {
// 先判断这个是不是在上传途中被删除掉了 // 先判断这个是不是在上传途中被删除掉了
...@@ -74,7 +87,7 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled, ...@@ -74,7 +87,7 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
id: Math.floor(Math.random() * 100), id: Math.floor(Math.random() * 100),
name: '', name: '',
fileList: [], fileList: [],
tip: true, tip: false,
loading: false, loading: false,
message: '123', message: '123',
}; };
...@@ -97,13 +110,17 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled, ...@@ -97,13 +110,17 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
// 点击预览 // 点击预览
const handlePreview = async (file: any) => { const handlePreview = async (file: any) => {
if (!file.url && !file.preview) { setPdfUrl(file);
// file.preview = await getBase64(file.originFileObj); setModalVisible(true);
} };
console.log(file);
// setpreviewImage(file.url || file.preview); // 点击上传记录index
// setpreviewTitle(file.name); const opens = (i: any) => {
// setpreviewVisible(true); setIdx(i);
};
const icons = () => {
return <FilePdfOutlined />;
}; };
return ( return (
...@@ -124,15 +141,16 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled, ...@@ -124,15 +141,16 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
name="file" name="file"
listType="picture-card" listType="picture-card"
fileList={item.fileList} fileList={item.fileList}
// showUploadList={false}
onPreview={handlePreview} // 预览 onPreview={handlePreview} // 预览
beforeUpload={beforeUpload} beforeUpload={beforeUpload} //上传前检测
onChange={handleChange} onChange={handleChange}
id={index} id={index}
iconRender={icons}
> >
{item.fileList && item.fileList.length >= 5 ? null : ( {item.fileList && item.fileList.length >= 5 ? null : (
<div> <div onClick={() => opens(index)}>
{loading[index] ? <LoadingOutlined /> : <PlusOutlined />} {loading[index] ? <LoadingOutlined /> : <PlusOutlined />}
{/* <PlusOutlined></PlusOutlined> */}
<div style={{ marginTop: 8 }}>Upload</div> <div style={{ marginTop: 8 }}>Upload</div>
</div> </div>
)} )}
...@@ -161,6 +179,8 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled, ...@@ -161,6 +179,8 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
) : ( ) : (
'' ''
)} )}
{/* 弹出层 */}
</> </>
); );
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment