Commit 186fb8d6 by DESKTOP-HF0LVOG\myhr

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

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