251127:1700 Frontend Start Build

This commit is contained in:
admin
2025-11-27 17:08:49 +07:00
parent b42c8c0c9f
commit f725bd5d3e
1795 changed files with 893474 additions and 10 deletions

View File

@@ -0,0 +1,15 @@
// File: src/types/dto/circulation/create-circulation.dto.ts
export interface CreateCirculationDto {
/** เอกสารต้นเรื่องที่จะเวียน (Correspondence ID) */
correspondenceId: number;
/** หัวข้อเรื่อง (Subject) */
subject: string;
/** รายชื่อ User ID ที่ต้องการส่งให้ (ผู้รับผิดชอบ) */
assigneeIds: number[];
/** หมายเหตุเพิ่มเติม (ถ้ามี) */
remarks?: string;
}

View File

@@ -0,0 +1,13 @@
// File: src/types/dto/circulation/search-circulation.dto.ts
export interface SearchCirculationDto {
/** ค้นหาจาก Subject หรือ No. */
search?: string;
/** OPEN, COMPLETED, CANCELLED */
status?: string;
page?: number;
limit?: number;
}

View File

@@ -0,0 +1,11 @@
export enum CirculationAction {
COMPLETED = 'COMPLETED',
REJECTED = 'REJECTED',
// IN_PROGRESS อาจจะไม่ต้องส่งมา เพราะเป็น auto state ตอนเริ่มดู
}
export interface UpdateCirculationRoutingDto {
status: string; // สถานะที่ต้องการอัปเดต
comments?: string; // ความคิดเห็นเพิ่มเติม
}

View File

@@ -0,0 +1,11 @@
// File: src/types/dto/correspondence/add-reference.dto.ts
export interface AddReferenceDto {
/** ID ของเอกสารที่ต้องการอ้างอิงถึง */
targetId: number;
}
export interface RemoveReferenceDto {
/** ID ของเอกสารที่ต้องการลบการอ้างอิง */
targetId: number;
}

View File

@@ -0,0 +1,32 @@
// File: src/types/dto/correspondence/create-correspondence.dto.ts
export interface CreateCorrespondenceDto {
/** ID ของโครงการ */
projectId: number;
/** ID ของประเภทเอกสาร (เช่น RFA, LETTER) */
typeId: number;
/** [Req 6B] สาขางาน (เช่น GEN, STR) */
disciplineId?: number;
/** [Req 6B] ประเภทย่อย (เช่น MAT, SHP สำหรับ Transmittal/RFA) */
subTypeId?: number;
/** หัวข้อเอกสาร */
title: string;
/** รายละเอียดเพิ่มเติม (Optional) */
description?: string;
/** ข้อมูล JSON เฉพาะประเภท (เช่น RFI question, RFA details) */
details?: Record<string, any>;
/** เอกสารภายในหรือไม่ (True = ภายใน) */
isInternal?: boolean;
/** * ✅ Field สำหรับ Impersonation (เลือกองค์กรผู้ส่ง)
* ใช้กรณี Admin สร้างเอกสารแทนผู้อื่น
*/
originatorId?: number;
}

View File

@@ -0,0 +1,12 @@
// File: src/types/dto/correspondence/search-correspondence.dto.ts
export interface SearchCorrespondenceDto {
search?: string; // ค้นหาจาก Title หรือ Number
typeId?: number; // กรองตามประเภทเอกสาร
projectId?: number; // กรองตามโครงการ
statusId?: number; // กรองตามสถานะ (จาก Revision ปัจจุบัน)
// เพิ่มเติมสำหรับการแบ่งหน้า (Pagination)
page?: number;
limit?: number;
}

View File

@@ -0,0 +1,6 @@
// File: src/types/dto/correspondence/submit-correspondence.dto.ts
export interface SubmitCorrespondenceDto {
/** ID ของ Routing Template ที่เลือกใช้ในการเดินเอกสาร */
templateId: number;
}

View File

@@ -0,0 +1,16 @@
// File: src/types/dto/correspondence/workflow-action.dto.ts
export type WorkflowAction = 'APPROVE' | 'REJECT' | 'RETURN' | 'ACKNOWLEDGE' | 'FORWARD';
export interface WorkflowActionDto {
/** การกระทำ (Approve, Reject, etc.) */
action: WorkflowAction;
/** ความคิดเห็นเพิ่มเติม */
comments?: string;
/** * ลำดับที่ต้องการส่งกลับ (ใช้กรณี action = RETURN)
* เช่น ส่งกลับไป step 1
*/
returnToSequence?: number;
}

