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 = '';
}
}
......@@ -3,13 +3,15 @@ import { NgbModal, ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap';
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 { 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 { EquirmentService } from 'src/app/service/equirment.service';
import { RoomService } from 'src/app/service/room.service';
import { RoomDetailService } from 'src/app/service/room-detail.service';
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({
selector: 'app-admin-equirment',
......@@ -44,7 +46,8 @@ export class AdminEquirmentComponent implements OnInit {
modelRoom: Room
modelItemDetail = new ItemDetail();
modelRoomDetail = new RoomDetail();
modelType = new Type();
modelTypeRoom = new TypeRoom();
modelTypeEq = new TypeEq();
RoomForm = new FormGroup({
rId: new FormControl(''),
......@@ -57,13 +60,23 @@ export class AdminEquirmentComponent implements OnInit {
myFormRoom: 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
, private fb: FormBuilder,private typeService: TypeService) {
, private fb: FormBuilder,private typeroomService: TypeRoomService, private typeeqService: TypeEqService) {
}
ngOnInit() {
this.typeroomService.getListTypeRoom().subscribe( result => {
this.listTypeRoom = result;
});
this.typeeqService.getListTypeEq().subscribe( result => {
this.listTypeEq = result;
});
this.equirmentService.getListEquirment().subscribe( result => {
this.listEquirmentModel = result;
});
......@@ -102,8 +115,11 @@ export class AdminEquirmentComponent implements OnInit {
remark : new FormControl(''),
})
this.myFormType = new FormGroup({
typeName : new FormControl('',[Validators.required]),
this.myFormTypeRoom = new FormGroup({
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 {
});
}
openType(contenttype) {
this.modelType = new Type ();
this.myFormType = new FormGroup({
typeId : new FormControl(this.modelType.typeId,[Validators.required]),
typeName : new FormControl(this.modelType.typeName,[Validators.required]),
openTypeRoom(contenttyperoom) {
this.modelTypeRoom = new TypeRoom ();
this.myFormTypeRoom = new FormGroup({
type_roomId : new FormControl(this.modelTypeRoom.type_roomId,[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}`;
}, (reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
......@@ -285,8 +314,14 @@ export class AdminEquirmentComponent implements OnInit {
}
saveType(){
this.typeService.addType(this.modelType);
saveTypeRoom(){
this.typeroomService.addTypeRoom(this.modelTypeRoom);
this.modalService.dismissAll();
this.ngOnInit();
}
saveTypeEq(){
this.typeeqService.addTypeEq(this.modelTypeEq);
this.modalService.dismissAll();
this.ngOnInit();
}
......
......@@ -412,14 +412,14 @@
<div class="col-sm-12 mb-1">
<label for="exampleFormControlSelect1">ชื่ออุปกรณ์</label>
<input readonly class="form-control" type="text"
[(ngModel)]="modelItemDetail.equirment.eqName" formControlName="eqName">
[(ngModel)]="modelItemDetail.equirments.eqName" formControlName="eqName">
</div>
</div>
<div class="row">
<div class="col-sm-12 mb-1">
<label for="exampleFormControlSelect1">รายละเอียดอุปกรณ์</label>
<input readonly class="form-control" type="text"
[(ngModel)]="modelItemDetail.equirment.eqDesc" formControlName="eqDesc">
[(ngModel)]="modelItemDetail.equirments.eqDesc" formControlName="eqDesc">
</div>
</div>
<div class="row">
......
......@@ -3,7 +3,7 @@ import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Equirment, SearchEquirmentModel } from '../models/equirment.model';
import { ItemDetail } from '../models/itemDetail.model';
import { Observable } from 'rxjs';
import { Type } from '../models/type.model';
import { TypeEq } from '../models/typeeq.model';
@Injectable({ providedIn: 'root' })
export class EquirmentService {
......@@ -20,8 +20,8 @@ export class EquirmentService {
})
}
addType(model : Type) {
this.http.post(this.url + "/type/", model).subscribe(response => {
addTypeeq(model : TypeEq) {
this.http.post(this.url + "/typeeq/", model).subscribe(response => {
console.log(response);
})
}
......
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { Type } from '../models/type.model';
import { TypeEq } from '../models/typeeq.model';
@Injectable({ providedIn: 'root' })
export class TypeService {
export class TypeEqService {
// addType(modelType: Function) {
// throw new Error('Method not implemented.');
// }
constructor(private http: HttpClient) { }
url: string = "http://0eb9-110-169-220-190.ngrok.io";
listType: Type[] = []
listType: TypeEq[] = []
addType(model: Type) {
addTypeEq(model: TypeEq) {
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);
})
}
getListType(): Observable<Type[]> {
return this.http.get<Type[]>(this.url + "/Type/lists");
getListTypeEq(): Observable<TypeEq[]> {
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