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 @@
<button class="btn btn-lg btn-outline-primary"
(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="col-sm-3"
......@@ -30,12 +31,15 @@
<div class="card" style="
padding: 10px;">
<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="...">
<br>
<p class="text-left">ชื่อ : {{item.rName}}</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 class="text-center">
......@@ -79,8 +83,9 @@
<div class="card-body">
<button class="btn btn-lg btn-outline-primary"
(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="col-sm-3"
......@@ -88,12 +93,15 @@
<div class="card" style="
padding: 10px;">
<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="...">
<br>
<p class="text-left">ชื่อ : {{item.eqName}}</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 class="text-center">
......@@ -156,12 +164,11 @@
<br>
<select class="form-select" aria-label="Default select example"
[(ngModel)]="modelEquirment.eqType" formControlName="eqType">
<option selected>เลือกหมวดหมู่</option>
<option value="4">IT</option>
<option value="5">Company</option>
<option *ngFor="let item of listTypeEq" [value]="item.type_eqId">
{{item.type_eqName}}</option>
<div style="color: red;" *ngIf="myFormEquir.controls.eqType.status=='INVALID'">
กรุณากรอกหมวดหมู่.</div>
</select>
<div style="color: red;" *ngIf="myFormEquir.controls.eqType.status=='INVALID'">
กรุณากรอกหมวดหมู่.</div>
</div>
</div>
</div>
......@@ -218,8 +225,8 @@
<br>
<select class="form-select" aria-label="Default select example"
[(ngModel)]="modelRoom.rType" formControlName="rType">
<option value="1">ห้อง</option>
<option value="2">รถ</option>
<option *ngFor="let item of listTypeRoom" [value]="item.type_roomId">
{{item.type_roomName}}</option>
</select>
<div style="color: red;" *ngIf="myFormRoom.controls.rType.status=='INVALID'">
กรุณากรอกประเภท</div>
......@@ -244,7 +251,7 @@
</div>
<div class=" card-footer">
<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"
(click)="modal.dismiss('Cross click')">Cancel</button>
</div>
......@@ -272,8 +279,8 @@
<label>ประเภท</label>
<select class="custom-select form-control" aria-label="Default select example"
formControlName="rType" [(ngModel)]="listRoomModelEdit.rType">
<option value="1" style="color: black;">ห้อง</option>
<option value="2" style="color: black;">รถ</option>
<option *ngFor="let item of listTypeRoom" [value]="item.type_roomId" style="color: rgb(0, 0, 0);">
{{item.type_roomName}}</option>
</select>
<div style="color: red;" *ngIf="myFormRoom.controls.rType.status=='INVALID'">
กรุณากรอกประเภท.</div>
......@@ -318,8 +325,8 @@
<label>ประเภทอุปกรณ์</label>
<select class="custom-select form-control" aria-label="Default select example"
formControlName="eqType" [(ngModel)]="listEquirmentModelEdit.eqType">
<option value="4" style="color: black;">IT</option>
<option value="5" style="color: black;">Company</option>
<option *ngFor="let item of listTypeEq" [value]="item.type_eqId" style="color: rgb(0, 0, 0);">
{{item.type_eqName}}</option>
</select>
<div style="color: red;" *ngIf="myFormEquir.controls.eqType.status=='INVALID'">
กรุณากรอกประเภท.</div>
......@@ -377,21 +384,22 @@
</div>
</ng-template>
<ng-template #contenttype let-model>
<ng-template #contenttyperoom 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]="myFormType" class="needs-validation">
<form [formGroup]="myFormTypeRoom" 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)]="modelType.typeName"
formControlName="typeName">
<div style="color: red;" *ngIf="myFormType.controls.typeName.status=='INVALID'">
<input class=" form-control" placeholder="" type="text"
[(ngModel)]="modelTypeRoom.type_roomName" formControlName="type_roomName">
<div style="color: red;"
*ngIf="myFormTypeRoom.controls.type_roomName.status=='INVALID'">
กรุณากรอกชื่อประเภท.</div>
</div>
</div>
......@@ -399,10 +407,40 @@
</form>
</div>
<div class=" card-footer">
<button class=" btn btn-fill btn-danger" [disabled]="myFormType.invalid" type="submit"
(click)="saveType()">Save</button>
<button class=" btn btn-fill btn-danger" type="cancel"
(click)="modal.dismiss('Cross click')">Cancel</button>
<button class=" btn btn-fill btn-danger" [disabled]="myFormTypeRoom.invalid" type="submit"
(click)="saveTypeRoom()">บันทึก</button>
<button class=" btn btn-fill btn-danger" type="cancel" (click)="modal.dismiss()">ยกเลิก</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>
......
......@@ -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