View File

@@ -0,0 +1,38 @@
// File: src/types/dto/drawing/contract-drawing.dto.ts
// --- Create ---
export interface CreateContractDrawingDto {
/** ID ของโครงการ */
projectId: number;
/** เลขที่แบบสัญญา */
contractDrawingNo: string;
/** ชื่อแบบ */
title: string;
/** ID หมวดหมู่ย่อย */
subCategoryId?: number;
/** ID เล่มของแบบ */
volumeId?: number;
/** รายการ ID ของไฟล์แนบ (PDF/DWG) */
attachmentIds?: number[];
}
// --- Update (Partial) ---
export interface UpdateContractDrawingDto extends Partial<CreateContractDrawingDto> {}
// --- Search ---
export interface SearchContractDrawingDto {
/** จำเป็นต้องระบุ Project ID เสมอ */
projectId: number;
volumeId?: number;
subCategoryId?: number;
search?: string; // ค้นหาจาก Title หรือ Number
page?: number; // Default: 1
pageSize?: number; // Default: 20
}

View File

@@ -0,0 +1,37 @@
// File: src/types/dto/drawing/shop-drawing.dto.ts
// --- Create New Shop Drawing ---
export interface CreateShopDrawingDto {
projectId: number;
drawingNumber: string;
title: string;
mainCategoryId: number;
subCategoryId: number;
// First Revision Data (Optional)
revisionLabel?: string;
revisionDate?: string; // ISO Date String
description?: string;
contractDrawingIds?: number[]; // อ้างอิงแบบสัญญา
attachmentIds?: number[];
}
// --- Create New Revision ---
export interface CreateShopDrawingRevisionDto {
revisionLabel: string;
revisionDate?: string;
description?: string;
contractDrawingIds?: number[];
attachmentIds?: number[];
}
// --- Search ---
export interface SearchShopDrawingDto {
projectId: number;
mainCategoryId?: number;
subCategoryId?: number;
search?: string;
page?: number; // Default: 1
pageSize?: number; // Default: 20
}

View File

@@ -0,0 +1,34 @@
// File: src/types/dto/json-schema/json-schema.dto.ts
// --- Create ---
export interface CreateJsonSchemaDto {
/** รหัส Schema (ต้องไม่ซ้ำ เช่น 'RFA_DWG_V1') */
schemaCode: string;
/** เวอร์ชัน (Default: 1) */
version?: number;
/** โครงสร้าง JSON Schema (Standard Format) */
schemaDefinition: Record<string, any>;
/** สถานะการใช้งาน */
isActive?: boolean;
}
// --- Update (Partial) ---
export interface UpdateJsonSchemaDto extends Partial<CreateJsonSchemaDto> {}
// --- Search ---
export interface SearchJsonSchemaDto {
/** ค้นหาจาก schemaCode */
search?: string;
/** กรองตามสถานะ */
isActive?: boolean;
/** หน้าปัจจุบัน (Default: 1) */
page?: number;
/** จำนวนต่อหน้า (Default: 20) */
limit?: number;
}

View File

@@ -0,0 +1,14 @@
// File: src/types/dto/master/discipline.dto.ts
export interface CreateDisciplineDto {
contractId: number;
/** รหัสสาขา (เช่น 'STR', 'ARC') */
disciplineCode: string;
codeNameTh?: string;
codeNameEn?: string;
isActive?: boolean;
}

View File

@@ -0,0 +1,10 @@
// File: src/types/dto/master/number-format.dto.ts
export interface SaveNumberFormatDto {
projectId: number;
correspondenceTypeId: number;
/** รูปแบบ Template เช่น '{ORG}-{TYPE}-{DISCIPLINE}-{SEQ:4}' */
formatTemplate: string;
}

View File

@@ -0,0 +1,15 @@
// File: src/types/dto/master/sub-type.dto.ts
export interface CreateSubTypeDto {
contractId: number;
correspondenceTypeId: number;
/** รหัสย่อย (เช่น 'MAT') */
subTypeCode: string;
subTypeName?: string;
/** เลขรหัสสำหรับ Running Number (เช่น '11') */
subTypeNumber?: string;
}

View File

@@ -0,0 +1,22 @@
// File: src/types/dto/master/tag.dto.ts
export interface CreateTagDto {
/** ชื่อ Tag (เช่น 'URGENT') */
tag_name: string;
/** คำอธิบาย */
description?: string;
}
export interface UpdateTagDto extends Partial<CreateTagDto> {}
export interface SearchTagDto {
/** คำค้นหา (ชื่อ Tag หรือ คำอธิบาย) */
search?: string;
/** หมายเลขหน้า (เริ่มต้น 1) */
page?: number;
/** จำนวนรายการต่อหน้า (Default: 20) */
limit?: number;
}

View File

@@ -0,0 +1,9 @@
// File: src/types/dto/monitoring/set-maintenance.dto.ts
export interface SetMaintenanceDto {
/** สถานะ Maintenance (true = เปิด, false = ปิด) */
enabled: boolean;
/** เหตุผลที่ปิดปรับปรุง (แสดงให้ User เห็น) */
reason?: string;
}

View File

@@ -0,0 +1,39 @@
// File: src/types/dto/notification/notification.dto.ts
export type NotificationType = 'EMAIL' | 'LINE' | 'SYSTEM';
// --- Create ---
export interface CreateNotificationDto {
/** ผู้รับ (User ID) */
userId: number;
/** หัวข้อแจ้งเตือน */
title: string;
/** ข้อความรายละเอียด */
message: string;
/** ประเภท: EMAIL, LINE, SYSTEM */
type: NotificationType;
/** Entity ที่เกี่ยวข้อง เช่น 'rfa', 'correspondence' */
entityType?: string;
/** ID ของ Entity */
entityId?: number;
/** Link ไปยังหน้าเว็บ (Frontend) */
link?: string;
}
// --- Search ---
export interface SearchNotificationDto {
/** หน้าปัจจุบัน (Default: 1) */
page?: number;
/** จำนวนต่อหน้า (Default: 20) */
limit?: number;
/** กรอง: อ่านแล้ว (true) / ยังไม่อ่าน (false) */
isRead?: boolean;
}

View File

@@ -0,0 +1,31 @@
// File: src/types/dto/project/project.dto.ts
// --- Create ---
export interface CreateProjectDto {
/** รหัสโครงการ (เช่น LCBP3) */
projectCode: string;
/** ชื่อโครงการ */
projectName: string;
/** สถานะการใช้งาน (Default: true) */
isActive?: boolean;
}
// --- Update (Partial) ---
export interface UpdateProjectDto extends Partial<CreateProjectDto> {}
// --- Search ---
export interface SearchProjectDto {
/** ค้นหาจาก Project Code หรือ Name */
search?: string;
/** กรองตามสถานะ Active */
isActive?: boolean;
/** หน้าปัจจุบัน (Default: 1) */
page?: number;
/** จำนวนรายการต่อหน้า (Default: 20) */
limit?: number;
}

View File

@@ -0,0 +1,55 @@
// File: src/types/dto/rfa/rfa.dto.ts
// --- Create ---
export interface CreateRfaDto {
/** ID ของโครงการ */
projectId: number;
/** ประเภท RFA (เช่น DWG, MAT) */
rfaTypeId: number;
/** [Req 6B] สาขางาน (จำเป็นสำหรับการรันเลข RFA) */
disciplineId?: number;
/** หัวข้อเรื่อง */
title: string;
/** ส่งถึงใคร (สำหรับ Routing Step 1) */
toOrganizationId: number;
/** รายละเอียดเพิ่มเติม */
description?: string;
/** วันที่ในเอกสาร (ISO Date String) */
documentDate?: string;
/** กำหนดวันตอบกลับ (ISO Date String) */
dueDate?: string;
/** รายการ ID ของ Shop Drawings ที่แนบมา (ถ้ามี) */
shopDrawingRevisionIds?: number[];
}
// --- Update (Partial) ---
export interface UpdateRfaDto extends Partial<CreateRfaDto> {}
// --- Search ---
export interface SearchRfaDto {
/** บังคับระบุ Project ID เสมอ */
projectId: number;
/** กรองตามประเภท RFA */
rfaTypeId?: number;
/** กรองตามสถานะ (เช่น Draft, For Approve) */
statusId?: number;
/** ค้นหาจาก เลขที่เอกสาร หรือ หัวข้อเรื่อง */
search?: string;
/** หน้าปัจจุบัน (Default: 1) */
page?: number;
/** จำนวนต่อหน้า (Default: 20) */
pageSize?: number;
}

View File

