Commit 318d51ac by Ooh-Ao

admin

parent eceb34fc
...@@ -23,7 +23,8 @@ async def create_equipment(equipment_data: EquipmentCreate, db: AsyncSession): ...@@ -23,7 +23,8 @@ async def create_equipment(equipment_data: EquipmentCreate, db: AsyncSession):
equipmentName=equipment_data.equipmentName, equipmentName=equipment_data.equipmentName,
description=equipment_data.description, description=equipment_data.description,
quantity=equipment_data.quantity, quantity=equipment_data.quantity,
is_returnable=equipment_data.is_returnable is_returnable=equipment_data.is_returnable,
picture=equipment_data.picture
) )
db.add(new_equipment) db.add(new_equipment)
try: try:
...@@ -45,6 +46,8 @@ async def update_equipment(equipment_id: UUID, equipment_data: EquipmentUpdate, ...@@ -45,6 +46,8 @@ async def update_equipment(equipment_id: UUID, equipment_data: EquipmentUpdate,
eq_db.description = equipment_data.description eq_db.description = equipment_data.description
if equipment_data.is_returnable is not None: if equipment_data.is_returnable is not None:
eq_db.is_returnable = equipment_data.is_returnable eq_db.is_returnable = equipment_data.is_returnable
if equipment_data.picture is not None:
eq_db.picture = equipment_data.picture
try: try:
await db.commit() await db.commit()
......
...@@ -7,6 +7,7 @@ from datetime import datetime ...@@ -7,6 +7,7 @@ from datetime import datetime
class EquipmentBase(BaseModel): class EquipmentBase(BaseModel):
equipmentName: str equipmentName: str
description: Optional[str] = None description: Optional[str] = None
picture: Optional[str] = None
quantity: int = 0 quantity: int = 0
is_returnable: bool = True is_returnable: bool = True
......
...@@ -67,7 +67,8 @@ ...@@ -67,7 +67,8 @@
</div> --> </div> -->
<div class="xxl:col-span-2 xl:col-span-3 lg:col-span-4 md:col-span-4 sm:col-span-6 col-span-12"> <div class="xxl:col-span-2 xl:col-span-3 lg:col-span-4 md:col-span-4 sm:col-span-6 col-span-12">
<div class="box custom-box"> <div class="box custom-box">
<img [src]="item.getPicture()" class="!rounded-t-md" alt="..."> <img [src]="item.getPicture()" class="!rounded-t-md" alt="..."
style="width: 100%;height: 200px;object-fit: cover;">
<div class="flex items-center justify-between nft-like-section w-full px-4"> <div class="flex items-center justify-between nft-like-section w-full px-4">
<!-- <div class="flex-grow"> <!-- <div class="flex-grow">
<button type="button" aria-label="button" <button type="button" aria-label="button"
...@@ -106,19 +107,14 @@ ...@@ -106,19 +107,14 @@
<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" <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> class="ti-btn ti-btn-sm ti-btn-primary me-[0.375rem]"><i class="ri-edit-line"></i></button>
<button routerLinkActive="active" type="button" aria-label="button" <button data-hs-overlay="#modal-stock" type="button" aria-label="button" (click)="viewStock(item);"
class="ti-btn ti-btn-sm ti-btn-secondary !me-[0.375rem]">
<i class="ri-time-line"></i>
</button>
<button data-hs-overlay="#modal-face" type="button" aria-label="button"
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-account-circle-line"></i> <i class="ri-store-line"></i>
</button> </button>
<button type="button" aria-label="button" class="ti-btn ti-btn-sm ti-btn-danger me-0"><i <button (click)="delete(item)" type="button" aria-label="button"
class="ri-delete-bin-line"></i></button> class="ti-btn ti-btn-sm ti-btn-danger me-0"><i class="ri-delete-bin-line"></i></button>
</div> </div>
</div> </div>
</div> </div>
...@@ -141,7 +137,7 @@ ...@@ -141,7 +137,7 @@
<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-detail"> data-hs-overlay="#modal-detail">
...@@ -163,16 +159,16 @@ ...@@ -163,16 +159,16 @@
</span> </span>
</div> </div>
</div> </div>
<div class="xl:col-span-6 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="text" class="form-control" id="deal-name" placeholder="ชื่ออุปกรณ์" <input type="text" class="form-control" id="deal-name" placeholder="ชื่ออุปกรณ์"
[(ngModel)]="selectModel.equipmentName"> [(ngModel)]="selectModel.equipmentName">
</div> </div>
<div class="xl:col-span-6 col-span-12"> <!-- <div class="xl:col-span-6 col-span-12">
<label for="deal-name" class="form-label">จำนวน</label> <label for="deal-name" class="form-label">จำนวน</label>
<input type="text" class="form-control" id="deal-name" placeholder="จำนวน" <input type="number" class="form-control" id="deal-name" placeholder="จำนวน"
[(ngModel)]="selectModel.quantity"> [(ngModel)]="selectModel.quantity">
</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="deal-lead-score" class="form-label">รายละเอียด</label>
<!-- <input type="text" class="form-control" id="deal-lead-score" placeholder="รายละเอียด" <!-- <input type="text" class="form-control" id="deal-lead-score" placeholder="รายละเอียด"
...@@ -182,7 +178,7 @@ ...@@ -182,7 +178,7 @@
</div> </div>
<div class="xl:col-span-12 col-span-12"> <div class="xl:col-span-12 col-span-12">
<div class="form-check form-check-lg flex items-center"> <div class="form-check form-check-lg flex items-center">
<input class="form-check-input" type="checkbox" value="" id="checkebox-lg" [(checked)]="selectModel.is_returnable"> <input class="form-check-input" type="checkbox" id="checkebox-lg" [(ngModel)]="selectModel.is_returnable">
<label class="form-check-label" for="checkebox-lg"> <label class="form-check-label" for="checkebox-lg">
ตรวจสอบการคืน ตรวจสอบการคืน
</label> </label>
...@@ -202,3 +198,67 @@ ...@@ -202,3 +198,67 @@
</div> </div>
</div> </div>
</div> </div>
<!-- Start:: New Deal -->
<div id="modal-stock" class="hs-overlay hidden ti-modal" *ngIf="selectStock">
<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-stock">
<span class="sr-only">Close</span>
<i class="ri-close-line"></i>
</button>
</div>
<div class="ti-modal-body px-4">
<div class="grid grid-cols-12 gap-4">
<div class="xl:col-span-12 col-span-12">
<img [src]="selectModel.getPicture()" class="!rounded-t-md" alt="..."
style="width: 100%;height: auto;object-fit: cover;">
</div>
<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)]="selectModel.equipmentName">
</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)]="selectStock.quantity">
</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 class="xl:col-span-12 col-span-12">
<label for="deal-lead-score" class="form-label">หมายเหตุ</label>
<!-- <input type="text" class="form-control" id="deal-lead-score" placeholder="รายละเอียด"
[(ngModel)]="selectModel.description"> -->
<textarea class="form-control" id="job-description" [(ngModel)]="selectStock.remark" rows="4"></textarea>
</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-stock">
ยกเลิก
</button>
<button type="button" class="ti-btn bg-primary text-white !font-medium" (click)="saveStock()">บันทึก</button>
</div>
</div>
</div>
</div>
...@@ -12,7 +12,7 @@ import { TokenService } from "../../../shared/services/token.service"; ...@@ -12,7 +12,7 @@ import { TokenService } from "../../../shared/services/token.service";
import { FileUploadModule } from 'ng2-file-upload'; import { FileUploadModule } from 'ng2-file-upload';
import { FileItem, FileUploader, ParsedResponseHeaders } from "ng2-file-upload"; import { FileItem, FileUploader, ParsedResponseHeaders } from "ng2-file-upload";
import { environment } from "../../../../environments/environment"; import { environment } from "../../../../environments/environment";
import { EquipmentModel } from "../../models/equipments.model"; import { EquipmentModel, EquipmentStockModel } from "../../models/equipments.model";
import { EquipmentService } from "../../services/equirement.service"; import { EquipmentService } from "../../services/equirement.service";
import { HttpClient } from "@angular/common/http"; import { HttpClient } from "@angular/common/http";
...@@ -33,7 +33,7 @@ import { HttpClient } from "@angular/common/http"; ...@@ -33,7 +33,7 @@ import { HttpClient } from "@angular/common/http";
}) })
export class AdminManageComponent { export class AdminManageComponent {
@ViewChild('closeModal') public childModal?: ElementRef; @ViewChild('closeModal') public childModal?: ElementRef;
@ViewChild('closeModalFace') public childModalFace?: ElementRef; @ViewChild('closeModalStock') public closeModalStock?: ElementRef;
@ViewChild('modalDetail') public modalDetail?: ElementRef; @ViewChild('modalDetail') public modalDetail?: ElementRef;
allSelected = false; allSelected = false;
someSelected = false; someSelected = false;
...@@ -42,6 +42,7 @@ export class AdminManageComponent { ...@@ -42,6 +42,7 @@ export class AdminManageComponent {
itemsList: EquipmentModel[] = [] itemsList: EquipmentModel[] = []
filterList: EquipmentModel[] = [] filterList: EquipmentModel[] = []
selectModel: EquipmentModel = new EquipmentModel() selectModel: EquipmentModel = new EquipmentModel()
selectStock?: EquipmentStockModel
selectedItems = new Map<string, boolean>(); selectedItems = new Map<string, boolean>();
pageIndex = 0; pageIndex = 0;
get searchTerm(): string { get searchTerm(): string {
...@@ -172,7 +173,16 @@ export class AdminManageComponent { ...@@ -172,7 +173,16 @@ export class AdminManageComponent {
this.selectModel = item this.selectModel = item
} }
viewStock(item: EquipmentModel) {
this.selectModel = item
this.selectStock = new EquipmentStockModel()
this.selectStock.equipmentId = this.selectModel.equipmentId
this.selectStock.created_by = this.tokenService.getUser().member.memberId
this.selectStock.action = "INBOUND"
}
save() { save() {
console.log(this.selectModel)
swal({ swal({
title: "Are you sure?", title: "Are you sure?",
text: "คุณต้องการบันทึกหรือไม่", text: "คุณต้องการบันทึกหรือไม่",
...@@ -238,4 +248,27 @@ export class AdminManageComponent { ...@@ -238,4 +248,27 @@ export class AdminManageComponent {
this.filterList = this.itemsList this.filterList = this.itemsList
} }
saveStock() {
console.log(this.selectStock)
swal({
title: "Are you sure?",
text: "คุณต้องการบันทึกหรือไม่",
icon: "warning",
dangerMode: false,
buttons: ["Cancel", "Confirm"],
})
.then((willDelete: any) => {
if (willDelete) {
this.eqService.stock(this.selectStock!).subscribe(result => {
swal("Save Success!!", "บันทึกข้อมูลสำเร็จ", "success");
this.ngOnInit()
this.closeModalStock?.nativeElement.click()
})
}
});
}
} }
...@@ -28,3 +28,13 @@ export class EquipmentModel extends BaseModel { ...@@ -28,3 +28,13 @@ export class EquipmentModel extends BaseModel {
return this.picture ? environment.baseUrl + '/images/' + this.picture : './assets/images/faces/111.jpg' return this.picture ? environment.baseUrl + '/images/' + this.picture : './assets/images/faces/111.jpg'
} }
} }
export class EquipmentStockModel {
equipmentId: string;
quantity: number;
action: string;
remark: string;
created_by: string;
lotId: string;
created_at: string;
}
...@@ -49,5 +49,23 @@ export class EquipmentService { ...@@ -49,5 +49,23 @@ export class EquipmentService {
}>(this.apiBaseUrl + "/" + body.equipmentId); }>(this.apiBaseUrl + "/" + body.equipmentId);
} }
stock(body: {
equipmentId: string;
quantity: number;
action: string;
remark: string;
created_by: string;
}) {
return this.http.post<{
equipmentId: string;
quantity: number;
action: string;
remark: string;
created_by: string;
lotId: string;
created_at: string;
}>("/inventory-lots", body);
}
} }
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