Commit fafe75a4 by Ooh-Ao

add borrow

parent 4c4314e6
...@@ -4,12 +4,12 @@ from typing import Optional ...@@ -4,12 +4,12 @@ from typing import Optional
from datetime import datetime from datetime import datetime
class BorrowTransactionBase(BaseModel): class BorrowTransactionBase(BaseModel):
# peId: UUID peId: Optional[UUID] = None
quantity_borrowed: int quantity_borrowed: int
status: str = "borrowed" # เช่น requested, borrowed, returned status: str = "borrowed" # เช่น requested, borrowed, returned
returned_date: Optional[datetime] = None returned_date: Optional[datetime] = None
memberId: UUID memberId: UUID
# approved_by: UUID approved_by : Optional[UUID] = None
class BorrowTransactionCreate(BorrowTransactionBase): class BorrowTransactionCreate(BorrowTransactionBase):
peId: UUID peId: UUID
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
class="badge bg-light text-default rounded-full ms-1 text-[0.75rem] align-middle">{{itemsList.length}}</span> class="badge bg-light text-default rounded-full ms-1 text-[0.75rem] align-middle">{{itemsList.length}}</span>
</div> </div>
<div class="flex flex-wrap gap-2"> <div class="flex flex-wrap gap-2">
<a href="javascript:void(0);" class="hs-dropdown-toggle ti-btn ti-btn-primary-full me-2" (click)="new()" <a href="javascript:void(0);" class="hs-dropdown-toggle ti-btn ti-btn-primary-full me-2"
data-hs-overlay="#modal-detail"><i class="ri-add-line font-semibold align-middle"></i>{{ 'เพิ่ม' | data-hs-overlay="#modal-detail"><i class="ri-add-line font-semibold align-middle"></i>{{ 'เพิ่ม' |
translate}} translate}}
</a> </a>
...@@ -66,20 +66,18 @@ ...@@ -66,20 +66,18 @@
<button type="button" class="ti-btn ti-btn-primary btn-wave waves-effect waves-light">Place Bid</button> <button type="button" class="ti-btn ti-btn-primary btn-wave waves-effect waves-light">Place Bid</button>
</div> --> </div> -->
</div> </div>
<!-- <div class="box-footer border-block-start-dashed dark:border-defaultborder/10 text-center"> <div class="box-footer border-block-start-dashed dark:border-defaultborder/10 text-center">
<div class="btn-list"> <div class="btn-list">
<div class="btn-list"> <div class="btn-list">
<button type="button" aria-label="button" data-hs-overlay="#modal-detail" (click)="view(item)"
class="ti-btn ti-btn-sm ti-btn-primary me-[0.375rem]"><i class="ri-edit-line"></i></button>
<button data-hs-overlay="#modal-stock" type="button" aria-label="button" (click)="viewStock(item);" <button data-hs-overlay="#modal-stock" type="button" aria-label="button" (click)="viewStock(item);"
class="ti-btn ti-btn-sm ti-btn-warning me-[0.375rem]"> class="ti-btn ti-btn-sm ti-btn-warning me-[0.375rem]">
<i class="ri-store-line"></i> <i class="ri-store-line"></i>
</button> </button>
<button (click)="delete(item)" type="button" aria-label="button" <button type="button" aria-label="button"
class="ti-btn ti-btn-sm ti-btn-danger me-0"><i class="ri-delete-bin-line"></i></button> class="ti-btn ti-btn-sm ti-btn-danger me-0"><i class="ri-time-line"></i></button>
</div>
</div> </div>
</div> </div>
</div> -->
</div> </div>
</div> </div>
} }
...@@ -92,7 +90,7 @@ ...@@ -92,7 +90,7 @@
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out lg:!max-w-4xl lg:w-full m-3 lg:!mx-auto"> <div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out lg:!max-w-4xl lg:w-full m-3 lg:!mx-auto">
<div class="ti-modal-content"> <div class="ti-modal-content">
<div class="ti-modal-header"> <div class="ti-modal-header">
<h6 class="modal-title text-[1rem] font-semibold text-defaulttextcolor" id="mail-ComposeLabel">ข้อมูลอุปกรณ์ <h6 class="modal-title text-[1rem] font-semibold text-defaulttextcolor" id="mail-ComposeLabel">นำเข้าอุปกรณ์
</h6> </h6>
<button type="button" class="hs-dropdown-toggle !text-[1rem] !font-semibold !text-defaulttextcolor" <button type="button" class="hs-dropdown-toggle !text-[1rem] !font-semibold !text-defaulttextcolor"
data-hs-overlay="#modal-detail"> data-hs-overlay="#modal-detail">
...@@ -185,11 +183,11 @@ ...@@ -185,11 +183,11 @@
<!-- Start:: New Deal --> <!-- Start:: New Deal -->
<div id="modal-stock" class="hs-overlay hidden ti-modal" *ngIf="selectStock"> <div id="modal-stock" class="hs-overlay hidden ti-modal" *ngIf="selectModel">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out"> <div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out">
<div class="ti-modal-content"> <div class="ti-modal-content">
<div class="ti-modal-header"> <div class="ti-modal-header">
<h6 class="modal-title text-[1rem] font-semibold text-defaulttextcolor" id="mail-ComposeLabel">ข้อมูลอุปกรณ์ <h6 class="modal-title text-[1rem] font-semibold text-defaulttextcolor" id="mail-ComposeLabel">การยืม/ข้อมูลอุปกรณ์
</h6> </h6>
<button type="button" class="hs-dropdown-toggle !text-[1rem] !font-semibold !text-defaulttextcolor" <button type="button" class="hs-dropdown-toggle !text-[1rem] !font-semibold !text-defaulttextcolor"
data-hs-overlay="#modal-stock"> data-hs-overlay="#modal-stock">
...@@ -200,46 +198,46 @@ ...@@ -200,46 +198,46 @@
<div class="ti-modal-body px-4"> <div class="ti-modal-body px-4">
<div class="grid grid-cols-12 gap-4"> <div class="grid grid-cols-12 gap-4">
<div class="xl:col-span-12 col-span-12"> <div class="xl:col-span-12 col-span-12">
<img [src]="selectModel.getPicture()" class="!rounded-t-md" alt="..." <img [src]="selectModel.equipment.getPicture()" class="!rounded-t-md" alt="..."
style="width: 100%;height: auto;object-fit: cover;"> style="width: 100%;height: auto;object-fit: cover;">
</div> </div>
<div class="xl:col-span-12 col-span-12"> <div class="xl:col-span-12 col-span-12">
<label for="deal-name" class="form-label">ชื่ออุปกรณ์</label> <label for="deal-name" class="form-label">ชื่ออุปกรณ์</label>
<input readonly type="text" class="form-control" id="deal-name" placeholder="ชื่ออุปกรณ์" <input readonly type="text" class="form-control" id="deal-name" placeholder="ชื่ออุปกรณ์"
[(ngModel)]="selectModel.equipmentName"> [(ngModel)]="selectModel.equipment.equipmentName">
</div> </div>
<div class="xl:col-span-12 col-span-12"> <div class="xl:col-span-12 col-span-12">
<label for="deal-name" class="form-label">S/N</label> <label for="deal-name" class="form-label">S/N</label>
<input readonly type="text" class="form-control" id="deal-name" placeholder="S/N" <input readonly type="text" class="form-control" id="deal-name" placeholder="S/N"
[(ngModel)]="selectModel.serialNumber"> [(ngModel)]="selectModel.equipment.serialNumber">
</div> </div>
<div class="xl:col-span-12 col-span-12"> <div class="xl:col-span-12 col-span-12">
<label for="deal-name" class="form-label">จำนวน</label> <label for="deal-name" class="form-label">จำนวนยืม</label>
<input type="number" class="form-control" id="deal-name" placeholder="จำนวน" <input type="number" class="form-control" id="deal-name" placeholder="จำนวนยืม"
[(ngModel)]="selectStock.quantity"> [(ngModel)]="borrowSelect.quantity_borrowed">
</div>
<div class="xl:col-span-12 col-span-12">
<div class="form-check form-check-lg flex items-center">
<label for="product-availability" class="form-label">ประเภท</label>
<select class="form-control" data-trigger name="product-availability" id="product-availability"
[(ngModel)]="selectStock.action" placeholder="Select">
<option value="INBOUND" selected>In Stock</option>
<option value="OUTBOUND">Out Of Stock</option>
<!-- <option value="OUTBOUND">Out Of Stock</option> -->
</select>
</div>
</div> </div>
<div class="xl:col-span-12 col-span-12"> <div class="xl:col-span-12 col-span-12">
<label for="deal-lead-score" class="form-label">หมายเหตุ</label> <label for="input-label" class="form-label">{{ "พนักงานที่ยืม" | translate}}</label>
<!-- <input type="text" class="form-control" id="deal-lead-score" placeholder="รายละเอียด" <!-- <ng-select [items]="customerList" bindLabel="companyThName" [(ngModel)]="projectModel.customer">
[(ngModel)]="selectModel.description"> --> </ng-select> -->
<textarea class="form-control" id="job-description" [(ngModel)]="selectStock.remark" rows="4"></textarea> <ng-select #selectCustomer [items]="empList" bindLabel="member.firstName" bindValue="memberId"
[(ngModel)]="borrowSelect.memberId">
<ng-template ng-header-tmp>
<input style="width: 100%; line-height: 24px" type="text"
(input)="selectCustomer.filter($any($event.target).value)" />
</ng-template>
</ng-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>
</div> </div>
</div> </div>
<div class="ti-modal-footer"> <div class="ti-modal-footer">
...@@ -247,7 +245,7 @@ ...@@ -247,7 +245,7 @@
data-hs-overlay="#modal-stock"> data-hs-overlay="#modal-stock">
ยกเลิก ยกเลิก
</button> </button>
<button type="button" class="ti-btn bg-primary text-white !font-medium" (click)="saveStock()">บันทึก</button> <button type="button" class="ti-btn bg-primary text-white !font-medium" (click)="saveBorrow()">บันทึก</button>
</div> </div>
</div> </div>
</div> </div>
......
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { environment } from 'src/environments/environment';
import { map, tap, switchMap, filter, reduce } from "rxjs/operators"; import { map, tap, switchMap, filter, reduce } from "rxjs/operators";
import { ProjectEquipmentModel } from '../models/project-equipments';
import { BorrowTransactionsModel } from '../models/borrow-transactions'; import { BorrowTransactionsModel } from '../models/borrow-transactions';
import { environment } from '../../../environments/environment';
@Injectable({ @Injectable({
...@@ -12,7 +10,7 @@ import { BorrowTransactionsModel } from '../models/borrow-transactions'; ...@@ -12,7 +10,7 @@ import { BorrowTransactionsModel } from '../models/borrow-transactions';
}) })
export class BorrowTransactionsService { export class BorrowTransactionsService {
apiBaseUrl = environment.baseUrl + "/borrow-transactions"; apiBaseUrl = environment.baseUrl + "/borrow-transactions";
constructor( constructor(
private http: HttpClient private http: HttpClient
) { } ) { }
...@@ -31,28 +29,24 @@ apiBaseUrl = environment.baseUrl + "/borrow-transactions"; ...@@ -31,28 +29,24 @@ apiBaseUrl = environment.baseUrl + "/borrow-transactions";
); );
} }
save(body: BorrowTransactionsModel) { save(body: any) {
return this.http.post<{ return this.http.post<BorrowTransactionsModel>(this.apiBaseUrl, body);
"message": string,
"user": BorrowTransactionsModel
}>(this.apiBaseUrl, new BorrowTransactionsModel(body));
} }
update(body: BorrowTransactionsModel) { update(body: BorrowTransactionsModel) {
return this.http.put<{ return this.http.put<{
"message": string, "message": string,
"user": BorrowTransactionsModel "user": BorrowTransactionsModel
}>(this.apiBaseUrl + "/" + body.borrow_id, new BorrowTransactionsModel(body)); }>(this.apiBaseUrl + "/" + body.borrowId, new BorrowTransactionsModel(body));
} }
delete(body: BorrowTransactionsModel) { delete(body: BorrowTransactionsModel) {
return this.http.delete<{ return this.http.delete<{
"message": string, "message": string,
"user": BorrowTransactionsModel "user": BorrowTransactionsModel
}>(this.apiBaseUrl + "/" + body.borrow_id); }>(this.apiBaseUrl + "/" + body.borrowId);
} }
} }
}
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Time Attendance System</title> <title>Assets Management</title>
<base href="/"> <base href="/">
<!-- <base href="/ynex-tailwind/preview/"> --> <!-- <base href="/ynex-tailwind/preview/"> -->
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
......
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