Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shenshaokai
jinfa-platform
Commits
ad050307
Commit
ad050307
authored
May 28, 2021
by
前端-黄佳鑫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🐞
fix: 更改导入物料
parent
288f3e88
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
30 deletions
+46
-30
index.tsx
src/components/UploadImport/index.tsx
+11
-3
index.tsx
src/components/UploadModal/index.tsx
+18
-23
material.tsx
...bility/purchaseInquiry/addInquiry/components/material.tsx
+15
-1
index.ts
src/services/file/index.ts
+2
-3
No files found.
src/components/UploadImport/index.tsx
View file @
ad050307
...
...
@@ -14,7 +14,7 @@ interface UploadImportProps {
/** 检查的接口 */
checkfetch
?:
string
,
/** 导入的接口 */
importfetch
?:
Promise
<
unknown
>
,
importfetch
?:
string
,
/** 完成导入 */
onClose
?:
(
e
)
=>
void
,
/** 成功导入后返回数据 */
...
...
@@ -79,7 +79,7 @@ const UploadImport: React.FC<UploadImportProps> = (props: any) => {
fileList
.
forEach
(
file
=>
{
formData
.
append
(
'file'
,
file
);
});
uploadFileExcel
(
formData
).
then
(
res
=>
{
uploadFileExcel
(
importfetch
,
formData
).
then
(
res
=>
{
if
(
res
.
code
!==
1000
)
{
setStep
(
4
)
return
...
...
@@ -103,7 +103,14 @@ const UploadImport: React.FC<UploadImportProps> = (props: any) => {
</>
const
continueImport
=
()
=>
{
setStep
(
0
)
setExceptionCheck
(
false
)
}
const
handleClose
=
()
=>
{
continueImport
()
onClose
()
}
return
(
<
Modal
title=
{
title
}
...
...
@@ -111,6 +118,7 @@ const UploadImport: React.FC<UploadImportProps> = (props: any) => {
footer=
{
null
}
bodyStyle=
{
{
padding
:
0
,
position
:
'relative'
}
}
visible=
{
visible
}
onCancel=
{
onClose
}
>
{
step
===
0
&&
(
<>
...
...
@@ -173,7 +181,7 @@ const UploadImport: React.FC<UploadImportProps> = (props: any) => {
extra=
{
<>
<
Button
type=
'primary'
onClick=
{
continueImport
}
>
继续导入
</
Button
>
<
Button
onClick=
{
on
Close
}
>
导入完成
</
Button
>
<
Button
onClick=
{
handle
Close
}
>
导入完成
</
Button
>
</>
}
/>
...
...
src/components/UploadModal/index.tsx
View file @
ad050307
...
...
@@ -2,7 +2,6 @@ import React, { useState, useEffect } from 'react';
import
{
Modal
,
Result
,
Progress
,
Upload
,
Button
}
from
'antd'
;
import
{
FileExcelOutlined
}
from
'@ant-design/icons'
;
import
styles
from
'./index.less'
;
import
{
UPLOAD_TYPE
}
from
'@/constants'
import
{
PublicApi
}
from
'@/services/api'
;
interface
Uploader
{
...
...
@@ -20,7 +19,7 @@ const UploadModal: React.FC<Uploader> = props => {
const
[
file
,
setFile
]
=
useState
();
const
[
fileList
,
setFileList
]
=
useState
([]);
const
downLoadTemplate
=
()
=>
{
};
const
downLoadTemplate
=
()
=>
{};
const
step0Description
=
(
<>
...
...
@@ -149,19 +148,14 @@ const UploadModal: React.FC<Uploader> = props => {
const
beforeUpload
=
file
=>
{
let
extension
=
file
.
name
.
split
(
'.'
)[
1
];
if
(
!
[
'xlsx'
,
'xls'
].
includes
(
extension
)
)
{
if
(
[
'xlsx'
,
'xls'
].
includes
[
extension
]
)
{
setTimeout
(()
=>
{
setExceptionCheck
(
true
);
},
250
);
}
const
flag
=
[
'xlsx'
,
'xls'
].
includes
(
extension
)
return
flag
;
return
false
;
};
const
handleChange
=
({
file
})
=>
{
console
.
log
(
file
)
}
// 上传
const
handleUpload
=
(
type
:
string
,
file
?:
any
,
step
:
number
=
0
)
=>
{
let
title
=
''
;
...
...
@@ -184,7 +178,7 @@ const UploadModal: React.FC<Uploader> = props => {
if
(
step
===
1
)
return
false
;
};
const
exportErrorLog
=
()
=>
{
};
const
exportErrorLog
=
()
=>
{};
const
handleClose
=
()
=>
{
setModalStep
(
0
);
...
...
@@ -210,19 +204,20 @@ const UploadModal: React.FC<Uploader> = props => {
icon=
{
<
FileExcelOutlined
/>
}
title=
{
step0Description
}
extra=
{
<
Upload
action=
"/api/purchase/purchase/inquiry/import/excel/check"
showUploadList=
{
false
}
beforeUpload=
{
beforeUpload
}
onChange=
{
handleChange
}
>
<
Button
type=
"primary"
>
导入
</
Button
>
</
Upload
>
// <>
// <Button type="primary" onClick=
{()
=>
handleUpload
(
'upload'
)}
>
// 导入
// </Button>
// </>
// <Upload
// name="file"
// action=""
// fileList=
{
fileList
}
// beforeUpload=
{
file
=>
beforeUpload
(
file
)}
// customRequest=
{
file
=>
console
.
log
(
file
)}
// >
// <Button type="primary">导入</Button>
// </Upload>
<>
<
Button
type=
"primary"
onClick=
{
()
=>
handleUpload
(
'upload'
)
}
>
导入
</
Button
>
</>
}
/>
</>
...
...
src/pages/transaction/purchaseAbility/purchaseInquiry/addInquiry/components/material.tsx
View file @
ad050307
...
...
@@ -122,6 +122,8 @@ const Material: React.FC<Iprops> = (props: any) => {
key
:
'category'
,
dataIndex
:
'category'
,
render
:
(
text
:
any
,
record
:
any
,
index
:
number
)
=>
(
<>
{
materielMode
===
1
&&
(
<
Form
.
Item
style=
{
{
margin
:
0
}
}
name=
{
`category_${index + 1}`
}
...
...
@@ -137,7 +139,18 @@ const Material: React.FC<Iprops> = (props: any) => {
notFoundContent=
{
<
Spin
size=
"small"
/>
}
/>
</
Form
.
Item
>
)
}
{
materielMode
===
2
&&
(
<
Form
.
Item
style=
{
{
margin
:
0
}
}
name=
{
`category_${index + 1}`
}
initialValue=
{
text
}
rules=
{
[{
required
:
true
,
message
:
'请输入'
}]
}
>
<
Input
onChange=
{
(
e
)
=>
handleEdit
(
e
,
'category'
,
index
)
}
/>
</
Form
.
Item
>
)
}
</>
),
},
{
...
...
@@ -304,6 +317,7 @@ const Material: React.FC<Iprops> = (props: any) => {
visible=
{
flag
}
title=
'导入'
checkfetch=
'/api/purchase/purchase/inquiry/import/excel/check'
importfetch=
'/api/purchase/purchase/inquiry/import/excel'
fetchData=
{
fetchData
}
onClose=
{
()
=>
setFlag
(
false
)
}
/>
...
...
src/services/file/index.ts
View file @
ad050307
...
...
@@ -19,9 +19,8 @@ export async function uploadFile(params) {
})
}
export
async
function
uploadFileExcel
(
params
)
{
return
umiRequest
(
'/purchase/inquiry/import/excel'
,
{
prefix
:
'/api/purchase'
,
export
async
function
uploadFileExcel
(
url
,
params
)
{
return
umiRequest
(
url
,
{
method
:
'post'
,
data
:
params
,
requestType
:
'form'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment