ใบอนุญาตปฏิบัติงาน (Work Permit) - Workflow
นี่คือเอกสารสำหรับ Work Permit Prototype กรุณาทดสอบและส่ง feedback
Referenced Templates
- Location:
frontend/src/assets/templates/08-*-work-permit/to15-*-work-permit/
Application Flow Diagram
The complete Safety App workflow showing all roles and document flow:
Open full size in new tab - Use Ctrl+scroll to zoom
safety-app-flow-v2.drawio.xml - Can be opened in draw.io for editing
Implementation Diagram (Dev Version)
The dev-version diagram shows the exact workflow states as implemented in code. This is the technical reference that always matches the codebase.
- SVG:
frontend/src/assets/workflows/work-permit-workflow-dev.svg - Draw.io:
frontend/src/assets/workflows/work-permit-workflow-dev.drawio.xml - States enum:
WorkPermitWorkflowStatesinwork-permit-workflow.mock.ts
Cell IDs in the dev-version SVG match state keys directly (e.g., data-cell-id="prepare-prerequisites").
This makes it easy to update the diagram when workflow states change.
Workflow Diagram (Simplified)
States
Phase 1: Prerequisites
| State | Thai Name | Description |
|---|---|---|
| Started | เริ่มต้น | สถานะเริ่มต้น |
| PreparePrerequisites | เตรียมเอกสารเบื้องต้น | ผู้รับเหมากรอก Doc 5, 6*, 4, 3 |
| ReviewPrereqByWorkOwner | เจ้าของงานตรวจสอบ | เจ้าของงานตรวจสอบเอกสารทั้งหมด |
| ReviewPrereqBySafetyOfficer | จป. ตรวจสอบรายชื่อ | จป. ตรวจสอบ Doc 4 (รายชื่อผู้ปฏิบัติงาน) แบบละเอียด |
Phase 2: PTW Filling
| State | Thai Name | Description |
|---|---|---|
| FillInPermitInfo | กรอกข้อมูลใบอนุญาต | ผู้รับเหมาเลือกประเภท PTW และกรอก Doc 7*-15 |
Phase 3: PTW Review (Parallel Co-Review)
| State | Thai Name | Description |
|---|---|---|
| ReviewPTWCoReview | ตรวจสอบใบอนุญาตร่วม | เจ้าของงาน + จป. + เจ้าของพื้นที่ ตรวจสอบร่วมกัน (ทั้ง 3 ต้องอนุมัติ) |
Phase 4: Execution
| State | Thai Name | Description |
|---|---|---|
| WorkInProgress | กำลังปฏิบัติงาน | อยู่ระหว่างปฏิบัติงานตาม PTW |
| RequestExtension | ขอขยายเวลา | ผู้รับเหมากรอกคำขอขยายเวลา |
| ReviewExtCoReview | ตรวจสอบคำขอขยายเวลา | ทั้ง 3 คน ตรวจสอบคำขอขยายเวลาร่วมกัน |
Phase 5: Close & Evaluation
| State | Thai Name | Description |
|---|---|---|
| RequestClose | ขอปิดงาน | ผู้รับเหมากรอก Delivery Document |
| ClosePTWCoReview | ตรวจสอบการปิดงาน | ทั้ง 3 คน ตรวจสอบการส่งมอบงานร่วมกัน |
| Evaluation | ประเมินผล | เจ้าของงาน (คุณภาพงาน) + จป. (ความปลอดภัย) กรอก Doc 16 |
Terminal States
| State | Thai Name | Description |
|---|---|---|
| Completed | เสร็จสิ้น | งานเสร็จสิ้นสมบูรณ์ |
| Cancelled | ยกเลิก | ใบอนุญาตถูกยกเลิก |
หมายเหตุ: * = conditional (ใช้เมื่อจำเป็นเท่านั้น เช่น Doc 6 เมื่อใช้ Mobile Crane, Doc 7 เมื่อใช้ Scaffolding)
Commands
Phase 1: Prerequisites
| Command | Thai Name | From State | To State |
|---|---|---|---|
| SubmitPrerequisites | ส่งเอกสารเบื้องต้น | PreparePrerequisites | ReviewPrereqByWorkOwner |
| ApprovePrereqByWorkOwner | อนุมัติเอกสารเบื้องต้น | ReviewPrereqByWorkOwner | ReviewPrereqBySafetyOfficer |
| RejectPrereqByWorkOwner | ส่งกลับแก้ไขเอกสาร | ReviewPrereqByWorkOwner | PreparePrerequisites |
| ApprovePrereqBySO | อนุมัติรายชื่อผู้ปฏิบัติงาน | ReviewPrereqBySafetyOfficer | FillInPermitInfo |
| RejectPrereqBySO | ส่งกลับแก้ไขรายชื่อ | ReviewPrereqBySafetyOfficer | PreparePrerequisites |
Phase 2: PTW Submission & Review
| Command | Thai Name | From State | To State |
|---|---|---|---|
| SubmitPTW | ส่งใบอนุญาตเพื่อตรวจสอบ | FillInPermitInfo | ReviewPTWCoReview |
| ApprovePTW | อนุมัติใบอนุญาต | ReviewPTWCoReview | WorkInProgress |
| RequestChangePTW | ขอให้แก้ไขใบอนุญาต | ReviewPTWCoReview | FillInPermitInfo |
Phase 3: Extension
| Command | Thai Name | From State | To State |
|---|---|---|---|
| RequestExtension | ขอขยายเวลา | WorkInProgress | RequestExtension |
| SubmitExtension | ส่งคำขอขยายเวลา | RequestExtension | ReviewExtCoReview |
| ApproveExtension | อนุมัติขยายเวลา | ReviewExtCoReview | WorkInProgress |
| RejectExtension | ปฏิเสธขยายเวลา | ReviewExtCoReview | WorkInProgress |
Phase 4: Close & Evaluation
| Command | Thai Name | From State | To State |
|---|---|---|---|
| RequestClose | ขอปิดงาน | WorkInProgress | RequestClose |
| SubmitClose | ส่งคำขอปิดงาน | RequestClose | ClosePTWCoReview |
| ApproveClose | อนุมัติปิดงาน | ClosePTWCoReview | Evaluation |
| RejectClose | ปฏิเสธปิดงาน | ClosePTWCoReview | WorkInProgress |
| CompleteEvaluation | เสร็จสิ้นการประเมิน | Evaluation | Completed |
Cancel
| Command | Thai Name | From State | To State |
|---|---|---|---|
| Cancel | ยกเลิกใบอนุญาต | Most states | Cancelled |
Permit Types (DocumentForms 8-15)
| ID | Template Folder | English Name | Thai Name |
|---|---|---|---|
| 8 | 08-work-at-height-work-permit | Work at Height Permit | ใบอนุญาตปฏิบัติงานในที่สูง |
| 9 | 09-chemical-work-permit | Chemical Work Permit | ใบอนุญาตงานกับวัตถุอันตรายหรือสารเคมี |
| 10 | 10-high-voltage-work-permit | High Voltage Work Permit | ใบอนุญาตปฏิบัติงานไฟฟ้าแรงสูง |
| 11 | 11-hot-work-permit | Hot Work Permit | ใบอนุญาตงานเชื่อม/ตัด |
| 12 | 12-confined-space-work-permit | Confined Space Work Permit | ใบอนุญาตงานในที่อับอากาศ |
| 13 | 13-general-work-permit | General Work Permit | ใบอนุญาตปฏิบัติงานทั่วไป |
| 14 | 14-radiation-work-permit | Radiation Work Permit | ใบอนุญาตงานรังสี |
| 15 | 15-excavate-work-permit | Excavate Work Permit | ใบอนุญาตงานขุดเจาะ |
Pre-requisite Documents
Before filling out the Work Permit form (Part 1), the following documents must be prepared:
| Doc ID | Document | Thai Name | Description |
|---|---|---|---|
| 03 | Risk Assessment (JSA) | การวิเคราะห์งานเพื่อความปลอดภัย | Job Safety Analysis for the work |
| 04 | Manpower Name List | รายชื่อผู้ปฏิบัติงาน | List of trained workers |
| 05 | Tool List | รายการเครื่องมือ | Equipment and tools required |
These documents are shown in the "เอกสารเบื้องต้น" (Prerequisites) tab in the review task view.
Workers in the Work Permit must be selected from the approved manpower list for the project. Only workers who have completed safety training are eligible.
Print-Only Documents
These documents are generated for printing only and are accessible via the Print button in the task review toolbar.
| Doc ID | Document | Thai Name | Node | Purpose |
|---|---|---|---|---|
| 20 | Training Attendance Sheet | ใบลงทะเบียนอบรม | #22 | Worker safety training registration record |
| 21 | Worker Badges | บัตรผู้ปฏิบัติงาน | #22 | ID cards for authorized workers |
| 22 | Worksite Poster | พิมพ์ใบอนุญาต | #23 | Posted work permit at the worksite |
Workflow-Specific Documents
These documents are created specifically for the workflow and do not have corresponding .docx templates:
| Doc ID | Document | Thai Name | Purpose |
|---|---|---|---|
| 18 | Delivery Document | เอกสารส่งมอบงาน | Work completion handover document |
| 19 | Extension Request | แบบฟอร์มขอขยายเวลา | Time extension request form |
- From .docx templates: Doc 6-7 (Inspections), Doc 8-15 (Work Permits), Doc 16 (Evaluation)
- Digital-only forms: Doc 18 (Delivery), Doc 19 (Extension) - designed for digital workflow
- Print-only output: Doc 20-22 - generated from approved data
State-Documents Mapping
Each workflow state shows different documents in the UI. This mapping is defined in getWorkPermitDocumentFormIds().
| State | Documents Shown |
|---|---|
prepare-prerequisites | Doc 5, 6*, 4, 3 (prerequisites) |
review-prereq-by-work-owner | Doc 5, 6*, 4, 3 (prerequisites) |
review-prereq-by-safety-officer | Doc 5, 6*, 4, 3 (prerequisites) |
fill-in-permit-info | Doc 7* + PTW forms (8-15) + prerequisites |
review-ptw-co-review | Doc 7* + PTW forms (8-15) + prerequisites |
work-in-progress | PTW forms + Doc 18 (Delivery) + Doc 19 (Extension Request) |
request-extension | PTW forms + Doc 19 (Extension Request) |
review-ext-co-review | PTW forms + Doc 19 (Extension Request) |
close-ptw-co-review | Doc 18 (Delivery) + PTW forms |
evaluation | Doc 16 (Evaluation) + Doc 18 + PTW forms |
completed | Doc 16 + Doc 18 + PTW + prerequisites (all for reference) |
Note: The
request-closestate is deprecated. The workflow goes directly fromwork-in-progresstoclose-ptw-co-review. The Delivery Document (Doc 18) is filled duringwork-in-progressstate.
Legend: * = conditional document (Doc 6 when Mobile Crane, Doc 7 when Scaffolding)
Form Edit Permissions
Controls which roles can edit which documents at each state. Defined in getWorkPermitFormEditPermissions().
| State | Editable Documents | Editable By | Lock Reason |
|---|---|---|---|
prepare-prerequisites | Doc 3, 4, 5, 6* | Contractor | - |
review-prereq-by-work-owner | (all locked) | - | เจ้าของงานกำลังตรวจสอบ |
review-prereq-by-safety-officer | (all locked) | - | จป. กำลังตรวจสอบรายชื่อ |
fill-in-permit-info | PTW forms, Doc 7* | Contractor | Prerequisites locked (อนุมัติแล้ว) |
review-ptw-co-review | (all locked) | - | กำลังตรวจสอบร่วม |
work-in-progress | Doc 18 | Contractor | PTW locked (กำลังปฏิบัติงาน) |
request-extension | PTW forms | Contractor | กรอกคำขอขยายเวลา |
review-ext-co-review | (all locked) | - | กำลังตรวจสอบคำขอขยายเวลา |
close-ptw-co-review | (all locked) | - | กำลังตรวจสอบการส่งมอบงาน |
evaluation | Doc 16 | Work Owner, Safety Officer | Doc 18 locked (ส่งมอบงานแล้ว) |
completed | (all locked) | - | เสร็จสิ้นแล้ว |
Expected Role per State
Shows which role(s) should be acting at each workflow state. Used for the role indicator badge in the UI. Defined in getWorkPermitExpectedRole().
| State | Expected Role(s) | Thai |
|---|---|---|
prepare-prerequisites | Contractor | ผู้รับเหมา |
review-prereq-by-work-owner | Work Owner | เจ้าของงาน |
review-prereq-by-safety-officer | Safety Officer | จป. |
fill-in-permit-info | Contractor | ผู้รับเหมา |
review-ptw-co-review | Work Owner + Safety Officer + Workspace Owner | ตรวจสอบร่วม 3 คน |
work-in-progress | Contractor | ผู้รับเหมา |
request-extension | Contractor | ผู้รับเหมา |
review-ext-co-review | Work Owner + Safety Officer + Workspace Owner | ตรวจสอบร่วม 3 คน |
close-ptw-co-review | Work Owner + Safety Officer + Workspace Owner | ตรวจสอบร่วม 3 คน |
evaluation | Work Owner + Safety Officer | เจ้าของงาน + จป. |
completed | (terminal) | - |
cancelled | (terminal) | - |
Five-Part Form Structure
Part 1: ผู้รับเหมากรอก (Contractor Fills In)
Template: Part 1: Contractor.html
| Section | Fields |
|---|---|
| PERMIT DETAILS | PO No., Contractor, Permit Number, Date Issued, Start/End DateTime, Location |
| WORKER DETAILS | 10 rows: Name, Worker ID, Gender, Skillset |
| WORK DESCRIPTION | Textarea for work procedures |
| PPE | Checkboxes (varies by permit type) |
Work at Height PPE Examples:
- สายรัดนิรภัย (Safety Harness)
- เชือกนิรภัย/สายช่วยชีวิต
- บันได (Ladder)
- รอกนิรภัย
- นั่งร้าน (Scaffold)
- ราวกันตก (Guard Rail)
- ตาข่ายนิรภัย (Safety Net)
- อุปกรณ์ลำเลียงสิ่งของ
- ป้ายกำหนดเขตอันตราย
Part 2: ตรวจสอบก่อนเริ่มงาน (Client Checklist)
Template: Part 2: Client (Check).html
Checklist items with ถูกต้อง/ไม่ถูกต้อง/หมายเหตุ (Pass/Fail/Remarks)
Work at Height Checklist (9 items):
- กำหนดเขตอันตรายที่อาจมีวัตถุตกหล่นและติดป้ายเตือน "พื้นที่อันตราย" ชัดเจน
- ตรวจสอบนั่งร้าน ระบุผู้ติดตั้ง/ผู้ควบคุมและความสามารถรับน้ำหนัก
- งานที่มีความสูงตั้งแต่ 4 เมตร มีการป้องกันการตกหล่น หรือวัสดุกระเด็น
- มีขั้นตอนการปฏิบัติงานและการควบคุมป้องกันอันตรายจากที่สูง
- ทำการชี้แจงการปฏิบัติงานและป้องกันอันตรายต่อผู้ปฏิบัติงาน
- อุปกรณ์ป้องกันอันตรายที่กำหนด อยู่ในสภาพพร้อมใช้งาน แข็งแรงและปลอดภัย
- ผู้ปฏิบัติงานแต่งกายเหมาะสมและสวมใส่ PPE ตลอดระยะเวลา
- เครื่องมืออุปกรณ์ที่ใช้มีสภาพปลอดภัยเป็นไปตามมาตรฐาน/กฎหมาย
- อื่นๆ ระบุ
Part 3: ลงนามให้ปฏิบัติงาน (Work Authorization)
Template: PART 3: ลงนามให้ปฏิบัติงาน.html
3 inspection phases with 3 signatures each:
| Phase | Description | Purpose |
|---|---|---|
| การตรวจสอบก่อนเริ่มปฏิบัติงาน | ตรวจสอบความปลอดภัยตามรายการที่ระบุข้างต้น | จึงอนุญาตให้ปฏิบัติงานได้ |
| การตรวจสอบขณะปฏิบัติงาน | ตรวจสอบความปลอดภัยขณะที่มีการปฏิบัติงาน | ไม่มีสิ่งที่ก่อให้เกิดอันตรายขึ้น |
| การตรวจสอบหลังปฏิบัติงาน | ตรวจสอบความเรียบร้อยของพื้นที่ที่ปฏิบัติงาน | มีการจัดเก็บพื้นที่ปฏิบัติงานเรียบร้อย |
Signers per phase (3 roles):
- ผู้คุมงาน (เจ้าของงาน) / Requester
- เจ้าหน้าที่ความปลอดภัยในการทำงาน (จป.)
- เจ้าของพื้นที่
Part 4: การขอขยายเวลางาน (Extension Request)
Template: PART 4: การขอขยายเวลางาน (ต่ออายุใบอนุญาต).html
Digital Form: Doc 19 - Extension Request Form (extension-request-form.component.ts)
| Field | Description |
|---|---|
| ตั้งแต่เวลา | Original end time |
| ถึงเวลา | New end time (requested) |
4 signatures required:
- ผู้ขออนุญาต (ผู้รับเหมา/หัวหน้า)
- ผู้คุมงาน (เจ้าของงาน) / Requester
- เจ้าหน้าที่ความปลอดภัยในการทำงาน
- เจ้าของพื้นที่
Part 5: การปิดใบอนุญาต (Work Completion)
Template: PART 5: การปิดใบอนุญาต (Complete of Working).html
Completion Investigation (6 categories)
| Category | Thai Name | Columns |
|---|---|---|
| General investigation | การตรวจโดยการสังเกตทั่วไป | Pass / Fail / Improve / Fixed |
| Quantity | การตรวจเชิงปริมาณ (ตามที่กำหนด) | Pass / Fail / Improve / Fixed |
| Quality | การตรวจเชิงคุณภาพ (เทียบกับมาตรฐาน ฟังก์ชั่นการทำงาน) | Pass / Fail / Improve / Fixed |
| Safety & Environment | ด้านความปลอดภัย และสิ่งแวดล้อม | Pass / Fail / Improve / Fixed |
| Cleanliness & Reinstated | ความสะอาดคืนสภาพเดิม | Pass / Fail / Improve / Fixed |
| System Testing | ทดสอบระบบเรียบร้อย | Pass / Fail / Improve / Fixed |
Investigation Result
- รับมอบ / Accepted
- งานยังไม่สมบูรณ์ / Not Complete
- ยกเลิกงาน / Rejected
3 signatures required:
- ผู้คุมงาน (เจ้าของงาน) / Requester
- เจ้าหน้าที่ความปลอดภัยในการทำงาน
- เจ้าของพื้นที่
Review Task UI
When viewing a Work Permit task, additional tabs are available:
| Tab | Thai Name | Description |
|---|---|---|
| งาน | Documents | Main form view with permit documents |
| ข้อมูลโครงการ | Project Info | Linked project details (PR#, PO#, contractor, roles) |
| เอกสารเบื้องต้น | Prerequisites | Pre-requisite documents (Tool List, Manpower, JSA) |
| Notes | Notes | Task notes |
| Logs | Logs | Transaction history and visualization |
| Workflow | Workflow | Workflow state diagram |
Checklist Items Per Permit Type
Each permit type has specific checklist items (Part 2) tailored to the type of work:
| Permit Type | Checklist Items |
|---|---|
| General Work (ID 13) | 7 items: Area inspection, tool safety, electrical isolation, work area barricade, risk assessment, PPE preparation |
| Work at Height (ID 8) | 9 items: Hazard zone, scaffold inspection, fall protection, work procedures, PPE condition |
| Hot Work (ID 11) | 10 items: Fire monitoring, ventilation, flammable materials, fire extinguisher, communication |
| Confined Space (ID 12) | 11 items: Air quality, entry/exit, rescue team, monitoring equipment |
| Chemical (ID 9) | 8 items: MSDS, chemical handling, containment, emergency procedures |
| High Voltage (ID 10) | 9 items: Power isolation, lockout/tagout, testing equipment |
| Radiation (ID 14) | 8 items: Radiation monitoring, shielding, dosimeter, safety equipment |
| Excavate (ID 15) | 9 items: Underground utilities, soil stability, cave-in protection |
Checklist items are automatically loaded based on the permit type selected.
See permit-type-configs.ts for the full list of items.
Testing Instructions
เข้าถึง Prototype
- เข้าสู่ระบบด้วย role ที่เหมาะสม
- ไปที่ "งานของฉัน" (My Tasks)
- เลือก task ที่เป็น Work Permit
Test Scenarios
- Part 1: กรอกข้อมูล, เพิ่ม/ลบรายชื่อผู้ปฏิบัติงาน, เลือก PPE
- Part 2: ตรวจสอบ checklist items, กด Submit/Reject
- Part 3: ดู 3 phases, จำลองการลงนาม
- Part 4: ทดสอบขอขยายเวลา
- Part 5: ทดสอบการปิดงาน
สิ่งที่ต้องตรวจสอบ
- ข้อมูลแสดงผลถูกต้อง
- Workflow state transitions ทำงานถูกต้อง
- Form validation ทำงาน
- การบันทึกข้อมูลสำเร็จ
Feedback
สิ่งที่ต้องการ Feedback
- Workflow: ลำดับขั้นตอนเหมาะสมหรือไม่?
- Form Fields: ฟิลด์ครบถ้วนตาม template หรือไม่?
- Checklist Items: รายการตรวจสอบถูกต้องหรือไม่?
- Roles & Signatures: บทบาทผู้ลงนามถูกต้องหรือไม่?
- Missing Features: มีอะไรที่ขาดหายไป?
วิธีส่ง Feedback
- ติดต่อทีมพัฒนาโดยตรง
- หรือสร้าง Issue ใน GitHub repository
Source Code Reference
All workflow definitions are in the frontend mock file (will be moved to backend when real workflow is implemented):
File: frontend/src/app/shared/mock/work-permit-workflow.mock.ts
| Export | Description |
|---|---|
WorkPermitWorkflowStates | State enum (14 states) |
WorkPermitWorkflowCommands | Command enum (18 commands + Cancel) |
WORK_PERMIT_COMMAND_CAPTIONS | Thai labels for commands |
WORK_PERMIT_STATE_LABELS | Thai/English labels for states |
getWorkPermitCommands() | State → Commands mapping |
getWorkPermitDocumentFormIds() | State → Documents mapping |
getWorkPermitFormEditPermissions() | State → Edit permissions mapping |
getWorkPermitExpectedRole() | State → Expected role mapping |
Related Files:
frontend/src/app/shared/enums/document-forms.ts- Document form IDs (1-22)frontend/src/app/shared/mock/mock-work-permit-task.data.ts- Mock task data using the mappingsfrontend/src/app/shared/config/workflow-state-metadata.config.ts- State metadata for UI