Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
myjob-manage
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
myjob-manage
Commits
ea4c9182
Commit
ea4c9182
authored
Jul 04, 2025
by
DESKTOP-E3GSHH7\myhr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
เเก้ createdate lastdate
parent
36eb5823
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
14 deletions
+82
-14
article-manage.component.html
...p/DPU/common/article-manage/article-manage.component.html
+4
-4
article-manage.component.ts
...app/DPU/common/article-manage/article-manage.component.ts
+78
-10
No files found.
src/app/DPU/common/article-manage/article-manage.component.html
View file @
ea4c9182
...
@@ -92,13 +92,13 @@
...
@@ -92,13 +92,13 @@
<td>
<td>
<span
class=
"badge bg-info/10 text-primary"
>
<span
class=
"badge bg-info/10 text-primary"
>
<i
class=
"bi bi-clock me-1"
></i>
<i
class=
"bi bi-clock me-1"
></i>
{{item.createdDate | date : '
mediu
m'}}
{{item.createdDate | date : '
dd/MM/yyyy HH:m
m'}}
</span>
</span>
</td>
</td>
<td>
<td>
<span
class=
"badge bg-info/10 text-primary"
>
<span
class=
"badge bg-info/10 text-primary"
>
<i
class=
"bi bi-clock me-1"
></i>
<i
class=
"bi bi-clock me-1"
></i>
{{item.lastModifiedDate | date : '
mediu
m'}}
{{item.lastModifiedDate | date : '
dd/MM/yyyy HH:m
m'}}
</span>
</span>
</td>
</td>
<td>
<td>
...
@@ -241,7 +241,7 @@
...
@@ -241,7 +241,7 @@
<div
class=
"xl:col-span-6 col-span-12"
>
<div
class=
"xl:col-span-6 col-span-12"
>
<label
for=
"createdDate"
class=
"mt-4 font-bold font-14 text-primary"
>
{{'วันที่สร้าง' | translate}}
</label>
<label
for=
"createdDate"
class=
"mt-4 font-bold font-14 text-primary"
>
{{'วันที่สร้าง' | translate}}
</label>
<input
type=
"datetime-local"
class=
"form-control"
id=
"createdDate"
placeholder=
""
<input
type=
"datetime-local"
class=
"form-control"
id=
"createdDate"
placeholder=
""
[(
ngModel
)]="
selectModel
.
createdDate
"
>
[(
ngModel
)]="
selectModel
.
createdDate
"
(
ngModelChange
)="
updateMinDate
()"
>
<div
class=
"text-danger"
*
ngIf=
"!selectModel.createdDate"
>
<div
class=
"text-danger"
*
ngIf=
"!selectModel.createdDate"
>
{{'Please fill in information' | translate}}
{{'Please fill in information' | translate}}
</div>
</div>
...
@@ -251,7 +251,7 @@
...
@@ -251,7 +251,7 @@
<label
for=
"lastModifiedDate"
class=
"mt-4 font-bold font-14 text-primary"
>
{{'วันที่เเก้ไขล่าสุด' |
<label
for=
"lastModifiedDate"
class=
"mt-4 font-bold font-14 text-primary"
>
{{'วันที่เเก้ไขล่าสุด' |
translate}}
</label>
translate}}
</label>
<input
type=
"datetime-local"
class=
"form-control"
id=
"lastModifiedDate"
placeholder=
""
<input
type=
"datetime-local"
class=
"form-control"
id=
"lastModifiedDate"
placeholder=
""
[(
ngModel
)]="
selectModel
.
lastModifiedDate
"
>
[(
ngModel
)]="
selectModel
.
lastModifiedDate
"
[
min
]="
selectModel
.
createdDate
"
>
<div
class=
"text-danger"
*
ngIf=
"!selectModel.lastModifiedDate"
>
<div
class=
"text-danger"
*
ngIf=
"!selectModel.lastModifiedDate"
>
{{'Please fill in information' | translate}}
{{'Please fill in information' | translate}}
</div>
</div>
...
...
src/app/DPU/common/article-manage/article-manage.component.ts
View file @
ea4c9182
...
@@ -96,7 +96,7 @@ export class ArticleManageComponent {
...
@@ -96,7 +96,7 @@ export class ArticleManageComponent {
_searchTerm
=
""
;
_searchTerm
=
""
;
constructor
(
private
articleService
:
ArticleService
,
public
translate
:
TranslateService
,
private
tokenService
:
TokenService
,
private
router
:
Router
,
private
dialog
:
MatDialog
,)
{
constructor
(
private
articleService
:
ArticleService
,
public
translate
:
TranslateService
,
private
tokenService
:
TokenService
,
private
router
:
Router
,
private
dialog
:
MatDialog
,)
{
this
.
uploadConfig
();
this
.
uploadConfig
();
}
}
...
@@ -146,7 +146,7 @@ export class ArticleManageComponent {
...
@@ -146,7 +146,7 @@ export class ArticleManageComponent {
console
.
log
(
"res"
,
res
);
console
.
log
(
"res"
,
res
);
this
.
selectModel
.
picture
=
res
.
resultObject
;
this
.
selectModel
.
picture
=
res
.
resultObject
;
swal
(
res
.
message
,
"บันทึกสำเร็จ"
,
"success"
);
swal
(
res
.
message
,
"บันทึกสำเร็จ"
,
"success"
);
console
.
log
(
'After Upload, selectModel is:'
,
this
.
selectModel
);
console
.
log
(
'After Upload, selectModel is:'
,
this
.
selectModel
);
}
else
{
}
else
{
this
.
uploadErrorMsg
=
"cannot upload file."
;
this
.
uploadErrorMsg
=
"cannot upload file."
;
swal
(
"Opp!!"
,
"ไม่สามารถอัพโหลดได้"
,
"info"
);
swal
(
"Opp!!"
,
"ไม่สามารถอัพโหลดได้"
,
"info"
);
...
@@ -154,16 +154,38 @@ export class ArticleManageComponent {
...
@@ -154,16 +154,38 @@ export class ArticleManageComponent {
};
};
}
}
// getArticle() {
// this.articleService.getList().subscribe({
// next: (response: ArticleModel[]) => {
// this.itemsList = response.map((x: any) => new ArticleModel(x, this.translate));
// console.log('ข้อมูลบริษัท (itemsList)', this.itemsList);
// this.updatePagedItems();
// },
// error: (error) => {
// console.error('error cant get company', error);
// swal("ข้อผิดพลาด", "ไม่สามารถดึงข้อมูลบริษัทได้", "error");
// }
// });
// }
getArticle
()
{
getArticle
()
{
this
.
articleService
.
getList
().
subscribe
({
this
.
articleService
.
getList
().
subscribe
({
next
:
(
response
:
ArticleModel
[])
=>
{
next
:
(
response
:
ArticleModel
[])
=>
{
this
.
itemsList
=
response
.
map
((
x
:
any
)
=>
new
ArticleModel
(
x
,
this
.
translate
));
this
.
itemsList
=
response
.
map
((
x
:
any
)
=>
{
console
.
log
(
'ข้อมูลบริษัท (itemsList)'
,
this
.
itemsList
);
const
article
=
new
ArticleModel
(
x
,
this
.
translate
);
if
(
x
.
createdDate
)
{
article
.
createdDate
=
this
.
formatDateToISOString
(
new
Date
(
x
.
createdDate
));
}
if
(
x
.
lastModifiedDate
)
{
article
.
lastModifiedDate
=
this
.
formatDateToISOString
(
new
Date
(
x
.
lastModifiedDate
));
}
return
article
;
});
console
.
log
(
'ข้อมูลบทความ (itemsList)'
,
this
.
itemsList
);
this
.
updatePagedItems
();
this
.
updatePagedItems
();
},
},
error
:
(
error
)
=>
{
error
:
(
error
)
=>
{
console
.
error
(
'error cant get
company
'
,
error
);
console
.
error
(
'error cant get
article
'
,
error
);
swal
(
"ข้อผิดพลาด"
,
"ไม่สามารถดึงข้อมูลบ
ริษัท
ได้"
,
"error"
);
swal
(
"ข้อผิดพลาด"
,
"ไม่สามารถดึงข้อมูลบ
ทความ
ได้"
,
"error"
);
}
}
});
});
}
}
...
@@ -171,6 +193,7 @@ export class ArticleManageComponent {
...
@@ -171,6 +193,7 @@ export class ArticleManageComponent {
ngOnInit
():
void
{
ngOnInit
():
void
{
this
.
getArticle
();
this
.
getArticle
();
this
.
itemsList
this
.
itemsList
this
.
updateMinDate
();
}
}
filter
(
v
:
string
)
{
filter
(
v
:
string
)
{
...
@@ -217,15 +240,37 @@ export class ArticleManageComponent {
...
@@ -217,15 +240,37 @@ export class ArticleManageComponent {
this
.
selectModel
.
content
=
""
;
this
.
selectModel
.
content
=
""
;
this
.
selectModel
.
author
=
""
;
this
.
selectModel
.
author
=
""
;
this
.
selectModel
.
createdDate
=
new
Date
().
toISOString
();
this
.
selectModel
.
createdDate
=
new
Date
().
toISOString
();
const
now
=
new
Date
();
this
.
selectModel
.
createdDate
=
this
.
formatDateToISOString
(
now
);
this
.
selectModel
.
lastModifiedDate
=
this
.
formatDateToISOString
(
now
);
}
}
view
(
item
:
ArticleModel
)
{
view
(
item
:
ArticleModel
)
{
this
.
action
=
'edit'
;
this
.
action
=
'edit'
;
this
.
selectModel
=
new
ArticleModel
(
item
);
this
.
selectModel
=
new
ArticleModel
(
item
);
console
.
log
(
this
.
selectModel
);
console
.
log
(
this
.
selectModel
);
if
(
this
.
selectModel
.
createdDate
)
{
const
createdDateObj
=
new
Date
(
this
.
selectModel
.
createdDate
);
this
.
selectModel
.
createdDate
=
this
.
formatDateToISOString
(
createdDateObj
);
}
if
(
this
.
selectModel
.
lastModifiedDate
)
{
const
lastModifiedDateObj
=
new
Date
(
this
.
selectModel
.
lastModifiedDate
);
this
.
selectModel
.
lastModifiedDate
=
this
.
formatDateToISOString
(
lastModifiedDateObj
);
}
else
{
if
(
this
.
selectModel
.
createdDate
)
{
this
.
selectModel
.
lastModifiedDate
=
this
.
selectModel
.
createdDate
;
}
}
}
}
viewArticleDetail
(
articleId
:
string
)
{
this
.
router
.
navigate
([
'/admin/sub-articles'
,
articleId
]);
private
formatDatesForDatetimeLocal
(
articleModel
:
ArticleModel
):
void
{
if
(
articleModel
.
createdDate
)
{
articleModel
.
createdDate
=
articleModel
.
createdDate
.
substring
(
0
,
16
);
}
if
(
articleModel
.
lastModifiedDate
)
{
articleModel
.
lastModifiedDate
=
articleModel
.
lastModifiedDate
.
substring
(
0
,
16
);
}
}
}
save
()
{
save
()
{
...
@@ -244,6 +289,7 @@ export class ArticleManageComponent {
...
@@ -244,6 +289,7 @@ export class ArticleManageComponent {
swal
(
"บันทึกสำเร็จ!!"
,
"บันทึกข้อมูลสมาชิก"
,
"success"
);
swal
(
"บันทึกสำเร็จ!!"
,
"บันทึกข้อมูลสมาชิก"
,
"success"
);
this
.
ngOnInit
();
this
.
ngOnInit
();
this
.
childModal
?.
nativeElement
.
click
();
this
.
childModal
?.
nativeElement
.
click
();
this
.
updateMinDate
();
this
.
closeDialog
();
this
.
closeDialog
();
},
error
=>
{
},
error
=>
{
console
.
error
(
"เกิดข้อผิดพลาดในการบันทึก/อัปเดต:"
,
error
);
console
.
error
(
"เกิดข้อผิดพลาดในการบันทึก/อัปเดต:"
,
error
);
...
@@ -398,4 +444,27 @@ export class ArticleManageComponent {
...
@@ -398,4 +444,27 @@ export class ArticleManageComponent {
this
.
profileChangeInputRef
.
nativeElement
.
click
();
this
.
profileChangeInputRef
.
nativeElement
.
click
();
}
}
}
}
}
private
formatDateToISOString
(
date
:
Date
):
string
{
\ No newline at end of file
const
year
=
date
.
getFullYear
();
const
month
=
(
date
.
getMonth
()
+
1
).
toString
().
padStart
(
2
,
'0'
);
const
day
=
date
.
getDate
().
toString
().
padStart
(
2
,
'0'
);
const
hours
=
date
.
getHours
().
toString
().
padStart
(
2
,
'0'
);
const
minutes
=
date
.
getMinutes
().
toString
().
padStart
(
2
,
'0'
);
return
`
${
year
}
-
${
month
}
-
${
day
}
T
${
hours
}
:
${
minutes
}
`
;
}
updateMinDate
()
{
if
(
this
.
selectModel
.
createdDate
)
{
const
created
=
new
Date
(
this
.
selectModel
.
createdDate
);
let
modified
=
this
.
selectModel
.
lastModifiedDate
?
new
Date
(
this
.
selectModel
.
lastModifiedDate
)
:
null
;
if
(
modified
&&
modified
<
created
)
{
// เมื่อมีการปรับค่า ให้แน่ใจว่าถูกจัดรูปแบบเป็น 24 ชั่วโมง
this
.
selectModel
.
lastModifiedDate
=
this
.
formatDateToISOString
(
created
);
}
else
if
(
!
modified
)
{
// เมื่อมีการตั้งค่าเริ่มต้น ให้แน่ใจว่าถูกจัดรูปแบบเป็น 24 ชั่วโมง
this
.
selectModel
.
lastModifiedDate
=
this
.
formatDateToISOString
(
created
);
}
}
}
}
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