Commit 186fb8d6 by DESKTOP-HF0LVOG\myhr

Edit การกรอกข้อมูล model หน้า equirment

parent 3fad6518
export class Equirment { export class Equirment {
eqid: number; eqId: number;
eqName: string; eqName: string;
eqdesc: string; eqDesc: string;
eqtype: string; eqType: string;
eqpic: string; eqPic: string;
constructor(init?: Equirment){ constructor(init?: Equirment){
Object.assign(this, init); Object.assign(this, init);
this.eqid = 0; this.eqId = 0;
this.eqName = ''; this.eqName = '';
this.eqdesc = ''; this.eqDesc = '';
this.eqtype = ''; this.eqType = '';
this.eqpic = ''; this.eqPic = '';
} }
} }
...@@ -30,3 +30,11 @@ export class SearchEquirmentModel { ...@@ -30,3 +30,11 @@ export class SearchEquirmentModel {
this.etime = ''; this.etime = '';
} }
} }
interface EquirmentModel {
id: number;
name: string;
desc: string;
type?: CategoryModel;
pic: string;
}
\ No newline at end of file
export class Room { export class Room {
rid: number; rId: number;
rname: string; rName: string;
title: string; rPic: string;
rpic: string; rType: string;
roomLimit: number; roomLimit: number;
rdesc: string; rDesc: string;
constructor(init?: Room) { constructor(init?: Room) {
Object.assign(this, init); Object.assign(this, init);
this.rid = 0; this.rId = 0;
this.rname = ''; this.rName = '';
this.title = ''; this.rType = '';
this.rpic = ''; this.rPic = '';
this.roomLimit = 0; this.roomLimit = 0;
this.rdesc = ''; this.rDesc = '';
} }
} }
......
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
<label> หมวดหมู่ </label> <label> หมวดหมู่ </label>
<br> <br>
<select class="form-select" <select class="form-select"
aria-label="Default select example"> aria-label="Default select example" [(ngModel)]="modelEquirment.eqType">
<option selected>เลือกหมวดหมู่</option> <option selected>เลือกหมวดหมู่</option>
<option value="4">IT</option> <option value="4">IT</option>
<option value="5">Company</option> <option value="5">Company</option>
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
<label> รายละเอียด</label> <label> รายละเอียด</label>
<textarea class="form-control" <textarea class="form-control"
id="exampleFormControlTextarea1" rows="3" id="exampleFormControlTextarea1" rows="3"
placeholder="......"></textarea> placeholder="......" [(ngModel)]="modelEquirment.eqDesc"></textarea>
</div> </div>
</div> </div>
</div> </div>
...@@ -188,7 +188,7 @@ ...@@ -188,7 +188,7 @@
<div class=" col-md-12"> <div class=" col-md-12">
<div class=" form-group"> <div class=" form-group">
<label> ชื่อ </label> <label> ชื่อ </label>
<input class=" form-control" placeholder="" type="text" value="" /> <input class=" form-control" placeholder="" type="text" [(ngModel)]="modelRoom.rName" value="" />
</div> </div>
</div> </div>
</div> </div>
...@@ -197,7 +197,7 @@ ...@@ -197,7 +197,7 @@
<div class=" form-group"> <div class=" form-group">
<label> ประเภท </label> <label> ประเภท </label>
<br> <br>
<select class="form-select" aria-label="Default select example"> <select class="form-select" aria-label="Default select example" [(ngModel)]="modelRoom.rType">
<option selected>เลือกประเภท</option> <option selected>เลือกประเภท</option>
<option value="1">ห้อง</option> <option value="1">ห้อง</option>
<option value="2">รถ</option> <option value="2">รถ</option>
...@@ -210,7 +210,7 @@ ...@@ -210,7 +210,7 @@
<div class=" form-group"> <div class=" form-group">
<label> รายละเอียด</label> <label> รายละเอียด</label>
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3" <textarea class="form-control" id="exampleFormControlTextarea1" rows="3"
placeholder="......"></textarea> placeholder="......" [(ngModel)]="modelRoom.rDesc"></textarea>
</div> </div>
</div> </div>
</div> </div>
...@@ -219,7 +219,7 @@ ...@@ -219,7 +219,7 @@
</form> </form>
</div> </div>
<div class=" card-footer"> <div class=" card-footer">
<button class=" btn btn-fill btn-danger" type="submit">Save</button> <button class=" btn btn-fill btn-danger" type="submit" (click)="saveRoom()">Save</button>
<button class=" btn btn-fill btn-danger" type="cancel">Cancel</button> <button class=" btn btn-fill btn-danger" type="cancel">Cancel</button>
</div> </div>
</div> </div>
......
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 { Room } from 'src/app/models/rooms.model';
interface EquirmentModel {
id: number;
name: string;
desc: string;
type?: CategoryModel;
pic: string;
}
@Component({ @Component({
selector: 'app-equipment', selector: 'app-equipment',
...@@ -25,6 +18,7 @@ export class EquipmentComponent implements OnInit { ...@@ -25,6 +18,7 @@ export class EquipmentComponent implements OnInit {
listEquirmentModel: Equirment[] = []; listEquirmentModel: Equirment[] = [];
collectionSize = this.listEquirmentModel.length; collectionSize = this.listEquirmentModel.length;
modelEquirment = new Equirment(); modelEquirment = new Equirment();
modelRoom = new Room();
constructor(private modalService: NgbModal) { } constructor(private modalService: NgbModal) { }
ngOnInit(): void { ngOnInit(): void {
...@@ -62,5 +56,11 @@ export class EquipmentComponent implements OnInit { ...@@ -62,5 +56,11 @@ export class EquipmentComponent implements OnInit {
console.log(this.modelEquirment); console.log(this.modelEquirment);
} }
saveRoom(){
console.log(this.modelRoom);
}
} }
...@@ -9,32 +9,32 @@ export class EquirmentService { ...@@ -9,32 +9,32 @@ export class EquirmentService {
url: string; url: string;
listEquirment: Equirment[] = [ listEquirment: Equirment[] = [
{ {
eqid: 1, eqId: 1,
eqName: "จอคอมพิวเตอร์", eqName: "จอคอมพิวเตอร์",
eqdesc: "หน้าจอขนาด 22 นิ้ว", eqDesc: "หน้าจอขนาด 22 นิ้ว",
eqtype: "it", eqType: "it",
eqpic: "assets/img/mo1.jpg" eqPic: "assets/img/mo1.jpg"
}, },
{ {
eqid: 2, eqId: 2,
eqName: "เมาส์", eqName: "เมาส์",
eqdesc: "...", eqDesc: "...",
eqtype: "it", eqType: "it",
eqpic: "assets/img/mou.jpg" eqPic: "assets/img/mou.jpg"
}, },
{ {
eqid: 3, eqId: 3,
eqName: "โน๊ตบุ๊ค", eqName: "โน๊ตบุ๊ค",
eqdesc: "หน้าจอขนาด 20 นิ้ว", eqDesc: "หน้าจอขนาด 20 นิ้ว",
eqtype: "it", eqType: "it",
eqpic: "assets/img/notebook.jpg" eqPic: "assets/img/notebook.jpg"
}, },
{ {
eqid: 4, eqId: 4,
eqName: "คีย์บอร์ด", eqName: "คีย์บอร์ด",
eqdesc: "...", eqDesc: "...",
eqtype: "it", eqType: "it",
eqpic: "assets/img/keyboard.png" eqPic: "assets/img/keyboard.png"
} }
] ]
listEquirmentModel: Equirment[] = []; listEquirmentModel: Equirment[] = [];
...@@ -68,7 +68,7 @@ export class EquirmentService { ...@@ -68,7 +68,7 @@ export class EquirmentService {
} }
deleteRoom(EquirmentModel: Equirment) { deleteRoom(EquirmentModel: Equirment) {
this.http.delete(this.url + "/" + EquirmentModel.eqid).subscribe(response => { this.http.delete(this.url + "/" + EquirmentModel.eqId).subscribe(response => {
console.log(response); console.log(response);
this.getListRoom() this.getListRoom()
alert("ลบข้อมูลอุปกรณ์สำเร็จ") alert("ลบข้อมูลอุปกรณ์สำเร็จ")
...@@ -76,13 +76,13 @@ export class EquirmentService { ...@@ -76,13 +76,13 @@ export class EquirmentService {
} }
updateRoom(EquirmentModel: Equirment) { updateRoom(EquirmentModel: Equirment) {
this.http.put(this.url + "/" + EquirmentModel.eqid, EquirmentModel).subscribe(response => { this.http.put(this.url + "/" + EquirmentModel.eqId, EquirmentModel).subscribe(response => {
console.log(response); console.log(response);
alert("อัพเดทข้อมูลอุปกรณ์สำเร็จ") alert("อัพเดทข้อมูลอุปกรณ์สำเร็จ")
}) })
} }
EquirmentModel(eqid: string) { EquirmentModel(eqId: string) {
} }
......
...@@ -10,29 +10,37 @@ export class RoomService { ...@@ -10,29 +10,37 @@ export class RoomService {
url: string; url: string;
listRoomModel: Room[] = [ listRoomModel: Room[] = [
{ {
rid: 1, rId: 1,
rname: "ห้องเดียว", rName: "ห้องเดียว",
title: "string", rType: '',
rpic: "assets/img/room.jpg", rPic: "assets/img/room.jpg",
roomLimit: 25, roomLimit: 25,
rdesc: "จำนวนคน 25 คน", rDesc: "จำนวนคน 25 คน",
}, },
{ {
rid: 2, rId: 2,
rname: "ห้องคู่", rName: "ห้องคู่",
title: "string", rType: '',
rpic: "assets/img/room.jpg", rPic: "assets/img/room.jpg",
roomLimit: 50, roomLimit: 50,
rdesc: "จำนวนคน 50 คน", rDesc: "จำนวนคน 50 คน",
}, },
{ {
rid: 3, rId: 3,
rname: "ห้องรวม", rName: "ห้องรวม",
title: "string", rType: '',
rpic: "assets/img/room.jpg", rPic: "assets/img/room.jpg",
roomLimit: 100, roomLimit: 100,
rdesc: "จำนวนคน 100 คน", rDesc: "จำนวนคน 100 คน",
}, },
{
rId: 4,
rName: "รถ",
rType: '',
rPic: "assets/img/car.jpg",
roomLimit: 0,
rDesc: "รถ",
}
] ]
listRoomSearch: Room[] = []; listRoomSearch: Room[] = [];
...@@ -65,7 +73,7 @@ export class RoomService { ...@@ -65,7 +73,7 @@ export class RoomService {
} }
deleteRoom(roomModel: Room) { deleteRoom(roomModel: Room) {
this.http.delete(this.url + "/" + roomModel.rid).subscribe(response => { this.http.delete(this.url + "/" + roomModel.rId).subscribe(response => {
console.log(response); console.log(response);
this.getListRoom() this.getListRoom()
alert("ลบข้อมูลห้องสำเร็จ") alert("ลบข้อมูลห้องสำเร็จ")
...@@ -73,13 +81,13 @@ export class RoomService { ...@@ -73,13 +81,13 @@ export class RoomService {
} }
updateRoom(roomModel: Room) { updateRoom(roomModel: Room) {
this.http.put(this.url + "/" + roomModel.rid, roomModel).subscribe(response => { this.http.put(this.url + "/" + roomModel.rId, roomModel).subscribe(response => {
console.log(response); console.log(response);
alert("อัพเดทข้อมูลห้องสำเร็จ") alert("อัพเดทข้อมูลห้องสำเร็จ")
}) })
} }
roomModel(rid: string) { roomModel(rId: string) {
} }
......
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