@@ -0,0 +1,18 @@
// File: src/types/dto/search/search-query.dto.ts
export interface SearchQueryDto {
/** คำค้นหา (Query) */
q?: string;
/** กรองประเภท: 'rfa', 'correspondence', 'drawing' */
type?: string;
/** ID ของโครงการ */
projectId?: number;
/** หน้าปัจจุบัน (Default: 1) */
page?: number;
/** จำนวนต่อหน้า (Default: 20) */
limit?: number;
}

View File

@@ -0,0 +1,43 @@
// File: src/types/dto/transmittal/transmittal.dto.ts
export enum TransmittalPurpose {
FOR_APPROVAL = 'FOR_APPROVAL',
FOR_INFORMATION = 'FOR_INFORMATION',
FOR_REVIEW = 'FOR_REVIEW',
OTHER = 'OTHER',
}
// --- Create ---
export interface CreateTransmittalDto {
/** จำเป็นสำหรับการออกเลขที่เอกสาร (Running Number) */
projectId: number;
/** วัตถุประสงค์การส่ง */
purpose?: TransmittalPurpose;
/** หมายเหตุเพิ่มเติม */
remarks?: string;
/** ID ของเอกสาร (Correspondence IDs) ที่จะแนบไปใน Transmittal นี้ */
itemIds: number[];
}
// --- Update (Partial) ---
export interface UpdateTransmittalDto extends Partial<CreateTransmittalDto> {}
// --- Search ---
export interface SearchTransmittalDto {
/** บังคับระบุ Project */
projectId: number;
purpose?: TransmittalPurpose;
/** ค้นหาจากเลขที่เอกสาร หรือ remarks */
search?: string;
/** หน้าปัจจุบัน (Default: 1) */
page?: number;
/** จำนวนต่อหน้า (Default: 20) */
pageSize?: number;
}

View File

@@ -0,0 +1,35 @@
// File: src/types/dto/user/user.dto.ts
// --- Create User ---
export interface CreateUserDto {
username: string;
password: string; // จำเป็นสำหรับการสร้าง
email: string;
firstName?: string;
lastName?: string;
lineId?: string;
primaryOrganizationId?: number;
isActive?: boolean;
}
// --- Update User ---
export interface UpdateUserDto extends Partial<CreateUserDto> {}
// --- Assign Role ---
export interface AssignRoleDto {
userId: number;
roleId: number;
// Scope (Optional)
organizationId?: number;
projectId?: number;
contractId?: number;
}
// --- Update Preferences ---
export interface UpdatePreferenceDto {
notifyEmail?: boolean;
notifyLine?: boolean;
digestMode?: boolean;
uiTheme?: 'light' | 'dark' | 'system';
}

View File

@@ -0,0 +1,40 @@
// File: src/types/dto/workflow-engine/workflow-engine.dto.ts
// --- Create Definition ---
export interface CreateWorkflowDefinitionDto {
/** รหัสของ Workflow (เช่น 'RFA', 'CORRESPONDENCE') */
workflow_code: string;
/** นิยาม Workflow (DSL JSON Object) */
dsl: any;
/** เปิดใช้งานทันทีหรือไม่ (Default: true) */
is_active?: boolean;
}
// --- Update Definition ---
export interface UpdateWorkflowDefinitionDto extends Partial<CreateWorkflowDefinitionDto> {}
// --- Evaluate (ประมวลผล/ตรวจสอบ State) ---
export interface EvaluateWorkflowDto {
/** รหัส Workflow */
workflow_code: string;
/** สถานะปัจจุบัน */
current_state: string;
/** Action ที่ต้องการทำ (เช่น 'SUBMIT', 'APPROVE') */
action: string;
/** Context ข้อมูลเพิ่มเติม (เช่น User ID, Data) */
context?: Record<string, any>;
}
// --- Get Available Actions ---
export interface GetAvailableActionsDto {
/** รหัส Workflow */
workflow_code: string;
/** สถานะปัจจุบัน */
current_state: string;
}

29
frontend/types/next-auth.d.ts vendored Normal file
View File

@@ -0,0 +1,29 @@
// File: types/next-auth.d.ts
import NextAuth, { DefaultSession } from "next-auth"
declare module "next-auth" {
interface Session {
user: {
id: string;
role: string;
organizationId?: number;
} & DefaultSession["user"]
accessToken?: string;
}
interface User {
id: string;
role: string;
organizationId?: number;
accessToken?: string;
}
}
declare module "next-auth/jwt" {
interface JWT {
id: string;
role: string;
organizationId?: number;
accessToken?: string;
}
}