Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
portal-apps-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
portal-apps-manage
Commits
e0c7aed6
Commit
e0c7aed6
authored
Jul 18, 2025
by
DESKTOP-E3GSHH7\myhr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
เอาฟังชั่นที่ไม่ได้ใช้เเล้วออก
parent
2c7f0f5d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
23 deletions
+11
-23
article-manage.component.ts
...app/DPU/common/article-manage/article-manage.component.ts
+11
-23
No files found.
src/app/DPU/common/article-manage/article-manage.component.ts
View file @
e0c7aed6
...
@@ -26,7 +26,6 @@ import { MatDialog, MatDialogModule } from '@angular/material/dialog';
...
@@ -26,7 +26,6 @@ import { MatDialog, MatDialogModule } from '@angular/material/dialog';
TranslateModule
,
TranslateModule
,
NgSelectModule
,
NgSelectModule
,
FormsModule
,
FormsModule
,
MatPaginator
,
RouterModule
,
RouterModule
,
FileUploadModule
,
FileUploadModule
,
QuillModule
,
QuillModule
,
...
@@ -198,7 +197,7 @@ export class ArticleManageComponent {
...
@@ -198,7 +197,7 @@ export class ArticleManageComponent {
x
.
excerpt
?.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
||
x
.
excerpt
?.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
||
x
.
author
?.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
||
x
.
author
?.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
||
x
.
publish
.
toString
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
||
x
.
publish
.
toString
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
||
x
.
endDate
?.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
// เพิ่ม filter สำหรับ endDate ด้วย
x
.
endDate
?.
toLowerCase
().
indexOf
(
v
.
toLowerCase
())
!==
-
1
);
);
}
}
...
@@ -225,24 +224,24 @@ export class ArticleManageComponent {
...
@@ -225,24 +224,24 @@ export class ArticleManageComponent {
new
()
{
new
()
{
this
.
action
=
'add'
;
this
.
action
=
'add'
;
this
.
selectModel
=
new
ArticleModel
();
// Constructor จะตั้งค่าเริ่มต้นให้ properties ต่างๆ
this
.
selectModel
=
new
ArticleModel
();
this
.
selectModel
.
excerpt
=
""
;
this
.
selectModel
.
excerpt
=
""
;
this
.
selectModel
.
picture
=
""
;
this
.
selectModel
.
picture
=
""
;
this
.
selectModel
.
title
=
""
;
this
.
selectModel
.
title
=
""
;
this
.
selectModel
.
articleId
=
""
;
this
.
selectModel
.
articleId
=
""
;
this
.
selectModel
.
content
=
""
;
this
.
selectModel
.
content
=
""
;
this
.
selectModel
.
author
=
""
;
this
.
selectModel
.
author
=
""
;
this
.
selectModel
.
publish
=
0
;
// ตั้งค่าเริ่มต้น publish เป็น 0 (unactive)
this
.
selectModel
.
publish
=
0
;
const
now
=
new
Date
();
const
now
=
new
Date
();
this
.
selectModel
.
createdDate
=
this
.
formatDateToISOString
(
now
);
// ตั้งค่า createdDate เป็นเวลาปัจจุบัน (YYYY-MM-DDTHH:mm)
this
.
selectModel
.
createdDate
=
this
.
formatDateToISOString
(
now
);
this
.
selectModel
.
lastModifiedDate
=
this
.
formatDateToISOString
(
now
);
// ตั้งค่า lastModifiedDate เป็นเวลาปัจจุบัน (YYYY-MM-DDTHH:mm)
this
.
selectModel
.
lastModifiedDate
=
this
.
formatDateToISOString
(
now
);
// ตั้งค่า lastModifiedDate เป็นเวลาปัจจุบัน (YYYY-MM-DDTHH:mm)
this
.
selectModel
.
endDate
=
''
;
// ตั้งค่า endDate เป็น string ว่าง เพื่อให้ Input ว่างเปล่าตอนสร้างใหม่
this
.
selectModel
.
endDate
=
''
;
// ตั้งค่า endDate เป็น string ว่าง เพื่อให้ Input ว่างเปล่าตอนสร้างใหม่
}
}
view
(
item
:
ArticleModel
)
{
view
(
item
:
ArticleModel
)
{
this
.
action
=
'edit'
;
this
.
action
=
'edit'
;
this
.
selectModel
=
new
ArticleModel
(
item
);
// โหลดค่า raw string จาก item
this
.
selectModel
=
new
ArticleModel
(
item
);
console
.
log
(
this
.
selectModel
);
console
.
log
(
this
.
selectModel
);
// แปลง createdDate
// แปลง createdDate
...
@@ -264,17 +263,7 @@ export class ArticleManageComponent {
...
@@ -264,17 +263,7 @@ export class ArticleManageComponent {
const
endDateObj
=
new
Date
(
this
.
selectModel
.
endDate
);
const
endDateObj
=
new
Date
(
this
.
selectModel
.
endDate
);
this
.
selectModel
.
endDate
=
this
.
formatDateToISOString
(
endDateObj
);
this
.
selectModel
.
endDate
=
this
.
formatDateToISOString
(
endDateObj
);
}
else
{
}
else
{
this
.
selectModel
.
endDate
=
''
;
// หาก Backend ส่ง null หรือไม่มี endDate มา ให้ตั้งค่าเป็น string ว่าง
this
.
selectModel
.
endDate
=
''
;
}
}
// เมธอดนี้ไม่ได้ถูกเรียกใช้แล้ว (หรือควรจะถูกลบ)
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
);
}
}
}
}
...
@@ -288,7 +277,7 @@ export class ArticleManageComponent {
...
@@ -288,7 +277,7 @@ export class ArticleManageComponent {
buttons
:
[
"ยกเลิก"
,
"ยืนยัน"
],
buttons
:
[
"ยกเลิก"
,
"ยืนยัน"
],
}).
then
((
willSave
:
any
)
=>
{
}).
then
((
willSave
:
any
)
=>
{
if
(
willSave
)
{
if
(
willSave
)
{
//
--- ส่วนสำคัญ:
แปลงวันที่ก่อนส่งไป Backend (ให้เป็น ISOZ) ---
// แปลงวันที่ก่อนส่งไป Backend (ให้เป็น ISOZ) ---
let
createdDateToSend
:
string
|
null
=
null
;
let
createdDateToSend
:
string
|
null
=
null
;
if
(
this
.
selectModel
.
createdDate
)
{
if
(
this
.
selectModel
.
createdDate
)
{
createdDateToSend
=
new
Date
(
this
.
selectModel
.
createdDate
).
toISOString
();
createdDateToSend
=
new
Date
(
this
.
selectModel
.
createdDate
).
toISOString
();
...
@@ -301,7 +290,7 @@ export class ArticleManageComponent {
...
@@ -301,7 +290,7 @@ export class ArticleManageComponent {
let
endDateToSend
:
string
|
null
=
null
;
let
endDateToSend
:
string
|
null
=
null
;
if
(
this
.
selectModel
.
endDate
)
{
if
(
this
.
selectModel
.
endDate
)
{
if
(
this
.
selectModel
.
endDate
!==
''
)
{
// ตรวจสอบว่าไม่ใช่ string ว่าง ก่อนแปลง
if
(
this
.
selectModel
.
endDate
!==
''
)
{
endDateToSend
=
new
Date
(
this
.
selectModel
.
endDate
).
toISOString
();
endDateToSend
=
new
Date
(
this
.
selectModel
.
endDate
).
toISOString
();
}
}
}
}
...
@@ -326,7 +315,7 @@ export class ArticleManageComponent {
...
@@ -326,7 +315,7 @@ export class ArticleManageComponent {
publish
:
this
.
selectModel
.
publish
,
publish
:
this
.
selectModel
.
publish
,
viewCount
:
this
.
selectModel
.
viewCount
,
viewCount
:
this
.
selectModel
.
viewCount
,
companyId
:
this
.
selectModel
.
companyId
.
map
(
company
=>
({
companyId
:
this
.
selectModel
.
companyId
.
map
(
company
=>
({
id
:
company
.
companyId
,
// สมมติว่า CompanyModel มี property ชื่อ companyId ที่เป็น ID
id
:
company
.
companyId
,
}))
as
any
}))
as
any
};
};
...
@@ -457,7 +446,6 @@ export class ArticleManageComponent {
...
@@ -457,7 +446,6 @@ export class ArticleManageComponent {
}
else
if
(
!
modified
)
{
}
else
if
(
!
modified
)
{
this
.
selectModel
.
lastModifiedDate
=
this
.
formatDateToISOString
(
created
);
this
.
selectModel
.
lastModifiedDate
=
this
.
formatDateToISOString
(
created
);
}
}
// ลบ logic สำหรับ endDate ออกแล้ว
}
}
}
}
...
@@ -491,7 +479,7 @@ export class ArticleManageComponent {
...
@@ -491,7 +479,7 @@ export class ArticleManageComponent {
.
then
((
willAdjust
:
any
)
=>
{
.
then
((
willAdjust
:
any
)
=>
{
if
(
willAdjust
)
{
if
(
willAdjust
)
{
const
updatePromises
=
selectedArticles
.
map
(
article
=>
{
const
updatePromises
=
selectedArticles
.
map
(
article
=>
{
//
--- ส่วนสำคัญ:
แปลงวันที่ก่อนส่งไป Backend (ให้เป็น ISOZ) ---
// แปลงวันที่ก่อนส่งไป Backend (ให้เป็น ISOZ) ---
let
createdDateToSend
:
string
|
null
=
null
;
let
createdDateToSend
:
string
|
null
=
null
;
if
(
article
.
createdDate
)
{
if
(
article
.
createdDate
)
{
createdDateToSend
=
new
Date
(
article
.
createdDate
).
toISOString
();
createdDateToSend
=
new
Date
(
article
.
createdDate
).
toISOString
();
...
@@ -529,7 +517,7 @@ export class ArticleManageComponent {
...
@@ -529,7 +517,7 @@ export class ArticleManageComponent {
publish
:
statusValue
,
// อัปเดตค่า publish ที่นี่
publish
:
statusValue
,
// อัปเดตค่า publish ที่นี่
viewCount
:
article
.
viewCount
,
viewCount
:
article
.
viewCount
,
companyId
:
article
.
companyId
.
map
(
company
=>
({
companyId
:
article
.
companyId
.
map
(
company
=>
({
id
:
company
.
companyId
,
// สมมติว่า CompanyModel มี property ชื่อ companyId ที่เป็น ID
id
:
company
.
companyId
,
}))
as
any
}))
as
any
};
};
...
...
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