Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
smart
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
wangqinghua
smart
Commits
3bc9cf2b
Commit
3bc9cf2b
authored
Dec 16, 2018
by
wangqinghua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commonService
parent
9119ac35
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
0 deletions
+79
-0
upload.component.html
src/main/webapp/app/work/modal/upload/upload.component.html
+18
-0
upload.component.ts
src/main/webapp/app/work/modal/upload/upload.component.ts
+61
-0
No files found.
src/main/webapp/app/work/modal/upload/upload.component.html
0 → 100644
View file @
3bc9cf2b
<!--添加图片-->
<nz-modal
[(
nzVisible
)]="
isVisible
"
nzTitle=
"上传文件"
(
nzOnCancel
)="
handleCancel
()"
(
nzOnOk
)="
handleOk
()"
>
<form
nz-form
>
<nz-form-item>
<nz-form-label
[
nzSpan
]="
7
"
nzRequired
nzFor=
"group"
>
选择文件
</nz-form-label>
<nz-form-control
[
nzSpan
]="
12
"
>
<nz-upload
[
nzBeforeUpload
]="
beforeUpload
"
[(
nzFileList
)]="
fileList
"
>
<button
nz-button
>
<i
class=
"anticon anticon-upload"
></i><span>
上传
</span>
</button>
</nz-upload>
</nz-form-control>
</nz-form-item>
</form>
</nz-modal>
\ No newline at end of file
src/main/webapp/app/work/modal/upload/upload.component.ts
0 → 100644
View file @
3bc9cf2b
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
NzMessageService
,
UploadFile
}
from
'ng-zorro-antd'
;
import
{
WorkService
}
from
'../../work.service'
;
@
Component
({
selector
:
'smart-upload'
,
templateUrl
:
'./upload.component.html'
,
styles
:
[]
})
export
class
UploadComponent
implements
OnInit
{
isVisible
=
false
;
fileList
:
UploadFile
[]
=
[];
constructor
(
private
message
:
NzMessageService
,
private
workSer
:
WorkService
)
{
}
ngOnInit
()
{
}
showModal
(){
this
.
isVisible
=
true
;
}
beforeUpload
=
(
file
:
UploadFile
):
boolean
=>
{
console
.
log
(
file
.
type
);
const
isExcel
=
file
.
type
===
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
;
if
(
!
isExcel
)
{
this
.
message
.
error
(
'请上传excel文件!'
);
}
else
{
this
.
fileList
.
push
(
file
);
}
return
false
;
};
handleCancel
(){
this
.
isVisible
=
false
;
this
.
fileList
=
[];
}
handleOk
(){
if
(
this
.
fileList
.
length
==
0
){
this
.
message
.
warning
(
"请选择文件"
);
return
false
;
}
const
formData
=
new
FormData
();
this
.
fileList
.
forEach
((
file
:
any
)
=>
{
formData
.
append
(
'file'
,
file
);
})
this
.
workSer
.
importInventory
(
formData
).
subscribe
(
(
res
)
=>
{
if
(
res
.
errCode
==
10000
){
this
.
isVisible
=
false
;
this
.
fileList
=
[];
this
.
message
.
success
(
"上传成功"
);
}
else
{
this
.
message
.
error
(
res
.
errMsg
);
}
}
)
}
}
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