Commit 6d169133 by DESKTOP-HF0LVOG\myhr

update เพิ่มปุ่มแก้ไข หน้า admin

parent c709d9e1
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { NgbModal, ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap'; import { NgbModal, ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap';
import { Equirment } from 'src/app/models/equirment.model'; import { Equirment } from 'src/app/models/equirment.model';
import { itemDetail } from 'src/app/models/itemDetail.model';
import { roomDetail } from 'src/app/models/roomDetail.model';
import { Room } from 'src/app/models/rooms.model'; import { Room } from 'src/app/models/rooms.model';
import { EquirmentService } from 'src/app/service/equirment.service'; import { EquirmentService } from 'src/app/service/equirment.service';
import { RoomService } from 'src/app/service/room.service'; import { RoomService } from 'src/app/service/room.service';
import { roomDetailService } from 'src/app/service/room-detail.service';
@Component({ @Component({
selector: 'app-admin-equirment', selector: 'app-admin-equirment',
...@@ -19,10 +22,18 @@ export class AdminEquirmentComponent implements OnInit { ...@@ -19,10 +22,18 @@ export class AdminEquirmentComponent implements OnInit {
listEquirmentModel: Equirment[] = []; listEquirmentModel: Equirment[] = [];
listRoomModel: Room[] = []; listRoomModel: Room[] = [];
listitemDetail: itemDetail[] = [];
listroomDetail: roomDetail[] = [];
collectionSize = this.listEquirmentModel.length; collectionSize = this.listEquirmentModel.length;
modelEquirment = new Equirment(); modelEquirment = new Equirment();
modelRoom = new Room(); modelRoom = new Room();
constructor(private modalService: NgbModal, private equirmentService: EquirmentService, private roomService: RoomService) { modelitemDetail = new itemDetail();
modelroomDetail = new roomDetail();
constructor(private modalService: NgbModal, private equirmentService: EquirmentService, private roomService: RoomService, private roomDetailService : roomDetailService) {
} }
...@@ -31,6 +42,32 @@ export class AdminEquirmentComponent implements OnInit { ...@@ -31,6 +42,32 @@ export class AdminEquirmentComponent implements OnInit {
this.listRoomModel = this.roomService.getListRoom(); this.listRoomModel = this.roomService.getListRoom();
} }
bookEquir(editLend, item: Equirment) {
this.modelitemDetail = new itemDetail();
this.modelitemDetail.equirment = item;
console.log("item", this.modelitemDetail);
this.modalService.open(editLend, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
this.closeResult = `Closed with: ${result}`;
}, (reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
});
}
bookRoom(editroom, item: Room) {
this.modelroomDetail = new roomDetail();
this.modelroomDetail.room = item;
console.log("room", this.modelroomDetail);
this.modalService.open(editroom, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
this.closeResult = `Closed with: ${result}`;
}, (reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
});
}
Eopen(contentequirment) { Eopen(contentequirment) {
this.modelEquirment = new Equirment(); this.modelEquirment = new Equirment();
this.modalService.open(contentequirment, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => { this.modalService.open(contentequirment, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
...@@ -49,6 +86,26 @@ export class AdminEquirmentComponent implements OnInit { ...@@ -49,6 +86,26 @@ export class AdminEquirmentComponent implements OnInit {
}); });
} }
openItemDetail(content: string, item: itemDetail) {
this.modelitemDetail = item;
console.log(item);
this.modalService.open(content, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
this.closeResult = `Closed with: ${result}`;
}, (reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
});
}
openRoomDetail(content: string, item: roomDetail) {
this.modelroomDetail = item;
console.log(item);
this.modalService.open(content, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
this.closeResult = `Closed with: ${result}`;
}, (reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
});
}
private getDismissReason(reason: any): string { private getDismissReason(reason: any): string {
if (reason === ModalDismissReasons.ESC) { if (reason === ModalDismissReasons.ESC) {
...@@ -85,4 +142,10 @@ export class AdminEquirmentComponent implements OnInit { ...@@ -85,4 +142,10 @@ export class AdminEquirmentComponent implements OnInit {
this.ngOnInit(); this.ngOnInit();
} }
editRoom() {
this.roomService.editroom(this.modelRoom);
this.modalService.dismissAll();
this.ngOnInit();
}
} }
...@@ -72,7 +72,59 @@ ...@@ -72,7 +72,59 @@
<div class="col-sm-12"> <div class="col-sm-12">
<div class=""> <div class="">
<div class="card-body"> <div class="card-body">
<ng-template #contentequirment let-modal style="padding: 0; "> <button class="btn btn-lg btn-outline-primary"
(click)="Eopen(contentequirment)">เพิ่มรายการ</button>
<div class="row">
<div class="col-sm-3" *ngFor="let item of listEquirmentModel">
<div class="card" style="
padding: 10px;">
<div class="card-body">
<img style="height: 200px;
width: 200px;" [src]="item.eqPic" class="nav justify-content-center"
alt="...">
<br>
<p class="text-left">ชื่อ : {{item.eqName}}</p>
<p class="text-left">รายละเอียด : {{item.eqDesc}}</p>
<p class="text-left">ประเภท : {{item.eqType}}</p>
</div>
<div class="text-center">
<div class="d-grid gap-2 a-md-flex justify-content-md-end">
<button class="btn btn-sm btn-outline-primary"
(click)="bookEquir(Lend,item)">เบิก</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="d-flex justify-content-between p-2">
<ngb-pagination [collectionSize]="collectionSize" [(page)]="page" [pageSize]="pageSize"
(pageChange)="refreshCountries()">
</ngb-pagination>
<select class="custom-select" style="width: auto" [(ngModel)]="pageSize"
(ngModelChange)="refreshCountries()">
<option [ngValue]="10">10 items per page</option>
<option [ngValue]="50">50 items per page</option>
<option [ngValue]="100">100 items per page</option>
</select>
</div>
</div>
</div>
</div>
</ng-template>
</li>
</ul>
<div [ngbNavOutlet]="nav"></div>
</div>
<ng-template #contentequirment let-modal style="padding: 0; ">
<div class=" col-md-12"> <div class=" col-md-12">
<div class="card"> <div class="card">
<div class=" card-header"> <div class=" card-header">
...@@ -124,57 +176,7 @@ ...@@ -124,57 +176,7 @@
</div> </div>
</div> </div>
</div> </div>
</ng-template> </ng-template>
<button class="btn btn-lg btn-outline-primary"
(click)="Eopen(contentequirment)">เพิ่มรายการ</button>
<div class="row">
<div class="col-sm-3" *ngFor="let item of listEquirmentModel">
<div class="card" style="
padding: 10px;">
<div class="card-body">
<img style="height: 200px;
width: 200px;" [src]="item.eqPic" class="nav justify-content-center"
alt="...">
<br>
<p class="text-left">ชื่อ : {{item.eqName}}</p>
<p class="text-left">รายละเอียด : {{item.eqDesc}}</p>
<p class="text-left">ประเภท : {{item.eqType}}</p>
</div>
<div class="text-center">
<div class="d-grid gap-2 a-md-flex justify-content-md-end">
<button class="btn btn-sm btn-outline-primary"
(click)="bookEquir(lend,item)">เบิก</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="d-flex justify-content-between p-2">
<ngb-pagination [collectionSize]="collectionSize" [(page)]="page" [pageSize]="pageSize"
(pageChange)="refreshCountries()">
</ngb-pagination>
<select class="custom-select" style="width: auto" [(ngModel)]="pageSize"
(ngModelChange)="refreshCountries()">
<option [ngValue]="10">10 items per page</option>
<option [ngValue]="50">50 items per page</option>
<option [ngValue]="100">100 items per page</option>
</select>
</div>
</div>
</div>
</div>
</ng-template>
</li>
</ul>
<div [ngbNavOutlet]="nav"></div>
</div>
<ng-template #contentroom let-modal style="padding: 0; "> <ng-template #contentroom let-modal style="padding: 0; ">
<div class=" col-md-12"> <div class=" col-md-12">
...@@ -301,7 +303,7 @@ ...@@ -301,7 +303,7 @@
</div> </div>
</ng-template> </ng-template>
<ng-template #lend let-modal style="padding: 0; "> <ng-template #Lend let-modal style="padding: 0; ">
<div class=" col-md-12"> <div class=" col-md-12">
<div class="card"> <div class="card">
<div class=" card-header"> <div class=" card-header">
......
...@@ -51,13 +51,13 @@ export class EquipmentComponent implements OnInit { ...@@ -51,13 +51,13 @@ export class EquipmentComponent implements OnInit {
} }
bookEquir(contentequirment,item : Equirment) { bookEquir(Lend,item : Equirment) {
this.modelitemDetail = new itemDetail(); this.modelitemDetail = new itemDetail();
this.modelitemDetail.equirment = item ; this.modelitemDetail.equirment = item ;
console.log("item",this.modelitemDetail); console.log("item",this.modelitemDetail);
this.modalService.open(contentequirment, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => { this.modalService.open(Lend, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
this.closeResult = `Closed with: ${result}`; this.closeResult = `Closed with: ${result}`;
}, (reason) => { }, (reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`; this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
......
...@@ -61,6 +61,10 @@ export class roomDetailService { ...@@ -61,6 +61,10 @@ export class roomDetailService {
] ]
editroomDetail(model: roomDetail) {
this.listroomDetail.push(model)
}
addroomDetail(model: roomDetail) { addroomDetail(model: roomDetail) {
console.log(this.listroomDetail); console.log(this.listroomDetail);
this.listroomDetail.push(model); this.listroomDetail.push(model);
......
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http'; import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Room, SearchRoomModel } from '../models/rooms.model'; import { Room, SearchRoomModel } from '../models/rooms.model';
import { roomDetail } from '../models/roomDetail.model';
...@@ -28,7 +29,6 @@ export class RoomService { ...@@ -28,7 +29,6 @@ export class RoomService {
{ {
rId: 3, rId: 3,
rName: "ห้องรวม", rName: "ห้องรวม",
rPic: "assets/img/room.jpg", rPic: "assets/img/room.jpg",
roomLimit: 100, roomLimit: 100,
rDesc: "จำนวนคน 100 คน", rDesc: "จำนวนคน 100 คน",
...@@ -43,6 +43,10 @@ export class RoomService { ...@@ -43,6 +43,10 @@ export class RoomService {
] ]
listRoomSearch: Room[] = []; listRoomSearch: Room[] = [];
editroom(model: Room) {
this.listRoomModel.push(model);
}
addRoom(model: Room) { addRoom(model: Room) {
this.listRoomModel.push(model); this.listRoomModel.push(model);
} }
......
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