Commit 1ef47521 by Your Name

update typeroom eqment

parent 837b6be0
export class Type {
typeId: number;
typeName : String;
constructor(init?: Type){
Object.assign(this, init);
this.typeId = 0;
this.typeName = '';
}
}
export class TypeEq {
type_eqId: number;
type_eqName : String;
constructor(init?: TypeEq){
Object.assign(this, init);
this.type_eqId = 0;
this.type_eqName = '';
}
}
export class TypeRoom {
type_roomId: number;
type_roomName : String;
constructor(init?: TypeRoom){
Object.assign(this, init);
this.type_roomId = 0;
this.type_roomName = '';
}
}
...@@ -22,7 +22,8 @@ ...@@ -22,7 +22,8 @@
<button class="btn btn-lg btn-outline-primary" <button class="btn btn-lg btn-outline-primary"
(click)="openRoomDetail(contentroom)">เพิ่มรายการ</button> (click)="openRoomDetail(contentroom)">เพิ่มรายการ</button>
<button class="btn btn-lg btn-outline-primary" (click)="openType(contenttype)">เพิ่มประเภท</button> <button class="btn btn-lg btn-outline-primary"
(click)="openTypeRoom(contenttyperoom)">เพิ่มประเภท</button>
<div class="row"> <div class="row">
<div class="col-sm-3" <div class="col-sm-3"
...@@ -30,12 +31,15 @@ ...@@ -30,12 +31,15 @@
<div class="card" style=" <div class="card" style="
padding: 10px;"> padding: 10px;">
<div class="card-body"> <div class="card-body">
<img style="object-fit: cover;" [src]="item.rPic" class="nav justify-content-center" width="150px" height="150px" <img style="object-fit: cover;" [src]="item.rPic"
class="nav justify-content-center" width="150px" height="150px"
alt="..."> alt="...">
<br> <br>
<p class="text-left">ชื่อ : {{item.rName}}</p> <p class="text-left">ชื่อ : {{item.rName}}</p>
<p class="text-left">รายละเอียด : {{item.rDesc}}</p> <p class="text-left">รายละเอียด : {{item.rDesc}}</p>
<p class="text-left">หมวดหมู่ : <td *ngIf="item.rType==1">ห้อง</td><td *ngIf="item.rType==2">รถ</td></p> <p class="text-left">หมวดหมู่ : <td *ngIf="item.rType==1">ห้อง</td>
<td *ngIf="item.rType==2">รถ</td>
</p>
</div> </div>
<div class="text-center"> <div class="text-center">
...@@ -79,8 +83,9 @@ ...@@ -79,8 +83,9 @@
<div class="card-body"> <div class="card-body">
<button class="btn btn-lg btn-outline-primary" <button class="btn btn-lg btn-outline-primary"
(click)="openItemDetail(contentequirment)">เพิ่มรายการ</button> (click)="openItemDetail(contentequirment)">เพิ่มรายการ</button>
<button class="btn btn-lg btn-outline-primary" (click)="openType(contenttype)">เพิ่มประเภท</button> <button class="btn btn-lg btn-outline-primary"
(click)="openTypeEq(contenttypeeqment)">เพิ่มประเภท</button>
<div class="row"> <div class="row">
<div class="col-sm-3" <div class="col-sm-3"
...@@ -88,12 +93,15 @@ ...@@ -88,12 +93,15 @@
<div class="card" style=" <div class="card" style="
padding: 10px;"> padding: 10px;">
<div class="card-body"> <div class="card-body">
<img style="object-fit: cover;" [src]="item.eqPic" class="nav justify-content-center" width="150px" height="150px" <img style="object-fit: cover;" [src]="item.eqPic"
class="nav justify-content-center" width="150px" height="150px"
alt="..."> alt="...">
<br> <br>
<p class="text-left">ชื่อ : {{item.eqName}}</p> <p class="text-left">ชื่อ : {{item.eqName}}</p>
<p class="text-left">รายละเอียด : {{item.eqDesc}}</p> <p class="text-left">รายละเอียด : {{item.eqDesc}}</p>
<p class="text-left">หมวดหมู่ : <td *ngIf="item.eqType==4">IT</td><td *ngIf="item.eqType==5">Company</td></p> <p class="text-left">หมวดหมู่ : <td *ngIf="item.eqType==4">IT</td>
<td *ngIf="item.eqType==5">Company</td>
</p>
</div> </div>
<div class="text-center"> <div class="text-center">
...@@ -156,12 +164,11 @@ ...@@ -156,12 +164,11 @@
<br> <br>
<select class="form-select" aria-label="Default select example" <select class="form-select" aria-label="Default select example"
[(ngModel)]="modelEquirment.eqType" formControlName="eqType"> [(ngModel)]="modelEquirment.eqType" formControlName="eqType">
<option selected>เลือกหมวดหมู่</option> <option *ngFor="let item of listTypeEq" [value]="item.type_eqId">
<option value="4">IT</option> {{item.type_eqName}}</option>
<option value="5">Company</option> <div style="color: red;" *ngIf="myFormEquir.controls.eqType.status=='INVALID'">
กรุณากรอกหมวดหมู่.</div>
</select> </select>
<div style="color: red;" *ngIf="myFormEquir.controls.eqType.status=='INVALID'">
กรุณากรอกหมวดหมู่.</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -218,8 +225,8 @@ ...@@ -218,8 +225,8 @@
<br> <br>
<select class="form-select" aria-label="Default select example" <select class="form-select" aria-label="Default select example"
[(ngModel)]="modelRoom.rType" formControlName="rType"> [(ngModel)]="modelRoom.rType" formControlName="rType">
<option value="1">ห้อง</option> <option *ngFor="let item of listTypeRoom" [value]="item.type_roomId">
<option value="2">รถ</option> {{item.type_roomName}}</option>
</select> </select>
<div style="color: red;" *ngIf="myFormRoom.controls.rType.status=='INVALID'"> <div style="color: red;" *ngIf="myFormRoom.controls.rType.status=='INVALID'">
กรุณากรอกประเภท</div> กรุณากรอกประเภท</div>
...@@ -244,7 +251,7 @@ ...@@ -244,7 +251,7 @@
</div> </div>
<div class=" card-footer"> <div class=" card-footer">
<button class=" btn btn-fill btn-danger" [disabled]="myFormRoom.invalid" type="submit" <button class=" btn btn-fill btn-danger" [disabled]="myFormRoom.invalid" type="submit"
(click)="saveType();modal.dismiss()">Save</button> (click)="saveRoom();modal.dismiss()">Save</button>
<button class=" btn btn-fill btn-danger" type="cancel" <button class=" btn btn-fill btn-danger" type="cancel"
(click)="modal.dismiss('Cross click')">Cancel</button> (click)="modal.dismiss('Cross click')">Cancel</button>
</div> </div>
...@@ -272,8 +279,8 @@ ...@@ -272,8 +279,8 @@
<label>ประเภท</label> <label>ประเภท</label>
<select class="custom-select form-control" aria-label="Default select example" <select class="custom-select form-control" aria-label="Default select example"
formControlName="rType" [(ngModel)]="listRoomModelEdit.rType"> formControlName="rType" [(ngModel)]="listRoomModelEdit.rType">
<option value="1" style="color: black;">ห้อง</option> <option *ngFor="let item of listTypeRoom" [value]="item.type_roomId" style="color: rgb(0, 0, 0);">
<option value="2" style="color: black;">รถ</option> {{item.type_roomName}}</option>
</select> </select>
<div style="color: red;" *ngIf="myFormRoom.controls.rType.status=='INVALID'"> <div style="color: red;" *ngIf="myFormRoom.controls.rType.status=='INVALID'">
กรุณากรอกประเภท.</div> กรุณากรอกประเภท.</div>
...@@ -318,8 +325,8 @@ ...@@ -318,8 +325,8 @@
<label>ประเภทอุปกรณ์</label> <label>ประเภทอุปกรณ์</label>
<select class="custom-select form-control" aria-label="Default select example" <select class="custom-select form-control" aria-label="Default select example"
formControlName="eqType" [(ngModel)]="listEquirmentModelEdit.eqType"> formControlName="eqType" [(ngModel)]="listEquirmentModelEdit.eqType">
<option value="4" style="color: black;">IT</option> <option *ngFor="let item of listTypeEq" [value]="item.type_eqId" style="color: rgb(0, 0, 0);">
<option value="5" style="color: black;">Company</option> {{item.type_eqName}}</option>
</select> </select>
<div style="color: red;" *ngIf="myFormEquir.controls.eqType.status=='INVALID'"> <div style="color: red;" *ngIf="myFormEquir.controls.eqType.status=='INVALID'">
กรุณากรอกประเภท.</div> กรุณากรอกประเภท.</div>
...@@ -377,21 +384,22 @@ ...@@ -377,21 +384,22 @@
</div> </div>
</ng-template> </ng-template>
<ng-template #contenttype let-model> <ng-template #contenttyperoom let-model>
<div class=" col-md-12" style="padding: 0; "> <div class=" col-md-12" style="padding: 0; ">
<div class="card" style="margin: 0; "> <div class="card" style="margin: 0; ">
<div class=" card-header"> <div class=" card-header">
<h5 class=" title">เพิ่มประเภท</h5> <h5 class=" title">เพิ่มประเภท</h5>
</div> </div>
<div class=" card-body"> <div class=" card-body">
<form [formGroup]="myFormType" class="needs-validation"> <form [formGroup]="myFormTypeRoom" class="needs-validation">
<div class=" row"> <div class=" row">
<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" [(ngModel)]="modelType.typeName" <input class=" form-control" placeholder="" type="text"
formControlName="typeName"> [(ngModel)]="modelTypeRoom.type_roomName" formControlName="type_roomName">
<div style="color: red;" *ngIf="myFormType.controls.typeName.status=='INVALID'"> <div style="color: red;"
*ngIf="myFormTypeRoom.controls.type_roomName.status=='INVALID'">
กรุณากรอกชื่อประเภท.</div> กรุณากรอกชื่อประเภท.</div>
</div> </div>
</div> </div>
...@@ -399,10 +407,40 @@ ...@@ -399,10 +407,40 @@
</form> </form>
</div> </div>
<div class=" card-footer"> <div class=" card-footer">
<button class=" btn btn-fill btn-danger" [disabled]="myFormType.invalid" type="submit" <button class=" btn btn-fill btn-danger" [disabled]="myFormTypeRoom.invalid" type="submit"
(click)="saveType()">Save</button> (click)="saveTypeRoom()">บันทึก</button>
<button class=" btn btn-fill btn-danger" type="cancel" <button class=" btn btn-fill btn-danger" type="cancel" (click)="modal.dismiss()">ยกเลิก</button>
(click)="modal.dismiss('Cross click')">Cancel</button> </div>
</div>
</div>
</ng-template>
<ng-template #contenttypeeqment let-model>
<div class=" col-md-12" style="padding: 0; ">
<div class="card" style="margin: 0; ">
<div class=" card-header">
<h5 class=" title">เพิ่มประเภท</h5>
</div>
<div class=" card-body">
<form [formGroup]="myFormTypeEqment" class="needs-validation">
<div class=" row">
<div class=" col-md-12">
<div class=" form-group">
<label> ชื่อประเภท </label>
<input class=" form-control" placeholder="" type="text"
[(ngModel)]="modelTypeEq.type_eqName" formControlName="type_eqName">
<div style="color: red;"
*ngIf="myFormTypeEqment.controls.type_eqName.status=='INVALID'">
กรุณากรอกชื่อประเภท.</div>
</div>
</div>
</div>
</form>
</div>
<div class=" card-footer">
<button class=" btn btn-fill btn-danger" [disabled]="myFormTypeEqment.invalid" type="submit"
(click)="saveTypeEq()">บันทึก</button>
<button class=" btn btn-fill btn-danger" type="cancel" (click)="modal.dismiss()">ยกเลิก</button>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -3,13 +3,15 @@ import { NgbModal, ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap'; ...@@ -3,13 +3,15 @@ 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 { ItemDetail } from 'src/app/models/itemDetail.model';
import { RoomDetail } from 'src/app/models/RoomDetail.model'; import { RoomDetail } from 'src/app/models/RoomDetail.model';
import { Type } from 'src/app/models/type.model'; import { TypeRoom } from 'src/app/models/typeroom.model';
import { MyRoom, Room } from 'src/app/models/rooms.model'; import { MyRoom, 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'; import { RoomDetailService } from 'src/app/service/room-detail.service';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { TypeService } from 'src/app/service/type.service'; import { TypeRoomService } from 'src/app/service/typeroom.service';
import { TypeEqService } from 'src/app/service/typeeq.service';
import { TypeEq } from 'src/app/models/typeeq.model';
@Component({ @Component({
selector: 'app-admin-equirment', selector: 'app-admin-equirment',
...@@ -44,7 +46,8 @@ export class AdminEquirmentComponent implements OnInit { ...@@ -44,7 +46,8 @@ export class AdminEquirmentComponent implements OnInit {
modelRoom: Room modelRoom: Room
modelItemDetail = new ItemDetail(); modelItemDetail = new ItemDetail();
modelRoomDetail = new RoomDetail(); modelRoomDetail = new RoomDetail();
modelType = new Type(); modelTypeRoom = new TypeRoom();
modelTypeEq = new TypeEq();
RoomForm = new FormGroup({ RoomForm = new FormGroup({
rId: new FormControl(''), rId: new FormControl(''),
...@@ -57,13 +60,23 @@ export class AdminEquirmentComponent implements OnInit { ...@@ -57,13 +60,23 @@ export class AdminEquirmentComponent implements OnInit {
myFormRoom: FormGroup; myFormRoom: FormGroup;
myFormEquir: FormGroup; myFormEquir: FormGroup;
myFormType: FormGroup; myFormTypeRoom: FormGroup;
myFormTypeEqment: FormGroup;
listTypeRoom : TypeRoom[] ;
listTypeEq: TypeEq[] ;
constructor(private modalService: NgbModal, private equirmentService: EquirmentService, private roomService: RoomService, private RoomDetailService: RoomDetailService constructor(private modalService: NgbModal, private equirmentService: EquirmentService, private roomService: RoomService, private RoomDetailService: RoomDetailService
, private fb: FormBuilder,private typeService: TypeService) { , private fb: FormBuilder,private typeroomService: TypeRoomService, private typeeqService: TypeEqService) {
} }
ngOnInit() { ngOnInit() {
this.typeroomService.getListTypeRoom().subscribe( result => {
this.listTypeRoom = result;
});
this.typeeqService.getListTypeEq().subscribe( result => {
this.listTypeEq = result;
});
this.equirmentService.getListEquirment().subscribe( result => { this.equirmentService.getListEquirment().subscribe( result => {
this.listEquirmentModel = result; this.listEquirmentModel = result;
}); });
...@@ -102,8 +115,11 @@ export class AdminEquirmentComponent implements OnInit { ...@@ -102,8 +115,11 @@ export class AdminEquirmentComponent implements OnInit {
remark : new FormControl(''), remark : new FormControl(''),
}) })
this.myFormType = new FormGroup({ this.myFormTypeRoom = new FormGroup({
typeName : new FormControl('',[Validators.required]), type_roomName : new FormControl('',[Validators.required]),
})
this.myFormTypeEqment = new FormGroup({
type_eqName : new FormControl('',[Validators.required]),
}) })
} }
...@@ -236,13 +252,26 @@ export class AdminEquirmentComponent implements OnInit { ...@@ -236,13 +252,26 @@ export class AdminEquirmentComponent implements OnInit {
}); });
} }
openType(contenttype) { openTypeRoom(contenttyperoom) {
this.modelType = new Type (); this.modelTypeRoom = new TypeRoom ();
this.myFormType = new FormGroup({ this.myFormTypeRoom = new FormGroup({
typeId : new FormControl(this.modelType.typeId,[Validators.required]), type_roomId : new FormControl(this.modelTypeRoom.type_roomId,[Validators.required]),
typeName : new FormControl(this.modelType.typeName,[Validators.required]), type_roomName : new FormControl(this.modelTypeRoom.type_roomName,[Validators.required]),
}) })
this.modalService.open(contenttype, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => { this.modalService.open(contenttyperoom, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
this.closeResult = `Closed with: ${result}`;
}, (reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
});
}
openTypeEq(contenttypeeqment) {
this.modelTypeRoom = new TypeRoom ();
this.myFormTypeEqment = new FormGroup({
type_eqId : new FormControl(this.modelTypeEq.type_eqId,[Validators.required]),
type_eqName : new FormControl(this.modelTypeEq.type_eqName,[Validators.required]),
})
this.modalService.open(contenttypeeqment, { 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)}`;
...@@ -285,8 +314,14 @@ export class AdminEquirmentComponent implements OnInit { ...@@ -285,8 +314,14 @@ export class AdminEquirmentComponent implements OnInit {
} }
saveType(){ saveTypeRoom(){
this.typeService.addType(this.modelType); this.typeroomService.addTypeRoom(this.modelTypeRoom);
this.modalService.dismissAll();
this.ngOnInit();
}
saveTypeEq(){
this.typeeqService.addTypeEq(this.modelTypeEq);
this.modalService.dismissAll(); this.modalService.dismissAll();
this.ngOnInit(); this.ngOnInit();
} }
......
...@@ -412,14 +412,14 @@ ...@@ -412,14 +412,14 @@
<div class="col-sm-12 mb-1"> <div class="col-sm-12 mb-1">
<label for="exampleFormControlSelect1">ชื่ออุปกรณ์</label> <label for="exampleFormControlSelect1">ชื่ออุปกรณ์</label>
<input readonly class="form-control" type="text" <input readonly class="form-control" type="text"
[(ngModel)]="modelItemDetail.equirment.eqName" formControlName="eqName"> [(ngModel)]="modelItemDetail.equirments.eqName" formControlName="eqName">
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-sm-12 mb-1"> <div class="col-sm-12 mb-1">
<label for="exampleFormControlSelect1">รายละเอียดอุปกรณ์</label> <label for="exampleFormControlSelect1">รายละเอียดอุปกรณ์</label>
<input readonly class="form-control" type="text" <input readonly class="form-control" type="text"
[(ngModel)]="modelItemDetail.equirment.eqDesc" formControlName="eqDesc"> [(ngModel)]="modelItemDetail.equirments.eqDesc" formControlName="eqDesc">
</div> </div>
</div> </div>
<div class="row"> <div class="row">
......
...@@ -3,7 +3,7 @@ import { HttpClient, HttpHeaders } from '@angular/common/http'; ...@@ -3,7 +3,7 @@ import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Equirment, SearchEquirmentModel } from '../models/equirment.model'; import { Equirment, SearchEquirmentModel } from '../models/equirment.model';
import { ItemDetail } from '../models/itemDetail.model'; import { ItemDetail } from '../models/itemDetail.model';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { Type } from '../models/type.model'; import { TypeEq } from '../models/typeeq.model';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class EquirmentService { export class EquirmentService {
...@@ -20,8 +20,8 @@ export class EquirmentService { ...@@ -20,8 +20,8 @@ export class EquirmentService {
}) })
} }
addType(model : Type) { addTypeeq(model : TypeEq) {
this.http.post(this.url + "/type/", model).subscribe(response => { this.http.post(this.url + "/typeeq/", model).subscribe(response => {
console.log(response); console.log(response);
}) })
} }
......
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { Type } from '../models/type.model'; import { TypeEq } from '../models/typeeq.model';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class TypeService { export class TypeEqService {
// addType(modelType: Function) { // addType(modelType: Function) {
// throw new Error('Method not implemented.'); // throw new Error('Method not implemented.');
// } // }
constructor(private http: HttpClient) { } constructor(private http: HttpClient) { }
url: string = "http://0eb9-110-169-220-190.ngrok.io"; url: string = "http://0eb9-110-169-220-190.ngrok.io";
listType: Type[] = [] listType: TypeEq[] = []
addType(model: Type) { addTypeEq(model: TypeEq) {
console.log("type", model) console.log("type", model)
this.http.post(this.url + "/type/", model).subscribe(response => { this.http.post(this.url + "/typeeq/", model).subscribe(response => {
console.log(response); console.log(response);
}) })
} }
getListType(): Observable<Type[]> { getListTypeEq(): Observable<TypeEq[]> {
return this.http.get<Type[]>(this.url + "/Type/lists"); return this.http.get<TypeEq[]>(this.url + "/typeeq/lists");
} }
} }
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { TypeRoom } from '../models/typeroom.model';
@Injectable({ providedIn: 'root' })
export class TypeRoomService {
// addType(modelType: Function) {
// throw new Error('Method not implemented.');
// }
constructor(private http: HttpClient) { }
url: string = "http://0eb9-110-169-220-190.ngrok.io";
listType: TypeRoom[] = []
addTypeRoom(model: TypeRoom) {
console.log("type", model)
this.http.post(this.url + "/typeroom/", model).subscribe(response => {
console.log(response);
})
}
getListTypeRoom(): Observable<TypeRoom[]> {
return this.http.get<TypeRoom[]>(this.url + "/typeroom/lists");
}
}
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