Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
myhr-portal
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
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
angular
myhr-portal
Commits
43bce44b
Commit
43bce44b
authored
7 months ago
by
Nakarin Luankla
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UPDATE ส่ง type file
parent
41b485e9
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
3 deletions
+8
-3
list-excell.component.html
src/app/apps/list-excell/list-excell.component.html
+1
-1
list-excell.component.ts
src/app/apps/list-excell/list-excell.component.ts
+4
-2
excel.model.ts
src/app/model/excel.model.ts
+3
-0
No files found.
src/app/apps/list-excell/list-excell.component.html
View file @
43bce44b
...
...
@@ -133,7 +133,7 @@
<label
for=
"name"
class=
"col-sm-4 col-form-label"
>
ไฟล์อัพโหลด
</label>
<div
class=
"{{!modelExcel.excelObj||!checkEdit ? 'col-sm-8' : 'col-sm-6'}}"
>
<input
type=
"file"
class=
"form-control"
(
change
)="
onSelectFile
($
event
)"
>
<div
class=
"msg-detail"
>
ไฟล์ที่อนุญาต:*.xlsx
</div>
<div
class=
"msg-detail"
>
ไฟล์ที่อนุญาต:*.xlsx
*.xlsm
</div>
</div>
<div
class=
"col-auto"
*
ngIf=
"modelExcel.excelObj&&checkEdit"
>
<button
class=
"btn btn-primary"
(
click
)="
downloadFile
(
modelExcel
.
logId
)"
><i
class=
"fas fa-download"
></i></button>
...
...
This diff is collapsed.
Click to expand it.
src/app/apps/list-excell/list-excell.component.ts
View file @
43bce44b
...
...
@@ -74,15 +74,17 @@ export class ListExcelComponent implements OnInit {
if
(
event
.
target
.
files
&&
event
.
target
.
files
[
0
])
{
const
reader
=
new
FileReader
();
const
file
:
File
=
event
.
target
.
files
[
0
];
console
.
log
(
"🚀 ~ ListExcelComponent ~ onSelectFile ~ file:"
,
file
.
type
)
reader
.
readAsDataURL
(
event
.
target
.
files
[
0
]);
// read file as data url
reader
.
onload
=
(
event
)
=>
{
// called once readAsDataURL is completed
if
(
event
){
const
allowedTypes
=
[
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
];
const
allowedTypes
=
[
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
,
'application/vnd.ms-excel.sheet.macroEnabled.12'
];
if
(
!
allowedTypes
.
includes
(
file
.
type
))
{
this
.
openAlertModal
(
'อัพโหลดได้เฉพาะไฟล์ *.xlsx เท่านั้น'
)
this
.
openAlertModal
(
'อัพโหลดได้เฉพาะไฟล์ *.xlsx
*.xlsm
เท่านั้น'
)
}
else
{
let
base64
=
event
.
target
!
.
result
as
string
this
.
modelExcel
.
excelObj
=
base64
.
split
(
','
)[
1
];
this
.
modelExcel
.
fileType
=
file
.
type
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/app/model/excel.model.ts
View file @
43bce44b
...
...
@@ -24,6 +24,7 @@ export interface ExcelModel {
approveTime
:
string
tags
:
TagModel
[]
group
:
GroupModel
fileType
:
string
}
export
class
ExcelModel
implements
ExcelModel
{
...
...
@@ -48,6 +49,7 @@ export class ExcelModel implements ExcelModel {
approveTime
:
string
tags
:
TagModel
[]
group
:
GroupModel
fileType
:
string
constructor
(
data
:
Partial
<
any
>
)
{
this
.
logId
=
data
.
logId
?
data
.
logId
:
''
this
.
thumbnail
=
data
.
thumbnail
?
data
.
thumbnail
:
''
...
...
@@ -70,6 +72,7 @@ export class ExcelModel implements ExcelModel {
this
.
approveDate
=
data
.
approveDate
?
data
.
approveDate
:
''
this
.
approveTime
=
data
.
approveTime
?
data
.
approveTime
:
''
this
.
group
=
data
.
group
?
new
GroupModel
(
data
.
group
):
new
GroupModel
({})
this
.
fileType
=
data
.
fileType
?
data
.
fileType
:
''
}
getImage
(){
if
(
this
.
thumbnail
){
...
...
This diff is collapsed.
Click to expand it.
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