Commit 9b29ce0c by Nakarin Luankla

UPDATE การจัดการรายละเอียดงาน

รายละเอียดของงาน
parent 0c874d39
......@@ -236,7 +236,7 @@ export class ImportDataComponent {
const formData = new FormData();
formData.append('file', this.selectedFile);
this.loading = true
this.fileService.uploadExcel(formData, 'MJOBCODE_COMPETENCY').subscribe({
this.fileService.uploadExcel(formData, 'MJOBCODE_GENERAL').subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
......
......@@ -3,12 +3,12 @@
<div class="flex pr-2">
<div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
data-hs-overlay="#company-registration-page-upload-modal">
data-hs-overlay="#supjob-upload-modal" (click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ri-add-line"></i>
นำเข้าข้อมูล
</button>
<a class="mx-2 justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px text-center text-secondary border-secondary border-b-2 align-items-end"
href="javascript:void(0);">
href="javascript:void(0);" (click)="downloadFile()">
ดาวน์โหลดตัวอย่างไฟล์
</a>
</div>
......@@ -18,8 +18,7 @@
<div class="relative shadow-md">
<input type="text" id="hs-leading-icon" name="hs-leading-icon"
class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
placeholder="Search by No. or Name" [(ngModel)]="search"
(ngModelChange)="searchChange()">
placeholder="Search by No. or Name" [(ngModel)]="search" (ngModelChange)="searchChange()" >
<div
class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4">
......@@ -27,13 +26,13 @@
</div>
</div>
</div>
<div class="px-1">
<!-- <div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-45px m-0 shadow-md"
data-hs-overlay="#work-detail-alert-delete-modal">
data-hs-overlay="#sub-command-structure-alert-delete-modal">
<i class="ri-delete-bin-6-line"></i>
Delete
</button>
</div>
</div> -->
<div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-45px m-0 shadow-md">
<i class="ti ti-book fs-l"></i>
......@@ -50,7 +49,7 @@
<thead>
<tr>
<ng-container
*ngFor="let item of ['ลำดับ','รหัสงาน','ชื่อลักษณะงาน (ไทย) *','ชื่อลักษณะงาน (อังกฤษ)','การจัดการ']; let f = first; let l = last">
*ngFor="let item of ['ลำดับ','รหัสงาน','ชื่อลักษณะงาน (ไทย)','ชื่อลักษณะงาน (อังกฤษ)*','การจัดการ']; let f = first; let l = last; let i = index">
<th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary !text-center">
<span class="font-size-12px font-weight-700">{{ item }}</span>
<div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!l">
......@@ -60,24 +59,37 @@
</ng-container>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of[
['01','001', 'Department Manager 1','Department Manager 1'],
['02','002', 'Department Manager 2','Department Manager 2'],
['03','003', 'Department 1-HRD','Department 1-HRD'],
['04','004', 'Department Manager 3','Department Manager 3'],
['05','005', 'Department Manager 4','Department Manager 4']];let i = index">
<tbody *ngIf="loading">
<tr>
<td class="text-center" colspan="100%">
<div *ngFor="let item of [1,2,3]" class="ti-spinner w-8 h-8 text-secondary mx-1" role="status"
aria-label="loading">
<span class="sr-only">Loading...</span>
</div>
</td>
</tr>
</tbody>
<tbody *ngIf="!loading&&!jobcodeFilter().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="!loading&&jobcodeFilter().length">
<tr
*ngFor="let item of jobcodeFilter() |slice:((currentPage-1) * pageSize) : (((currentPage-1) * pageSize) + pageSize);let i = index">
<td class="text-center">
{{i+1}}
{{((currentPage-1) * pageSize)+(i+1)}}
</td>
<td class="text-center">{{item[1]}}</td>
<td>{{item[2]}}</td>
<td>{{item[3]}}</td>
<td class="text-center">{{item.jobcodeId}}</td>
<td>{{item.tdesc}}</td>
<td>{{item.edesc}}</td>
<td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1"
data-hs-overlay="#work-detail-modal-edit"></i>
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1"
data-hs-overlay="#work-detail-alert-delete-modal"></i>
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" (click)="modalStatus='edit';edit(item)"
data-hs-overlay="#sub-job-competency-component-modal-edit"></i>
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" (click)="modalStatus='delete';edit(item)"
data-hs-overlay="#company-registration-page-alert-modal"></i>
</td>
</tr>
</tbody>
......@@ -93,8 +105,7 @@
</li>
<li *ngFor="let item of page;let f = first;let l = last">
<ng-container *ngIf="item==3&&currentPage!=1&&currentPage!=2&&currentPage!=3">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i
class="ri-more-line"></i>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a>
</ng-container>
<ng-container *ngIf="(f||l)||(item==currentPage-1||item==currentPage||item==currentPage+1)">
......@@ -104,8 +115,7 @@
</ng-container>
<ng-container
*ngIf="item==page.length-2&&currentPage!=page.length&&currentPage!=page.length-1&&currentPage!=page.length-2">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i
class="ri-more-line"></i>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a>
</ng-container>
</li>
......@@ -115,88 +125,35 @@
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
<li>
<select class="ti-form-select" [(ngModel)]="pageSize" (ngModelChange)="searchChange()">
<option [value]="10">10</option>
<option [value]="20">20</option>
<option [value]="50">50</option>
<option [value]="100">100</option>
</select>
</li>
</ul>
<ul class="nav-tabs mt-3">
<span>Show {{((currentPage-1) * pageSize)+1}} to {{(jobcodeFilter().length < pageSize) ?jobcodeFilter().length:
(currentPage==page.length ? ((currentPage * pageSize) - ((currentPage * pageSize) - jobcodeFilter().length) )
:(currentPage * pageSize) ) }} of {{jobcodeFilter().length}} items</span>
</ul>
</nav>
</div>
<div id="work-detail-modal-add" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)]">
<div class="max-h-full overflow-hidden ti-modal-content">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
เพิ่มข้อมูลรายละเอียดของงาน
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#work-detail-modal-add">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div>
</div>
<div class="ti-modal-center">
<div class="flex justify-end" style="padding-right: 1rem;">
<div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md">
<svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00"
xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA"
stroke-width="3.84" transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round">
</g>
<g id="SVGRepo_iconCarrier">
<path d="M15 49A24 24 0 0 1 32 8"></path>
<path d="M49 15a24 24 0 0 1-17 41"></path>
<polyline points="15.03 40 15.03 48.97 8 48.97"></polyline>
<polyline points="48.97 24 48.97 15.03 56 15.03"></polyline>
</g>
</svg>
Clear
</button>
</div>
<div class="px-1">
<button href="javascript:void(0);"
class="ti-btn ti-btn-soft-warning h-45px m-0 shadow-md">
<i class="ti ti-book fs-l"></i>
Help
</button>
</div>
</div>
</div>
<div class="ti-modal-body ">
<label for="input-label" class="ti-form-label mt-2rem">ฝ่าย</label>
<input type="text" id="input-label" class="ti-form-input w-1/2" [(ngModel)]="job.jobid">
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียดฝ่าย (ไทย)</label>
<input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="job.tdesc">
<label for="detail_eng" class="ti-form-label mt-2rem">รายละเอียดฝ่าย (อังกฤษ)</label>
<input type="text" id="detail_eng" class="ti-form-input h-16" [(ngModel)]="job.edesc">
<div class="flex justify-end mt-2rem mb-1rem">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#work-detail-modal-add">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#work-detail-alert-add-modal">
บันทึกข้อมูล
</a>
</div>
</div>
</div>
</div>
</div>
<div id="work-detail-modal-edit" class="hs-overlay hidden ti-modal">
<div id="sub-job-competency-component-modal-edit" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)]">
<div class="max-h-full overflow-hidden ti-modal-content">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
แก้ไขข้อมูลรายละเอียดของงาน
เเก้ไขข้อมูลความสามารถในตำเเหน่งงาน
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#work-detail-modal-edit">
data-hs-overlay="#sub-job-competency-component-modal-edit">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
......@@ -205,13 +162,12 @@
<div class="ti-modal-center">
<div class="flex justify-end" style="padding-right: 1rem;">
<div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md">
<button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md" (click)="clearValue()">
<svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00"
xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA"
stroke-width="3.84" transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA" stroke-width="3.84"
transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round">
</g>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
<g id="SVGRepo_iconCarrier">
<path d="M15 49A24 24 0 0 1 32 8"></path>
<path d="M49 15a24 24 0 0 1-17 41"></path>
......@@ -223,35 +179,31 @@
</button>
</div>
<div class="px-1">
<button href="javascript:void(0);"
class="ti-btn ti-btn-soft-warning h-45px m-0 shadow-md">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-45px m-0 shadow-md">
<i class="ti ti-book fs-l"></i>
Help
</button>
</div>
</div>
</div>
<div class="ti-modal-body mt-1">
<label for="input-label" class="ti-form-label">รหัสงาน*</label>
<input type="text" id="input-label" class="ti-form-input w-1/2 bg-input-readonly" readonly
value="001">
<label for="input-label" class="ti-form-label mt-2rem">ชื่อลักษณะงาน (ไทย)</label>
<input type="text" id="input-label" class="ti-form-input h-10 bg-input-readonly" readonly
value="Department Manager 1">
<label for="input-label" class="ti-form-label mt-2rem">ชื่อลักษณะงาน (อังกฤษ)</label>
<input type="text" id="input-label" class="ti-form-input h-10 bg-input-readonly" readonly
value="Department Manager 1">
<div class="ti-modal-body" style="padding-top: 0px;">
<label for="input-label" class="ti-form-label mt-1rem">รหัสงาน</label>
<input type="text" id="input-label" class="ti-form-input bg-input-readonly" readonly [(ngModel)]="selectJob.jobcodeId">
<label for="detail_th" class="ti-form-label mt-1rem">ชื่อลักษณะงาน (ไทย)</label>
<input type="text" id="detail_th" class="ti-form-input bg-input-readonly" readonly [(ngModel)]="selectJob.tdesc">
<label for="detail_eng" class="ti-form-label mt-1rem">ชื่อลักษณะงาน (อังกฤษ)</label>
<input type="text" id="detail_eng" class="ti-form-input bg-input-readonly" readonly [(ngModel)]="selectJob.edesc">
<div class="flex space-x-4 justify-center">
<!-- label และ textarea แรก -->
<div class="flex flex-col w-full">
<label for="input-label" class="ti-form-label mt-2rem">ABC</label>
<textarea id="input-label" class="ti-form-input w-80" rows="4" cols="50"></textarea>
<label for="input-label" class="ti-form-label mt-2rem">งานบริหาร (Management) </label>
<textarea id="input-label" class="ti-form-input w-80" rows="4" cols="50" [(ngModel)]="selectJob.serviceWorkText"></textarea>
</div>
<!-- label และ input ที่สอง -->
<div class="flex flex-col w-1/2">
<label for="input-label" class="ti-form-label mt-2rem">เปอร์เซ็นต์ %</label>
<input type="text" id="input-label" class="ti-form-input w-auto" value="10.0">
<input type="text" id="input-label" class="ti-form-input w-auto" oninput="value = value.replace(/[^0-9.]/g, '');" onclick="value = value=='0'?'':value" [(ngModel)]="selectJob.serviceWorkPercent">
</div>
</div>
<div class="flex space-x-4 justify-center">
......@@ -259,26 +211,26 @@
<div class="flex flex-col w-full">
<label for="input-label" class="ti-form-label mt-2rem">งานที่รับผิดชอบ
(งานปฏิบัติ)</label>
<textarea id="input-label" class="ti-form-input w-80" rows="4" cols="50"></textarea>
<textarea id="input-label" class="ti-form-input w-80" rows="4" cols="50" [(ngModel)]="selectJob.responsibleWorkText"></textarea>
</div>
<!-- label และ input ที่สอง -->
<div class="flex flex-col w-1/2">
<label for="input-label" class="ti-form-label mt-2rem">เปอร์เซ็นต์ %</label>
<input type="text" id="input-label" class="ti-form-input w-auto" value="10.0">
<input type="text" id="input-label" class="ti-form-input w-auto"oninput="value = value.replace(/[^0-9.]/g, '');" [(ngModel)]="selectJob.responsibleWorkPercent">
</div>
</div>
<div class="flex space-x-4 justify-center">
<!-- label และ textarea แรก -->
<div class="flex flex-col w-full">
<label for="input-label" class="ti-form-label mt-2rem">งานที่ได้รับมอบหมายพิเศษ</label>
<textarea id="input-label" class="ti-form-input w-80" rows="4" cols="50"></textarea>
<textarea id="input-label" class="ti-form-input w-80" rows="4" cols="50" [(ngModel)]="selectJob.specialWorkText"></textarea>
</div>
<!-- label และ input ที่สอง -->
<div class="flex flex-col w-1/2">
<label for="input-label" class="ti-form-label mt-2rem">เปอร์เซ็นต์ %</label>
<input type="text" id="input-label" class="ti-form-input w-auto" value="10.0">
<input type="text" id="input-label" class="ti-form-input w-auto" oninput="value = value.replace(/[^0-9]/g, '');" [(ngModel)]="selectJob.specialWorkPercent">
</div>
</div>
<div class="flex space-x-4 justify-center">
......@@ -286,45 +238,46 @@
<div class="flex flex-col w-full">
<label for="input-label"
class="ti-form-label mt-2rem">งานที่ทุกตำแหน่งต้องปฏิบัติ</label>
<textarea id="input-label" class="ti-form-input w-80" rows="4" cols="50"></textarea>
<textarea id="input-label" class="ti-form-input w-80" rows="4" cols="50" [(ngModel)]="selectJob.allPositionWorkText"></textarea>
</div>
<!-- label และ input ที่สอง -->
<div class="flex flex-col w-1/2">
<label for="input-label" class="ti-form-label mt-2rem">เปอร์เซ็นต์ %</label>
<input type="text" id="input-label" class="ti-form-input w-auto" value="10.0">
<input type="text" id="input-label" class="ti-form-input w-auto" oninput="value = value.replace(/[^0-9]/g, '');" [(ngModel)]="selectJob.allPositionWorkPercent">
</div>
</div>
<div class="flex space-x-4 justify-center">
<!-- label และ textarea แรก -->
<div class="flex flex-col w-full">
<label for="input-label" class="ti-form-label mt-2rem">อื่นๆ</label>
<textarea id="input-label" class="ti-form-input w-80" rows="4" cols="50"></textarea>
<textarea id="input-label" class="ti-form-input w-80" rows="4" cols="50" [(ngModel)]="selectJob.otherWorkText"></textarea>
</div>
<!-- label และ input ที่สอง -->
<div class="flex flex-col w-1/2">
<label for="input-label" class="ti-form-label mt-2rem">เปอร์เซ็นต์ %</label>
<input type="text" id="input-label" class="ti-form-input w-auto" value="10.0">
<input type="text" id="input-label" class="ti-form-input w-auto" oninput="value = value.replace(/[^0-9]/g, '');" [(ngModel)]="selectJob.otherWorkPercent" >
</div>
</div>
<div class="flex justify-end mt-3rem mb-1rem space-x-4">
<div class="flex justify-end mt-2rem mb-1rem">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#work-detail-modal-edit">
data-hs-overlay="#sub-job-competency-component-modal-edit">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#work-detail-alert-add-modal">
data-hs-overlay="#company-registration-page-alert-modal">
บันทึกข้อมูล
</a>
</div>
</div>
</div>
</div>
</div>
<div id="work-detail-alert-add-modal" class="hs-overlay hidden ti-modal">
<div id="company-registration-page-alert-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
<div class="max-h-full overflow-hidden ti-modal-content w-full">
<div class="ti-modal-header">
......@@ -333,7 +286,7 @@
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#work-detail-alert-add-modal">
data-hs-overlay="#company-registration-page-alert-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
......@@ -341,57 +294,73 @@
</div>
<div class="ti-modal-body ">
<p class="mt-1 text-gray-800 dark:text-white/70">
<ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'">
ยืนยันการบันทึกข้อมูลหรือไม่
</ng-container>
<ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'">
ยืนยันการลบข้อมูลหรือไม่
</ng-container>
</p>
<div class="flex justify-end mt-2rem mb-1rem">
<ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#work-detail-modal-edit">
data-hs-overlay="#company-registration-page-alert-modal">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#work-detail-alert-add-modal" (click)="addBu1();showSuccessAdd()">
data-hs-overlay="#company-registration-page-alert-modal" (click)="save()">
บันทึกข้อมูล
</a>
</div>
</div>
</div>
</div>
</div>
<div id="work-detail-alert-delete-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
<div class="max-h-full overflow-hidden ti-modal-content w-full">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
แจ้งเตือน
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#work-detail-alert-delete-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div>
</div>
<div class="ti-modal-body ">
<p class="mt-1 text-gray-800 dark:text-white/70">
ยืนยันการลบข้อมูลหรือไม่!
</p>
<div class="flex justify-end mt-2rem mb-1rem">
</ng-container>
<ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#work-detail-alert-delete-modal">
data-hs-overlay="#company-registration-page-alert-modal">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#work-detail-alert-delete-modal"
(click)="addBu1();showSuccessDelete()">
<a class="ti-btn ti-btn-danger" href="javascript:void(0);"
data-hs-overlay="#company-registration-page-alert-modal" (click)="deleteJob()">
ลบข้อมูล
</a>
</ng-container>
</div>
</div>
</div>
</div>
</div>
<div id="supjob-upload-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out rounded-md">
<div class="ti-modal-header bg-primary !rounded-none !rounded-t-sm">
<h5 class="text-xxl font-bold text-white">
นำเข้า Job Competency
</h5>
</div>
<div class="ti-modal-body max-h-full overflow-hidden ti-modal-content !rounded-t-none !rounded-b-sm">
<h1 class="mt-2" style="text-align: center;">ไฟล์</h1>
<div class="mt-2 p-2">
<div class="flex rounded-md">
<input #fileInput id="fileInput" type="file" (change)="onFileSelected($event)" hidden>
<input type="text" [value]="selectedFileName" readonly (click)="fileInput.click()"
class="ti-form-input rounded-none ltr:rounded-l-md rtl:rounded-r-md focus:z-10 cursor-pointer">
<button type="button" (click)="fileInput.click()"
class="inline-flex flex-shrink-0 justify-center items-center h-[2.875rem] w-[2.875rem] ltr:rounded-r-md rtl:rounded-l-md border border-transparent font-semibold bg-secondary text-white hover:bg-secondary focus:z-10 focus:outline-none focus:ring-0 focus:ring-secondary transition-all text-sm">
<i class="ti ti-upload"></i>
</button>
</div>
<div class="flex justify-center mt-2rem mb-1rem space-x-4">
<button type="submit" class="ti-btn ti-btn-secondary"
data-hs-overlay="#section-registration-upload-modal" (click)="uploadFile()"
[class.ti-btn-disabled]="!selectedFile" [disabled]="!selectedFile">
อัปโหลด
</button>
</div>
</div>
</div>
</div>
</div>
import { Component } from '@angular/core';
import { ChangeDetectorRef, Component} from '@angular/core';
import { ToastrService } from 'ngx-toastr';
import { JobModel, MyJobModel } from 'src/app/shared/model/job.model';
import { JobCodeModel, MyJobCodeModel } from 'src/app/shared/model/job-code.model';
import { FileService } from 'src/app/shared/services/file.service';
import { JobCodeService } from 'src/app/shared/services/job-code.service';
@Component({
selector: 'app-work-detail',
......@@ -10,62 +14,158 @@ import { JobModel, MyJobModel } from 'src/app/shared/model/job.model';
export class WorkDetailComponent {
currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1);
jobList: JobModel[] = []
job: JobModel = new MyJobModel({})
pageSize=10
search = ""
jobCodeList:JobCodeModel[]=[]
loading = false
selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์';
selectJob:JobCodeModel=new MyJobCodeModel({})
modalStatus=''
constructor(
private toastr: ToastrService
private toastr: ToastrService,
private fileService: FileService,
private jobcodeService: JobCodeService,
private cdr: ChangeDetectorRef,
) { }
ngOnInit(): void {
this.getListJob();
}
getListJob(){
this.loading = false
this.jobcodeService.getList().subscribe({
next: response => {
this.jobCodeList = response.map((x: any) => new MyJobCodeModel(x))
this.jobCodeList = this.jobCodeList.sort((a, b) => a.jobcodeId.localeCompare(b.jobcodeId))
this.loading = false
this.searchChange()
this.cdr.detectChanges()
}, error: error => {
this.loading = false
this.cdr.detectChanges()
}
})
}
searchChange() {
this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.jobListFilter().length / 10) }, (_, i) => i + 1);
this.page = Array.from({ length: Math.ceil(this.jobcodeFilter().length / this.pageSize) }, (_, i) => i + 1);
}
edit(item :JobCodeModel){
this.selectJob = new MyJobCodeModel({})
this.selectJob = new MyJobCodeModel(item)
}
jobListFilter() {
return this.jobList.filter(x => x.jobid.includes(this.search) ||
x.tdesc.includes(this.search) ||
x.edesc.includes(this.search))
clearValue(){
this.selectJob.competencyWorkText = ''
this.selectJob.serviceWorkText=''
this.selectJob.serviceWorkPercent = 0
this.selectJob.responsibleWorkText =''
this.selectJob.responsibleWorkPercent = 0
this.selectJob.specialWorkText =''
this.selectJob.specialWorkPercent = 0
this.selectJob.allPositionWorkText =''
this.selectJob.allPositionWorkPercent = 0
this.selectJob.otherWorkText=''
this.selectJob.otherWorkPercent = 0
}
selectJob(job: JobModel) {
// this.showSuccess()
this.job = new MyJobModel(job)
toNumber(value: string | number): number {
return typeof value === 'string' ? parseInt(value) : value;
}
save(){
this.selectJob.serviceWorkPercent = this.toNumber(this.selectJob.serviceWorkPercent)
this.selectJob.responsibleWorkPercent = this.toNumber(this.selectJob.responsibleWorkPercent)
this.selectJob.specialWorkPercent = this.toNumber(this.selectJob.specialWorkPercent)
this.selectJob.allPositionWorkPercent = this.toNumber(this.selectJob.allPositionWorkPercent)
this.selectJob.otherWorkPercent = this.toNumber(this.selectJob.otherWorkPercent)
showSuccessAdd() {
this.toastr.success('บันทึกข้อมูลสำเร็จ', 'เเจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
this.jobcodeService.post(this.selectJob).subscribe((response:any) => {
if (response.success) {
this.showAlert(response.message, 'success')
this.selectJob = new MyJobCodeModel({})
this.getListJob();
} else {
this.showAlert(response.message, 'error')
}
this.cdr.detectChanges()
})
}
deleteJob(){
this.jobcodeService.delete(this.selectJob).subscribe((response:any) => {
if (response.success) {
this.showAlert(response.message, 'success')
this.selectJob = new MyJobCodeModel({})
this.getListJob();
} else {
this.showAlert(response.message, 'error')
}
this.cdr.detectChanges()
})
}
jobcodeFilter() {
return this.jobCodeList.filter(x =>
x.tdesc.toLowerCase().includes(this.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.search.toLowerCase()) ||
x.jobcodeId.toLowerCase().includes(this.search.toLowerCase())
)
}
onFileSelected(event: any) {
this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์"
}
showSuccessEdit() {
this.toastr.success('เเก้ไขข้อมูลสำเร็จ', 'เเจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
uploadFile() {
if (!this.selectedFile) {
alert('กรุณาเลือกไฟล์ก่อนอัปโหลด')
return
}
const formData = new FormData();
formData.append('file', this.selectedFile);
this.loading = true
this.fileService.uploadExcel(formData, 'MJOBCODE_COMPETENCY').subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getListJob();
} else {
this.showAlert(response.message, 'error')
this.loading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.loading = false
}
})
}
showSuccessDelete() {
this.toastr.success('ลบข้อมูลสำเร็จ', 'เเจ้งเตือน', {
downloadFile() {
const fileName = 'IMPORT_MJOBCODEV2.xlsx'
this.fileService.downloadTemplate(fileName).subscribe({
next: response => {
const url = window.URL.createObjectURL(response);
const a = document.createElement("a");
a.href = url;
a.download = fileName;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, error: error => {
this.showAlert(error.message, 'error')
}
})
}
showAlert(text: string, type: 'success' | 'error') {
this.toastr[type](text, 'แจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
}
addBu1() {
// this.bu1Service.post(this.bu1).subscribe((response:any) => {
// if (response.success) {
// this.getBu1List()
// }
// })
}
deleteJob(job: JobModel) {
// this.bu1Service.delete(new MyBu1Model(bu1)).subscribe((response:any) => {
// if (response.success) {
// this.getBu1List()
// }
// })
})
}
}
......@@ -34,6 +34,16 @@ export interface JobCodeModel {
supervisor: string
competencyWorkText: string
supervisorPosition:PositionModel
serviceWorkText: string
serviceWorkPercent: number
responsibleWorkText: string
responsibleWorkPercent: number
specialWorkText: string
specialWorkPercent: number
allPositionWorkText: string
allPositionWorkPercent: number
otherWorkText: string
otherWorkPercent: number
}
export class MyJobCodeModel implements JobCodeModel {
......@@ -62,6 +72,16 @@ export class MyJobCodeModel implements JobCodeModel {
supervisor: string
competencyWorkText: string
supervisorPosition:PositionModel
serviceWorkText: string
serviceWorkPercent: number
responsibleWorkText: string
responsibleWorkPercent: number
specialWorkText: string
specialWorkPercent: number
allPositionWorkText: string
allPositionWorkPercent: number
otherWorkText: string
otherWorkPercent: number
constructor(data: Partial<JobCodeModel>) {
this.jobcodeId = data.jobcodeId || ""
this.tdesc = data.tdesc || ""
......@@ -88,7 +108,16 @@ export class MyJobCodeModel implements JobCodeModel {
this.supervisor = data.supervisor || ""
this.competencyWorkText = data.competencyWorkText || ""
this.supervisorPosition = new MyPositionModel(data.supervisorPosition || {})
this.serviceWorkText = data.serviceWorkText || ""
this.serviceWorkPercent = data.serviceWorkPercent ?? 0
this.responsibleWorkText = data.responsibleWorkText || ""
this.responsibleWorkPercent = data.responsibleWorkPercent ?? 0
this.specialWorkText = data.specialWorkText || ""
this.specialWorkPercent = data.specialWorkPercent ?? 0
this.allPositionWorkText = data.allPositionWorkText || ""
this.allPositionWorkPercent = data.allPositionWorkPercent ?? 0
this.otherWorkText = data.otherWorkText || ""
this.otherWorkPercent = data.otherWorkPercent ?? 0
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment