Commit 5e6ea45f by DESKTOP-E0VCCBD\zedan

update

parent 3f575b1c
...@@ -81,6 +81,12 @@ export const companyRoutes: Routes = [ ...@@ -81,6 +81,12 @@ export const companyRoutes: Routes = [
loadComponent: () => loadComponent: () =>
import('./emp-borrow-manage/emp-borrow-manage.component').then((m) => m.EmpBorrowManageComponent) import('./emp-borrow-manage/emp-borrow-manage.component').then((m) => m.EmpBorrowManageComponent)
}, },
{
path:'company/emp-borrowrepair',
loadComponent: () =>
import('./emp-borrow-repair/emp-borrow-repair.component').then((m) => m.EmpBorrowRepairComponent)
},
{ {
path:'company/emp-transaction', path:'company/emp-transaction',
loadComponent: () => loadComponent: () =>
......
<app-page-header <app-page-header
[title]="'อนุมัติการคืนอุปกรณ์'" [title]="'จัดการอุปการณ์ ซ่อม-ชำรุด'"
[activeTitle]="'ผู้ดูแลระบบ'" [activeTitle]="'ผู้ดูแลระบบ'"
[title1]="'อนุมัติการคืนอุปกรณ์'" [title1]="'จัดการอุปการณ์ ซ่อม-ชำรุด'"
></app-page-header> ></app-page-header>
<div class="grid grid-cols-12 gap-x-6"> <div class="grid grid-cols-12 gap-x-6">
...@@ -17,49 +17,6 @@ ...@@ -17,49 +17,6 @@
</div> </div>
<!-- แท็บสถานะ --> <!-- แท็บสถานะ -->
<div class="flex flex-wrap gap-2"> <div class="flex flex-wrap gap-2">
<!-- สถานะทั้งหมด -->
<div>
<button
class="px-4 py-2 rounded-full border text-sm font-medium bg-blue-100 text-blue-800 border-blue-200"
(click)="selectedStatus = '!requested,!rejected'; applyFilter()"
>
ทั้งหมด
</button>
</div>
<div>
<button
class="px-4 py-2 rounded-full border text-sm font-medium bg-warning/10 text-warning border-warning/20"
(click)="selectedStatus = 'approved'; applyFilter()"
>
รอคืนอุปกรณื
</button>
</div>
<!-- <div>
<button
class="px-4 py-2 rounded-full border text-sm font-medium bg-success/10 text-success border-success/20"
(click)="filterByStatus('approved')"
>
อนุมัติแล้ว
</button>
</div> -->
<div>
<button
class="px-4 py-2 rounded-full border text-sm font-medium bg-info/10 text-info border-info/20"
(click)="selectedStatus = 'returned'; applyFilter()"
>
คืนแล้ว
</button>
</div>
<!-- <div>
<button
class="px-4 py-2 rounded-full border text-sm font-medium bg-danger/10 text-danger border-danger/20"
(click)="filterByStatus('rejected')"
>
ไม่อนุมัติ
</button>
</div> -->
</div>
<div class="flex flex-wrap gap-2">
<div> <div>
<input <input
[(ngModel)]="searchTerm" [(ngModel)]="searchTerm"
...@@ -81,8 +38,7 @@ ...@@ -81,8 +38,7 @@
<th scope="col" class="text-start">อุปกรณ์ที่ยืม</th> <th scope="col" class="text-start">อุปกรณ์ที่ยืม</th>
<th scope="col" class="text-start">พนักงาน</th> <th scope="col" class="text-start">พนักงาน</th>
<th scope="col" class="text-start">จำนวน</th> <th scope="col" class="text-start">จำนวน</th>
<th scope="col" class="text-start">วันที่ยืม</th> <th scope="col" class="text-start">วันที่ส่งซ่อม</th>
<th scope="col" class="text-start">วันที่คืน</th>
<th scope="col" class="text-start">สถานะ</th> <th scope="col" class="text-start">สถานะ</th>
<th scope="col" class="text-start">ผู้อนุมัติ</th> <th scope="col" class="text-start">ผู้อนุมัติ</th>
<th scope="col" class="text-start">การดำเนินการ</th> <th scope="col" class="text-start">การดำเนินการ</th>
...@@ -105,21 +61,18 @@ ...@@ -105,21 +61,18 @@
</td> </td>
<td>{{ product.quantity_borrowed }}</td> <td>{{ product.quantity_borrowed }}</td>
<td>{{ product.created_at | date : "dd/MM/yyyy HH:mm" }}</td> <td>{{ product.created_at | date : "dd/MM/yyyy HH:mm" }}</td>
<td>
@if(product.returned_date) {
{{ product.returned_date | date : "dd/MM/yyyy HH:mm" }}
}
</td>
<td> <td>
<span <span
class="badge" class="badge"
[ngClass]="{ [ngClass]="{
'bg-warning/10 text-warning': 'bg-warning/10 text-warning':
product.status === 'approved', product.status === 'repair',
'bg-danger/10 text-danger': 'bg-danger/10 text-danger':
product.status === 'rejected', product.status === 'rejected',
'bg-info/10 text-info': 'bg-info/10 text-info':
product.status === 'returned', product.status === 'returned',
}" }"
> >
{{ getStatusText(product.status) }} {{ getStatusText(product.status) }}
...@@ -131,7 +84,7 @@ ...@@ -131,7 +84,7 @@
<div class="flex gap-1"> <div class="flex gap-1">
<!-- ปุ่มอนุมัติการคืน --> <!-- ปุ่มอนุมัติการคืน -->
@if(product.project_equipment?.equipment?.is_returnable && @if(product.project_equipment?.equipment?.is_returnable &&
product.status === 'approved' && !product.returned_date) { product.status === 'repair' && !product.returned_date) {
<button <button
aria-label="อนุมัติการคืน" aria-label="อนุมัติการคืน"
(click)="view(product)" (click)="view(product)"
...@@ -141,29 +94,6 @@ ...@@ -141,29 +94,6 @@
<i class="ri-check-line"></i> <i class="ri-check-line"></i>
</button> </button>
} }
<!-- ปุ่มแจ้งซ่อม -->
@if(product.project_equipment?.equipment?.is_returnable &&
(product.status === 'returned' || product.status ===
'returned')) {
<button
aria-label="แจ้งซ่อม"
(click)="reportRepair(product)"
class="ti-btn ti-btn-sm ti-btn-warning"
>
<i class="ri-tools-line"></i>
</button>
} @if(product.status === 'approved' || product.status ===
'returned'){
<button
aria-label="รายละเอียด"
(click)="view(product)"
class="ti-btn ti-btn-sm ti-btn-light me-[0.375rem]"
data-hs-overlay="#detail-borrow"
>
<i class="fe fe-eye"></i>
</button>
}
</div> </div>
</td> </td>
</tr> </tr>
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<div> <div>
<button <button
class="px-4 py-2 rounded-full border text-sm font-medium bg-blue-100 text-blue-800 border-blue-200" class="px-4 py-2 rounded-full border text-sm font-medium bg-blue-100 text-blue-800 border-blue-200"
(click)="selectedStatus = '!requested,!rejected'; applyFilter()" (click)="selectedStatus = '!requested,!rejected,!remove,!repair'; applyFilter()"
> >
ทั้งหมด ทั้งหมด
</button> </button>
...@@ -143,17 +143,19 @@ ...@@ -143,17 +143,19 @@
} }
<!-- ปุ่มแจ้งซ่อม --> <!-- ปุ่มแจ้งซ่อม -->
@if(product.project_equipment?.equipment?.is_returnable && <!-- @if(product.project_equipment?.equipment?.is_returnable &&
(product.status === 'returned' || product.status === (product.status === 'returned' || product.status ===
'returned')) { 'returned')) {
<button <button
aria-label="แจ้งซ่อม" aria-label="แจ้งซ่อม"
(click)="reportRepair(product)" data-hs-overlay="#modal-repair"
(click)="view(product)"
class="ti-btn ti-btn-sm ti-btn-warning" class="ti-btn ti-btn-sm ti-btn-warning"
> >
<i class="ri-tools-line"></i> <i class="ri-tools-line"></i>
</button> </button>
} @if(product.status === 'approved' || product.status === } -->
@if(product.status === 'approved' || product.status ===
'returned'){ 'returned'){
<button <button
aria-label="รายละเอียด" aria-label="รายละเอียด"
...@@ -288,6 +290,100 @@ ...@@ -288,6 +290,100 @@
</div> </div>
</div> </div>
</div> </div>
<!-- Start:: New Deal -->
<div id="modal-repair" class="hs-overlay hidden ti-modal" *ngIf="selectModel">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out">
<div class="ti-modal-content">
<div class="ti-modal-header">
<h6
class="modal-title text-[1rem] font-semibold text-defaulttextcolor"
id="mail-ComposeLabel"
>
ซ่อม/ซำรุด
</h6>
<button
type="button"
class="hs-dropdown-toggle !text-[1rem] !font-semibold !text-defaulttextcolor"
data-hs-overlay="#modal-repair"
>
<span class="sr-only">Close</span>
<i class="ri-close-line"></i>
</button>
</div>
<div class="ti-modal-body px-4">
<div class="xl:col-span-12 col-span-12">
<img
[src]="selectModel.equipment.getPicture()"
class="!rounded-t-md"
alt="..."
style="width: 100%; height: auto; object-fit: cover"
/>
</div>
<div class="grid grid-cols-12 gap-4">
<div class="xl:col-span-12 col-span-12">
<label for="deal-name" class="form-label">ชื่ออุปกรณ์</label>
<input
readonly
type="text"
class="form-control"
id="deal-name"
placeholder="ชื่ออุปกรณ์"
[(ngModel)]="selectedBorrowItem.project_equipment.equipment.equipmentName"
/>
</div>
<div class="xl:col-span-12 col-span-12">
<label for="input-label" class="form-label">{{
"สถานะ" | translate
}}</label>
<!-- <ng-select [items]="customerList" bindLabel="companyThName" [(ngModel)]="projectModel.customer">
</ng-select> -->
<select class="mb-4 sm:mb-0 form-select !py-3" id="inlineFormSelectPref"
[(ngModel)]="borrowSelect.status">
<option ngValue="repair" selected>ส่งซ่อม</option>
<option ngValue="remove" selected>นำอุปกรณ์ออก</option>
</select>
<!-- <select class="mb-4 sm:mb-0 form-select !py-3" id="inlineFormSelectPref"
[(ngModel)]="projectModel.customer">
<option [ngValue]="null" selected>-</option>
<option *ngFor="let item of customerList" [ngValue]="item">{{item.getCompanyName()}}</option>
</select> -->
</div>
<div class="xl:col-span-12 col-span-12">
<label for="deal-name" class="form-label">จำนวน</label>
<input
type="number"
class="form-control"
id="deal-name"
placeholder="จำนวนที่ชำรุด"
[(ngModel)]="selectedBorrowItem.quantity_borrowed"
/>
</div>
</div>
</div>
<div class="ti-modal-footer">
<button
#closeModalStock
type="button"
class="hs-dropdown-toggle ti-btn ti-btn-light align-middle"
data-hs-overlay="#modal-repair"
>
ยกเลิก
</button>
<button
type="button"
class="ti-btn bg-primary text-white !font-medium"
(click)="saveRepair()"
>
บันทึก
</button>
</div>
</div>
</div>
</div>
<div <div
id="detail-borrow" id="detail-borrow"
class="hs-overlay hidden ti-modal" class="hs-overlay hidden ti-modal"
......
...@@ -62,6 +62,8 @@ export class EmpBorrowReturnStatusComponent { ...@@ -62,6 +62,8 @@ export class EmpBorrowReturnStatusComponent {
borrowSelect: BorrowTransactionsModel = new BorrowTransactionsModel() borrowSelect: BorrowTransactionsModel = new BorrowTransactionsModel()
filteredList: any[] = []; filteredList: any[] = [];
pageIndex = 0; pageIndex = 0;
damagedQuantity: number = 0;
quantityExceeded: boolean = false;
member: UserProfileModel; member: UserProfileModel;
get searchTerm(): string { get searchTerm(): string {
return this._searchTerm; return this._searchTerm;
...@@ -81,7 +83,7 @@ export class EmpBorrowReturnStatusComponent { ...@@ -81,7 +83,7 @@ export class EmpBorrowReturnStatusComponent {
isEdit = false; isEdit = false;
empList: ProjectMemberModel[] = [] empList: ProjectMemberModel[] = []
hisList: BorrowTransactionsModel[] = []; hisList: BorrowTransactionsModel[] = [];
selectedStatus: string = '!requested,!rejected'; selectedStatus: string = '!requested,!rejected,!remove,!repair';
isProcessing = false; isProcessing = false;
constructor( constructor(
private http: HttpClient, private http: HttpClient,
...@@ -330,66 +332,37 @@ export class EmpBorrowReturnStatusComponent { ...@@ -330,66 +332,37 @@ export class EmpBorrowReturnStatusComponent {
} }
}); });
} }
reportRepair(item: BorrowTransactionsModel): void {
swal({
title: "แจ้งซ่อมอุปกรณ์",
text: `คุณต้องการแจ้งซ่อมอุปกรณ์ ${item.project_equipment?.equipment?.equipmentName} หรือไม่?`,
content: {
element: this.createRepairForm(item.quantity_borrowed) // << ส่งจำนวนยืมเข้าไป
},
icon: "warning",
buttons: ["ยกเลิก", "แจ้งซ่อม"],
}).then((confirmed) => {
if (confirmed) {
const description = (document.getElementById("repairDescription") as HTMLInputElement).value;
const quantity = +(document.getElementById("repairQuantity") as HTMLInputElement).value;
if (!description || quantity <= 0) {
swal("กรุณากรอกข้อมูลให้ครบถ้วน", "", "error");
return;
}
const repairData = {
borrowTransactionId: item.borrowId,
equipmentId: item.project_equipment?.equipment?.equipmentId,
reportedBy: this.tokenService.getUser().member.memberId,
description: `${description} (จำนวน ${quantity})`,
status: 'pending'
};
const updateBorrowData = {
status: 'repairing'
};
// เรียก service เพื่อบันทึกการแจ้งซ่อม... saveRepair() {
} // console.log(this.selectStock)
}); swal({
title: "Are you sure?",
text: "คุณต้องการบันทึกหรือไม่",
icon: "warning",
dangerMode: false,
buttons: ["Cancel", "Confirm"],
})
.then((willDelete: any) => {
if (willDelete) {
this.borrowTransactionsService.save({
"peId": this.selectModel.peId,
"quantity_borrowed": this.borrowSelect.quantity_borrowed,
"status": this.borrowSelect.status,
"memberId": this.tokenService.getUser().member.memberId,
"approved_by": this.tokenService.getUser().member.memberId
}).subscribe(result => {
swal("Save Success!!", "บันทึกข้อมูลสำเร็จ", "success");
this.ngOnInit()
this.closeModalStock?.nativeElement.click()
}, (error: any) => {
swal("Fail!!", error.error.detail, "info");
})
} }
private createRepairForm(defaultQuantity: number): HTMLElement { });
const wrapper = document.createElement("div");
const qtyInput = document.createElement("input");
qtyInput.id = "repairQuantity";
qtyInput.placeholder = "จำนวนที่แจ้งซ่อม";
qtyInput.type = "number";
qtyInput.min = "1";
qtyInput.className = "swal-content__input";
qtyInput.style.marginTop = "10px";
qtyInput.value = defaultQuantity?.toString() || '1';
const descInput = document.createElement("input");
descInput.id = "repairDescription";
descInput.placeholder = "ระบุอาการเสีย/ปัญหาที่พบ";
descInput.type = "text";
descInput.className = "swal-content__input";
wrapper.appendChild(descInput);
wrapper.appendChild(qtyInput);
return wrapper;
} }
updatePagedItems() { updatePagedItems() {
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<div> <div>
<button <button
class="px-4 py-2 rounded-full border text-sm font-medium bg-blue-100 text-blue-800 border-blue-200" class="px-4 py-2 rounded-full border text-sm font-medium bg-blue-100 text-blue-800 border-blue-200"
(click)="selectedStatus = '!returned'; applyFilter()" (click)="selectedStatus = '!returned,!remove,!repair'; applyFilter()"
> >
ทั้งหมด ทั้งหมด
</button> </button>
......
...@@ -68,7 +68,7 @@ export class EmpBorrowStatusComponent { ...@@ -68,7 +68,7 @@ export class EmpBorrowStatusComponent {
isEdit = false; isEdit = false;
empList: ProjectMemberModel[] = [] empList: ProjectMemberModel[] = []
hisList: BorrowTransactionsModel [] = []; hisList: BorrowTransactionsModel [] = [];
selectedStatus: string = '!returned'; selectedStatus: string = '!returned,!remove,!repair';
constructor( constructor(
private http: HttpClient, private http: HttpClient,
private eqService: EquipmentService, private eqService: EquipmentService,
......
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
<!--Header Notifictaion --> <!--Header Notifictaion -->
<!-- <div <div
class="header-element py-[1rem] md:px-[0.65rem] px-2 notifications-dropdown header-notification hs-dropdown ti-dropdown !hidden md:!block [--placement:bottom-left]"> class="header-element py-[1rem] md:px-[0.65rem] px-2 notifications-dropdown header-notification hs-dropdown ti-dropdown !hidden md:!block [--placement:bottom-left]">
<button id="dropdown-notification" type="button" <button id="dropdown-notification" type="button"
class="hs-dropdown-toggle relative ti-dropdown-toggle !p-0 !border-0 flex-shrink-0 !rounded-full !shadow-none align-middle text-xs"> class="hs-dropdown-toggle relative ti-dropdown-toggle !p-0 !border-0 flex-shrink-0 !rounded-full !shadow-none align-middle text-xs">
...@@ -72,10 +72,10 @@ ...@@ -72,10 +72,10 @@
<div class="ti-dropdown-header !m-0 !p-4 !bg-transparent flex justify-between items-center"> <div class="ti-dropdown-header !m-0 !p-4 !bg-transparent flex justify-between items-center">
<p <p
class="mb-0 text-[1.0625rem] text-defaulttextcolor font-semibold dark:text-[#8c9097] dark:text-white/50"> class="mb-0 text-[1.0625rem] text-defaulttextcolor font-semibold dark:text-[#8c9097] dark:text-white/50">
Notifications</p> แจ้งเตือน</p>
<span <span
class="text-[0.75em] py-[0.25rem/2] px-[0.45rem] font-[600] rounded-sm bg-secondary/10 text-secondary" class="text-[0.75em] py-[0.25rem/2] px-[0.45rem] font-[600] rounded-sm bg-secondary/10 text-secondary"
id="notifiation-data">{{ notificationCount }} Unread</span> id="notifiation-data">{{ notificationCount }} รายการ</span>
</div> </div>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<ul class="list-none !m-0 !p-0 end-0" id="header-notification-scroll" (click)="handleCardClick($event)"> <ul class="list-none !m-0 !p-0 end-0" id="header-notification-scroll" (click)="handleCardClick($event)">
...@@ -225,7 +225,7 @@ ...@@ -225,7 +225,7 @@
</div> </div>
</div> </div>
</div> </div>
</div> --> </div>
<!--End Header Notifictaion --> <!--End Header Notifictaion -->
<!-- Related Apps --> <!-- Related Apps -->
......
...@@ -152,7 +152,7 @@ export class NavService implements OnDestroy { ...@@ -152,7 +152,7 @@ export class NavService implements OnDestroy {
{ headTitle: 'จัดการโครงการ' }, { headTitle: 'จัดการโครงการ' },
{ {
icon: 'home', icon: 'home',
path: '/company/home', path: '/company/home/:projectId',
title: 'หน้าแรก', title: 'หน้าแรก',
type: 'link', type: 'link',
selected: false, selected: false,
...@@ -192,7 +192,7 @@ export class NavService implements OnDestroy { ...@@ -192,7 +192,7 @@ export class NavService implements OnDestroy {
active: false, active: false,
Menusub: true, Menusub: true,
children: [ children: [
{ path: '/company/emp-borrow-status', title: 'อุปกรณ์ที่ซ่อม/ชำรุด', type: 'link' }, { path: '/company/emp-borrowrepair', title: 'อุปกรณ์ที่ซ่อม/ชำรุด', type: 'link' },
], ],
}, },
]; ];
...@@ -204,6 +204,15 @@ export class NavService implements OnDestroy { ...@@ -204,6 +204,15 @@ export class NavService implements OnDestroy {
{ headTitle: 'จัดการบริษัท' }, { headTitle: 'จัดการบริษัท' },
// { headTitle: 'User Management' } // { headTitle: 'User Management' }
{ {
icon: 'home',
path: '/company/home/:projectId',
title: 'หน้าแรก',
type: 'link',
selected: false,
Menusub: true,
active: false,
},
{
title: 'หน้าทำรายการ', title: 'หน้าทำรายการ',
icon: 'time', icon: 'time',
type: 'sub', type: 'sub',
......
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