Commit 853f4e4d authored by GuanHua's avatar GuanHua

fix: 创建店铺上传文件问题

parent ee60296b
...@@ -49,18 +49,16 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -49,18 +49,16 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => {
const PDFList = ['application/pdf'] const PDFList = ['application/pdf']
const isPDF = PDFList.includes(file.type) const isPDF = PDFList.includes(file.type)
if (!isLt50M) { if (!isLt50M) {
setFileLoading(false);
message.error('上传文件大小不超过 50M!'); message.error('上传文件大小不超过 50M!');
} }
if (!isPDF) { if (!isPDF) {
setFileLoading(false);
message.error('请上传pdf格式文件'); message.error('请上传pdf格式文件');
} }
return isLt50M && isPDF; return isLt50M && isPDF;
} }
const handleChange = ({ file }) => { const handleChange = ({ file }) => {
setFileLoading(true);
if (file.response) { if (file.response) {
setFileLoading(true);
if (file.response.code !== 1000) { if (file.response.code !== 1000) {
setFileLoading(false); setFileLoading(false);
return return
...@@ -70,6 +68,8 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -70,6 +68,8 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => {
albumName: file.name, albumName: file.name,
albumUrl: file.response.data, albumUrl: file.response.data,
}) })
} else {
setFileLoading(false);
} }
} }
const fileRemove = () => { const fileRemove = () => {
......
...@@ -49,18 +49,16 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -49,18 +49,16 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => {
const PDFList = ['application/pdf'] const PDFList = ['application/pdf']
const isPDF = PDFList.includes(file.type) const isPDF = PDFList.includes(file.type)
if (!isLt50M) { if (!isLt50M) {
setFileLoading(false);
message.error('上传文件大小不超过 50M!'); message.error('上传文件大小不超过 50M!');
} }
if (!isPDF) { if (!isPDF) {
setFileLoading(false);
message.error('请上传pdf格式文件'); message.error('请上传pdf格式文件');
} }
return isLt50M && isPDF; return isLt50M && isPDF;
} }
const handleChange = ({ file }) => { const handleChange = ({ file }) => {
setFileLoading(true);
if (file.response) { if (file.response) {
setFileLoading(true);
if (file.response.code !== 1000) { if (file.response.code !== 1000) {
setFileLoading(false); setFileLoading(false);
return return
...@@ -70,6 +68,8 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -70,6 +68,8 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => {
albumName: file.name, albumName: file.name,
albumUrl: file.response.data, albumUrl: file.response.data,
}) })
} else {
setFileLoading(false);
} }
} }
const fileRemove = () => { const fileRemove = () => {
...@@ -433,7 +433,7 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -433,7 +433,7 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => {
action="/api/file/file/upload" action="/api/file/file/upload"
data={{ fileType: UPLOAD_TYPE }} data={{ fileType: UPLOAD_TYPE }}
showUploadList={false} showUploadList={false}
accept='.pdf' // accept='.pdf'
beforeUpload={beforeDocUpload} beforeUpload={beforeDocUpload}
onChange={handleChange} onChange={handleChange}
> >
......
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