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) {
...@@ -80,9 +137,15 @@ export class AdminEquirmentComponent implements OnInit { ...@@ -80,9 +137,15 @@ export class AdminEquirmentComponent implements OnInit {
saveRoom() { saveRoom() {
this.roomService.addRoom(this.modelRoom); this.roomService.addRoom(this.modelRoom);
this.modalService.dismissAll(); this.modalService.dismissAll();
this.ngOnInit(); this.ngOnInit();
} }
editRoom() {
this.roomService.editroom(this.modelRoom);
this.modalService.dismissAll();
this.ngOnInit();
}
} }
...@@ -72,60 +72,6 @@ ...@@ -72,60 +72,6 @@
<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; ">
<div class=" col-md-12">
<div class="card">
<div class=" card-header">
<h5 class=" title">Add Equirment</h5>
</div>
<div class=" card-body">
<form>
<div class=" row">
<div class=" col-md-12">
<div class=" form-group">
<label> ชื่อ </label>
<input class=" form-control" placeholder="" type="text" [(ngModel)]="modelEquirment.eqName"
value="" />
</div>
</div>
</div>
<div class=" row">
<div class=" col-md-6 mb-2">
<div class=" form-group">
<label> หมวดหมู่ </label>
<br>
<select class="form-select"
aria-label="Default select example" [(ngModel)]="modelEquirment.eqType">
<option selected>เลือกหมวดหมู่</option>
<option value="4">IT</option>
<option value="5">Company</option>
</select>
</div>
</div>
</div>
<div class=" row">
<div class=" col-md-12">
<div class=" form-group">
<label> รายละเอียด</label>
<textarea class="form-control"
id="exampleFormControlTextarea1" rows="3"
placeholder="......" [(ngModel)]="modelEquirment.eqDesc"></textarea>
</div>
</div>
</div>
<label for="exampleFormControlFile">แนบไฟล์รูปภาพ</label>
<input type="file" class="form-control-file"
id="exampleFormControlFile">
</form>
</div>
<div class=" card-footer">
<button class=" btn btn-fill btn-danger" type="submit" (click)="saveEquirment()">Save</button>
<button class=" btn btn-fill btn-danger" type="cancel" (click)="modal.dismiss('Cross click')">Cancel</button>
</div>
</div>
</div>
</ng-template>
<button class="btn btn-lg btn-outline-primary" <button class="btn btn-lg btn-outline-primary"
(click)="Eopen(contentequirment)">เพิ่มรายการ</button> (click)="Eopen(contentequirment)">เพิ่มรายการ</button>
...@@ -146,7 +92,7 @@ ...@@ -146,7 +92,7 @@
<div class="text-center"> <div class="text-center">
<div class="d-grid gap-2 a-md-flex justify-content-md-end"> <div class="d-grid gap-2 a-md-flex justify-content-md-end">
<button class="btn btn-sm btn-outline-primary" <button class="btn btn-sm btn-outline-primary"
(click)="bookEquir(lend,item)">เบิก</button> (click)="bookEquir(Lend,item)">เบิก</button>
</div> </div>
</div> </div>
</div> </div>
...@@ -176,6 +122,62 @@ ...@@ -176,6 +122,62 @@
<div [ngbNavOutlet]="nav"></div> <div [ngbNavOutlet]="nav"></div>
</div> </div>
<ng-template #contentequirment let-modal style="padding: 0; ">
<div class=" col-md-12">
<div class="card">
<div class=" card-header">
<h5 class=" title">Add Equirment</h5>
</div>
<div class=" card-body">
<form>
<div class=" row">
<div class=" col-md-12">
<div class=" form-group">
<label> ชื่อ </label>
<input class=" form-control" placeholder="" type="text" [(ngModel)]="modelEquirment.eqName"
value="" />
</div>
</div>
</div>
<div class=" row">
<div class=" col-md-6 mb-2">
<div class=" form-group">
<label> หมวดหมู่ </label>
<br>
<select class="form-select"
aria-label="Default select example" [(ngModel)]="modelEquirment.eqType">
<option selected>เลือกหมวดหมู่</option>
<option value="4">IT</option>
<option value="5">Company</option>
</select>
</div>
</div>
</div>
<div class=" row">
<div class=" col-md-12">
<div class=" form-group">
<label> รายละเอียด</label>
<textarea class="form-control"
id="exampleFormControlTextarea1" rows="3"
placeholder="......" [(ngModel)]="modelEquirment.eqDesc"></textarea>
</div>
</div>
</div>
<label for="exampleFormControlFile">แนบไฟล์รูปภาพ</label>
<input type="file" class="form-control-file"
id="exampleFormControlFile">
</form>
</div>
<div class=" card-footer">
<button class=" btn btn-fill btn-danger" type="submit" (click)="saveEquirment()">Save</button>
<button class=" btn btn-fill btn-danger" type="cancel" (click)="modal.dismiss('Cross click')">Cancel</button>
</div>
</div>
</div>
</ng-template>
<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">
<div class="card"> <div class="card">
...@@ -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